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 // 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 (0,PEI_TOK
, NULL
, 0) ;
262 PERF_START (0,DXE_TOK
, 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 // Initialize the Event Services
313 Status
= CoreInitializeEventServices ();
314 ASSERT_EFI_ERROR (Status
);
318 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
320 // These Protocols are not architectural. This implementation is sharing code between
321 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
322 // as part of the DXE Core. However, that would also require the DXE Core to be ported
323 // each time a different CPU is used, a different Decompression algorithm is used, or a
324 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
325 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
326 // and from CPU to CPU.
330 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
332 Status
= CoreInstallMultipleProtocolInterfaces (
334 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
337 ASSERT_EFI_ERROR (Status
);
340 // Register for the GUIDs of the Architectural Protocols, so the rest of the
341 // EFI Boot Services and EFI Runtime Services tables can be filled in.
343 CoreNotifyOnArchProtocolInstallation ();
346 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
348 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
349 ASSERT_EFI_ERROR (Status
);
351 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
352 ASSERT_EFI_ERROR (Status
);
355 // Produce the Section Extraction Protocol
357 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
358 ASSERT_EFI_ERROR (Status
);
361 // Initialize the DXE Dispatcher
363 PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ;
364 CoreInitializeDispatcher ();
365 PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ;
368 // Invoke the DXE Dispatcher
370 PERF_START (0, "CoreDispatcher", "DxeMain", 0);
372 PERF_END (0, "CoreDispatcher", "DxeMain", 0);
375 // Display Architectural protocols that were not loaded if this is DEBUG build
378 CoreDisplayMissingArchProtocols ();
382 // Display any drivers that were not dispatched because dependency expression
383 // evaluated to false if this is a debug build
386 CoreDisplayDiscoveredNotDispatched ();
390 // Assert if the Architectural Protocols are not present.
392 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
395 // Report Status code before transfer control to BDS
399 FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds
)
403 // Transfer control to the BDS Architectural Protocol
408 // BDS should never return
417 Place holder function until all the Boot Services and Runtime Services are
420 @return EFI_NOT_AVAILABLE_YET
425 CoreEfiNotAvailableYetArg0 (
430 // This function should never be executed. If it does, then the architectural protocols
431 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
432 // DXE Core and all the Architectural Protocols are complete.
435 return EFI_NOT_AVAILABLE_YET
;
440 Place holder function until all the Boot Services and Runtime Services are
443 @param Arg1 Undefined
445 @return EFI_NOT_AVAILABLE_YET
450 CoreEfiNotAvailableYetArg1 (
455 // This function should never be executed. If it does, then the architectural protocols
456 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
457 // DXE Core and all the Architectural Protocols are complete.
460 return EFI_NOT_AVAILABLE_YET
;
465 Place holder function until all the Boot Services and Runtime Services are available.
467 @param Arg1 Undefined
468 @param Arg2 Undefined
470 @return EFI_NOT_AVAILABLE_YET
475 CoreEfiNotAvailableYetArg2 (
481 // This function should never be executed. If it does, then the architectural protocols
482 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
483 // DXE Core and all the Architectural Protocols are complete.
486 return EFI_NOT_AVAILABLE_YET
;
491 Place holder function until all the Boot Services and Runtime Services are available.
493 @param Arg1 Undefined
494 @param Arg2 Undefined
495 @param Arg3 Undefined
497 @return EFI_NOT_AVAILABLE_YET
502 CoreEfiNotAvailableYetArg3 (
509 // This function should never be executed. If it does, then the architectural protocols
510 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
511 // DXE Core and all the Architectural Protocols are complete.
514 return EFI_NOT_AVAILABLE_YET
;
519 Place holder function until all the Boot Services and Runtime Services are available.
521 @param Arg1 Undefined
522 @param Arg2 Undefined
523 @param Arg3 Undefined
524 @param Arg4 Undefined
526 @return EFI_NOT_AVAILABLE_YET
531 CoreEfiNotAvailableYetArg4 (
539 // This function should never be executed. If it does, then the architectural protocols
540 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
541 // DXE Core and all the Architectural Protocols are complete.
544 return EFI_NOT_AVAILABLE_YET
;
549 Place holder function until all the Boot Services and Runtime Services are available.
551 @param Arg1 Undefined
552 @param Arg2 Undefined
553 @param Arg3 Undefined
554 @param Arg4 Undefined
555 @param Arg5 Undefined
557 @return EFI_NOT_AVAILABLE_YET
562 CoreEfiNotAvailableYetArg5 (
571 // This function should never be executed. If it does, then the architectural protocols
572 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
573 // DXE Core and all the Architectural Protocols are complete.
576 return EFI_NOT_AVAILABLE_YET
;
581 Calcualte the 32-bit CRC in a EFI table using the service provided by the
584 @param Hdr Pointer to an EFI standard header
589 IN OUT EFI_TABLE_HEADER
*Hdr
597 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
598 // Crc will come back as zero if we set it to zero here
601 gBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
607 Terminates all boot services.
609 @param ImageHandle Handle that identifies the exiting image.
610 @param MapKey Key to the latest memory map.
612 @retval EFI_SUCCESS Boot Services terminated
613 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
618 CoreExitBootServices (
619 IN EFI_HANDLE ImageHandle
,
624 EFI_STATUS StatusTemp
;
625 EFI_TCG_PLATFORM_PROTOCOL
*TcgPlatformProtocol
;
628 // Measure invocation of ExitBootServices,
629 // which is defined by TCG_EFI_Platform_1_20_Final Specification
631 TcgPlatformProtocol
= NULL
;
632 Status
= CoreLocateProtocol (
633 &gEfiTcgPlatformProtocolGuid
,
635 (VOID
**) &TcgPlatformProtocol
637 if (!EFI_ERROR (Status
)) {
638 Status
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION
);
639 ASSERT_EFI_ERROR (Status
);
643 // Terminate memory services if the MapKey matches
645 Status
= CoreTerminateMemoryMap (MapKey
);
646 if (EFI_ERROR (Status
)) {
648 // Measure failure of ExitBootServices
650 if (TcgPlatformProtocol
!= NULL
) {
651 StatusTemp
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED
);
652 ASSERT_EFI_ERROR (StatusTemp
);
659 // Notify other drivers that we are exiting boot services.
661 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
666 gTimer
->SetTimerPeriod (gTimer
, 0);
669 // Disable CPU Interrupts
671 gCpu
->DisableInterrupt (gCpu
);
674 // Report that ExitBootServices() has been called
678 FixedPcdGet32 (PcdStatusCodeValueBootServiceExit
)
682 // Clear the non-runtime values of the EFI System Table
684 gDxeCoreST
->BootServices
= NULL
;
685 gDxeCoreST
->ConIn
= NULL
;
686 gDxeCoreST
->ConsoleInHandle
= NULL
;
687 gDxeCoreST
->ConOut
= NULL
;
688 gDxeCoreST
->ConsoleOutHandle
= NULL
;
689 gDxeCoreST
->StdErr
= NULL
;
690 gDxeCoreST
->StandardErrorHandle
= NULL
;
693 // Recompute the 32-bit CRC of the EFI System Table
695 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
698 // Zero out the Boot Service Table
700 ZeroMem (gBS
, sizeof (EFI_BOOT_SERVICES
));
704 // Update the AtRuntime field in Runtiem AP.
706 gRuntime
->AtRuntime
= TRUE
;
709 // Measure success of ExitBootServices
711 if (TcgPlatformProtocol
!= NULL
) {
712 StatusTemp
= TcgPlatformProtocol
->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED
);
713 ASSERT_EFI_ERROR (StatusTemp
);
721 Given a compressed source buffer, this function retrieves the size of the
722 uncompressed buffer and the size of the scratch buffer required to decompress
723 the compressed source buffer.
725 The GetInfo() function retrieves the size of the uncompressed buffer and the
726 temporary scratch buffer required to decompress the buffer specified by Source
727 and SourceSize. If the size of the uncompressed buffer or the size of the
728 scratch buffer cannot be determined from the compressed data specified by
729 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
730 size of the uncompressed buffer is returned in DestinationSize, the size of
731 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
732 The GetInfo() function does not have scratch buffer available to perform a
733 thorough checking of the validity of the source data. It just retrieves the
734 "Original Size" field from the beginning bytes of the source data and output
735 it as DestinationSize. And ScratchSize is specific to the decompression
738 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
739 @param Source The source buffer containing the compressed data.
740 @param SourceSize The size, in bytes, of the source buffer.
741 @param DestinationSize A pointer to the size, in bytes, of the
742 uncompressed buffer that will be generated when the
743 compressed buffer specified by Source and
744 SourceSize is decompressed.
745 @param ScratchSize A pointer to the size, in bytes, of the scratch
746 buffer that is required to decompress the
747 compressed buffer specified by Source and
750 @retval EFI_SUCCESS The size of the uncompressed data was returned in
751 DestinationSize and the size of the scratch buffer
752 was returned in ScratchSize.
753 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
754 the scratch buffer cannot be determined from the
755 compressed data specified by Source and
761 DxeMainUefiDecompressGetInfo (
762 IN EFI_DECOMPRESS_PROTOCOL
*This
,
764 IN UINT32 SourceSize
,
765 OUT UINT32
*DestinationSize
,
766 OUT UINT32
*ScratchSize
769 if (Source
== NULL
|| DestinationSize
== NULL
|| ScratchSize
== NULL
) {
770 return EFI_INVALID_PARAMETER
;
772 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
777 Decompresses a compressed source buffer.
779 The Decompress() function extracts decompressed data to its original form.
780 This protocol is designed so that the decompression algorithm can be
781 implemented without using any memory services. As a result, the Decompress()
782 Function is not allowed to call AllocatePool() or AllocatePages() in its
783 implementation. It is the caller's responsibility to allocate and free the
784 Destination and Scratch buffers.
785 If the compressed source data specified by Source and SourceSize is
786 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
787 the compressed source data specified by Source and SourceSize is not in a
788 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
790 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
791 @param Source The source buffer containing the compressed data.
792 @param SourceSize SourceSizeThe size of source data.
793 @param Destination On output, the destination buffer that contains
794 the uncompressed data.
795 @param DestinationSize The size of the destination buffer. The size of
796 the destination buffer needed is obtained from
797 EFI_DECOMPRESS_PROTOCOL.GetInfo().
798 @param Scratch A temporary scratch buffer that is used to perform
800 @param ScratchSize The size of scratch buffer. The size of the
801 scratch buffer needed is obtained from GetInfo().
803 @retval EFI_SUCCESS Decompression completed successfully, and the
804 uncompressed buffer is returned in Destination.
805 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
806 SourceSize is corrupted (not in a valid
812 DxeMainUefiDecompress (
813 IN EFI_DECOMPRESS_PROTOCOL
*This
,
815 IN UINT32 SourceSize
,
816 IN OUT VOID
*Destination
,
817 IN UINT32 DestinationSize
,
818 IN OUT VOID
*Scratch
,
819 IN UINT32 ScratchSize
823 UINT32 TestDestinationSize
;
824 UINT32 TestScratchSize
;
826 if (Source
== NULL
|| Destination
== NULL
|| Scratch
== NULL
) {
827 return EFI_INVALID_PARAMETER
;
830 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
831 if (EFI_ERROR (Status
)) {
835 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
836 return RETURN_INVALID_PARAMETER
;
839 return UefiDecompress (Source
, Destination
, Scratch
);