]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c
Remove EBC arch from supported arch list to fix tracker EDKII350.
[mirror_edk2.git] / EdkModulePkg / Core / Dxe / DxeMain / DxeMain.c
CommitLineData
ef99a95a 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 DxeMain.c\r
15\r
16Abstract:\r
17\r
18 DXE Core Main Entry Point\r
19\r
20--*/\r
21\r
22#include <DxeMain.h>\r
23\r
24VOID\r
25EFIAPI\r
26DxeMain (\r
27 IN VOID *HobStart\r
28 );\r
29\r
30EFI_STATUS\r
31EFIAPI\r
32CoreEfiNotAvailableYetArg0 (\r
33 VOID\r
34 );\r
35\r
36EFI_STATUS\r
37EFIAPI\r
38CoreEfiNotAvailableYetArg1 (\r
39 UINTN Arg1\r
40 );\r
41\r
42EFI_STATUS\r
43EFIAPI\r
44CoreEfiNotAvailableYetArg2 (\r
45 UINTN Arg1,\r
46 UINTN Arg2\r
47 );\r
48\r
49EFI_STATUS\r
50EFIAPI\r
51CoreEfiNotAvailableYetArg3 (\r
52 UINTN Arg1,\r
53 UINTN Arg2,\r
54 UINTN Arg3\r
55 );\r
56\r
57EFI_STATUS\r
58EFIAPI\r
59CoreEfiNotAvailableYetArg4 (\r
60 UINTN Arg1,\r
61 UINTN Arg2,\r
62 UINTN Arg3,\r
63 UINTN Arg4\r
64 );\r
65\r
66EFI_STATUS\r
67EFIAPI\r
68CoreEfiNotAvailableYetArg5 (\r
69 UINTN Arg1,\r
70 UINTN Arg2,\r
71 UINTN Arg3,\r
72 UINTN Arg4,\r
73 UINTN Arg5\r
74 );\r
75\r
76EFI_STATUS\r
77CoreGetPeiProtocol (\r
78 IN EFI_GUID *ProtocolGuid,\r
79 IN VOID **Interface\r
80 );\r
81 \r
82EFI_STATUS\r
83DxeMainUefiDecompressGetInfo (\r
84 IN EFI_DECOMPRESS_PROTOCOL *This,\r
85 IN VOID *Source,\r
86 IN UINT32 SourceSize,\r
87 OUT UINT32 *DestinationSize,\r
88 OUT UINT32 *ScratchSize\r
89 );\r
90\r
91EFI_STATUS\r
92EFIAPI\r
93DxeMainUefiDecompress (\r
94 IN EFI_DECOMPRESS_PROTOCOL *This,\r
95 IN VOID *Source,\r
96 IN UINT32 SourceSize,\r
97 IN OUT VOID *Destination,\r
98 IN UINT32 DestinationSize,\r
99 IN OUT VOID *Scratch,\r
100 IN UINT32 ScratchSize\r
101 );\r
102\r
103EFI_STATUS\r
104DxeMainTianoDecompressGetInfo (\r
105 IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
106 IN VOID *Source,\r
107 IN UINT32 SourceSize,\r
108 OUT UINT32 *DestinationSize,\r
109 OUT UINT32 *ScratchSize\r
110 );\r
111\r
112EFI_STATUS\r
113EFIAPI\r
114DxeMainTianoDecompress (\r
115 IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
116 IN VOID *Source,\r
117 IN UINT32 SourceSize,\r
118 IN OUT VOID *Destination,\r
119 IN UINT32 DestinationSize,\r
120 IN OUT VOID *Scratch,\r
121 IN UINT32 ScratchSize\r
122 );\r
123\r
124EFI_STATUS\r
125DxeMainCustomDecompressGetInfo (\r
126 IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,\r
127 IN VOID *Source,\r
128 IN UINT32 SourceSize,\r
129 OUT UINT32 *DestinationSize,\r
130 OUT UINT32 *ScratchSize\r
131 );\r
132\r
133EFI_STATUS\r
134EFIAPI\r
135DxeMainCustomDecompress (\r
136 IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,\r
137 IN VOID *Source,\r
138 IN UINT32 SourceSize,\r
139 IN OUT VOID *Destination,\r
140 IN UINT32 DestinationSize,\r
141 IN OUT VOID *Scratch,\r
142 IN UINT32 ScratchSize\r
143 );\r
144\r
145//\r
146// DXE Core Global Variables for Protocols from PEI\r
147//\r
148EFI_HANDLE mDecompressHandle = NULL;\r
149EFI_PEI_PE_COFF_LOADER_PROTOCOL *gEfiPeiPeCoffLoader = NULL;\r
150\r
151//\r
152// DXE Core globals for Architecture Protocols\r
153//\r
154EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;\r
155EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;\r
156EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;\r
157EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;\r
158EFI_BDS_ARCH_PROTOCOL *gBds = NULL;\r
159EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;\r
160EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = NULL;\r
161\r
162//\r
163// BugBug: I'n not runtime, but is the PPI?\r
164//\r
165EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance = {\r
166 NULL\r
167};\r
168\r
169EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance;\r
170\r
171\r
172//\r
173// DXE Core Global used to update core loaded image protocol handle\r
174//\r
175EFI_GUID *gDxeCoreFileName;\r
176EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;\r
177\r
178\r
179\r
180//\r
181// DXE Core Module Variables\r
182//\r
183\r
184EFI_BOOT_SERVICES mBootServices = {\r
185 {\r
186 EFI_BOOT_SERVICES_SIGNATURE, // Signature\r
187 EFI_BOOT_SERVICES_REVISION, // Revision\r
188 sizeof (EFI_BOOT_SERVICES), // HeaderSize\r
189 0, // CRC32\r
190 0 // Reserved\r
191 }, \r
192 (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL\r
193 (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL\r
194 (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages\r
195 (EFI_FREE_PAGES) CoreFreePages, // FreePages\r
196 (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap\r
197 (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool\r
198 (EFI_FREE_POOL) CoreFreePool, // FreePool\r
199 (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent\r
200 (EFI_SET_TIMER) CoreSetTimer, // SetTimer\r
201 (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent\r
202 (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent\r
203 (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent\r
204 (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent\r
205 (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface\r
206 (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface\r
207 (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface\r
208 (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol\r
209 (VOID *) NULL, // Reserved\r
210 (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify\r
211 (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle\r
212 (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath\r
213 (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable\r
214 (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage\r
215 (EFI_IMAGE_START) CoreStartImage, // StartImage\r
216 (EFI_EXIT) CoreExit, // Exit\r
217 (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage\r
218 (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices\r
219 (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount\r
220 (EFI_STALL) CoreStall, // Stall\r
221 (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer\r
222 (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController\r
223 (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController\r
224 (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol\r
225 (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol\r
226 (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation\r
227 (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle\r
228 (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer\r
229 (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol\r
230 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces\r
231 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces\r
232 (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32\r
233 (EFI_COPY_MEM) CopyMem, // CopyMem\r
234 (EFI_SET_MEM) SetMem // SetMem\r
235#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
236 , \r
237 (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx\r
238#endif\r
239};\r
240\r
241EFI_DXE_SERVICES mDxeServices = {\r
242 {\r
243 EFI_DXE_SERVICES_SIGNATURE, // Signature\r
244 EFI_DXE_SERVICES_REVISION, // Revision\r
245 sizeof (EFI_DXE_SERVICES), // HeaderSize\r
246 0, // CRC32\r
247 0 // Reserved\r
248 },\r
249 (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace\r
250 (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace\r
251 (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace\r
252 (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace\r
253 (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor\r
254 (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes\r
255 (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap\r
256 (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace\r
257 (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace\r
258 (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace\r
259 (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace\r
260 (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor\r
261 (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap\r
262 (EFI_DISPATCH) CoreDispatcher, // Dispatch\r
263 (EFI_SCHEDULE) CoreSchedule, // Schedule\r
264 (EFI_TRUST) CoreTrust, // Trust\r
265 (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume\r
266};\r
267\r
268EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {\r
269 {\r
270 EFI_SYSTEM_TABLE_SIGNATURE, // Signature\r
271 EFI_SYSTEM_TABLE_REVISION, // Revision\r
272 sizeof (EFI_SYSTEM_TABLE), // HeaderSize\r
273 0, // CRC32\r
274 0 // Reserved\r
275 },\r
276 NULL, // FirmwareVendor\r
277 0, // FirmwareRevision\r
278 NULL, // ConsoleInHandle\r
279 NULL, // ConIn\r
280 NULL, // ConsoleOutHandle\r
281 NULL, // ConOut\r
282 NULL, // StandardErrorHandle\r
283 NULL, // StdErr\r
284 NULL, // RuntimeServices\r
285 &mBootServices, // BootServices\r
286 0, // NumberOfConfigurationTableEntries\r
287 NULL // ConfigurationTable\r
288};\r
289\r
290EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {\r
291 {\r
292 EFI_RUNTIME_SERVICES_SIGNATURE, // Signature\r
293 EFI_RUNTIME_SERVICES_REVISION, // Revision\r
294 sizeof (EFI_RUNTIME_SERVICES), // HeaderSize\r
295 0, // CRC32\r
296 0 // Reserved\r
297 },\r
298 (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime\r
299 (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime\r
300 (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime\r
301 (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime\r
302 (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap\r
303 (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer\r
304 (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable\r
305 (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName\r
306 (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable\r
307 (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount\r
308 (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4 // ResetSystem \r
309#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
a537f148 310 //\r
311 // This Tiano extension was removed when UEFI 2.0 support was added. \r
312 // It's now just a protocol.\r
313 //\r
ef99a95a 314 ,\r
36122070 315 (EFI_REPORT_STATUS_CODE) CoreEfiNotAvailableYetArg5 // ReportStatusCode\r
ef99a95a 316#elif (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
a537f148 317 //\r
318 // New runtime services added by UEFI 2.0\r
319 //\r
ef99a95a 320 ,\r
321 (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule\r
322 (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities\r
323 (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo\r
324#endif\r
325};\r
326\r
327//\r
328// DXE Core Global Variables for the EFI System Table, Boot Services Table, \r
329// DXE Services Table, and Runtime Services Table\r
330//\r
331EFI_BOOT_SERVICES *gBS = &mBootServices;\r
332EFI_DXE_SERVICES *gDS = &mDxeServices;\r
333EFI_SYSTEM_TABLE *gST = NULL;\r
334\r
335//\r
336// For debug initialize gRT to template. gRT must be allocated from RT memory\r
337// but gRT is used for ASSERT () and DEBUG () type macros so lets give it\r
338// a value that will not cause debug infrastructure to crash early on.\r
339//\r
340EFI_RUNTIME_SERVICES *gRT = &mEfiRuntimeServicesTableTemplate;\r
341EFI_HANDLE gDxeCoreImageHandle = NULL;\r
342\r
343VOID *mHobStart;\r
344\r
345//\r
346// EFI Decompress Protocol\r
347//\r
348EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {\r
349 DxeMainUefiDecompressGetInfo,\r
350 DxeMainUefiDecompress\r
351};\r
352\r
353//\r
354// Tiano Decompress Protocol\r
355//\r
356EFI_TIANO_DECOMPRESS_PROTOCOL gEfiTianoDecompress = {\r
357 DxeMainTianoDecompressGetInfo,\r
358 DxeMainTianoDecompress\r
359};\r
360\r
361//\r
362// Customized Decompress Protocol\r
363//\r
364EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL gEfiCustomizedDecompress = {\r
365 DxeMainCustomDecompressGetInfo,\r
366 DxeMainCustomDecompress\r
367};\r
368\r
369//\r
370// Main entry point to the DXE Core\r
371//\r
372VOID\r
373EFIAPI\r
374DxeMain (\r
375 IN VOID *HobStart\r
376 )\r
377/*++\r
378\r
379Routine Description:\r
380\r
381 Main entry point to DXE Core.\r
382\r
383Arguments:\r
384\r
385 HobStart - Pointer to the beginning of the HOB List from PEI\r
386\r
387Returns:\r
388\r
389 This function should never return\r
390\r
391--*/\r
392{\r
393 EFI_STATUS Status;\r
394 EFI_PHYSICAL_ADDRESS MemoryBaseAddress;\r
395 UINT64 MemoryLength;\r
396\r
ef99a95a 397 mHobStart = HobStart;\r
398\r
399 //\r
400 // Initialize Memory Services\r
401 //\r
402 CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);\r
403\r
404 //\r
405 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r
406 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r
407 //\r
408 gST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r
409 ASSERT (gST != NULL);\r
410\r
411 gRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r
412 ASSERT (gRT != NULL);\r
413\r
414 gST->RuntimeServices = gRT;\r
415 \r
416 //\r
417 // Start the Image Services.\r
418 //\r
419 Status = CoreInitializeImageServices (HobStart);\r
420 ASSERT_EFI_ERROR (Status);\r
421\r
422 //\r
423 // Call constructor for all libraries\r
424 //\r
425 ProcessLibraryConstructorList (gDxeCoreImageHandle, gST);\r
426\r
427 //\r
428 // Initialize the Global Coherency Domain Services\r
429 //\r
430 Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);\r
431 ASSERT_EFI_ERROR (Status);\r
432\r
433 //\r
434 // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
435 //\r
436 Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS);\r
437 ASSERT_EFI_ERROR (Status);\r
438\r
439 //\r
440 // Install the HOB List into the EFI System Tables's Configuration Table\r
441 //\r
442 Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);\r
443 ASSERT_EFI_ERROR (Status);\r
444\r
445 //\r
446 // Install Memory Type Information Table into the EFI System Tables's Configuration Table\r
447 //\r
448 Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);\r
449 ASSERT_EFI_ERROR (Status);\r
450\r
451 //\r
452 // Initialize the ReportStatusCode with PEI version, if availible\r
453 //\r
454 CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode);\r
455#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
a537f148 456 //\r
457 // This Tiano extension was removed when UEFI 2.0 support was added. \r
458 // It's now just a protocol.\r
459 //\r
ef99a95a 460 gRT->ReportStatusCode = gStatusCode->ReportStatusCode;\r
461#endif\r
462\r
463 //\r
464 // Report Status Code here for DXE_ENTRY_POINT once it is available\r
465 //\r
466 CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT));\r
467\r
468 //\r
469 // Create the aligned system table pointer structure that is used by external\r
470 // debuggers to locate the system table... Also, install debug image info\r
471 // configuration table.\r
472 //\r
473 CoreInitializeDebugImageInfoTable ();\r
474 CoreNewDebugImageInfoEntry (\r
475 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,\r
476 gDxeCoreLoadedImage,\r
477 gDxeCoreImageHandle\r
478 );\r
479\r
480 DEBUG ((EFI_D_INFO | EFI_D_LOAD, "HOBLIST address in DXE = 0x%08x\n", HobStart));\r
481\r
482 //\r
483 // Initialize the Event Services\r
484 //\r
485 Status = CoreInitializeEventServices ();\r
486 ASSERT_EFI_ERROR (Status);\r
487\r
488 \r
489 //\r
490 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r
491 //\r
492 // These Protocols are not architectural. This implementation is sharing code between \r
493 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented \r
494 // as part of the DXE Core. However, that would also require the DXE Core to be ported \r
495 // each time a different CPU is used, a different Decompression algorithm is used, or a \r
496 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains \r
497 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform, \r
498 // and from CPU to CPU.\r
499 //\r
500\r
501 //\r
502 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components\r
503 // \r
504 Status = CoreInstallMultipleProtocolInterfaces (\r
505 &mDecompressHandle,\r
506 &gEfiDecompressProtocolGuid, &gEfiDecompress,\r
507 &gEfiTianoDecompressProtocolGuid, &gEfiTianoDecompress,\r
508 &gEfiCustomizedDecompressProtocolGuid, &gEfiCustomizedDecompress,\r
509 NULL\r
510 );\r
511 ASSERT_EFI_ERROR (Status);\r
512\r
513 gEfiPeiPeCoffLoader = GetPeCoffLoaderProtocol ();\r
514 ASSERT (gEfiPeiPeCoffLoader != NULL);\r
515\r
516 //\r
517 // Register for the GUIDs of the Architectural Protocols, so the rest of the\r
518 // EFI Boot Services and EFI Runtime Services tables can be filled in.\r
519 //\r
520 CoreNotifyOnArchProtocolInstallation ();\r
521\r
522 //\r
523 // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r
524 //\r
525 Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gST);\r
526 ASSERT_EFI_ERROR (Status);\r
527\r
528 Status = FwVolDriverInit (gDxeCoreImageHandle, gST);\r
529 ASSERT_EFI_ERROR (Status);\r
530\r
531 //\r
532 // Produce the Section Extraction Protocol \r
533 //\r
534 Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST);\r
535 ASSERT_EFI_ERROR (Status);\r
536\r
537 //\r
538 // Initialize the DXE Dispatcher\r
539 //\r
540 PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ;\r
541 CoreInitializeDispatcher ();\r
542 PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ;\r
543\r
544 //\r
545 // Invoke the DXE Dispatcher\r
546 //\r
547 PERF_START (0, "CoreDispatcher", "DxeMain", 0);\r
548 CoreDispatcher ();\r
549 PERF_END (0, "CoreDispatcher", "DxeMain", 0);\r
550\r
551 //\r
552 // Display Architectural protocols that were not loaded if this is DEBUG build\r
553 //\r
2ce31132 554 DEBUG_CODE_BEGIN ();\r
ef99a95a 555 CoreDisplayMissingArchProtocols ();\r
2ce31132 556 DEBUG_CODE_END ();\r
ef99a95a 557 \r
558 //\r
559 // Assert if the Architectural Protocols are not present.\r
560 //\r
561 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());\r
562\r
563 //\r
564 // Report Status code before transfer control to BDS\r
565 //\r
566 CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT));\r
567 //\r
568 // Display any drivers that were not dispatched because dependency expression\r
569 // evaluated to false if this is a debug build\r
570 //\r
2ce31132 571 DEBUG_CODE_BEGIN ();\r
ef99a95a 572 CoreDisplayDiscoveredNotDispatched ();\r
2ce31132 573 DEBUG_CODE_END ();\r
ef99a95a 574\r
575 //\r
576 // Transfer control to the BDS Architectural Protocol\r
577 //\r
578 gBds->Entry (gBds);\r
579 \r
580 //\r
581 // BDS should never return\r
582 //\r
583 ASSERT (FALSE);\r
584 CpuDeadLoop ();\r
585}\r
586\r
587\r
588EFI_STATUS\r
589EFIAPI\r
590CoreEfiNotAvailableYetArg0 (\r
591 VOID\r
592 )\r
593/*++\r
594\r
595Routine Description:\r
596\r
597 Place holder function until all the Boot Services and Runtime Services are available\r
598\r
599Arguments:\r
600\r
601 None\r
602\r
603Returns:\r
604\r
605 EFI_NOT_AVAILABLE_YET\r
606\r
607--*/\r
608{\r
609 //\r
610 // This function should never be executed. If it does, then the architectural protocols\r
611 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
612 // DXE Core and all the Architectural Protocols are complete.\r
613 //\r
614\r
615 return EFI_NOT_AVAILABLE_YET;\r
616}\r
617\r
618EFI_STATUS\r
619EFIAPI\r
620CoreEfiNotAvailableYetArg1 (\r
621 UINTN Arg1\r
622 )\r
623/*++\r
624\r
625Routine Description:\r
626\r
627 Place holder function until all the Boot Services and Runtime Services are available\r
628\r
629Arguments:\r
630\r
631 Arg1 - Undefined\r
632\r
633Returns:\r
634\r
635 EFI_NOT_AVAILABLE_YET\r
636\r
637--*/\r
638{\r
639 //\r
640 // This function should never be executed. If it does, then the architectural protocols\r
641 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
642 // DXE Core and all the Architectural Protocols are complete.\r
643 //\r
644\r
645 return EFI_NOT_AVAILABLE_YET;\r
646}\r
647\r
648EFI_STATUS\r
649EFIAPI\r
650CoreEfiNotAvailableYetArg2 (\r
651 UINTN Arg1,\r
652 UINTN Arg2\r
653 )\r
654/*++\r
655\r
656Routine Description:\r
657\r
658 Place holder function until all the Boot Services and Runtime Services are available\r
659\r
660Arguments:\r
661\r
662 Arg1 - Undefined\r
663 \r
664 Arg2 - Undefined\r
665\r
666Returns:\r
667\r
668 EFI_NOT_AVAILABLE_YET\r
669\r
670--*/\r
671{\r
672 //\r
673 // This function should never be executed. If it does, then the architectural protocols\r
674 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
675 // DXE Core and all the Architectural Protocols are complete.\r
676 //\r
677\r
678 return EFI_NOT_AVAILABLE_YET;\r
679}\r
680\r
681EFI_STATUS\r
682EFIAPI\r
683CoreEfiNotAvailableYetArg3 (\r
684 UINTN Arg1,\r
685 UINTN Arg2,\r
686 UINTN Arg3\r
687 )\r
688/*++\r
689\r
690Routine Description:\r
691\r
692 Place holder function until all the Boot Services and Runtime Services are available\r
693\r
694Arguments:\r
695\r
696 Arg1 - Undefined\r
697 \r
698 Arg2 - Undefined\r
699 \r
700 Arg3 - Undefined\r
701\r
702Returns:\r
703\r
704 EFI_NOT_AVAILABLE_YET\r
705\r
706--*/\r
707{\r
708 //\r
709 // This function should never be executed. If it does, then the architectural protocols\r
710 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
711 // DXE Core and all the Architectural Protocols are complete.\r
712 //\r
713\r
714 return EFI_NOT_AVAILABLE_YET;\r
715}\r
716\r
717EFI_STATUS\r
718EFIAPI\r
719CoreEfiNotAvailableYetArg4 (\r
720 UINTN Arg1,\r
721 UINTN Arg2,\r
722 UINTN Arg3,\r
723 UINTN Arg4\r
724 )\r
725/*++\r
726\r
727Routine Description:\r
728\r
729 Place holder function until all the Boot Services and Runtime Services are available\r
730\r
731Arguments:\r
732\r
733 Arg1 - Undefined\r
734 \r
735 Arg2 - Undefined\r
736 \r
737 Arg3 - Undefined\r
738 \r
739 Arg4 - Undefined\r
740\r
741Returns:\r
742\r
743 EFI_NOT_AVAILABLE_YET\r
744\r
745--*/\r
746{\r
747 //\r
748 // This function should never be executed. If it does, then the architectural protocols\r
749 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
750 // DXE Core and all the Architectural Protocols are complete.\r
751 //\r
752\r
753 return EFI_NOT_AVAILABLE_YET;\r
754}\r
755\r
756EFI_STATUS\r
757EFIAPI\r
758CoreEfiNotAvailableYetArg5 (\r
759 UINTN Arg1,\r
760 UINTN Arg2,\r
761 UINTN Arg3,\r
762 UINTN Arg4,\r
763 UINTN Arg5\r
764 )\r
765/*++\r
766\r
767Routine Description:\r
768\r
769 Place holder function until all the Boot Services and Runtime Services are available\r
770\r
771Arguments:\r
772\r
773 Arg1 - Undefined\r
774 \r
775 Arg2 - Undefined\r
776 \r
777 Arg3 - Undefined\r
778 \r
779 Arg4 - Undefined\r
780 \r
781 Arg5 - Undefined\r
782\r
783Returns:\r
784\r
785 EFI_NOT_AVAILABLE_YET\r
786\r
787--*/\r
788{\r
789 //\r
790 // This function should never be executed. If it does, then the architectural protocols\r
791 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
792 // DXE Core and all the Architectural Protocols are complete.\r
793 //\r
794\r
795 return EFI_NOT_AVAILABLE_YET;\r
796}\r
797\r
798\r
799EFI_STATUS\r
800CoreGetPeiProtocol (\r
801 IN EFI_GUID *ProtocolGuid,\r
802 IN VOID **Interface\r
803 )\r
804/*++\r
805\r
806Routine Description:\r
807\r
808 Searches for a Protocol Interface passed from PEI through a HOB\r
809\r
810Arguments:\r
811\r
812 ProtocolGuid - The Protocol GUID to search for in the HOB List\r
813\r
814 Interface - A pointer to the interface for the Protocol GUID\r
815\r
816Returns:\r
817\r
818 EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface\r
819\r
820 EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List\r
821\r
822--*/\r
823{\r
824 EFI_HOB_GUID_TYPE *GuidHob;\r
825 VOID *Buffer;\r
826\r
827 GuidHob = GetNextGuidHob (ProtocolGuid, mHobStart);\r
828 if (GuidHob == NULL) {\r
829 return EFI_NOT_FOUND;\r
830 }\r
831 \r
832 Buffer = GET_GUID_HOB_DATA (GuidHob);\r
833 ASSERT (Buffer != NULL);\r
834\r
835 *Interface = (VOID *)(*(UINTN *)(Buffer));\r
836\r
837 return EFI_SUCCESS;\r
838}\r
839\r
840\r
841VOID\r
842CalculateEfiHdrCrc (\r
843 IN OUT EFI_TABLE_HEADER *Hdr\r
844 )\r
845/*++\r
846\r
847Routine Description:\r
848\r
849 Calcualte the 32-bit CRC in a EFI table using the service provided by the\r
850 gRuntime service.\r
851\r
852Arguments:\r
853\r
854 Hdr - Pointer to an EFI standard header\r
855\r
856Returns:\r
857\r
858 None\r
859\r
860--*/\r
861{\r
862 UINT32 Crc;\r
863\r
864 Hdr->CRC32 = 0;\r
865 \r
866 //\r
867 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
868 // Crc will come back as zero if we set it to zero here\r
869 //\r
870 Crc = 0;\r
871 gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
872 Hdr->CRC32 = Crc; \r
873}\r
874\r
875\r
876\r
877EFI_STATUS\r
878EFIAPI\r
879CoreExitBootServices (\r
880 IN EFI_HANDLE ImageHandle,\r
881 IN UINTN MapKey\r
882 )\r
883/*++\r
884\r
885Routine Description:\r
886\r
887 EFI 1.0 API to terminate Boot Services\r
888\r
889Arguments:\r
890\r
891 ImageHandle - Handle that represents the identity of the calling image\r
892\r
893 MapKey -Key to the latest memory map.\r
894\r
895Returns:\r
896\r
897 EFI_SUCCESS - Boot Services terminated\r
898 EFI_INVALID_PARAMETER - MapKey is incorrect.\r
899\r
900--*/\r
901{\r
902 EFI_STATUS Status;\r
903\r
904 //\r
905 // Terminate memory services if the MapKey matches\r
906 //\r
907 Status = CoreTerminateMemoryMap (MapKey);\r
908 if (EFI_ERROR (Status)) {\r
909 return Status;\r
910 }\r
911\r
912 //\r
913 // Notify other drivers that we are exiting boot services.\r
914 //\r
915 CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r
916\r
917 //\r
918 // Disable Timer\r
919 //\r
920 gTimer->SetTimerPeriod (gTimer, 0);\r
921\r
922 //\r
923 // Disable CPU Interrupts\r
924 //\r
925 gCpu->DisableInterrupt (gCpu);\r
926\r
927 //\r
928 // Register Runtime events with the Runtime Architectural Protocol\r
929 //\r
930 CoreShutdownEventServices ();\r
931\r
932 //\r
933 // Register Runtime images with the Runtime Architectural Protocol\r
934 //\r
935 CoreShutdownImageServices ();\r
936\r
937 //\r
938 // Report that ExitBootServices() has been called\r
939 //\r
940 // We are using gEfiDxeServicesTableGuid as the caller ID for Dxe Core\r
941 //\r
942 CoreReportProgressCode ((EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES));\r
943\r
944 //\r
945 // Clear the non-runtime values of the EFI System Table\r
946 //\r
947 gST->BootServices = NULL;\r
948 gST->ConIn = NULL;\r
949 gST->ConsoleInHandle = NULL;\r
950 gST->ConOut = NULL;\r
951 gST->ConsoleOutHandle = NULL;\r
952 gST->StdErr = NULL;\r
953 gST->StandardErrorHandle = NULL;\r
954\r
955 //\r
956 // Recompute the 32-bit CRC of the EFI System Table\r
957 //\r
958 CalculateEfiHdrCrc (&gST->Hdr);\r
959\r
960 //\r
961 // Zero out the Boot Service Table\r
962 //\r
963 SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);\r
964 gBS = NULL;\r
965\r
966 return Status;\r
967}\r
968\r
969EFI_STATUS\r
970DxeMainUefiDecompressGetInfo (\r
971 IN EFI_DECOMPRESS_PROTOCOL *This,\r
972 IN VOID *Source,\r
973 IN UINT32 SourceSize,\r
974 OUT UINT32 *DestinationSize,\r
975 OUT UINT32 *ScratchSize\r
976 )\r
977{\r
978 return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
979}\r
980\r
981EFI_STATUS\r
982EFIAPI\r
983DxeMainUefiDecompress (\r
984 IN EFI_DECOMPRESS_PROTOCOL *This,\r
985 IN VOID *Source,\r
986 IN UINT32 SourceSize,\r
987 IN OUT VOID *Destination,\r
988 IN UINT32 DestinationSize,\r
989 IN OUT VOID *Scratch,\r
990 IN UINT32 ScratchSize\r
991 )\r
992{\r
993 EFI_STATUS Status;\r
994 UINT32 TestDestinationSize;\r
995 UINT32 TestScratchSize;\r
996\r
997 Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
998 if (EFI_ERROR (Status)) {\r
999 return Status;\r
1000 }\r
1001\r
1002 if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) {\r
1003 return RETURN_INVALID_PARAMETER;\r
1004 }\r
1005\r
1006 return UefiDecompress (Source, Destination, Scratch);\r
1007}\r
1008\r
1009EFI_STATUS\r
1010DxeMainTianoDecompressGetInfo (\r
1011 IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
1012 IN VOID *Source,\r
1013 IN UINT32 SourceSize,\r
1014 OUT UINT32 *DestinationSize,\r
1015 OUT UINT32 *ScratchSize\r
1016 )\r
1017{\r
1018 return TianoDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
1019}\r
1020\r
1021EFI_STATUS\r
1022EFIAPI\r
1023DxeMainTianoDecompress (\r
1024 IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,\r
1025 IN VOID *Source,\r
1026 IN UINT32 SourceSize,\r
1027 IN OUT VOID *Destination,\r
1028 IN UINT32 DestinationSize,\r
1029 IN OUT VOID *Scratch,\r
1030 IN UINT32 ScratchSize\r
1031 )\r
1032{\r
1033 EFI_STATUS Status;\r
1034 UINT32 TestDestinationSize;\r
1035 UINT32 TestScratchSize;\r
1036\r
1037 Status = TianoDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
1038 if (EFI_ERROR (Status)) {\r
1039 return Status;\r
1040 }\r
1041\r
1042 if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) {\r
1043 return RETURN_INVALID_PARAMETER;\r
1044 }\r
1045\r
1046 return TianoDecompress (Source, Destination, Scratch);\r
1047}\r
1048\r
1049EFI_STATUS\r
1050DxeMainCustomDecompressGetInfo (\r
1051 IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,\r
1052 IN VOID *Source,\r
1053 IN UINT32 SourceSize,\r
1054 OUT UINT32 *DestinationSize,\r
1055 OUT UINT32 *ScratchSize\r
1056 )\r
1057{\r
1058 return CustomDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
1059}\r
1060\r
1061EFI_STATUS\r
1062EFIAPI\r
1063DxeMainCustomDecompress (\r
1064 IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,\r
1065 IN VOID *Source,\r
1066 IN UINT32 SourceSize,\r
1067 IN OUT VOID *Destination,\r
1068 IN UINT32 DestinationSize,\r
1069 IN OUT VOID *Scratch,\r
1070 IN UINT32 ScratchSize\r
1071 )\r
1072{\r
1073 EFI_STATUS Status;\r
1074 UINT32 TestDestinationSize;\r
1075 UINT32 TestScratchSize;\r
1076\r
1077 Status = CustomDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
1078 if (EFI_ERROR (Status)) {\r
1079 return Status;\r
1080 }\r
1081\r
1082 if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) {\r
1083 return RETURN_INVALID_PARAMETER;\r
1084 }\r
1085\r
1086 return CustomDecompress (Source, Destination, Scratch);\r
1087}\r
1088\r