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.
51 @retval EFI_SUCCESS All AP services are available
52 @retval EFI_NOT_FOUND At least one AP service is not available
56 CoreAllEfiServicesAvailable (
60 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
62 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
63 if (!Entry
->Present
) {
73 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
74 This notify function is registered for every architectural protocol. This handler
75 updates mArchProtocol[] array entry with protocol instance data and sets it's
76 present flag to TRUE. If any constructor is required it is executed. The EFI
77 System Table headers are updated.
79 @param Event The Event that is being processed, not used.
80 @param Context Event Context, not used.
85 GenericArchProtocolNotify (
91 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
95 LIST_ENTRY TempLinkNode
;
98 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
100 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
101 if (EFI_ERROR (Status
)) {
106 Entry
->Present
= TRUE
;
109 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
110 // if one exists in the DXE core for this Architectural Protocol
112 if (Entry
->Protocol
!= NULL
) {
113 *(Entry
->Protocol
) = Protocol
;
116 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
118 // Register the Core timer tick handler with the Timer AP
120 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
123 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
125 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
127 CoreUpdateDebugTableCrc32 ();
130 // Update the Runtime Architectural protocol with the template that the core was
131 // using so there would not need to be a dependency on the Runtime AP
135 // Copy all the registered Image to new gRuntime protocol
137 for (Link
= gRuntimeTemplate
.ImageHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.ImageHead
; Link
= TempLinkNode
.ForwardLink
) {
138 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
139 InsertTailList (&gRuntime
->ImageHead
, Link
);
142 // Copy all the registered Event to new gRuntime protocol
144 for (Link
= gRuntimeTemplate
.EventHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.EventHead
; Link
= TempLinkNode
.ForwardLink
) {
145 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
146 InsertTailList (&gRuntime
->EventHead
, Link
);
150 // Clean up gRuntimeTemplate
152 gRuntimeTemplate
.ImageHead
.ForwardLink
= &gRuntimeTemplate
.ImageHead
;
153 gRuntimeTemplate
.ImageHead
.BackLink
= &gRuntimeTemplate
.ImageHead
;
154 gRuntimeTemplate
.EventHead
.ForwardLink
= &gRuntimeTemplate
.EventHead
;
155 gRuntimeTemplate
.EventHead
.BackLink
= &gRuntimeTemplate
.EventHead
;
160 // It's over kill to do them all every time, but it saves a lot of code.
163 CalculateEfiHdrCrc (&gDxeCoreRT
->Hdr
);
164 CalculateEfiHdrCrc (&gBS
->Hdr
);
165 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
166 CalculateEfiHdrCrc (&gDxeCoreDS
->Hdr
);
173 Creates an event that is fired everytime a Protocol of a specific type is installed.
177 CoreNotifyOnArchProtocolInstallation (
182 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
184 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
189 Status
= CoreCreateEvent (
192 GenericArchProtocolNotify
,
196 ASSERT_EFI_ERROR(Status
);
199 // Register for protocol notifactions on this event
201 Status
= CoreRegisterProtocolNotify (
206 ASSERT_EFI_ERROR(Status
);
212 // Following is needed to display missing architectural protocols in debug builds
215 EFI_GUID
*ProtocolGuid
;
217 } GUID_TO_STRING_PROTOCOL_ENTRY
;
219 GLOBAL_REMOVE_IF_UNREFERENCED CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
220 { &gEfiSecurityArchProtocolGuid
, "Security" },
221 { &gEfiCpuArchProtocolGuid
, "CPU" },
222 { &gEfiMetronomeArchProtocolGuid
, "Metronome" },
223 { &gEfiTimerArchProtocolGuid
, "Timer" },
224 { &gEfiBdsArchProtocolGuid
, "Bds" },
225 { &gEfiWatchdogTimerArchProtocolGuid
, "Watchdog Timer" },
226 { &gEfiRuntimeArchProtocolGuid
, "Runtime" },
227 { &gEfiVariableArchProtocolGuid
, "Variable" },
228 { &gEfiVariableWriteArchProtocolGuid
, "Variable Write" },
229 { &gEfiCapsuleArchProtocolGuid
, "Capsule" },
230 { &gEfiMonotonicCounterArchProtocolGuid
, "Monotonic Counter" },
231 { &gEfiResetArchProtocolGuid
, "Reset" },
232 { &gEfiRealTimeClockArchProtocolGuid
, "Real Time Clock" }
237 Displays Architectural protocols that were not loaded and are required for DXE
238 core to function. Only used in Debug Builds.
242 CoreDisplayMissingArchProtocols (
246 CONST GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
247 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
249 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
250 if (!Entry
->Present
) {
251 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
252 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
253 DEBUG ((DEBUG_ERROR
, "\n%a Arch Protocol not present!!\n", MissingEntry
->GuidString
));