]>
Commit | Line | Data |
---|---|---|
162ed594 | 1 | /** @file\r |
797a9d67 | 2 | DXE Core library services.\r |
23c98c94 | 3 | \r |
4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r | |
28a00297 | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
797a9d67 | 13 | **/\r |
28a00297 | 14 | \r |
9c4ac31c | 15 | #include "DxeMain.h"\r |
28a00297 | 16 | \r |
28a00297 | 17 | //\r |
18 | // Lock Stuff\r | |
19 | //\r | |
162ed594 | 20 | /**\r |
28a00297 | 21 | Initialize a basic mutual exclusion lock. Each lock\r |
22 | provides mutual exclusion access at it's task priority\r | |
23 | level. Since there is no-premption (at any TPL) or\r | |
24 | multiprocessor support, acquiring the lock only consists\r | |
25 | of raising to the locks TPL.\r | |
26 | \r | |
022c6d45 | 27 | @param Lock The EFI_LOCK structure to initialize\r |
28a00297 | 28 | \r |
022c6d45 | 29 | @retval EFI_SUCCESS Lock Owned.\r |
162ed594 | 30 | @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.\r |
28a00297 | 31 | \r |
162ed594 | 32 | **/\r |
33 | EFI_STATUS\r | |
34 | CoreAcquireLockOrFail (\r | |
35 | IN EFI_LOCK *Lock\r | |
36 | )\r | |
28a00297 | 37 | {\r |
38 | ASSERT (Lock != NULL);\r | |
39 | ASSERT (Lock->Lock != EfiLockUninitialized);\r | |
40 | \r | |
41 | if (Lock->Lock == EfiLockAcquired) {\r | |
42 | //\r | |
43 | // Lock is already owned, so bail out\r | |
44 | //\r | |
45 | return EFI_ACCESS_DENIED;\r | |
46 | }\r | |
47 | \r | |
48 | Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl);\r | |
49 | \r | |
50 | Lock->Lock = EfiLockAcquired;\r | |
51 | return EFI_SUCCESS;\r | |
52 | }\r | |
53 | \r | |
54 | \r | |
28a00297 | 55 | \r |
162ed594 | 56 | /**\r |
28a00297 | 57 | Raising to the task priority level of the mutual exclusion\r |
58 | lock, and then acquires ownership of the lock.\r | |
59 | \r | |
022c6d45 | 60 | @param Lock The lock to acquire\r |
28a00297 | 61 | \r |
162ed594 | 62 | @return Lock owned\r |
28a00297 | 63 | \r |
162ed594 | 64 | **/\r |
65 | VOID\r | |
66 | CoreAcquireLock (\r | |
67 | IN EFI_LOCK *Lock\r | |
68 | )\r | |
28a00297 | 69 | {\r |
70 | ASSERT (Lock != NULL);\r | |
71 | ASSERT (Lock->Lock == EfiLockReleased);\r | |
72 | \r | |
73 | Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl);\r | |
74 | Lock->Lock = EfiLockAcquired;\r | |
75 | }\r | |
76 | \r | |
77 | \r | |
28a00297 | 78 | \r |
162ed594 | 79 | /**\r |
80 | Releases ownership of the mutual exclusion lock, and\r | |
81 | restores the previous task priority level.\r | |
28a00297 | 82 | \r |
022c6d45 | 83 | @param Lock The lock to release\r |
28a00297 | 84 | \r |
162ed594 | 85 | @return Lock unowned\r |
28a00297 | 86 | \r |
162ed594 | 87 | **/\r |
88 | VOID\r | |
89 | CoreReleaseLock (\r | |
90 | IN EFI_LOCK *Lock\r | |
91 | )\r | |
28a00297 | 92 | {\r |
93 | EFI_TPL Tpl;\r | |
94 | \r | |
95 | ASSERT (Lock != NULL);\r | |
96 | ASSERT (Lock->Lock == EfiLockAcquired);\r | |
97 | \r | |
98 | Tpl = Lock->OwnerTpl;\r | |
99 | \r | |
100 | Lock->Lock = EfiLockReleased;\r | |
101 | \r | |
102 | CoreRestoreTpl (Tpl);\r | |
103 | }\r | |
104 | \r | |
105 | \r | |
162ed594 | 106 | \r |