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 - 2010, 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
, TRUE
},
31 { &gEfiCpuArchProtocolGuid
, (VOID
**)&gCpu
, NULL
, NULL
, FALSE
, TRUE
},
32 { &gEfiMetronomeArchProtocolGuid
, (VOID
**)&gMetronome
, NULL
, NULL
, FALSE
, TRUE
},
33 { &gEfiTimerArchProtocolGuid
, (VOID
**)&gTimer
, NULL
, NULL
, FALSE
, TRUE
},
34 { &gEfiBdsArchProtocolGuid
, (VOID
**)&gBds
, NULL
, NULL
, FALSE
, TRUE
},
35 { &gEfiWatchdogTimerArchProtocolGuid
, (VOID
**)&gWatchdogTimer
, NULL
, NULL
, FALSE
, TRUE
},
36 { &gEfiRuntimeArchProtocolGuid
, (VOID
**)&gRuntime
, NULL
, NULL
, FALSE
, TRUE
},
37 { &gEfiVariableArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
, TRUE
},
38 { &gEfiVariableWriteArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
, TRUE
},
39 { &gEfiCapsuleArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
, TRUE
},
40 { &gEfiMonotonicCounterArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
, TRUE
},
41 { &gEfiResetArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
, TRUE
},
42 { &gEfiRealTimeClockArchProtocolGuid
, (VOID
**)NULL
, NULL
, NULL
, FALSE
, TRUE
},
43 { &gEfiSmmBase2ProtocolGuid
, (VOID
**)&gSmmBase2
, NULL
, NULL
, FALSE
, FALSE
}
47 // Following is needed to display missing architectural protocols in debug builds
50 EFI_GUID
*ProtocolGuid
;
52 } GUID_TO_STRING_PROTOCOL_ENTRY
;
54 GLOBAL_REMOVE_IF_UNREFERENCED CONST GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols
[] = {
55 { &gEfiSecurityArchProtocolGuid
, "Security" },
56 { &gEfiCpuArchProtocolGuid
, "CPU" },
57 { &gEfiMetronomeArchProtocolGuid
, "Metronome" },
58 { &gEfiTimerArchProtocolGuid
, "Timer" },
59 { &gEfiBdsArchProtocolGuid
, "Bds" },
60 { &gEfiWatchdogTimerArchProtocolGuid
, "Watchdog Timer" },
61 { &gEfiRuntimeArchProtocolGuid
, "Runtime" },
62 { &gEfiVariableArchProtocolGuid
, "Variable" },
63 { &gEfiVariableWriteArchProtocolGuid
, "Variable Write" },
64 { &gEfiCapsuleArchProtocolGuid
, "Capsule" },
65 { &gEfiMonotonicCounterArchProtocolGuid
, "Monotonic Counter" },
66 { &gEfiResetArchProtocolGuid
, "Reset" },
67 { &gEfiRealTimeClockArchProtocolGuid
, "Real Time Clock" }
71 Return TRUE if all AP services are availible.
73 @retval EFI_SUCCESS All AP services are available
74 @retval EFI_NOT_FOUND At least one AP service is not available
78 CoreAllEfiServicesAvailable (
84 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
85 if (mArchProtocols
[Index
].ArchitecturalProtocol
&& !mArchProtocols
[Index
].Present
) {
95 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
96 This notify function is registered for every architectural protocol. This handler
97 updates mArchProtocol[] array entry with protocol instance data and sets it's
98 present flag to TRUE. If any constructor is required it is executed. The EFI
99 System Table headers are updated.
101 @param Event The Event that is being processed, not used.
102 @param Context Event Context, not used.
107 GenericArchProtocolNotify (
113 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
117 LIST_ENTRY TempLinkNode
;
121 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
122 Entry
= &mArchProtocols
[Index
];
124 Status
= CoreLocateProtocol (Entry
->ProtocolGuid
, Entry
->Registration
, &Protocol
);
125 if (EFI_ERROR (Status
)) {
130 Entry
->Present
= TRUE
;
133 // Update protocol global variable if one exists. Entry->Protocol points to a global variable
134 // if one exists in the DXE core for this Architectural Protocol
136 if (Entry
->Protocol
!= NULL
) {
137 *(Entry
->Protocol
) = Protocol
;
140 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiTimerArchProtocolGuid
)) {
142 // Register the Core timer tick handler with the Timer AP
144 gTimer
->RegisterHandler (gTimer
, CoreTimerTick
);
147 if (CompareGuid (Entry
->ProtocolGuid
, &gEfiRuntimeArchProtocolGuid
)) {
149 // When runtime architectural protocol is available, updates CRC32 in the Debug Table
151 CoreUpdateDebugTableCrc32 ();
154 // Update the Runtime Architectural protocol with the template that the core was
155 // using so there would not need to be a dependency on the Runtime AP
159 // Copy all the registered Image to new gRuntime protocol
161 for (Link
= gRuntimeTemplate
.ImageHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.ImageHead
; Link
= TempLinkNode
.ForwardLink
) {
162 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
163 InsertTailList (&gRuntime
->ImageHead
, Link
);
166 // Copy all the registered Event to new gRuntime protocol
168 for (Link
= gRuntimeTemplate
.EventHead
.ForwardLink
; Link
!= &gRuntimeTemplate
.EventHead
; Link
= TempLinkNode
.ForwardLink
) {
169 CopyMem (&TempLinkNode
, Link
, sizeof(LIST_ENTRY
));
170 InsertTailList (&gRuntime
->EventHead
, Link
);
174 // Clean up gRuntimeTemplate
176 gRuntimeTemplate
.ImageHead
.ForwardLink
= &gRuntimeTemplate
.ImageHead
;
177 gRuntimeTemplate
.ImageHead
.BackLink
= &gRuntimeTemplate
.ImageHead
;
178 gRuntimeTemplate
.EventHead
.ForwardLink
= &gRuntimeTemplate
.EventHead
;
179 gRuntimeTemplate
.EventHead
.BackLink
= &gRuntimeTemplate
.EventHead
;
184 // It's over kill to do them all every time, but it saves a lot of code.
187 CalculateEfiHdrCrc (&gDxeCoreRT
->Hdr
);
188 CalculateEfiHdrCrc (&gBS
->Hdr
);
189 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
190 CalculateEfiHdrCrc (&gDxeCoreDS
->Hdr
);
197 Creates an event that is fired everytime a Protocol of a specific type is installed.
201 CoreNotifyOnArchProtocolInstallation (
206 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
209 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
210 Entry
= &mArchProtocols
[Index
];
215 Status
= CoreCreateEvent (
218 GenericArchProtocolNotify
,
222 ASSERT_EFI_ERROR(Status
);
225 // Register for protocol notifactions on this event
227 Status
= CoreRegisterProtocolNotify (
232 ASSERT_EFI_ERROR(Status
);
239 Displays Architectural protocols that were not loaded and are required for DXE
240 core to function. Only used in Debug Builds.
244 CoreDisplayMissingArchProtocols (
248 CONST GUID_TO_STRING_PROTOCOL_ENTRY
*MissingEntry
;
249 ARCHITECTURAL_PROTOCOL_ENTRY
*Entry
;
252 for (Index
= 0; Index
< sizeof (mArchProtocols
) / sizeof (mArchProtocols
[0]); Index
++) {
253 Entry
= &mArchProtocols
[Index
];
254 if (!Entry
->Present
) {
255 for (MissingEntry
= MissingProtocols
; TRUE
; MissingEntry
++) {
256 if (CompareGuid (Entry
->ProtocolGuid
, MissingEntry
->ProtocolGuid
)) {
257 DEBUG ((DEBUG_ERROR
, "\n%a Arch Protocol not present!!\n", MissingEntry
->GuidString
));