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
}
50 Return TRUE if all AP services are availible.
53 @retval EFI_SUCCESS All AP services are available
54 @retval EFI_NOT_FOUND At least one AP service is not available
58 CoreAllEfiServicesAvailable (
62 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
64 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
65 if (!Entry
->Present
) {
75 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
76 This notify function is registered for every architectural protocol. This handler
77 updates mArchProtocol[] array entry with protocol instance data and sets it's
78 present flag to TRUE. If any constructor is required it is executed. The EFI
79 System Table headers are updated.
81 @param Event The Event that is being processed, not used.
82 @param Context Event Context, not used.
88 GenericArchProtocolNotify (
94 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
98 LIST_ENTRY TempLinkNode
;
101 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
103 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
104 if (EFI_ERROR (Status
)) {
109 Entry
->Present
= TRUE
;
112 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
113 // if one exists in the DXE core for this Architectural Protocol
115 if (Entry
->Protocol
!= NULL
) {
116 *(Entry
->Protocol
) = Protocol
;
119 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
121 // Register the Core timer tick handler with the Timer AP
123 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
126 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
128 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
130 CoreUpdateDebugTableCrc32 ();
133 // Update the Runtime Architectural protocol with the template that the core was
134 // using so there would not need to be a dependency on the Runtime AP
138 // Copy all the registered Image to new gRuntime protocol
140 for (Link
= gRuntimeTemplate
.ImageHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.ImageHead
; Link
= TempLinkNode
.ForwardLink
) {
141 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
142 InsertTailList (&gRuntime
->ImageHead
, Link
);
145 // Copy all the registered Event to new gRuntime protocol
147 for (Link
= gRuntimeTemplate
.EventHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.EventHead
; Link
= TempLinkNode
.ForwardLink
) {
148 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
149 InsertTailList (&gRuntime
->EventHead
, Link
);
153 // Clean up gRuntimeTemplate
155 gRuntimeTemplate
.ImageHead
.ForwardLink
= &gRuntimeTemplate
.ImageHead
;
156 gRuntimeTemplate
.ImageHead
.BackLink
= &gRuntimeTemplate
.ImageHead
;
157 gRuntimeTemplate
.EventHead
.ForwardLink
= &gRuntimeTemplate
.EventHead
;
158 gRuntimeTemplate
.EventHead
.BackLink
= &gRuntimeTemplate
.EventHead
;
163 // It's over kill to do them all every time, but it saves a lot of code.
166 CalculateEfiHdrCrc (&gDxeCoreRT
->Hdr
);
167 CalculateEfiHdrCrc (&gDxeCoreBS
->Hdr
);
168 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
169 CalculateEfiHdrCrc (&gDxeCoreDS
->Hdr
);
177 Creates an event that is fired everytime a Protocol of a specific type is installed.
181 CoreNotifyOnArchProtocolInstallation (
186 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
188 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
193 Status
= CoreCreateEvent (
196 GenericArchProtocolNotify
,
200 ASSERT_EFI_ERROR(Status
);
203 // Register for protocol notifactions on this event
205 Status
= CoreRegisterProtocolNotify (
210 ASSERT_EFI_ERROR(Status
);
216 // Following is needed to display missing architectural protocols in debug builds
219 EFI_GUID
*ProtocolGuid
;
221 } GUID_TO_STRING_PROTOCOL_ENTRY
;
223 static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
224 { &gEfiSecurityArchProtocolGuid
, (CHAR16
*)L
"Security" },
225 { &gEfiCpuArchProtocolGuid
, (CHAR16
*)L
"CPU" },
226 { &gEfiMetronomeArchProtocolGuid
, (CHAR16
*)L
"Metronome" },
227 { &gEfiTimerArchProtocolGuid
, (CHAR16
*)L
"Timer" },
228 { &gEfiBdsArchProtocolGuid
, (CHAR16
*)L
"Bds" },
229 { &gEfiWatchdogTimerArchProtocolGuid
, (CHAR16
*)L
"Watchdog Timer" },
230 { &gEfiRuntimeArchProtocolGuid
, (CHAR16
*)L
"Runtime" },
231 { &gEfiVariableArchProtocolGuid
, (CHAR16
*)L
"Variable" },
232 { &gEfiVariableWriteArchProtocolGuid
, (CHAR16
*)L
"Variable Write" },
233 { &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" }
242 Displays Architectural protocols that were not loaded and are required for DXE
243 core to function. Only used in Debug Builds.
247 CoreDisplayMissingArchProtocols (
251 const GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
252 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
254 for (Entry
= mArchProtocols
; Entry
->ProtocolGuid
!= NULL
; Entry
++) {
255 if (!Entry
->Present
) {
256 MissingEntry
= MissingProtocols
;
257 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
258 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
259 DEBUG ((DEBUG_ERROR
, "\n%s Arch Protocol not present!!\n", MissingEntry
->GuidString
));