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