2 DXE Core Main Entry Point
4 Copyright (c) 2006 - 2010, 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_CPU_ARCH_PROTOCOL
*gCpu
= NULL
;
27 EFI_METRONOME_ARCH_PROTOCOL
*gMetronome
= NULL
;
28 EFI_TIMER_ARCH_PROTOCOL
*gTimer
= NULL
;
29 EFI_BDS_ARCH_PROTOCOL
*gBds
= NULL
;
30 EFI_WATCHDOG_TIMER_ARCH_PROTOCOL
*gWatchdogTimer
= NULL
;
33 // DXE Core globals for optional protocol dependencies
35 EFI_SMM_BASE2_PROTOCOL
*gSmmBase2
= NULL
;
38 // DXE Core Global used to update core loaded image protocol handle
40 EFI_GUID
*gDxeCoreFileName
;
41 EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
44 // DXE Core Module Variables
46 EFI_BOOT_SERVICES mBootServices
= {
48 EFI_BOOT_SERVICES_SIGNATURE
, // Signature
49 EFI_BOOT_SERVICES_REVISION
, // Revision
50 sizeof (EFI_BOOT_SERVICES
), // HeaderSize
54 (EFI_RAISE_TPL
) CoreRaiseTpl
, // RaiseTPL
55 (EFI_RESTORE_TPL
) CoreRestoreTpl
, // RestoreTPL
56 (EFI_ALLOCATE_PAGES
) CoreAllocatePages
, // AllocatePages
57 (EFI_FREE_PAGES
) CoreFreePages
, // FreePages
58 (EFI_GET_MEMORY_MAP
) CoreGetMemoryMap
, // GetMemoryMap
59 (EFI_ALLOCATE_POOL
) CoreAllocatePool
, // AllocatePool
60 (EFI_FREE_POOL
) CoreFreePool
, // FreePool
61 (EFI_CREATE_EVENT
) CoreCreateEvent
, // CreateEvent
62 (EFI_SET_TIMER
) CoreSetTimer
, // SetTimer
63 (EFI_WAIT_FOR_EVENT
) CoreWaitForEvent
, // WaitForEvent
64 (EFI_SIGNAL_EVENT
) CoreSignalEvent
, // SignalEvent
65 (EFI_CLOSE_EVENT
) CoreCloseEvent
, // CloseEvent
66 (EFI_CHECK_EVENT
) CoreCheckEvent
, // CheckEvent
67 (EFI_INSTALL_PROTOCOL_INTERFACE
) CoreInstallProtocolInterface
, // InstallProtocolInterface
68 (EFI_REINSTALL_PROTOCOL_INTERFACE
) CoreReinstallProtocolInterface
, // ReinstallProtocolInterface
69 (EFI_UNINSTALL_PROTOCOL_INTERFACE
) CoreUninstallProtocolInterface
, // UninstallProtocolInterface
70 (EFI_HANDLE_PROTOCOL
) CoreHandleProtocol
, // HandleProtocol
71 (VOID
*) NULL
, // Reserved
72 (EFI_REGISTER_PROTOCOL_NOTIFY
) CoreRegisterProtocolNotify
, // RegisterProtocolNotify
73 (EFI_LOCATE_HANDLE
) CoreLocateHandle
, // LocateHandle
74 (EFI_LOCATE_DEVICE_PATH
) CoreLocateDevicePath
, // LocateDevicePath
75 (EFI_INSTALL_CONFIGURATION_TABLE
) CoreInstallConfigurationTable
, // InstallConfigurationTable
76 (EFI_IMAGE_LOAD
) CoreLoadImage
, // LoadImage
77 (EFI_IMAGE_START
) CoreStartImage
, // StartImage
78 (EFI_EXIT
) CoreExit
, // Exit
79 (EFI_IMAGE_UNLOAD
) CoreUnloadImage
, // UnloadImage
80 (EFI_EXIT_BOOT_SERVICES
) CoreExitBootServices
, // ExitBootServices
81 (EFI_GET_NEXT_MONOTONIC_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextMonotonicCount
82 (EFI_STALL
) CoreStall
, // Stall
83 (EFI_SET_WATCHDOG_TIMER
) CoreSetWatchdogTimer
, // SetWatchdogTimer
84 (EFI_CONNECT_CONTROLLER
) CoreConnectController
, // ConnectController
85 (EFI_DISCONNECT_CONTROLLER
) CoreDisconnectController
, // DisconnectController
86 (EFI_OPEN_PROTOCOL
) CoreOpenProtocol
, // OpenProtocol
87 (EFI_CLOSE_PROTOCOL
) CoreCloseProtocol
, // CloseProtocol
88 (EFI_OPEN_PROTOCOL_INFORMATION
) CoreOpenProtocolInformation
, // OpenProtocolInformation
89 (EFI_PROTOCOLS_PER_HANDLE
) CoreProtocolsPerHandle
, // ProtocolsPerHandle
90 (EFI_LOCATE_HANDLE_BUFFER
) CoreLocateHandleBuffer
, // LocateHandleBuffer
91 (EFI_LOCATE_PROTOCOL
) CoreLocateProtocol
, // LocateProtocol
92 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreInstallMultipleProtocolInterfaces
, // InstallMultipleProtocolInterfaces
93 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreUninstallMultipleProtocolInterfaces
, // UninstallMultipleProtocolInterfaces
94 (EFI_CALCULATE_CRC32
) CoreEfiNotAvailableYetArg3
, // CalculateCrc32
95 (EFI_COPY_MEM
) CopyMem
, // CopyMem
96 (EFI_SET_MEM
) SetMem
, // SetMem
97 (EFI_CREATE_EVENT_EX
) CoreCreateEventEx
// CreateEventEx
100 EFI_DXE_SERVICES mDxeServices
= {
102 DXE_SERVICES_SIGNATURE
, // Signature
103 DXE_SERVICES_REVISION
, // Revision
104 sizeof (DXE_SERVICES
), // HeaderSize
108 (EFI_ADD_MEMORY_SPACE
) CoreAddMemorySpace
, // AddMemorySpace
109 (EFI_ALLOCATE_MEMORY_SPACE
) CoreAllocateMemorySpace
, // AllocateMemorySpace
110 (EFI_FREE_MEMORY_SPACE
) CoreFreeMemorySpace
, // FreeMemorySpace
111 (EFI_REMOVE_MEMORY_SPACE
) CoreRemoveMemorySpace
, // RemoveMemorySpace
112 (EFI_GET_MEMORY_SPACE_DESCRIPTOR
) CoreGetMemorySpaceDescriptor
, // GetMemorySpaceDescriptor
113 (EFI_SET_MEMORY_SPACE_ATTRIBUTES
) CoreSetMemorySpaceAttributes
, // SetMemorySpaceAttributes
114 (EFI_GET_MEMORY_SPACE_MAP
) CoreGetMemorySpaceMap
, // GetMemorySpaceMap
115 (EFI_ADD_IO_SPACE
) CoreAddIoSpace
, // AddIoSpace
116 (EFI_ALLOCATE_IO_SPACE
) CoreAllocateIoSpace
, // AllocateIoSpace
117 (EFI_FREE_IO_SPACE
) CoreFreeIoSpace
, // FreeIoSpace
118 (EFI_REMOVE_IO_SPACE
) CoreRemoveIoSpace
, // RemoveIoSpace
119 (EFI_GET_IO_SPACE_DESCRIPTOR
) CoreGetIoSpaceDescriptor
, // GetIoSpaceDescriptor
120 (EFI_GET_IO_SPACE_MAP
) CoreGetIoSpaceMap
, // GetIoSpaceMap
121 (EFI_DISPATCH
) CoreDispatcher
, // Dispatch
122 (EFI_SCHEDULE
) CoreSchedule
, // Schedule
123 (EFI_TRUST
) CoreTrust
, // Trust
124 (EFI_PROCESS_FIRMWARE_VOLUME
) CoreProcessFirmwareVolume
, // ProcessFirmwareVolume
127 EFI_SYSTEM_TABLE mEfiSystemTableTemplate
= {
129 EFI_SYSTEM_TABLE_SIGNATURE
, // Signature
130 EFI_SYSTEM_TABLE_REVISION
, // Revision
131 sizeof (EFI_SYSTEM_TABLE
), // HeaderSize
135 NULL
, // FirmwareVendor
136 0, // FirmwareRevision
137 NULL
, // ConsoleInHandle
139 NULL
, // ConsoleOutHandle
141 NULL
, // StandardErrorHandle
143 NULL
, // RuntimeServices
144 &mBootServices
, // BootServices
145 0, // NumberOfConfigurationTableEntries
146 NULL
// ConfigurationTable
149 EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate
= {
151 EFI_RUNTIME_SERVICES_SIGNATURE
, // Signature
152 EFI_RUNTIME_SERVICES_REVISION
, // Revision
153 sizeof (EFI_RUNTIME_SERVICES
), // HeaderSize
157 (EFI_GET_TIME
) CoreEfiNotAvailableYetArg2
, // GetTime
158 (EFI_SET_TIME
) CoreEfiNotAvailableYetArg1
, // SetTime
159 (EFI_GET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg3
, // GetWakeupTime
160 (EFI_SET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg2
, // SetWakeupTime
161 (EFI_SET_VIRTUAL_ADDRESS_MAP
) CoreEfiNotAvailableYetArg4
, // SetVirtualAddressMap
162 (EFI_CONVERT_POINTER
) CoreEfiNotAvailableYetArg2
, // ConvertPointer
163 (EFI_GET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // GetVariable
164 (EFI_GET_NEXT_VARIABLE_NAME
) CoreEfiNotAvailableYetArg3
, // GetNextVariableName
165 (EFI_SET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // SetVariable
166 (EFI_GET_NEXT_HIGH_MONO_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextHighMonotonicCount
167 (EFI_RESET_SYSTEM
) CoreEfiNotAvailableYetArg4
, // ResetSystem
168 (EFI_UPDATE_CAPSULE
) CoreEfiNotAvailableYetArg3
, // UpdateCapsule
169 (EFI_QUERY_CAPSULE_CAPABILITIES
) CoreEfiNotAvailableYetArg4
, // QueryCapsuleCapabilities
170 (EFI_QUERY_VARIABLE_INFO
) CoreEfiNotAvailableYetArg4
// QueryVariableInfo
173 EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
= {
174 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.ImageHead
),
175 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.EventHead
),
178 // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
179 // prevent people from having pointer math bugs in their code.
180 // now you have to use *DescriptorSize to make things work.
182 sizeof (EFI_MEMORY_DESCRIPTOR
) + sizeof (UINT64
) - (sizeof (EFI_MEMORY_DESCRIPTOR
) % sizeof (UINT64
)),
183 EFI_MEMORY_DESCRIPTOR_VERSION
,
191 EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
= &gRuntimeTemplate
;
194 // DXE Core Global Variables for the EFI System Table, Boot Services Table,
195 // DXE Services Table, and Runtime Services Table
197 EFI_DXE_SERVICES
*gDxeCoreDS
= &mDxeServices
;
198 EFI_SYSTEM_TABLE
*gDxeCoreST
= NULL
;
201 // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
202 // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
203 // a value that will not cause debug infrastructure to crash early on.
205 EFI_RUNTIME_SERVICES
*gDxeCoreRT
= &mEfiRuntimeServicesTableTemplate
;
206 EFI_HANDLE gDxeCoreImageHandle
= NULL
;
210 // EFI Decompress Protocol
212 EFI_DECOMPRESS_PROTOCOL gEfiDecompress
= {
213 DxeMainUefiDecompressGetInfo
,
214 DxeMainUefiDecompress
218 // For Loading modules at fixed address feature, the configuration table is to cache the top address below which to load
219 // Runtime code&boot time code
221 GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
= {0, 0};
223 // Main entry point to the DXE Core
227 Main entry point to DXE Core.
229 @param HobStart Pointer to the beginning of the HOB List from PEI.
231 @return This function should never return.
241 EFI_PHYSICAL_ADDRESS MemoryBaseAddress
;
243 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
246 // Initialize Debug Agent to support source level debug in DXE phase
248 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_CORE
, HobStart
, NULL
);
251 // Initialize Memory Services
253 CoreInitializeMemoryServices (&HobStart
, &MemoryBaseAddress
, &MemoryLength
);
256 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
257 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
259 gDxeCoreST
= AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE
), &mEfiSystemTableTemplate
);
260 ASSERT (gDxeCoreST
!= NULL
);
262 gDxeCoreRT
= AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES
), &mEfiRuntimeServicesTableTemplate
);
263 ASSERT (gDxeCoreRT
!= NULL
);
265 gDxeCoreST
->RuntimeServices
= gDxeCoreRT
;
268 // Start the Image Services.
270 Status
= CoreInitializeImageServices (HobStart
);
271 ASSERT_EFI_ERROR (Status
);
274 // Call constructor for all libraries
276 ProcessLibraryConstructorList (gDxeCoreImageHandle
, gDxeCoreST
);
277 PERF_END (NULL
,"PEI", NULL
, 0) ;
278 PERF_START (NULL
,"DXE", NULL
, 0) ;
281 // Report DXE Core image information to the PE/COFF Extra Action Library
283 ImageContext
.ImageAddress
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)gDxeCoreLoadedImage
->ImageBase
;
284 ImageContext
.PdbPointer
= PeCoffLoaderGetPdbPointer ((VOID
*) (UINTN
) ImageContext
.ImageAddress
);
285 PeCoffLoaderRelocateImageExtraAction (&ImageContext
);
288 // Initialize the Global Coherency Domain Services
290 Status
= CoreInitializeGcdServices (&HobStart
, MemoryBaseAddress
, MemoryLength
);
291 ASSERT_EFI_ERROR (Status
);
294 // Install the DXE Services Table into the EFI System Tables's Configuration Table
296 Status
= CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid
, gDxeCoreDS
);
297 ASSERT_EFI_ERROR (Status
);
300 // Install the HOB List into the EFI System Tables's Configuration Table
302 Status
= CoreInstallConfigurationTable (&gEfiHobListGuid
, HobStart
);
303 ASSERT_EFI_ERROR (Status
);
306 // Install Memory Type Information Table into the EFI System Tables's Configuration Table
308 Status
= CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid
, &gMemoryTypeInformation
);
309 ASSERT_EFI_ERROR (Status
);
312 // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address
313 // Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI
314 // Code and Tseg base to load SMM driver.
316 if (PcdGet64(PcdLoadModuleAtFixAddressEnable
) != 0) {
317 Status
= CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid
, &gLoadModuleAtFixAddressConfigurationTable
);
318 ASSERT_EFI_ERROR (Status
);
321 // Report Status Code here for DXE_ENTRY_POINT once it is available
325 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_ENTRY_POINT
)
329 // Create the aligned system table pointer structure that is used by external
330 // debuggers to locate the system table... Also, install debug image info
331 // configuration table.
333 CoreInitializeDebugImageInfoTable ();
334 CoreNewDebugImageInfoEntry (
335 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL
,
340 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "HOBLIST address in DXE = 0x%p\n", HobStart
));
343 EFI_PEI_HOB_POINTERS Hob
;
345 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
346 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_MEMORY_ALLOCATION
) {
347 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "Memory Allocation 0x%08x 0x%0lx - 0x%0lx\n", \
348 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryType
, \
349 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
, \
350 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
+ Hob
.MemoryAllocation
->AllocDescriptor
.MemoryLength
- 1));
353 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
354 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV2
) {
355 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "FV2 Hob 0x%0lx - 0x%0lx\n", Hob
.FirmwareVolume2
->BaseAddress
, Hob
.FirmwareVolume2
->BaseAddress
+ Hob
.FirmwareVolume2
->Length
- 1));
356 } else if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV
) {
357 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "FV Hob 0x%0lx - 0x%0lx\n", Hob
.FirmwareVolume
->BaseAddress
, Hob
.FirmwareVolume
->BaseAddress
+ Hob
.FirmwareVolume2
->Length
- 1));
363 // Initialize the Event Services
365 Status
= CoreInitializeEventServices ();
366 ASSERT_EFI_ERROR (Status
);
370 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
372 // These Protocols are not architectural. This implementation is sharing code between
373 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
374 // as part of the DXE Core. However, that would also require the DXE Core to be ported
375 // each time a different CPU is used, a different Decompression algorithm is used, or a
376 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
377 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
378 // and from CPU to CPU.
382 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
384 Status
= CoreInstallMultipleProtocolInterfaces (
386 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
389 ASSERT_EFI_ERROR (Status
);
392 // Register for the GUIDs of the Architectural Protocols, so the rest of the
393 // EFI Boot Services and EFI Runtime Services tables can be filled in.
394 // Also register for the GUIDs of optional protocols.
396 CoreNotifyOnProtocolInstallation ();
399 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
401 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
402 ASSERT_EFI_ERROR (Status
);
404 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
405 ASSERT_EFI_ERROR (Status
);
408 // Produce the Section Extraction Protocol
410 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
411 ASSERT_EFI_ERROR (Status
);
414 // Initialize the DXE Dispatcher
416 PERF_START (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
417 CoreInitializeDispatcher ();
418 PERF_END (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
421 // Invoke the DXE Dispatcher
423 PERF_START (NULL
, "CoreDispatcher", "DxeMain", 0);
425 PERF_END (NULL
, "CoreDispatcher", "DxeMain", 0);
428 // Display Architectural protocols that were not loaded if this is DEBUG build
431 CoreDisplayMissingArchProtocols ();
435 // Display any drivers that were not dispatched because dependency expression
436 // evaluated to false if this is a debug build
439 CoreDisplayDiscoveredNotDispatched ();
443 // Assert if the Architectural Protocols are not present.
445 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
448 // Report Status code before transfer control to BDS
452 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)
456 // Transfer control to the BDS Architectural Protocol
461 // BDS should never return
470 Place holder function until all the Boot Services and Runtime Services are
473 @return EFI_NOT_AVAILABLE_YET
478 CoreEfiNotAvailableYetArg0 (
483 // This function should never be executed. If it does, then the architectural protocols
484 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
485 // DXE Core and all the Architectural Protocols are complete.
488 return EFI_NOT_AVAILABLE_YET
;
493 Place holder function until all the Boot Services and Runtime Services are
496 @param Arg1 Undefined
498 @return EFI_NOT_AVAILABLE_YET
503 CoreEfiNotAvailableYetArg1 (
508 // This function should never be executed. If it does, then the architectural protocols
509 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
510 // DXE Core and all the Architectural Protocols are complete.
513 return EFI_NOT_AVAILABLE_YET
;
518 Place holder function until all the Boot Services and Runtime Services are available.
520 @param Arg1 Undefined
521 @param Arg2 Undefined
523 @return EFI_NOT_AVAILABLE_YET
528 CoreEfiNotAvailableYetArg2 (
534 // This function should never be executed. If it does, then the architectural protocols
535 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
536 // DXE Core and all the Architectural Protocols are complete.
539 return EFI_NOT_AVAILABLE_YET
;
544 Place holder function until all the Boot Services and Runtime Services are available.
546 @param Arg1 Undefined
547 @param Arg2 Undefined
548 @param Arg3 Undefined
550 @return EFI_NOT_AVAILABLE_YET
555 CoreEfiNotAvailableYetArg3 (
562 // This function should never be executed. If it does, then the architectural protocols
563 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
564 // DXE Core and all the Architectural Protocols are complete.
567 return EFI_NOT_AVAILABLE_YET
;
572 Place holder function until all the Boot Services and Runtime Services are available.
574 @param Arg1 Undefined
575 @param Arg2 Undefined
576 @param Arg3 Undefined
577 @param Arg4 Undefined
579 @return EFI_NOT_AVAILABLE_YET
584 CoreEfiNotAvailableYetArg4 (
592 // This function should never be executed. If it does, then the architectural protocols
593 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
594 // DXE Core and all the Architectural Protocols are complete.
597 return EFI_NOT_AVAILABLE_YET
;
602 Place holder function until all the Boot Services and Runtime Services are available.
604 @param Arg1 Undefined
605 @param Arg2 Undefined
606 @param Arg3 Undefined
607 @param Arg4 Undefined
608 @param Arg5 Undefined
610 @return EFI_NOT_AVAILABLE_YET
615 CoreEfiNotAvailableYetArg5 (
624 // This function should never be executed. If it does, then the architectural protocols
625 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
626 // DXE Core and all the Architectural Protocols are complete.
629 return EFI_NOT_AVAILABLE_YET
;
634 Calcualte the 32-bit CRC in a EFI table using the service provided by the
637 @param Hdr Pointer to an EFI standard header
642 IN OUT EFI_TABLE_HEADER
*Hdr
650 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
651 // Crc will come back as zero if we set it to zero here
654 gBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
660 Terminates all boot services.
662 @param ImageHandle Handle that identifies the exiting image.
663 @param MapKey Key to the latest memory map.
665 @retval EFI_SUCCESS Boot Services terminated
666 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
671 CoreExitBootServices (
672 IN EFI_HANDLE ImageHandle
,
679 // Terminate memory services if the MapKey matches
681 Status
= CoreTerminateMemoryMap (MapKey
);
682 if (EFI_ERROR (Status
)) {
689 gTimer
->SetTimerPeriod (gTimer
, 0);
692 // Notify other drivers that we are exiting boot services.
694 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
697 // Disable interrupt of Debug timer.
699 SaveAndSetDebugTimerInterrupt (FALSE
);
702 // Disable CPU Interrupts
704 gCpu
->DisableInterrupt (gCpu
);
707 // Report that ExitBootServices() has been called
711 (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)
715 // Clear the non-runtime values of the EFI System Table
717 gDxeCoreST
->BootServices
= NULL
;
718 gDxeCoreST
->ConIn
= NULL
;
719 gDxeCoreST
->ConsoleInHandle
= NULL
;
720 gDxeCoreST
->ConOut
= NULL
;
721 gDxeCoreST
->ConsoleOutHandle
= NULL
;
722 gDxeCoreST
->StdErr
= NULL
;
723 gDxeCoreST
->StandardErrorHandle
= NULL
;
726 // Recompute the 32-bit CRC of the EFI System Table
728 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
731 // Zero out the Boot Service Table
733 ZeroMem (gBS
, sizeof (EFI_BOOT_SERVICES
));
737 // Update the AtRuntime field in Runtiem AP.
739 gRuntime
->AtRuntime
= TRUE
;
746 Given a compressed source buffer, this function retrieves the size of the
747 uncompressed buffer and the size of the scratch buffer required to decompress
748 the compressed source buffer.
750 The GetInfo() function retrieves the size of the uncompressed buffer and the
751 temporary scratch buffer required to decompress the buffer specified by Source
752 and SourceSize. If the size of the uncompressed buffer or the size of the
753 scratch buffer cannot be determined from the compressed data specified by
754 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
755 size of the uncompressed buffer is returned in DestinationSize, the size of
756 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
757 The GetInfo() function does not have scratch buffer available to perform a
758 thorough checking of the validity of the source data. It just retrieves the
759 "Original Size" field from the beginning bytes of the source data and output
760 it as DestinationSize. And ScratchSize is specific to the decompression
763 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
764 @param Source The source buffer containing the compressed data.
765 @param SourceSize The size, in bytes, of the source buffer.
766 @param DestinationSize A pointer to the size, in bytes, of the
767 uncompressed buffer that will be generated when the
768 compressed buffer specified by Source and
769 SourceSize is decompressed.
770 @param ScratchSize A pointer to the size, in bytes, of the scratch
771 buffer that is required to decompress the
772 compressed buffer specified by Source and
775 @retval EFI_SUCCESS The size of the uncompressed data was returned in
776 DestinationSize and the size of the scratch buffer
777 was returned in ScratchSize.
778 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
779 the scratch buffer cannot be determined from the
780 compressed data specified by Source and
786 DxeMainUefiDecompressGetInfo (
787 IN EFI_DECOMPRESS_PROTOCOL
*This
,
789 IN UINT32 SourceSize
,
790 OUT UINT32
*DestinationSize
,
791 OUT UINT32
*ScratchSize
794 if (Source
== NULL
|| DestinationSize
== NULL
|| ScratchSize
== NULL
) {
795 return EFI_INVALID_PARAMETER
;
797 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
802 Decompresses a compressed source buffer.
804 The Decompress() function extracts decompressed data to its original form.
805 This protocol is designed so that the decompression algorithm can be
806 implemented without using any memory services. As a result, the Decompress()
807 Function is not allowed to call AllocatePool() or AllocatePages() in its
808 implementation. It is the caller's responsibility to allocate and free the
809 Destination and Scratch buffers.
810 If the compressed source data specified by Source and SourceSize is
811 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
812 the compressed source data specified by Source and SourceSize is not in a
813 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
815 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
816 @param Source The source buffer containing the compressed data.
817 @param SourceSize SourceSizeThe size of source data.
818 @param Destination On output, the destination buffer that contains
819 the uncompressed data.
820 @param DestinationSize The size of the destination buffer. The size of
821 the destination buffer needed is obtained from
822 EFI_DECOMPRESS_PROTOCOL.GetInfo().
823 @param Scratch A temporary scratch buffer that is used to perform
825 @param ScratchSize The size of scratch buffer. The size of the
826 scratch buffer needed is obtained from GetInfo().
828 @retval EFI_SUCCESS Decompression completed successfully, and the
829 uncompressed buffer is returned in Destination.
830 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
831 SourceSize is corrupted (not in a valid
837 DxeMainUefiDecompress (
838 IN EFI_DECOMPRESS_PROTOCOL
*This
,
840 IN UINT32 SourceSize
,
841 IN OUT VOID
*Destination
,
842 IN UINT32 DestinationSize
,
843 IN OUT VOID
*Scratch
,
844 IN UINT32 ScratchSize
848 UINT32 TestDestinationSize
;
849 UINT32 TestScratchSize
;
851 if (Source
== NULL
|| Destination
== NULL
|| Scratch
== NULL
) {
852 return EFI_INVALID_PARAMETER
;
855 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
856 if (EFI_ERROR (Status
)) {
860 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
861 return RETURN_INVALID_PARAMETER
;
864 return UefiDecompress (Source
, Destination
, Scratch
);