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.
17 UINTN mErrorLevel
= DEBUG_ERROR
| DEBUG_LOAD
;
19 EFI_DXE_DEVICE_HANDLE_EXTENDED_DATA mStatusCodeData
= {
21 sizeof (EFI_STATUS_CODE_DATA
),
23 EFI_STATUS_CODE_DXE_CORE_GUID
30 Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid,
31 with a handle as additional information.
33 @param Value Describes the class/subclass/operation of the
34 hardware or software entity that the Status Code
36 @param Handle Additional information.
40 CoreReportProgressCodeSpecific (
41 IN EFI_STATUS_CODE_VALUE Value
,
45 mStatusCodeData
.DataHeader
.Size
= sizeof (EFI_DXE_DEVICE_HANDLE_EXTENDED_DATA
) - sizeof (EFI_STATUS_CODE_DATA
);
46 mStatusCodeData
.Handle
= Handle
;
48 if ((gStatusCode
!= NULL
) && (gStatusCode
->ReportStatusCode
!= NULL
) ) {
49 gStatusCode
->ReportStatusCode (
54 (EFI_STATUS_CODE_DATA
*) &mStatusCodeData
61 Report status code of type EFI_PROGRESS_CODE by caller ID gEfiCallerIdGuid.
63 @param Value Describes the class/subclass/operation of the
64 hardware or software entity that the Status Code
69 CoreReportProgressCode (
70 IN EFI_STATUS_CODE_VALUE Value
73 if ((gStatusCode
!= NULL
) && (gStatusCode
->ReportStatusCode
!= NULL
) ) {
74 gStatusCode
->ReportStatusCode (
89 Initialize a basic mutual exclusion lock. Each lock
90 provides mutual exclusion access at it's task priority
91 level. Since there is no-premption (at any TPL) or
92 multiprocessor support, acquiring the lock only consists
93 of raising to the locks TPL.
95 @param Lock The EFI_LOCK structure to initialize
97 @retval EFI_SUCCESS Lock Owned.
98 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.
102 CoreAcquireLockOrFail (
106 ASSERT (Lock
!= NULL
);
107 ASSERT (Lock
->Lock
!= EfiLockUninitialized
);
109 if (Lock
->Lock
== EfiLockAcquired
) {
111 // Lock is already owned, so bail out
113 return EFI_ACCESS_DENIED
;
116 Lock
->OwnerTpl
= CoreRaiseTpl (Lock
->Tpl
);
118 Lock
->Lock
= EfiLockAcquired
;
125 Raising to the task priority level of the mutual exclusion
126 lock, and then acquires ownership of the lock.
128 @param Lock The lock to acquire
138 ASSERT (Lock
!= NULL
);
139 ASSERT (Lock
->Lock
== EfiLockReleased
);
141 Lock
->OwnerTpl
= CoreRaiseTpl (Lock
->Tpl
);
142 Lock
->Lock
= EfiLockAcquired
;
148 Releases ownership of the mutual exclusion lock, and
149 restores the previous task priority level.
151 @param Lock The lock to release
163 ASSERT (Lock
!= NULL
);
164 ASSERT (Lock
->Lock
== EfiLockAcquired
);
166 Tpl
= Lock
->OwnerTpl
;
168 Lock
->Lock
= EfiLockReleased
;
170 CoreRestoreTpl (Tpl
);
175 Create a protocol notification event and return it.
177 @param ProtocolGuid Protocol to register notification event on.
178 @param NotifyTpl Maximum TPL to signal the NotifyFunction.
179 @param NotifyFunction EFI notification routine.
180 @param NotifyContext Context passed into Event when it is created.
181 @param Registration Registration key returned from
182 RegisterProtocolNotify().
183 @param SignalFlag Boolean value to decide whether kick the event after
186 @return The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
187 is added to the system.
191 CoreCreateProtocolNotifyEvent (
192 IN EFI_GUID
*ProtocolGuid
,
193 IN EFI_TPL NotifyTpl
,
194 IN EFI_EVENT_NOTIFY NotifyFunction
,
195 IN VOID
*NotifyContext
,
196 OUT VOID
**Registration
,
197 IN BOOLEAN SignalFlag
206 Status
= CoreCreateEvent (
213 ASSERT_EFI_ERROR (Status
);
216 // Register for protocol notifactions on this event
218 Status
= CoreRegisterProtocolNotify (
223 ASSERT_EFI_ERROR (Status
);
227 // Kick the event so we will perform an initial pass of
228 // current installed drivers
230 CoreSignalEvent (Event
);