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