2 DXE Core library services.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 Initialize a basic mutual exclusion lock. Each lock
22 provides mutual exclusion access at it's task priority
23 level. Since there is no-premption (at any TPL) or
24 multiprocessor support, acquiring the lock only consists
25 of raising to the locks TPL.
27 @param Lock The EFI_LOCK structure to initialize
29 @retval EFI_SUCCESS Lock Owned.
30 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
34 CoreAcquireLockOrFail (
38 ASSERT (Lock
!= NULL
);
39 ASSERT (Lock
->Lock
!= EfiLockUninitialized
);
41 if (Lock
->Lock
== EfiLockAcquired
) {
43 // Lock is already owned, so bail out
45 return EFI_ACCESS_DENIED
;
48 Lock
->OwnerTpl
= CoreRaiseTpl (Lock
->Tpl
);
50 Lock
->Lock
= EfiLockAcquired
;
57 Raising to the task priority level of the mutual exclusion
58 lock, and then acquires ownership of the lock.
60 @param Lock The lock to acquire
70 ASSERT (Lock
!= NULL
);
71 ASSERT (Lock
->Lock
== EfiLockReleased
);
73 Lock
->OwnerTpl
= CoreRaiseTpl (Lock
->Tpl
);
74 Lock
->Lock
= EfiLockAcquired
;
80 Releases ownership of the mutual exclusion lock, and
81 restores the previous task priority level.
83 @param Lock The lock to release
95 ASSERT (Lock
!= NULL
);
96 ASSERT (Lock
->Lock
== EfiLockAcquired
);
100 Lock
->Lock
= EfiLockReleased
;
102 CoreRestoreTpl (Tpl
);
107 Create a protocol notification event and return it.
109 @param ProtocolGuid Protocol to register notification event on.
110 @param NotifyTpl Maximum TPL to signal the NotifyFunction.
111 @param NotifyFunction EFI notification routine.
112 @param NotifyContext Context passed into Event when it is created.
113 @param Registration Registration key returned from
114 RegisterProtocolNotify().
115 @param SignalFlag Boolean value to decide whether kick the event after
118 @return The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
119 is added to the system.
123 CoreCreateProtocolNotifyEvent (
124 IN EFI_GUID
*ProtocolGuid
,
125 IN EFI_TPL NotifyTpl
,
126 IN EFI_EVENT_NOTIFY NotifyFunction
,
127 IN VOID
*NotifyContext
,
128 OUT VOID
**Registration
,
129 IN BOOLEAN SignalFlag
138 Status
= CoreCreateEvent (
145 ASSERT_EFI_ERROR (Status
);
148 // Register for protocol notifactions on this event
150 Status
= CoreRegisterProtocolNotify (
155 ASSERT_EFI_ERROR (Status
);
159 // Kick the event so we will perform an initial pass of
160 // current installed drivers
162 CoreSignalEvent (Event
);