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