2 DXE Core Main Entry Point
4 Copyright (c) 2006 - 2008, 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 // BugBug: I'n not runtime, but is the PPI?
41 EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance
= {
45 EFI_STATUS_CODE_PROTOCOL
*gStatusCode
= &gStatusCodeInstance
;
48 // DXE Core Module Variables
51 EFI_BOOT_SERVICES mBootServices
= {
53 EFI_BOOT_SERVICES_SIGNATURE
, // Signature
54 EFI_BOOT_SERVICES_REVISION
, // Revision
55 sizeof (EFI_BOOT_SERVICES
), // HeaderSize
59 (EFI_RAISE_TPL
) CoreRaiseTpl
, // RaiseTPL
60 (EFI_RESTORE_TPL
) CoreRestoreTpl
, // RestoreTPL
61 (EFI_ALLOCATE_PAGES
) CoreAllocatePages
, // AllocatePages
62 (EFI_FREE_PAGES
) CoreFreePages
, // FreePages
63 (EFI_GET_MEMORY_MAP
) CoreGetMemoryMap
, // GetMemoryMap
64 (EFI_ALLOCATE_POOL
) CoreAllocatePool
, // AllocatePool
65 (EFI_FREE_POOL
) CoreFreePool
, // FreePool
66 (EFI_CREATE_EVENT
) CoreCreateEvent
, // CreateEvent
67 (EFI_SET_TIMER
) CoreSetTimer
, // SetTimer
68 (EFI_WAIT_FOR_EVENT
) CoreWaitForEvent
, // WaitForEvent
69 (EFI_SIGNAL_EVENT
) CoreSignalEvent
, // SignalEvent
70 (EFI_CLOSE_EVENT
) CoreCloseEvent
, // CloseEvent
71 (EFI_CHECK_EVENT
) CoreCheckEvent
, // CheckEvent
72 (EFI_INSTALL_PROTOCOL_INTERFACE
) CoreInstallProtocolInterface
, // InstallProtocolInterface
73 (EFI_REINSTALL_PROTOCOL_INTERFACE
) CoreReinstallProtocolInterface
, // ReinstallProtocolInterface
74 (EFI_UNINSTALL_PROTOCOL_INTERFACE
) CoreUninstallProtocolInterface
, // UninstallProtocolInterface
75 (EFI_HANDLE_PROTOCOL
) CoreHandleProtocol
, // HandleProtocol
76 (VOID
*) NULL
, // Reserved
77 (EFI_REGISTER_PROTOCOL_NOTIFY
) CoreRegisterProtocolNotify
, // RegisterProtocolNotify
78 (EFI_LOCATE_HANDLE
) CoreLocateHandle
, // LocateHandle
79 (EFI_LOCATE_DEVICE_PATH
) CoreLocateDevicePath
, // LocateDevicePath
80 (EFI_INSTALL_CONFIGURATION_TABLE
) CoreInstallConfigurationTable
, // InstallConfigurationTable
81 (EFI_IMAGE_LOAD
) CoreLoadImage
, // LoadImage
82 (EFI_IMAGE_START
) CoreStartImage
, // StartImage
83 (EFI_EXIT
) CoreExit
, // Exit
84 (EFI_IMAGE_UNLOAD
) CoreUnloadImage
, // UnloadImage
85 (EFI_EXIT_BOOT_SERVICES
) CoreExitBootServices
, // ExitBootServices
86 (EFI_GET_NEXT_MONOTONIC_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextMonotonicCount
87 (EFI_STALL
) CoreStall
, // Stall
88 (EFI_SET_WATCHDOG_TIMER
) CoreSetWatchdogTimer
, // SetWatchdogTimer
89 (EFI_CONNECT_CONTROLLER
) CoreConnectController
, // ConnectController
90 (EFI_DISCONNECT_CONTROLLER
) CoreDisconnectController
, // DisconnectController
91 (EFI_OPEN_PROTOCOL
) CoreOpenProtocol
, // OpenProtocol
92 (EFI_CLOSE_PROTOCOL
) CoreCloseProtocol
, // CloseProtocol
93 (EFI_OPEN_PROTOCOL_INFORMATION
) CoreOpenProtocolInformation
, // OpenProtocolInformation
94 (EFI_PROTOCOLS_PER_HANDLE
) CoreProtocolsPerHandle
, // ProtocolsPerHandle
95 (EFI_LOCATE_HANDLE_BUFFER
) CoreLocateHandleBuffer
, // LocateHandleBuffer
96 (EFI_LOCATE_PROTOCOL
) CoreLocateProtocol
, // LocateProtocol
97 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreInstallMultipleProtocolInterfaces
, // InstallMultipleProtocolInterfaces
98 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreUninstallMultipleProtocolInterfaces
, // UninstallMultipleProtocolInterfaces
99 (EFI_CALCULATE_CRC32
) CoreEfiNotAvailableYetArg3
, // CalculateCrc32
100 (EFI_COPY_MEM
) CopyMem
, // CopyMem
101 (EFI_SET_MEM
) SetMem
, // SetMem
102 (EFI_CREATE_EVENT_EX
) CoreCreateEventEx
// CreateEventEx
105 EFI_DXE_SERVICES mDxeServices
= {
107 DXE_SERVICES_SIGNATURE
, // Signature
108 DXE_SERVICES_REVISION
, // Revision
109 sizeof (DXE_SERVICES
), // HeaderSize
113 (EFI_ADD_MEMORY_SPACE
) CoreAddMemorySpace
, // AddMemorySpace
114 (EFI_ALLOCATE_MEMORY_SPACE
) CoreAllocateMemorySpace
, // AllocateMemorySpace
115 (EFI_FREE_MEMORY_SPACE
) CoreFreeMemorySpace
, // FreeMemorySpace
116 (EFI_REMOVE_MEMORY_SPACE
) CoreRemoveMemorySpace
, // RemoveMemorySpace
117 (EFI_GET_MEMORY_SPACE_DESCRIPTOR
) CoreGetMemorySpaceDescriptor
, // GetMemorySpaceDescriptor
118 (EFI_SET_MEMORY_SPACE_ATTRIBUTES
) CoreSetMemorySpaceAttributes
, // SetMemorySpaceAttributes
119 (EFI_GET_MEMORY_SPACE_MAP
) CoreGetMemorySpaceMap
, // GetMemorySpaceMap
120 (EFI_ADD_IO_SPACE
) CoreAddIoSpace
, // AddIoSpace
121 (EFI_ALLOCATE_IO_SPACE
) CoreAllocateIoSpace
, // AllocateIoSpace
122 (EFI_FREE_IO_SPACE
) CoreFreeIoSpace
, // FreeIoSpace
123 (EFI_REMOVE_IO_SPACE
) CoreRemoveIoSpace
, // RemoveIoSpace
124 (EFI_GET_IO_SPACE_DESCRIPTOR
) CoreGetIoSpaceDescriptor
, // GetIoSpaceDescriptor
125 (EFI_GET_IO_SPACE_MAP
) CoreGetIoSpaceMap
, // GetIoSpaceMap
126 (EFI_DISPATCH
) CoreDispatcher
, // Dispatch
127 (EFI_SCHEDULE
) CoreSchedule
, // Schedule
128 (EFI_TRUST
) CoreTrust
, // Trust
129 (EFI_PROCESS_FIRMWARE_VOLUME
) CoreProcessFirmwareVolume
, // ProcessFirmwareVolume
132 EFI_SYSTEM_TABLE mEfiSystemTableTemplate
= {
134 EFI_SYSTEM_TABLE_SIGNATURE
, // Signature
135 EFI_SYSTEM_TABLE_REVISION
, // Revision
136 sizeof (EFI_SYSTEM_TABLE
), // HeaderSize
140 NULL
, // FirmwareVendor
141 0, // FirmwareRevision
142 NULL
, // ConsoleInHandle
144 NULL
, // ConsoleOutHandle
146 NULL
, // StandardErrorHandle
148 NULL
, // RuntimeServices
149 &mBootServices
, // BootServices
150 0, // NumberOfConfigurationTableEntries
151 NULL
// ConfigurationTable
154 EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate
= {
156 EFI_RUNTIME_SERVICES_SIGNATURE
, // Signature
157 EFI_RUNTIME_SERVICES_REVISION
, // Revision
158 sizeof (EFI_RUNTIME_SERVICES
), // HeaderSize
162 (EFI_GET_TIME
) CoreEfiNotAvailableYetArg2
, // GetTime
163 (EFI_SET_TIME
) CoreEfiNotAvailableYetArg1
, // SetTime
164 (EFI_GET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg3
, // GetWakeupTime
165 (EFI_SET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg2
, // SetWakeupTime
166 (EFI_SET_VIRTUAL_ADDRESS_MAP
) CoreEfiNotAvailableYetArg4
, // SetVirtualAddressMap
167 (EFI_CONVERT_POINTER
) CoreEfiNotAvailableYetArg2
, // ConvertPointer
168 (EFI_GET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // GetVariable
169 (EFI_GET_NEXT_VARIABLE_NAME
) CoreEfiNotAvailableYetArg3
, // GetNextVariableName
170 (EFI_SET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // SetVariable
171 (EFI_GET_NEXT_HIGH_MONO_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextHighMonotonicCount
172 (EFI_RESET_SYSTEM
) CoreEfiNotAvailableYetArg4
, // ResetSystem
173 (EFI_UPDATE_CAPSULE
) CoreEfiNotAvailableYetArg3
, // UpdateCapsule
174 (EFI_QUERY_CAPSULE_CAPABILITIES
) CoreEfiNotAvailableYetArg4
, // QueryCapsuleCapabilities
175 (EFI_QUERY_VARIABLE_INFO
) CoreEfiNotAvailableYetArg4
// QueryVariableInfo
178 EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
= {
179 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.ImageHead
),
180 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.EventHead
),
183 // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
184 // prevent people from having pointer math bugs in their code.
185 // now you have to use *DescriptorSize to make things work.
187 sizeof (EFI_MEMORY_DESCRIPTOR
) + sizeof (UINT64
) - (sizeof (EFI_MEMORY_DESCRIPTOR
) % sizeof (UINT64
)),
188 EFI_MEMORY_DESCRIPTOR_VERSION
,
196 EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
= &gRuntimeTemplate
;
199 // DXE Core Global Variables for the EFI System Table, Boot Services Table,
200 // DXE Services Table, and Runtime Services Table
202 EFI_DXE_SERVICES
*gDxeCoreDS
= &mDxeServices
;
203 EFI_SYSTEM_TABLE
*gDxeCoreST
= NULL
;
206 // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
207 // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
208 // a value that will not cause debug infrastructure to crash early on.
210 EFI_RUNTIME_SERVICES
*gDxeCoreRT
= &mEfiRuntimeServicesTableTemplate
;
211 EFI_HANDLE gDxeCoreImageHandle
= NULL
;
215 // EFI Decompress Protocol
217 EFI_DECOMPRESS_PROTOCOL gEfiDecompress
= {
218 DxeMainUefiDecompressGetInfo
,
219 DxeMainUefiDecompress
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
;
245 // Initialize Memory Services
247 CoreInitializeMemoryServices (&HobStart
, &MemoryBaseAddress
, &MemoryLength
);
250 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
251 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
253 gDxeCoreST
= AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE
), &mEfiSystemTableTemplate
);
254 ASSERT (gDxeCoreST
!= NULL
);
256 gDxeCoreRT
= AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES
), &mEfiRuntimeServicesTableTemplate
);
257 ASSERT (gDxeCoreRT
!= NULL
);
259 gDxeCoreST
->RuntimeServices
= gDxeCoreRT
;
262 // Start the Image Services.
264 Status
= CoreInitializeImageServices (HobStart
);
265 ASSERT_EFI_ERROR (Status
);
268 // Call constructor for all libraries
270 ProcessLibraryConstructorList (gDxeCoreImageHandle
, gDxeCoreST
);
271 PERF_END (0,PEI_TOK
, NULL
, 0) ;
272 PERF_START (0,DXE_TOK
, NULL
, 0) ;
275 // Initialize the Global Coherency Domain Services
277 Status
= CoreInitializeGcdServices (&HobStart
, MemoryBaseAddress
, MemoryLength
);
278 ASSERT_EFI_ERROR (Status
);
281 // Install the DXE Services Table into the EFI System Tables's Configuration Table
283 Status
= CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid
, gDxeCoreDS
);
284 ASSERT_EFI_ERROR (Status
);
287 // Install the HOB List into the EFI System Tables's Configuration Table
289 Status
= CoreInstallConfigurationTable (&gEfiHobListGuid
, HobStart
);
290 ASSERT_EFI_ERROR (Status
);
293 // Install Memory Type Information Table into the EFI System Tables's Configuration Table
295 Status
= CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid
, &gMemoryTypeInformation
);
296 ASSERT_EFI_ERROR (Status
);
299 // Initialize the ReportStatusCode with PEI version, if available
301 CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid
, (VOID
**) &gStatusCode
->ReportStatusCode
);
304 // Report Status Code here for DXE_ENTRY_POINT once it is available
306 CoreReportProgressCode (FixedPcdGet32(PcdStatusCodeValueDxeCoreEntry
));
309 // Create the aligned system table pointer structure that is used by external
310 // debuggers to locate the system table... Also, install debug image info
311 // configuration table.
313 CoreInitializeDebugImageInfoTable ();
314 CoreNewDebugImageInfoEntry (
315 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL
,
320 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "HOBLIST address in DXE = 0x%p\n", HobStart
));
323 // Initialize the Event Services
325 Status
= CoreInitializeEventServices ();
326 ASSERT_EFI_ERROR (Status
);
330 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
332 // These Protocols are not architectural. This implementation is sharing code between
333 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
334 // as part of the DXE Core. However, that would also require the DXE Core to be ported
335 // each time a different CPU is used, a different Decompression algorithm is used, or a
336 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
337 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
338 // and from CPU to CPU.
342 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
344 Status
= CoreInstallMultipleProtocolInterfaces (
346 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
349 ASSERT_EFI_ERROR (Status
);
352 // Register for the GUIDs of the Architectural Protocols, so the rest of the
353 // EFI Boot Services and EFI Runtime Services tables can be filled in.
355 CoreNotifyOnArchProtocolInstallation ();
358 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
360 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
361 ASSERT_EFI_ERROR (Status
);
363 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
364 ASSERT_EFI_ERROR (Status
);
367 // Produce the Section Extraction Protocol
369 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
370 ASSERT_EFI_ERROR (Status
);
373 // Initialize the DXE Dispatcher
375 PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ;
376 CoreInitializeDispatcher ();
377 PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ;
380 // Invoke the DXE Dispatcher
382 PERF_START (0, "CoreDispatcher", "DxeMain", 0);
384 PERF_END (0, "CoreDispatcher", "DxeMain", 0);
387 // Display Architectural protocols that were not loaded if this is DEBUG build
390 CoreDisplayMissingArchProtocols ();
394 // Assert if the Architectural Protocols are not present.
396 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
399 // Report Status code before transfer control to BDS
401 CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds
));
404 // Display any drivers that were not dispatched because dependency expression
405 // evaluated to false if this is a debug build
408 CoreDisplayDiscoveredNotDispatched ();
412 // Transfer control to the BDS Architectural Protocol
417 // BDS should never return
426 Place holder function until all the Boot Services and Runtime Services are
429 @return EFI_NOT_AVAILABLE_YET
434 CoreEfiNotAvailableYetArg0 (
439 // This function should never be executed. If it does, then the architectural protocols
440 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
441 // DXE Core and all the Architectural Protocols are complete.
444 return EFI_NOT_AVAILABLE_YET
;
449 Place holder function until all the Boot Services and Runtime Services are
452 @param Arg1 Undefined
454 @return EFI_NOT_AVAILABLE_YET
459 CoreEfiNotAvailableYetArg1 (
464 // This function should never be executed. If it does, then the architectural protocols
465 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
466 // DXE Core and all the Architectural Protocols are complete.
469 return EFI_NOT_AVAILABLE_YET
;
474 Place holder function until all the Boot Services and Runtime Services are available.
476 @param Arg1 Undefined
477 @param Arg2 Undefined
479 @return EFI_NOT_AVAILABLE_YET
484 CoreEfiNotAvailableYetArg2 (
490 // This function should never be executed. If it does, then the architectural protocols
491 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
492 // DXE Core and all the Architectural Protocols are complete.
495 return EFI_NOT_AVAILABLE_YET
;
500 Place holder function until all the Boot Services and Runtime Services are available.
502 @param Arg1 Undefined
503 @param Arg2 Undefined
504 @param Arg3 Undefined
506 @return EFI_NOT_AVAILABLE_YET
511 CoreEfiNotAvailableYetArg3 (
518 // This function should never be executed. If it does, then the architectural protocols
519 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
520 // DXE Core and all the Architectural Protocols are complete.
523 return EFI_NOT_AVAILABLE_YET
;
528 Place holder function until all the Boot Services and Runtime Services are available.
530 @param Arg1 Undefined
531 @param Arg2 Undefined
532 @param Arg3 Undefined
533 @param Arg4 Undefined
535 @return EFI_NOT_AVAILABLE_YET
540 CoreEfiNotAvailableYetArg4 (
548 // This function should never be executed. If it does, then the architectural protocols
549 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
550 // DXE Core and all the Architectural Protocols are complete.
553 return EFI_NOT_AVAILABLE_YET
;
558 Place holder function until all the Boot Services and Runtime Services are available.
560 @param Arg1 Undefined
561 @param Arg2 Undefined
562 @param Arg3 Undefined
563 @param Arg4 Undefined
564 @param Arg5 Undefined
566 @return EFI_NOT_AVAILABLE_YET
571 CoreEfiNotAvailableYetArg5 (
580 // This function should never be executed. If it does, then the architectural protocols
581 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
582 // DXE Core and all the Architectural Protocols are complete.
585 return EFI_NOT_AVAILABLE_YET
;
591 Searches for a Protocol Interface passed from PEI through a HOB.
593 @param ProtocolGuid The Protocol GUID to search for in the HOB List
594 @param Interface A pointer to the interface for the Protocol GUID
596 @retval EFI_SUCCESS The Protocol GUID was found and its interface is
597 returned in Interface
598 @retval EFI_NOT_FOUND The Protocol GUID was not found in the HOB List
603 IN EFI_GUID
*ProtocolGuid
,
607 EFI_HOB_GUID_TYPE
*GuidHob
;
610 GuidHob
= GetFirstGuidHob (ProtocolGuid
);
611 if (GuidHob
== NULL
) {
612 return EFI_NOT_FOUND
;
615 Buffer
= GET_GUID_HOB_DATA (GuidHob
);
616 ASSERT (Buffer
!= NULL
);
618 *Interface
= (VOID
*)(*(UINTN
*)(Buffer
));
626 Calcualte the 32-bit CRC in a EFI table using the service provided by the
629 @param Hdr Pointer to an EFI standard header
634 IN OUT EFI_TABLE_HEADER
*Hdr
642 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
643 // Crc will come back as zero if we set it to zero here
646 gBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
654 Terminates all boot services.
656 @param ImageHandle Handle that identifies the exiting image.
657 @param MapKey Key to the latest memory map.
659 @retval EFI_SUCCESS Boot Services terminated
660 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
665 CoreExitBootServices (
666 IN EFI_HANDLE ImageHandle
,
671 EFI_STATUS StatusTemp
;
672 EFI_TCG_PLATFORM_PROTOCOL
*TcgPlatformProtocol
;
675 // Measure invocation of ExitBootServices,
676 // which is defined by TCG_EFI_Platform_1_20_Final Specification
678 TcgPlatformProtocol
= NULL
;
679 Status
= CoreLocateProtocol (
680 &gEfiTcgPlatformProtocolGuid
,
682 (VOID
**) &TcgPlatformProtocol
684 if (!EFI_ERROR (Status
)) {
685 Status
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION
);
686 ASSERT_EFI_ERROR (Status
);
690 // Terminate memory services if the MapKey matches
692 Status
= CoreTerminateMemoryMap (MapKey
);
693 if (EFI_ERROR (Status
)) {
695 // Measure failure of ExitBootServices
697 if (TcgPlatformProtocol
!= NULL
) {
698 StatusTemp
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED
);
699 ASSERT_EFI_ERROR (StatusTemp
);
706 // Notify other drivers that we are exiting boot services.
708 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
713 gTimer
->SetTimerPeriod (gTimer
, 0);
716 // Disable CPU Interrupts
718 gCpu
->DisableInterrupt (gCpu
);
721 // Report that ExitBootServices() has been called
723 // We are using gEfiCallerIdGuid as the caller ID for Dxe Core
725 CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueBootServiceExit
));
728 // Clear the non-runtime values of the EFI System Table
730 gDxeCoreST
->BootServices
= NULL
;
731 gDxeCoreST
->ConIn
= NULL
;
732 gDxeCoreST
->ConsoleInHandle
= NULL
;
733 gDxeCoreST
->ConOut
= NULL
;
734 gDxeCoreST
->ConsoleOutHandle
= NULL
;
735 gDxeCoreST
->StdErr
= NULL
;
736 gDxeCoreST
->StandardErrorHandle
= NULL
;
739 // Recompute the 32-bit CRC of the EFI System Table
741 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
744 // Zero out the Boot Service Table
746 ZeroMem (gBS
, sizeof (EFI_BOOT_SERVICES
));
750 // Update the AtRuntime field in Runtiem AP.
752 gRuntime
->AtRuntime
= TRUE
;
755 // Measure success of ExitBootServices
757 if (TcgPlatformProtocol
!= NULL
) {
758 StatusTemp
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED
);
759 ASSERT_EFI_ERROR (StatusTemp
);
767 Given a compressed source buffer, this function retrieves the size of the
768 uncompressed buffer and the size of the scratch buffer required to decompress
769 the compressed source buffer.
771 The GetInfo() function retrieves the size of the uncompressed buffer and the
772 temporary scratch buffer required to decompress the buffer specified by Source
773 and SourceSize. If the size of the uncompressed buffer or the size of the
774 scratch buffer cannot be determined from the compressed data specified by
775 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
776 size of the uncompressed buffer is returned in DestinationSize, the size of
777 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
778 The GetInfo() function does not have scratch buffer available to perform a
779 thorough checking of the validity of the source data. It just retrieves the
780 "Original Size" field from the beginning bytes of the source data and output
781 it as DestinationSize. And ScratchSize is specific to the decompression
784 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
785 @param Source The source buffer containing the compressed data.
786 @param SourceSize The size, in bytes, of the source buffer.
787 @param DestinationSize A pointer to the size, in bytes, of the
788 uncompressed buffer that will be generated when the
789 compressed buffer specified by Source and
790 SourceSize is decompressed.
791 @param ScratchSize A pointer to the size, in bytes, of the scratch
792 buffer that is required to decompress the
793 compressed buffer specified by Source and
796 @retval EFI_SUCCESS The size of the uncompressed data was returned in
797 DestinationSize and the size of the scratch buffer
798 was returned in ScratchSize.
799 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
800 the scratch buffer cannot be determined from the
801 compressed data specified by Source and
807 DxeMainUefiDecompressGetInfo (
808 IN EFI_DECOMPRESS_PROTOCOL
*This
,
810 IN UINT32 SourceSize
,
811 OUT UINT32
*DestinationSize
,
812 OUT UINT32
*ScratchSize
815 if (Source
== NULL
|| DestinationSize
== NULL
|| ScratchSize
== NULL
) {
816 return EFI_INVALID_PARAMETER
;
818 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
823 Decompresses a compressed source buffer.
825 The Decompress() function extracts decompressed data to its original form.
826 This protocol is designed so that the decompression algorithm can be
827 implemented without using any memory services. As a result, the Decompress()
828 Function is not allowed to call AllocatePool() or AllocatePages() in its
829 implementation. It is the caller's responsibility to allocate and free the
830 Destination and Scratch buffers.
831 If the compressed source data specified by Source and SourceSize is
832 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
833 the compressed source data specified by Source and SourceSize is not in a
834 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
836 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
837 @param Source The source buffer containing the compressed data.
838 @param SourceSize SourceSizeThe size of source data.
839 @param Destination On output, the destination buffer that contains
840 the uncompressed data.
841 @param DestinationSize The size of the destination buffer. The size of
842 the destination buffer needed is obtained from
843 EFI_DECOMPRESS_PROTOCOL.GetInfo().
844 @param Scratch A temporary scratch buffer that is used to perform
846 @param ScratchSize The size of scratch buffer. The size of the
847 scratch buffer needed is obtained from GetInfo().
849 @retval EFI_SUCCESS Decompression completed successfully, and the
850 uncompressed buffer is returned in Destination.
851 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
852 SourceSize is corrupted (not in a valid
858 DxeMainUefiDecompress (
859 IN EFI_DECOMPRESS_PROTOCOL
*This
,
861 IN UINT32 SourceSize
,
862 IN OUT VOID
*Destination
,
863 IN UINT32 DestinationSize
,
864 IN OUT VOID
*Scratch
,
865 IN UINT32 ScratchSize
869 UINT32 TestDestinationSize
;
870 UINT32 TestScratchSize
;
872 if (Source
== NULL
|| Destination
== NULL
|| Scratch
== NULL
) {
873 return EFI_INVALID_PARAMETER
;
876 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
877 if (EFI_ERROR (Status
)) {
881 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
882 return RETURN_INVALID_PARAMETER
;
885 return UefiDecompress (Source
, Destination
, Scratch
);