Rev 2726 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2726 | vana | 1 | /*++ |
2 | |||
3 | Copyright (c) 1998 Intel Corporation |
||
4 | |||
5 | Module Name: |
||
6 | |||
7 | lock.c |
||
8 | |||
9 | Abstract: |
||
10 | |||
11 | Implements FLOCK |
||
12 | |||
13 | |||
14 | |||
15 | Revision History |
||
16 | |||
17 | --*/ |
||
18 | |||
19 | |||
20 | #include "lib.h" |
||
21 | |||
22 | |||
23 | |||
24 | #pragma RUNTIME_CODE(RtAcquireLock) |
||
25 | VOID |
||
26 | RtAcquireLock ( |
||
27 | IN FLOCK *Lock |
||
28 | ) |
||
29 | /*++ |
||
30 | |||
31 | Routine Description: |
||
32 | |||
33 | Raising to the task priority level of the mutual exclusion |
||
34 | lock, and then acquires ownership of the lock. |
||
35 | |||
36 | Arguments: |
||
37 | |||
38 | Lock - The lock to acquire |
||
39 | |||
40 | Returns: |
||
41 | |||
42 | Lock owned |
||
43 | |||
44 | --*/ |
||
45 | { |
||
46 | if (BS) { |
||
47 | if (BS->RaiseTPL != NULL) { |
||
48 | Lock->OwnerTpl = BS->RaiseTPL(Lock->Tpl); |
||
49 | } |
||
50 | } |
||
51 | else { |
||
52 | if (LibRuntimeRaiseTPL != NULL) { |
||
53 | Lock->OwnerTpl = LibRuntimeRaiseTPL(Lock->Tpl); |
||
54 | } |
||
55 | } |
||
56 | Lock->Lock += 1; |
||
57 | ASSERT (Lock->Lock == 1); |
||
58 | } |
||
59 | |||
60 | |||
61 | #pragma RUNTIME_CODE(RtAcquireLock) |
||
62 | VOID |
||
63 | RtReleaseLock ( |
||
64 | IN FLOCK *Lock |
||
65 | ) |
||
66 | /*++ |
||
67 | |||
68 | Routine Description: |
||
69 | |||
70 | Releases ownership of the mutual exclusion lock, and |
||
71 | restores the previous task priority level. |
||
72 | |||
73 | Arguments: |
||
74 | |||
75 | Lock - The lock to release |
||
76 | |||
77 | Returns: |
||
78 | |||
79 | Lock unowned |
||
80 | |||
81 | --*/ |
||
82 | { |
||
83 | EFI_TPL Tpl; |
||
84 | |||
85 | Tpl = Lock->OwnerTpl; |
||
86 | ASSERT(Lock->Lock == 1); |
||
87 | Lock->Lock -= 1; |
||
88 | if (BS) { |
||
89 | if (BS->RestoreTPL != NULL) { |
||
90 | BS->RestoreTPL (Tpl); |
||
91 | } |
||
92 | } |
||
93 | else { |
||
94 | if (LibRuntimeRestoreTPL != NULL) { |
||
95 | LibRuntimeRestoreTPL(Tpl); |
||
96 | } |
||
97 | } |
||
98 | } |