3 This file deals with Architecture Protocol (AP) registration in
4 the Dxe Core. The mArchProtocols[] array represents a list of
5 events that represent the Architectural Protocols.
7 Copyright (c) 2006 - 2008, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 // DXE Core Global Variables for all of the Architectural Protocols.
23 // If a protocol is installed mArchProtocols[].Present will be TRUE.
25 // CoreNotifyOnArchProtocolInstallation () fills in mArchProtocols[].Event
26 // and mArchProtocols[].Registration as it creates events for every array
30 ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols
[] = {
31 { &gEfiSecurityArchProtocolGuid
, (VOID
**)&gSecurity
, NULL
, NULL
, FALSE
},
32 { &gEfiCpuArchProtocolGuid
, (VOID
**)&gCpu
, NULL
, NULL
, FALSE
},
33 { &gEfiMetronomeArchProtocolGuid
, (VOID
**)&gMetronome
, NULL
, NULL
, FALSE
},
34 { &gEfiTimerArchProtocolGuid
, (VOID
**)&gTimer
, NULL
, NULL
, FALSE
},
35 { &gEfiBdsArchProtocolGuid
, (VOID
**)&gBds
, NULL
, NULL
, FALSE
},
36 { &gEfiWatchdogTimerArchProtocolGuid
, (VOID
**)&gWatchdogTimer
, NULL
, NULL
, FALSE
},
37 { &gEfiRuntimeArchProtocolGuid
, (VOID
**)&gRuntime
, NULL
, NULL
, FALSE
},
38 { &gEfiVariableArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
39 { &gEfiVariableWriteArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
40 { &gEfiCapsuleArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
41 { &gEfiMonotonicCounterArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
42 { &gEfiResetArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
43 { &gEfiRealTimeClockArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
44 { NULL
, (VOID
**)NULL
, NULL
, NULL
, FALSE
}
49 CoreAllEfiServicesAvailable (
55 Return TRUE if all AP services are availible.
61 EFI_SUCCESS - All AP services are available
62 EFI_NOT_FOUND - At least one AP service is not available
66 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
68 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
69 if (!Entry
->Present
) {
80 GenericArchProtocolNotify (
87 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
88 This notify function is registered for every architectural protocol. This handler
89 updates mArchProtocol[] array entry with protocol instance data and sets it's
90 present flag to TRUE. If any constructor is required it is executed. The EFI
91 System Table headers are updated.
95 Event - The Event that is being processed, not used.
97 Context - Event Context, not used.
106 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
110 LIST_ENTRY TempLinkNode
;
113 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
115 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
116 if (EFI_ERROR (Status
)) {
121 Entry
->Present
= TRUE
;
124 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
125 // if one exists in the DXE core for this Architectural Protocol
127 if (Entry
->Protocol
!= NULL
) {
128 *(Entry
->Protocol
) = Protocol
;
131 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
133 // Register the Core timer tick handler with the Timer AP
135 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
138 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
140 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
142 CoreUpdateDebugTableCrc32 ();
145 // Update the Runtime Architectural protocol with the template that the core was
146 // using so there would not need to be a dependency on the Runtime AP
150 // Copy all the registered Image to new gRuntime protocol
152 for (Link
= gRuntimeTemplate
.ImageHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.ImageHead
; Link
= TempLinkNode
.ForwardLink
) {
153 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
154 InsertTailList (&gRuntime
->ImageHead
, Link
);
157 // Copy all the registered Event to new gRuntime protocol
159 for (Link
= gRuntimeTemplate
.EventHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.EventHead
; Link
= TempLinkNode
.ForwardLink
) {
160 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
161 InsertTailList (&gRuntime
->EventHead
, Link
);
165 // Clean up gRuntimeTemplate
167 gRuntimeTemplate
.ImageHead
.ForwardLink
= &gRuntimeTemplate
.ImageHead
;
168 gRuntimeTemplate
.ImageHead
.BackLink
= &gRuntimeTemplate
.ImageHead
;
169 gRuntimeTemplate
.EventHead
.ForwardLink
= &gRuntimeTemplate
.EventHead
;
170 gRuntimeTemplate
.EventHead
.BackLink
= &gRuntimeTemplate
.EventHead
;
175 // It's over kill to do them all every time, but it saves a lot of code.
178 CalculateEfiHdrCrc (&gDxeCoreRT
->Hdr
);
179 CalculateEfiHdrCrc (&gDxeCoreBS
->Hdr
);
180 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
181 CalculateEfiHdrCrc (&gDxeCoreDS
->Hdr
);
188 CoreNotifyOnArchProtocolInstallation (
194 Creates an event that is fired everytime a Protocol of a specific type is installed
205 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
207 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
212 Status
= CoreCreateEvent (
215 GenericArchProtocolNotify
,
219 ASSERT_EFI_ERROR(Status
);
222 // Register for protocol notifactions on this event
224 Status
= CoreRegisterProtocolNotify (
229 ASSERT_EFI_ERROR(Status
);
235 // Following is needed to display missing architectural protocols in debug builds
238 EFI_GUID
*ProtocolGuid
;
240 } GUID_TO_STRING_PROTOCOL_ENTRY
;
242 static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
243 { &gEfiSecurityArchProtocolGuid
, (CHAR16
*)L
"Security" },
244 { &gEfiCpuArchProtocolGuid
, (CHAR16
*)L
"CPU" },
245 { &gEfiMetronomeArchProtocolGuid
, (CHAR16
*)L
"Metronome" },
246 { &gEfiTimerArchProtocolGuid
, (CHAR16
*)L
"Timer" },
247 { &gEfiBdsArchProtocolGuid
, (CHAR16
*)L
"Bds" },
248 { &gEfiWatchdogTimerArchProtocolGuid
, (CHAR16
*)L
"Watchdog Timer" },
249 { &gEfiRuntimeArchProtocolGuid
, (CHAR16
*)L
"Runtime" },
250 { &gEfiVariableArchProtocolGuid
, (CHAR16
*)L
"Variable" },
251 { &gEfiVariableWriteArchProtocolGuid
, (CHAR16
*)L
"Variable Write" },
252 { &gEfiCapsuleArchProtocolGuid
, (CHAR16
*)L
"Capsule" },
253 { &gEfiMonotonicCounterArchProtocolGuid
, (CHAR16
*)L
"Monotonic Counter" },
254 { &gEfiResetArchProtocolGuid
, (CHAR16
*)L
"Reset" },
255 // { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },
256 { &gEfiRealTimeClockArchProtocolGuid
, (CHAR16
*)L
"Real Time Clock" }
260 CoreDisplayMissingArchProtocols (
266 Displays Architectural protocols that were not loaded and are required for DXE core to function
267 Only used in Debug Builds
277 const GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
278 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
280 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
281 if (!Entry
->Present
) {
282 MissingEntry
= MissingProtocols
;
283 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
284 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
285 DEBUG ((EFI_D_ERROR
, "\n%s Arch Protocol not present!!\n", MissingEntry
->GuidString
));