2 DXE Core Main Entry Point
4 Copyright (c) 2006 - 2009, Intel Corporation. <BR>
5 All rights reserved. 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 Global used to update core loaded image protocol handle
35 EFI_GUID
*gDxeCoreFileName
;
36 EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
39 // DXE Core Module Variables
41 EFI_BOOT_SERVICES mBootServices
= {
43 EFI_BOOT_SERVICES_SIGNATURE
, // Signature
44 EFI_BOOT_SERVICES_REVISION
, // Revision
45 sizeof (EFI_BOOT_SERVICES
), // HeaderSize
49 (EFI_RAISE_TPL
) CoreRaiseTpl
, // RaiseTPL
50 (EFI_RESTORE_TPL
) CoreRestoreTpl
, // RestoreTPL
51 (EFI_ALLOCATE_PAGES
) CoreAllocatePages
, // AllocatePages
52 (EFI_FREE_PAGES
) CoreFreePages
, // FreePages
53 (EFI_GET_MEMORY_MAP
) CoreGetMemoryMap
, // GetMemoryMap
54 (EFI_ALLOCATE_POOL
) CoreAllocatePool
, // AllocatePool
55 (EFI_FREE_POOL
) CoreFreePool
, // FreePool
56 (EFI_CREATE_EVENT
) CoreCreateEvent
, // CreateEvent
57 (EFI_SET_TIMER
) CoreSetTimer
, // SetTimer
58 (EFI_WAIT_FOR_EVENT
) CoreWaitForEvent
, // WaitForEvent
59 (EFI_SIGNAL_EVENT
) CoreSignalEvent
, // SignalEvent
60 (EFI_CLOSE_EVENT
) CoreCloseEvent
, // CloseEvent
61 (EFI_CHECK_EVENT
) CoreCheckEvent
, // CheckEvent
62 (EFI_INSTALL_PROTOCOL_INTERFACE
) CoreInstallProtocolInterface
, // InstallProtocolInterface
63 (EFI_REINSTALL_PROTOCOL_INTERFACE
) CoreReinstallProtocolInterface
, // ReinstallProtocolInterface
64 (EFI_UNINSTALL_PROTOCOL_INTERFACE
) CoreUninstallProtocolInterface
, // UninstallProtocolInterface
65 (EFI_HANDLE_PROTOCOL
) CoreHandleProtocol
, // HandleProtocol
66 (VOID
*) NULL
, // Reserved
67 (EFI_REGISTER_PROTOCOL_NOTIFY
) CoreRegisterProtocolNotify
, // RegisterProtocolNotify
68 (EFI_LOCATE_HANDLE
) CoreLocateHandle
, // LocateHandle
69 (EFI_LOCATE_DEVICE_PATH
) CoreLocateDevicePath
, // LocateDevicePath
70 (EFI_INSTALL_CONFIGURATION_TABLE
) CoreInstallConfigurationTable
, // InstallConfigurationTable
71 (EFI_IMAGE_LOAD
) CoreLoadImage
, // LoadImage
72 (EFI_IMAGE_START
) CoreStartImage
, // StartImage
73 (EFI_EXIT
) CoreExit
, // Exit
74 (EFI_IMAGE_UNLOAD
) CoreUnloadImage
, // UnloadImage
75 (EFI_EXIT_BOOT_SERVICES
) CoreExitBootServices
, // ExitBootServices
76 (EFI_GET_NEXT_MONOTONIC_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextMonotonicCount
77 (EFI_STALL
) CoreStall
, // Stall
78 (EFI_SET_WATCHDOG_TIMER
) CoreSetWatchdogTimer
, // SetWatchdogTimer
79 (EFI_CONNECT_CONTROLLER
) CoreConnectController
, // ConnectController
80 (EFI_DISCONNECT_CONTROLLER
) CoreDisconnectController
, // DisconnectController
81 (EFI_OPEN_PROTOCOL
) CoreOpenProtocol
, // OpenProtocol
82 (EFI_CLOSE_PROTOCOL
) CoreCloseProtocol
, // CloseProtocol
83 (EFI_OPEN_PROTOCOL_INFORMATION
) CoreOpenProtocolInformation
, // OpenProtocolInformation
84 (EFI_PROTOCOLS_PER_HANDLE
) CoreProtocolsPerHandle
, // ProtocolsPerHandle
85 (EFI_LOCATE_HANDLE_BUFFER
) CoreLocateHandleBuffer
, // LocateHandleBuffer
86 (EFI_LOCATE_PROTOCOL
) CoreLocateProtocol
, // LocateProtocol
87 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreInstallMultipleProtocolInterfaces
, // InstallMultipleProtocolInterfaces
88 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreUninstallMultipleProtocolInterfaces
, // UninstallMultipleProtocolInterfaces
89 (EFI_CALCULATE_CRC32
) CoreEfiNotAvailableYetArg3
, // CalculateCrc32
90 (EFI_COPY_MEM
) CopyMem
, // CopyMem
91 (EFI_SET_MEM
) SetMem
, // SetMem
92 (EFI_CREATE_EVENT_EX
) CoreCreateEventEx
// CreateEventEx
95 EFI_DXE_SERVICES mDxeServices
= {
97 DXE_SERVICES_SIGNATURE
, // Signature
98 DXE_SERVICES_REVISION
, // Revision
99 sizeof (DXE_SERVICES
), // HeaderSize
103 (EFI_ADD_MEMORY_SPACE
) CoreAddMemorySpace
, // AddMemorySpace
104 (EFI_ALLOCATE_MEMORY_SPACE
) CoreAllocateMemorySpace
, // AllocateMemorySpace
105 (EFI_FREE_MEMORY_SPACE
) CoreFreeMemorySpace
, // FreeMemorySpace
106 (EFI_REMOVE_MEMORY_SPACE
) CoreRemoveMemorySpace
, // RemoveMemorySpace
107 (EFI_GET_MEMORY_SPACE_DESCRIPTOR
) CoreGetMemorySpaceDescriptor
, // GetMemorySpaceDescriptor
108 (EFI_SET_MEMORY_SPACE_ATTRIBUTES
) CoreSetMemorySpaceAttributes
, // SetMemorySpaceAttributes
109 (EFI_GET_MEMORY_SPACE_MAP
) CoreGetMemorySpaceMap
, // GetMemorySpaceMap
110 (EFI_ADD_IO_SPACE
) CoreAddIoSpace
, // AddIoSpace
111 (EFI_ALLOCATE_IO_SPACE
) CoreAllocateIoSpace
, // AllocateIoSpace
112 (EFI_FREE_IO_SPACE
) CoreFreeIoSpace
, // FreeIoSpace
113 (EFI_REMOVE_IO_SPACE
) CoreRemoveIoSpace
, // RemoveIoSpace
114 (EFI_GET_IO_SPACE_DESCRIPTOR
) CoreGetIoSpaceDescriptor
, // GetIoSpaceDescriptor
115 (EFI_GET_IO_SPACE_MAP
) CoreGetIoSpaceMap
, // GetIoSpaceMap
116 (EFI_DISPATCH
) CoreDispatcher
, // Dispatch
117 (EFI_SCHEDULE
) CoreSchedule
, // Schedule
118 (EFI_TRUST
) CoreTrust
, // Trust
119 (EFI_PROCESS_FIRMWARE_VOLUME
) CoreProcessFirmwareVolume
, // ProcessFirmwareVolume
122 EFI_SYSTEM_TABLE mEfiSystemTableTemplate
= {
124 EFI_SYSTEM_TABLE_SIGNATURE
, // Signature
125 EFI_SYSTEM_TABLE_REVISION
, // Revision
126 sizeof (EFI_SYSTEM_TABLE
), // HeaderSize
130 NULL
, // FirmwareVendor
131 0, // FirmwareRevision
132 NULL
, // ConsoleInHandle
134 NULL
, // ConsoleOutHandle
136 NULL
, // StandardErrorHandle
138 NULL
, // RuntimeServices
139 &mBootServices
, // BootServices
140 0, // NumberOfConfigurationTableEntries
141 NULL
// ConfigurationTable
144 EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate
= {
146 EFI_RUNTIME_SERVICES_SIGNATURE
, // Signature
147 EFI_RUNTIME_SERVICES_REVISION
, // Revision
148 sizeof (EFI_RUNTIME_SERVICES
), // HeaderSize
152 (EFI_GET_TIME
) CoreEfiNotAvailableYetArg2
, // GetTime
153 (EFI_SET_TIME
) CoreEfiNotAvailableYetArg1
, // SetTime
154 (EFI_GET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg3
, // GetWakeupTime
155 (EFI_SET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg2
, // SetWakeupTime
156 (EFI_SET_VIRTUAL_ADDRESS_MAP
) CoreEfiNotAvailableYetArg4
, // SetVirtualAddressMap
157 (EFI_CONVERT_POINTER
) CoreEfiNotAvailableYetArg2
, // ConvertPointer
158 (EFI_GET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // GetVariable
159 (EFI_GET_NEXT_VARIABLE_NAME
) CoreEfiNotAvailableYetArg3
, // GetNextVariableName
160 (EFI_SET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // SetVariable
161 (EFI_GET_NEXT_HIGH_MONO_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextHighMonotonicCount
162 (EFI_RESET_SYSTEM
) CoreEfiNotAvailableYetArg4
, // ResetSystem
163 (EFI_UPDATE_CAPSULE
) CoreEfiNotAvailableYetArg3
, // UpdateCapsule
164 (EFI_QUERY_CAPSULE_CAPABILITIES
) CoreEfiNotAvailableYetArg4
, // QueryCapsuleCapabilities
165 (EFI_QUERY_VARIABLE_INFO
) CoreEfiNotAvailableYetArg4
// QueryVariableInfo
168 EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
= {
169 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.ImageHead
),
170 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.EventHead
),
173 // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
174 // prevent people from having pointer math bugs in their code.
175 // now you have to use *DescriptorSize to make things work.
177 sizeof (EFI_MEMORY_DESCRIPTOR
) + sizeof (UINT64
) - (sizeof (EFI_MEMORY_DESCRIPTOR
) % sizeof (UINT64
)),
178 EFI_MEMORY_DESCRIPTOR_VERSION
,
186 EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
= &gRuntimeTemplate
;
189 // DXE Core Global Variables for the EFI System Table, Boot Services Table,
190 // DXE Services Table, and Runtime Services Table
192 EFI_DXE_SERVICES
*gDxeCoreDS
= &mDxeServices
;
193 EFI_SYSTEM_TABLE
*gDxeCoreST
= NULL
;
196 // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
197 // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
198 // a value that will not cause debug infrastructure to crash early on.
200 EFI_RUNTIME_SERVICES
*gDxeCoreRT
= &mEfiRuntimeServicesTableTemplate
;
201 EFI_HANDLE gDxeCoreImageHandle
= NULL
;
205 // EFI Decompress Protocol
207 EFI_DECOMPRESS_PROTOCOL gEfiDecompress
= {
208 DxeMainUefiDecompressGetInfo
,
209 DxeMainUefiDecompress
213 // Main entry point to the DXE Core
217 Main entry point to DXE Core.
219 @param HobStart Pointer to the beginning of the HOB List from PEI.
221 @return This function should never return.
231 EFI_PHYSICAL_ADDRESS MemoryBaseAddress
;
235 // Initialize Memory Services
237 CoreInitializeMemoryServices (&HobStart
, &MemoryBaseAddress
, &MemoryLength
);
240 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
241 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
243 gDxeCoreST
= AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE
), &mEfiSystemTableTemplate
);
244 ASSERT (gDxeCoreST
!= NULL
);
246 gDxeCoreRT
= AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES
), &mEfiRuntimeServicesTableTemplate
);
247 ASSERT (gDxeCoreRT
!= NULL
);
249 gDxeCoreST
->RuntimeServices
= gDxeCoreRT
;
252 // Start the Image Services.
254 Status
= CoreInitializeImageServices (HobStart
);
255 ASSERT_EFI_ERROR (Status
);
258 // Call constructor for all libraries
260 ProcessLibraryConstructorList (gDxeCoreImageHandle
, gDxeCoreST
);
261 PERF_END (NULL
,"PEI", NULL
, 0) ;
262 PERF_START (NULL
,"DXE", NULL
, 0) ;
265 // Initialize the Global Coherency Domain Services
267 Status
= CoreInitializeGcdServices (&HobStart
, MemoryBaseAddress
, MemoryLength
);
268 ASSERT_EFI_ERROR (Status
);
271 // Install the DXE Services Table into the EFI System Tables's Configuration Table
273 Status
= CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid
, gDxeCoreDS
);
274 ASSERT_EFI_ERROR (Status
);
277 // Install the HOB List into the EFI System Tables's Configuration Table
279 Status
= CoreInstallConfigurationTable (&gEfiHobListGuid
, HobStart
);
280 ASSERT_EFI_ERROR (Status
);
283 // Install Memory Type Information Table into the EFI System Tables's Configuration Table
285 Status
= CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid
, &gMemoryTypeInformation
);
286 ASSERT_EFI_ERROR (Status
);
289 // Report Status Code here for DXE_ENTRY_POINT once it is available
293 FixedPcdGet32(PcdStatusCodeValueDxeCoreEntry
)
297 // Create the aligned system table pointer structure that is used by external
298 // debuggers to locate the system table... Also, install debug image info
299 // configuration table.
301 CoreInitializeDebugImageInfoTable ();
302 CoreNewDebugImageInfoEntry (
303 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL
,
308 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "HOBLIST address in DXE = 0x%p\n", HobStart
));
311 EFI_PEI_HOB_POINTERS Hob
;
313 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
314 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_MEMORY_ALLOCATION
) {
315 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "Memory Allocation %08x %0lx - %0lx\n", \
316 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryType
, \
317 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
, \
318 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
+ Hob
.MemoryAllocation
->AllocDescriptor
.MemoryLength
- 1));
321 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
322 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV2
) {
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
));
324 } else if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV
) {
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
));
331 // Initialize the Event Services
333 Status
= CoreInitializeEventServices ();
334 ASSERT_EFI_ERROR (Status
);
338 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
340 // These Protocols are not architectural. This implementation is sharing code between
341 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
342 // as part of the DXE Core. However, that would also require the DXE Core to be ported
343 // each time a different CPU is used, a different Decompression algorithm is used, or a
344 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
345 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
346 // and from CPU to CPU.
350 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
352 Status
= CoreInstallMultipleProtocolInterfaces (
354 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
357 ASSERT_EFI_ERROR (Status
);
360 // Register for the GUIDs of the Architectural Protocols, so the rest of the
361 // EFI Boot Services and EFI Runtime Services tables can be filled in.
363 CoreNotifyOnArchProtocolInstallation ();
366 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
368 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
369 ASSERT_EFI_ERROR (Status
);
371 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
372 ASSERT_EFI_ERROR (Status
);
375 // Produce the Section Extraction Protocol
377 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
378 ASSERT_EFI_ERROR (Status
);
381 // Initialize the DXE Dispatcher
383 PERF_START (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
384 CoreInitializeDispatcher ();
385 PERF_END (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
388 // Invoke the DXE Dispatcher
390 PERF_START (NULL
, "CoreDispatcher", "DxeMain", 0);
392 PERF_END (NULL
, "CoreDispatcher", "DxeMain", 0);
395 // Display Architectural protocols that were not loaded if this is DEBUG build
398 CoreDisplayMissingArchProtocols ();
402 // Display any drivers that were not dispatched because dependency expression
403 // evaluated to false if this is a debug build
406 CoreDisplayDiscoveredNotDispatched ();
410 // Assert if the Architectural Protocols are not present.
412 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
415 // Report Status code before transfer control to BDS
419 FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds
)
423 // Transfer control to the BDS Architectural Protocol
428 // BDS should never return
437 Place holder function until all the Boot Services and Runtime Services are
440 @return EFI_NOT_AVAILABLE_YET
445 CoreEfiNotAvailableYetArg0 (
450 // This function should never be executed. If it does, then the architectural protocols
451 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
452 // DXE Core and all the Architectural Protocols are complete.
455 return EFI_NOT_AVAILABLE_YET
;
460 Place holder function until all the Boot Services and Runtime Services are
463 @param Arg1 Undefined
465 @return EFI_NOT_AVAILABLE_YET
470 CoreEfiNotAvailableYetArg1 (
475 // This function should never be executed. If it does, then the architectural protocols
476 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
477 // DXE Core and all the Architectural Protocols are complete.
480 return EFI_NOT_AVAILABLE_YET
;
485 Place holder function until all the Boot Services and Runtime Services are available.
487 @param Arg1 Undefined
488 @param Arg2 Undefined
490 @return EFI_NOT_AVAILABLE_YET
495 CoreEfiNotAvailableYetArg2 (
501 // This function should never be executed. If it does, then the architectural protocols
502 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
503 // DXE Core and all the Architectural Protocols are complete.
506 return EFI_NOT_AVAILABLE_YET
;
511 Place holder function until all the Boot Services and Runtime Services are available.
513 @param Arg1 Undefined
514 @param Arg2 Undefined
515 @param Arg3 Undefined
517 @return EFI_NOT_AVAILABLE_YET
522 CoreEfiNotAvailableYetArg3 (
529 // This function should never be executed. If it does, then the architectural protocols
530 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
531 // DXE Core and all the Architectural Protocols are complete.
534 return EFI_NOT_AVAILABLE_YET
;
539 Place holder function until all the Boot Services and Runtime Services are available.
541 @param Arg1 Undefined
542 @param Arg2 Undefined
543 @param Arg3 Undefined
544 @param Arg4 Undefined
546 @return EFI_NOT_AVAILABLE_YET
551 CoreEfiNotAvailableYetArg4 (
559 // This function should never be executed. If it does, then the architectural protocols
560 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
561 // DXE Core and all the Architectural Protocols are complete.
564 return EFI_NOT_AVAILABLE_YET
;
569 Place holder function until all the Boot Services and Runtime Services are available.
571 @param Arg1 Undefined
572 @param Arg2 Undefined
573 @param Arg3 Undefined
574 @param Arg4 Undefined
575 @param Arg5 Undefined
577 @return EFI_NOT_AVAILABLE_YET
582 CoreEfiNotAvailableYetArg5 (
591 // This function should never be executed. If it does, then the architectural protocols
592 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
593 // DXE Core and all the Architectural Protocols are complete.
596 return EFI_NOT_AVAILABLE_YET
;
601 Calcualte the 32-bit CRC in a EFI table using the service provided by the
604 @param Hdr Pointer to an EFI standard header
609 IN OUT EFI_TABLE_HEADER
*Hdr
617 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
618 // Crc will come back as zero if we set it to zero here
621 gBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
627 Terminates all boot services.
629 @param ImageHandle Handle that identifies the exiting image.
630 @param MapKey Key to the latest memory map.
632 @retval EFI_SUCCESS Boot Services terminated
633 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
638 CoreExitBootServices (
639 IN EFI_HANDLE ImageHandle
,
646 // Terminate memory services if the MapKey matches
648 Status
= CoreTerminateMemoryMap (MapKey
);
649 if (EFI_ERROR (Status
)) {
656 gTimer
->SetTimerPeriod (gTimer
, 0);
659 // Notify other drivers that we are exiting boot services.
661 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
664 // Disable CPU Interrupts
666 gCpu
->DisableInterrupt (gCpu
);
669 // Report that ExitBootServices() has been called
673 FixedPcdGet32 (PcdStatusCodeValueBootServiceExit
)
677 // Clear the non-runtime values of the EFI System Table
679 gDxeCoreST
->BootServices
= NULL
;
680 gDxeCoreST
->ConIn
= NULL
;
681 gDxeCoreST
->ConsoleInHandle
= NULL
;
682 gDxeCoreST
->ConOut
= NULL
;
683 gDxeCoreST
->ConsoleOutHandle
= NULL
;
684 gDxeCoreST
->StdErr
= NULL
;
685 gDxeCoreST
->StandardErrorHandle
= NULL
;
688 // Recompute the 32-bit CRC of the EFI System Table
690 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
693 // Zero out the Boot Service Table
695 ZeroMem (gBS
, sizeof (EFI_BOOT_SERVICES
));
699 // Update the AtRuntime field in Runtiem AP.
701 gRuntime
->AtRuntime
= TRUE
;
708 Given a compressed source buffer, this function retrieves the size of the
709 uncompressed buffer and the size of the scratch buffer required to decompress
710 the compressed source buffer.
712 The GetInfo() function retrieves the size of the uncompressed buffer and the
713 temporary scratch buffer required to decompress the buffer specified by Source
714 and SourceSize. If the size of the uncompressed buffer or the size of the
715 scratch buffer cannot be determined from the compressed data specified by
716 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
717 size of the uncompressed buffer is returned in DestinationSize, the size of
718 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
719 The GetInfo() function does not have scratch buffer available to perform a
720 thorough checking of the validity of the source data. It just retrieves the
721 "Original Size" field from the beginning bytes of the source data and output
722 it as DestinationSize. And ScratchSize is specific to the decompression
725 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
726 @param Source The source buffer containing the compressed data.
727 @param SourceSize The size, in bytes, of the source buffer.
728 @param DestinationSize A pointer to the size, in bytes, of the
729 uncompressed buffer that will be generated when the
730 compressed buffer specified by Source and
731 SourceSize is decompressed.
732 @param ScratchSize A pointer to the size, in bytes, of the scratch
733 buffer that is required to decompress the
734 compressed buffer specified by Source and
737 @retval EFI_SUCCESS The size of the uncompressed data was returned in
738 DestinationSize and the size of the scratch buffer
739 was returned in ScratchSize.
740 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
741 the scratch buffer cannot be determined from the
742 compressed data specified by Source and
748 DxeMainUefiDecompressGetInfo (
749 IN EFI_DECOMPRESS_PROTOCOL
*This
,
751 IN UINT32 SourceSize
,
752 OUT UINT32
*DestinationSize
,
753 OUT UINT32
*ScratchSize
756 if (Source
== NULL
|| DestinationSize
== NULL
|| ScratchSize
== NULL
) {
757 return EFI_INVALID_PARAMETER
;
759 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
764 Decompresses a compressed source buffer.
766 The Decompress() function extracts decompressed data to its original form.
767 This protocol is designed so that the decompression algorithm can be
768 implemented without using any memory services. As a result, the Decompress()
769 Function is not allowed to call AllocatePool() or AllocatePages() in its
770 implementation. It is the caller's responsibility to allocate and free the
771 Destination and Scratch buffers.
772 If the compressed source data specified by Source and SourceSize is
773 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
774 the compressed source data specified by Source and SourceSize is not in a
775 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
777 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
778 @param Source The source buffer containing the compressed data.
779 @param SourceSize SourceSizeThe size of source data.
780 @param Destination On output, the destination buffer that contains
781 the uncompressed data.
782 @param DestinationSize The size of the destination buffer. The size of
783 the destination buffer needed is obtained from
784 EFI_DECOMPRESS_PROTOCOL.GetInfo().
785 @param Scratch A temporary scratch buffer that is used to perform
787 @param ScratchSize The size of scratch buffer. The size of the
788 scratch buffer needed is obtained from GetInfo().
790 @retval EFI_SUCCESS Decompression completed successfully, and the
791 uncompressed buffer is returned in Destination.
792 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
793 SourceSize is corrupted (not in a valid
799 DxeMainUefiDecompress (
800 IN EFI_DECOMPRESS_PROTOCOL
*This
,
802 IN UINT32 SourceSize
,
803 IN OUT VOID
*Destination
,
804 IN UINT32 DestinationSize
,
805 IN OUT VOID
*Scratch
,
806 IN UINT32 ScratchSize
810 UINT32 TestDestinationSize
;
811 UINT32 TestScratchSize
;
813 if (Source
== NULL
|| Destination
== NULL
|| Scratch
== NULL
) {
814 return EFI_INVALID_PARAMETER
;
817 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
818 if (EFI_ERROR (Status
)) {
822 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
823 return RETURN_INVALID_PARAMETER
;
826 return UefiDecompress (Source
, Destination
, Scratch
);