3 Copyright (c) 2006, 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 This file deals with Architecture Protocol (AP) registration in
19 the Dxe Core. The mArchProtocols[] array represents a list of
20 events that represent the Architectural Protocols.
28 // DXE Core Global Variables for all of the Architectural Protocols.
29 // If a protocol is installed mArchProtocols[].Present will be TRUE.
31 // CoreNotifyOnArchProtocolInstallation () fills in mArchProtocols[].Event
32 // and mArchProtocols[].Registration as it creates events for every array
36 ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols
[] = {
37 { &gEfiSecurityArchProtocolGuid
, (VOID
**)&gSecurity
, NULL
, NULL
, FALSE
},
38 { &gEfiCpuArchProtocolGuid
, (VOID
**)&gCpu
, NULL
, NULL
, FALSE
},
39 { &gEfiMetronomeArchProtocolGuid
, (VOID
**)&gMetronome
, NULL
, NULL
, FALSE
},
40 { &gEfiTimerArchProtocolGuid
, (VOID
**)&gTimer
, NULL
, NULL
, FALSE
},
41 { &gEfiBdsArchProtocolGuid
, (VOID
**)&gBds
, NULL
, NULL
, FALSE
},
42 { &gEfiWatchdogTimerArchProtocolGuid
, (VOID
**)&gWatchdogTimer
, NULL
, NULL
, FALSE
},
43 { &gEfiRuntimeArchProtocolGuid
, (VOID
**)&gRuntime
, NULL
, NULL
, FALSE
},
44 { &gEfiVariableArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
45 { &gEfiVariableWriteArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
46 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
49 // UEFI 2.0 added support for Capsule services. DXE CIS ??? Added support for this AP
51 { &gEfiCapsuleArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
54 { &gEfiMonotonicCounterArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
55 { &gEfiResetArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
56 #if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
58 // The ReportStatusCode Runtime service is in conflict with the UEFI 2.0 specificaiton
59 // Thus gEfiStatusCodeRuntimeProtocolGuid becomes a normal protocol in UEFI 2.0 systems
60 // It is only included if the EFI 1.10 with Tiano extensions is enabled for backward
63 { &gEfiStatusCodeRuntimeProtocolGuid
, (VOID
**)&gStatusCode
, NULL
, NULL
, FALSE
},
65 { &gEfiRealTimeClockArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
66 { NULL
, (VOID
**)NULL
, NULL
, NULL
, FALSE
}
71 CoreAllEfiServicesAvailable (
77 Return TRUE if all AP services are availible.
83 EFI_SUCCESS - All AP services are available
84 EFI_NOT_FOUND - At least one AP service is not available
88 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
90 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
91 if (!Entry
->Present
) {
102 GenericArchProtocolNotify (
109 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
110 This notify function is registered for every architectural protocol. This handler
111 updates mArchProtocol[] array entry with protocol instance data and sets it's
112 present flag to TRUE. If any constructor is required it is executed. The EFI
113 System Table headers are updated.
117 Event - The Event that is being processed, not used.
119 Context - Event Context, not used.
128 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
133 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
135 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
136 if (EFI_ERROR (Status
)) {
141 Entry
->Present
= TRUE
;
144 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
145 // if one exists in the DXE core for this Architectural Protocol
147 if (Entry
->Protocol
!= NULL
) {
148 *(Entry
->Protocol
) = Protocol
;
151 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
153 // Register the Core timer tick handler with the Timer AP
155 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
158 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
160 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
162 CoreUpdateDebugTableCrc32 ();
167 // It's over kill to do them all every time, but it saves a lot of code.
170 CalculateEfiHdrCrc (&gRT
->Hdr
);
171 CalculateEfiHdrCrc (&gBS
->Hdr
);
172 CalculateEfiHdrCrc (&gST
->Hdr
);
173 CalculateEfiHdrCrc (&gDS
->Hdr
);
180 CoreNotifyOnArchProtocolInstallation (
186 Creates an event that is fired everytime a Protocol of a specific type is installed
197 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
199 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
204 Status
= CoreCreateEvent (
205 EFI_EVENT_NOTIFY_SIGNAL
,
207 GenericArchProtocolNotify
,
211 ASSERT_EFI_ERROR(Status
);
214 // Register for protocol notifactions on this event
216 Status
= CoreRegisterProtocolNotify (
221 ASSERT_EFI_ERROR(Status
);
227 // Following is needed to display missing architectural protocols in debug builds
230 EFI_GUID
*ProtocolGuid
;
232 } GUID_TO_STRING_PROTOCOL_ENTRY
;
234 static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
235 { &gEfiSecurityArchProtocolGuid
, (CHAR16
*)L
"Security" },
236 { &gEfiCpuArchProtocolGuid
, (CHAR16
*)L
"CPU" },
237 { &gEfiMetronomeArchProtocolGuid
, (CHAR16
*)L
"Metronome" },
238 { &gEfiTimerArchProtocolGuid
, (CHAR16
*)L
"Timer" },
239 { &gEfiBdsArchProtocolGuid
, (CHAR16
*)L
"Bds" },
240 { &gEfiWatchdogTimerArchProtocolGuid
, (CHAR16
*)L
"Watchdog Timer" },
241 { &gEfiRuntimeArchProtocolGuid
, (CHAR16
*)L
"Runtime" },
242 { &gEfiVariableArchProtocolGuid
, (CHAR16
*)L
"Variable" },
243 { &gEfiVariableWriteArchProtocolGuid
, (CHAR16
*)L
"Variable Write" },
244 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
245 { &gEfiCapsuleArchProtocolGuid
, (CHAR16
*)L
"Capsule" },
247 { &gEfiMonotonicCounterArchProtocolGuid
, (CHAR16
*)L
"Monotonic Counter" },
248 { &gEfiResetArchProtocolGuid
, (CHAR16
*)L
"Reset" },
249 // { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },
250 { &gEfiRealTimeClockArchProtocolGuid
, (CHAR16
*)L
"Real Time Clock" }
254 CoreDisplayMissingArchProtocols (
260 Displays Architectural protocols that were not loaded and are required for DXE core to function
261 Only used in Debug Builds
271 const GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
272 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
274 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
275 if (!Entry
->Present
) {
276 MissingEntry
= MissingProtocols
;
277 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
278 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
279 DEBUG ((EFI_D_ERROR
, "\n%s Arch Protocol not present!!\n", MissingEntry
->GuidString
));