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
;
34 // BugBug: I'n not runtime, but is the PPI?
36 EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance
= {
40 EFI_STATUS_CODE_PROTOCOL
*gStatusCode
= &gStatusCodeInstance
;
44 // DXE Core Global used to update core loaded image protocol handle
46 EFI_GUID
*gDxeCoreFileName
;
47 EFI_LOADED_IMAGE_PROTOCOL
*gDxeCoreLoadedImage
;
52 // DXE Core Module Variables
55 EFI_BOOT_SERVICES mBootServices
= {
57 EFI_BOOT_SERVICES_SIGNATURE
, // Signature
58 EFI_BOOT_SERVICES_REVISION
, // Revision
59 sizeof (EFI_BOOT_SERVICES
), // HeaderSize
63 (EFI_RAISE_TPL
) CoreRaiseTpl
, // RaiseTPL
64 (EFI_RESTORE_TPL
) CoreRestoreTpl
, // RestoreTPL
65 (EFI_ALLOCATE_PAGES
) CoreAllocatePages
, // AllocatePages
66 (EFI_FREE_PAGES
) CoreFreePages
, // FreePages
67 (EFI_GET_MEMORY_MAP
) CoreGetMemoryMap
, // GetMemoryMap
68 (EFI_ALLOCATE_POOL
) CoreAllocatePool
, // AllocatePool
69 (EFI_FREE_POOL
) CoreFreePool
, // FreePool
70 (EFI_CREATE_EVENT
) CoreCreateEvent
, // CreateEvent
71 (EFI_SET_TIMER
) CoreSetTimer
, // SetTimer
72 (EFI_WAIT_FOR_EVENT
) CoreWaitForEvent
, // WaitForEvent
73 (EFI_SIGNAL_EVENT
) CoreSignalEvent
, // SignalEvent
74 (EFI_CLOSE_EVENT
) CoreCloseEvent
, // CloseEvent
75 (EFI_CHECK_EVENT
) CoreCheckEvent
, // CheckEvent
76 (EFI_INSTALL_PROTOCOL_INTERFACE
) CoreInstallProtocolInterface
, // InstallProtocolInterface
77 (EFI_REINSTALL_PROTOCOL_INTERFACE
) CoreReinstallProtocolInterface
, // ReinstallProtocolInterface
78 (EFI_UNINSTALL_PROTOCOL_INTERFACE
) CoreUninstallProtocolInterface
, // UninstallProtocolInterface
79 (EFI_HANDLE_PROTOCOL
) CoreHandleProtocol
, // HandleProtocol
80 (VOID
*) NULL
, // Reserved
81 (EFI_REGISTER_PROTOCOL_NOTIFY
) CoreRegisterProtocolNotify
, // RegisterProtocolNotify
82 (EFI_LOCATE_HANDLE
) CoreLocateHandle
, // LocateHandle
83 (EFI_LOCATE_DEVICE_PATH
) CoreLocateDevicePath
, // LocateDevicePath
84 (EFI_INSTALL_CONFIGURATION_TABLE
) CoreInstallConfigurationTable
, // InstallConfigurationTable
85 (EFI_IMAGE_LOAD
) CoreLoadImage
, // LoadImage
86 (EFI_IMAGE_START
) CoreStartImage
, // StartImage
87 (EFI_EXIT
) CoreExit
, // Exit
88 (EFI_IMAGE_UNLOAD
) CoreUnloadImage
, // UnloadImage
89 (EFI_EXIT_BOOT_SERVICES
) CoreExitBootServices
, // ExitBootServices
90 (EFI_GET_NEXT_MONOTONIC_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextMonotonicCount
91 (EFI_STALL
) CoreStall
, // Stall
92 (EFI_SET_WATCHDOG_TIMER
) CoreSetWatchdogTimer
, // SetWatchdogTimer
93 (EFI_CONNECT_CONTROLLER
) CoreConnectController
, // ConnectController
94 (EFI_DISCONNECT_CONTROLLER
) CoreDisconnectController
, // DisconnectController
95 (EFI_OPEN_PROTOCOL
) CoreOpenProtocol
, // OpenProtocol
96 (EFI_CLOSE_PROTOCOL
) CoreCloseProtocol
, // CloseProtocol
97 (EFI_OPEN_PROTOCOL_INFORMATION
) CoreOpenProtocolInformation
, // OpenProtocolInformation
98 (EFI_PROTOCOLS_PER_HANDLE
) CoreProtocolsPerHandle
, // ProtocolsPerHandle
99 (EFI_LOCATE_HANDLE_BUFFER
) CoreLocateHandleBuffer
, // LocateHandleBuffer
100 (EFI_LOCATE_PROTOCOL
) CoreLocateProtocol
, // LocateProtocol
101 (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreInstallMultipleProtocolInterfaces
, // InstallMultipleProtocolInterfaces
102 (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES
) CoreUninstallMultipleProtocolInterfaces
, // UninstallMultipleProtocolInterfaces
103 (EFI_CALCULATE_CRC32
) CoreEfiNotAvailableYetArg3
, // CalculateCrc32
104 (EFI_COPY_MEM
) CopyMem
, // CopyMem
105 (EFI_SET_MEM
) SetMem
, // SetMem
106 (EFI_CREATE_EVENT_EX
) CoreCreateEventEx
// CreateEventEx
109 EFI_DXE_SERVICES mDxeServices
= {
111 DXE_SERVICES_SIGNATURE
, // Signature
112 DXE_SERVICES_REVISION
, // Revision
113 sizeof (DXE_SERVICES
), // HeaderSize
117 (EFI_ADD_MEMORY_SPACE
) CoreAddMemorySpace
, // AddMemorySpace
118 (EFI_ALLOCATE_MEMORY_SPACE
) CoreAllocateMemorySpace
, // AllocateMemorySpace
119 (EFI_FREE_MEMORY_SPACE
) CoreFreeMemorySpace
, // FreeMemorySpace
120 (EFI_REMOVE_MEMORY_SPACE
) CoreRemoveMemorySpace
, // RemoveMemorySpace
121 (EFI_GET_MEMORY_SPACE_DESCRIPTOR
) CoreGetMemorySpaceDescriptor
, // GetMemorySpaceDescriptor
122 (EFI_SET_MEMORY_SPACE_ATTRIBUTES
) CoreSetMemorySpaceAttributes
, // SetMemorySpaceAttributes
123 (EFI_GET_MEMORY_SPACE_MAP
) CoreGetMemorySpaceMap
, // GetMemorySpaceMap
124 (EFI_ADD_IO_SPACE
) CoreAddIoSpace
, // AddIoSpace
125 (EFI_ALLOCATE_IO_SPACE
) CoreAllocateIoSpace
, // AllocateIoSpace
126 (EFI_FREE_IO_SPACE
) CoreFreeIoSpace
, // FreeIoSpace
127 (EFI_REMOVE_IO_SPACE
) CoreRemoveIoSpace
, // RemoveIoSpace
128 (EFI_GET_IO_SPACE_DESCRIPTOR
) CoreGetIoSpaceDescriptor
, // GetIoSpaceDescriptor
129 (EFI_GET_IO_SPACE_MAP
) CoreGetIoSpaceMap
, // GetIoSpaceMap
130 (EFI_DISPATCH
) CoreDispatcher
, // Dispatch
131 (EFI_SCHEDULE
) CoreSchedule
, // Schedule
132 (EFI_TRUST
) CoreTrust
, // Trust
133 (EFI_PROCESS_FIRMWARE_VOLUME
) CoreProcessFirmwareVolume
, // ProcessFirmwareVolume
136 EFI_SYSTEM_TABLE mEfiSystemTableTemplate
= {
138 EFI_SYSTEM_TABLE_SIGNATURE
, // Signature
139 EFI_SYSTEM_TABLE_REVISION
, // Revision
140 sizeof (EFI_SYSTEM_TABLE
), // HeaderSize
144 NULL
, // FirmwareVendor
145 0, // FirmwareRevision
146 NULL
, // ConsoleInHandle
148 NULL
, // ConsoleOutHandle
150 NULL
, // StandardErrorHandle
152 NULL
, // RuntimeServices
153 &mBootServices
, // BootServices
154 0, // NumberOfConfigurationTableEntries
155 NULL
// ConfigurationTable
158 EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate
= {
160 EFI_RUNTIME_SERVICES_SIGNATURE
, // Signature
161 EFI_RUNTIME_SERVICES_REVISION
, // Revision
162 sizeof (EFI_RUNTIME_SERVICES
), // HeaderSize
166 (EFI_GET_TIME
) CoreEfiNotAvailableYetArg2
, // GetTime
167 (EFI_SET_TIME
) CoreEfiNotAvailableYetArg1
, // SetTime
168 (EFI_GET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg3
, // GetWakeupTime
169 (EFI_SET_WAKEUP_TIME
) CoreEfiNotAvailableYetArg2
, // SetWakeupTime
170 (EFI_SET_VIRTUAL_ADDRESS_MAP
) CoreEfiNotAvailableYetArg4
, // SetVirtualAddressMap
171 (EFI_CONVERT_POINTER
) CoreEfiNotAvailableYetArg2
, // ConvertPointer
172 (EFI_GET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // GetVariable
173 (EFI_GET_NEXT_VARIABLE_NAME
) CoreEfiNotAvailableYetArg3
, // GetNextVariableName
174 (EFI_SET_VARIABLE
) CoreEfiNotAvailableYetArg5
, // SetVariable
175 (EFI_GET_NEXT_HIGH_MONO_COUNT
) CoreEfiNotAvailableYetArg1
, // GetNextHighMonotonicCount
176 (EFI_RESET_SYSTEM
) CoreEfiNotAvailableYetArg4
, // ResetSystem
177 (EFI_UPDATE_CAPSULE
) CoreEfiNotAvailableYetArg3
, // UpdateCapsule
178 (EFI_QUERY_CAPSULE_CAPABILITIES
) CoreEfiNotAvailableYetArg4
, // QueryCapsuleCapabilities
179 (EFI_QUERY_VARIABLE_INFO
) CoreEfiNotAvailableYetArg4
// QueryVariableInfo
182 EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate
= {
183 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.ImageHead
),
184 INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate
.EventHead
),
187 // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
188 // prevent people from having pointer math bugs in their code.
189 // now you have to use *DescriptorSize to make things work.
191 sizeof (EFI_MEMORY_DESCRIPTOR
) + sizeof (UINT64
) - (sizeof (EFI_MEMORY_DESCRIPTOR
) % sizeof (UINT64
)),
192 EFI_MEMORY_DESCRIPTOR_VERSION
,
200 EFI_RUNTIME_ARCH_PROTOCOL
*gRuntime
= &gRuntimeTemplate
;
203 // DXE Core Global Variables for the EFI System Table, Boot Services Table,
204 // DXE Services Table, and Runtime Services Table
206 EFI_BOOT_SERVICES
*gDxeCoreBS
= &mBootServices
;
207 EFI_DXE_SERVICES
*gDxeCoreDS
= &mDxeServices
;
208 EFI_SYSTEM_TABLE
*gDxeCoreST
= NULL
;
211 // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory
212 // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it
213 // a value that will not cause debug infrastructure to crash early on.
215 EFI_RUNTIME_SERVICES
*gDxeCoreRT
= &mEfiRuntimeServicesTableTemplate
;
216 EFI_HANDLE gDxeCoreImageHandle
= NULL
;
221 // EFI Decompress Protocol
223 EFI_DECOMPRESS_PROTOCOL gEfiDecompress
= {
224 DxeMainUefiDecompressGetInfo
,
225 DxeMainUefiDecompress
229 // Main entry point to the DXE Core
233 Main entry point to DXE Core.
235 @param HobStart Pointer to the beginning of the HOB List from
238 @return This function should never return
248 EFI_PHYSICAL_ADDRESS MemoryBaseAddress
;
251 mHobStart
= HobStart
;
254 // Initialize Memory Services
256 CoreInitializeMemoryServices (&HobStart
, &MemoryBaseAddress
, &MemoryLength
);
259 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
260 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
262 gDxeCoreST
= CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE
), &mEfiSystemTableTemplate
);
263 ASSERT (gDxeCoreST
!= NULL
);
265 gDxeCoreRT
= CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES
), &mEfiRuntimeServicesTableTemplate
);
266 ASSERT (gDxeCoreRT
!= NULL
);
268 gDxeCoreST
->RuntimeServices
= gDxeCoreRT
;
271 // Start the Image Services.
273 Status
= CoreInitializeImageServices (HobStart
);
274 ASSERT_EFI_ERROR (Status
);
277 // Call constructor for all libraries
279 ProcessLibraryConstructorList (gDxeCoreImageHandle
, gDxeCoreST
);
280 PERF_END (0,PEI_TOK
, NULL
, 0) ;
281 PERF_START (0,DXE_TOK
, NULL
, 0) ;
284 // Initialize the Global Coherency Domain Services
286 Status
= CoreInitializeGcdServices (&HobStart
, MemoryBaseAddress
, MemoryLength
);
287 ASSERT_EFI_ERROR (Status
);
290 // The HobStart is relocated in gcd service init. Sync mHobStart varible.
292 mHobStart
= HobStart
;
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 // Initialize the ReportStatusCode with PEI version, if available
314 CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid
, (VOID
**)&gStatusCode
->ReportStatusCode
);
317 // Report Status Code here for DXE_ENTRY_POINT once it is available
319 CoreReportProgressCode (FixedPcdGet32(PcdStatusCodeValueDxeCoreEntry
));
322 // Create the aligned system table pointer structure that is used by external
323 // debuggers to locate the system table... Also, install debug image info
324 // configuration table.
326 CoreInitializeDebugImageInfoTable ();
327 CoreNewDebugImageInfoEntry (
328 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL
,
333 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "HOBLIST address in DXE = 0x%016lx\n", (UINT64
) (UINTN
) HobStart
));
336 // Initialize the Event Services
338 Status
= CoreInitializeEventServices ();
339 ASSERT_EFI_ERROR (Status
);
343 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
345 // These Protocols are not architectural. This implementation is sharing code between
346 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
347 // as part of the DXE Core. However, that would also require the DXE Core to be ported
348 // each time a different CPU is used, a different Decompression algorithm is used, or a
349 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
350 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
351 // and from CPU to CPU.
355 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
357 Status
= CoreInstallMultipleProtocolInterfaces (
359 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
362 ASSERT_EFI_ERROR (Status
);
365 // Register for the GUIDs of the Architectural Protocols, so the rest of the
366 // EFI Boot Services and EFI Runtime Services tables can be filled in.
368 CoreNotifyOnArchProtocolInstallation ();
371 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
373 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
374 ASSERT_EFI_ERROR (Status
);
376 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
377 ASSERT_EFI_ERROR (Status
);
380 // Produce the Section Extraction Protocol
382 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
383 ASSERT_EFI_ERROR (Status
);
386 // Initialize the DXE Dispatcher
388 PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ;
389 CoreInitializeDispatcher ();
390 PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ;
393 // Invoke the DXE Dispatcher
395 PERF_START (0, "CoreDispatcher", "DxeMain", 0);
397 PERF_END (0, "CoreDispatcher", "DxeMain", 0);
400 // Display Architectural protocols that were not loaded if this is DEBUG build
403 CoreDisplayMissingArchProtocols ();
407 // Assert if the Architectural Protocols are not present.
409 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
412 // Report Status code before transfer control to BDS
414 CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds
));
416 // Display any drivers that were not dispatched because dependency expression
417 // evaluated to false if this is a debug build
420 CoreDisplayDiscoveredNotDispatched ();
424 // Transfer control to the BDS Architectural Protocol
429 // BDS should never return
438 Place holder function until all the Boot Services and Runtime Services are
441 @return EFI_NOT_AVAILABLE_YET
446 CoreEfiNotAvailableYetArg0 (
451 // This function should never be executed. If it does, then the architectural protocols
452 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
453 // DXE Core and all the Architectural Protocols are complete.
456 return EFI_NOT_AVAILABLE_YET
;
461 Place holder function until all the Boot Services and Runtime Services are
464 @param Arg1 Undefined
466 @return EFI_NOT_AVAILABLE_YET
471 CoreEfiNotAvailableYetArg1 (
476 // This function should never be executed. If it does, then the architectural protocols
477 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
478 // DXE Core and all the Architectural Protocols are complete.
481 return EFI_NOT_AVAILABLE_YET
;
486 Place holder function until all the Boot Services and Runtime Services are available.
488 @param Arg1 Undefined
489 @param Arg2 Undefined
491 @return EFI_NOT_AVAILABLE_YET
496 CoreEfiNotAvailableYetArg2 (
502 // This function should never be executed. If it does, then the architectural protocols
503 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
504 // DXE Core and all the Architectural Protocols are complete.
507 return EFI_NOT_AVAILABLE_YET
;
512 Place holder function until all the Boot Services and Runtime Services are available.
514 @param Arg1 Undefined
515 @param Arg2 Undefined
516 @param Arg3 Undefined
518 @return EFI_NOT_AVAILABLE_YET
523 CoreEfiNotAvailableYetArg3 (
530 // This function should never be executed. If it does, then the architectural protocols
531 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
532 // DXE Core and all the Architectural Protocols are complete.
535 return EFI_NOT_AVAILABLE_YET
;
540 Place holder function until all the Boot Services and Runtime Services are available.
542 @param Arg1 Undefined
543 @param Arg2 Undefined
544 @param Arg3 Undefined
545 @param Arg4 Undefined
547 @return EFI_NOT_AVAILABLE_YET
552 CoreEfiNotAvailableYetArg4 (
560 // This function should never be executed. If it does, then the architectural protocols
561 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
562 // DXE Core and all the Architectural Protocols are complete.
565 return EFI_NOT_AVAILABLE_YET
;
570 Place holder function until all the Boot Services and Runtime Services are available.
572 @param Arg1 Undefined
573 @param Arg2 Undefined
574 @param Arg3 Undefined
575 @param Arg4 Undefined
576 @param Arg5 Undefined
578 @return EFI_NOT_AVAILABLE_YET
583 CoreEfiNotAvailableYetArg5 (
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
;
603 Searches for a Protocol Interface passed from PEI through a HOB.
605 @param ProtocolGuid The Protocol GUID to search for in the HOB List
606 @param Interface A pointer to the interface for the Protocol GUID
608 @retval EFI_SUCCESS The Protocol GUID was found and its interface is
609 returned in Interface
610 @retval EFI_NOT_FOUND The Protocol GUID was not found in the HOB List
615 IN EFI_GUID
*ProtocolGuid
,
619 EFI_HOB_GUID_TYPE
*GuidHob
;
622 GuidHob
= GetNextGuidHob (ProtocolGuid
, mHobStart
);
623 if (GuidHob
== NULL
) {
624 return EFI_NOT_FOUND
;
627 Buffer
= GET_GUID_HOB_DATA (GuidHob
);
628 ASSERT (Buffer
!= NULL
);
630 *Interface
= (VOID
*)(*(UINTN
*)(Buffer
));
638 Calcualte the 32-bit CRC in a EFI table using the service provided by the
641 @param Hdr Pointer to an EFI standard header
646 IN OUT EFI_TABLE_HEADER
*Hdr
654 // If gDxeCoreBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
655 // Crc will come back as zero if we set it to zero here
658 gDxeCoreBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
666 Terminates all boot services.
668 @param ImageHandle Handle that identifies the exiting image.
669 @param MapKey Key to the latest memory map.
671 @retval EFI_SUCCESS Boot Services terminated
672 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
677 CoreExitBootServices (
678 IN EFI_HANDLE ImageHandle
,
683 EFI_STATUS StatusTemp
;
684 EFI_TCG_PLATFORM_PROTOCOL
*TcgPlatformProtocol
;
687 // Measure invocation of ExitBootServices,
688 // which is defined by TCG_EFI_Platform_1_20_Final Specification
690 TcgPlatformProtocol
= NULL
;
691 Status
= CoreLocateProtocol (
692 &gEfiTcgPlatformProtocolGuid
,
694 (VOID
**) &TcgPlatformProtocol
696 if (!EFI_ERROR (Status
)) {
697 Status
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION
);
698 ASSERT_EFI_ERROR (Status
);
702 // Terminate memory services if the MapKey matches
704 Status
= CoreTerminateMemoryMap (MapKey
);
705 if (EFI_ERROR (Status
)) {
707 // Measure failure of ExitBootServices
709 if (TcgPlatformProtocol
!= NULL
) {
710 StatusTemp
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED
);
711 ASSERT_EFI_ERROR (StatusTemp
);
718 // Notify other drivers that we are exiting boot services.
720 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
725 gTimer
->SetTimerPeriod (gTimer
, 0);
728 // Disable CPU Interrupts
730 gCpu
->DisableInterrupt (gCpu
);
733 // Report that ExitBootServices() has been called
735 // We are using gEfiCallerIdGuid as the caller ID for Dxe Core
737 CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueBootServiceExit
));
740 // Clear the non-runtime values of the EFI System Table
742 gDxeCoreST
->BootServices
= NULL
;
743 gDxeCoreST
->ConIn
= NULL
;
744 gDxeCoreST
->ConsoleInHandle
= NULL
;
745 gDxeCoreST
->ConOut
= NULL
;
746 gDxeCoreST
->ConsoleOutHandle
= NULL
;
747 gDxeCoreST
->StdErr
= NULL
;
748 gDxeCoreST
->StandardErrorHandle
= NULL
;
751 // Recompute the 32-bit CRC of the EFI System Table
753 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
756 // Zero out the Boot Service Table
758 SetMem (gDxeCoreBS
, sizeof (EFI_BOOT_SERVICES
), 0);
762 // Update the AtRuntime field in Runtiem AP.
764 gRuntime
->AtRuntime
= TRUE
;
767 // Measure success of ExitBootServices
769 if (TcgPlatformProtocol
!= NULL
) {
770 StatusTemp
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED
);
771 ASSERT_EFI_ERROR (StatusTemp
);
779 Given a compressed source buffer, this function retrieves the size of the
780 uncompressed buffer and the size of the scratch buffer required to decompress
781 the compressed source buffer.
783 The GetInfo() function retrieves the size of the uncompressed buffer and the
784 temporary scratch buffer required to decompress the buffer specified by Source
785 and SourceSize. If the size of the uncompressed buffer or the size of the
786 scratch buffer cannot be determined from the compressed data specified by
787 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
788 size of the uncompressed buffer is returned in DestinationSize, the size of
789 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
790 The GetInfo() function does not have scratch buffer available to perform a
791 thorough checking of the validity of the source data. It just retrieves the
792 "Original Size" field from the beginning bytes of the source data and output
793 it as DestinationSize. And ScratchSize is specific to the decompression
796 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
797 @param Source The source buffer containing the compressed data.
798 @param SourceSize The size, in bytes, of the source buffer.
799 @param DestinationSize A pointer to the size, in bytes, of the
800 uncompressed buffer that will be generated when the
801 compressed buffer specified by Source and
802 SourceSize is decompressed.
803 @param ScratchSize A pointer to the size, in bytes, of the scratch
804 buffer that is required to decompress the
805 compressed buffer specified by Source and
808 @retval EFI_SUCCESS The size of the uncompressed data was returned in
809 DestinationSize and the size of the scratch buffer
810 was returned in ScratchSize.
811 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
812 the scratch buffer cannot be determined from the
813 compressed data specified by Source and
819 DxeMainUefiDecompressGetInfo (
820 IN EFI_DECOMPRESS_PROTOCOL
*This
,
822 IN UINT32 SourceSize
,
823 OUT UINT32
*DestinationSize
,
824 OUT UINT32
*ScratchSize
828 || DestinationSize
== NULL
829 || ScratchSize
== NULL
) {
830 return EFI_INVALID_PARAMETER
;
832 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
837 Decompresses a compressed source buffer.
839 The Decompress() function extracts decompressed data to its original form.
840 This protocol is designed so that the decompression algorithm can be
841 implemented without using any memory services. As a result, the Decompress()
842 Function is not allowed to call AllocatePool() or AllocatePages() in its
843 implementation. It is the caller's responsibility to allocate and free the
844 Destination and Scratch buffers.
845 If the compressed source data specified by Source and SourceSize is
846 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
847 the compressed source data specified by Source and SourceSize is not in a
848 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
850 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
851 @param Source The source buffer containing the compressed data.
852 @param SourceSize SourceSizeThe size of source data.
853 @param Destination On output, the destination buffer that contains
854 the uncompressed data.
855 @param DestinationSize The size of the destination buffer. The size of
856 the destination buffer needed is obtained from
857 EFI_DECOMPRESS_PROTOCOL.GetInfo().
858 @param Scratch A temporary scratch buffer that is used to perform
860 @param ScratchSize The size of scratch buffer. The size of the
861 scratch buffer needed is obtained from GetInfo().
863 @retval EFI_SUCCESS Decompression completed successfully, and the
864 uncompressed buffer is returned in Destination.
865 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
866 SourceSize is corrupted (not in a valid
872 DxeMainUefiDecompress (
873 IN EFI_DECOMPRESS_PROTOCOL
*This
,
875 IN UINT32 SourceSize
,
876 IN OUT VOID
*Destination
,
877 IN UINT32 DestinationSize
,
878 IN OUT VOID
*Scratch
,
879 IN UINT32 ScratchSize
883 UINT32 TestDestinationSize
;
884 UINT32 TestScratchSize
;
887 || Destination
== NULL
888 || Scratch
== NULL
) {
889 return EFI_INVALID_PARAMETER
;
892 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
893 if (EFI_ERROR (Status
)) {
897 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
898 return RETURN_INVALID_PARAMETER
;
901 return UefiDecompress (Source
, Destination
, Scratch
);