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
}
46 // Following is needed to display missing architectural protocols in debug builds
49 EFI_GUID
*ProtocolGuid
;
51 } GUID_TO_STRING_PROTOCOL_ENTRY
;
53 GLOBAL_REMOVE_IF_UNREFERENCED CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
54 { &gEfiSecurityArchProtocolGuid
, "Security" },
55 { &gEfiCpuArchProtocolGuid
, "CPU" },
56 { &gEfiMetronomeArchProtocolGuid
, "Metronome" },
57 { &gEfiTimerArchProtocolGuid
, "Timer" },
58 { &gEfiBdsArchProtocolGuid
, "Bds" },
59 { &gEfiWatchdogTimerArchProtocolGuid
, "Watchdog Timer" },
60 { &gEfiRuntimeArchProtocolGuid
, "Runtime" },
61 { &gEfiVariableArchProtocolGuid
, "Variable" },
62 { &gEfiVariableWriteArchProtocolGuid
, "Variable Write" },
63 { &gEfiCapsuleArchProtocolGuid
, "Capsule" },
64 { &gEfiMonotonicCounterArchProtocolGuid
, "Monotonic Counter" },
65 { &gEfiResetArchProtocolGuid
, "Reset" },
66 { &gEfiRealTimeClockArchProtocolGuid
, "Real Time Clock" }
70 Return TRUE if all AP services are availible.
72 @retval EFI_SUCCESS All AP services are available
73 @retval EFI_NOT_FOUND At least one AP service is not available
77 CoreAllEfiServicesAvailable (
83 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
84 if (!mArchProtocols
[Index
].Present
) {
94 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
95 This notify function is registered for every architectural protocol. This handler
96 updates mArchProtocol[] array entry with protocol instance data and sets it's
97 present flag to TRUE. If any constructor is required it is executed. The EFI
98 System Table headers are updated.
100 @param Event The Event that is being processed, not used.
101 @param Context Event Context, not used.
106 GenericArchProtocolNotify (
112 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
116 LIST_ENTRY TempLinkNode
;
120 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
121 Entry
= &mArchProtocols
[Index
];
123 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
124 if (EFI_ERROR (Status
)) {
129 Entry
->Present
= TRUE
;
132 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
133 // if one exists in the DXE core for this Architectural Protocol
135 if (Entry
->Protocol
!= NULL
) {
136 *(Entry
->Protocol
) = Protocol
;
139 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
141 // Register the Core timer tick handler with the Timer AP
143 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
146 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
148 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
150 CoreUpdateDebugTableCrc32 ();
153 // Update the Runtime Architectural protocol with the template that the core was
154 // using so there would not need to be a dependency on the Runtime AP
158 // Copy all the registered Image to new gRuntime protocol
160 for (Link
= gRuntimeTemplate
.ImageHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.ImageHead
; Link
= TempLinkNode
.ForwardLink
) {
161 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
162 InsertTailList (&gRuntime
->ImageHead
, Link
);
165 // Copy all the registered Event to new gRuntime protocol
167 for (Link
= gRuntimeTemplate
.EventHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.EventHead
; Link
= TempLinkNode
.ForwardLink
) {
168 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
169 InsertTailList (&gRuntime
->EventHead
, Link
);
173 // Clean up gRuntimeTemplate
175 gRuntimeTemplate
.ImageHead
.ForwardLink
= &gRuntimeTemplate
.ImageHead
;
176 gRuntimeTemplate
.ImageHead
.BackLink
= &gRuntimeTemplate
.ImageHead
;
177 gRuntimeTemplate
.EventHead
.ForwardLink
= &gRuntimeTemplate
.EventHead
;
178 gRuntimeTemplate
.EventHead
.BackLink
= &gRuntimeTemplate
.EventHead
;
183 // It's over kill to do them all every time, but it saves a lot of code.
186 CalculateEfiHdrCrc (&gDxeCoreRT
->Hdr
);
187 CalculateEfiHdrCrc (&gBS
->Hdr
);
188 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
189 CalculateEfiHdrCrc (&gDxeCoreDS
->Hdr
);
196 Creates an event that is fired everytime a Protocol of a specific type is installed.
200 CoreNotifyOnArchProtocolInstallation (
205 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
208 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
209 Entry
= &mArchProtocols
[Index
];
214 Status
= CoreCreateEvent (
217 GenericArchProtocolNotify
,
221 ASSERT_EFI_ERROR(Status
);
224 // Register for protocol notifactions on this event
226 Status
= CoreRegisterProtocolNotify (
231 ASSERT_EFI_ERROR(Status
);
238 Displays Architectural protocols that were not loaded and are required for DXE
239 core to function. Only used in Debug Builds.
243 CoreDisplayMissingArchProtocols (
247 CONST GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
248 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
251 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
252 Entry
= &mArchProtocols
[Index
];
253 if (!Entry
->Present
) {
254 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
255 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
256 DEBUG ((DEBUG_ERROR
, "\n%a Arch Protocol not present!!\n", MissingEntry
->GuidString
));