2 DXE Core Main Entry Point
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // DXE Core Global Variables for Protocols from PEI
20 EFI_HANDLE mDecompressHandle
= NULL
;
23 // DXE Core globals for Architecture Protocols
25 EFI_SECURITY_ARCH_PROTOCOL
*gSecurity
= NULL
;
26 EFI_SECURITY2_ARCH_PROTOCOL
*gSecurity2
= NULL
;
27 EFI_CPU_ARCH_PROTOCOL
*gCpu
= NULL
;
28 EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
= NULL
;
29 EFI_TIMER_ARCH_PROTOCOL
*gTimer
= NULL
;
30 EFI_BDS_ARCH_PROTOCOL
*gBds
= NULL
;
31 EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
= NULL
;
34 // DXE Core globals for optional protocol dependencies
36 EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
= NULL
;
39 // DXE Core Global used to update core loaded image protocol handle
41 EFI_GUID
*gDxeCoreFileName
;
42 EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
45 // DXE Core Module Variables
47 EFI_BOOT_SERVICES mBootServices
= {
49 EFI_BOOT_SERVICES_SIGNATURE
, // Signature
50 EFI_BOOT_SERVICES_REVISION
, // Revision
51 sizeof (EFI_BOOT_SERVICES
), // HeaderSize
55 (EFI_RAISE_TPL
) CoreRaiseTpl
, // RaiseTPL
56 (EFI_RESTORE_TPL
) CoreRestoreTpl
, // RestoreTPL
57 (EFI_ALLOCATE_PAGES
) CoreAllocatePages
, // AllocatePages
58 (EFI_FREE_PAGES
) CoreFreePages
, // FreePages
59 (EFI_GET_MEMORY_MAP
) CoreGetMemoryMap
, // GetMemoryMap
60 (EFI_ALLOCATE_POOL
) CoreAllocatePool
, // AllocatePool
61 (EFI_FREE_POOL
) CoreFreePool
, // FreePool
62 (EFI_CREATE_EVENT
) CoreCreateEvent
, // CreateEvent
63 (EFI_SET_TIMER
) CoreSetTimer
, // SetTimer
64 (EFI_WAIT_FOR_EVENT
) CoreWaitForEvent
, // WaitForEvent
65 (EFI_SIGNAL_EVENT
) CoreSignalEvent
, // SignalEvent
66 (EFI_CLOSE_EVENT
) CoreCloseEvent
, // CloseEvent
67 (EFI_CHECK_EVENT
) CoreCheckEvent
, // CheckEvent
68 (EFI_INSTALL_PROTOCOL_INTERFACE
) CoreInstallProtocolInterface
, // InstallProtocolInterface
69 (EFI_REINSTALL_PROTOCOL_INTERFACE
) CoreReinstallProtocolInterface
, // ReinstallProtocolInterface
70 (EFI_UNINSTALL_PROTOCOL_INTERFACE
) CoreUninstallProtocolInterface
, // UninstallProtocolInterface
71 (EFI_HANDLE_PROTOCOL
) CoreHandleProtocol
, // HandleProtocol
72 (VOID
*) NULL
, // Reserved
73 (EFI_REGISTER_PROTOCOL_NOTIFY
) CoreRegisterProtocolNotify
, // RegisterProtocolNotify
74 (EFI_LOCATE_HANDLE
) CoreLocateHandle
, // LocateHandle
75 (EFI_LOCATE_DEVICE_PATH
) CoreLocateDevicePath
, // LocateDevicePath
76 (EFI_INSTALL_CONFIGURATION_TABLE
) CoreInstallConfigurationTable
, // InstallConfigurationTable
77 (EFI_IMAGE_LOAD
) CoreLoadImage
, // LoadImage
78 (EFI_IMAGE_START
) CoreStartImage
, // StartImage
79 (EFI_EXIT
) CoreExit
, // Exit
80 (EFI_IMAGE_UNLOAD
) CoreUnloadImage
, // UnloadImage
81 (EFI_EXIT_BOOT_SERVICES
) CoreExitBootServices
, // ExitBootServices
82 (EFI_GET_NEXT_MONOTONIC_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextMonotonicCount
83 (EFI_STALL
) CoreStall
, // Stall
84 (EFI_SET_WATCHDOG_TIMER
) CoreSetWatchdogTimer
, // SetWatchdogTimer
85 (EFI_CONNECT_CONTROLLER
) CoreConnectController
, // ConnectController
86 (EFI_DISCONNECT_CONTROLLER
) CoreDisconnectController
, // DisconnectController
87 (EFI_OPEN_PROTOCOL
) CoreOpenProtocol
, // OpenProtocol
88 (EFI_CLOSE_PROTOCOL
) CoreCloseProtocol
, // CloseProtocol
89 (EFI_OPEN_PROTOCOL_INFORMATION
) CoreOpenProtocolInformation
, // OpenProtocolInformation
90 (EFI_PROTOCOLS_PER_HANDLE
) CoreProtocolsPerHandle
, // ProtocolsPerHandle
91 (EFI_LOCATE_HANDLE_BUFFER
) CoreLocateHandleBuffer
, // LocateHandleBuffer
92 (EFI_LOCATE_PROTOCOL
) CoreLocateProtocol
, // LocateProtocol
93 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreInstallMultipleProtocolInterfaces
, // InstallMultipleProtocolInterfaces
94 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreUninstallMultipleProtocolInterfaces
, // UninstallMultipleProtocolInterfaces
95 (EFI_CALCULATE_CRC32
) CoreEfiNotAvailableYetArg3
, // CalculateCrc32
96 (EFI_COPY_MEM
) CopyMem
, // CopyMem
97 (EFI_SET_MEM
) SetMem
, // SetMem
98 (EFI_CREATE_EVENT_EX
) CoreCreateEventEx
// CreateEventEx
101 EFI_DXE_SERVICES mDxeServices
= {
103 DXE_SERVICES_SIGNATURE
, // Signature
104 DXE_SERVICES_REVISION
, // Revision
105 sizeof (DXE_SERVICES
), // HeaderSize
109 (EFI_ADD_MEMORY_SPACE
) CoreAddMemorySpace
, // AddMemorySpace
110 (EFI_ALLOCATE_MEMORY_SPACE
) CoreAllocateMemorySpace
, // AllocateMemorySpace
111 (EFI_FREE_MEMORY_SPACE
) CoreFreeMemorySpace
, // FreeMemorySpace
112 (EFI_REMOVE_MEMORY_SPACE
) CoreRemoveMemorySpace
, // RemoveMemorySpace
113 (EFI_GET_MEMORY_SPACE_DESCRIPTOR
) CoreGetMemorySpaceDescriptor
, // GetMemorySpaceDescriptor
114 (EFI_SET_MEMORY_SPACE_ATTRIBUTES
) CoreSetMemorySpaceAttributes
, // SetMemorySpaceAttributes
115 (EFI_GET_MEMORY_SPACE_MAP
) CoreGetMemorySpaceMap
, // GetMemorySpaceMap
116 (EFI_ADD_IO_SPACE
) CoreAddIoSpace
, // AddIoSpace
117 (EFI_ALLOCATE_IO_SPACE
) CoreAllocateIoSpace
, // AllocateIoSpace
118 (EFI_FREE_IO_SPACE
) CoreFreeIoSpace
, // FreeIoSpace
119 (EFI_REMOVE_IO_SPACE
) CoreRemoveIoSpace
, // RemoveIoSpace
120 (EFI_GET_IO_SPACE_DESCRIPTOR
) CoreGetIoSpaceDescriptor
, // GetIoSpaceDescriptor
121 (EFI_GET_IO_SPACE_MAP
) CoreGetIoSpaceMap
, // GetIoSpaceMap
122 (EFI_DISPATCH
) CoreDispatcher
, // Dispatch
123 (EFI_SCHEDULE
) CoreSchedule
, // Schedule
124 (EFI_TRUST
) CoreTrust
, // Trust
125 (EFI_PROCESS_FIRMWARE_VOLUME
) CoreProcessFirmwareVolume
, // ProcessFirmwareVolume
126 (EFI_SET_MEMORY_SPACE_CAPABILITIES
)CoreSetMemorySpaceCapabilities
, // SetMemorySpaceCapabilities
129 EFI_SYSTEM_TABLE mEfiSystemTableTemplate
= {
131 EFI_SYSTEM_TABLE_SIGNATURE
, // Signature
132 EFI_SYSTEM_TABLE_REVISION
, // Revision
133 sizeof (EFI_SYSTEM_TABLE
), // HeaderSize
137 NULL
, // FirmwareVendor
138 0, // FirmwareRevision
139 NULL
, // ConsoleInHandle
141 NULL
, // ConsoleOutHandle
143 NULL
, // StandardErrorHandle
145 NULL
, // RuntimeServices
146 &mBootServices
, // BootServices
147 0, // NumberOfConfigurationTableEntries
148 NULL
// ConfigurationTable
151 EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate
= {
153 EFI_RUNTIME_SERVICES_SIGNATURE
, // Signature
154 EFI_RUNTIME_SERVICES_REVISION
, // Revision
155 sizeof (EFI_RUNTIME_SERVICES
), // HeaderSize
159 (EFI_GET_TIME
) CoreEfiNotAvailableYetArg2
, // GetTime
160 (EFI_SET_TIME
) CoreEfiNotAvailableYetArg1
, // SetTime
161 (EFI_GET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg3
, // GetWakeupTime
162 (EFI_SET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg2
, // SetWakeupTime
163 (EFI_SET_VIRTUAL_ADDRESS_MAP
) CoreEfiNotAvailableYetArg4
, // SetVirtualAddressMap
164 (EFI_CONVERT_POINTER
) CoreEfiNotAvailableYetArg2
, // ConvertPointer
165 (EFI_GET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // GetVariable
166 (EFI_GET_NEXT_VARIABLE_NAME
) CoreEfiNotAvailableYetArg3
, // GetNextVariableName
167 (EFI_SET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // SetVariable
168 (EFI_GET_NEXT_HIGH_MONO_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextHighMonotonicCount
169 (EFI_RESET_SYSTEM
) CoreEfiNotAvailableYetArg4
, // ResetSystem
170 (EFI_UPDATE_CAPSULE
) CoreEfiNotAvailableYetArg3
, // UpdateCapsule
171 (EFI_QUERY_CAPSULE_CAPABILITIES
) CoreEfiNotAvailableYetArg4
, // QueryCapsuleCapabilities
172 (EFI_QUERY_VARIABLE_INFO
) CoreEfiNotAvailableYetArg4
// QueryVariableInfo
175 EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
= {
176 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.ImageHead
),
177 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.EventHead
),
180 // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
181 // prevent people from having pointer math bugs in their code.
182 // now you have to use *DescriptorSize to make things work.
184 sizeof (EFI_MEMORY_DESCRIPTOR
) + sizeof (UINT64
) - (sizeof (EFI_MEMORY_DESCRIPTOR
) % sizeof (UINT64
)),
185 EFI_MEMORY_DESCRIPTOR_VERSION
,
193 EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
= &gRuntimeTemplate
;
196 // DXE Core Global Variables for the EFI System Table, Boot Services Table,
197 // DXE Services Table, and Runtime Services Table
199 EFI_DXE_SERVICES
*gDxeCoreDS
= &mDxeServices
;
200 EFI_SYSTEM_TABLE
*gDxeCoreST
= NULL
;
203 // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
204 // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
205 // a value that will not cause debug infrastructure to crash early on.
207 EFI_RUNTIME_SERVICES
*gDxeCoreRT
= &mEfiRuntimeServicesTableTemplate
;
208 EFI_HANDLE gDxeCoreImageHandle
= NULL
;
212 // EFI Decompress Protocol
214 EFI_DECOMPRESS_PROTOCOL gEfiDecompress
= {
215 DxeMainUefiDecompressGetInfo
,
216 DxeMainUefiDecompress
220 // For Loading modules at fixed address feature, the configuration table is to cache the top address below which to load
221 // Runtime code&boot time code
223 GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
= {0, 0};
225 // Main entry point to the DXE Core
229 Main entry point to DXE Core.
231 @param HobStart Pointer to the beginning of the HOB List from PEI.
233 @return This function should never return.
243 EFI_PHYSICAL_ADDRESS MemoryBaseAddress
;
245 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
247 EFI_HOB_GUID_TYPE
*GuidHob
;
248 EFI_VECTOR_HANDOFF_INFO
*VectorInfoList
;
249 EFI_VECTOR_HANDOFF_INFO
*VectorInfo
;
252 // Setup the default exception handlers
254 VectorInfoList
= NULL
;
255 GuidHob
= GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid
, HobStart
);
256 if (GuidHob
!= NULL
) {
257 VectorInfoList
= (EFI_VECTOR_HANDOFF_INFO
*) (GET_GUID_HOB_DATA(GuidHob
));
259 Status
= InitializeCpuExceptionHandlers (VectorInfoList
);
260 ASSERT_EFI_ERROR (Status
);
263 // Initialize Debug Agent to support source level debug in DXE phase
265 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_CORE
, HobStart
, NULL
);
268 // Initialize Memory Services
270 CoreInitializeMemoryServices (&HobStart
, &MemoryBaseAddress
, &MemoryLength
);
272 MemoryProfileInit (HobStart
);
275 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
276 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
278 gDxeCoreST
= AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE
), &mEfiSystemTableTemplate
);
279 ASSERT (gDxeCoreST
!= NULL
);
281 gDxeCoreRT
= AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES
), &mEfiRuntimeServicesTableTemplate
);
282 ASSERT (gDxeCoreRT
!= NULL
);
284 gDxeCoreST
->RuntimeServices
= gDxeCoreRT
;
287 // Start the Image Services.
289 Status
= CoreInitializeImageServices (HobStart
);
290 ASSERT_EFI_ERROR (Status
);
293 // Report DXE Core image information to the PE/COFF Extra Action Library
295 ZeroMem (&ImageContext
, sizeof (ImageContext
));
296 ImageContext
.ImageAddress
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)gDxeCoreLoadedImage
->ImageBase
;
297 ImageContext
.PdbPointer
= PeCoffLoaderGetPdbPointer ((VOID
*) (UINTN
) ImageContext
.ImageAddress
);
298 PeCoffLoaderRelocateImageExtraAction (&ImageContext
);
301 // Initialize the Global Coherency Domain Services
303 Status
= CoreInitializeGcdServices (&HobStart
, MemoryBaseAddress
, MemoryLength
);
304 ASSERT_EFI_ERROR (Status
);
307 // Call constructor for all libraries
309 ProcessLibraryConstructorList (gDxeCoreImageHandle
, gDxeCoreST
);
310 PERF_END (NULL
,"PEI", NULL
, 0) ;
311 PERF_START (NULL
,"DXE", NULL
, 0) ;
314 // Install the DXE Services Table into the EFI System Tables's Configuration Table
316 Status
= CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid
, gDxeCoreDS
);
317 ASSERT_EFI_ERROR (Status
);
320 // Install the HOB List into the EFI System Tables's Configuration Table
322 Status
= CoreInstallConfigurationTable (&gEfiHobListGuid
, HobStart
);
323 ASSERT_EFI_ERROR (Status
);
326 // Install Memory Type Information Table into the EFI System Tables's Configuration Table
328 Status
= CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid
, &gMemoryTypeInformation
);
329 ASSERT_EFI_ERROR (Status
);
332 // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address
333 // Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI
334 // Code and Tseg base to load SMM driver.
336 if (PcdGet64(PcdLoadModuleAtFixAddressEnable
) != 0) {
337 Status
= CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid
, &gLoadModuleAtFixAddressConfigurationTable
);
338 ASSERT_EFI_ERROR (Status
);
341 // Report Status Code here for DXE_ENTRY_POINT once it is available
345 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_ENTRY_POINT
)
349 // Create the aligned system table pointer structure that is used by external
350 // debuggers to locate the system table... Also, install debug image info
351 // configuration table.
353 CoreInitializeDebugImageInfoTable ();
354 CoreNewDebugImageInfoEntry (
355 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL
,
360 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "HOBLIST address in DXE = 0x%p\n", HobStart
));
363 EFI_PEI_HOB_POINTERS Hob
;
365 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
366 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_MEMORY_ALLOCATION
) {
367 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "Memory Allocation 0x%08x 0x%0lx - 0x%0lx\n", \
368 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryType
, \
369 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
, \
370 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
+ Hob
.MemoryAllocation
->AllocDescriptor
.MemoryLength
- 1));
373 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
374 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV2
) {
375 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "FV2 Hob 0x%0lx - 0x%0lx\n", Hob
.FirmwareVolume2
->BaseAddress
, Hob
.FirmwareVolume2
->BaseAddress
+ Hob
.FirmwareVolume2
->Length
- 1));
376 } else if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV
) {
377 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "FV Hob 0x%0lx - 0x%0lx\n", Hob
.FirmwareVolume
->BaseAddress
, Hob
.FirmwareVolume
->BaseAddress
+ Hob
.FirmwareVolume
->Length
- 1));
383 // Initialize the Event Services
385 Status
= CoreInitializeEventServices ();
386 ASSERT_EFI_ERROR (Status
);
388 MemoryProfileInstallProtocol ();
390 CoreInitializePropertiesTable ();
391 CoreInitializeMemoryAttributesTable ();
394 // Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated,
395 // and install configuration table
397 GuidHob
= GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid
, HobStart
);
398 if (GuidHob
!= NULL
) {
399 VectorInfoList
= (EFI_VECTOR_HANDOFF_INFO
*) (GET_GUID_HOB_DATA(GuidHob
));
400 VectorInfo
= VectorInfoList
;
402 while (VectorInfo
->Attribute
!= EFI_VECTOR_HANDOFF_LAST_ENTRY
) {
406 VectorInfo
= AllocateCopyPool (sizeof (EFI_VECTOR_HANDOFF_INFO
) * Index
, (VOID
*) VectorInfoList
);
407 ASSERT (VectorInfo
!= NULL
);
408 Status
= CoreInstallConfigurationTable (&gEfiVectorHandoffTableGuid
, (VOID
*) VectorInfo
);
409 ASSERT_EFI_ERROR (Status
);
413 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
415 // These Protocols are not architectural. This implementation is sharing code between
416 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
417 // as part of the DXE Core. However, that would also require the DXE Core to be ported
418 // each time a different CPU is used, a different Decompression algorithm is used, or a
419 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
420 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
421 // and from CPU to CPU.
425 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
427 Status
= CoreInstallMultipleProtocolInterfaces (
429 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
432 ASSERT_EFI_ERROR (Status
);
435 // Register for the GUIDs of the Architectural Protocols, so the rest of the
436 // EFI Boot Services and EFI Runtime Services tables can be filled in.
437 // Also register for the GUIDs of optional protocols.
439 CoreNotifyOnProtocolInstallation ();
442 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
444 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
445 ASSERT_EFI_ERROR (Status
);
447 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
448 ASSERT_EFI_ERROR (Status
);
451 // Produce the Section Extraction Protocol
453 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
454 ASSERT_EFI_ERROR (Status
);
457 // Initialize the DXE Dispatcher
459 PERF_START (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
460 CoreInitializeDispatcher ();
461 PERF_END (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
464 // Invoke the DXE Dispatcher
466 PERF_START (NULL
, "CoreDispatcher", "DxeMain", 0);
468 PERF_END (NULL
, "CoreDispatcher", "DxeMain", 0);
471 // Display Architectural protocols that were not loaded if this is DEBUG build
474 CoreDisplayMissingArchProtocols ();
478 // Display any drivers that were not dispatched because dependency expression
479 // evaluated to false if this is a debug build
482 CoreDisplayDiscoveredNotDispatched ();
486 // Assert if the Architectural Protocols are not present.
488 Status
= CoreAllEfiServicesAvailable ();
489 if (EFI_ERROR(Status
)) {
491 // Report Status code that some Architectural Protocols are not present.
494 EFI_ERROR_CODE
| EFI_ERROR_MAJOR
,
495 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_EC_NO_ARCH
)
498 ASSERT_EFI_ERROR (Status
);
501 // Report Status code before transfer control to BDS
505 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)
509 // Transfer control to the BDS Architectural Protocol
514 // BDS should never return
523 Place holder function until all the Boot Services and Runtime Services are
526 @return EFI_NOT_AVAILABLE_YET
531 CoreEfiNotAvailableYetArg0 (
536 // This function should never be executed. If it does, then the architectural protocols
537 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
538 // DXE Core and all the Architectural Protocols are complete.
541 return EFI_NOT_AVAILABLE_YET
;
546 Place holder function until all the Boot Services and Runtime Services are
549 @param Arg1 Undefined
551 @return EFI_NOT_AVAILABLE_YET
556 CoreEfiNotAvailableYetArg1 (
561 // This function should never be executed. If it does, then the architectural protocols
562 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
563 // DXE Core and all the Architectural Protocols are complete.
566 return EFI_NOT_AVAILABLE_YET
;
571 Place holder function until all the Boot Services and Runtime Services are available.
573 @param Arg1 Undefined
574 @param Arg2 Undefined
576 @return EFI_NOT_AVAILABLE_YET
581 CoreEfiNotAvailableYetArg2 (
587 // This function should never be executed. If it does, then the architectural protocols
588 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
589 // DXE Core and all the Architectural Protocols are complete.
592 return EFI_NOT_AVAILABLE_YET
;
597 Place holder function until all the Boot Services and Runtime Services are available.
599 @param Arg1 Undefined
600 @param Arg2 Undefined
601 @param Arg3 Undefined
603 @return EFI_NOT_AVAILABLE_YET
608 CoreEfiNotAvailableYetArg3 (
615 // This function should never be executed. If it does, then the architectural protocols
616 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
617 // DXE Core and all the Architectural Protocols are complete.
620 return EFI_NOT_AVAILABLE_YET
;
625 Place holder function until all the Boot Services and Runtime Services are available.
627 @param Arg1 Undefined
628 @param Arg2 Undefined
629 @param Arg3 Undefined
630 @param Arg4 Undefined
632 @return EFI_NOT_AVAILABLE_YET
637 CoreEfiNotAvailableYetArg4 (
645 // This function should never be executed. If it does, then the architectural protocols
646 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
647 // DXE Core and all the Architectural Protocols are complete.
650 return EFI_NOT_AVAILABLE_YET
;
655 Place holder function until all the Boot Services and Runtime Services are available.
657 @param Arg1 Undefined
658 @param Arg2 Undefined
659 @param Arg3 Undefined
660 @param Arg4 Undefined
661 @param Arg5 Undefined
663 @return EFI_NOT_AVAILABLE_YET
668 CoreEfiNotAvailableYetArg5 (
677 // This function should never be executed. If it does, then the architectural protocols
678 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
679 // DXE Core and all the Architectural Protocols are complete.
682 return EFI_NOT_AVAILABLE_YET
;
687 Calcualte the 32-bit CRC in a EFI table using the service provided by the
690 @param Hdr Pointer to an EFI standard header
695 IN OUT EFI_TABLE_HEADER
*Hdr
703 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
704 // Crc will come back as zero if we set it to zero here
707 gBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
713 Terminates all boot services.
715 @param ImageHandle Handle that identifies the exiting image.
716 @param MapKey Key to the latest memory map.
718 @retval EFI_SUCCESS Boot Services terminated
719 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
724 CoreExitBootServices (
725 IN EFI_HANDLE ImageHandle
,
734 gTimer
->SetTimerPeriod (gTimer
, 0);
737 // Terminate memory services if the MapKey matches
739 Status
= CoreTerminateMemoryMap (MapKey
);
740 if (EFI_ERROR (Status
)) {
742 // Notify other drivers that ExitBootServices fail
744 CoreNotifySignalList (&gEventExitBootServicesFailedGuid
);
749 // Notify other drivers that we are exiting boot services.
751 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
754 // Report that ExitBootServices() has been called
758 (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)
762 // Disable interrupt of Debug timer.
764 SaveAndSetDebugTimerInterrupt (FALSE
);
767 // Disable CPU Interrupts
769 gCpu
->DisableInterrupt (gCpu
);
772 // Clear the non-runtime values of the EFI System Table
774 gDxeCoreST
->BootServices
= NULL
;
775 gDxeCoreST
->ConIn
= NULL
;
776 gDxeCoreST
->ConsoleInHandle
= NULL
;
777 gDxeCoreST
->ConOut
= NULL
;
778 gDxeCoreST
->ConsoleOutHandle
= NULL
;
779 gDxeCoreST
->StdErr
= NULL
;
780 gDxeCoreST
->StandardErrorHandle
= NULL
;
783 // Recompute the 32-bit CRC of the EFI System Table
785 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
788 // Zero out the Boot Service Table
790 ZeroMem (gBS
, sizeof (EFI_BOOT_SERVICES
));
794 // Update the AtRuntime field in Runtiem AP.
796 gRuntime
->AtRuntime
= TRUE
;
803 Given a compressed source buffer, this function retrieves the size of the
804 uncompressed buffer and the size of the scratch buffer required to decompress
805 the compressed source buffer.
807 The GetInfo() function retrieves the size of the uncompressed buffer and the
808 temporary scratch buffer required to decompress the buffer specified by Source
809 and SourceSize. If the size of the uncompressed buffer or the size of the
810 scratch buffer cannot be determined from the compressed data specified by
811 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
812 size of the uncompressed buffer is returned in DestinationSize, the size of
813 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
814 The GetInfo() function does not have scratch buffer available to perform a
815 thorough checking of the validity of the source data. It just retrieves the
816 "Original Size" field from the beginning bytes of the source data and output
817 it as DestinationSize. And ScratchSize is specific to the decompression
820 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
821 @param Source The source buffer containing the compressed data.
822 @param SourceSize The size, in bytes, of the source buffer.
823 @param DestinationSize A pointer to the size, in bytes, of the
824 uncompressed buffer that will be generated when the
825 compressed buffer specified by Source and
826 SourceSize is decompressed.
827 @param ScratchSize A pointer to the size, in bytes, of the scratch
828 buffer that is required to decompress the
829 compressed buffer specified by Source and
832 @retval EFI_SUCCESS The size of the uncompressed data was returned in
833 DestinationSize and the size of the scratch buffer
834 was returned in ScratchSize.
835 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
836 the scratch buffer cannot be determined from the
837 compressed data specified by Source and
843 DxeMainUefiDecompressGetInfo (
844 IN EFI_DECOMPRESS_PROTOCOL
*This
,
846 IN UINT32 SourceSize
,
847 OUT UINT32
*DestinationSize
,
848 OUT UINT32
*ScratchSize
851 if (Source
== NULL
|| DestinationSize
== NULL
|| ScratchSize
== NULL
) {
852 return EFI_INVALID_PARAMETER
;
854 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
859 Decompresses a compressed source buffer.
861 The Decompress() function extracts decompressed data to its original form.
862 This protocol is designed so that the decompression algorithm can be
863 implemented without using any memory services. As a result, the Decompress()
864 Function is not allowed to call AllocatePool() or AllocatePages() in its
865 implementation. It is the caller's responsibility to allocate and free the
866 Destination and Scratch buffers.
867 If the compressed source data specified by Source and SourceSize is
868 successfully decompressed into Destination, then EFI_SUCCESS is returned. If
869 the compressed source data specified by Source and SourceSize is not in a
870 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
872 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
873 @param Source The source buffer containing the compressed data.
874 @param SourceSize SourceSizeThe size of source data.
875 @param Destination On output, the destination buffer that contains
876 the uncompressed data.
877 @param DestinationSize The size of the destination buffer. The size of
878 the destination buffer needed is obtained from
879 EFI_DECOMPRESS_PROTOCOL.GetInfo().
880 @param Scratch A temporary scratch buffer that is used to perform
882 @param ScratchSize The size of scratch buffer. The size of the
883 scratch buffer needed is obtained from GetInfo().
885 @retval EFI_SUCCESS Decompression completed successfully, and the
886 uncompressed buffer is returned in Destination.
887 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
888 SourceSize is corrupted (not in a valid
894 DxeMainUefiDecompress (
895 IN EFI_DECOMPRESS_PROTOCOL
*This
,
897 IN UINT32 SourceSize
,
898 IN OUT VOID
*Destination
,
899 IN UINT32 DestinationSize
,
900 IN OUT VOID
*Scratch
,
901 IN UINT32 ScratchSize
905 UINT32 TestDestinationSize
;
906 UINT32 TestScratchSize
;
908 if (Source
== NULL
|| Destination
== NULL
|| Scratch
== NULL
) {
909 return EFI_INVALID_PARAMETER
;
912 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
913 if (EFI_ERROR (Status
)) {
917 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
918 return RETURN_INVALID_PARAMETER
;
921 return UefiDecompress (Source
, Destination
, Scratch
);