]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/Library/Library.c
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Library / Library.c
... / ...
CommitLineData
1/** @file\r
2 DXE Core library services.\r
3\r
4Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "DxeMain.h"\r
16\r
17//\r
18// Lock Stuff\r
19//\r
20/**\r
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
27 @param Lock The EFI_LOCK structure to initialize\r
28\r
29 @retval EFI_SUCCESS Lock Owned.\r
30 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.\r
31\r
32**/\r
33EFI_STATUS\r
34CoreAcquireLockOrFail (\r
35 IN EFI_LOCK *Lock\r
36 )\r
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
55\r
56/**\r
57 Raising to the task priority level of the mutual exclusion\r
58 lock, and then acquires ownership of the lock.\r
59\r
60 @param Lock The lock to acquire\r
61\r
62 @return Lock owned\r
63\r
64**/\r
65VOID\r
66CoreAcquireLock (\r
67 IN EFI_LOCK *Lock\r
68 )\r
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
78\r
79/**\r
80 Releases ownership of the mutual exclusion lock, and\r
81 restores the previous task priority level.\r
82\r
83 @param Lock The lock to release\r
84\r
85 @return Lock unowned\r
86\r
87**/\r
88VOID\r
89CoreReleaseLock (\r
90 IN EFI_LOCK *Lock\r
91 )\r
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
106\r