]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
Fixed some naming issues and update to the EDK II name. I also fixed an issue with...
[mirror_edk2.git] / EdkModulePkg / Core / Dxe / DxeMain / DxeProtocolNotify.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 DxeProtocolNotify.c\r
15\r
16Abstract:\r
17\r
18 This file deals with Architecture Protocol (AP) registration in \r
19 the Dxe Core. The mArchProtocols[] array represents a list of \r
20 events that represent the Architectural Protocols.\r
21\r
22--*/\r
23\r
24#include <DxeMain.h>\r
25\r
26\r
27//\r
28// DXE Core Global Variables for all of the Architectural Protocols.\r
29// If a protocol is installed mArchProtocols[].Present will be TRUE.\r
30//\r
31// CoreNotifyOnArchProtocolInstallation () fills in mArchProtocols[].Event\r
32// and mArchProtocols[].Registration as it creates events for every array\r
33// entry.\r
34//\r
35\r
36ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = {\r
37 { &gEfiSecurityArchProtocolGuid, (VOID **)&gSecurity, NULL, NULL, FALSE },\r
38 { &gEfiCpuArchProtocolGuid, (VOID **)&gCpu, NULL, NULL, FALSE },\r
39 { &gEfiMetronomeArchProtocolGuid, (VOID **)&gMetronome, NULL, NULL, FALSE },\r
40 { &gEfiTimerArchProtocolGuid, (VOID **)&gTimer, NULL, NULL, FALSE },\r
41 { &gEfiBdsArchProtocolGuid, (VOID **)&gBds, NULL, NULL, FALSE },\r
42 { &gEfiWatchdogTimerArchProtocolGuid, (VOID **)&gWatchdogTimer, NULL, NULL, FALSE },\r
43 { &gEfiRuntimeArchProtocolGuid, (VOID **)&gRuntime, NULL, NULL, FALSE },\r
44 { &gEfiVariableArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
45 { &gEfiVariableWriteArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
a537f148 46#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
47 //\r
48 // UEFI 2.0 added support for Capsule services. DXE CIS ??? Added support for this AP\r
49 //\r
045f4521 50 { &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE},\r
a537f148 51#endif\r
878ddf1f 52 { &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
53 { &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
a537f148 54#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
55 //\r
56 // The ReportStatusCode Runtime service is in conflict with the UEFI 2.0 specificaiton\r
57 // Thus gEfiStatusCodeRuntimeProtocolGuid becomes a normal protocol in UEFI 2.0 systems\r
58 // It is only included if the EFI 1.10 with Tiano extensions is enabled for backward\r
59 // compatability\r
60 //\r
61 { &gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode, NULL, NULL, FALSE },\r
62#endif\r
878ddf1f 63 { &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
64 { NULL, (VOID **)NULL, NULL, NULL, FALSE }\r
65};\r
66\r
67\r
68EFI_STATUS\r
69CoreAllEfiServicesAvailable (\r
70 VOID\r
71 )\r
72/*++\r
73\r
74Routine Description:\r
75 Return TRUE if all AP services are availible.\r
76\r
77Arguments:\r
78 NONE\r
79\r
80Returns:\r
81 EFI_SUCCESS - All AP services are available\r
82 EFI_NOT_FOUND - At least one AP service is not available \r
83\r
84--*/\r
85{\r
86 ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
87\r
88 for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
89 if (!Entry->Present) {\r
90 return EFI_NOT_FOUND;\r
91 }\r
92 }\r
93\r
94 return EFI_SUCCESS;\r
95}\r
96\r
97\r
98VOID\r
99EFIAPI\r
100GenericArchProtocolNotify (\r
101 IN EFI_EVENT Event,\r
102 IN VOID *Context\r
103 )\r
104/*++\r
105\r
106Routine Description:\r
107 Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().\r
108 This notify function is registered for every architectural protocol. This handler\r
109 updates mArchProtocol[] array entry with protocol instance data and sets it's \r
110 present flag to TRUE. If any constructor is required it is executed. The EFI \r
111 System Table headers are updated.\r
112\r
113Arguments:\r
114\r
115 Event - The Event that is being processed, not used.\r
116 \r
117 Context - Event Context, not used.\r
118\r
119Returns:\r
120\r
121 None\r
122\r
123--*/\r
124{\r
125 EFI_STATUS Status;\r
126 ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
127 VOID *Protocol;\r
128 BOOLEAN Found;\r
129 \r
130 Found = FALSE;\r
131 for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
132 \r
133 Status = CoreLocateProtocol (Entry->ProtocolGuid, Entry->Registration, &Protocol);\r
134 if (EFI_ERROR (Status)) {\r
135 continue;\r
136 } \r
137 \r
138 Found = TRUE;\r
139 Entry->Present = TRUE;\r
140 \r
141 //\r
142 // Update protocol global variable if one exists. Entry->Protocol points to a global variable\r
143 // if one exists in the DXE core for this Architectural Protocol \r
144 //\r
145 if (Entry->Protocol != NULL) {\r
146 *(Entry->Protocol) = Protocol;\r
147 }\r
148\r
149 if (CompareGuid (Entry->ProtocolGuid, &gEfiTimerArchProtocolGuid)) {\r
150 //\r
151 // Register the Core timer tick handler with the Timer AP\r
152 //\r
153 gTimer->RegisterHandler (gTimer, CoreTimerTick);\r
154 }\r
155\r
156 if (CompareGuid (Entry->ProtocolGuid, &gEfiRuntimeArchProtocolGuid)) {\r
157 //\r
158 // When runtime architectural protocol is available, updates CRC32 in the Debug Table\r
159 //\r
160 CoreUpdateDebugTableCrc32 ();\r
161 }\r
162 }\r
163\r
164 //\r
165 // It's over kill to do them all every time, but it saves a lot of code.\r
166 //\r
167 if (Found) {\r
168 CalculateEfiHdrCrc (&gRT->Hdr);\r
169 CalculateEfiHdrCrc (&gBS->Hdr);\r
170 CalculateEfiHdrCrc (&gST->Hdr);\r
171 CalculateEfiHdrCrc (&gDS->Hdr);\r
172 }\r
173}\r
174\r
175\r
176\r
177VOID\r
178CoreNotifyOnArchProtocolInstallation (\r
179 VOID\r
180 )\r
181/*++\r
182\r
183Routine Description:\r
184 Creates an event that is fired everytime a Protocol of a specific type is installed\r
185\r
186Arguments:\r
187 NONE\r
188\r
189Returns:\r
190 NONE\r
191\r
192--*/\r
193{\r
194 EFI_STATUS Status;\r
195 ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
196\r
197 for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
198 \r
199 //\r
200 // Create the event\r
201 //\r
202 Status = CoreCreateEvent (\r
203 EFI_EVENT_NOTIFY_SIGNAL,\r
204 EFI_TPL_CALLBACK,\r
205 GenericArchProtocolNotify,\r
206 NULL,\r
207 &Entry->Event\r
208 );\r
209 ASSERT_EFI_ERROR(Status);\r
210\r
211 //\r
212 // Register for protocol notifactions on this event\r
213 //\r
214 Status = CoreRegisterProtocolNotify (\r
215 Entry->ProtocolGuid, \r
216 Entry->Event, \r
217 &Entry->Registration\r
218 );\r
219 ASSERT_EFI_ERROR(Status);\r
220\r
221 }\r
222}\r
223\r
224//\r
225// Following is needed to display missing architectural protocols in debug builds\r
226//\r
227typedef struct {\r
228 EFI_GUID *ProtocolGuid;\r
229 CHAR16 *GuidString;\r
230} GUID_TO_STRING_PROTOCOL_ENTRY;\r
231\r
232static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {\r
233 { &gEfiSecurityArchProtocolGuid, (CHAR16 *)L"Security" },\r
234 { &gEfiCpuArchProtocolGuid, (CHAR16 *)L"CPU" },\r
235 { &gEfiMetronomeArchProtocolGuid, (CHAR16 *)L"Metronome" },\r
236 { &gEfiTimerArchProtocolGuid, (CHAR16 *)L"Timer" },\r
237 { &gEfiBdsArchProtocolGuid, (CHAR16 *)L"Bds" },\r
238 { &gEfiWatchdogTimerArchProtocolGuid, (CHAR16 *)L"Watchdog Timer" },\r
239 { &gEfiRuntimeArchProtocolGuid, (CHAR16 *)L"Runtime" },\r
240 { &gEfiVariableArchProtocolGuid, (CHAR16 *)L"Variable" },\r
241 { &gEfiVariableWriteArchProtocolGuid, (CHAR16 *)L"Variable Write" },\r
045f4521 242 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
243 { &gEfiCapsuleArchProtocolGuid, (CHAR16 *)L"Capsule" },\r
244 #endif\r
878ddf1f 245 { &gEfiMonotonicCounterArchProtocolGuid, (CHAR16 *)L"Monotonic Counter" },\r
246 { &gEfiResetArchProtocolGuid, (CHAR16 *)L"Reset" },\r
247// { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },\r
248 { &gEfiRealTimeClockArchProtocolGuid, (CHAR16 *)L"Real Time Clock" }\r
249};\r
250\r
251VOID\r
252CoreDisplayMissingArchProtocols (\r
253 VOID\r
254 )\r
255/*++\r
256\r
257Routine Description:\r
258 Displays Architectural protocols that were not loaded and are required for DXE core to function\r
259 Only used in Debug Builds\r
260\r
261Arguments:\r
262 NONE\r
263\r
264Returns:\r
265 NONE\r
266\r
267--*/\r
268{\r
269 const GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry;\r
270 ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
271\r
272 for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
273 if (!Entry->Present) {\r
274 MissingEntry = MissingProtocols;\r
275 for (MissingEntry = MissingProtocols; TRUE ; MissingEntry++) {\r
276 if (CompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) {\r
277 DEBUG ((EFI_D_ERROR, "\n%s Arch Protocol not present!!\n", MissingEntry->GuidString));\r
278 break;\r
279 }\r
280 }\r
281 }\r
282 } \r
283}\r