2 This file deals with Architecture Protocol (AP) registration in
3 the Dxe Core. The mArchProtocols[] array represents a list of
4 events that represent the Architectural Protocols.
6 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // DXE Core Global Variables for all of the Architectural Protocols.
22 // If a protocol is installed mArchProtocols[].Present will be TRUE.
24 // CoreNotifyOnArchProtocolInstallation () fills in mArchProtocols[].Event
25 // and mArchProtocols[].Registration as it creates events for every array
29 ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols
[] = {
30 { &gEfiSecurityArchProtocolGuid
, (VOID
**)&gSecurity
, NULL
, NULL
, FALSE
},
31 { &gEfiCpuArchProtocolGuid
, (VOID
**)&gCpu
, NULL
, NULL
, FALSE
},
32 { &gEfiMetronomeArchProtocolGuid
, (VOID
**)&gMetronome
, NULL
, NULL
, FALSE
},
33 { &gEfiTimerArchProtocolGuid
, (VOID
**)&gTimer
, NULL
, NULL
, FALSE
},
34 { &gEfiBdsArchProtocolGuid
, (VOID
**)&gBds
, NULL
, NULL
, FALSE
},
35 { &gEfiWatchdogTimerArchProtocolGuid
, (VOID
**)&gWatchdogTimer
, NULL
, NULL
, FALSE
},
36 { &gEfiRuntimeArchProtocolGuid
, (VOID
**)&gRuntime
, NULL
, NULL
, FALSE
},
37 { &gEfiVariableArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
38 { &gEfiVariableWriteArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
39 { &gEfiCapsuleArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
40 { &gEfiMonotonicCounterArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
41 { &gEfiResetArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
42 { &gEfiRealTimeClockArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
},
43 { NULL
, (VOID
**)NULL
, NULL
, NULL
, FALSE
}
49 Return TRUE if all AP services are availible.
52 @retval EFI_SUCCESS All AP services are available
53 @retval EFI_NOT_FOUND At least one AP service is not available
57 CoreAllEfiServicesAvailable (
61 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
63 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
64 if (!Entry
->Present
) {
74 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
75 This notify function is registered for every architectural protocol. This handler
76 updates mArchProtocol[] array entry with protocol instance data and sets it's
77 present flag to TRUE. If any constructor is required it is executed. The EFI
78 System Table headers are updated.
80 @param Event The Event that is being processed, not used.
81 @param Context Event Context, not used.
86 GenericArchProtocolNotify (
92 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
96 LIST_ENTRY TempLinkNode
;
99 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
101 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
102 if (EFI_ERROR (Status
)) {
107 Entry
->Present
= TRUE
;
110 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
111 // if one exists in the DXE core for this Architectural Protocol
113 if (Entry
->Protocol
!= NULL
) {
114 *(Entry
->Protocol
) = Protocol
;
117 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
119 // Register the Core timer tick handler with the Timer AP
121 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
124 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
126 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
128 CoreUpdateDebugTableCrc32 ();
131 // Update the Runtime Architectural protocol with the template that the core was
132 // using so there would not need to be a dependency on the Runtime AP
136 // Copy all the registered Image to new gRuntime protocol
138 for (Link
= gRuntimeTemplate
.ImageHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.ImageHead
; Link
= TempLinkNode
.ForwardLink
) {
139 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
140 InsertTailList (&gRuntime
->ImageHead
, Link
);
143 // Copy all the registered Event to new gRuntime protocol
145 for (Link
= gRuntimeTemplate
.EventHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.EventHead
; Link
= TempLinkNode
.ForwardLink
) {
146 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
147 InsertTailList (&gRuntime
->EventHead
, Link
);
151 // Clean up gRuntimeTemplate
153 gRuntimeTemplate
.ImageHead
.ForwardLink
= &gRuntimeTemplate
.ImageHead
;
154 gRuntimeTemplate
.ImageHead
.BackLink
= &gRuntimeTemplate
.ImageHead
;
155 gRuntimeTemplate
.EventHead
.ForwardLink
= &gRuntimeTemplate
.EventHead
;
156 gRuntimeTemplate
.EventHead
.BackLink
= &gRuntimeTemplate
.EventHead
;
161 // It's over kill to do them all every time, but it saves a lot of code.
164 CalculateEfiHdrCrc (&gDxeCoreRT
->Hdr
);
165 CalculateEfiHdrCrc (&gDxeCoreBS
->Hdr
);
166 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
167 CalculateEfiHdrCrc (&gDxeCoreDS
->Hdr
);
175 Creates an event that is fired everytime a Protocol of a specific type is installed.
179 CoreNotifyOnArchProtocolInstallation (
184 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
186 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
191 Status
= CoreCreateEvent (
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 { &gEfiCapsuleArchProtocolGuid
, (CHAR16
*)L
"Capsule" },
232 { &gEfiMonotonicCounterArchProtocolGuid
, (CHAR16
*)L
"Monotonic Counter" },
233 { &gEfiResetArchProtocolGuid
, (CHAR16
*)L
"Reset" },
234 // { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },
235 { &gEfiRealTimeClockArchProtocolGuid
, (CHAR16
*)L
"Real Time Clock" }
240 Displays Architectural protocols that were not loaded and are required for DXE
241 core to function. Only used in Debug Builds.
245 CoreDisplayMissingArchProtocols (
249 const GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
250 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
252 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
253 if (!Entry
->Present
) {
254 MissingEntry
= MissingProtocols
;
255 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
256 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
257 DEBUG ((DEBUG_ERROR
, "\n%s Arch Protocol not present!!\n", MissingEntry
->GuidString
));