]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/Lock.c
d815d0c206da1940379f4f83439313c9aa95c529
3 Copyright (c) 2005, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Support for locking lib services.
23 #include "EfiDriverLib.h"
33 IN OUT EFI_LOCK
*Lock
,
40 Initialize a basic mutual exclusion lock. Each lock
41 provides mutual exclusion access at it's task priority
42 level. Since there is no-premption (at any TPL) or
43 multiprocessor support, acquiring the lock only consists
44 of raising to the locks TPL.
46 Note on a check build ASSERT()s are used to ensure proper
51 Lock - The EFI_LOCK structure to initialize
53 Priority - The task priority level of the lock
58 An initialized Efi Lock structure.
68 EfiAcquireLockOrFail (
75 Initialize a basic mutual exclusion lock. Each lock
76 provides mutual exclusion access at it's task priority
77 level. Since there is no-premption (at any TPL) or
78 multiprocessor support, acquiring the lock only consists
79 of raising to the locks TPL.
83 Lock - The EFI_LOCK structure to initialize
87 EFI_SUCCESS - Lock Owned.
88 EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
92 if (Lock
->Lock
!= 0) {
94 // Lock is already owned, so bail out
96 return EFI_ACCESS_DENIED
;
99 if (!EfiAtRuntime ()) {
101 // The check is just debug code for core inplementation. It must
102 // always be true in a driver
104 Lock
->OwnerTpl
= gBS
->RaiseTPL (Lock
->Tpl
);
119 Raising to the task priority level of the mutual exclusion
120 lock, and then acquires ownership of the lock.
124 Lock - The lock to acquire
134 Status
= EfiAcquireLockOrFail (Lock
);
137 // Lock was already locked.
139 ASSERT_EFI_ERROR (Status
);
150 Releases ownership of the mutual exclusion lock, and
151 restores the previous task priority level.
155 Lock - The lock to release
165 Tpl
= Lock
->OwnerTpl
;
167 ASSERT (Lock
->Lock
== 1);
170 if (!EfiAtRuntime ()) {
172 // The check is just debug code for core inplementation. It must
173 // always be true in a driver
175 gBS
->RestoreTPL (Tpl
);