]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
Clean up HOB debug prints
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain / DxeMain.c
CommitLineData
31f228cf 1/** @file\r
2 DXE Core Main Entry Point\r
3\r
f9876ecf 4Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
31f228cf 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "DxeMain.h"\r
16\r
17//\r
18// DXE Core Global Variables for Protocols from PEI\r
19//\r
20EFI_HANDLE mDecompressHandle = NULL;\r
21\r
22//\r
23// DXE Core globals for Architecture Protocols\r
24//\r
25EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;\r
26EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;\r
27EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;\r
28EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;\r
29EFI_BDS_ARCH_PROTOCOL *gBds = NULL;\r
30EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;\r
31\r
0803854b 32//\r
33// DXE Core globals for optional protocol dependencies\r
34//\r
35EFI_SMM_BASE2_PROTOCOL *gSmmBase2 = NULL;\r
36\r
31f228cf 37//\r
38// DXE Core Global used to update core loaded image protocol handle\r
39//\r
40EFI_GUID *gDxeCoreFileName;\r
41EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;\r
42\r
43//\r
44// DXE Core Module Variables\r
45//\r
46EFI_BOOT_SERVICES mBootServices = {\r
47 {\r
48 EFI_BOOT_SERVICES_SIGNATURE, // Signature\r
49 EFI_BOOT_SERVICES_REVISION, // Revision\r
50 sizeof (EFI_BOOT_SERVICES), // HeaderSize\r
51 0, // CRC32\r
52 0 // Reserved\r
53 },\r
54 (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL\r
55 (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL\r
56 (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages\r
57 (EFI_FREE_PAGES) CoreFreePages, // FreePages\r
58 (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap\r
59 (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool\r
60 (EFI_FREE_POOL) CoreFreePool, // FreePool\r
61 (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent\r
62 (EFI_SET_TIMER) CoreSetTimer, // SetTimer\r
63 (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent\r
64 (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent\r
65 (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent\r
66 (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent\r
67 (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface\r
68 (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface\r
69 (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface\r
70 (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol\r
71 (VOID *) NULL, // Reserved\r
72 (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify\r
73 (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle\r
74 (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath\r
75 (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable\r
76 (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage\r
77 (EFI_IMAGE_START) CoreStartImage, // StartImage\r
78 (EFI_EXIT) CoreExit, // Exit\r
79 (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage\r
80 (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices\r
81 (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount\r
82 (EFI_STALL) CoreStall, // Stall\r
83 (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer\r
84 (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController\r
85 (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController\r
86 (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol\r
87 (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol\r
88 (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation\r
89 (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle\r
90 (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer\r
91 (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol\r
92 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces\r
93 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces\r
94 (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32\r
95 (EFI_COPY_MEM) CopyMem, // CopyMem\r
96 (EFI_SET_MEM) SetMem, // SetMem\r
97 (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx\r
98};\r
99\r
100EFI_DXE_SERVICES mDxeServices = {\r
101 {\r
102 DXE_SERVICES_SIGNATURE, // Signature\r
103 DXE_SERVICES_REVISION, // Revision\r
104 sizeof (DXE_SERVICES), // HeaderSize\r
105 0, // CRC32\r
106 0 // Reserved\r
107 },\r
108 (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace\r
109 (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace\r
110 (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace\r
111 (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace\r
112 (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor\r
113 (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes\r
114 (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap\r
115 (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace\r
116 (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace\r
117 (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace\r
118 (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace\r
119 (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor\r
120 (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap\r
121 (EFI_DISPATCH) CoreDispatcher, // Dispatch\r
122 (EFI_SCHEDULE) CoreSchedule, // Schedule\r
123 (EFI_TRUST) CoreTrust, // Trust\r
124 (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume\r
125};\r
126\r
127EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {\r
128 {\r
129 EFI_SYSTEM_TABLE_SIGNATURE, // Signature\r
130 EFI_SYSTEM_TABLE_REVISION, // Revision\r
131 sizeof (EFI_SYSTEM_TABLE), // HeaderSize\r
132 0, // CRC32\r
133 0 // Reserved\r
134 },\r
135 NULL, // FirmwareVendor\r
136 0, // FirmwareRevision\r
137 NULL, // ConsoleInHandle\r
138 NULL, // ConIn\r
139 NULL, // ConsoleOutHandle\r
140 NULL, // ConOut\r
141 NULL, // StandardErrorHandle\r
142 NULL, // StdErr\r
143 NULL, // RuntimeServices\r
144 &mBootServices, // BootServices\r
145 0, // NumberOfConfigurationTableEntries\r
146 NULL // ConfigurationTable\r
147};\r
148\r
149EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {\r
150 {\r
151 EFI_RUNTIME_SERVICES_SIGNATURE, // Signature\r
152 EFI_RUNTIME_SERVICES_REVISION, // Revision\r
153 sizeof (EFI_RUNTIME_SERVICES), // HeaderSize\r
154 0, // CRC32\r
155 0 // Reserved\r
156 },\r
157 (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime\r
158 (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime\r
159 (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime\r
160 (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime\r
161 (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap\r
162 (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer\r
163 (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable\r
164 (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName\r
165 (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable\r
166 (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount\r
167 (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4, // ResetSystem\r
168 (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule\r
169 (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities\r
170 (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo\r
171};\r
172\r
173EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {\r
174 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),\r
175 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),\r
176\r
177 //\r
178 // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r
179 // prevent people from having pointer math bugs in their code.\r
180 // now you have to use *DescriptorSize to make things work.\r
181 //\r
182 sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),\r
183 EFI_MEMORY_DESCRIPTOR_VERSION,\r
184 0,\r
185 NULL,\r
186 NULL,\r
187 FALSE,\r
188 FALSE\r
189};\r
190\r
191EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;\r
192\r
193//\r
194// DXE Core Global Variables for the EFI System Table, Boot Services Table,\r
195// DXE Services Table, and Runtime Services Table\r
196//\r
197EFI_DXE_SERVICES *gDxeCoreDS = &mDxeServices;\r
198EFI_SYSTEM_TABLE *gDxeCoreST = NULL;\r
199\r
200//\r
201// For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory\r
202// but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it\r
203// a value that will not cause debug infrastructure to crash early on.\r
204//\r
205EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;\r
206EFI_HANDLE gDxeCoreImageHandle = NULL;\r
207\r
208\r
209//\r
210// EFI Decompress Protocol\r
211//\r
212EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {\r
213 DxeMainUefiDecompressGetInfo,\r
214 DxeMainUefiDecompress\r
215};\r
216\r
217//\r
54ea99a7 218// For Loading modules at fixed address feature, the configuration table is to cache the top address below which to load \r
219// Runtime code&boot time code \r
220//\r
ebfb7bb5 221GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable = {0, 0};\r
54ea99a7 222\r
31f228cf 223// Main entry point to the DXE Core\r
224//\r
225\r
226/**\r
227 Main entry point to DXE Core.\r
228\r
229 @param HobStart Pointer to the beginning of the HOB List from PEI.\r
230\r
231 @return This function should never return.\r
232\r
233**/\r
234VOID\r
235EFIAPI\r
236DxeMain (\r
237 IN VOID *HobStart\r
238 )\r
239{\r
240 EFI_STATUS Status;\r
241 EFI_PHYSICAL_ADDRESS MemoryBaseAddress;\r
242 UINT64 MemoryLength;\r
243\r
244 //\r
245 // Initialize Memory Services\r
246 //\r
247 CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);\r
248\r
249 //\r
250 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r
251 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r
252 //\r
253 gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r
254 ASSERT (gDxeCoreST != NULL);\r
255\r
256 gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r
257 ASSERT (gDxeCoreRT != NULL);\r
258\r
259 gDxeCoreST->RuntimeServices = gDxeCoreRT;\r
260\r
261 //\r
262 // Start the Image Services.\r
263 //\r
264 Status = CoreInitializeImageServices (HobStart);\r
265 ASSERT_EFI_ERROR (Status);\r
266\r
267 //\r
268 // Call constructor for all libraries\r
269 //\r
270 ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);\r
271 PERF_END (NULL,"PEI", NULL, 0) ;\r
272 PERF_START (NULL,"DXE", NULL, 0) ;\r
273\r
274 //\r
275 // Initialize the Global Coherency Domain Services\r
276 //\r
277 Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);\r
278 ASSERT_EFI_ERROR (Status);\r
279\r
280 //\r
281 // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
282 //\r
283 Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);\r
284 ASSERT_EFI_ERROR (Status);\r
285\r
286 //\r
287 // Install the HOB List into the EFI System Tables's Configuration Table\r
288 //\r
289 Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);\r
290 ASSERT_EFI_ERROR (Status);\r
291\r
292 //\r
293 // Install Memory Type Information Table into the EFI System Tables's Configuration Table\r
294 //\r
295 Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);\r
296 ASSERT_EFI_ERROR (Status);\r
54ea99a7 297 \r
298 //\r
299 // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address \r
300 // Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI\r
301 // Code and Tseg base to load SMM driver. \r
302 //\r
852081fc 303 if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {\r
54ea99a7 304 Status = CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid, &gLoadModuleAtFixAddressConfigurationTable);\r
305 ASSERT_EFI_ERROR (Status);\r
306 }\r
31f228cf 307 //\r
308 // Report Status Code here for DXE_ENTRY_POINT once it is available\r
309 //\r
310 REPORT_STATUS_CODE (\r
311 EFI_PROGRESS_CODE,\r
f9876ecf 312 (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT)\r
31f228cf 313 );\r
314\r
315 //\r
316 // Create the aligned system table pointer structure that is used by external\r
317 // debuggers to locate the system table... Also, install debug image info\r
318 // configuration table.\r
319 //\r
320 CoreInitializeDebugImageInfoTable ();\r
321 CoreNewDebugImageInfoEntry (\r
322 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,\r
323 gDxeCoreLoadedImage,\r
324 gDxeCoreImageHandle\r
325 );\r
326\r
327 DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%p\n", HobStart));\r
328\r
329 DEBUG_CODE_BEGIN ();\r
330 EFI_PEI_HOB_POINTERS Hob;\r
331\r
332 for (Hob.Raw = HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
333 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r
8e90dd6b 334 DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Memory Allocation 0x%08x 0x%0lx - 0x%0lx\n", \\r
bfef82a1 335 Hob.MemoryAllocation->AllocDescriptor.MemoryType, \\r
31f228cf 336 Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress, \\r
bfef82a1 337 Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength - 1));\r
31f228cf 338 }\r
339 }\r
340 for (Hob.Raw = HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
341 if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) {\r
8e90dd6b 342 DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV2 Hob 0x%08x 0x%0lx - 0x%0lx\n", Hob.ResourceDescriptor->ResourceType, Hob.FirmwareVolume2->BaseAddress, Hob.FirmwareVolume2->BaseAddress + Hob.FirmwareVolume2->Length - 1));\r
31f228cf 343 } else if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) {\r
8e90dd6b 344 DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV Hob 0x%08x 0x%0lx - 0x%0lx\n", Hob.ResourceDescriptor->ResourceType, Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->BaseAddress + Hob.FirmwareVolume2->Length - 1));\r
31f228cf 345 }\r
346 }\r
347 DEBUG_CODE_END ();\r
348\r
349 //\r
350 // Initialize the Event Services\r
351 //\r
352 Status = CoreInitializeEventServices ();\r
353 ASSERT_EFI_ERROR (Status);\r
354\r
355\r
356 //\r
357 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r
358 //\r
359 // These Protocols are not architectural. This implementation is sharing code between\r
360 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented\r
361 // as part of the DXE Core. However, that would also require the DXE Core to be ported\r
362 // each time a different CPU is used, a different Decompression algorithm is used, or a\r
363 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains\r
364 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,\r
365 // and from CPU to CPU.\r
366 //\r
367\r
368 //\r
369 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components\r
370 //\r
371 Status = CoreInstallMultipleProtocolInterfaces (\r
372 &mDecompressHandle,\r
373 &gEfiDecompressProtocolGuid, &gEfiDecompress,\r
374 NULL\r
375 );\r
376 ASSERT_EFI_ERROR (Status);\r
377\r
378 //\r
379 // Register for the GUIDs of the Architectural Protocols, so the rest of the\r
380 // EFI Boot Services and EFI Runtime Services tables can be filled in.\r
381 //\r
382 CoreNotifyOnArchProtocolInstallation ();\r
383\r
384 //\r
385 // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r
386 //\r
387 Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r
388 ASSERT_EFI_ERROR (Status);\r
389\r
390 Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r
391 ASSERT_EFI_ERROR (Status);\r
392\r
393 //\r
394 // Produce the Section Extraction Protocol\r
395 //\r
396 Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);\r
397 ASSERT_EFI_ERROR (Status);\r
398\r
399 //\r
400 // Initialize the DXE Dispatcher\r
401 //\r
402 PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ;\r
403 CoreInitializeDispatcher ();\r
404 PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ;\r
405\r
406 //\r
407 // Invoke the DXE Dispatcher\r
408 //\r
409 PERF_START (NULL, "CoreDispatcher", "DxeMain", 0);\r
410 CoreDispatcher ();\r
411 PERF_END (NULL, "CoreDispatcher", "DxeMain", 0);\r
412\r
413 //\r
414 // Display Architectural protocols that were not loaded if this is DEBUG build\r
415 //\r
416 DEBUG_CODE_BEGIN ();\r
417 CoreDisplayMissingArchProtocols ();\r
418 DEBUG_CODE_END ();\r
419\r
420 //\r
421 // Display any drivers that were not dispatched because dependency expression\r
422 // evaluated to false if this is a debug build\r
423 //\r
424 DEBUG_CODE_BEGIN ();\r
425 CoreDisplayDiscoveredNotDispatched ();\r
426 DEBUG_CODE_END ();\r
427\r
428 //\r
429 // Assert if the Architectural Protocols are not present.\r
430 //\r
431 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());\r
432\r
433 //\r
434 // Report Status code before transfer control to BDS\r
435 //\r
436 REPORT_STATUS_CODE (\r
437 EFI_PROGRESS_CODE,\r
f9876ecf 438 (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)\r
31f228cf 439 );\r
440\r
441 //\r
442 // Transfer control to the BDS Architectural Protocol\r
443 //\r
444 gBds->Entry (gBds);\r
445\r
446 //\r
447 // BDS should never return\r
448 //\r
449 ASSERT (FALSE);\r
450 CpuDeadLoop ();\r
451}\r
452\r
453\r
454\r
455/**\r
456 Place holder function until all the Boot Services and Runtime Services are\r
457 available.\r
458\r
459 @return EFI_NOT_AVAILABLE_YET\r
460\r
461**/\r
462EFI_STATUS\r
463EFIAPI\r
464CoreEfiNotAvailableYetArg0 (\r
465 VOID\r
466 )\r
467{\r
468 //\r
469 // This function should never be executed. If it does, then the architectural protocols\r
470 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
471 // DXE Core and all the Architectural Protocols are complete.\r
472 //\r
473\r
474 return EFI_NOT_AVAILABLE_YET;\r
475}\r
476\r
477\r
478/**\r
479 Place holder function until all the Boot Services and Runtime Services are\r
480 available.\r
481\r
482 @param Arg1 Undefined\r
483\r
484 @return EFI_NOT_AVAILABLE_YET\r
485\r
486**/\r
487EFI_STATUS\r
488EFIAPI\r
489CoreEfiNotAvailableYetArg1 (\r
490 UINTN Arg1\r
491 )\r
492{\r
493 //\r
494 // This function should never be executed. If it does, then the architectural protocols\r
495 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
496 // DXE Core and all the Architectural Protocols are complete.\r
497 //\r
498\r
499 return EFI_NOT_AVAILABLE_YET;\r
500}\r
501\r
502\r
503/**\r
504 Place holder function until all the Boot Services and Runtime Services are available.\r
505\r
506 @param Arg1 Undefined\r
507 @param Arg2 Undefined\r
508\r
509 @return EFI_NOT_AVAILABLE_YET\r
510\r
511**/\r
512EFI_STATUS\r
513EFIAPI\r
514CoreEfiNotAvailableYetArg2 (\r
515 UINTN Arg1,\r
516 UINTN Arg2\r
517 )\r
518{\r
519 //\r
520 // This function should never be executed. If it does, then the architectural protocols\r
521 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
522 // DXE Core and all the Architectural Protocols are complete.\r
523 //\r
524\r
525 return EFI_NOT_AVAILABLE_YET;\r
526}\r
527\r
528\r
529/**\r
530 Place holder function until all the Boot Services and Runtime Services are available.\r
531\r
532 @param Arg1 Undefined\r
533 @param Arg2 Undefined\r
534 @param Arg3 Undefined\r
535\r
536 @return EFI_NOT_AVAILABLE_YET\r
537\r
538**/\r
539EFI_STATUS\r
540EFIAPI\r
541CoreEfiNotAvailableYetArg3 (\r
542 UINTN Arg1,\r
543 UINTN Arg2,\r
544 UINTN Arg3\r
545 )\r
546{\r
547 //\r
548 // This function should never be executed. If it does, then the architectural protocols\r
549 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
550 // DXE Core and all the Architectural Protocols are complete.\r
551 //\r
552\r
553 return EFI_NOT_AVAILABLE_YET;\r
554}\r
555\r
556\r
557/**\r
558 Place holder function until all the Boot Services and Runtime Services are available.\r
559\r
560 @param Arg1 Undefined\r
561 @param Arg2 Undefined\r
562 @param Arg3 Undefined\r
563 @param Arg4 Undefined\r
564\r
565 @return EFI_NOT_AVAILABLE_YET\r
566\r
567**/\r
568EFI_STATUS\r
569EFIAPI\r
570CoreEfiNotAvailableYetArg4 (\r
571 UINTN Arg1,\r
572 UINTN Arg2,\r
573 UINTN Arg3,\r
574 UINTN Arg4\r
575 )\r
576{\r
577 //\r
578 // This function should never be executed. If it does, then the architectural protocols\r
579 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r
580 // DXE Core and all the Architectural Protocols are complete.\r
581 //\r
582\r
583 return EFI_NOT_AVAILABLE_YET;\r
584}\r
585\r
586\r
587/**\r
588 Place holder function until all the Boot Services and Runtime Services are available.\r
589\r
590 @param Arg1 Undefined\r
591 @param Arg2 Undefined\r
592 @param Arg3 Undefined\r
593 @param Arg4 Undefined\r
594 @param Arg5 Undefined\r
595\r
596 @return EFI_NOT_AVAILABLE_YET\r
597\r
598**/\r
599EFI_STATUS\r
600EFIAPI\r
601CoreEfiNotAvailableYetArg5 (\r
602 UINTN Arg1,\r
603 UINTN Arg2,\r
604 UINTN Arg3,\r
605 UINTN Arg4,\r
606 UINTN Arg5\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
618\r
619/**\r
620 Calcualte the 32-bit CRC in a EFI table using the service provided by the\r
621 gRuntime service.\r
622\r
623 @param Hdr Pointer to an EFI standard header\r
624\r
625**/\r
626VOID\r
627CalculateEfiHdrCrc (\r
628 IN OUT EFI_TABLE_HEADER *Hdr\r
629 )\r
630{\r
631 UINT32 Crc;\r
632\r
633 Hdr->CRC32 = 0;\r
634\r
635 //\r
636 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
637 // Crc will come back as zero if we set it to zero here\r
638 //\r
639 Crc = 0;\r
640 gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
641 Hdr->CRC32 = Crc;\r
642}\r
643\r
644\r
645/**\r
646 Terminates all boot services.\r
647\r
648 @param ImageHandle Handle that identifies the exiting image.\r
649 @param MapKey Key to the latest memory map.\r
650\r
651 @retval EFI_SUCCESS Boot Services terminated\r
652 @retval EFI_INVALID_PARAMETER MapKey is incorrect.\r
653\r
654**/\r
655EFI_STATUS\r
656EFIAPI\r
657CoreExitBootServices (\r
658 IN EFI_HANDLE ImageHandle,\r
659 IN UINTN MapKey\r
660 )\r
661{\r
662 EFI_STATUS Status;\r
663\r
664 //\r
665 // Terminate memory services if the MapKey matches\r
666 //\r
667 Status = CoreTerminateMemoryMap (MapKey);\r
668 if (EFI_ERROR (Status)) {\r
669 return Status;\r
670 }\r
671\r
672 //\r
673 // Disable Timer\r
674 //\r
675 gTimer->SetTimerPeriod (gTimer, 0);\r
676\r
677 //\r
678 // Notify other drivers that we are exiting boot services.\r
679 //\r
680 CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r
681\r
682 //\r
683 // Disable CPU Interrupts\r
684 //\r
685 gCpu->DisableInterrupt (gCpu);\r
686\r
687 //\r
688 // Report that ExitBootServices() has been called\r
689 //\r
690 REPORT_STATUS_CODE (\r
691 EFI_PROGRESS_CODE,\r
f9876ecf 692 (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)\r
31f228cf 693 );\r
694\r
695 //\r
696 // Clear the non-runtime values of the EFI System Table\r
697 //\r
698 gDxeCoreST->BootServices = NULL;\r
699 gDxeCoreST->ConIn = NULL;\r
700 gDxeCoreST->ConsoleInHandle = NULL;\r
701 gDxeCoreST->ConOut = NULL;\r
702 gDxeCoreST->ConsoleOutHandle = NULL;\r
703 gDxeCoreST->StdErr = NULL;\r
704 gDxeCoreST->StandardErrorHandle = NULL;\r
705\r
706 //\r
707 // Recompute the 32-bit CRC of the EFI System Table\r
708 //\r
709 CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
710\r
711 //\r
712 // Zero out the Boot Service Table\r
713 //\r
714 ZeroMem (gBS, sizeof (EFI_BOOT_SERVICES));\r
715 gBS = NULL;\r
716\r
717 //\r
718 // Update the AtRuntime field in Runtiem AP.\r
719 //\r
720 gRuntime->AtRuntime = TRUE;\r
721\r
722 return Status;\r
723}\r
724\r
725\r
726/**\r
727 Given a compressed source buffer, this function retrieves the size of the\r
728 uncompressed buffer and the size of the scratch buffer required to decompress\r
729 the compressed source buffer.\r
730\r
731 The GetInfo() function retrieves the size of the uncompressed buffer and the\r
732 temporary scratch buffer required to decompress the buffer specified by Source\r
733 and SourceSize. If the size of the uncompressed buffer or the size of the\r
734 scratch buffer cannot be determined from the compressed data specified by\r
735 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the\r
736 size of the uncompressed buffer is returned in DestinationSize, the size of\r
737 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.\r
738 The GetInfo() function does not have scratch buffer available to perform a\r
739 thorough checking of the validity of the source data. It just retrieves the\r
740 "Original Size" field from the beginning bytes of the source data and output\r
741 it as DestinationSize. And ScratchSize is specific to the decompression\r
742 implementation.\r
743\r
744 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r
745 @param Source The source buffer containing the compressed data.\r
746 @param SourceSize The size, in bytes, of the source buffer.\r
747 @param DestinationSize A pointer to the size, in bytes, of the\r
748 uncompressed buffer that will be generated when the\r
749 compressed buffer specified by Source and\r
750 SourceSize is decompressed.\r
751 @param ScratchSize A pointer to the size, in bytes, of the scratch\r
752 buffer that is required to decompress the\r
753 compressed buffer specified by Source and\r
754 SourceSize.\r
755\r
756 @retval EFI_SUCCESS The size of the uncompressed data was returned in\r
757 DestinationSize and the size of the scratch buffer\r
758 was returned in ScratchSize.\r
759 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of\r
760 the scratch buffer cannot be determined from the\r
761 compressed data specified by Source and\r
762 SourceSize.\r
763\r
764**/\r
765EFI_STATUS\r
766EFIAPI\r
767DxeMainUefiDecompressGetInfo (\r
768 IN EFI_DECOMPRESS_PROTOCOL *This,\r
769 IN VOID *Source,\r
770 IN UINT32 SourceSize,\r
771 OUT UINT32 *DestinationSize,\r
772 OUT UINT32 *ScratchSize\r
773 )\r
774{\r
775 if (Source == NULL || DestinationSize == NULL || ScratchSize == NULL) {\r
776 return EFI_INVALID_PARAMETER;\r
777 }\r
778 return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
779}\r
780\r
781\r
782/**\r
783 Decompresses a compressed source buffer.\r
784\r
785 The Decompress() function extracts decompressed data to its original form.\r
786 This protocol is designed so that the decompression algorithm can be\r
787 implemented without using any memory services. As a result, the Decompress()\r
788 Function is not allowed to call AllocatePool() or AllocatePages() in its\r
789 implementation. It is the caller's responsibility to allocate and free the\r
790 Destination and Scratch buffers.\r
791 If the compressed source data specified by Source and SourceSize is\r
792 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If\r
793 the compressed source data specified by Source and SourceSize is not in a\r
794 valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r
795\r
796 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r
797 @param Source The source buffer containing the compressed data.\r
798 @param SourceSize SourceSizeThe size of source data.\r
799 @param Destination On output, the destination buffer that contains\r
800 the uncompressed data.\r
801 @param DestinationSize The size of the destination buffer. The size of\r
802 the destination buffer needed is obtained from\r
803 EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
804 @param Scratch A temporary scratch buffer that is used to perform\r
805 the decompression.\r
806 @param ScratchSize The size of scratch buffer. The size of the\r
807 scratch buffer needed is obtained from GetInfo().\r
808\r
809 @retval EFI_SUCCESS Decompression completed successfully, and the\r
810 uncompressed buffer is returned in Destination.\r
811 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and\r
812 SourceSize is corrupted (not in a valid\r
813 compressed format).\r
814\r
815**/\r
816EFI_STATUS\r
817EFIAPI\r
818DxeMainUefiDecompress (\r
819 IN EFI_DECOMPRESS_PROTOCOL *This,\r
820 IN VOID *Source,\r
821 IN UINT32 SourceSize,\r
822 IN OUT VOID *Destination,\r
823 IN UINT32 DestinationSize,\r
824 IN OUT VOID *Scratch,\r
825 IN UINT32 ScratchSize\r
826 )\r
827{\r
828 EFI_STATUS Status;\r
829 UINT32 TestDestinationSize;\r
830 UINT32 TestScratchSize;\r
831\r
832 if (Source == NULL || Destination== NULL || Scratch == NULL) {\r
833 return EFI_INVALID_PARAMETER;\r
834 }\r
835\r
836 Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r
837 if (EFI_ERROR (Status)) {\r
838 return Status;\r
839 }\r
840\r
841 if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) {\r
842 return RETURN_INVALID_PARAMETER;\r
843 }\r
844\r
845 return UefiDecompress (Source, Destination, Scratch);\r
846}\r