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)
47 { &gEfiCapsuleArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
49 { &gEfiMonotonicCounterArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
50 { &gEfiResetArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
51 // { &gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode, NULL, NULL, FALSE },
52 { &gEfiRealTimeClockArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
53 { NULL
, (VOID
**)NULL
, NULL
, NULL
, FALSE
}
58 CoreAllEfiServicesAvailable (
64 Return TRUE if all AP services are availible.
70 EFI_SUCCESS - All AP services are available
71 EFI_NOT_FOUND - At least one AP service is not available
75 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
77 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
78 if (!Entry
->Present
) {
89 GenericArchProtocolNotify (
96 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
97 This notify function is registered for every architectural protocol. This handler
98 updates mArchProtocol[] array entry with protocol instance data and sets it's
99 present flag to TRUE. If any constructor is required it is executed. The EFI
100 System Table headers are updated.
104 Event - The Event that is being processed, not used.
106 Context - Event Context, not used.
115 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
120 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
122 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
123 if (EFI_ERROR (Status
)) {
128 Entry
->Present
= TRUE
;
131 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
132 // if one exists in the DXE core for this Architectural Protocol
134 if (Entry
->Protocol
!= NULL
) {
135 *(Entry
->Protocol
) = Protocol
;
138 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
140 // Register the Core timer tick handler with the Timer AP
142 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
145 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
147 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
149 CoreUpdateDebugTableCrc32 ();
154 // It's over kill to do them all every time, but it saves a lot of code.
157 CalculateEfiHdrCrc (&gRT
->Hdr
);
158 CalculateEfiHdrCrc (&gBS
->Hdr
);
159 CalculateEfiHdrCrc (&gST
->Hdr
);
160 CalculateEfiHdrCrc (&gDS
->Hdr
);
167 CoreNotifyOnArchProtocolInstallation (
173 Creates an event that is fired everytime a Protocol of a specific type is installed
184 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
186 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
191 Status
= CoreCreateEvent (
192 EFI_EVENT_NOTIFY_SIGNAL
,
194 GenericArchProtocolNotify
,
198 ASSERT_EFI_ERROR(Status
);
201 // Register for protocol notifactions on this event
203 Status
= CoreRegisterProtocolNotify (
208 ASSERT_EFI_ERROR(Status
);
214 // Following is needed to display missing architectural protocols in debug builds
217 EFI_GUID
*ProtocolGuid
;
219 } GUID_TO_STRING_PROTOCOL_ENTRY
;
221 static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
222 { &gEfiSecurityArchProtocolGuid
, (CHAR16
*)L
"Security" },
223 { &gEfiCpuArchProtocolGuid
, (CHAR16
*)L
"CPU" },
224 { &gEfiMetronomeArchProtocolGuid
, (CHAR16
*)L
"Metronome" },
225 { &gEfiTimerArchProtocolGuid
, (CHAR16
*)L
"Timer" },
226 { &gEfiBdsArchProtocolGuid
, (CHAR16
*)L
"Bds" },
227 { &gEfiWatchdogTimerArchProtocolGuid
, (CHAR16
*)L
"Watchdog Timer" },
228 { &gEfiRuntimeArchProtocolGuid
, (CHAR16
*)L
"Runtime" },
229 { &gEfiVariableArchProtocolGuid
, (CHAR16
*)L
"Variable" },
230 { &gEfiVariableWriteArchProtocolGuid
, (CHAR16
*)L
"Variable Write" },
231 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
232 { &gEfiCapsuleArchProtocolGuid
, (CHAR16
*)L
"Capsule" },
234 { &gEfiMonotonicCounterArchProtocolGuid
, (CHAR16
*)L
"Monotonic Counter" },
235 { &gEfiResetArchProtocolGuid
, (CHAR16
*)L
"Reset" },
236 // { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },
237 { &gEfiRealTimeClockArchProtocolGuid
, (CHAR16
*)L
"Real Time Clock" }
241 CoreDisplayMissingArchProtocols (
247 Displays Architectural protocols that were not loaded and are required for DXE core to function
248 Only used in Debug Builds
258 const GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
259 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
261 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
262 if (!Entry
->Present
) {
263 MissingEntry
= MissingProtocols
;
264 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
265 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
266 DEBUG ((EFI_D_ERROR
, "\n%s Arch Protocol not present!!\n", MissingEntry
->GuidString
));