3 Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
4 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"
27 IN OUT EFI_LOCK
*Lock
,
34 Initialize a basic mutual exclusion lock. Each lock
35 provides mutual exclusion access at it's task priority
36 level. Since there is no-premption (at any TPL) or
37 multiprocessor support, acquiring the lock only consists
38 of raising to the locks TPL.
40 Note on a check build ASSERT()s are used to ensure proper
45 Lock - The EFI_LOCK structure to initialize
47 Priority - The task priority level of the lock
52 An initialized Efi Lock structure.
62 EfiAcquireLockOrFail (
69 Initialize a basic mutual exclusion lock. Each lock
70 provides mutual exclusion access at it's task priority
71 level. Since there is no-premption (at any TPL) or
72 multiprocessor support, acquiring the lock only consists
73 of raising to the locks TPL.
77 Lock - The EFI_LOCK structure to initialize
81 EFI_SUCCESS - Lock Owned.
82 EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
86 if (Lock
->Lock
!= 0) {
88 // Lock is already owned, so bail out
90 return EFI_ACCESS_DENIED
;
93 Lock
->OwnerTpl
= gBS
->RaiseTPL (Lock
->Tpl
);
107 Raising to the task priority level of the mutual exclusion
108 lock, and then acquires ownership of the lock.
112 Lock - The lock to acquire
122 Status
= EfiAcquireLockOrFail (Lock
);
125 // Lock was already locked.
127 ASSERT_EFI_ERROR (Status
);
138 Releases ownership of the mutual exclusion lock, and
139 restores the previous task priority level.
143 Lock - The lock to release
153 Tpl
= Lock
->OwnerTpl
;
155 ASSERT (Lock
->Lock
== 1);
158 gBS
->RestoreTPL (Tpl
);