2 DXE Core Main Entry Point
4 Copyright (c) 2006 - 2010, 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 // For Loading modules at fixed address feature, the configuration table is to cache the top address below which to load
214 // Runtime code&boot time code
216 GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable
= {0, 0};
218 // Main entry point to the DXE Core
222 Main entry point to DXE Core.
224 @param HobStart Pointer to the beginning of the HOB List from PEI.
226 @return This function should never return.
236 EFI_PHYSICAL_ADDRESS MemoryBaseAddress
;
240 // Initialize Memory Services
242 CoreInitializeMemoryServices (&HobStart
, &MemoryBaseAddress
, &MemoryLength
);
245 // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
246 // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
248 gDxeCoreST
= AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE
), &mEfiSystemTableTemplate
);
249 ASSERT (gDxeCoreST
!= NULL
);
251 gDxeCoreRT
= AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES
), &mEfiRuntimeServicesTableTemplate
);
252 ASSERT (gDxeCoreRT
!= NULL
);
254 gDxeCoreST
->RuntimeServices
= gDxeCoreRT
;
257 // Start the Image Services.
259 Status
= CoreInitializeImageServices (HobStart
);
260 ASSERT_EFI_ERROR (Status
);
263 // Call constructor for all libraries
265 ProcessLibraryConstructorList (gDxeCoreImageHandle
, gDxeCoreST
);
266 PERF_END (NULL
,"PEI", NULL
, 0) ;
267 PERF_START (NULL
,"DXE", NULL
, 0) ;
270 // Initialize the Global Coherency Domain Services
272 Status
= CoreInitializeGcdServices (&HobStart
, MemoryBaseAddress
, MemoryLength
);
273 ASSERT_EFI_ERROR (Status
);
276 // Install the DXE Services Table into the EFI System Tables's Configuration Table
278 Status
= CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid
, gDxeCoreDS
);
279 ASSERT_EFI_ERROR (Status
);
282 // Install the HOB List into the EFI System Tables's Configuration Table
284 Status
= CoreInstallConfigurationTable (&gEfiHobListGuid
, HobStart
);
285 ASSERT_EFI_ERROR (Status
);
288 // Install Memory Type Information Table into the EFI System Tables's Configuration Table
290 Status
= CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid
, &gMemoryTypeInformation
);
291 ASSERT_EFI_ERROR (Status
);
294 // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address
295 // Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI
296 // Code and Tseg base to load SMM driver.
298 if (FixedPcdGet64(PcdLoadModuleAtFixAddressEnable
) != 0) {
299 Status
= CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid
, &gLoadModuleAtFixAddressConfigurationTable
);
300 ASSERT_EFI_ERROR (Status
);
303 // Report Status Code here for DXE_ENTRY_POINT once it is available
307 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_ENTRY_POINT
)
311 // Create the aligned system table pointer structure that is used by external
312 // debuggers to locate the system table... Also, install debug image info
313 // configuration table.
315 CoreInitializeDebugImageInfoTable ();
316 CoreNewDebugImageInfoEntry (
317 EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL
,
322 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "HOBLIST address in DXE = 0x%p\n", HobStart
));
325 EFI_PEI_HOB_POINTERS Hob
;
327 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
328 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_MEMORY_ALLOCATION
) {
329 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "Memory Allocation %08x %0lx - %0lx\n", \
330 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryType
, \
331 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
, \
332 Hob
.MemoryAllocation
->AllocDescriptor
.MemoryBaseAddress
+ Hob
.MemoryAllocation
->AllocDescriptor
.MemoryLength
- 1));
335 for (Hob
.Raw
= HobStart
; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
336 if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV2
) {
337 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "FV2 Hob %08x %0lx - %0lx\n", Hob
.FirmwareVolume2
->BaseAddress
, Hob
.FirmwareVolume2
->BaseAddress
+ Hob
.FirmwareVolume2
->Length
- 1, Hob
.ResourceDescriptor
->ResourceType
));
338 } else if (GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_FV
) {
339 DEBUG ((DEBUG_INFO
| DEBUG_LOAD
, "FV Hob %08x %0lx - %0lx\n", Hob
.FirmwareVolume
->BaseAddress
, Hob
.FirmwareVolume
->BaseAddress
+ Hob
.FirmwareVolume2
->Length
- 1, Hob
.ResourceDescriptor
->ResourceType
));
345 // Initialize the Event Services
347 Status
= CoreInitializeEventServices ();
348 ASSERT_EFI_ERROR (Status
);
352 // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
354 // These Protocols are not architectural. This implementation is sharing code between
355 // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
356 // as part of the DXE Core. However, that would also require the DXE Core to be ported
357 // each time a different CPU is used, a different Decompression algorithm is used, or a
358 // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
359 // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
360 // and from CPU to CPU.
364 // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
366 Status
= CoreInstallMultipleProtocolInterfaces (
368 &gEfiDecompressProtocolGuid
, &gEfiDecompress
,
371 ASSERT_EFI_ERROR (Status
);
374 // Register for the GUIDs of the Architectural Protocols, so the rest of the
375 // EFI Boot Services and EFI Runtime Services tables can be filled in.
377 CoreNotifyOnArchProtocolInstallation ();
380 // Produce Firmware Volume Protocols, one for each FV in the HOB list.
382 Status
= FwVolBlockDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
383 ASSERT_EFI_ERROR (Status
);
385 Status
= FwVolDriverInit (gDxeCoreImageHandle
, gDxeCoreST
);
386 ASSERT_EFI_ERROR (Status
);
389 // Produce the Section Extraction Protocol
391 Status
= InitializeSectionExtraction (gDxeCoreImageHandle
, gDxeCoreST
);
392 ASSERT_EFI_ERROR (Status
);
395 // Initialize the DXE Dispatcher
397 PERF_START (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
398 CoreInitializeDispatcher ();
399 PERF_END (NULL
,"CoreInitializeDispatcher", "DxeMain", 0) ;
402 // Invoke the DXE Dispatcher
404 PERF_START (NULL
, "CoreDispatcher", "DxeMain", 0);
406 PERF_END (NULL
, "CoreDispatcher", "DxeMain", 0);
409 // Display Architectural protocols that were not loaded if this is DEBUG build
412 CoreDisplayMissingArchProtocols ();
416 // Display any drivers that were not dispatched because dependency expression
417 // evaluated to false if this is a debug build
420 CoreDisplayDiscoveredNotDispatched ();
424 // Assert if the Architectural Protocols are not present.
426 ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
429 // Report Status code before transfer control to BDS
433 (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)
437 // Transfer control to the BDS Architectural Protocol
442 // BDS should never return
451 Place holder function until all the Boot Services and Runtime Services are
454 @return EFI_NOT_AVAILABLE_YET
459 CoreEfiNotAvailableYetArg0 (
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
477 @param Arg1 Undefined
479 @return EFI_NOT_AVAILABLE_YET
484 CoreEfiNotAvailableYetArg1 (
489 // This function should never be executed. If it does, then the architectural protocols
490 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
491 // DXE Core and all the Architectural Protocols are complete.
494 return EFI_NOT_AVAILABLE_YET
;
499 Place holder function until all the Boot Services and Runtime Services are available.
501 @param Arg1 Undefined
502 @param Arg2 Undefined
504 @return EFI_NOT_AVAILABLE_YET
509 CoreEfiNotAvailableYetArg2 (
515 // This function should never be executed. If it does, then the architectural protocols
516 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
517 // DXE Core and all the Architectural Protocols are complete.
520 return EFI_NOT_AVAILABLE_YET
;
525 Place holder function until all the Boot Services and Runtime Services are available.
527 @param Arg1 Undefined
528 @param Arg2 Undefined
529 @param Arg3 Undefined
531 @return EFI_NOT_AVAILABLE_YET
536 CoreEfiNotAvailableYetArg3 (
543 // This function should never be executed. If it does, then the architectural protocols
544 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
545 // DXE Core and all the Architectural Protocols are complete.
548 return EFI_NOT_AVAILABLE_YET
;
553 Place holder function until all the Boot Services and Runtime Services are available.
555 @param Arg1 Undefined
556 @param Arg2 Undefined
557 @param Arg3 Undefined
558 @param Arg4 Undefined
560 @return EFI_NOT_AVAILABLE_YET
565 CoreEfiNotAvailableYetArg4 (
573 // This function should never be executed. If it does, then the architectural protocols
574 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
575 // DXE Core and all the Architectural Protocols are complete.
578 return EFI_NOT_AVAILABLE_YET
;
583 Place holder function until all the Boot Services and Runtime Services are available.
585 @param Arg1 Undefined
586 @param Arg2 Undefined
587 @param Arg3 Undefined
588 @param Arg4 Undefined
589 @param Arg5 Undefined
591 @return EFI_NOT_AVAILABLE_YET
596 CoreEfiNotAvailableYetArg5 (
605 // This function should never be executed. If it does, then the architectural protocols
606 // have not been designed correctly. The CpuBreakpoint () is commented out for now until the
607 // DXE Core and all the Architectural Protocols are complete.
610 return EFI_NOT_AVAILABLE_YET
;
615 Calcualte the 32-bit CRC in a EFI table using the service provided by the
618 @param Hdr Pointer to an EFI standard header
623 IN OUT EFI_TABLE_HEADER
*Hdr
631 // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
632 // Crc will come back as zero if we set it to zero here
635 gBS
->CalculateCrc32 ((UINT8
*)Hdr
, Hdr
->HeaderSize
, &Crc
);
641 Terminates all boot services.
643 @param ImageHandle Handle that identifies the exiting image.
644 @param MapKey Key to the latest memory map.
646 @retval EFI_SUCCESS Boot Services terminated
647 @retval EFI_INVALID_PARAMETER MapKey is incorrect.
652 CoreExitBootServices (
653 IN EFI_HANDLE ImageHandle
,
660 // Terminate memory services if the MapKey matches
662 Status
= CoreTerminateMemoryMap (MapKey
);
663 if (EFI_ERROR (Status
)) {
670 gTimer
->SetTimerPeriod (gTimer
, 0);
673 // Notify other drivers that we are exiting boot services.
675 CoreNotifySignalList (&gEfiEventExitBootServicesGuid
);
678 // Disable CPU Interrupts
680 gCpu
->DisableInterrupt (gCpu
);
683 // Report that ExitBootServices() has been called
687 (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)
691 // Clear the non-runtime values of the EFI System Table
693 gDxeCoreST
->BootServices
= NULL
;
694 gDxeCoreST
->ConIn
= NULL
;
695 gDxeCoreST
->ConsoleInHandle
= NULL
;
696 gDxeCoreST
->ConOut
= NULL
;
697 gDxeCoreST
->ConsoleOutHandle
= NULL
;
698 gDxeCoreST
->StdErr
= NULL
;
699 gDxeCoreST
->StandardErrorHandle
= NULL
;
702 // Recompute the 32-bit CRC of the EFI System Table
704 CalculateEfiHdrCrc (&gDxeCoreST
->Hdr
);
707 // Zero out the Boot Service Table
709 ZeroMem (gBS
, sizeof (EFI_BOOT_SERVICES
));
713 // Update the AtRuntime field in Runtiem AP.
715 gRuntime
->AtRuntime
= TRUE
;
722 Given a compressed source buffer, this function retrieves the size of the
723 uncompressed buffer and the size of the scratch buffer required to decompress
724 the compressed source buffer.
726 The GetInfo() function retrieves the size of the uncompressed buffer and the
727 temporary scratch buffer required to decompress the buffer specified by Source
728 and SourceSize. If the size of the uncompressed buffer or the size of the
729 scratch buffer cannot be determined from the compressed data specified by
730 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the
731 size of the uncompressed buffer is returned in DestinationSize, the size of
732 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.
733 The GetInfo() function does not have scratch buffer available to perform a
734 thorough checking of the validity of the source data. It just retrieves the
735 "Original Size" field from the beginning bytes of the source data and output
736 it as DestinationSize. And ScratchSize is specific to the decompression
739 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
740 @param Source The source buffer containing the compressed data.
741 @param SourceSize The size, in bytes, of the source buffer.
742 @param DestinationSize A pointer to the size, in bytes, of the
743 uncompressed buffer that will be generated when the
744 compressed buffer specified by Source and
745 SourceSize is decompressed.
746 @param ScratchSize A pointer to the size, in bytes, of the scratch
747 buffer that is required to decompress the
748 compressed buffer specified by Source and
751 @retval EFI_SUCCESS The size of the uncompressed data was returned in
752 DestinationSize and the size of the scratch buffer
753 was returned in ScratchSize.
754 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of
755 the scratch buffer cannot be determined from the
756 compressed data specified by Source and
762 DxeMainUefiDecompressGetInfo (
763 IN EFI_DECOMPRESS_PROTOCOL
*This
,
765 IN UINT32 SourceSize
,
766 OUT UINT32
*DestinationSize
,
767 OUT UINT32
*ScratchSize
770 if (Source
== NULL
|| DestinationSize
== NULL
|| ScratchSize
== NULL
) {
771 return EFI_INVALID_PARAMETER
;
773 return UefiDecompressGetInfo (Source
, SourceSize
, DestinationSize
, ScratchSize
);
778 Decompresses a compressed source buffer.
780 The Decompress() function extracts decompressed data to its original form.
781 This protocol is designed so that the decompression algorithm can be
782 implemented without using any memory services. As a result, the Decompress()
783 Function is not allowed to call AllocatePool() or AllocatePages() in its
784 implementation. It is the caller's responsibility to allocate and free the
785 Destination and Scratch buffers.
786 If the compressed source data specified by Source and SourceSize is
787 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If
788 the compressed source data specified by Source and SourceSize is not in a
789 valid compressed data format, then EFI_INVALID_PARAMETER is returned.
791 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.
792 @param Source The source buffer containing the compressed data.
793 @param SourceSize SourceSizeThe size of source data.
794 @param Destination On output, the destination buffer that contains
795 the uncompressed data.
796 @param DestinationSize The size of the destination buffer. The size of
797 the destination buffer needed is obtained from
798 EFI_DECOMPRESS_PROTOCOL.GetInfo().
799 @param Scratch A temporary scratch buffer that is used to perform
801 @param ScratchSize The size of scratch buffer. The size of the
802 scratch buffer needed is obtained from GetInfo().
804 @retval EFI_SUCCESS Decompression completed successfully, and the
805 uncompressed buffer is returned in Destination.
806 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and
807 SourceSize is corrupted (not in a valid
813 DxeMainUefiDecompress (
814 IN EFI_DECOMPRESS_PROTOCOL
*This
,
816 IN UINT32 SourceSize
,
817 IN OUT VOID
*Destination
,
818 IN UINT32 DestinationSize
,
819 IN OUT VOID
*Scratch
,
820 IN UINT32 ScratchSize
824 UINT32 TestDestinationSize
;
825 UINT32 TestScratchSize
;
827 if (Source
== NULL
|| Destination
== NULL
|| Scratch
== NULL
) {
828 return EFI_INVALID_PARAMETER
;
831 Status
= UefiDecompressGetInfo (Source
, SourceSize
, &TestDestinationSize
, &TestScratchSize
);
832 if (EFI_ERROR (Status
)) {
836 if (ScratchSize
< TestScratchSize
|| DestinationSize
< TestDestinationSize
) {
837 return RETURN_INVALID_PARAMETER
;
840 return UefiDecompress (Source
, Destination
, Scratch
);