From e20ee534ac22960fef84e868cb45eb54b813a290 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Sun, 14 May 2006 09:14:46 +0000 Subject: git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@150 6f19259b-4bc3-4df7-8a09-765794883524 --- EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c | 9 - EdkModulePkg/Core/Dxe/DxeMain.mbd | 84 +- EdkModulePkg/Core/Dxe/DxeMain.msa | 331 +-- EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c | 2166 ++++++++-------- EdkModulePkg/Core/Dxe/Event/event.c | 1724 ++++++------- EdkModulePkg/Core/DxeIplPeim/DxeIpl.mbd | 126 +- EdkModulePkg/Core/DxeIplPeim/DxeIplX64.mbd | 98 +- EdkModulePkg/Core/DxeIplPeim/DxeIplX64.msa | 207 +- EdkModulePkg/Core/DxeIplPeim/DxeLoadX64.c | 2006 +++++++-------- EdkModulePkg/Core/DxeIplPeim/build.xml | 119 +- EdkModulePkg/Core/DxeIplPeim/x64/LongMode.asm | 2707 ++++++++++---------- EdkModulePkg/Core/Pei/Image/Image.c | 480 ++-- EdkModulePkg/Core/Pei/PeiMain.mbd | 106 +- EdkModulePkg/Core/Pei/PeiMain/PeiMain.c | 485 ++-- EdkModulePkg/EdkModulePkg.spd | 1332 +++++----- .../Universal/StatusCode/RuntimeDxe/StatusCode.mbd | 110 +- EdkModulePkg/Universal/Variable/Pei/Variable.mbd | 86 +- 17 files changed, 6105 insertions(+), 6071 deletions(-) (limited to 'EdkModulePkg') diff --git a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c index 2b8f52a..4cf882e 100644 --- a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c +++ b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.c @@ -503,15 +503,6 @@ IDEBusDriverBindingStart ( IdeBlkIoDevicePtr->IoPort->BusMasterBaseAddr = IdeRegsBaseAddr[IdeChannel].BusMasterBaseAddr; // - // Report Status code: is about to detect IDE drive - // - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_PROGRESS_CODE, - (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_PRESENCE_DETECT), - IdeBlkIoDevicePtr->DevicePath - ); - - // // Discover device, now! // PERF_START (0, "DiscoverIdeDevice", "IDE", 0); diff --git a/EdkModulePkg/Core/Dxe/DxeMain.mbd b/EdkModulePkg/Core/Dxe/DxeMain.mbd index ec084b5..55967ca 100644 --- a/EdkModulePkg/Core/Dxe/DxeMain.mbd +++ b/EdkModulePkg/Core/Dxe/DxeMain.mbd @@ -1,42 +1,42 @@ - - - - - DxeMain - D6A2CB7F-6A18-4e2f-B43B-9920A733700A - 0 - FIX ME! - Copyright (c) 2004-2006, Intel Corporation - All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - 2006-03-12 17:09 - 2006-03-19 15:18 - - - BaseLib - BaseCacheMaintenanceLib - DxeReportStatusCodeLib - BaseDebugLibReportStatusCode - DxeCoreUefiDecompressLibFromHob - DxeCoreTianoDecompressLibFromHob - DxeCoreCustomDecompressLibFromHob - EdkDxePeCoffLoaderFromHobLib - DxeCoreHobLib - DxeCoreEntryPoint - BaseMemoryLib - UefiLib - BasePerformanceLibNull - - - _ModuleEntryPoint - - - + + + + + DxeMain + D6A2CB7F-6A18-4e2f-B43B-9920A733700A + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + 2006-03-12 17:09 + 2006-03-19 15:18 + + + BaseLib + BaseCacheMaintenanceLib + DxeReportStatusCodeLib + BaseDebugLibReportStatusCode + DxeCoreUefiDecompressLibFromHob + DxeCoreTianoDecompressLibFromHob + DxeCoreCustomDecompressLibFromHob + EdkDxePeCoffLoaderFromHobLib + DxeCoreHobLib + DxeCoreEntryPoint + BaseMemoryLib + UefiLib + BasePerformanceLibNull + + + _ModuleEntryPoint + + + diff --git a/EdkModulePkg/Core/Dxe/DxeMain.msa b/EdkModulePkg/Core/Dxe/DxeMain.msa index 9f9de4a..991e945 100644 --- a/EdkModulePkg/Core/Dxe/DxeMain.msa +++ b/EdkModulePkg/Core/Dxe/DxeMain.msa @@ -1,164 +1,167 @@ - - - - - DxeMain - DXE_CORE - BS_DRIVER - D6A2CB7F-6A18-4e2f-B43B-9920A733700A - 0 - Component description file for DxeMain. - FIX ME! - Copyright (c) 2004-2006, Intel Corporation - All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - 0 - 2006-03-12 17:09 - 2006-03-19 15:18 - - - DxeCoreEntryPoint - DebugLib - UefiLib - BaseLib - HobLib - PerformanceLib - UefiDecompressLib - TianoDecompressLib - CustomDecompressLib - EdkPeCoffLoaderLib - CacheMaintenanceLib - BaseMemoryLib - - - DxeMain/DxeMain.c - DxeMain/DxeProtocolNotify.c - Dispatcher/Dispatcher.c - Dispatcher/Dependency.c - Event/ExecData.c - Event/Event.c - Event/Timer.c - Event/Tpl.c - FwVol/FwVol.c - FwVol/Ffs.c - FwVol/FwVolAttrib.c - FwVol/FwVolRead.c - FwVol/FwVolWrite.c - FwVolBlock/FwVolBlock.c - Mem/MemData.c - Mem/Page.c - Mem/Pool.c - Gcd/Gcd.c - Hand/Handle.c - Hand/Locate.c - Hand/Notify.c - Hand/DriverSupport.c - Library/Library.c - Misc/InstallConfigurationTable.c - Misc/SetWatchdogTimer.c - Misc/Stall.c - Misc/DebugImageInfo.c - Image/Image.c - Image/ImageFile.c - SectionExtraction/CoreSectionExtraction.c - DebugImageInfo.h - DebugMask.h - DxeMain.h - Exec.h - FwVolBlock.h - FwVolDriver.h - Gcd.h - Hand.h - Image.h - Imem.h - Library.h - - - MdePkg - EdkModulePkg - - - Ebc - LoadedImage - DevicePath - Cpu - FirmwareVolume - FirmwareVolumeDispatch - FirmwareVolumeBlock - SectionExtraction - DriverBinding - PlatformDriverOverride - BusSpecificDriverOverride - Timer - Metronome - MonotonicCounter - VariableWrite - Bds - Variable - Security - WatchdogTimer - Runtime - RealTimeClock - Reset - LoadFile - SimpleFileSystem - LoadPeImage - - - - MemoryTypeInformation - - - DxeServicesTable - - - HobList - - - DebugImageInfoTable - - - Apriori - - - FirmwareFileSystem - - - FileInfo - - - HobMemoryAllocModule - - - PeiPeCoffLoader - - - LoadPeImage - - - EventExitBootServices - - - EventVirtualAddressChange - - - EventMemoryMapChange - - - - - DxeMain - - - - - - + + + + + DxeMain + DXE_CORE + BS_DRIVER + D6A2CB7F-6A18-4e2f-B43B-9920A733700A + 0 + Component description file for DxeMain. + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + 0 + 2006-03-12 17:09 + 2006-03-19 15:18 + + + DxeCoreEntryPoint + DebugLib + UefiLib + BaseLib + HobLib + PerformanceLib + UefiDecompressLib + TianoDecompressLib + CustomDecompressLib + EdkPeCoffLoaderLib + CacheMaintenanceLib + BaseMemoryLib + + + DxeMain/DxeMain.c + DxeMain/DxeProtocolNotify.c + Dispatcher/Dispatcher.c + Dispatcher/Dependency.c + Event/ExecData.c + Event/Event.c + Event/Timer.c + Event/Tpl.c + FwVol/FwVol.c + FwVol/Ffs.c + FwVol/FwVolAttrib.c + FwVol/FwVolRead.c + FwVol/FwVolWrite.c + FwVolBlock/FwVolBlock.c + Mem/MemData.c + Mem/Page.c + Mem/Pool.c + Gcd/Gcd.c + Hand/Handle.c + Hand/Locate.c + Hand/Notify.c + Hand/DriverSupport.c + Library/Library.c + Misc/InstallConfigurationTable.c + Misc/SetWatchdogTimer.c + Misc/Stall.c + Misc/DebugImageInfo.c + Image/Image.c + Image/ImageFile.c + SectionExtraction/CoreSectionExtraction.c + DebugImageInfo.h + DebugMask.h + DxeMain.h + Exec.h + FwVolBlock.h + FwVolDriver.h + Gcd.h + Hand.h + Image.h + Imem.h + Library.h + + + MdePkg + EdkModulePkg + + + Ebc + LoadedImage + DevicePath + Cpu + FirmwareVolume + FirmwareVolumeDispatch + FirmwareVolumeBlock + SectionExtraction + DriverBinding + PlatformDriverOverride + BusSpecificDriverOverride + Timer + Metronome + MonotonicCounter + VariableWrite + Bds + Variable + Security + WatchdogTimer + Runtime + RealTimeClock + Reset + LoadFile + SimpleFileSystem + LoadPeImage + Decompress + CustomizedDecompress + TianoDecompress + + + + MemoryTypeInformation + + + DxeServicesTable + + + HobList + + + DebugImageInfoTable + + + Apriori + + + FirmwareFileSystem + + + FileInfo + + + HobMemoryAllocModule + + + PeiPeCoffLoader + + + LoadPeImage + + + EventExitBootServices + + + EventVirtualAddressChange + + + EventMemoryMapChange + + + + + DxeMain + + + + + + diff --git a/EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c b/EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c index f98f054..67a26fe 100644 --- a/EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -1,1083 +1,1083 @@ -/*++ - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - DxeMain.c - -Abstract: - - DXE Core Main Entry Point - ---*/ - -#include - -VOID -EFIAPI -DxeMain ( - IN VOID *HobStart - ); - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg0 ( - VOID - ); - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg1 ( - UINTN Arg1 - ); - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg2 ( - UINTN Arg1, - UINTN Arg2 - ); - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg3 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3 - ); - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg4 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3, - UINTN Arg4 - ); - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg5 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3, - UINTN Arg4, - UINTN Arg5 - ); - -EFI_STATUS -CoreGetPeiProtocol ( - IN EFI_GUID *ProtocolGuid, - IN VOID **Interface - ); - -EFI_STATUS -DxeMainUefiDecompressGetInfo ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize - ); - -EFI_STATUS -EFIAPI -DxeMainUefiDecompress ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - IN OUT VOID *Destination, - IN UINT32 DestinationSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ); - -EFI_STATUS -DxeMainTianoDecompressGetInfo ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize - ); - -EFI_STATUS -EFIAPI -DxeMainTianoDecompress ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - IN OUT VOID *Destination, - IN UINT32 DestinationSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ); - -EFI_STATUS -DxeMainCustomDecompressGetInfo ( - IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize - ); - -EFI_STATUS -EFIAPI -DxeMainCustomDecompress ( - IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - IN OUT VOID *Destination, - IN UINT32 DestinationSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ); - -// -// DXE Core Global Variables for Protocols from PEI -// -EFI_HANDLE mDecompressHandle = NULL; -EFI_PEI_PE_COFF_LOADER_PROTOCOL *gEfiPeiPeCoffLoader = NULL; - -// -// DXE Core globals for Architecture Protocols -// -EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL; -EFI_CPU_ARCH_PROTOCOL *gCpu = NULL; -EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL; -EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL; -EFI_BDS_ARCH_PROTOCOL *gBds = NULL; -EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL; -EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = NULL; - -// -// BugBug: I'n not runtime, but is the PPI? -// -EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance = { - NULL -}; - -EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance; - - -// -// DXE Core Global used to update core loaded image protocol handle -// -EFI_GUID *gDxeCoreFileName; -EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; - - - -// -// DXE Core Module Variables -// - -EFI_BOOT_SERVICES mBootServices = { - { - EFI_BOOT_SERVICES_SIGNATURE, // Signature - EFI_BOOT_SERVICES_REVISION, // Revision - sizeof (EFI_BOOT_SERVICES), // HeaderSize - 0, // CRC32 - 0 // Reserved - }, - (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL - (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL - (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages - (EFI_FREE_PAGES) CoreFreePages, // FreePages - (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap - (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool - (EFI_FREE_POOL) CoreFreePool, // FreePool - (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent - (EFI_SET_TIMER) CoreSetTimer, // SetTimer - (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent - (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent - (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent - (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent - (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface - (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface - (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface - (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol - (VOID *) NULL, // Reserved - (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify - (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle - (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath - (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable - (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage - (EFI_IMAGE_START) CoreStartImage, // StartImage - (EFI_EXIT) CoreExit, // Exit - (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage - (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices - (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount - (EFI_STALL) CoreStall, // Stall - (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer - (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController - (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController - (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol - (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol - (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation - (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle - (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer - (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol - (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces - (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces - (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32 - (EFI_COPY_MEM) CopyMem, // CopyMem - (EFI_SET_MEM) SetMem // SetMem -#if (EFI_SPECIFICATION_VERSION >= 0x00020000) - , - (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx -#endif -}; - -EFI_DXE_SERVICES mDxeServices = { - { - EFI_DXE_SERVICES_SIGNATURE, // Signature - EFI_DXE_SERVICES_REVISION, // Revision - sizeof (EFI_DXE_SERVICES), // HeaderSize - 0, // CRC32 - 0 // Reserved - }, - (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace - (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace - (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace - (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace - (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor - (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes - (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap - (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace - (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace - (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace - (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace - (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor - (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap - (EFI_DISPATCH) CoreDispatcher, // Dispatch - (EFI_SCHEDULE) CoreSchedule, // Schedule - (EFI_TRUST) CoreTrust, // Trust - (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume -}; - -EFI_SYSTEM_TABLE mEfiSystemTableTemplate = { - { - EFI_SYSTEM_TABLE_SIGNATURE, // Signature - EFI_SYSTEM_TABLE_REVISION, // Revision - sizeof (EFI_SYSTEM_TABLE), // HeaderSize - 0, // CRC32 - 0 // Reserved - }, - NULL, // FirmwareVendor - 0, // FirmwareRevision - NULL, // ConsoleInHandle - NULL, // ConIn - NULL, // ConsoleOutHandle - NULL, // ConOut - NULL, // StandardErrorHandle - NULL, // StdErr - NULL, // RuntimeServices - &mBootServices, // BootServices - 0, // NumberOfConfigurationTableEntries - NULL // ConfigurationTable -}; - -EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = { - { - EFI_RUNTIME_SERVICES_SIGNATURE, // Signature - EFI_RUNTIME_SERVICES_REVISION, // Revision - sizeof (EFI_RUNTIME_SERVICES), // HeaderSize - 0, // CRC32 - 0 // Reserved - }, - (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime - (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime - (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime - (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime - (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap - (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer - (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable - (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName - (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable - (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount - (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4 // ResetSystem -#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) - , - (TIANO_REPORT_STATUS_CODE) CoreEfiNotAvailableYetArg5 // ReportStatusCode -#elif (EFI_SPECIFICATION_VERSION >= 0x00020000) - , - (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule - (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities - (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo -#endif -}; - -// -// DXE Core Global Variables for the EFI System Table, Boot Services Table, -// DXE Services Table, and Runtime Services Table -// -EFI_BOOT_SERVICES *gBS = &mBootServices; -EFI_DXE_SERVICES *gDS = &mDxeServices; -EFI_SYSTEM_TABLE *gST = NULL; - -// -// For debug initialize gRT to template. gRT must be allocated from RT memory -// but gRT is used for ASSERT () and DEBUG () type macros so lets give it -// a value that will not cause debug infrastructure to crash early on. -// -EFI_RUNTIME_SERVICES *gRT = &mEfiRuntimeServicesTableTemplate; -EFI_HANDLE gDxeCoreImageHandle = NULL; - -VOID *mHobStart; - -// -// EFI Decompress Protocol -// -EFI_DECOMPRESS_PROTOCOL gEfiDecompress = { - DxeMainUefiDecompressGetInfo, - DxeMainUefiDecompress -}; - -// -// Tiano Decompress Protocol -// -EFI_TIANO_DECOMPRESS_PROTOCOL gEfiTianoDecompress = { - DxeMainTianoDecompressGetInfo, - DxeMainTianoDecompress -}; - -// -// Customized Decompress Protocol -// -EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL gEfiCustomizedDecompress = { - DxeMainCustomDecompressGetInfo, - DxeMainCustomDecompress -}; - -// -// Main entry point to the DXE Core -// -VOID -EFIAPI -DxeMain ( - IN VOID *HobStart - ) -/*++ - -Routine Description: - - Main entry point to DXE Core. - -Arguments: - - HobStart - Pointer to the beginning of the HOB List from PEI - -Returns: - - This function should never return - ---*/ -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS MemoryBaseAddress; - UINT64 MemoryLength; - -#ifdef EFI_DXE_PERFORMANCE - UINT64 Tick; - - GetTimerValue (&Tick); -#endif - - mHobStart = HobStart; - - // - // Initialize Memory Services - // - CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength); - - // - // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData - // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table - // - gST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate); - ASSERT (gST != NULL); - - gRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate); - ASSERT (gRT != NULL); - - gST->RuntimeServices = gRT; - - // - // Start the Image Services. - // - Status = CoreInitializeImageServices (HobStart); - ASSERT_EFI_ERROR (Status); - - // - // Call constructor for all libraries - // - ProcessLibraryConstructorList (gDxeCoreImageHandle, gST); - - // - // Initialize the Global Coherency Domain Services - // - Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength); - ASSERT_EFI_ERROR (Status); - - // - // Install the DXE Services Table into the EFI System Tables's Configuration Table - // - Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS); - ASSERT_EFI_ERROR (Status); - - // - // Install the HOB List into the EFI System Tables's Configuration Table - // - Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart); - ASSERT_EFI_ERROR (Status); - - // - // Install Memory Type Information Table into the EFI System Tables's Configuration Table - // - Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation); - ASSERT_EFI_ERROR (Status); - - // - // Initialize the ReportStatusCode with PEI version, if availible - // - CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode); -#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) - gRT->ReportStatusCode = gStatusCode->ReportStatusCode; -#endif - - // - // Report Status Code here for DXE_ENTRY_POINT once it is available - // - CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT)); - - // - // Create the aligned system table pointer structure that is used by external - // debuggers to locate the system table... Also, install debug image info - // configuration table. - // - CoreInitializeDebugImageInfoTable (); - CoreNewDebugImageInfoEntry ( - EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, - gDxeCoreLoadedImage, - gDxeCoreImageHandle - ); - - DEBUG ((EFI_D_INFO | EFI_D_LOAD, "HOBLIST address in DXE = 0x%08x\n", HobStart)); - - // - // Initialize the Event Services - // - Status = CoreInitializeEventServices (); - ASSERT_EFI_ERROR (Status); - - - // - // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs - // - // These Protocols are not architectural. This implementation is sharing code between - // PEI and DXE in order to save FLASH space. These Protocols could also be implemented - // as part of the DXE Core. However, that would also require the DXE Core to be ported - // each time a different CPU is used, a different Decompression algorithm is used, or a - // different Image type is used. By placing these Protocols in PEI, the DXE Core remains - // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform, - // and from CPU to CPU. - // - - // - // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components - // - Status = CoreInstallMultipleProtocolInterfaces ( - &mDecompressHandle, - &gEfiDecompressProtocolGuid, &gEfiDecompress, - &gEfiTianoDecompressProtocolGuid, &gEfiTianoDecompress, - &gEfiCustomizedDecompressProtocolGuid, &gEfiCustomizedDecompress, - NULL - ); - ASSERT_EFI_ERROR (Status); - - gEfiPeiPeCoffLoader = GetPeCoffLoaderProtocol (); - ASSERT (gEfiPeiPeCoffLoader != NULL); - - // - // Register for the GUIDs of the Architectural Protocols, so the rest of the - // EFI Boot Services and EFI Runtime Services tables can be filled in. - // - CoreNotifyOnArchProtocolInstallation (); - - // - // Produce Firmware Volume Protocols, one for each FV in the HOB list. - // - Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gST); - ASSERT_EFI_ERROR (Status); - - Status = FwVolDriverInit (gDxeCoreImageHandle, gST); - ASSERT_EFI_ERROR (Status); - - // - // Produce the Section Extraction Protocol - // - Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST); - ASSERT_EFI_ERROR (Status); - - // - // Initialize the DXE Dispatcher - // - PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ; - CoreInitializeDispatcher (); - PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ; - - // - // Invoke the DXE Dispatcher - // - PERF_START (0, "CoreDispatcher", "DxeMain", 0); - CoreDispatcher (); - PERF_END (0, "CoreDispatcher", "DxeMain", 0); - - // - // Display Architectural protocols that were not loaded if this is DEBUG build - // - DEBUG_CODE ( - CoreDisplayMissingArchProtocols (); - ); - - // - // Assert if the Architectural Protocols are not present. - // - ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ()); - - // - // Report Status code before transfer control to BDS - // - CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)); - // - // Display any drivers that were not dispatched because dependency expression - // evaluated to false if this is a debug build - // - DEBUG_CODE ( - CoreDisplayDiscoveredNotDispatched (); - ); - - // - // Transfer control to the BDS Architectural Protocol - // - gBds->Entry (gBds); - - // - // BDS should never return - // - ASSERT (FALSE); - CpuDeadLoop (); -} - - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg0 ( - VOID - ) -/*++ - -Routine Description: - - Place holder function until all the Boot Services and Runtime Services are available - -Arguments: - - None - -Returns: - - EFI_NOT_AVAILABLE_YET - ---*/ -{ - // - // This function should never be executed. If it does, then the architectural protocols - // have not been designed correctly. The CpuBreakpoint () is commented out for now until the - // DXE Core and all the Architectural Protocols are complete. - // - - return EFI_NOT_AVAILABLE_YET; -} - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg1 ( - UINTN Arg1 - ) -/*++ - -Routine Description: - - Place holder function until all the Boot Services and Runtime Services are available - -Arguments: - - Arg1 - Undefined - -Returns: - - EFI_NOT_AVAILABLE_YET - ---*/ -{ - // - // This function should never be executed. If it does, then the architectural protocols - // have not been designed correctly. The CpuBreakpoint () is commented out for now until the - // DXE Core and all the Architectural Protocols are complete. - // - - return EFI_NOT_AVAILABLE_YET; -} - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg2 ( - UINTN Arg1, - UINTN Arg2 - ) -/*++ - -Routine Description: - - Place holder function until all the Boot Services and Runtime Services are available - -Arguments: - - Arg1 - Undefined - - Arg2 - Undefined - -Returns: - - EFI_NOT_AVAILABLE_YET - ---*/ -{ - // - // This function should never be executed. If it does, then the architectural protocols - // have not been designed correctly. The CpuBreakpoint () is commented out for now until the - // DXE Core and all the Architectural Protocols are complete. - // - - return EFI_NOT_AVAILABLE_YET; -} - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg3 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3 - ) -/*++ - -Routine Description: - - Place holder function until all the Boot Services and Runtime Services are available - -Arguments: - - Arg1 - Undefined - - Arg2 - Undefined - - Arg3 - Undefined - -Returns: - - EFI_NOT_AVAILABLE_YET - ---*/ -{ - // - // This function should never be executed. If it does, then the architectural protocols - // have not been designed correctly. The CpuBreakpoint () is commented out for now until the - // DXE Core and all the Architectural Protocols are complete. - // - - return EFI_NOT_AVAILABLE_YET; -} - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg4 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3, - UINTN Arg4 - ) -/*++ - -Routine Description: - - Place holder function until all the Boot Services and Runtime Services are available - -Arguments: - - Arg1 - Undefined - - Arg2 - Undefined - - Arg3 - Undefined - - Arg4 - Undefined - -Returns: - - EFI_NOT_AVAILABLE_YET - ---*/ -{ - // - // This function should never be executed. If it does, then the architectural protocols - // have not been designed correctly. The CpuBreakpoint () is commented out for now until the - // DXE Core and all the Architectural Protocols are complete. - // - - return EFI_NOT_AVAILABLE_YET; -} - -EFI_STATUS -EFIAPI -CoreEfiNotAvailableYetArg5 ( - UINTN Arg1, - UINTN Arg2, - UINTN Arg3, - UINTN Arg4, - UINTN Arg5 - ) -/*++ - -Routine Description: - - Place holder function until all the Boot Services and Runtime Services are available - -Arguments: - - Arg1 - Undefined - - Arg2 - Undefined - - Arg3 - Undefined - - Arg4 - Undefined - - Arg5 - Undefined - -Returns: - - EFI_NOT_AVAILABLE_YET - ---*/ -{ - // - // This function should never be executed. If it does, then the architectural protocols - // have not been designed correctly. The CpuBreakpoint () is commented out for now until the - // DXE Core and all the Architectural Protocols are complete. - // - - return EFI_NOT_AVAILABLE_YET; -} - - -EFI_STATUS -CoreGetPeiProtocol ( - IN EFI_GUID *ProtocolGuid, - IN VOID **Interface - ) -/*++ - -Routine Description: - - Searches for a Protocol Interface passed from PEI through a HOB - -Arguments: - - ProtocolGuid - The Protocol GUID to search for in the HOB List - - Interface - A pointer to the interface for the Protocol GUID - -Returns: - - EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface - - EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List - ---*/ -{ - EFI_HOB_GUID_TYPE *GuidHob; - VOID *Buffer; - - GuidHob = GetNextGuidHob (ProtocolGuid, mHobStart); - if (GuidHob == NULL) { - return EFI_NOT_FOUND; - } - - Buffer = GET_GUID_HOB_DATA (GuidHob); - ASSERT (Buffer != NULL); - - *Interface = (VOID *)(*(UINTN *)(Buffer)); - - return EFI_SUCCESS; -} - - -VOID -CalculateEfiHdrCrc ( - IN OUT EFI_TABLE_HEADER *Hdr - ) -/*++ - -Routine Description: - - Calcualte the 32-bit CRC in a EFI table using the service provided by the - gRuntime service. - -Arguments: - - Hdr - Pointer to an EFI standard header - -Returns: - - None - ---*/ -{ - UINT32 Crc; - - Hdr->CRC32 = 0; - - // - // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then - // Crc will come back as zero if we set it to zero here - // - Crc = 0; - gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc); - Hdr->CRC32 = Crc; -} - - - -EFI_STATUS -EFIAPI -CoreExitBootServices ( - IN EFI_HANDLE ImageHandle, - IN UINTN MapKey - ) -/*++ - -Routine Description: - - EFI 1.0 API to terminate Boot Services - -Arguments: - - ImageHandle - Handle that represents the identity of the calling image - - MapKey -Key to the latest memory map. - -Returns: - - EFI_SUCCESS - Boot Services terminated - EFI_INVALID_PARAMETER - MapKey is incorrect. - ---*/ -{ - EFI_STATUS Status; - - // - // Terminate memory services if the MapKey matches - // - Status = CoreTerminateMemoryMap (MapKey); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Notify other drivers that we are exiting boot services. - // - CoreNotifySignalList (&gEfiEventExitBootServicesGuid); - - // - // Disable Timer - // - gTimer->SetTimerPeriod (gTimer, 0); - - // - // Disable CPU Interrupts - // - gCpu->DisableInterrupt (gCpu); - - // - // Register Runtime events with the Runtime Architectural Protocol - // - CoreShutdownEventServices (); - - // - // Register Runtime images with the Runtime Architectural Protocol - // - CoreShutdownImageServices (); - - // - // Report that ExitBootServices() has been called - // - // We are using gEfiDxeServicesTableGuid as the caller ID for Dxe Core - // - CoreReportProgressCode ((EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)); - - // - // Clear the non-runtime values of the EFI System Table - // - gST->BootServices = NULL; - gST->ConIn = NULL; - gST->ConsoleInHandle = NULL; - gST->ConOut = NULL; - gST->ConsoleOutHandle = NULL; - gST->StdErr = NULL; - gST->StandardErrorHandle = NULL; - - // - // Recompute the 32-bit CRC of the EFI System Table - // - CalculateEfiHdrCrc (&gST->Hdr); - - // - // Zero out the Boot Service Table - // - SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0); - gBS = NULL; - - return Status; -} - -EFI_STATUS -DxeMainUefiDecompressGetInfo ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize - ) -{ - return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); -} - -EFI_STATUS -EFIAPI -DxeMainUefiDecompress ( - IN EFI_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - IN OUT VOID *Destination, - IN UINT32 DestinationSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ) -{ - EFI_STATUS Status; - UINT32 TestDestinationSize; - UINT32 TestScratchSize; - - Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); - if (EFI_ERROR (Status)) { - return Status; - } - - if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { - return RETURN_INVALID_PARAMETER; - } - - return UefiDecompress (Source, Destination, Scratch); -} - -EFI_STATUS -DxeMainTianoDecompressGetInfo ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize - ) -{ - return TianoDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); -} - -EFI_STATUS -EFIAPI -DxeMainTianoDecompress ( - IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - IN OUT VOID *Destination, - IN UINT32 DestinationSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ) -{ - EFI_STATUS Status; - UINT32 TestDestinationSize; - UINT32 TestScratchSize; - - Status = TianoDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); - if (EFI_ERROR (Status)) { - return Status; - } - - if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { - return RETURN_INVALID_PARAMETER; - } - - return TianoDecompress (Source, Destination, Scratch); -} - -EFI_STATUS -DxeMainCustomDecompressGetInfo ( - IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - OUT UINT32 *DestinationSize, - OUT UINT32 *ScratchSize - ) -{ - return CustomDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); -} - -EFI_STATUS -EFIAPI -DxeMainCustomDecompress ( - IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, - IN VOID *Source, - IN UINT32 SourceSize, - IN OUT VOID *Destination, - IN UINT32 DestinationSize, - IN OUT VOID *Scratch, - IN UINT32 ScratchSize - ) -{ - EFI_STATUS Status; - UINT32 TestDestinationSize; - UINT32 TestScratchSize; - - Status = CustomDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); - if (EFI_ERROR (Status)) { - return Status; - } - - if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { - return RETURN_INVALID_PARAMETER; - } - - return CustomDecompress (Source, Destination, Scratch); -} - +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeMain.c + +Abstract: + + DXE Core Main Entry Point + +--*/ + +#include + +VOID +EFIAPI +DxeMain ( + IN VOID *HobStart + ); + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg0 ( + VOID + ); + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg1 ( + UINTN Arg1 + ); + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg2 ( + UINTN Arg1, + UINTN Arg2 + ); + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg3 ( + UINTN Arg1, + UINTN Arg2, + UINTN Arg3 + ); + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg4 ( + UINTN Arg1, + UINTN Arg2, + UINTN Arg3, + UINTN Arg4 + ); + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg5 ( + UINTN Arg1, + UINTN Arg2, + UINTN Arg3, + UINTN Arg4, + UINTN Arg5 + ); + +EFI_STATUS +CoreGetPeiProtocol ( + IN EFI_GUID *ProtocolGuid, + IN VOID **Interface + ); + +EFI_STATUS +DxeMainUefiDecompressGetInfo ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); + +EFI_STATUS +EFIAPI +DxeMainUefiDecompress ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +EFI_STATUS +DxeMainTianoDecompressGetInfo ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); + +EFI_STATUS +EFIAPI +DxeMainTianoDecompress ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +EFI_STATUS +DxeMainCustomDecompressGetInfo ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ); + +EFI_STATUS +EFIAPI +DxeMainCustomDecompress ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ); + +// +// DXE Core Global Variables for Protocols from PEI +// +EFI_HANDLE mDecompressHandle = NULL; +EFI_PEI_PE_COFF_LOADER_PROTOCOL *gEfiPeiPeCoffLoader = NULL; + +// +// DXE Core globals for Architecture Protocols +// +EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL; +EFI_CPU_ARCH_PROTOCOL *gCpu = NULL; +EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL; +EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL; +EFI_BDS_ARCH_PROTOCOL *gBds = NULL; +EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL; +EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = NULL; + +// +// BugBug: I'n not runtime, but is the PPI? +// +EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance = { + NULL +}; + +EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance; + + +// +// DXE Core Global used to update core loaded image protocol handle +// +EFI_GUID *gDxeCoreFileName; +EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; + + + +// +// DXE Core Module Variables +// + +EFI_BOOT_SERVICES mBootServices = { + { + EFI_BOOT_SERVICES_SIGNATURE, // Signature + EFI_BOOT_SERVICES_REVISION, // Revision + sizeof (EFI_BOOT_SERVICES), // HeaderSize + 0, // CRC32 + 0 // Reserved + }, + (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL + (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL + (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages + (EFI_FREE_PAGES) CoreFreePages, // FreePages + (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap + (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool + (EFI_FREE_POOL) CoreFreePool, // FreePool + (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent + (EFI_SET_TIMER) CoreSetTimer, // SetTimer + (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent + (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent + (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent + (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent + (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface + (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface + (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface + (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol + (VOID *) NULL, // Reserved + (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify + (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle + (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath + (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable + (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage + (EFI_IMAGE_START) CoreStartImage, // StartImage + (EFI_EXIT) CoreExit, // Exit + (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage + (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices + (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount + (EFI_STALL) CoreStall, // Stall + (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer + (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController + (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController + (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol + (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol + (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation + (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle + (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer + (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol + (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces + (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces + (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32 + (EFI_COPY_MEM) CopyMem, // CopyMem + (EFI_SET_MEM) SetMem // SetMem +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) + , + (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx +#endif +}; + +EFI_DXE_SERVICES mDxeServices = { + { + EFI_DXE_SERVICES_SIGNATURE, // Signature + EFI_DXE_SERVICES_REVISION, // Revision + sizeof (EFI_DXE_SERVICES), // HeaderSize + 0, // CRC32 + 0 // Reserved + }, + (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace + (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace + (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace + (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace + (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor + (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes + (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap + (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace + (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace + (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace + (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace + (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor + (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap + (EFI_DISPATCH) CoreDispatcher, // Dispatch + (EFI_SCHEDULE) CoreSchedule, // Schedule + (EFI_TRUST) CoreTrust, // Trust + (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume +}; + +EFI_SYSTEM_TABLE mEfiSystemTableTemplate = { + { + EFI_SYSTEM_TABLE_SIGNATURE, // Signature + EFI_SYSTEM_TABLE_REVISION, // Revision + sizeof (EFI_SYSTEM_TABLE), // HeaderSize + 0, // CRC32 + 0 // Reserved + }, + NULL, // FirmwareVendor + 0, // FirmwareRevision + NULL, // ConsoleInHandle + NULL, // ConIn + NULL, // ConsoleOutHandle + NULL, // ConOut + NULL, // StandardErrorHandle + NULL, // StdErr + NULL, // RuntimeServices + &mBootServices, // BootServices + 0, // NumberOfConfigurationTableEntries + NULL // ConfigurationTable +}; + +EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = { + { + EFI_RUNTIME_SERVICES_SIGNATURE, // Signature + EFI_RUNTIME_SERVICES_REVISION, // Revision + sizeof (EFI_RUNTIME_SERVICES), // HeaderSize + 0, // CRC32 + 0 // Reserved + }, + (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime + (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime + (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime + (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime + (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap + (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer + (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable + (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName + (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable + (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount + (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4 // ResetSystem +#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) + , + (TIANO_REPORT_STATUS_CODE) CoreEfiNotAvailableYetArg5 // ReportStatusCode +#elif (EFI_SPECIFICATION_VERSION >= 0x00020000) + , + (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule + (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities + (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo +#endif +}; + +// +// DXE Core Global Variables for the EFI System Table, Boot Services Table, +// DXE Services Table, and Runtime Services Table +// +EFI_BOOT_SERVICES *gBS = &mBootServices; +EFI_DXE_SERVICES *gDS = &mDxeServices; +EFI_SYSTEM_TABLE *gST = NULL; + +// +// For debug initialize gRT to template. gRT must be allocated from RT memory +// but gRT is used for ASSERT () and DEBUG () type macros so lets give it +// a value that will not cause debug infrastructure to crash early on. +// +EFI_RUNTIME_SERVICES *gRT = &mEfiRuntimeServicesTableTemplate; +EFI_HANDLE gDxeCoreImageHandle = NULL; + +VOID *mHobStart; + +// +// EFI Decompress Protocol +// +EFI_DECOMPRESS_PROTOCOL gEfiDecompress = { + DxeMainUefiDecompressGetInfo, + DxeMainUefiDecompress +}; + +// +// Tiano Decompress Protocol +// +EFI_TIANO_DECOMPRESS_PROTOCOL gEfiTianoDecompress = { + DxeMainTianoDecompressGetInfo, + DxeMainTianoDecompress +}; + +// +// Customized Decompress Protocol +// +EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL gEfiCustomizedDecompress = { + DxeMainCustomDecompressGetInfo, + DxeMainCustomDecompress +}; + +// +// Main entry point to the DXE Core +// +VOID +EFIAPI +DxeMain ( + IN VOID *HobStart + ) +/*++ + +Routine Description: + + Main entry point to DXE Core. + +Arguments: + + HobStart - Pointer to the beginning of the HOB List from PEI + +Returns: + + This function should never return + +--*/ +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS MemoryBaseAddress; + UINT64 MemoryLength; + +#ifdef EFI_DXE_PERFORMANCE + UINT64 Tick; + + GetTimerValue (&Tick); +#endif + + mHobStart = HobStart; + + // + // Initialize Memory Services + // + CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength); + + // + // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData + // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table + // + gST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate); + ASSERT (gST != NULL); + + gRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate); + ASSERT (gRT != NULL); + + gST->RuntimeServices = gRT; + + // + // Start the Image Services. + // + Status = CoreInitializeImageServices (HobStart); + ASSERT_EFI_ERROR (Status); + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (gDxeCoreImageHandle, gST); + + // + // Initialize the Global Coherency Domain Services + // + Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength); + ASSERT_EFI_ERROR (Status); + + // + // Install the DXE Services Table into the EFI System Tables's Configuration Table + // + Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS); + ASSERT_EFI_ERROR (Status); + + // + // Install the HOB List into the EFI System Tables's Configuration Table + // + Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart); + ASSERT_EFI_ERROR (Status); + + // + // Install Memory Type Information Table into the EFI System Tables's Configuration Table + // + Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation); + ASSERT_EFI_ERROR (Status); + + // + // Initialize the ReportStatusCode with PEI version, if availible + // + CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode); +#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000)) + gRT->ReportStatusCode = gStatusCode->ReportStatusCode; +#endif + + // + // Report Status Code here for DXE_ENTRY_POINT once it is available + // + CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT)); + + // + // Create the aligned system table pointer structure that is used by external + // debuggers to locate the system table... Also, install debug image info + // configuration table. + // + CoreInitializeDebugImageInfoTable (); + CoreNewDebugImageInfoEntry ( + EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, + gDxeCoreLoadedImage, + gDxeCoreImageHandle + ); + + DEBUG ((EFI_D_INFO | EFI_D_LOAD, "HOBLIST address in DXE = 0x%08x\n", HobStart)); + + // + // Initialize the Event Services + // + Status = CoreInitializeEventServices (); + ASSERT_EFI_ERROR (Status); + + + // + // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs + // + // These Protocols are not architectural. This implementation is sharing code between + // PEI and DXE in order to save FLASH space. These Protocols could also be implemented + // as part of the DXE Core. However, that would also require the DXE Core to be ported + // each time a different CPU is used, a different Decompression algorithm is used, or a + // different Image type is used. By placing these Protocols in PEI, the DXE Core remains + // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform, + // and from CPU to CPU. + // + + // + // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components + // + Status = CoreInstallMultipleProtocolInterfaces ( + &mDecompressHandle, + &gEfiDecompressProtocolGuid, &gEfiDecompress, + &gEfiTianoDecompressProtocolGuid, &gEfiTianoDecompress, + &gEfiCustomizedDecompressProtocolGuid, &gEfiCustomizedDecompress, + NULL + ); + ASSERT_EFI_ERROR (Status); + + gEfiPeiPeCoffLoader = GetPeCoffLoaderProtocol (); + ASSERT (gEfiPeiPeCoffLoader != NULL); + + // + // Register for the GUIDs of the Architectural Protocols, so the rest of the + // EFI Boot Services and EFI Runtime Services tables can be filled in. + // + CoreNotifyOnArchProtocolInstallation (); + + // + // Produce Firmware Volume Protocols, one for each FV in the HOB list. + // + Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gST); + ASSERT_EFI_ERROR (Status); + + Status = FwVolDriverInit (gDxeCoreImageHandle, gST); + ASSERT_EFI_ERROR (Status); + + // + // Produce the Section Extraction Protocol + // + Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST); + ASSERT_EFI_ERROR (Status); + + // + // Initialize the DXE Dispatcher + // + PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ; + CoreInitializeDispatcher (); + PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ; + + // + // Invoke the DXE Dispatcher + // + PERF_START (0, "CoreDispatcher", "DxeMain", 0); + CoreDispatcher (); + PERF_END (0, "CoreDispatcher", "DxeMain", 0); + + // + // Display Architectural protocols that were not loaded if this is DEBUG build + // + DEBUG_CODE ( + CoreDisplayMissingArchProtocols (); + ); + + // + // Assert if the Architectural Protocols are not present. + // + ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ()); + + // + // Report Status code before transfer control to BDS + // + CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)); + // + // Display any drivers that were not dispatched because dependency expression + // evaluated to false if this is a debug build + // + DEBUG_CODE ( + CoreDisplayDiscoveredNotDispatched (); + ); + + // + // Transfer control to the BDS Architectural Protocol + // + gBds->Entry (gBds); + + // + // BDS should never return + // + ASSERT (FALSE); + CpuDeadLoop (); +} + + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg0 ( + VOID + ) +/*++ + +Routine Description: + + Place holder function until all the Boot Services and Runtime Services are available + +Arguments: + + None + +Returns: + + EFI_NOT_AVAILABLE_YET + +--*/ +{ + // + // This function should never be executed. If it does, then the architectural protocols + // have not been designed correctly. The CpuBreakpoint () is commented out for now until the + // DXE Core and all the Architectural Protocols are complete. + // + + return EFI_NOT_AVAILABLE_YET; +} + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg1 ( + UINTN Arg1 + ) +/*++ + +Routine Description: + + Place holder function until all the Boot Services and Runtime Services are available + +Arguments: + + Arg1 - Undefined + +Returns: + + EFI_NOT_AVAILABLE_YET + +--*/ +{ + // + // This function should never be executed. If it does, then the architectural protocols + // have not been designed correctly. The CpuBreakpoint () is commented out for now until the + // DXE Core and all the Architectural Protocols are complete. + // + + return EFI_NOT_AVAILABLE_YET; +} + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg2 ( + UINTN Arg1, + UINTN Arg2 + ) +/*++ + +Routine Description: + + Place holder function until all the Boot Services and Runtime Services are available + +Arguments: + + Arg1 - Undefined + + Arg2 - Undefined + +Returns: + + EFI_NOT_AVAILABLE_YET + +--*/ +{ + // + // This function should never be executed. If it does, then the architectural protocols + // have not been designed correctly. The CpuBreakpoint () is commented out for now until the + // DXE Core and all the Architectural Protocols are complete. + // + + return EFI_NOT_AVAILABLE_YET; +} + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg3 ( + UINTN Arg1, + UINTN Arg2, + UINTN Arg3 + ) +/*++ + +Routine Description: + + Place holder function until all the Boot Services and Runtime Services are available + +Arguments: + + Arg1 - Undefined + + Arg2 - Undefined + + Arg3 - Undefined + +Returns: + + EFI_NOT_AVAILABLE_YET + +--*/ +{ + // + // This function should never be executed. If it does, then the architectural protocols + // have not been designed correctly. The CpuBreakpoint () is commented out for now until the + // DXE Core and all the Architectural Protocols are complete. + // + + return EFI_NOT_AVAILABLE_YET; +} + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg4 ( + UINTN Arg1, + UINTN Arg2, + UINTN Arg3, + UINTN Arg4 + ) +/*++ + +Routine Description: + + Place holder function until all the Boot Services and Runtime Services are available + +Arguments: + + Arg1 - Undefined + + Arg2 - Undefined + + Arg3 - Undefined + + Arg4 - Undefined + +Returns: + + EFI_NOT_AVAILABLE_YET + +--*/ +{ + // + // This function should never be executed. If it does, then the architectural protocols + // have not been designed correctly. The CpuBreakpoint () is commented out for now until the + // DXE Core and all the Architectural Protocols are complete. + // + + return EFI_NOT_AVAILABLE_YET; +} + +EFI_STATUS +EFIAPI +CoreEfiNotAvailableYetArg5 ( + UINTN Arg1, + UINTN Arg2, + UINTN Arg3, + UINTN Arg4, + UINTN Arg5 + ) +/*++ + +Routine Description: + + Place holder function until all the Boot Services and Runtime Services are available + +Arguments: + + Arg1 - Undefined + + Arg2 - Undefined + + Arg3 - Undefined + + Arg4 - Undefined + + Arg5 - Undefined + +Returns: + + EFI_NOT_AVAILABLE_YET + +--*/ +{ + // + // This function should never be executed. If it does, then the architectural protocols + // have not been designed correctly. The CpuBreakpoint () is commented out for now until the + // DXE Core and all the Architectural Protocols are complete. + // + + return EFI_NOT_AVAILABLE_YET; +} + + +EFI_STATUS +CoreGetPeiProtocol ( + IN EFI_GUID *ProtocolGuid, + IN VOID **Interface + ) +/*++ + +Routine Description: + + Searches for a Protocol Interface passed from PEI through a HOB + +Arguments: + + ProtocolGuid - The Protocol GUID to search for in the HOB List + + Interface - A pointer to the interface for the Protocol GUID + +Returns: + + EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface + + EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List + +--*/ +{ + EFI_HOB_GUID_TYPE *GuidHob; + VOID *Buffer; + + GuidHob = GetNextGuidHob (ProtocolGuid, mHobStart); + if (GuidHob == NULL) { + return EFI_NOT_FOUND; + } + + Buffer = GET_GUID_HOB_DATA (GuidHob); + ASSERT (Buffer != NULL); + + *Interface = (VOID *)(*(UINTN *)(Buffer)); + + return EFI_SUCCESS; +} + + +VOID +CalculateEfiHdrCrc ( + IN OUT EFI_TABLE_HEADER *Hdr + ) +/*++ + +Routine Description: + + Calcualte the 32-bit CRC in a EFI table using the service provided by the + gRuntime service. + +Arguments: + + Hdr - Pointer to an EFI standard header + +Returns: + + None + +--*/ +{ + UINT32 Crc; + + Hdr->CRC32 = 0; + + // + // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then + // Crc will come back as zero if we set it to zero here + // + Crc = 0; + gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc); + Hdr->CRC32 = Crc; +} + + + +EFI_STATUS +EFIAPI +CoreExitBootServices ( + IN EFI_HANDLE ImageHandle, + IN UINTN MapKey + ) +/*++ + +Routine Description: + + EFI 1.0 API to terminate Boot Services + +Arguments: + + ImageHandle - Handle that represents the identity of the calling image + + MapKey -Key to the latest memory map. + +Returns: + + EFI_SUCCESS - Boot Services terminated + EFI_INVALID_PARAMETER - MapKey is incorrect. + +--*/ +{ + EFI_STATUS Status; + + // + // Terminate memory services if the MapKey matches + // + Status = CoreTerminateMemoryMap (MapKey); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Notify other drivers that we are exiting boot services. + // + CoreNotifySignalList (&gEfiEventExitBootServicesGuid); + + // + // Disable Timer + // + gTimer->SetTimerPeriod (gTimer, 0); + + // + // Disable CPU Interrupts + // + gCpu->DisableInterrupt (gCpu); + + // + // Register Runtime events with the Runtime Architectural Protocol + // + CoreShutdownEventServices (); + + // + // Register Runtime images with the Runtime Architectural Protocol + // + CoreShutdownImageServices (); + + // + // Report that ExitBootServices() has been called + // + // We are using gEfiDxeServicesTableGuid as the caller ID for Dxe Core + // + CoreReportProgressCode ((EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)); + + // + // Clear the non-runtime values of the EFI System Table + // + gST->BootServices = NULL; + gST->ConIn = NULL; + gST->ConsoleInHandle = NULL; + gST->ConOut = NULL; + gST->ConsoleOutHandle = NULL; + gST->StdErr = NULL; + gST->StandardErrorHandle = NULL; + + // + // Recompute the 32-bit CRC of the EFI System Table + // + CalculateEfiHdrCrc (&gST->Hdr); + + // + // Zero out the Boot Service Table + // + SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0); + gBS = NULL; + + return Status; +} + +EFI_STATUS +DxeMainUefiDecompressGetInfo ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ) +{ + return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); +} + +EFI_STATUS +EFIAPI +DxeMainUefiDecompress ( + IN EFI_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +{ + EFI_STATUS Status; + UINT32 TestDestinationSize; + UINT32 TestScratchSize; + + Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); + if (EFI_ERROR (Status)) { + return Status; + } + + if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { + return RETURN_INVALID_PARAMETER; + } + + return UefiDecompress (Source, Destination, Scratch); +} + +EFI_STATUS +DxeMainTianoDecompressGetInfo ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ) +{ + return TianoDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); +} + +EFI_STATUS +EFIAPI +DxeMainTianoDecompress ( + IN EFI_TIANO_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +{ + EFI_STATUS Status; + UINT32 TestDestinationSize; + UINT32 TestScratchSize; + + Status = TianoDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); + if (EFI_ERROR (Status)) { + return Status; + } + + if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { + return RETURN_INVALID_PARAMETER; + } + + return TianoDecompress (Source, Destination, Scratch); +} + +EFI_STATUS +DxeMainCustomDecompressGetInfo ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + OUT UINT32 *DestinationSize, + OUT UINT32 *ScratchSize + ) +{ + return CustomDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize); +} + +EFI_STATUS +EFIAPI +DxeMainCustomDecompress ( + IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This, + IN VOID *Source, + IN UINT32 SourceSize, + IN OUT VOID *Destination, + IN UINT32 DestinationSize, + IN OUT VOID *Scratch, + IN UINT32 ScratchSize + ) +{ + EFI_STATUS Status; + UINT32 TestDestinationSize; + UINT32 TestScratchSize; + + Status = CustomDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize); + if (EFI_ERROR (Status)) { + return Status; + } + + if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) { + return RETURN_INVALID_PARAMETER; + } + + return CustomDecompress (Source, Destination, Scratch); +} + diff --git a/EdkModulePkg/Core/Dxe/Event/event.c b/EdkModulePkg/Core/Dxe/Event/event.c index e839141..6751b18 100644 --- a/EdkModulePkg/Core/Dxe/Event/event.c +++ b/EdkModulePkg/Core/Dxe/Event/event.c @@ -1,862 +1,862 @@ -/*++ - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - event.c - -Abstract: - - EFI Event support - ---*/ - - -#include - -// -// Enumerate the valid types -// -UINT32 mEventTable[] = { - // - // 0x80000200 Timer event with a notification function that is - // queue when the event is signaled with SignalEvent() - // - EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL, - // - // 0x80000000 Timer event without a notification function. It can be - // signaled with SignalEvent() and checked with CheckEvent() or WaitForEvent(). - // - EFI_EVENT_TIMER, - // - // 0x00000100 Generic event with a notification function that - // can be waited on with CheckEvent() or WaitForEvent() - // - EFI_EVENT_NOTIFY_WAIT, - // - // 0x00000200 Generic event with a notification function that - // is queue when the event is signaled with SignalEvent() - // - EFI_EVENT_NOTIFY_SIGNAL, - // - // 0x00000201 ExitBootServicesEvent. - // - EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, - // - // 0x60000202 SetVirtualAddressMapEvent. - // - EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, - -#if (EFI_SPECIFICATION_VERSION < 0x00020000) - // - // 0x00000203 ReadyToBootEvent. - // - EFI_EVENT_SIGNAL_READY_TO_BOOT, - // - // 0x00000204 LegacyBootEvent. - // - EFI_EVENT_SIGNAL_LEGACY_BOOT, - // - // 0x00000603 Signal all ReadyToBootEvents. - // - EFI_EVENT_NOTIFY_SIGNAL_ALL | EFI_EVENT_SIGNAL_READY_TO_BOOT, - // - // 0x00000604 Signal all LegacyBootEvents. - // - EFI_EVENT_NOTIFY_SIGNAL_ALL | EFI_EVENT_SIGNAL_LEGACY_BOOT, -#endif - - // - // 0x00000000 Generic event without a notification function. - // It can be signaled with SignalEvent() and checked with CheckEvent() - // or WaitForEvent(). - // - 0x00000000, - // - // 0x80000100 Timer event with a notification function that can be - // waited on with CheckEvent() or WaitForEvent() - // - EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_WAIT, -}; - - -VOID -CoreAcquireEventLock ( - VOID - ) -/*++ - -Routine Description: - - Enter critical section by acquiring the lock on gEventQueueLock. - -Arguments: - - None - -Returns: - - None - ---*/ -{ - CoreAcquireLock (&gEventQueueLock); -} - - -VOID -CoreReleaseEventLock ( - VOID - ) -/*++ - -Routine Description: - - Exit critical section by releasing the lock on gEventQueueLock. - -Arguments: - - None - -Returns: - - None - ---*/ -{ - CoreReleaseLock (&gEventQueueLock); -} - - -EFI_STATUS -CoreInitializeEventServices ( - VOID - ) -/*++ - -Routine Description: - - Initializes "event" support and populates parts of the System and Runtime Table. - -Arguments: - - None - -Returns: - - EFI_SUCCESS - Always return success - ---*/ -{ - UINTN Index; - - for (Index=0; Index <= EFI_TPL_HIGH_LEVEL; Index++) { - InitializeListHead (&gEventQueue[Index]); - } - - CoreInitializeTimer (); - - return EFI_SUCCESS; -} - - -EFI_STATUS -CoreShutdownEventServices ( - VOID - ) -/*++ - -Routine Description: - - Register all runtime events to make sure they are still available after ExitBootService. - -Arguments: - - None - -Returns: - - EFI_SUCCESS - Always return success. - ---*/ -{ - LIST_ENTRY *Link; - IEVENT *Event; - - // - // The Runtime AP is required for the core to function! - // - ASSERT (gRuntime != NULL); - - for (Link = mRuntimeEventList.ForwardLink; Link != &mRuntimeEventList; Link = Link->ForwardLink) { - Event = CR (Link, IEVENT, RuntimeLink, EVENT_SIGNATURE); - gRuntime->RegisterEvent ( - gRuntime, - Event->Type, - Event->NotifyTpl, - Event->NotifyFunction, - Event->NotifyContext, - (VOID **)Event - ); - } - - return EFI_SUCCESS; -} - - -VOID -CoreDispatchEventNotifies ( - IN EFI_TPL Priority - ) -/*++ - -Routine Description: - - Dispatches all pending events. - -Arguments: - - Priority - The task priority level of event notifications to dispatch - -Returns: - - None - ---*/ -{ - IEVENT *Event; - LIST_ENTRY *Head; - - CoreAcquireEventLock (); - ASSERT (gEventQueueLock.OwnerTpl == Priority); - Head = &gEventQueue[Priority]; - - // - // Dispatch all the pending notifications - // - while (!IsListEmpty (Head)) { - - Event = CR (Head->ForwardLink, IEVENT, NotifyLink, EVENT_SIGNATURE); - RemoveEntryList (&Event->NotifyLink); - - Event->NotifyLink.ForwardLink = NULL; - - // - // Only clear the SIGNAL status if it is a SIGNAL type event. - // WAIT type events are only cleared in CheckEvent() - // - if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) { - Event->SignalCount = 0; - } - - CoreReleaseEventLock (); - - // - // Notify this event - // - ASSERT (Event->NotifyFunction != NULL); - Event->NotifyFunction (Event, Event->NotifyContext); - - // - // Check for next pending event - // - CoreAcquireEventLock (); - } - - gEventPending &= ~(1 << Priority); - CoreReleaseEventLock (); -} - - -VOID -STATIC -CoreNotifyEvent ( - IN IEVENT *Event - ) -/*++ - -Routine Description: - - Queues the event's notification function to fire - -Arguments: - - Event - The Event to notify - -Returns: - - None - ---*/ -{ - - // - // Event database must be locked - // - ASSERT_LOCKED (&gEventQueueLock); - - // - // If the event is queued somewhere, remove it - // - - if (Event->NotifyLink.ForwardLink != NULL) { - RemoveEntryList (&Event->NotifyLink); - Event->NotifyLink.ForwardLink = NULL; - } - - // - // Queue the event to the pending notification list - // - - InsertTailList (&gEventQueue[Event->NotifyTpl], &Event->NotifyLink); - gEventPending |= (UINTN)(1 << Event->NotifyTpl); -} - - - -VOID -CoreNotifySignalList ( - IN EFI_GUID *EventGroup - ) -/*++ - -Routine Description: - Signals all events in the EventGroup - -Arguments: - EventGroup - The list to signal - -Returns: - - None - ---*/ -{ - LIST_ENTRY *Link; - LIST_ENTRY *Head; - IEVENT *Event; - - CoreAcquireEventLock (); - - Head = &gEventSignalQueue; - for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) { - Event = CR (Link, IEVENT, SignalLink, EVENT_SIGNATURE); - if (CompareGuid (&Event->EventGroup, EventGroup)) { - CoreNotifyEvent (Event); - } - } - - CoreReleaseEventLock (); -} - - -#if (EFI_SPECIFICATION_VERSION < 0x00020000) - -static -VOID -EFIAPI -EventNofitySignalAllNullEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - // - // This null event is a size efficent way to enusre that - // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly. - // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into - // CreateEventEx() and this function is used to make the - // old error checking in CreateEvent() for Tiano extensions - // function. - // - return; -} - -#endif - - - - -EFI_STATUS -EFIAPI -CoreCreateEvent ( - IN UINT32 Type, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN VOID *NotifyContext, OPTIONAL - OUT EFI_EVENT *Event - ) -/*++ - -Routine Description: - Creates a general-purpose event structure - -Arguments: - Type - The type of event to create and its mode and attributes - NotifyTpl - The task priority level of event notifications - NotifyFunction - Pointer to the events notification function - NotifyContext - Pointer to the notification functions context; corresponds to - parameter "Context" in the notification function - Event - Pointer to the newly created event if the call succeeds; undefined otherwise - -Returns: - EFI_SUCCESS - The event structure was created - EFI_INVALID_PARAMETER - One of the parameters has an invalid value - EFI_OUT_OF_RESOURCES - The event could not be allocated - ---*/ -{ - EFI_GUID *GuidPtr; - EFI_EVENT_NOTIFY Function; - - GuidPtr = NULL; - Function = NotifyFunction; - -#if (EFI_SPECIFICATION_VERSION < 0x00020000) - // - // Clear EFI_EVENT_NOFITY_SIGNAL_ALL (Tiano extension) as all events in the - // EventGroup now have this property. So we need to filter it out. - // - if (Type & EFI_EVENT_NOTIFY_SIGNAL_ALL) { - Type &= ~EFI_EVENT_NOTIFY_SIGNAL_ALL; - Function = EventNofitySignalAllNullEvent; - } - - // - // Map the Tiano extensions Events to CreateEventEx form - // - if (Type == EFI_EVENT_SIGNAL_READY_TO_BOOT) { - GuidPtr = &gEfiEventReadToBootGuid; - } else if (Type == EFI_EVENT_SIGNAL_LEGACY_BOOT) { - GuidPtr = &gEfiEventLegacyBootGuid - } -#endif - - // - // Convert EFI 1.10 Events to thier UEFI 2.0 CreateEventEx mapping - // - if (Type == EVENT_SIGNAL_EXIT_BOOT_SERVICES) { - GuidPtr = &gEfiEventExitBootServicesGuid; - } else if (Type == EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) { - GuidPtr = &gEfiEventVirtualAddressChangeGuid; - } - - return CoreCreateEventEx (Type, NotifyTpl, Function, NotifyContext, GuidPtr, Event); -} - - -EFI_STATUS -EFIAPI -CoreCreateEventEx ( - IN UINT32 Type, - IN EFI_TPL NotifyTpl, - IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL - IN CONST VOID *NotifyContext, OPTIONAL - IN CONST EFI_GUID *EventGroup, OPTIONAL - OUT EFI_EVENT *Event - ) -/*++ - -Routine Description: - Creates a general-purpose event structure - -Arguments: - Type - The type of event to create and its mode and attributes - NotifyTpl - The task priority level of event notifications - NotifyFunction - Pointer to the events notification function - NotifyContext - Pointer to the notification functions context; corresponds to - parameter "Context" in the notification function - EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent(). - Event - Pointer to the newly created event if the call succeeds; undefined otherwise - -Returns: - EFI_SUCCESS - The event structure was created - EFI_INVALID_PARAMETER - One of the parameters has an invalid value - EFI_OUT_OF_RESOURCES - The event could not be allocated - ---*/ -{ - EFI_STATUS Status; - IEVENT *IEvent; - INTN Index; - - - if ((Event == NULL) || (NotifyTpl == EFI_TPL_APPLICATION)) { - return EFI_INVALID_PARAMETER; - } - - // - // Check to make sure no reserved flags are set - // - Status = EFI_INVALID_PARAMETER; - for (Index = 0; Index < (sizeof (mEventTable) / sizeof (UINT32)); Index++) { - if (Type == mEventTable[Index]) { - Status = EFI_SUCCESS; - break; - } - } - if(EFI_ERROR (Status)) { - return EFI_INVALID_PARAMETER; - } - - // - // If it's a notify type of event, check its parameters - // - if ((Type & (EFI_EVENT_NOTIFY_WAIT | EFI_EVENT_NOTIFY_SIGNAL))) { - // - // Check for an invalid NotifyFunction or NotifyTpl - // - if ((NotifyFunction == NULL) || - (NotifyTpl < EFI_TPL_APPLICATION) || - (NotifyTpl >= EFI_TPL_HIGH_LEVEL)) { - return EFI_INVALID_PARAMETER; - } - - } else { - // - // No notification needed, zero ignored values - // - NotifyTpl = 0; - NotifyFunction = NULL; - NotifyContext = NULL; - } - - // - // Allcoate and initialize a new event structure. - // - Status = CoreAllocatePool ( - (Type & EFI_EVENT_RUNTIME) ? EfiRuntimeServicesData: EfiBootServicesData, - sizeof (IEVENT), - (VOID **)&IEvent - ); - if (EFI_ERROR (Status)) { - return EFI_OUT_OF_RESOURCES; - } - - SetMem (IEvent, sizeof (IEVENT), 0); - - IEvent->Signature = EVENT_SIGNATURE; - IEvent->Type = Type; - - IEvent->NotifyTpl = NotifyTpl; - IEvent->NotifyFunction = NotifyFunction; - IEvent->NotifyContext = (VOID *)NotifyContext; - if (EventGroup != NULL) { - CopyGuid (&IEvent->EventGroup, EventGroup); - IEvent->ExFlag = TRUE; - } - - *Event = IEvent; - - if (Type & EFI_EVENT_RUNTIME) { - // - // Keep a list of all RT events so we can tell the RT AP. - // - InsertTailList (&mRuntimeEventList, &IEvent->RuntimeLink); - } - - CoreAcquireEventLock (); - - if ((Type & EFI_EVENT_NOTIFY_SIGNAL) != 0x00000000) { - // - // The Event's NotifyFunction must be queued whenever the event is signaled - // - InsertHeadList (&gEventSignalQueue, &IEvent->SignalLink); - } - - CoreReleaseEventLock (); - - // - // Done - // - return EFI_SUCCESS; -} - - - -EFI_STATUS -EFIAPI -CoreSignalEvent ( - IN EFI_EVENT UserEvent - ) -/*++ - -Routine Description: - - Signals the event. Queues the event to be notified if needed - -Arguments: - - UserEvent - The event to signal - -Returns: - - EFI_INVALID_PARAMETER - Parameters are not valid. - - EFI_SUCCESS - The event was signaled. - ---*/ -{ - IEVENT *Event; - - Event = UserEvent; - - if (Event == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (Event->Signature != EVENT_SIGNATURE) { - return EFI_INVALID_PARAMETER; - } - - CoreAcquireEventLock (); - - // - // If the event is not already signalled, do so - // - - if (Event->SignalCount == 0x00000000) { - Event->SignalCount++; - - // - // If signalling type is a notify function, queue it - // - if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) { - if (Event->ExFlag) { - // - // The CreateEventEx() style requires all members of the Event Group - // to be signaled. - // - CoreReleaseEventLock (); - CoreNotifySignalList (&Event->EventGroup); - CoreAcquireEventLock (); - } else { - CoreNotifyEvent (Event); - } - } - } - - CoreReleaseEventLock (); - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -CoreCheckEvent ( - IN EFI_EVENT UserEvent - ) -/*++ - -Routine Description: - - Check the status of an event - -Arguments: - - UserEvent - The event to check - -Returns: - - EFI_SUCCESS - The event is in the signaled state - EFI_NOT_READY - The event is not in the signaled state - EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL - ---*/ - -{ - IEVENT *Event; - EFI_STATUS Status; - - Event = UserEvent; - - if (Event == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (Event->Signature != EVENT_SIGNATURE) { - return EFI_INVALID_PARAMETER; - } - - if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) { - return EFI_INVALID_PARAMETER; - } - - Status = EFI_NOT_READY; - - if (!Event->SignalCount && (Event->Type & EFI_EVENT_NOTIFY_WAIT)) { - - // - // Queue the wait notify function - // - - CoreAcquireEventLock (); - if (!Event->SignalCount) { - CoreNotifyEvent (Event); - } - CoreReleaseEventLock (); - } - - // - // If the even looks signalled, get the lock and clear it - // - - if (Event->SignalCount) { - CoreAcquireEventLock (); - - if (Event->SignalCount) { - Event->SignalCount = 0; - Status = EFI_SUCCESS; - } - - CoreReleaseEventLock (); - } - - return Status; -} - - - -EFI_STATUS -EFIAPI -CoreWaitForEvent ( - IN UINTN NumberOfEvents, - IN EFI_EVENT *UserEvents, - OUT UINTN *UserIndex - ) -/*++ - -Routine Description: - - Stops execution until an event is signaled. - -Arguments: - - NumberOfEvents - The number of events in the UserEvents array - UserEvents - An array of EFI_EVENT - UserIndex - Pointer to the index of the event which satisfied the wait condition - -Returns: - - EFI_SUCCESS - The event indicated by Index was signaled. - EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or - Event was not a valid type - EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION - ---*/ - -{ - EFI_STATUS Status; - UINTN Index; - - // - // Can only WaitForEvent at TPL_APPLICATION - // - if (gEfiCurrentTpl != EFI_TPL_APPLICATION) { - return EFI_UNSUPPORTED; - } - - for(;;) { - - for(Index = 0; Index < NumberOfEvents; Index++) { - - Status = CoreCheckEvent (UserEvents[Index]); - - // - // provide index of event that caused problem - // - if (Status != EFI_NOT_READY) { - *UserIndex = Index; - return Status; - } - } - - // - // This was the location of the Idle loop callback in EFI 1.x reference - // code. We don't have that concept in this base at this point. - // - } -} - - -EFI_STATUS -EFIAPI -CoreCloseEvent ( - IN EFI_EVENT UserEvent - ) -/*++ - -Routine Description: - - Closes an event and frees the event structure. - -Arguments: - - UserEvent - Event to close - -Returns: - - EFI_INVALID_PARAMETER - Parameters are not valid. - - EFI_SUCCESS - The event has been closed - ---*/ - -{ - EFI_STATUS Status; - IEVENT *Event; - - Event = UserEvent; - - if (Event == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (Event->Signature != EVENT_SIGNATURE) { - return EFI_INVALID_PARAMETER; - } - - // - // If it's a timer event, make sure it's not pending - // - if (Event->Type & EFI_EVENT_TIMER) { - CoreSetTimer (Event, TimerCancel, 0); - } - - CoreAcquireEventLock (); - - // - // If the event is queued somewhere, remove it - // - - if (Event->RuntimeLink.ForwardLink != NULL) { - RemoveEntryList (&Event->RuntimeLink); - } - - if (Event->NotifyLink.ForwardLink != NULL) { - RemoveEntryList (&Event->NotifyLink); - } - - if (Event->SignalLink.ForwardLink != NULL) { - RemoveEntryList (&Event->SignalLink); - } - - CoreReleaseEventLock (); - - // - // If the event is registered on a protocol notify, then remove it from the protocol database - // - CoreUnregisterProtocolNotify (Event); - - Status = CoreFreePool (Event); - ASSERT_EFI_ERROR (Status); - - return Status; -} +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + event.c + +Abstract: + + EFI Event support + +--*/ + + +#include + +// +// Enumerate the valid types +// +UINT32 mEventTable[] = { + // + // 0x80000200 Timer event with a notification function that is + // queue when the event is signaled with SignalEvent() + // + EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL, + // + // 0x80000000 Timer event without a notification function. It can be + // signaled with SignalEvent() and checked with CheckEvent() or WaitForEvent(). + // + EFI_EVENT_TIMER, + // + // 0x00000100 Generic event with a notification function that + // can be waited on with CheckEvent() or WaitForEvent() + // + EFI_EVENT_NOTIFY_WAIT, + // + // 0x00000200 Generic event with a notification function that + // is queue when the event is signaled with SignalEvent() + // + EFI_EVENT_NOTIFY_SIGNAL, + // + // 0x00000201 ExitBootServicesEvent. + // + EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES, + // + // 0x60000202 SetVirtualAddressMapEvent. + // + EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + // + // 0x00000203 ReadyToBootEvent. + // + EFI_EVENT_SIGNAL_READY_TO_BOOT, + // + // 0x00000204 LegacyBootEvent. + // + EFI_EVENT_SIGNAL_LEGACY_BOOT, + // + // 0x00000603 Signal all ReadyToBootEvents. + // + EFI_EVENT_NOTIFY_SIGNAL_ALL | EFI_EVENT_SIGNAL_READY_TO_BOOT, + // + // 0x00000604 Signal all LegacyBootEvents. + // + EFI_EVENT_NOTIFY_SIGNAL_ALL | EFI_EVENT_SIGNAL_LEGACY_BOOT, +#endif + + // + // 0x00000000 Generic event without a notification function. + // It can be signaled with SignalEvent() and checked with CheckEvent() + // or WaitForEvent(). + // + 0x00000000, + // + // 0x80000100 Timer event with a notification function that can be + // waited on with CheckEvent() or WaitForEvent() + // + EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_WAIT, +}; + + +VOID +CoreAcquireEventLock ( + VOID + ) +/*++ + +Routine Description: + + Enter critical section by acquiring the lock on gEventQueueLock. + +Arguments: + + None + +Returns: + + None + +--*/ +{ + CoreAcquireLock (&gEventQueueLock); +} + + +VOID +CoreReleaseEventLock ( + VOID + ) +/*++ + +Routine Description: + + Exit critical section by releasing the lock on gEventQueueLock. + +Arguments: + + None + +Returns: + + None + +--*/ +{ + CoreReleaseLock (&gEventQueueLock); +} + + +EFI_STATUS +CoreInitializeEventServices ( + VOID + ) +/*++ + +Routine Description: + + Initializes "event" support and populates parts of the System and Runtime Table. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Always return success + +--*/ +{ + UINTN Index; + + for (Index=0; Index <= EFI_TPL_HIGH_LEVEL; Index++) { + InitializeListHead (&gEventQueue[Index]); + } + + CoreInitializeTimer (); + + return EFI_SUCCESS; +} + + +EFI_STATUS +CoreShutdownEventServices ( + VOID + ) +/*++ + +Routine Description: + + Register all runtime events to make sure they are still available after ExitBootService. + +Arguments: + + None + +Returns: + + EFI_SUCCESS - Always return success. + +--*/ +{ + LIST_ENTRY *Link; + IEVENT *Event; + + // + // The Runtime AP is required for the core to function! + // + ASSERT (gRuntime != NULL); + + for (Link = mRuntimeEventList.ForwardLink; Link != &mRuntimeEventList; Link = Link->ForwardLink) { + Event = CR (Link, IEVENT, RuntimeLink, EVENT_SIGNATURE); + gRuntime->RegisterEvent ( + gRuntime, + Event->Type, + Event->NotifyTpl, + Event->NotifyFunction, + Event->NotifyContext, + (VOID **)Event + ); + } + + return EFI_SUCCESS; +} + + +VOID +CoreDispatchEventNotifies ( + IN EFI_TPL Priority + ) +/*++ + +Routine Description: + + Dispatches all pending events. + +Arguments: + + Priority - The task priority level of event notifications to dispatch + +Returns: + + None + +--*/ +{ + IEVENT *Event; + LIST_ENTRY *Head; + + CoreAcquireEventLock (); + ASSERT (gEventQueueLock.OwnerTpl == Priority); + Head = &gEventQueue[Priority]; + + // + // Dispatch all the pending notifications + // + while (!IsListEmpty (Head)) { + + Event = CR (Head->ForwardLink, IEVENT, NotifyLink, EVENT_SIGNATURE); + RemoveEntryList (&Event->NotifyLink); + + Event->NotifyLink.ForwardLink = NULL; + + // + // Only clear the SIGNAL status if it is a SIGNAL type event. + // WAIT type events are only cleared in CheckEvent() + // + if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) { + Event->SignalCount = 0; + } + + CoreReleaseEventLock (); + + // + // Notify this event + // + ASSERT (Event->NotifyFunction != NULL); + Event->NotifyFunction (Event, Event->NotifyContext); + + // + // Check for next pending event + // + CoreAcquireEventLock (); + } + + gEventPending &= ~(1 << Priority); + CoreReleaseEventLock (); +} + + +VOID +STATIC +CoreNotifyEvent ( + IN IEVENT *Event + ) +/*++ + +Routine Description: + + Queues the event's notification function to fire + +Arguments: + + Event - The Event to notify + +Returns: + + None + +--*/ +{ + + // + // Event database must be locked + // + ASSERT_LOCKED (&gEventQueueLock); + + // + // If the event is queued somewhere, remove it + // + + if (Event->NotifyLink.ForwardLink != NULL) { + RemoveEntryList (&Event->NotifyLink); + Event->NotifyLink.ForwardLink = NULL; + } + + // + // Queue the event to the pending notification list + // + + InsertTailList (&gEventQueue[Event->NotifyTpl], &Event->NotifyLink); + gEventPending |= (UINTN)(1 << Event->NotifyTpl); +} + + + +VOID +CoreNotifySignalList ( + IN EFI_GUID *EventGroup + ) +/*++ + +Routine Description: + Signals all events in the EventGroup + +Arguments: + EventGroup - The list to signal + +Returns: + + None + +--*/ +{ + LIST_ENTRY *Link; + LIST_ENTRY *Head; + IEVENT *Event; + + CoreAcquireEventLock (); + + Head = &gEventSignalQueue; + for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) { + Event = CR (Link, IEVENT, SignalLink, EVENT_SIGNATURE); + if (CompareGuid (&Event->EventGroup, EventGroup)) { + CoreNotifyEvent (Event); + } + } + + CoreReleaseEventLock (); +} + + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + +static +VOID +EFIAPI +EventNofitySignalAllNullEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // This null event is a size efficent way to enusre that + // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly. + // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into + // CreateEventEx() and this function is used to make the + // old error checking in CreateEvent() for Tiano extensions + // function. + // + return; +} + +#endif + + + + +EFI_STATUS +EFIAPI +CoreCreateEvent ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *Event + ) +/*++ + +Routine Description: + Creates a general-purpose event structure + +Arguments: + Type - The type of event to create and its mode and attributes + NotifyTpl - The task priority level of event notifications + NotifyFunction - Pointer to the events notification function + NotifyContext - Pointer to the notification functions context; corresponds to + parameter "Context" in the notification function + Event - Pointer to the newly created event if the call succeeds; undefined otherwise + +Returns: + EFI_SUCCESS - The event structure was created + EFI_INVALID_PARAMETER - One of the parameters has an invalid value + EFI_OUT_OF_RESOURCES - The event could not be allocated + +--*/ +{ + EFI_GUID *GuidPtr; + EFI_EVENT_NOTIFY Function; + + GuidPtr = NULL; + Function = NotifyFunction; + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + // + // Clear EFI_EVENT_NOFITY_SIGNAL_ALL (Tiano extension) as all events in the + // EventGroup now have this property. So we need to filter it out. + // + if (Type & EFI_EVENT_NOTIFY_SIGNAL_ALL) { + Type &= ~EFI_EVENT_NOTIFY_SIGNAL_ALL; + Function = EventNofitySignalAllNullEvent; + } + + // + // Map the Tiano extensions Events to CreateEventEx form + // + if (Type == EFI_EVENT_SIGNAL_READY_TO_BOOT) { + GuidPtr = &gEfiEventReadyToBootGuid; + } else if (Type == EFI_EVENT_SIGNAL_LEGACY_BOOT) { + GuidPtr = &gEfiEventLegacyBootGuid + } +#endif + + // + // Convert EFI 1.10 Events to thier UEFI 2.0 CreateEventEx mapping + // + if (Type == EVENT_SIGNAL_EXIT_BOOT_SERVICES) { + GuidPtr = &gEfiEventExitBootServicesGuid; + } else if (Type == EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) { + GuidPtr = &gEfiEventVirtualAddressChangeGuid; + } + + return CoreCreateEventEx (Type, NotifyTpl, Function, NotifyContext, GuidPtr, Event); +} + + +EFI_STATUS +EFIAPI +CoreCreateEventEx ( + IN UINT32 Type, + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN CONST VOID *NotifyContext, OPTIONAL + IN CONST EFI_GUID *EventGroup, OPTIONAL + OUT EFI_EVENT *Event + ) +/*++ + +Routine Description: + Creates a general-purpose event structure + +Arguments: + Type - The type of event to create and its mode and attributes + NotifyTpl - The task priority level of event notifications + NotifyFunction - Pointer to the events notification function + NotifyContext - Pointer to the notification functions context; corresponds to + parameter "Context" in the notification function + EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent(). + Event - Pointer to the newly created event if the call succeeds; undefined otherwise + +Returns: + EFI_SUCCESS - The event structure was created + EFI_INVALID_PARAMETER - One of the parameters has an invalid value + EFI_OUT_OF_RESOURCES - The event could not be allocated + +--*/ +{ + EFI_STATUS Status; + IEVENT *IEvent; + INTN Index; + + + if ((Event == NULL) || (NotifyTpl == EFI_TPL_APPLICATION)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to make sure no reserved flags are set + // + Status = EFI_INVALID_PARAMETER; + for (Index = 0; Index < (sizeof (mEventTable) / sizeof (UINT32)); Index++) { + if (Type == mEventTable[Index]) { + Status = EFI_SUCCESS; + break; + } + } + if(EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + + // + // If it's a notify type of event, check its parameters + // + if ((Type & (EFI_EVENT_NOTIFY_WAIT | EFI_EVENT_NOTIFY_SIGNAL))) { + // + // Check for an invalid NotifyFunction or NotifyTpl + // + if ((NotifyFunction == NULL) || + (NotifyTpl < EFI_TPL_APPLICATION) || + (NotifyTpl >= EFI_TPL_HIGH_LEVEL)) { + return EFI_INVALID_PARAMETER; + } + + } else { + // + // No notification needed, zero ignored values + // + NotifyTpl = 0; + NotifyFunction = NULL; + NotifyContext = NULL; + } + + // + // Allcoate and initialize a new event structure. + // + Status = CoreAllocatePool ( + (Type & EFI_EVENT_RUNTIME) ? EfiRuntimeServicesData: EfiBootServicesData, + sizeof (IEVENT), + (VOID **)&IEvent + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + SetMem (IEvent, sizeof (IEVENT), 0); + + IEvent->Signature = EVENT_SIGNATURE; + IEvent->Type = Type; + + IEvent->NotifyTpl = NotifyTpl; + IEvent->NotifyFunction = NotifyFunction; + IEvent->NotifyContext = (VOID *)NotifyContext; + if (EventGroup != NULL) { + CopyGuid (&IEvent->EventGroup, EventGroup); + IEvent->ExFlag = TRUE; + } + + *Event = IEvent; + + if (Type & EFI_EVENT_RUNTIME) { + // + // Keep a list of all RT events so we can tell the RT AP. + // + InsertTailList (&mRuntimeEventList, &IEvent->RuntimeLink); + } + + CoreAcquireEventLock (); + + if ((Type & EFI_EVENT_NOTIFY_SIGNAL) != 0x00000000) { + // + // The Event's NotifyFunction must be queued whenever the event is signaled + // + InsertHeadList (&gEventSignalQueue, &IEvent->SignalLink); + } + + CoreReleaseEventLock (); + + // + // Done + // + return EFI_SUCCESS; +} + + + +EFI_STATUS +EFIAPI +CoreSignalEvent ( + IN EFI_EVENT UserEvent + ) +/*++ + +Routine Description: + + Signals the event. Queues the event to be notified if needed + +Arguments: + + UserEvent - The event to signal + +Returns: + + EFI_INVALID_PARAMETER - Parameters are not valid. + + EFI_SUCCESS - The event was signaled. + +--*/ +{ + IEVENT *Event; + + Event = UserEvent; + + if (Event == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Event->Signature != EVENT_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + + CoreAcquireEventLock (); + + // + // If the event is not already signalled, do so + // + + if (Event->SignalCount == 0x00000000) { + Event->SignalCount++; + + // + // If signalling type is a notify function, queue it + // + if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) { + if (Event->ExFlag) { + // + // The CreateEventEx() style requires all members of the Event Group + // to be signaled. + // + CoreReleaseEventLock (); + CoreNotifySignalList (&Event->EventGroup); + CoreAcquireEventLock (); + } else { + CoreNotifyEvent (Event); + } + } + } + + CoreReleaseEventLock (); + return EFI_SUCCESS; +} + + +EFI_STATUS +EFIAPI +CoreCheckEvent ( + IN EFI_EVENT UserEvent + ) +/*++ + +Routine Description: + + Check the status of an event + +Arguments: + + UserEvent - The event to check + +Returns: + + EFI_SUCCESS - The event is in the signaled state + EFI_NOT_READY - The event is not in the signaled state + EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL + +--*/ + +{ + IEVENT *Event; + EFI_STATUS Status; + + Event = UserEvent; + + if (Event == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Event->Signature != EVENT_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + + if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) { + return EFI_INVALID_PARAMETER; + } + + Status = EFI_NOT_READY; + + if (!Event->SignalCount && (Event->Type & EFI_EVENT_NOTIFY_WAIT)) { + + // + // Queue the wait notify function + // + + CoreAcquireEventLock (); + if (!Event->SignalCount) { + CoreNotifyEvent (Event); + } + CoreReleaseEventLock (); + } + + // + // If the even looks signalled, get the lock and clear it + // + + if (Event->SignalCount) { + CoreAcquireEventLock (); + + if (Event->SignalCount) { + Event->SignalCount = 0; + Status = EFI_SUCCESS; + } + + CoreReleaseEventLock (); + } + + return Status; +} + + + +EFI_STATUS +EFIAPI +CoreWaitForEvent ( + IN UINTN NumberOfEvents, + IN EFI_EVENT *UserEvents, + OUT UINTN *UserIndex + ) +/*++ + +Routine Description: + + Stops execution until an event is signaled. + +Arguments: + + NumberOfEvents - The number of events in the UserEvents array + UserEvents - An array of EFI_EVENT + UserIndex - Pointer to the index of the event which satisfied the wait condition + +Returns: + + EFI_SUCCESS - The event indicated by Index was signaled. + EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or + Event was not a valid type + EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION + +--*/ + +{ + EFI_STATUS Status; + UINTN Index; + + // + // Can only WaitForEvent at TPL_APPLICATION + // + if (gEfiCurrentTpl != EFI_TPL_APPLICATION) { + return EFI_UNSUPPORTED; + } + + for(;;) { + + for(Index = 0; Index < NumberOfEvents; Index++) { + + Status = CoreCheckEvent (UserEvents[Index]); + + // + // provide index of event that caused problem + // + if (Status != EFI_NOT_READY) { + *UserIndex = Index; + return Status; + } + } + + // + // This was the location of the Idle loop callback in EFI 1.x reference + // code. We don't have that concept in this base at this point. + // + } +} + + +EFI_STATUS +EFIAPI +CoreCloseEvent ( + IN EFI_EVENT UserEvent + ) +/*++ + +Routine Description: + + Closes an event and frees the event structure. + +Arguments: + + UserEvent - Event to close + +Returns: + + EFI_INVALID_PARAMETER - Parameters are not valid. + + EFI_SUCCESS - The event has been closed + +--*/ + +{ + EFI_STATUS Status; + IEVENT *Event; + + Event = UserEvent; + + if (Event == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Event->Signature != EVENT_SIGNATURE) { + return EFI_INVALID_PARAMETER; + } + + // + // If it's a timer event, make sure it's not pending + // + if (Event->Type & EFI_EVENT_TIMER) { + CoreSetTimer (Event, TimerCancel, 0); + } + + CoreAcquireEventLock (); + + // + // If the event is queued somewhere, remove it + // + + if (Event->RuntimeLink.ForwardLink != NULL) { + RemoveEntryList (&Event->RuntimeLink); + } + + if (Event->NotifyLink.ForwardLink != NULL) { + RemoveEntryList (&Event->NotifyLink); + } + + if (Event->SignalLink.ForwardLink != NULL) { + RemoveEntryList (&Event->SignalLink); + } + + CoreReleaseEventLock (); + + // + // If the event is registered on a protocol notify, then remove it from the protocol database + // + CoreUnregisterProtocolNotify (Event); + + Status = CoreFreePool (Event); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/EdkModulePkg/Core/DxeIplPeim/DxeIpl.mbd b/EdkModulePkg/Core/DxeIplPeim/DxeIpl.mbd index a604fcc..3b5ae36 100644 --- a/EdkModulePkg/Core/DxeIplPeim/DxeIpl.mbd +++ b/EdkModulePkg/Core/DxeIplPeim/DxeIpl.mbd @@ -1,63 +1,63 @@ - - - - - DxeIpl - 86D70125-BAA3-4296-A62F-602BEBBB9081 - EDK_RELEASE_VERSION 0x00020000 - FIX ME! - Copyright (c) 2004-2006, Intel Corporation - - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - 2006-03-12 17:09 - 2006-03-22 18:54 - - - PeimEntryPoint - PeiMemoryLib - PeiCoreLib - PeiServicesTablePointerLib - PeiHobLib - BaseCacheMaintenanceLib - BaseUefiTianoDecompressLib - BaseCustomDecompressLibNull - PeiReportStatusCodeLib - BaseDebugLibReportStatusCode - BaseLib - PeiMemoryAllocationLib - - EdkPeCoffLoaderLib - BasePeCoffLib - - - EdkPeCoffLoaderLib - BasePeCoffLib - - - EdkPeCoffLoaderLib - BasePeCoffLib - - - EdkPeCoffLoaderLib - BasePeCoffLib - - - - _ModuleEntryPoint - - + + + + + DxeIpl + 86D70125-BAA3-4296-A62F-602BEBBB9081 + EDK_RELEASE_VERSION 0x00020000 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-12 17:09 + 2006-03-22 18:54 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + BaseCacheMaintenanceLib + BaseUefiTianoDecompressLib + BaseCustomDecompressLibNull + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + PeiMemoryAllocationLib + + EdkPeCoffLoaderLib + BasePeCoffLib + + + EdkPeCoffLoaderLib + BasePeCoffLib + + + EdkPeCoffLoaderLib + BasePeCoffLib + + + EdkPeCoffLoaderLib + BasePeCoffLib + + + + _ModuleEntryPoint + + diff --git a/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.mbd b/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.mbd index 2df91ec..ef039fc 100644 --- a/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.mbd +++ b/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.mbd @@ -1,49 +1,49 @@ - - - - - DxeIpl - 86D70125-BAA3-4296-A62F-602BEBBB9081 - EDK_RELEASE_VERSION 0x00020000 - FIX ME! - Copyright 2004-2006, Intel Corporation - - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - 2006-04-03 23:58 - - - PeimEntryPoint - PeiMemoryLib - PeiCoreLib - PeiServicesTablePointerLib - PeiHobLib - BaseCacheMaintenanceLib - BaseUefiTianoDecompressLib - BaseCustomDecompressLibNull - PeiReportStatusCodeLib - BaseDebugLibReportStatusCode - BaseLib - PeiMemoryAllocationLib - PeiReportStatusCodeLib - - EdkPeCoffLoaderX64Lib - EdkPeCoffLoaderLib - BasePeCoffLib - - - + + + + + DxeIplX64 + 86D70125-BAA3-4296-A62F-602BEBBB9081 + EDK_RELEASE_VERSION 0x00020000 + FIX ME! + Copyright 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-04-03 23:58 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + BaseCacheMaintenanceLib + BaseUefiTianoDecompressLib + BaseCustomDecompressLibNull + BaseDebugLibReportStatusCode + BaseLib + PeiMemoryAllocationLib + PeiReportStatusCodeLib + EdkPeCoffLoaderX64Lib + EdkPeCoffLoaderLib + BasePeCoffLib + + + _ModuleEntryPoint + + diff --git a/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.msa b/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.msa index e69b824..638809d 100644 --- a/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.msa +++ b/EdkModulePkg/Core/DxeIplPeim/DxeIplX64.msa @@ -1,85 +1,122 @@ - - - - - DxeIpl - PEIM - PE32_PEIM - 86D70125-BAA3-4296-A62F-602BEBBB9081 - EDK_RELEASE_VERSION 0x00020000 - Component description file for DxeIpl module - FIX ME! - Copyright 2004-2006, Intel Corporation - - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - EFI_SPECIFICATION_VERSION 0x00000000 - 2006-04-03 23:58 - - - DebugLib - PeimEntryPoint - BaseLib - HobLib - PerformanceLib - PeiCoreLib - ReportStatusCodeLib - CacheMaintenanceLib - EdkPeCoffLoaderLib - UefiDecompressLib - TianoDecompressLib - CustomDecompressLib - PeiServicesTablePointerLib - BaseMemoryLib - MemoryAllocationLib - EdkPeCoffLoaderX64Lib - - - DxeIpl.dxs - DxeLoadX64.c - - x64/ImageRead.c - x64/LongMode.asm - x64/DxeLoadFunc.c - x64/VirtualMemory.c - - - - MdePkg - EdkModulePkg - - - Decompress - TianoDecompress - CustomizedDecompress - - - PeiInMemory - RecoveryModule - SectionExtraction - Security - DxeIpl - S3Resume - EndOfPeiSignal - FvFileLoader - - - - PeiPeCoffLoader - - - + + + + + DxeIplX64 + PEIM + PE32_PEIM + 86D70125-BAA3-4296-A62F-602BEBBB9081 + EDK_RELEASE_VERSION 0x00020000 + Component description file for DxeIpl module + FIX ME! + Copyright 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + EFI_SPECIFICATION_VERSION 0x00000000 + 2006-04-03 23:58 + + + DebugLib + PeimEntryPoint + BaseLib + HobLib + PerformanceLib + PeiCoreLib + ReportStatusCodeLib + CacheMaintenanceLib + EdkPeCoffLoaderLib + UefiDecompressLib + TianoDecompressLib + CustomDecompressLib + PeiServicesTablePointerLib + BaseMemoryLib + MemoryAllocationLib + EdkPeCoffLoaderX64Lib + + + DxeIpl.dxs + DxeLoadX64.c + + x64/ImageRead.c + x64/LongMode.asm + x64/DxeLoadFunc.c + x64/VirtualMemory.c + + + + MdePkg + EdkModulePkg + + + Decompress + TianoDecompress + CustomizedDecompress + + + + gEfiHobMemoryAllocBspStoreGuid + 0x564b33cd, 0xc92a, 0x4593, 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 + + + gEfiDecompressProtocolGuid + 0xd8117cfe, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiTianoDecompressProtocolGuid + 0xe84cf29c, 0x191f, 0x4eae, 0x96, 0xe1, 0xf4, 0x6a, 0xec, 0xea, 0xea, 0x0b + + + gEfiCustomizedDecompressProtocolGuid + 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f + + + gEfiPeiPeCoffLoaderGuid + 0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiHobMemoryAllocModuleGuid + 0xf8e21975, 0x0899, 0x4f58, 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a + + + DecompressedFvmain.fv + + + + DxeIpl + FvFileLoader + EndOfPeiSignal + RecoveryModule + S3Resume + SectionExtraction + Security + PeiInMemory + + + + PeiPeCoffLoader + + + + + PeimInitializeDxeIpl + + + + _ModuleEntryPoint + + diff --git a/EdkModulePkg/Core/DxeIplPeim/DxeLoadX64.c b/EdkModulePkg/Core/DxeIplPeim/DxeLoadX64.c index 6727bf4..e0dbe84 100644 --- a/EdkModulePkg/Core/DxeIplPeim/DxeLoadX64.c +++ b/EdkModulePkg/Core/DxeIplPeim/DxeLoadX64.c @@ -1,1018 +1,990 @@ -/*++ - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - DxeLoad.c - -Abstract: - - Last PEIM. - Responsibility of this module is to load the DXE Core from a Firmware Volume. - ---*/ - -#include - -#pragma warning( disable : 4305 ) - -BOOLEAN gInMemory = FALSE; - -// -// GUID for EM64T -// -#define EFI_PPI_NEEDED_BY_DXE \ - { \ - 0x4d37da42, 0x3a0c, 0x4eda, 0xb9, 0xeb, 0xbc, 0x0e, 0x1d, 0xb4, 0x71, 0x3b \ - } -EFI_GUID mPpiNeededByDxeGuid = EFI_PPI_NEEDED_BY_DXE; - -// -// Module Globals used in the DXE to PEI handoff -// These must be module globals, so the stack can be switched -// -static EFI_DXE_IPL_PPI mDxeIplPpi = { - DxeLoadCore -}; - -static EFI_PEI_FV_FILE_LOADER_PPI mLoadFilePpi = { - DxeIplLoadFile -}; - -static EFI_PEI_PPI_DESCRIPTOR mPpiLoadFile = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiFvFileLoaderPpiGuid, - &mLoadFilePpi -}; - -static EFI_PEI_PPI_DESCRIPTOR mPpiList = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiDxeIplPpiGuid, - &mDxeIplPpi -}; - -static EFI_PEI_PPI_DESCRIPTOR mPpiPeiInMemory = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gPeiInMemoryGuid, - NULL -}; - -static EFI_PEI_PPI_DESCRIPTOR mPpiSignal = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiEndOfPeiSignalPpiGuid, - NULL -}; - -DECOMPRESS_LIBRARY gEfiDecompress = { - UefiDecompressGetInfo, - UefiDecompress -}; - -DECOMPRESS_LIBRARY gTianoDecompress = { - TianoDecompressGetInfo, - TianoDecompress -}; - -DECOMPRESS_LIBRARY gCustomDecompress = { - CustomDecompressGetInfo, - CustomDecompress -}; - -STATIC -UINTN -GetOccupiedSize ( - IN UINTN ActualSize, - IN UINTN Alignment - ) -{ - UINTN OccupiedSize; - - OccupiedSize = ActualSize; - while ((OccupiedSize & (Alignment - 1)) != 0) { - OccupiedSize++; - } - - return OccupiedSize; -} - -EFI_STATUS -EFIAPI -PeimInitializeDxeIpl ( - IN EFI_FFS_FILE_HEADER *FfsHeader, - IN EFI_PEI_SERVICES **PeiServices - ) -/*++ - -Routine Description: - - Initializes the Dxe Ipl PPI - -Arguments: - - FfsHeader - Pointer to FFS file header - PeiServices - General purpose services available to every PEIM. - -Returns: - - EFI_SUCCESS - ---*/ -{ - EFI_STATUS Status; - EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader; - EFI_BOOT_MODE BootMode; - - Status = PeiCoreGetBootMode (&BootMode); - - ASSERT_EFI_ERROR (Status); - - Status = PeiCoreLocatePpi ( - &gPeiInMemoryGuid, - 0, - NULL, - NULL - ); - - if (EFI_ERROR (Status) && (BootMode != BOOT_ON_S3_RESUME)) { - // - // The DxeIpl has not yet been shadowed - // - PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol (); - - // - // Shadow DxeIpl and then re-run its entry point - // - Status = ShadowDxeIpl (FfsHeader, PeiEfiPeiPeCoffLoader); - if (EFI_ERROR (Status)) { - return Status; - } - - } else { - if (BootMode != BOOT_ON_S3_RESUME) { - // - // The DxeIpl has been shadowed - // - gInMemory = TRUE; - - // - // Install LoadFile PPI - // - Status = PeiCoreInstallPpi (&mPpiLoadFile); - - if (EFI_ERROR (Status)) { - return Status; - } - } - // - // Install DxeIpl PPI - // - PeiCoreInstallPpi (&mPpiList); - - if (EFI_ERROR (Status)) { - return Status; - } - - } - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -DxeLoadCore ( - IN EFI_DXE_IPL_PPI *This, - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_HOB_POINTERS HobList - ) -/*++ - -Routine Description: - - Main entry point to last PEIM - -Arguments: - - This - Entry point for DXE IPL PPI - PeiServices - General purpose services available to every PEIM. - HobList - Address to the Pei HOB list - -Returns: - - EFI_SUCCESS - DEX core was successfully loaded. - EFI_OUT_OF_RESOURCES - There are not enough resources to load DXE core. - ---*/ -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS TopOfStack; - EFI_PHYSICAL_ADDRESS BaseOfStack; - EFI_PHYSICAL_ADDRESS BspStore; - EFI_GUID DxeCoreFileName; - VOID *DxeCorePe32Data; - EFI_PHYSICAL_ADDRESS DxeCoreAddress; - UINT64 DxeCoreSize; - EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint; - VOID *PpisNeededByDxePe32Data; - EFI_PHYSICAL_ADDRESS PpisNeededByDxeAddress; - UINT64 PpisNeededByDxeSize; - EFI_PHYSICAL_ADDRESS PpisNeededByDxeEntryPoint; - EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader; - EFI_BOOT_MODE BootMode; - EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery; - EFI_PEI_S3_RESUME_PPI *S3Resume; - EFI_PHYSICAL_ADDRESS PageTables; - - TopOfStack = 0; - BaseOfStack = 0; - BspStore = 0; - Status = EFI_SUCCESS; - - // - // if in S3 Resume, restore configure - // - Status = PeiCoreGetBootMode (&BootMode); - - if (!EFI_ERROR (Status) && (BootMode == BOOT_ON_S3_RESUME)) { - Status = PeiCoreLocatePpi ( - &gEfiPeiS3ResumePpiGuid, - 0, - NULL, - (VOID **)&S3Resume - ); - - ASSERT_EFI_ERROR (Status); - - Status = S3Resume->S3RestoreConfig (PeiServices); - - ASSERT_EFI_ERROR (Status); - } - - Status = EFI_SUCCESS; - - // - // Install the PEI Protocols that are shared between PEI and DXE - // -#ifdef EFI_NT_EMULATOR - PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol (); - ASSERT (PeiEfiPeiPeCoffLoader != NULL); -#else - PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderX64Protocol (); -#endif - -#if 0 - Status = InstallEfiPeiPeCoffLoader64 (PeiServices, &PeiEfiPeiPeCoffLoader, NULL); - ASSERT_EFI_ERROR (Status); -#endif - // - // Allocate 128KB for the Stack - // - PeiCoreAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack); - ASSERT (BaseOfStack != 0); - - // - // Compute the top of the stack we were allocated. Pre-allocate a 32 bytes - // for safety (PpisNeededByDxe and DxeCore). - // - TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32; - - // - // Add architecture-specifc HOBs (including the BspStore HOB) - // - Status = CreateArchSpecificHobs (&BspStore); - ASSERT_EFI_ERROR (Status); - - // - // See if we are in crisis recovery - // - Status = PeiCoreGetBootMode (&BootMode); - if (!EFI_ERROR (Status) && (BootMode == BOOT_IN_RECOVERY_MODE)) { - Status = PeiCoreLocatePpi ( - &gEfiPeiRecoveryModulePpiGuid, - 0, - NULL, - (VOID **)&PeiRecovery - ); - - ASSERT_EFI_ERROR (Status); - Status = PeiRecovery->LoadRecoveryCapsule (PeiServices, PeiRecovery); - ASSERT_EFI_ERROR (Status); - } - - // - // Find the DXE Core in a Firmware Volume - // - Status = PeiFindFile ( - EFI_FV_FILETYPE_DXE_CORE, - EFI_SECTION_PE32, - &DxeCoreFileName, - &DxeCorePe32Data - ); - ASSERT_EFI_ERROR (Status); - - // - // Find the PpisNeededByDxe in a Firmware Volume - // - Status = PeiFindFile ( - EFI_FV_FILETYPE_ALL, - EFI_SECTION_PE32, - &mPpiNeededByDxeGuid, - &PpisNeededByDxePe32Data - ); - ASSERT_EFI_ERROR (Status); - - // - // Transfer control to the DXE Core - // The handoff state is simply a pointer to the HOB list - // - // PEI_PERF_END (PeiServices, L"DxeIpl", NULL, 0); - - Status = PeiCoreInstallPpi (&mPpiSignal); - ASSERT_EFI_ERROR (Status); - - // - // Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA \ - // memory, it may be corrupted when copying FV to high-end memory - LoadGo64Gdt(); - - // - // Limit to 36 bits of addressing for debug. Should get it from CPU - // - PageTables = CreateIdentityMappingPageTables (36); - - // - // Load the PpiNeededByDxe from a Firmware Volume - // - Status = PeiLoadx64File ( - PeiEfiPeiPeCoffLoader, - PpisNeededByDxePe32Data, - EfiBootServicesData, - &PpisNeededByDxeAddress, - &PpisNeededByDxeSize, - &PpisNeededByDxeEntryPoint - ); - ASSERT_EFI_ERROR (Status); - - - // - // Load the DXE Core from a Firmware Volume - // - Status = PeiLoadx64File ( - PeiEfiPeiPeCoffLoader, - DxeCorePe32Data, - EfiBootServicesData, - &DxeCoreAddress, - &DxeCoreSize, - &DxeCoreEntryPoint - ); - ASSERT_EFI_ERROR (Status); - - // - // - // Add HOB for the DXE Core - // - BuildModuleHob ( - &DxeCoreFileName, - DxeCoreAddress, - DxeCoreSize, - DxeCoreEntryPoint - ); - - // - // Report Status Code EFI_SW_PEI_PC_HANDOFF_TO_NEXT - // - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT - ); - - DEBUG ((EFI_D_INFO, "DXE Core Entry\n")); - // - // Go to Long Mode. Interrupts will not get turned on until the CPU AP is loaded. - // Call x64 drivers passing in single argument, a pointer to the HOBs. - // - ActivateLongMode ( - PageTables, - (EFI_PHYSICAL_ADDRESS)(UINTN)(HobList.Raw), - TopOfStack, - PpisNeededByDxeEntryPoint, - DxeCoreEntryPoint - ); - - // - // If we get here, then the DXE Core returned. This is an error - // - ASSERT_EFI_ERROR (Status); - - return EFI_OUT_OF_RESOURCES; -} - -EFI_STATUS -PeiFindFile ( - IN UINT8 Type, - IN UINT16 SectionType, - OUT EFI_GUID *FileName, - OUT VOID **Pe32Data - ) -/*++ - -Routine Description: - - Finds a PE/COFF of a specific Type and SectionType in the Firmware Volumes - described in the HOB list. Able to search in a compression set in a FFS file. - But only one level of compression is supported, that is, not able to search - in a compression set that is within another compression set. - -Arguments: - - Type - The Type of file to retrieve - - SectionType - The type of section to retrieve from a file - - FileName - The name of the file found in the Firmware Volume - - Pe32Data - Pointer to the beginning of the PE/COFF file found in the Firmware Volume - -Returns: - - EFI_SUCCESS - The file was found, and the name is returned in FileName, and a pointer to - the PE/COFF image is returned in Pe32Data - - EFI_NOT_FOUND - The file was not found in the Firmware Volumes present in the HOB List - ---*/ -{ - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; - EFI_FFS_FILE_HEADER *FfsFileHeader; - VOID *SectionData; - EFI_STATUS Status; - EFI_PEI_HOB_POINTERS Hob; - - - FwVolHeader = NULL; - FfsFileHeader = NULL; - SectionData = NULL; - - // - // Foreach Firmware Volume, look for a specified type - // of file and break out when one is found - // - Hob.Raw = GetHobList (); - while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw)) != NULL) { - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (Hob.FirmwareVolume->BaseAddress); - Status = PeiCoreFfsFindNextFile ( - Type, - FwVolHeader, - &FfsFileHeader - ); - if (!EFI_ERROR (Status)) { - CopyMem (FileName, &FfsFileHeader->Name, sizeof (EFI_GUID)); - Status = PeiProcessFile ( - SectionType, - FfsFileHeader, - Pe32Data - ); - return Status; - } - Hob.Raw = GET_NEXT_HOB (Hob); - } - return EFI_NOT_FOUND; -} - -EFI_STATUS -PeiLoadx64File ( - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader, - IN VOID *Pe32Data, - IN EFI_MEMORY_TYPE MemoryType, - OUT EFI_PHYSICAL_ADDRESS *ImageAddress, - OUT UINT64 *ImageSize, - OUT EFI_PHYSICAL_ADDRESS *EntryPoint - ) -/*++ - -Routine Description: - - Loads and relocates a PE/COFF image into memory. - -Arguments: - - PeiEfiPeiPeCoffLoader - Pointer to a PE COFF loader protocol - - Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated - - ImageAddress - The base address of the relocated PE/COFF image - - ImageSize - The size of the relocated PE/COFF image - - EntryPoint - The entry point of the relocated PE/COFF image - -Returns: - - EFI_SUCCESS - The file was loaded and relocated - EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file - ---*/ -{ - EFI_STATUS Status; - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - EFI_PHYSICAL_ADDRESS MemoryBuffer; - - ZeroMem (&ImageContext, sizeof (ImageContext)); - ImageContext.Handle = Pe32Data; - Status = GetImageReadFunction (&ImageContext); - - ASSERT_EFI_ERROR (Status); - - Status = PeiEfiPeiPeCoffLoader->GetImageInfo (PeiEfiPeiPeCoffLoader, &ImageContext); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Allocate Memory for the image - // - // - // Allocate Memory for the image - // - PeiCoreAllocatePages (MemoryType, EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize), &MemoryBuffer); - ImageContext.ImageAddress = MemoryBuffer; - ASSERT (ImageContext.ImageAddress != 0); - - // - // Load the image to our new buffer - // - - Status = PeiEfiPeiPeCoffLoader->LoadImage (PeiEfiPeiPeCoffLoader, &ImageContext); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Relocate the image in our new buffer - // - Status = PeiEfiPeiPeCoffLoader->RelocateImage (PeiEfiPeiPeCoffLoader, &ImageContext); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Flush the instruction cache so the image data is written before we execute it - // - InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize); - - *ImageAddress = ImageContext.ImageAddress; - *ImageSize = ImageContext.ImageSize; - *EntryPoint = ImageContext.EntryPoint; - - return EFI_SUCCESS; -} - -EFI_STATUS -ShadowDxeIpl ( - IN EFI_FFS_FILE_HEADER *DxeIplFileHeader, - IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader - ) -/*++ - -Routine Description: - - Shadow the DXE IPL to a different memory location. This occurs after permanent - memory has been discovered. - -Arguments: - - DxeIplFileHeader - Pointer to the FFS file header of the DXE IPL driver - - PeiEfiPeiPeCoffLoader - Pointer to a PE COFF loader protocol - -Returns: - - EFI_SUCCESS - DXE IPL was successfully shadowed to a different memory location. - - EFI_ ERROR - The shadow was unsuccessful. - - ---*/ -{ - UINTN SectionLength; - UINTN OccupiedSectionLength; - EFI_PHYSICAL_ADDRESS DxeIplAddress; - UINT64 DxeIplSize; - EFI_PHYSICAL_ADDRESS DxeIplEntryPoint; - EFI_STATUS Status; - EFI_COMMON_SECTION_HEADER *Section; - - Section = (EFI_COMMON_SECTION_HEADER *) (DxeIplFileHeader + 1); - - while ((Section->Type != EFI_SECTION_PE32) && (Section->Type != EFI_SECTION_TE)) { - SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff; - OccupiedSectionLength = GetOccupiedSize (SectionLength, 4); - Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + OccupiedSectionLength); - } - - // - // Relocate DxeIpl into memory by using loadfile service - // - Status = PeiLoadx64File ( - PeiEfiPeiPeCoffLoader, - (VOID *) (Section + 1), - EfiBootServicesData, - &DxeIplAddress, - &DxeIplSize, - &DxeIplEntryPoint - ); - - if (Status == EFI_SUCCESS) { - // - // Install PeiInMemory to indicate the Dxeipl is shadowed - // - Status = PeiCoreInstallPpi (&mPpiPeiInMemory); - - if (EFI_ERROR (Status)) { - return Status; - } - - Status = ((EFI_PEIM_ENTRY_POINT) (UINTN) DxeIplEntryPoint) (DxeIplFileHeader, GetPeiServicesTablePointer()); - } - - return Status; -} - -EFI_STATUS -EFIAPI -DxeIplLoadFile ( - IN EFI_PEI_FV_FILE_LOADER_PPI *This, - IN EFI_FFS_FILE_HEADER *FfsHeader, - OUT EFI_PHYSICAL_ADDRESS *ImageAddress, - OUT UINT64 *ImageSize, - OUT EFI_PHYSICAL_ADDRESS *EntryPoint - ) -/*++ - -Routine Description: - - Given a pointer to an FFS file containing a PE32 image, get the - information on the PE32 image, and then "load" it so that it - can be executed. - -Arguments: - - This - pointer to our file loader protocol - FfsHeader - pointer to the FFS file header of the FFS file that - contains the PE32 image we want to load - ImageAddress - returned address where the PE32 image is loaded - ImageSize - returned size of the loaded PE32 image - EntryPoint - entry point to the loaded PE32 image - -Returns: - - EFI_SUCCESS - The FFS file was successfully loaded. - EFI_ERROR - Unable to load the FFS file. - ---*/ -{ - EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader; - EFI_STATUS Status; - VOID *Pe32Data; - - Pe32Data = NULL; - PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol (); - - // - // Preprocess the FFS file to get a pointer to the PE32 information - // in the enclosed PE32 image. - // - Status = PeiProcessFile ( - EFI_SECTION_PE32, - FfsHeader, - &Pe32Data - ); - - if (EFI_ERROR (Status)) { - return Status; - } - // - // Load the PE image from the FFS file - // - Status = PeiLoadx64File ( - PeiEfiPeiPeCoffLoader, - Pe32Data, - EfiBootServicesData, - ImageAddress, - ImageSize, - EntryPoint - ); - - return Status; -} - -EFI_STATUS -PeiProcessFile ( - IN UINT16 SectionType, - IN EFI_FFS_FILE_HEADER *FfsFileHeader, - OUT VOID **Pe32Data - ) -/*++ - -Routine Description: - -Arguments: - - SectionType - The type of section in the FFS file to process. - - FfsFileHeader - Pointer to the FFS file to process, looking for the - specified SectionType - - Pe32Data - returned pointer to the start of the PE32 image found - in the FFS file. - -Returns: - - EFI_SUCCESS - found the PE32 section in the FFS file - ---*/ -{ - EFI_STATUS Status; - VOID *SectionData; - DECOMPRESS_LIBRARY *DecompressLibrary; - UINT8 *DstBuffer; - UINT8 *ScratchBuffer; - UINT32 DstBufferSize; - UINT32 ScratchBufferSize; - EFI_COMMON_SECTION_HEADER *CmpSection; - UINTN CmpSectionLength; - UINTN OccupiedCmpSectionLength; - VOID *CmpFileData; - UINTN CmpFileSize; - EFI_COMMON_SECTION_HEADER *Section; - UINTN SectionLength; - UINTN OccupiedSectionLength; - UINT64 FileSize; - EFI_GUID_DEFINED_SECTION *GuidedSectionHeader; - UINT32 AuthenticationStatus; - EFI_PEI_SECTION_EXTRACTION_PPI *SectionExtract; - UINT32 BufferSize; - UINT8 *Buffer; - EFI_PEI_SECURITY_PPI *Security; - BOOLEAN StartCrisisRecovery; - EFI_GUID TempGuid; - EFI_FIRMWARE_VOLUME_HEADER *FvHeader; - EFI_COMPRESSION_SECTION *CompressionSection; - - Status = PeiCoreFfsFindSectionData ( - EFI_SECTION_COMPRESSION, - FfsFileHeader, - &SectionData - ); - - // - // Upon finding a DXE Core file, see if there is first a compression section - // - if (!EFI_ERROR (Status)) { - // - // Yes, there is a compression section, so extract the contents - // Decompress the image here - // - Section = (EFI_COMMON_SECTION_HEADER *) (UINTN) (VOID *) ((UINT8 *) (FfsFileHeader) + (UINTN) sizeof (EFI_FFS_FILE_HEADER)); - - do { - SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff; - OccupiedSectionLength = GetOccupiedSize (SectionLength, 4); - - // - // Was the DXE Core file encapsulated in a GUID'd section? - // - if (Section->Type == EFI_SECTION_GUID_DEFINED) { - // - // Locate the GUID'd Section Extractor - // - GuidedSectionHeader = (VOID *) (Section + 1); - - // - // This following code constitutes the addition of the security model - // to the DXE IPL. - // - // - // Set a default authenticatino state - // - AuthenticationStatus = 0; - - Status = PeiCoreLocatePpi ( - &gEfiPeiSectionExtractionPpiGuid, - 0, - NULL, - (VOID **)&SectionExtract - ); - - if (EFI_ERROR (Status)) { - return Status; - } - // - // Verify Authentication State - // - CopyMem (&TempGuid, Section + 1, sizeof (EFI_GUID)); - - Status = SectionExtract->PeiGetSection ( - GetPeiServicesTablePointer(), - SectionExtract, - (EFI_SECTION_TYPE *) &SectionType, - &TempGuid, - 0, - (VOID **) &Buffer, - &BufferSize, - &AuthenticationStatus - ); - - if (EFI_ERROR (Status)) { - return Status; - } - // - // If not ask the Security PPI, if exists, for disposition - // - // - Status = PeiCoreLocatePpi ( - &gEfiPeiSecurityPpiGuid, - 0, - NULL, - (VOID **)&Security - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = Security->AuthenticationState ( - GetPeiServicesTablePointer(), - (struct _EFI_PEI_SECURITY_PPI *) Security, - AuthenticationStatus, - FfsFileHeader, - &StartCrisisRecovery - ); - - if (EFI_ERROR (Status)) { - return Status; - } - // - // If there is a security violation, report to caller and have - // the upper-level logic possible engender a crisis recovery - // - if (StartCrisisRecovery) { - return EFI_SECURITY_VIOLATION; - } - } - - if (Section->Type == EFI_SECTION_PE32) { - // - // This is what we want - // - *Pe32Data = (VOID *) (Section + 1); - return EFI_SUCCESS; - } else if (Section->Type == EFI_SECTION_COMPRESSION) { - // - // This is a compression set, expand it - // - CompressionSection = (EFI_COMPRESSION_SECTION *) Section; - - switch (CompressionSection->CompressionType) { - case EFI_STANDARD_COMPRESSION: - DecompressLibrary = &gTianoDecompress; - break; - - case EFI_CUSTOMIZED_COMPRESSION: - // - // Load user customized compression protocol. - // - DecompressLibrary = &gCustomDecompress; - break; - - case EFI_NOT_COMPRESSED: - default: - // - // Need to support not compressed file - // - ASSERT_EFI_ERROR (Status); - return EFI_NOT_FOUND; - } - - Status = DecompressLibrary->GetInfo ( - (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), - (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION), - &DstBufferSize, - &ScratchBufferSize - ); - if (EFI_ERROR (Status)) { - // - // GetInfo failed - // - return EFI_NOT_FOUND; - } - - // - // Allocate scratch buffer - // - ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize)); - if (ScratchBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Allocate destination buffer - // - DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize)); - if (DstBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Call decompress function - // - Status = DecompressLibrary->Decompress ( - (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), - DstBuffer, - ScratchBuffer - ); - - CmpSection = (EFI_COMMON_SECTION_HEADER *) DstBuffer; - if (CmpSection->Type == EFI_SECTION_RAW) { - // - // Skip the section header and - // adjust the pointer alignment to 16 - // - FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (DstBuffer + 16); - - if (FvHeader->Signature == EFI_FVH_SIGNATURE) { - FfsFileHeader = NULL; - BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader, FvHeader->FvLength); - Status = PeiCoreFfsFindNextFile ( - EFI_FV_FILETYPE_DXE_CORE, - FvHeader, - &FfsFileHeader - ); - - if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; - } - - return PeiProcessFile (SectionType, FfsFileHeader, Pe32Data); - } - } - // - // Decompress successfully. - // Loop the decompressed data searching for expected section. - // - CmpFileData = (VOID *) DstBuffer; - CmpFileSize = DstBufferSize; - do { - CmpSectionLength = *(UINT32 *) (CmpSection->Size) & 0x00ffffff; - if (CmpSection->Type == EFI_SECTION_PE32) { - // - // This is what we want - // - *Pe32Data = (VOID *) (CmpSection + 1); - return EFI_SUCCESS; - } - - OccupiedCmpSectionLength = GetOccupiedSize (CmpSectionLength, 4); - CmpSection = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) CmpSection + OccupiedCmpSectionLength); - } while (CmpSection->Type != 0 && (UINTN) ((UINT8 *) CmpSection - (UINT8 *) CmpFileData) < CmpFileSize); - } - - Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + OccupiedSectionLength); - FileSize = FfsFileHeader->Size[0] & 0xFF; - FileSize += (FfsFileHeader->Size[1] << 8) & 0xFF00; - FileSize += (FfsFileHeader->Size[2] << 16) & 0xFF0000; - FileSize &= 0x00FFFFFF; - } while (Section->Type != 0 && (UINTN) ((UINT8 *) Section - (UINT8 *) FfsFileHeader) < FileSize); - - // - // End of the decompression activity - // - } else { - - Status = PeiCoreFfsFindSectionData ( - EFI_SECTION_PE32, - FfsFileHeader, - &SectionData - ); - - if (EFI_ERROR (Status)) { - Status = PeiCoreFfsFindSectionData ( - EFI_SECTION_TE, - FfsFileHeader, - &SectionData - ); - if (EFI_ERROR (Status)) { - return Status; - } - } - } - - *Pe32Data = SectionData; - - return EFI_SUCCESS; +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + DxeLoad.c + +Abstract: + + Last PEIM. + Responsibility of this module is to load the DXE Core from a Firmware Volume. + +--*/ + +#include + +#pragma warning( disable : 4305 ) + +BOOLEAN gInMemory = FALSE; + +// +// GUID for EM64T +// +#define EFI_PPI_NEEDED_BY_DXE \ + { \ + 0x4d37da42, 0x3a0c, 0x4eda, 0xb9, 0xeb, 0xbc, 0x0e, 0x1d, 0xb4, 0x71, 0x3b \ + } +EFI_GUID mPpiNeededByDxeGuid = EFI_PPI_NEEDED_BY_DXE; + +// +// Module Globals used in the DXE to PEI handoff +// These must be module globals, so the stack can be switched +// +static EFI_DXE_IPL_PPI mDxeIplPpi = { + DxeLoadCore +}; + +static EFI_PEI_FV_FILE_LOADER_PPI mLoadFilePpi = { + DxeIplLoadFile +}; + +static EFI_PEI_PPI_DESCRIPTOR mPpiLoadFile = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiFvFileLoaderPpiGuid, + &mLoadFilePpi +}; + +static EFI_PEI_PPI_DESCRIPTOR mPpiList = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiDxeIplPpiGuid, + &mDxeIplPpi +}; + +static EFI_PEI_PPI_DESCRIPTOR mPpiPeiInMemory = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gPeiInMemoryGuid, + NULL +}; + +static EFI_PEI_PPI_DESCRIPTOR mPpiSignal = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiEndOfPeiSignalPpiGuid, + NULL +}; + +DECOMPRESS_LIBRARY gEfiDecompress = { + UefiDecompressGetInfo, + UefiDecompress +}; + +DECOMPRESS_LIBRARY gTianoDecompress = { + TianoDecompressGetInfo, + TianoDecompress +}; + +DECOMPRESS_LIBRARY gCustomDecompress = { + CustomDecompressGetInfo, + CustomDecompress +}; + +STATIC +UINTN +GetOccupiedSize ( + IN UINTN ActualSize, + IN UINTN Alignment + ) +{ + UINTN OccupiedSize; + + OccupiedSize = ActualSize; + while ((OccupiedSize & (Alignment - 1)) != 0) { + OccupiedSize++; + } + + return OccupiedSize; +} + +EFI_STATUS +EFIAPI +PeimInitializeDxeIpl ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Initializes the Dxe Ipl PPI + +Arguments: + + FfsHeader - Pointer to FFS file header + PeiServices - General purpose services available to every PEIM. + +Returns: + + EFI_SUCCESS + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader; + EFI_BOOT_MODE BootMode; + + Status = PeiCoreGetBootMode (&BootMode); + + ASSERT_EFI_ERROR (Status); + + Status = PeiCoreLocatePpi ( + &gPeiInMemoryGuid, + 0, + NULL, + NULL + ); + + if (EFI_ERROR (Status) && (BootMode != BOOT_ON_S3_RESUME)) { + // + // The DxeIpl has not yet been shadowed + // + PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol (); + + // + // Shadow DxeIpl and then re-run its entry point + // + Status = ShadowDxeIpl (FfsHeader, PeiEfiPeiPeCoffLoader); + if (EFI_ERROR (Status)) { + return Status; + } + + } else { + if (BootMode != BOOT_ON_S3_RESUME) { + // + // The DxeIpl has been shadowed + // + gInMemory = TRUE; + + // + // Install LoadFile PPI + // + Status = PeiCoreInstallPpi (&mPpiLoadFile); + + if (EFI_ERROR (Status)) { + return Status; + } + } + // + // Install DxeIpl PPI + // + PeiCoreInstallPpi (&mPpiList); + + if (EFI_ERROR (Status)) { + return Status; + } + + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +DxeLoadCore ( + IN EFI_DXE_IPL_PPI *This, + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_HOB_POINTERS HobList + ) +/*++ + +Routine Description: + + Main entry point to last PEIM + +Arguments: + + This - Entry point for DXE IPL PPI + PeiServices - General purpose services available to every PEIM. + HobList - Address to the Pei HOB list + +Returns: + + EFI_SUCCESS - DEX core was successfully loaded. + EFI_OUT_OF_RESOURCES - There are not enough resources to load DXE core. + +--*/ +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS TopOfStack; + EFI_PHYSICAL_ADDRESS BaseOfStack; + EFI_PHYSICAL_ADDRESS BspStore; + EFI_GUID DxeCoreFileName; + VOID *DxeCorePe32Data; + EFI_PHYSICAL_ADDRESS DxeCoreAddress; + UINT64 DxeCoreSize; + EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint; + EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader; + EFI_BOOT_MODE BootMode; + EFI_PEI_RECOVERY_MODULE_PPI *PeiRecovery; + EFI_PEI_S3_RESUME_PPI *S3Resume; + EFI_PHYSICAL_ADDRESS PageTables; + + TopOfStack = 0; + BaseOfStack = 0; + BspStore = 0; + Status = EFI_SUCCESS; + + // + // if in S3 Resume, restore configure + // + Status = PeiCoreGetBootMode (&BootMode); + + if (!EFI_ERROR (Status) && (BootMode == BOOT_ON_S3_RESUME)) { + Status = PeiCoreLocatePpi ( + &gEfiPeiS3ResumePpiGuid, + 0, + NULL, + (VOID **)&S3Resume + ); + + ASSERT_EFI_ERROR (Status); + + Status = S3Resume->S3RestoreConfig (PeiServices); + + ASSERT_EFI_ERROR (Status); + } + + Status = EFI_SUCCESS; + + // + // Install the PEI Protocols that are shared between PEI and DXE + // +#ifdef EFI_NT_EMULATOR + PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol (); + ASSERT (PeiEfiPeiPeCoffLoader != NULL); +#else + PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderX64Protocol (); +#endif + +#if 0 + Status = InstallEfiPeiPeCoffLoader64 (PeiServices, &PeiEfiPeiPeCoffLoader, NULL); + ASSERT_EFI_ERROR (Status); +#endif + // + // Allocate 128KB for the Stack + // + PeiCoreAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack); + ASSERT (BaseOfStack != 0); + + // + // Compute the top of the stack we were allocated. Pre-allocate a 32 bytes + // for safety (PpisNeededByDxe and DxeCore). + // + TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32; + + // + // Add architecture-specifc HOBs (including the BspStore HOB) + // + Status = CreateArchSpecificHobs (&BspStore); + ASSERT_EFI_ERROR (Status); + + // + // See if we are in crisis recovery + // + Status = PeiCoreGetBootMode (&BootMode); + if (!EFI_ERROR (Status) && (BootMode == BOOT_IN_RECOVERY_MODE)) { + Status = PeiCoreLocatePpi ( + &gEfiPeiRecoveryModulePpiGuid, + 0, + NULL, + (VOID **)&PeiRecovery + ); + + ASSERT_EFI_ERROR (Status); + Status = PeiRecovery->LoadRecoveryCapsule (PeiServices, PeiRecovery); + ASSERT_EFI_ERROR (Status); + } + + // + // Find the DXE Core in a Firmware Volume + // + Status = PeiFindFile ( + EFI_FV_FILETYPE_DXE_CORE, + EFI_SECTION_PE32, + &DxeCoreFileName, + &DxeCorePe32Data + ); + ASSERT_EFI_ERROR (Status); + + // + // Transfer control to the DXE Core + // The handoff state is simply a pointer to the HOB list + // + // PEI_PERF_END (PeiServices, L"DxeIpl", NULL, 0); + + Status = PeiCoreInstallPpi (&mPpiSignal); + ASSERT_EFI_ERROR (Status); + + // + // Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA \ + // memory, it may be corrupted when copying FV to high-end memory + LoadGo64Gdt(); + + // + // Limit to 36 bits of addressing for debug. Should get it from CPU + // + PageTables = CreateIdentityMappingPageTables (36); + + + // + // Load the DXE Core from a Firmware Volume + // + Status = PeiLoadx64File ( + PeiEfiPeiPeCoffLoader, + DxeCorePe32Data, + EfiBootServicesData, + &DxeCoreAddress, + &DxeCoreSize, + &DxeCoreEntryPoint + ); + ASSERT_EFI_ERROR (Status); + + // + // + // Add HOB for the DXE Core + // + BuildModuleHob ( + &DxeCoreFileName, + DxeCoreAddress, + DxeCoreSize, + DxeCoreEntryPoint + ); + + // + // Report Status Code EFI_SW_PEI_PC_HANDOFF_TO_NEXT + // + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT + ); + + DEBUG ((EFI_D_INFO, "DXE Core Entry\n")); + // + // Go to Long Mode. Interrupts will not get turned on until the CPU AP is loaded. + // Call x64 drivers passing in single argument, a pointer to the HOBs. + // + ActivateLongMode ( + PageTables, + (EFI_PHYSICAL_ADDRESS)(UINTN)(HobList.Raw), + TopOfStack, + 0x00000000, + DxeCoreEntryPoint + ); + + // + // If we get here, then the DXE Core returned. This is an error + // + ASSERT_EFI_ERROR (Status); + + return EFI_OUT_OF_RESOURCES; +} + +EFI_STATUS +PeiFindFile ( + IN UINT8 Type, + IN UINT16 SectionType, + OUT EFI_GUID *FileName, + OUT VOID **Pe32Data + ) +/*++ + +Routine Description: + + Finds a PE/COFF of a specific Type and SectionType in the Firmware Volumes + described in the HOB list. Able to search in a compression set in a FFS file. + But only one level of compression is supported, that is, not able to search + in a compression set that is within another compression set. + +Arguments: + + Type - The Type of file to retrieve + + SectionType - The type of section to retrieve from a file + + FileName - The name of the file found in the Firmware Volume + + Pe32Data - Pointer to the beginning of the PE/COFF file found in the Firmware Volume + +Returns: + + EFI_SUCCESS - The file was found, and the name is returned in FileName, and a pointer to + the PE/COFF image is returned in Pe32Data + + EFI_NOT_FOUND - The file was not found in the Firmware Volumes present in the HOB List + +--*/ +{ + EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; + EFI_FFS_FILE_HEADER *FfsFileHeader; + VOID *SectionData; + EFI_STATUS Status; + EFI_PEI_HOB_POINTERS Hob; + + + FwVolHeader = NULL; + FfsFileHeader = NULL; + SectionData = NULL; + + // + // Foreach Firmware Volume, look for a specified type + // of file and break out when one is found + // + Hob.Raw = GetHobList (); + while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw)) != NULL) { + FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (Hob.FirmwareVolume->BaseAddress); + Status = PeiCoreFfsFindNextFile ( + Type, + FwVolHeader, + &FfsFileHeader + ); + if (!EFI_ERROR (Status)) { + CopyMem (FileName, &FfsFileHeader->Name, sizeof (EFI_GUID)); + Status = PeiProcessFile ( + SectionType, + FfsFileHeader, + Pe32Data + ); + return Status; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } + return EFI_NOT_FOUND; +} + +EFI_STATUS +PeiLoadx64File ( + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader, + IN VOID *Pe32Data, + IN EFI_MEMORY_TYPE MemoryType, + OUT EFI_PHYSICAL_ADDRESS *ImageAddress, + OUT UINT64 *ImageSize, + OUT EFI_PHYSICAL_ADDRESS *EntryPoint + ) +/*++ + +Routine Description: + + Loads and relocates a PE/COFF image into memory. + +Arguments: + + PeiEfiPeiPeCoffLoader - Pointer to a PE COFF loader protocol + + Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated + + ImageAddress - The base address of the relocated PE/COFF image + + ImageSize - The size of the relocated PE/COFF image + + EntryPoint - The entry point of the relocated PE/COFF image + +Returns: + + EFI_SUCCESS - The file was loaded and relocated + EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file + +--*/ +{ + EFI_STATUS Status; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + EFI_PHYSICAL_ADDRESS MemoryBuffer; + + ZeroMem (&ImageContext, sizeof (ImageContext)); + ImageContext.Handle = Pe32Data; + Status = GetImageReadFunction (&ImageContext); + + ASSERT_EFI_ERROR (Status); + + Status = PeiEfiPeiPeCoffLoader->GetImageInfo (PeiEfiPeiPeCoffLoader, &ImageContext); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Allocate Memory for the image + // + // + // Allocate Memory for the image + // + PeiCoreAllocatePages (MemoryType, EFI_SIZE_TO_PAGES ((UINT32) ImageContext.ImageSize), &MemoryBuffer); + ImageContext.ImageAddress = MemoryBuffer; + ASSERT (ImageContext.ImageAddress != 0); + + // + // Load the image to our new buffer + // + + Status = PeiEfiPeiPeCoffLoader->LoadImage (PeiEfiPeiPeCoffLoader, &ImageContext); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Relocate the image in our new buffer + // + Status = PeiEfiPeiPeCoffLoader->RelocateImage (PeiEfiPeiPeCoffLoader, &ImageContext); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Flush the instruction cache so the image data is written before we execute it + // + InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize); + + *ImageAddress = ImageContext.ImageAddress; + *ImageSize = ImageContext.ImageSize; + *EntryPoint = ImageContext.EntryPoint; + + return EFI_SUCCESS; +} + +EFI_STATUS +ShadowDxeIpl ( + IN EFI_FFS_FILE_HEADER *DxeIplFileHeader, + IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader + ) +/*++ + +Routine Description: + + Shadow the DXE IPL to a different memory location. This occurs after permanent + memory has been discovered. + +Arguments: + + DxeIplFileHeader - Pointer to the FFS file header of the DXE IPL driver + + PeiEfiPeiPeCoffLoader - Pointer to a PE COFF loader protocol + +Returns: + + EFI_SUCCESS - DXE IPL was successfully shadowed to a different memory location. + + EFI_ ERROR - The shadow was unsuccessful. + + +--*/ +{ + UINTN SectionLength; + UINTN OccupiedSectionLength; + EFI_PHYSICAL_ADDRESS DxeIplAddress; + UINT64 DxeIplSize; + EFI_PHYSICAL_ADDRESS DxeIplEntryPoint; + EFI_STATUS Status; + EFI_COMMON_SECTION_HEADER *Section; + + Section = (EFI_COMMON_SECTION_HEADER *) (DxeIplFileHeader + 1); + + while ((Section->Type != EFI_SECTION_PE32) && (Section->Type != EFI_SECTION_TE)) { + SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff; + OccupiedSectionLength = GetOccupiedSize (SectionLength, 4); + Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + OccupiedSectionLength); + } + + // + // Relocate DxeIpl into memory by using loadfile service + // + Status = PeiLoadx64File ( + PeiEfiPeiPeCoffLoader, + (VOID *) (Section + 1), + EfiBootServicesData, + &DxeIplAddress, + &DxeIplSize, + &DxeIplEntryPoint + ); + + if (Status == EFI_SUCCESS) { + // + // Install PeiInMemory to indicate the Dxeipl is shadowed + // + Status = PeiCoreInstallPpi (&mPpiPeiInMemory); + + if (EFI_ERROR (Status)) { + return Status; + } + + Status = ((EFI_PEIM_ENTRY_POINT) (UINTN) DxeIplEntryPoint) (DxeIplFileHeader, GetPeiServicesTablePointer()); + } + + return Status; +} + +EFI_STATUS +EFIAPI +DxeIplLoadFile ( + IN EFI_PEI_FV_FILE_LOADER_PPI *This, + IN EFI_FFS_FILE_HEADER *FfsHeader, + OUT EFI_PHYSICAL_ADDRESS *ImageAddress, + OUT UINT64 *ImageSize, + OUT EFI_PHYSICAL_ADDRESS *EntryPoint + ) +/*++ + +Routine Description: + + Given a pointer to an FFS file containing a PE32 image, get the + information on the PE32 image, and then "load" it so that it + can be executed. + +Arguments: + + This - pointer to our file loader protocol + FfsHeader - pointer to the FFS file header of the FFS file that + contains the PE32 image we want to load + ImageAddress - returned address where the PE32 image is loaded + ImageSize - returned size of the loaded PE32 image + EntryPoint - entry point to the loaded PE32 image + +Returns: + + EFI_SUCCESS - The FFS file was successfully loaded. + EFI_ERROR - Unable to load the FFS file. + +--*/ +{ + EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeiEfiPeiPeCoffLoader; + EFI_STATUS Status; + VOID *Pe32Data; + + Pe32Data = NULL; + PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol (); + + // + // Preprocess the FFS file to get a pointer to the PE32 information + // in the enclosed PE32 image. + // + Status = PeiProcessFile ( + EFI_SECTION_PE32, + FfsHeader, + &Pe32Data + ); + + if (EFI_ERROR (Status)) { + return Status; + } + // + // Load the PE image from the FFS file + // + Status = PeiLoadx64File ( + PeiEfiPeiPeCoffLoader, + Pe32Data, + EfiBootServicesData, + ImageAddress, + ImageSize, + EntryPoint + ); + + return Status; +} + +EFI_STATUS +PeiProcessFile ( + IN UINT16 SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + OUT VOID **Pe32Data + ) +/*++ + +Routine Description: + +Arguments: + + SectionType - The type of section in the FFS file to process. + + FfsFileHeader - Pointer to the FFS file to process, looking for the + specified SectionType + + Pe32Data - returned pointer to the start of the PE32 image found + in the FFS file. + +Returns: + + EFI_SUCCESS - found the PE32 section in the FFS file + +--*/ +{ + EFI_STATUS Status; + VOID *SectionData; + DECOMPRESS_LIBRARY *DecompressLibrary; + UINT8 *DstBuffer; + UINT8 *ScratchBuffer; + UINT32 DstBufferSize; + UINT32 ScratchBufferSize; + EFI_COMMON_SECTION_HEADER *CmpSection; + UINTN CmpSectionLength; + UINTN OccupiedCmpSectionLength; + VOID *CmpFileData; + UINTN CmpFileSize; + EFI_COMMON_SECTION_HEADER *Section; + UINTN SectionLength; + UINTN OccupiedSectionLength; + UINT64 FileSize; + EFI_GUID_DEFINED_SECTION *GuidedSectionHeader; + UINT32 AuthenticationStatus; + EFI_PEI_SECTION_EXTRACTION_PPI *SectionExtract; + UINT32 BufferSize; + UINT8 *Buffer; + EFI_PEI_SECURITY_PPI *Security; + BOOLEAN StartCrisisRecovery; + EFI_GUID TempGuid; + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + EFI_COMPRESSION_SECTION *CompressionSection; + + Status = PeiCoreFfsFindSectionData ( + EFI_SECTION_COMPRESSION, + FfsFileHeader, + &SectionData + ); + + // + // Upon finding a DXE Core file, see if there is first a compression section + // + if (!EFI_ERROR (Status)) { + // + // Yes, there is a compression section, so extract the contents + // Decompress the image here + // + Section = (EFI_COMMON_SECTION_HEADER *) (UINTN) (VOID *) ((UINT8 *) (FfsFileHeader) + (UINTN) sizeof (EFI_FFS_FILE_HEADER)); + + do { + SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff; + OccupiedSectionLength = GetOccupiedSize (SectionLength, 4); + + // + // Was the DXE Core file encapsulated in a GUID'd section? + // + if (Section->Type == EFI_SECTION_GUID_DEFINED) { + // + // Locate the GUID'd Section Extractor + // + GuidedSectionHeader = (VOID *) (Section + 1); + + // + // This following code constitutes the addition of the security model + // to the DXE IPL. + // + // + // Set a default authenticatino state + // + AuthenticationStatus = 0; + + Status = PeiCoreLocatePpi ( + &gEfiPeiSectionExtractionPpiGuid, + 0, + NULL, + (VOID **)&SectionExtract + ); + + if (EFI_ERROR (Status)) { + return Status; + } + // + // Verify Authentication State + // + CopyMem (&TempGuid, Section + 1, sizeof (EFI_GUID)); + + Status = SectionExtract->PeiGetSection ( + GetPeiServicesTablePointer(), + SectionExtract, + (EFI_SECTION_TYPE *) &SectionType, + &TempGuid, + 0, + (VOID **) &Buffer, + &BufferSize, + &AuthenticationStatus + ); + + if (EFI_ERROR (Status)) { + return Status; + } + // + // If not ask the Security PPI, if exists, for disposition + // + // + Status = PeiCoreLocatePpi ( + &gEfiPeiSecurityPpiGuid, + 0, + NULL, + (VOID **)&Security + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = Security->AuthenticationState ( + GetPeiServicesTablePointer(), + (struct _EFI_PEI_SECURITY_PPI *) Security, + AuthenticationStatus, + FfsFileHeader, + &StartCrisisRecovery + ); + + if (EFI_ERROR (Status)) { + return Status; + } + // + // If there is a security violation, report to caller and have + // the upper-level logic possible engender a crisis recovery + // + if (StartCrisisRecovery) { + return EFI_SECURITY_VIOLATION; + } + } + + if (Section->Type == EFI_SECTION_PE32) { + // + // This is what we want + // + *Pe32Data = (VOID *) (Section + 1); + return EFI_SUCCESS; + } else if (Section->Type == EFI_SECTION_COMPRESSION) { + // + // This is a compression set, expand it + // + CompressionSection = (EFI_COMPRESSION_SECTION *) Section; + + switch (CompressionSection->CompressionType) { + case EFI_STANDARD_COMPRESSION: + DecompressLibrary = &gTianoDecompress; + break; + + case EFI_CUSTOMIZED_COMPRESSION: + // + // Load user customized compression protocol. + // + DecompressLibrary = &gCustomDecompress; + break; + + case EFI_NOT_COMPRESSED: + default: + // + // Need to support not compressed file + // + ASSERT_EFI_ERROR (Status); + return EFI_NOT_FOUND; + } + + Status = DecompressLibrary->GetInfo ( + (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), + (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION), + &DstBufferSize, + &ScratchBufferSize + ); + if (EFI_ERROR (Status)) { + // + // GetInfo failed + // + return EFI_NOT_FOUND; + } + + // + // Allocate scratch buffer + // + ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize)); + if (ScratchBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Allocate destination buffer + // + DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize)); + if (DstBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Call decompress function + // + Status = DecompressLibrary->Decompress ( + (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), + DstBuffer, + ScratchBuffer + ); + + CmpSection = (EFI_COMMON_SECTION_HEADER *) DstBuffer; + if (CmpSection->Type == EFI_SECTION_RAW) { + // + // Skip the section header and + // adjust the pointer alignment to 16 + // + FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (DstBuffer + 16); + + if (FvHeader->Signature == EFI_FVH_SIGNATURE) { + FfsFileHeader = NULL; + BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader, FvHeader->FvLength); + Status = PeiCoreFfsFindNextFile ( + EFI_FV_FILETYPE_DXE_CORE, + FvHeader, + &FfsFileHeader + ); + + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + return PeiProcessFile (SectionType, FfsFileHeader, Pe32Data); + } + } + // + // Decompress successfully. + // Loop the decompressed data searching for expected section. + // + CmpFileData = (VOID *) DstBuffer; + CmpFileSize = DstBufferSize; + do { + CmpSectionLength = *(UINT32 *) (CmpSection->Size) & 0x00ffffff; + if (CmpSection->Type == EFI_SECTION_PE32) { + // + // This is what we want + // + *Pe32Data = (VOID *) (CmpSection + 1); + return EFI_SUCCESS; + } + + OccupiedCmpSectionLength = GetOccupiedSize (CmpSectionLength, 4); + CmpSection = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) CmpSection + OccupiedCmpSectionLength); + } while (CmpSection->Type != 0 && (UINTN) ((UINT8 *) CmpSection - (UINT8 *) CmpFileData) < CmpFileSize); + } + + Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + OccupiedSectionLength); + FileSize = FfsFileHeader->Size[0] & 0xFF; + FileSize += (FfsFileHeader->Size[1] << 8) & 0xFF00; + FileSize += (FfsFileHeader->Size[2] << 16) & 0xFF0000; + FileSize &= 0x00FFFFFF; + } while (Section->Type != 0 && (UINTN) ((UINT8 *) Section - (UINT8 *) FfsFileHeader) < FileSize); + + // + // End of the decompression activity + // + } else { + + Status = PeiCoreFfsFindSectionData ( + EFI_SECTION_PE32, + FfsFileHeader, + &SectionData + ); + + if (EFI_ERROR (Status)) { + Status = PeiCoreFfsFindSectionData ( + EFI_SECTION_TE, + FfsFileHeader, + &SectionData + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + } + + *Pe32Data = SectionData; + + return EFI_SUCCESS; } \ No newline at end of file diff --git a/EdkModulePkg/Core/DxeIplPeim/build.xml b/EdkModulePkg/Core/DxeIplPeim/build.xml index bb88e8a..158d088 100644 --- a/EdkModulePkg/Core/DxeIplPeim/build.xml +++ b/EdkModulePkg/Core/DxeIplPeim/build.xml @@ -1,47 +1,74 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EdkModulePkg/Core/DxeIplPeim/x64/LongMode.asm b/EdkModulePkg/Core/DxeIplPeim/x64/LongMode.asm index a9c4e77..ae87bd8 100644 --- a/EdkModulePkg/Core/DxeIplPeim/x64/LongMode.asm +++ b/EdkModulePkg/Core/DxeIplPeim/x64/LongMode.asm @@ -1,1357 +1,1350 @@ - TITLE LongMode.asm: Assembly code for the entering long mode - -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2006, Intel Corporation -;* All rights reserved. This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* LongMode.asm -;* -;* Abstract: -;* -;* Transition from 32-bit protected mode EFI environment into x64 -;* 64-bit bit long mode. -;* -;------------------------------------------------------------------------------ - -.686p -.model flat - -; -; Create the exception handler code in IA32 C code -; - -.code -.stack -.MMX -.XMM - -_LoadGo64Gdt PROC Near Public - push ebp ; C prolog - push edi - mov ebp, esp - ; - ; Disable interrupts - ; - cli - ; - ; Reload the selectors - ; Note: - ; Make the Selectors 64-bit ready - ; - mov edi, OFFSET gdtr ; Load GDT register - mov ax,cs ; Get the selector data from our code image - mov es,ax - lgdt FWORD PTR es:[edi] ; and update the GDTR - - db 067h - db 0eah ; Far Jump Offset:Selector to reload CS - dd OFFSET DataSelectorRld; Offset is ensuing instruction boundary - dw LINEAR_CODE_SEL ; Selector is our code selector, 10h -DataSelectorRld:: - mov ax, SYS_DATA_SEL ; Update the Base for the new selectors, too - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - - pop edi - pop ebp - ret -_LoadGo64Gdt endp - - -; VOID -; ActivateLongMode ( -; IN EFI_PHYSICAL_ADDRESS PageTables, -; IN EFI_PHYSICAL_ADDRESS HobStart, -; IN EFI_PHYSICAL_ADDRESS Stack, -; IN EFI_PHYSICAL_ADDRESS PpisNeededByDxeIplEntryPoint, -; IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint -; ) -; -; Input: [ebp][0h] = Original ebp -; [ebp][4h] = Return address -; [ebp][8h] = PageTables -; [ebp][10h] = HobStart -; [ebp][18h] = Stack -; [ebp][20h] = CodeEntryPoint1 <--- Call this first (for each call, pass HOB pointer) -; [ebp][28h] = CodeEntryPoint2 <--- Call this second -; -; -_ActivateLongMode PROC Near Public - push ebp ; C prolog - mov ebp, esp - - ; - ; Use CPUID to determine if the processor supports long mode. - ; - mov eax, 80000000h ; Extended-function code 8000000h. - cpuid ; Is largest extended function - cmp eax, 80000000h ; any function > 80000000h? - jbe no_long_mode ; If not, no long mode. - mov eax, 80000001h ; Extended-function code 8000001h. - cpuid ; Now EDX = extended-features flags. - bt edx, 29 ; Test if long mode is supported. - jnc no_long_mode ; Exit if not supported. - - ; - ; Enable the 64-bit page-translation-table entries by - ; setting CR4.PAE=1 (this is _required_ before activating - ; long mode). Paging is not enabled until after long mode - ; is enabled. - ; - mov eax, cr4 - bts eax, 5 - mov cr4, eax - - ; - ; Get the long-mode page tables, and initialize the - ; 64-bit CR3 (page-table base address) to point to the base - ; of the PML4 page table. The PML4 page table must be located - ; below 4 Gbytes because only 32 bits of CR3 are loaded when - ; the processor is not in 64-bit mode. - ; - mov eax, [ebp+8h] ; Get Page Tables - mov cr3, eax ; Initialize CR3 with PML4 base. - - ; - ; Enable long mode (set EFER.LME=1). - ; - mov ecx, 0c0000080h ; EFER MSR number. - rdmsr ; Read EFER. - bts eax, 8 ; Set LME=1. - wrmsr ; Write EFER. - - ; - ; Enable paging to activate long mode (set CR0.PG=1) - ; - - - mov eax, cr0 ; Read CR0. - bts eax, 31 ; Set PG=1. - mov cr0, eax ; Write CR0. - jmp go_to_long_mode -go_to_long_mode: - - ; - ; This is the next instruction after enabling paging. Jump to long mode - ; - db 067h - db 0eah ; Far Jump Offset:Selector to reload CS - dd OFFSET in_long_mode; Offset is ensuing instruction boundary - dw SYS_CODE64_SEL ; Selector is our code selector, 10h -in_long_mode:: - mov ax, SYS_DATA64_SEL - mov es, ax - mov ss, ax - mov ds, ax -;; jmp $ - - - ; - ; We're in long mode, so marshall the arguments to call the - ; passed in function pointers - ; Recall - ; [ebp][10h] = HobStart - ; [ebp][18h] = Stack - ; [ebp][20h] = PpisNeededByDxeIplEntryPoint <--- Call this first (for each call, pass HOB pointer) - ; [ebp][28h] = DxeCoreEntryPoint <--- Call this second - ; - db 48h - mov ebx, [ebp+18h] ; Setup the stack - db 48h - mov esp, ebx ; On a new stack now - - db 48h - mov ecx, [ebp+10h] ; Pass Hob Start in RCX - db 48h - mov eax, [ebp+20h] ; Get the function pointer for - ; PpisNeededByDxeIplEntryPoint into EAX - -;; 00000905 FF D0 call rax - db 0ffh - db 0d0h - - db 48h - mov ecx, [ebp+10h] ; Pass Hob Start in RCX - db 48h - mov eax, [ebp+28h] ; Get the function pointer for - ; DxeCoreEntryPoint into EAX - -;; 00000905 FF D0 call rax - db 0ffh - db 0d0h - - ; - ; WE SHOULD NEVER GET HERE!!!!!!!!!!!!! - ; -no_long_mode: - jmp no_long_mode -_ActivateLongMode endp - - align 16 - -gdtr dw GDT_END - GDT_BASE - 1 ; GDT limit - dd OFFSET GDT_BASE ; (GDT base gets set above) - -;-----------------------------------------------------------------------------; -; global descriptor table (GDT) -;-----------------------------------------------------------------------------; - - align 16 - -public GDT_BASE -GDT_BASE: -; null descriptor -NULL_SEL equ $-GDT_BASE ; Selector [0] - dw 0 ; limit 15:0 - dw 0 ; base 15:0 - db 0 ; base 23:16 - db 0 ; type - db 0 ; limit 19:16, flags - db 0 ; base 31:24 - -; linear data segment descriptor -LINEAR_SEL equ $-GDT_BASE ; Selector [0x8] - dw 0FFFFh ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 092h ; present, ring 0, data, expand-up, writable - db 0CFh ; page-granular, 32-bit - db 0 - -; linear code segment descriptor -LINEAR_CODE_SEL equ $-GDT_BASE ; Selector [0x10] - dw 0FFFFh ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 09Fh ; present, ring 0, data, expand-up, writable - db 0CFh ; page-granular, 32-bit - db 0 - -; system data segment descriptor -SYS_DATA_SEL equ $-GDT_BASE ; Selector [0x18] - dw 0FFFFh ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 093h ; present, ring 0, data, expand-up, writable - db 0CFh ; page-granular, 32-bit - db 0 - -; system code segment descriptor -SYS_CODE_SEL equ $-GDT_BASE ; Selector [0x20] - dw 0FFFFh ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 09Ah ; present, ring 0, data, expand-up, writable - db 0CFh ; page-granular, 32-bit - db 0 - -; spare segment descriptor -SPARE3_SEL equ $-GDT_BASE ; Selector [0x28] - dw 0 ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 0 ; present, ring 0, data, expand-up, writable - db 0 ; page-granular, 32-bit - db 0 - -; -; system data segment descriptor -; -SYS_DATA64_SEL equ $-GDT_BASE ; Selector [0x30] - dw 0FFFFh ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 092h ; P | DPL [1..2] | 1 | 1 | C | R | A - db 0CFh ; G | D | L | AVL | Segment [19..16] - db 0 - -; -; system code segment descriptor -; -SYS_CODE64_SEL equ $-GDT_BASE ; Selector [0x38] - dw 0FFFFh ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 09Ah ; P | DPL [1..2] | 1 | 1 | C | R | A - db 0AFh ; G | D | L | AVL | Segment [19..16] - db 0 - -; spare segment descriptor -SPARE4_SEL equ $-GDT_BASE ; Selector [0x40] - dw 0 ; limit 0xFFFFF - dw 0 ; base 0 - db 0 - db 0 ; present, ring 0, data, expand-up, writable - db 0 ; page-granular, 32-bit - db 0 - -GDT_END: - -; -; -;------------------------------------------------------------------------------ -; Generic IDT Vector Handlers for the Host. They are all the same so they -; will compress really well. -; -; By knowing the return address for Vector 00 you can can calculate the -; vector number by looking at the call CommonInterruptEntry return address. -; (return address - AsmIdtVector00Base)/8 == IDT index -; -;------------------------------------------------------------------------------ - -_AsmIdtVector00 PROC NEAR PUBLIC - call CommonInterruptEntry -_AsmIdtVector00 ENDP -AsmIdtVector00Base PROC NEAR PUBLIC - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop - call CommonInterruptEntry - nop - nop - nop -AsmIdtVector00Base ENDP - - -;---------------------------------------; -; CommonInterruptEntry ; -;---------------------------------------; -; The follow algorithm is used for the common interrupt routine. -; TBD: Save EFI_SYSTEM_CONTEXT_x64 on the stack per AP definition -; -; -CommonInterruptEntry PROC NEAR PUBLIC - cli - jmp $ - iret - -CommonInterruptEntry ENDP - -END - + TITLE LongMode.asm: Assembly code for the entering long mode + +;------------------------------------------------------------------------------ +;* +;* Copyright (c) 2006, Intel Corporation +;* All rights reserved. This program and the accompanying materials +;* are licensed and made available under the terms and conditions of the BSD License +;* which accompanies this distribution. The full text of the license may be found at +;* http://opensource.org/licenses/bsd-license.php +;* +;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +;* +;* LongMode.asm +;* +;* Abstract: +;* +;* Transition from 32-bit protected mode EFI environment into x64 +;* 64-bit bit long mode. +;* +;------------------------------------------------------------------------------ + +.686p +.model flat + +; +; Create the exception handler code in IA32 C code +; + +.code +.stack +.MMX +.XMM + +_LoadGo64Gdt PROC Near Public + push ebp ; C prolog + push edi + mov ebp, esp + ; + ; Disable interrupts + ; + cli + ; + ; Reload the selectors + ; Note: + ; Make the Selectors 64-bit ready + ; + mov edi, OFFSET gdtr ; Load GDT register + mov ax,cs ; Get the selector data from our code image + mov es,ax + lgdt FWORD PTR es:[edi] ; and update the GDTR + + db 067h + db 0eah ; Far Jump Offset:Selector to reload CS + dd OFFSET DataSelectorRld; Offset is ensuing instruction boundary + dw LINEAR_CODE_SEL ; Selector is our code selector, 10h +DataSelectorRld:: + mov ax, SYS_DATA_SEL ; Update the Base for the new selectors, too + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + + pop edi + pop ebp + ret +_LoadGo64Gdt endp + + +; VOID +; ActivateLongMode ( +; IN EFI_PHYSICAL_ADDRESS PageTables, +; IN EFI_PHYSICAL_ADDRESS HobStart, +; IN EFI_PHYSICAL_ADDRESS Stack, +; IN EFI_PHYSICAL_ADDRESS PpisNeededByDxeIplEntryPoint, +; IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint +; ) +; +; Input: [ebp][0h] = Original ebp +; [ebp][4h] = Return address +; [ebp][8h] = PageTables +; [ebp][10h] = HobStart +; [ebp][18h] = Stack +; [ebp][20h] = CodeEntryPoint1 <--- Call this first (for each call, pass HOB pointer) +; [ebp][28h] = CodeEntryPoint2 <--- Call this second +; +; +_ActivateLongMode PROC Near Public + push ebp ; C prolog + mov ebp, esp + + ; + ; Use CPUID to determine if the processor supports long mode. + ; + mov eax, 80000000h ; Extended-function code 8000000h. + cpuid ; Is largest extended function + cmp eax, 80000000h ; any function > 80000000h? + jbe no_long_mode ; If not, no long mode. + mov eax, 80000001h ; Extended-function code 8000001h. + cpuid ; Now EDX = extended-features flags. + bt edx, 29 ; Test if long mode is supported. + jnc no_long_mode ; Exit if not supported. + + ; + ; Enable the 64-bit page-translation-table entries by + ; setting CR4.PAE=1 (this is _required_ before activating + ; long mode). Paging is not enabled until after long mode + ; is enabled. + ; + mov eax, cr4 + bts eax, 5 + mov cr4, eax + + ; + ; Get the long-mode page tables, and initialize the + ; 64-bit CR3 (page-table base address) to point to the base + ; of the PML4 page table. The PML4 page table must be located + ; below 4 Gbytes because only 32 bits of CR3 are loaded when + ; the processor is not in 64-bit mode. + ; + mov eax, [ebp+8h] ; Get Page Tables + mov cr3, eax ; Initialize CR3 with PML4 base. + + ; + ; Enable long mode (set EFER.LME=1). + ; + mov ecx, 0c0000080h ; EFER MSR number. + rdmsr ; Read EFER. + bts eax, 8 ; Set LME=1. + wrmsr ; Write EFER. + + ; + ; Enable paging to activate long mode (set CR0.PG=1) + ; + + + mov eax, cr0 ; Read CR0. + bts eax, 31 ; Set PG=1. + mov cr0, eax ; Write CR0. + jmp go_to_long_mode +go_to_long_mode: + + ; + ; This is the next instruction after enabling paging. Jump to long mode + ; + db 067h + db 0eah ; Far Jump Offset:Selector to reload CS + dd OFFSET in_long_mode; Offset is ensuing instruction boundary + dw SYS_CODE64_SEL ; Selector is our code selector, 10h +in_long_mode:: + mov ax, SYS_DATA64_SEL + mov es, ax + mov ss, ax + mov ds, ax +;; jmp $ + + + ; + ; We're in long mode, so marshall the arguments to call the + ; passed in function pointers + ; Recall + ; [ebp][10h] = HobStart + ; [ebp][18h] = Stack + ; [ebp][20h] = PpisNeededByDxeIplEntryPoint <--- Call this first (for each call, pass HOB pointer) + ; [ebp][28h] = DxeCoreEntryPoint <--- Call this second + ; + db 48h + mov ebx, [ebp+18h] ; Setup the stack + db 48h + mov esp, ebx ; On a new stack now + + +;; 00000905 FF D0 call rax + + db 48h + mov ecx, [ebp+10h] ; Pass Hob Start in RCX + db 48h + mov eax, [ebp+28h] ; Get the function pointer for + ; DxeCoreEntryPoint into EAX + +;; 00000905 FF D0 call rax + db 0ffh + db 0d0h + + ; + ; WE SHOULD NEVER GET HERE!!!!!!!!!!!!! + ; +no_long_mode: + jmp no_long_mode +_ActivateLongMode endp + + align 16 + +gdtr dw GDT_END - GDT_BASE - 1 ; GDT limit + dd OFFSET GDT_BASE ; (GDT base gets set above) + +;-----------------------------------------------------------------------------; +; global descriptor table (GDT) +;-----------------------------------------------------------------------------; + + align 16 + +public GDT_BASE +GDT_BASE: +; null descriptor +NULL_SEL equ $-GDT_BASE ; Selector [0] + dw 0 ; limit 15:0 + dw 0 ; base 15:0 + db 0 ; base 23:16 + db 0 ; type + db 0 ; limit 19:16, flags + db 0 ; base 31:24 + +; linear data segment descriptor +LINEAR_SEL equ $-GDT_BASE ; Selector [0x8] + dw 0FFFFh ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 092h ; present, ring 0, data, expand-up, writable + db 0CFh ; page-granular, 32-bit + db 0 + +; linear code segment descriptor +LINEAR_CODE_SEL equ $-GDT_BASE ; Selector [0x10] + dw 0FFFFh ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 09Fh ; present, ring 0, data, expand-up, writable + db 0CFh ; page-granular, 32-bit + db 0 + +; system data segment descriptor +SYS_DATA_SEL equ $-GDT_BASE ; Selector [0x18] + dw 0FFFFh ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 093h ; present, ring 0, data, expand-up, writable + db 0CFh ; page-granular, 32-bit + db 0 + +; system code segment descriptor +SYS_CODE_SEL equ $-GDT_BASE ; Selector [0x20] + dw 0FFFFh ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 09Ah ; present, ring 0, data, expand-up, writable + db 0CFh ; page-granular, 32-bit + db 0 + +; spare segment descriptor +SPARE3_SEL equ $-GDT_BASE ; Selector [0x28] + dw 0 ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 0 ; present, ring 0, data, expand-up, writable + db 0 ; page-granular, 32-bit + db 0 + +; +; system data segment descriptor +; +SYS_DATA64_SEL equ $-GDT_BASE ; Selector [0x30] + dw 0FFFFh ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 092h ; P | DPL [1..2] | 1 | 1 | C | R | A + db 0CFh ; G | D | L | AVL | Segment [19..16] + db 0 + +; +; system code segment descriptor +; +SYS_CODE64_SEL equ $-GDT_BASE ; Selector [0x38] + dw 0FFFFh ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 09Ah ; P | DPL [1..2] | 1 | 1 | C | R | A + db 0AFh ; G | D | L | AVL | Segment [19..16] + db 0 + +; spare segment descriptor +SPARE4_SEL equ $-GDT_BASE ; Selector [0x40] + dw 0 ; limit 0xFFFFF + dw 0 ; base 0 + db 0 + db 0 ; present, ring 0, data, expand-up, writable + db 0 ; page-granular, 32-bit + db 0 + +GDT_END: + +; +; +;------------------------------------------------------------------------------ +; Generic IDT Vector Handlers for the Host. They are all the same so they +; will compress really well. +; +; By knowing the return address for Vector 00 you can can calculate the +; vector number by looking at the call CommonInterruptEntry return address. +; (return address - AsmIdtVector00Base)/8 == IDT index +; +;------------------------------------------------------------------------------ + +_AsmIdtVector00 PROC NEAR PUBLIC + call CommonInterruptEntry +_AsmIdtVector00 ENDP +AsmIdtVector00Base PROC NEAR PUBLIC + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop + call CommonInterruptEntry + nop + nop + nop +AsmIdtVector00Base ENDP + + +;---------------------------------------; +; CommonInterruptEntry ; +;---------------------------------------; +; The follow algorithm is used for the common interrupt routine. +; TBD: Save EFI_SYSTEM_CONTEXT_x64 on the stack per AP definition +; +; +CommonInterruptEntry PROC NEAR PUBLIC + cli + jmp $ + iret + +CommonInterruptEntry ENDP + +END + diff --git a/EdkModulePkg/Core/Pei/Image/Image.c b/EdkModulePkg/Core/Pei/Image/Image.c index 74286cf..4c1fcf6 100644 --- a/EdkModulePkg/Core/Pei/Image/Image.c +++ b/EdkModulePkg/Core/Pei/Image/Image.c @@ -1,237 +1,243 @@ -/*++ - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Image.c - -Abstract: - - Pei Core Load Image Support - ---*/ - -#include - -EFI_STATUS -PeiLoadImage ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_FFS_FILE_HEADER *PeimFileHeader, - OUT VOID **EntryPoint - ) -/*++ - -Routine Description: - - Routine for loading file image. - -Arguments: - - PeiServices - The PEI core services table. - PeimFileHeader - Pointer to the FFS file header of the image. - EntryPoint - Pointer to entry point of specified image file for output. - -Returns: - - Status - EFI_SUCCESS - Image is successfully loaded. - EFI_NOT_FOUND - Fail to locate necessary PPI - Others - Fail to load file. - ---*/ -{ - EFI_STATUS Status; - VOID *Pe32Data; - EFI_PEI_FV_FILE_LOADER_PPI *FvLoadFilePpi; -//#ifdef EFI_NT_EMULATOR -// EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; -// NT_PEI_LOAD_FILE_PPI *PeiNtService; -//#endif - EFI_PHYSICAL_ADDRESS ImageAddress; - UINT64 ImageSize; - EFI_PHYSICAL_ADDRESS ImageEntryPoint; - EFI_TE_IMAGE_HEADER *TEImageHeader; - - *EntryPoint = NULL; - TEImageHeader = NULL; - - // - // Try to find a PE32 section. - // - Status = PeiCoreFfsFindSectionData ( - EFI_SECTION_PE32, - PeimFileHeader, - &Pe32Data - ); - // - // If we didn't find a PE32 section, try to find a TE section. - // - if (EFI_ERROR (Status)) { - Status = PeiCoreFfsFindSectionData ( - EFI_SECTION_TE, - PeimFileHeader, - (VOID **) &TEImageHeader - ); - if (EFI_ERROR (Status) || TEImageHeader == NULL) { - // - // There was not a PE32 or a TE section, so assume that it's a Compressed section - // and use the LoadFile - // - Status = PeiCoreLocatePpi ( - &gEfiPeiFvFileLoaderPpiGuid, - 0, - NULL, - (VOID **)&FvLoadFilePpi - ); - if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; - } - - Status = FvLoadFilePpi->FvLoadFile ( - FvLoadFilePpi, - PeimFileHeader, - &ImageAddress, - &ImageSize, - &ImageEntryPoint - ); - - if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; - } - - // - // Retrieve the entry point from the PE/COFF image header - // - Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)ImageAddress, EntryPoint); - if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; - } - } else { - // - // Retrieve the entry point from the TE image header - // - ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) TEImageHeader; - *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) + - TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize); - } - } else { - // - // Retrieve the entry point from the PE/COFF image header - // - ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Pe32Data; - Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint); - if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; - } - } - - // - // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi - // - DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%08x EntryPoint=0x%08x ", Pe32Data, *EntryPoint)); - DEBUG_CODE ( - EFI_IMAGE_DATA_DIRECTORY * DirectoryEntry; - EFI_IMAGE_DEBUG_DIRECTORY_ENTRY * DebugEntry; - UINTN DirCount; - UINTN Index; - UINTN Index1; - BOOLEAN FileNameFound; - CHAR8 *AsciiString; - CHAR8 AsciiBuffer[512]; - VOID *CodeViewEntryPointer; - INTN TEImageAdjust; - EFI_IMAGE_DOS_HEADER *DosHeader; - EFI_IMAGE_NT_HEADERS *PeHeader; - - DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; - if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // DOS image header is present, so read the PE header after the DOS image header - // - PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); - } else { - // - // DOS image header is not present, so PE header is at the image base - // - PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data; - } - - // - // Find the codeview info in the image and display the file name - // being loaded. - // - // Per the PE/COFF spec, you can't assume that a given data directory - // is present in the image. You have to check the NumberOfRvaAndSizes in - // the optional header to verify a desired directory entry is there. - // - DebugEntry = NULL; - DirectoryEntry = NULL; - TEImageAdjust = 0; - if (TEImageHeader == NULL) { - if (PeHeader->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { - DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHeader->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); - DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) ImageAddress + DirectoryEntry->VirtualAddress); - } - } else { - if (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) { - DirectoryEntry = &TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG]; - TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize; - DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) TEImageHeader + - TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress + - TEImageAdjust); - } - } - - if (DebugEntry != NULL && DirectoryEntry != NULL) { - for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) { - if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { - if (DebugEntry->SizeOfData > 0) { - CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageAddress + (UINTN)TEImageAdjust); - switch (* (UINT32 *) CodeViewEntryPointer) { - case CODEVIEW_SIGNATURE_NB10: - AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); - break; - - case CODEVIEW_SIGNATURE_RSDS: - AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); - break; - - default: - AsciiString = NULL; - break; - } - if (AsciiString != NULL) { - FileNameFound = FALSE; - for (Index = 0, Index1 = 0; AsciiString[Index] != 0; Index++) { - if (AsciiString[Index] == '\\') { - Index1 = Index; - FileNameFound = TRUE; - } - } - - if (FileNameFound) { - for (Index = Index1 + 1; AsciiString[Index] != '.'; Index++) { - AsciiBuffer[Index - (Index1 + 1)] = AsciiString[Index]; - } - AsciiBuffer[Index - (Index1 + 1)] = 0; - DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer)); - break; - } - } - } - } - } - } - ); - - DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n")); - - return EFI_SUCCESS; -} +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Image.c + +Abstract: + + Pei Core Load Image Support + +--*/ + +#include + +EFI_STATUS +PeiLoadImage ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_FFS_FILE_HEADER *PeimFileHeader, + OUT VOID **EntryPoint + ) +/*++ + +Routine Description: + + Routine for loading file image. + +Arguments: + + PeiServices - The PEI core services table. + PeimFileHeader - Pointer to the FFS file header of the image. + EntryPoint - Pointer to entry point of specified image file for output. + +Returns: + + Status - EFI_SUCCESS - Image is successfully loaded. + EFI_NOT_FOUND - Fail to locate necessary PPI + Others - Fail to load file. + +--*/ +{ + EFI_STATUS Status; + VOID *Pe32Data; + EFI_PEI_FV_FILE_LOADER_PPI *FvLoadFilePpi; +//#ifdef EFI_NT_EMULATOR +// EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; +// NT_PEI_LOAD_FILE_PPI *PeiNtService; +//#endif + EFI_PHYSICAL_ADDRESS ImageAddress; + UINT64 ImageSize; + EFI_PHYSICAL_ADDRESS ImageEntryPoint; + EFI_TE_IMAGE_HEADER *TEImageHeader; + + *EntryPoint = NULL; + TEImageHeader = NULL; + + // + // Try to find a PE32 section. + // + Status = PeiCoreFfsFindSectionData ( + EFI_SECTION_PE32, + PeimFileHeader, + &Pe32Data + ); + // + // If we didn't find a PE32 section, try to find a TE section. + // + if (EFI_ERROR (Status)) { + Status = PeiCoreFfsFindSectionData ( + EFI_SECTION_TE, + PeimFileHeader, + (VOID **) &TEImageHeader + ); + if (EFI_ERROR (Status) || TEImageHeader == NULL) { + // + // There was not a PE32 or a TE section, so assume that it's a Compressed section + // and use the LoadFile + // + Status = PeiCoreLocatePpi ( + &gEfiPeiFvFileLoaderPpiGuid, + 0, + NULL, + (VOID **)&FvLoadFilePpi + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + Status = FvLoadFilePpi->FvLoadFile ( + FvLoadFilePpi, + PeimFileHeader, + &ImageAddress, + &ImageSize, + &ImageEntryPoint + ); + + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + // + // Retrieve the entry point from the PE/COFF image header + // + Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)ImageAddress, EntryPoint); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + } else { + // + // Retrieve the entry point from the TE image header + // + ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) TEImageHeader; + *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) + + TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize); + } + } else { + // + // Retrieve the entry point from the PE/COFF image header + // + ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Pe32Data; + Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + } + + // + // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi + // + DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%08x EntryPoint=0x%08x ", Pe32Data, *EntryPoint)); + DEBUG_CODE ( + EFI_IMAGE_DATA_DIRECTORY * DirectoryEntry; + EFI_IMAGE_DEBUG_DIRECTORY_ENTRY * DebugEntry; + UINTN DirCount; + UINTN Index; + UINTN Index1; + BOOLEAN FileNameFound; + CHAR8 *AsciiString; + CHAR8 AsciiBuffer[512]; + VOID *CodeViewEntryPointer; + INTN TEImageAdjust; + EFI_IMAGE_DOS_HEADER *DosHeader; + EFI_IMAGE_NT_HEADERS *PeHeader; + + // + // Pe32Data is NULL when load TE image + // + PeHeader = NULL; + if (TEImageHeader == NULL) { + DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data; + if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + // + // DOS image header is present, so read the PE header after the DOS image header + // + PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff)); + } else { + // + // DOS image header is not present, so PE header is at the image base + // + PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data; + } + } + + // + // Find the codeview info in the image and display the file name + // being loaded. + // + // Per the PE/COFF spec, you can't assume that a given data directory + // is present in the image. You have to check the NumberOfRvaAndSizes in + // the optional header to verify a desired directory entry is there. + // + DebugEntry = NULL; + DirectoryEntry = NULL; + TEImageAdjust = 0; + if (TEImageHeader == NULL) { + if (PeHeader->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) { + DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHeader->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) ImageAddress + DirectoryEntry->VirtualAddress); + } + } else { + if (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) { + DirectoryEntry = &TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG]; + TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize; + DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) TEImageHeader + + TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress + + TEImageAdjust); + } + } + + if (DebugEntry != NULL && DirectoryEntry != NULL) { + for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) { + if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) { + if (DebugEntry->SizeOfData > 0) { + CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageAddress + (UINTN)TEImageAdjust); + switch (* (UINT32 *) CodeViewEntryPointer) { + case CODEVIEW_SIGNATURE_NB10: + AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY); + break; + + case CODEVIEW_SIGNATURE_RSDS: + AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY); + break; + + default: + AsciiString = NULL; + break; + } + if (AsciiString != NULL) { + FileNameFound = FALSE; + for (Index = 0, Index1 = 0; AsciiString[Index] != 0; Index++) { + if (AsciiString[Index] == '\\') { + Index1 = Index; + FileNameFound = TRUE; + } + } + + if (FileNameFound) { + for (Index = Index1 + 1; AsciiString[Index] != '.'; Index++) { + AsciiBuffer[Index - (Index1 + 1)] = AsciiString[Index]; + } + AsciiBuffer[Index - (Index1 + 1)] = 0; + DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer)); + break; + } + } + } + } + } + } + ); + + DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n")); + + return EFI_SUCCESS; +} diff --git a/EdkModulePkg/Core/Pei/PeiMain.mbd b/EdkModulePkg/Core/Pei/PeiMain.mbd index c9d64e3..145a544 100644 --- a/EdkModulePkg/Core/Pei/PeiMain.mbd +++ b/EdkModulePkg/Core/Pei/PeiMain.mbd @@ -1,53 +1,53 @@ - - - - - PeiMain - 52C05B14-0B98-496c-BC3B-04B50211D680 - 0 - FIX ME! - Copyright (c) 2004-2006, Intel Corporation - - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - 2006-03-12 17:09 - 2006-03-19 15:18 - - - PeiCoreEntryPoint - BaseLib - BaseMemoryLib - PeiServicesTablePointerLib - PeiCoreLib - PeiHobLib - PeiReportStatusCodeLib - BaseDebugLibReportStatusCode - BasePerformanceLibNull - - BasePeCoffGetEntryPointLib - - - BasePeCoffGetEntryPointLib - - - BasePeCoffGetEntryPointLib - - - BasePeCoffGetEntryPointLib - - - + + + + + PeiMain + 52C05B14-0B98-496c-BC3B-04B50211D680 + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-12 17:09 + 2006-03-19 15:18 + + + PeiCoreEntryPoint + BaseLib + BaseMemoryLib + PeiServicesTablePointerLib + PeiCoreLib + PeiHobLib + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BasePerformanceLibNull + + BasePeCoffGetEntryPointLib + + + BasePeCoffGetEntryPointLib + + + BasePeCoffGetEntryPointLib + + + BasePeCoffGetEntryPointLib + + + diff --git a/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c b/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c index 014c571..a7ae320 100644 --- a/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -1,243 +1,242 @@ -/*++ - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - PeiMain.c - -Abstract: - - Pei Core Main Entry Point - -Revision History - ---*/ - -#include - -// -//CAR is filled with this initial value during SEC phase -// -#define INIT_CAR_VALUE 0x5AA55AA5 - -static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiMemoryDiscoveredPpiGuid, - NULL -}; - -// -// Pei Core Module Variables -// -// -static EFI_PEI_SERVICES mPS = { - { - PEI_SERVICES_SIGNATURE, - PEI_SERVICES_REVISION, - sizeof (EFI_PEI_SERVICES), - 0, - 0 - }, - PeiInstallPpi, - PeiReInstallPpi, - PeiLocatePpi, - PeiNotifyPpi, - - PeiGetBootMode, - PeiSetBootMode, - - PeiGetHobList, - PeiCreateHob, - - PeiFvFindNextVolume, - PeiFfsFindNextFile, - PeiFfsFindSectionData, - - PeiInstallPeiMemory, - PeiAllocatePages, - PeiAllocatePool, - (EFI_PEI_COPY_MEM)CopyMem, - (EFI_PEI_SET_MEM)SetMem, - - PeiReportStatusCode, - - PeiResetSystem -}; - -EFI_STATUS -EFIAPI -PeiCore ( - IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor, - IN PEI_CORE_INSTANCE *OldCoreData - ) -/*++ - -Routine Description: - - The entry routine to Pei Core, invoked by PeiMain during transition - from SEC to PEI. After switching stack in the PEI core, it will restart - with the old core data. - -Arguments: - - PeiStartupDescriptor - Information and services provided by SEC phase. - OldCoreData - Pointer to old core data that is used to initialize the - core's data areas. - -Returns: - - This function never returns - EFI_NOT_FOUND - Never reach - ---*/ -{ - PEI_CORE_INSTANCE PrivateData; - EFI_STATUS Status; - PEI_CORE_TEMP_POINTERS TempPtr; - PEI_CORE_DISPATCH_DATA *DispatchData; - UINT64 mTick; - - mTick = 0; - -#ifdef EFI_PEI_PERFORMANCE - if (OldCoreData == NULL) { - mTick = GetPerformanceCounter (); - } -#endif - - - // - // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory() - // the 63-bit of address is set to 1. - // - SWITCH_TO_CACHE_MODE (OldCoreData); - - if (OldCoreData != NULL) { - CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE)); - } else { - ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE)); - } - - PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE; - PrivateData.PS = &mPS; - - // - // Initialize libraries that the PeiCore is linked against - // BUGBUG: The FfsHeader is passed in as NULL. Do we look it up or remove it from the lib init? - // - ProcessLibraryConstructorList (NULL, &PrivateData.PS); - - InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData); - - InitializePpiServices (&PrivateData.PS, OldCoreData); - - InitializeSecurityServices (&PrivateData.PS, OldCoreData); - - InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor); - - if (OldCoreData != NULL) { - - PERF_END (NULL,"PreMem", NULL, 0); - PERF_START (NULL,"PostMem", NULL, 0); - - // - // The following code dumps out interesting cache as RAM usage information - // so we can keep tabs on how the cache as RAM is being utilized. The - // DEBUG_CODE macro is used to prevent this code from being compiled - // on a debug build. - // - DEBUG_CODE ( - UINTN *StackPointer; - UINTN StackValue; - - StackValue = INIT_CAR_VALUE; - for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap; - ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam)) - && StackValue == INIT_CAR_VALUE; - StackPointer++) { - StackValue = *StackPointer; - } - - DEBUG ((EFI_D_INFO, "Total Cache as RAM: %d bytes.\n", OldCoreData->SizeOfCacheAsRam)); - DEBUG ((EFI_D_INFO, " CAR stack ever used: %d bytes.\n", - ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer) - )); - DEBUG ((EFI_D_INFO, " CAR heap used: %d bytes.\n", - ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom - - (UINTN) OldCoreData->HobList.Raw) - )); - ); - - // - // Alert any listeners that there is permanent memory available - // - PERF_START (NULL,"DisMem", NULL, 0); - Status = PeiCoreInstallPpi (&mMemoryDiscoveredPpi); - PERF_END (NULL,"DisMem", NULL, 0); - - } else { - - // - // Report Status Code EFI_SW_PC_INIT - // - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT - ); - - // - // If first pass, start performance measurement. - // - PERF_START (NULL,"PreMem", NULL, mTick); - - // - // If SEC provided any PPI services to PEI, install them. - // - if (PeiStartupDescriptor->DispatchTable != NULL) { - Status = PeiCoreInstallPpi (PeiStartupDescriptor->DispatchTable); - ASSERT_EFI_ERROR (Status); - } - } - - DispatchData = &PrivateData.DispatchData; - - // - // Call PEIM dispatcher - // - PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData); - - // - // Check if InstallPeiMemory service was called. - // - ASSERT(PrivateData.PeiMemoryInstalled == TRUE); - - PERF_END (NULL, "PostMem", NULL, 0); - - Status = PeiCoreLocatePpi ( - &gEfiDxeIplPpiGuid, - 0, - NULL, - (VOID **)&TempPtr.DxeIpl - ); - ASSERT_EFI_ERROR (Status); - - DEBUG ((EFI_D_INFO, "DXE IPL Entry\n")); - Status = TempPtr.DxeIpl->Entry ( - TempPtr.DxeIpl, - &PrivateData.PS, - PrivateData.HobList - ); - - ASSERT_EFI_ERROR (Status); - - return EFI_NOT_FOUND; -} - +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PeiMain.c + +Abstract: + + Pei Core Main Entry Point + +Revision History + +--*/ + +#include + +// +//CAR is filled with this initial value during SEC phase +// +#define INIT_CAR_VALUE 0x5AA55AA5 + +static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiMemoryDiscoveredPpiGuid, + NULL +}; + +// +// Pei Core Module Variables +// +// +static EFI_PEI_SERVICES mPS = { + { + PEI_SERVICES_SIGNATURE, + PEI_SERVICES_REVISION, + sizeof (EFI_PEI_SERVICES), + 0, + 0 + }, + PeiInstallPpi, + PeiReInstallPpi, + PeiLocatePpi, + PeiNotifyPpi, + + PeiGetBootMode, + PeiSetBootMode, + + PeiGetHobList, + PeiCreateHob, + + PeiFvFindNextVolume, + PeiFfsFindNextFile, + PeiFfsFindSectionData, + + PeiInstallPeiMemory, + PeiAllocatePages, + PeiAllocatePool, + (EFI_PEI_COPY_MEM)CopyMem, + (EFI_PEI_SET_MEM)SetMem, + + PeiReportStatusCode, + + PeiResetSystem +}; + +EFI_STATUS +EFIAPI +PeiCore ( + IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor, + IN PEI_CORE_INSTANCE *OldCoreData + ) +/*++ + +Routine Description: + + The entry routine to Pei Core, invoked by PeiMain during transition + from SEC to PEI. After switching stack in the PEI core, it will restart + with the old core data. + +Arguments: + + PeiStartupDescriptor - Information and services provided by SEC phase. + OldCoreData - Pointer to old core data that is used to initialize the + core's data areas. + +Returns: + + This function never returns + EFI_NOT_FOUND - Never reach + +--*/ +{ + PEI_CORE_INSTANCE PrivateData; + EFI_STATUS Status; + PEI_CORE_TEMP_POINTERS TempPtr; + PEI_CORE_DISPATCH_DATA *DispatchData; + UINT64 mTick; + + mTick = 0; + +#ifdef EFI_PEI_PERFORMANCE + if (OldCoreData == NULL) { + mTick = GetPerformanceCounter (); + } +#endif + + // + // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory() + // the 63-bit of address is set to 1. + // + SWITCH_TO_CACHE_MODE (OldCoreData); + + if (OldCoreData != NULL) { + CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE)); + } else { + ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE)); + } + + PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE; + PrivateData.PS = &mPS; + + // + // Initialize libraries that the PeiCore is linked against + // BUGBUG: The FfsHeader is passed in as NULL. Do we look it up or remove it from the lib init? + // + ProcessLibraryConstructorList (NULL, &PrivateData.PS); + + InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData); + + InitializePpiServices (&PrivateData.PS, OldCoreData); + + InitializeSecurityServices (&PrivateData.PS, OldCoreData); + + InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor); + + if (OldCoreData != NULL) { + + PERF_END (NULL,"PreMem", NULL, 0); + PERF_START (NULL,"PostMem", NULL, 0); + + // + // The following code dumps out interesting cache as RAM usage information + // so we can keep tabs on how the cache as RAM is being utilized. The + // DEBUG_CODE macro is used to prevent this code from being compiled + // on a debug build. + // + DEBUG_CODE ( + UINTN *StackPointer; + UINTN StackValue; + + StackValue = INIT_CAR_VALUE; + for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap; + ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam)) + && StackValue == INIT_CAR_VALUE; + StackPointer++) { + StackValue = *StackPointer; + } + + DEBUG ((EFI_D_INFO, "Total Cache as RAM: %d bytes.\n", OldCoreData->SizeOfCacheAsRam)); + DEBUG ((EFI_D_INFO, " CAR stack ever used: %d bytes.\n", + ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer) + )); + DEBUG ((EFI_D_INFO, " CAR heap used: %d bytes.\n", + ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom - + (UINTN) OldCoreData->HobList.Raw) + )); + ); + + // + // Alert any listeners that there is permanent memory available + // + PERF_START (NULL,"DisMem", NULL, 0); + Status = PeiCoreInstallPpi (&mMemoryDiscoveredPpi); + PERF_END (NULL,"DisMem", NULL, 0); + + } else { + + // + // Report Status Code EFI_SW_PC_INIT + // + REPORT_STATUS_CODE ( + EFI_PROGRESS_CODE, + EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT + ); + + // + // If first pass, start performance measurement. + // + PERF_START (NULL,"PreMem", NULL, mTick); + + // + // If SEC provided any PPI services to PEI, install them. + // + if (PeiStartupDescriptor->DispatchTable != NULL) { + Status = PeiCoreInstallPpi (PeiStartupDescriptor->DispatchTable); + ASSERT_EFI_ERROR (Status); + } + } + + DispatchData = &PrivateData.DispatchData; + + // + // Call PEIM dispatcher + // + PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData); + + // + // Check if InstallPeiMemory service was called. + // + ASSERT(PrivateData.PeiMemoryInstalled == TRUE); + + PERF_END (NULL, "PostMem", NULL, 0); + + Status = PeiCoreLocatePpi ( + &gEfiDxeIplPpiGuid, + 0, + NULL, + (VOID **)&TempPtr.DxeIpl + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((EFI_D_INFO, "DXE IPL Entry\n")); + Status = TempPtr.DxeIpl->Entry ( + TempPtr.DxeIpl, + &PrivateData.PS, + PrivateData.HobList + ); + + ASSERT_EFI_ERROR (Status); + + return EFI_NOT_FOUND; +} + diff --git a/EdkModulePkg/EdkModulePkg.spd b/EdkModulePkg/EdkModulePkg.spd index 40c20d4..1d75273 100644 --- a/EdkModulePkg/EdkModulePkg.spd +++ b/EdkModulePkg/EdkModulePkg.spd @@ -1,663 +1,669 @@ - - - - - EdkModulePkg - 0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 - 0 - Edk Module Package Reference Implementations - This Module provides standard reference information for EFI/Tiano implementations. - Copyright (c) 2006, Intel Corporation. - - All rights reserved. - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this distribution. - The full text of the license may be found at http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES - OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - 2006-02-21 17:43 - 2006-03-19 16:26 - http://www.TianoCore.org - SOURCE - true - false - - - - CustomDecompressLib - Include/Library/CustomDecompressLib.h - - - EdkBsDataHubStatusCodeLib - Include/Library/EdkBsDataHubStatusCodeLib.h - - - EdkDxeSalLib - Include/Library/EdkDxeSalLib.h - - - EdkFvbServiceLib - Include/Library/EdkFvbServiceLib.h - - - EdkGraphicsLib - Include/Library/EdkGraphicsLib.h - - - EdkIfrSupportLib - Include/Library/EdkIfrSupportLib.h - - - EdkMemoryStatusCodeLib - Include/Library/EdkMemoryStatusCodeLib.h - - - EdkPeCoffLoaderLib - Include/Library/EdkPeCoffLoaderLib.h - - - EdkPeCoffLoaderX64Lib - Include/Library/EdkPeCoffLoaderX64Lib.h - - - EdkRtMemoryStatusCodeLib - Include/Library/EdkRtMemoryStatusCodeLib.h - - - EdkRtPlatformStatusCodeLib - Include/Library/EdkRtPlatformStatusCodeLib.h - - - EdkScsiLib - Include/Library/EdkScsiLib.h - - - EdkUsbLib - Include/Library/EdkUsbLib.h - - - TianoDecompressLib - Include/Library/TianoDecompressLib.h - - - - - Application/HelloWorld/HelloWorld.msa - - - Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.msa - - - Bus/Pci/CirrusLogic/Dxe/CirrusLogic5430.msa - - - Bus/Pci/IdeBus/Dxe/idebus.msa - - - Bus/Pci/IdeBus/Dxe/idebusLite.msa - - - Bus/Pci/PciBus/Dxe/LightPciBus.msa - - - Bus/Pci/PciBus/Dxe/PciBus.msa - - - Bus/Pci/PciBus/Dxe/PciBusLite.msa - - - Bus/Pci/Uhci/Dxe/Uhci.msa - - - Bus/Pci/Undi/RuntimeDxe/Undi.msa - - - Bus/Scsi/ScsiBus/Dxe/ScsiBus.msa - - - Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.msa - - - Bus/Usb/UsbBot/Dxe/UsbBot.msa - - - Bus/Usb/UsbBus/Dxe/UsbBus.msa - - - Bus/Usb/UsbCbi/Dxe/Cbi0/UsbCbi0.msa - - - Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa - - - Bus/Usb/UsbKb/Dxe/UsbKb.msa - - - Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.msa - - - Bus/Usb/UsbMouse/Dxe/UsbMouse.msa - - - Core/Dxe/DxeMain.msa - - - Core/DxeIplPeim/DxeIpl.msa - - - Core/Pei/PeiMain.msa - - - Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.msa - - - Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.msa - - - Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.msa - - - Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa - - - Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.msa - - - Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.msa - - - Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa - - - Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.msa - - - Library/EdkDxePerformanceLib/EdkDxePerformanceLib.msa - - - Library/EdkDxePrintLib/EdkDxePrintLib.msa - - - Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.msa - - - Library/EdkDxeSalLib/EdkDxeSalLib.msa - - - Library/EdkFvbServiceLib/EdkFvbServiceLib.msa - - - Library/EdkGraphicsLib/EdkGraphicsLib.msa - - - Library/EdkIfrSupportLib/EdkIfrSupportLib.msa - - - Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.msa - - - Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa - - - Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa - - - Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa - - - Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.msa - - - Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa - - - Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa - - - Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa - - - Library/EdkScsiLib/EdkScsiLib.msa - - - Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa - - - Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa - - - Library/EdkUsbLib/EdkUsbLib.msa - - - Universal/Console/ConSplitter/Dxe/ConSplitter.msa - - - Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.msa - - - Universal/Console/Terminal/Dxe/Terminal.msa - - - Universal/DataHub/DataHub/Dxe/DataHub.msa - - - Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.msa - - - Universal/Debugger/Debugport/Dxe/DebugPort.msa - - - Universal/DebugSupport/Dxe/DebugSupport.msa - - - Universal/Disk/DiskIo/Dxe/DiskIo.msa - - - Universal/Disk/DiskIoPartition/dxe/DiskIoPartition.msa - - - Universal/Disk/Partition/Dxe/Partition.msa - - - Universal/Disk/UnicodeCollation/English/Dxe/English.msa - - - Universal/Ebc/Dxe/Ebc.msa - - - Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.msa - - - Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.msa - - - Universal/GenericMemoryTest/Dxe/NullMemoryTest.msa - - - Universal/GenericMemoryTest/Pei/BaseMemoryTest.msa - - - Universal/MonotonicCounter/RuntimeDxe/MonotonicCounter.msa - - - Universal/Network/PxeBc/Dxe/BC.msa - - - Universal/Network/PxeDhcp4/Dxe/Dhcp4.msa - - - Universal/Network/Snp32_64/Dxe/SNP.msa - - - Universal/Runtime/RuntimeDxe/Runtime.msa - - - Universal/Security/SecurityStub/Dxe/SecurityStub.msa - - - Universal/StatusCode/RuntimeDxe/StatusCode.msa - - - Universal/UserInterface/HiiDataBase/Dxe/HiiDatabase.msa - - - Universal/UserInterface/SetupBrowser/Dxe/DriverSample/DriverSample.msa - - - Universal/UserInterface/SetupBrowser/Dxe/SetupBrowser.msa - - - Universal/Variable/Pei/Variable.msa - - - Universal/EmuVariable/RuntimeDxe/EmuVariable.msa - - - Universal/Variable/RuntimeDxe/Variable.msa - - - Universal/WatchdogTimer/Dxe/WatchDogTimer.msa - - - - Include/EdkPeim.h - Include/EdkPeiCore.h - Include/EdkPeim.h - Include/EdkDxeCore.h - Include/EdkDxe.h - Include/EdkDxe.h - Include/EdkDxe.h - Include/EdkDxe.h - Include/EdkDxe.h - - - - gEfiPeiPeCoffLoaderGuid - 0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d - - - gEfiFlashMapHobGuid - 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 - - - gEfiStatusCodeDataTypeStringGuid - 0x92D11080, 0x496F, 0x4D95, 0xBE, 0x7E, 0x03, 0x74, 0x88, 0x38, 0x2B, 0x0A - - - gEfiStatusCodeDataTypeDebugGuid - 0x9A4E9246, 0xD553, 0x11D5, 0x87, 0xE2, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xb9 - - - gEfiStatusCodeDataTypeAssertGuid - 0xDA571595, 0x4D99, 0x487C, 0x82, 0x7C, 0x26, 0x22, 0x67, 0x7D, 0x33, 0x07 - - - gEfiStatusCodeDataTypeExceptionHandlerGuid - 0x3BC2BD12, 0xAD2E, 0x11D5, 0x87, 0xDD, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9 - - - gEfiStatusCodeDataTypeErrorGuid - 0xAB359CE3, 0x99B3, 0xAE18, 0xC8, 0x9D, 0x95, 0xD3, 0xB0, 0x72, 0xE1, 0x9B - - - gEfiStatusCodeDataTypeProgressCodeGuid - 0xA356AB39, 0x35C4, 0x35DA, 0xB3, 0x7A, 0xF8, 0xEA, 0x9E, 0x8B, 0x36, 0xA3 - - - gEfiStatusCodeSpecificDataGuid - 0x335984bd, 0xe805, 0x409a, 0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 0xa6 - - - gEfiSystemNvDataHobGuid - 0xd6e5092d, 0xc7b2, 0x4872, 0xaf, 0x66, 0xfd, 0xc0, 0xe6, 0xf9, 0x5e, 0x78 - - - gEfiSystemNvDataFvGuid - 0xfff12b8d, 0x7696, 0x4c8b, 0xa9, 0x85, 0x27, 0x47, 0x07, 0x5b, 0x4f, 0x50 - - - gEfiDiskInfoIdeInterfaceGuid - 0x5e948fe3, 0x26d3, 0x42b5, 0xaf, 0x17, 0x61, 0x02, 0x87, 0x18, 0x8d, 0xec - - - gEfiDiskInfoScsiInterfaceGuid - 0x8f74baa, 0xea36, 0x41d9, 0x95, 0x21, 0x21, 0xa7, 0x0f, 0x87, 0x80, 0xbc - - - gEfiDiskInfoUsbInterfaceGuid - 0xcb871572, 0xc11a, 0x47b5, 0xb4, 0x92, 0x67, 0x5e, 0xaf, 0xa7, 0x77, 0x27 - - - gEfiAlternateFvBlockGuid - 0xf496922d, 0x172f, 0x4bbc, 0xa1, 0xeb, 0x0e, 0xeb, 0x94, 0x9c, 0x34, 0x86 - - - gEfiConsoleInDeviceGuid - 0xd3b36f2b, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d - - - gEfiConsoleOutDeviceGuid - 0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d - - - gEfiStandardErrorDeviceGuid - 0xd3b36f2d, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d - - - gEfiHotPlugDeviceGuid - 0x220ac432, 0x1d43, 0x49e5, 0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b - - - gEfiPrimaryStandardErrorDeviceGuid - 0x5a68191b, 0x9b97, 0x4752, 0x99, 0x46, 0xe3, 0x6a, 0x5d, 0xa9, 0x42, 0xb1 - - - gEfiPrimaryConsoleInDeviceGuid - 0xe451dcbe, 0x96a1, 0x4729, 0xa5, 0xcf, 0x6b, 0x9c, 0x2c, 0xff, 0x47, 0xfd - - - gEfiPrimaryConsoleOutDeviceGuid - 0x62bdf38a, 0xe3d5, 0x492c, 0x95, 0x0c, 0x23, 0xa7, 0xf6, 0x6e, 0x67, 0x2e - - - gEfiDefaultBmpLogoGuid - 0x7BB28B99, 0x61BB, 0x11d5, 0x9A, 0x5D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D - - - gEfiBootStateGuid - 0x60b5e939, 0xfcf, 0x4227, 0xba, 0x83, 0x6b, 0xbe, 0xd4, 0x5b, 0xc0, 0xe3 - - - gEfiShellFileGuid - 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 - - - gEfiMiniShellFileGuid - 0x86ad232b, 0xd33a, 0x465c, 0xbf, 0x5f, 0x41, 0x37, 0x0b, 0xa9, 0x2f, 0xe2 - - - gEfiStatusCodeGuid - 0xd083e94c, 0x6560, 0x42e4, 0xb6, 0xd4, 0x2d, 0xf7, 0x5a, 0xdf, 0x6a, 0x2a - - - gEfiPciOptionRomTableGuid - 0x7462660f, 0x1cbd, 0x48da, 0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c - - - gEfiPciHotplugDeviceGuid - 0x0b280816, 0x52e7, 0x4e51, 0xaa, 0x57, 0x11, 0xbd, 0x41, 0xcb, 0xef, 0xc3 - - - gEfiMemoryTypeInformationGuid - 0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa - - - gEfiCapsuleVendorGuid - 0x711C703F, 0xC285, 0x4B10, 0xA3, 0xB0, 0x36, 0xEC, 0xBD, 0x3C, 0x8B, 0xE2 - - - gEfiCompatibleMemoryTestedGuid - 0x64c475ef, 0x344b, 0x492c, 0x93, 0xad, 0xab, 0x9e, 0xb4, 0x39, 0x50, 0x4 - - - gPeiPerformanceHobGuid - 0xec4df5af, 0x4395, 0x4cc9, 0x94, 0xde, 0x77, 0x50, 0x6d, 0x12, 0xc7, 0xb8 - - - - - gEfiCustomizedDecompressProtocolGuid - 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f - - - gEfiDebugLevelProtocolGuid - 0x8d4c62e6, 0xcd98, 0x4e1d, 0xad, 0x6e, 0x48, 0xbb, 0x50, 0xd2, 0x9f, 0xf7 - - - gEfiTianoDecompressProtocolGuid - 0xe84cf29c, 0x191f, 0x4eae, 0x96, 0xe1, 0xf4, 0x6a, 0xec, 0xea, 0xea, 0x0b - - - gEfiLoadPeImageProtocolGuid - 0x5cb5c776, 0x60d5, 0x45ee, 0x88, 0x3c, 0x45, 0x27, 0x08, 0xcd, 0x74, 0x3f - - - gEfiPrintProtocolGuid - 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 - - - gEfiGenericMemTestProtocolGuid - 0x309de7f1, 0x7f5e, 0x4ace, 0xb4, 0x9c, 0x53, 0x1b, 0xe5, 0xaa, 0x95, 0xef - - - gEfiDiskInfoProtocolGuid - 0xd432a67f, 0x14dc, 0x484b, 0xb3, 0xbb, 0x3f, 0x02, 0x91, 0x84, 0x93, 0x27 - - - gEfiFvbExtensionProtocolGuid - 0x53a4c71b, 0xb581, 0x4170, 0x91, 0xb3, 0x8d, 0xb8, 0x7a, 0x4b, 0x5c, 0x46 - - - gEfiFaultTolerantWriteLiteProtocolGuid - 0x3f557189, 0x8dae, 0x45ae, 0xa0, 0xb3, 0x2b, 0x99, 0xca, 0x7a, 0xa7, 0xa0 - - - gEfiConsoleControlProtocolGuid - 0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x04, 0xf7, 0x21 - - - gEfiOEMBadgingProtocolGuid - 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc - - - gEfiUgaSplashProtocolGuid - 0xa45b3a0d, 0x2e55, 0x4c03, 0xad, 0x9c, 0x27, 0xd4, 0x82, 0x0b, 0x50, 0x7e - - - gEfiAcpiS3SaveProtocolGuid - 0x125f2de1, 0xfb85, 0x440c, 0xa5, 0x4c, 0x4d, 0x99, 0x35, 0x8a, 0x8d, 0x38 - - - gEfiPerformanceProtocolGuid - 0xFFECFFFF, 0x923C, 0x14d2, 0x9E, 0x3F, 0x22, 0xA0, 0xC9, 0x69, 0x56, 0x3B - - - gEfiPxeDhcp4ProtocolGuid - 0x03c4e624, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x29, 0x3f, 0xc1, 0x4d - - - gEfiPxeDhcp4CallbackProtocolGuid - 0xc1544c01, 0x92a4, 0x4198, 0x8a, 0x84, 0x77, 0x85, 0x83, 0xc2, 0x36, 0x21 - - - gEfiUgaIoProtocolGuid - 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0x0b, 0x07, 0xa2 - - - gEfiDebugAssertProtocolGuid - 0xbe499c92, 0x7d4b, 0x11d4, 0xbc, 0xee, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 - - - gEfiUsbAtapiProtocolGuid - 0x2B2F68DA, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 - - - gEfiPciHotPlugRequestProtocolGuid - 0x19cb87ab, 0x2cb9, 0x4665, 0x83, 0x60, 0xdd, 0xcf, 0x60, 0x54, 0xf7, 0x9d - - - gEfiExtendedSalBootServiceProtocolGuid - 0xde0ee9a4, 0x3c7a, 0x44f2, 0xb7, 0x8b, 0xe3, 0xcc, 0xd6, 0x9c, 0x3a, 0xf7 - - - gEfiExtendedSalVariableServicesProtocolGuid - 0x4ecb6c53, 0xc641, 0x4370, 0x8c, 0xb2, 0x3b, 0x0e, 0x49, 0x6e, 0x83, 0x78 - - - gEfiExtendedSalStatusCodeServicesProtocolGuid - 0x00dbd91d, 0x55e9, 0x420f, 0x96, 0x39, 0x5e, 0x9f, 0x84, 0x37, 0xb4, 0x4f - - - gEfiIsaIoProtocolGuid - 0x7ee2bd44, 0x3da0, 0x11d4, 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d - - - gEfiIsaAcpiProtocolGuid - 0x64a892dc, 0x5561, 0x4536, 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 - - - gPerformanceProtocolGuid - 0x76b6bdfa, 0x2acd, 0x4462, 0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 - - - - - gPeiInMemoryGuid - 0x643b8786, 0xb417, 0x48d2, 0x8f, 0x5e, 0x78, 0x19, 0x93, 0x1c, 0xae, 0xd8 - - - gPeiFlashMapPpiGuid - 0xf34c2fa0, 0xde88, 0x4270, 0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c - - - gPeiBaseMemoryTestPpiGuid - 0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 - - - gPeiStatusCodeMemoryPpiGuid - 0x26f8ab01, 0xd3cd, 0x489c, 0x98, 0x4f, 0xdf, 0xde, 0xf7, 0x68, 0x39, 0x5b - - - - - PcdMaximumUnicodeStringLength - 0x00000001 - UINT32 - 1000000 - - - PcdMaximumAsciiStringLength - 0x00000002 - UINT32 - 1000000 - - - PcdMaximumLinkedListLength - 0x00000003 - UINT32 - 1000000 - - - PcdSpinLockTimeout - 0x00000004 - UINT32 - 10000000 - - - PcdDebugPropertyMask - 0x00000005 - UINT8 - 0x0f - - - PcdDebugPrintErrorLevel - 0x00000006 - UINT32 - 0x80000000 - - - PcdReportStatusCodePropertyMask - 0x00000007 - UINT8 - 0x07 - - - PcdDebugClearMemoryValue - 0x00000008 - UINT8 - 0xAF - - - PcdDebugClearMemoryValue - 0x00000008 - UINT8 - 0xAF - - - PcdPerformanceLibraryPropertyMask - 0x00000009 - UINT8 - 0 - - - + + + + + EdkModulePkg + 0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 + 0 + Edk Module Package Reference Implementations + This Module provides standard reference information for EFI/Tiano implementations. + Copyright (c) 2006, Intel Corporation. + + All rights reserved. + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this distribution. + The full text of the license may be found at http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES + OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-02-21 17:43 + 2006-03-19 16:26 + http://www.TianoCore.org + SOURCE + true + false + + + + CustomDecompressLib + Include/Library/CustomDecompressLib.h + + + EdkBsDataHubStatusCodeLib + Include/Library/EdkBsDataHubStatusCodeLib.h + + + EdkDxeSalLib + Include/Library/EdkDxeSalLib.h + + + EdkFvbServiceLib + Include/Library/EdkFvbServiceLib.h + + + EdkGraphicsLib + Include/Library/EdkGraphicsLib.h + + + EdkIfrSupportLib + Include/Library/EdkIfrSupportLib.h + + + EdkMemoryStatusCodeLib + Include/Library/EdkMemoryStatusCodeLib.h + + + EdkPeCoffLoaderLib + Include/Library/EdkPeCoffLoaderLib.h + + + EdkPeCoffLoaderX64Lib + Include/Library/EdkPeCoffLoaderX64Lib.h + + + EdkRtMemoryStatusCodeLib + Include/Library/EdkRtMemoryStatusCodeLib.h + + + EdkRtPlatformStatusCodeLib + Include/Library/EdkRtPlatformStatusCodeLib.h + + + EdkScsiLib + Include/Library/EdkScsiLib.h + + + EdkUsbLib + Include/Library/EdkUsbLib.h + + + TianoDecompressLib + Include/Library/TianoDecompressLib.h + + + + + Application/HelloWorld/HelloWorld.msa + + + Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.msa + + + Bus/Pci/CirrusLogic/Dxe/CirrusLogic5430.msa + + + Bus/Pci/IdeBus/Dxe/idebus.msa + + + Bus/Pci/IdeBus/Dxe/idebusLite.msa + + + Bus/Pci/PciBus/Dxe/LightPciBus.msa + + + Bus/Pci/PciBus/Dxe/PciBus.msa + + + Bus/Pci/PciBus/Dxe/PciBusLite.msa + + + Bus/Pci/Uhci/Dxe/Uhci.msa + + + Bus/Pci/Undi/RuntimeDxe/Undi.msa + + + Bus/Scsi/ScsiBus/Dxe/ScsiBus.msa + + + Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.msa + + + Bus/Usb/UsbBot/Dxe/UsbBot.msa + + + Bus/Usb/UsbBus/Dxe/UsbBus.msa + + + Bus/Usb/UsbCbi/Dxe/Cbi0/UsbCbi0.msa + + + Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.msa + + + Bus/Usb/UsbKb/Dxe/UsbKb.msa + + + Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.msa + + + Bus/Usb/UsbMouse/Dxe/UsbMouse.msa + + + Core/Dxe/DxeMain.msa + + + Core/DxeIplPeim/DxeIpl.msa + + + Core/DxeIplPeim/DxeIplX64.msa + + + Core/Pei/PeiMain.msa + + + Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.msa + + + Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.msa + + + Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.msa + + + Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa + + + Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.msa + + + Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.msa + + + Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa + + + Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.msa + + + Library/EdkDxePerformanceLib/EdkDxePerformanceLib.msa + + + Library/EdkDxePrintLib/EdkDxePrintLib.msa + + + Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.msa + + + Library/EdkDxeSalLib/EdkDxeSalLib.msa + + + Library/EdkFvbServiceLib/EdkFvbServiceLib.msa + + + Library/EdkGraphicsLib/EdkGraphicsLib.msa + + + Library/EdkIfrSupportLib/EdkIfrSupportLib.msa + + + Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.msa + + + Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa + + + Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa + + + Library/EdkPeCoffLoaderLibX64/EdkPeCoffLoaderLibX64.msa + + + Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa + + + Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.msa + + + Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa + + + Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa + + + Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa + + + Library/EdkScsiLib/EdkScsiLib.msa + + + Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa + + + Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa + + + Library/EdkUsbLib/EdkUsbLib.msa + + + Universal/Console/ConSplitter/Dxe/ConSplitter.msa + + + Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.msa + + + Universal/Console/Terminal/Dxe/Terminal.msa + + + Universal/DataHub/DataHub/Dxe/DataHub.msa + + + Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.msa + + + Universal/Debugger/Debugport/Dxe/DebugPort.msa + + + Universal/DebugSupport/Dxe/DebugSupport.msa + + + Universal/Disk/DiskIo/Dxe/DiskIo.msa + + + Universal/Disk/DiskIoPartition/dxe/DiskIoPartition.msa + + + Universal/Disk/Partition/Dxe/Partition.msa + + + Universal/Disk/UnicodeCollation/English/Dxe/English.msa + + + Universal/Ebc/Dxe/Ebc.msa + + + Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.msa + + + Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.msa + + + Universal/GenericMemoryTest/Dxe/NullMemoryTest.msa + + + Universal/GenericMemoryTest/Pei/BaseMemoryTest.msa + + + Universal/MonotonicCounter/RuntimeDxe/MonotonicCounter.msa + + + Universal/Network/PxeBc/Dxe/BC.msa + + + Universal/Network/PxeDhcp4/Dxe/Dhcp4.msa + + + Universal/Network/Snp32_64/Dxe/SNP.msa + + + Universal/Runtime/RuntimeDxe/Runtime.msa + + + Universal/Security/SecurityStub/Dxe/SecurityStub.msa + + + Universal/StatusCode/RuntimeDxe/StatusCode.msa + + + Universal/UserInterface/HiiDataBase/Dxe/HiiDatabase.msa + + + Universal/UserInterface/SetupBrowser/Dxe/DriverSample/DriverSample.msa + + + Universal/UserInterface/SetupBrowser/Dxe/SetupBrowser.msa + + + Universal/Variable/Pei/Variable.msa + + + Universal/EmuVariable/RuntimeDxe/EmuVariable.msa + + + Universal/Variable/RuntimeDxe/Variable.msa + + + Universal/WatchdogTimer/Dxe/WatchDogTimer.msa + + + + Include/EdkPeim.h + Include/EdkPeiCore.h + Include/EdkPeim.h + Include/EdkDxeCore.h + Include/EdkDxe.h + Include/EdkDxe.h + Include/EdkDxe.h + Include/EdkDxe.h + Include/EdkDxe.h + + + + gEfiPeiPeCoffLoaderGuid + 0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiFlashMapHobGuid + 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 + + + gEfiStatusCodeDataTypeStringGuid + 0x92D11080, 0x496F, 0x4D95, 0xBE, 0x7E, 0x03, 0x74, 0x88, 0x38, 0x2B, 0x0A + + + gEfiStatusCodeDataTypeDebugGuid + 0x9A4E9246, 0xD553, 0x11D5, 0x87, 0xE2, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xb9 + + + gEfiStatusCodeDataTypeAssertGuid + 0xDA571595, 0x4D99, 0x487C, 0x82, 0x7C, 0x26, 0x22, 0x67, 0x7D, 0x33, 0x07 + + + gEfiStatusCodeDataTypeExceptionHandlerGuid + 0x3BC2BD12, 0xAD2E, 0x11D5, 0x87, 0xDD, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9 + + + gEfiStatusCodeDataTypeErrorGuid + 0xAB359CE3, 0x99B3, 0xAE18, 0xC8, 0x9D, 0x95, 0xD3, 0xB0, 0x72, 0xE1, 0x9B + + + gEfiStatusCodeDataTypeProgressCodeGuid + 0xA356AB39, 0x35C4, 0x35DA, 0xB3, 0x7A, 0xF8, 0xEA, 0x9E, 0x8B, 0x36, 0xA3 + + + gEfiStatusCodeSpecificDataGuid + 0x335984bd, 0xe805, 0x409a, 0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 0xa6 + + + gEfiSystemNvDataHobGuid + 0xd6e5092d, 0xc7b2, 0x4872, 0xaf, 0x66, 0xfd, 0xc0, 0xe6, 0xf9, 0x5e, 0x78 + + + gEfiSystemNvDataFvGuid + 0xfff12b8d, 0x7696, 0x4c8b, 0xa9, 0x85, 0x27, 0x47, 0x07, 0x5b, 0x4f, 0x50 + + + gEfiDiskInfoIdeInterfaceGuid + 0x5e948fe3, 0x26d3, 0x42b5, 0xaf, 0x17, 0x61, 0x02, 0x87, 0x18, 0x8d, 0xec + + + gEfiDiskInfoScsiInterfaceGuid + 0x8f74baa, 0xea36, 0x41d9, 0x95, 0x21, 0x21, 0xa7, 0x0f, 0x87, 0x80, 0xbc + + + gEfiDiskInfoUsbInterfaceGuid + 0xcb871572, 0xc11a, 0x47b5, 0xb4, 0x92, 0x67, 0x5e, 0xaf, 0xa7, 0x77, 0x27 + + + gEfiAlternateFvBlockGuid + 0xf496922d, 0x172f, 0x4bbc, 0xa1, 0xeb, 0x0e, 0xeb, 0x94, 0x9c, 0x34, 0x86 + + + gEfiConsoleInDeviceGuid + 0xd3b36f2b, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiConsoleOutDeviceGuid + 0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiStandardErrorDeviceGuid + 0xd3b36f2d, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiHotPlugDeviceGuid + 0x220ac432, 0x1d43, 0x49e5, 0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b + + + gEfiPrimaryStandardErrorDeviceGuid + 0x5a68191b, 0x9b97, 0x4752, 0x99, 0x46, 0xe3, 0x6a, 0x5d, 0xa9, 0x42, 0xb1 + + + gEfiPrimaryConsoleInDeviceGuid + 0xe451dcbe, 0x96a1, 0x4729, 0xa5, 0xcf, 0x6b, 0x9c, 0x2c, 0xff, 0x47, 0xfd + + + gEfiPrimaryConsoleOutDeviceGuid + 0x62bdf38a, 0xe3d5, 0x492c, 0x95, 0x0c, 0x23, 0xa7, 0xf6, 0x6e, 0x67, 0x2e + + + gEfiDefaultBmpLogoGuid + 0x7BB28B99, 0x61BB, 0x11d5, 0x9A, 0x5D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D + + + gEfiBootStateGuid + 0x60b5e939, 0xfcf, 0x4227, 0xba, 0x83, 0x6b, 0xbe, 0xd4, 0x5b, 0xc0, 0xe3 + + + gEfiShellFileGuid + 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 + + + gEfiMiniShellFileGuid + 0x86ad232b, 0xd33a, 0x465c, 0xbf, 0x5f, 0x41, 0x37, 0x0b, 0xa9, 0x2f, 0xe2 + + + gEfiStatusCodeGuid + 0xd083e94c, 0x6560, 0x42e4, 0xb6, 0xd4, 0x2d, 0xf7, 0x5a, 0xdf, 0x6a, 0x2a + + + gEfiPciOptionRomTableGuid + 0x7462660f, 0x1cbd, 0x48da, 0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c + + + gEfiPciHotplugDeviceGuid + 0x0b280816, 0x52e7, 0x4e51, 0xaa, 0x57, 0x11, 0xbd, 0x41, 0xcb, 0xef, 0xc3 + + + gEfiMemoryTypeInformationGuid + 0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa + + + gEfiCapsuleVendorGuid + 0x711C703F, 0xC285, 0x4B10, 0xA3, 0xB0, 0x36, 0xEC, 0xBD, 0x3C, 0x8B, 0xE2 + + + gEfiCompatibleMemoryTestedGuid + 0x64c475ef, 0x344b, 0x492c, 0x93, 0xad, 0xab, 0x9e, 0xb4, 0x39, 0x50, 0x4 + + + gPeiPerformanceHobGuid + 0xec4df5af, 0x4395, 0x4cc9, 0x94, 0xde, 0x77, 0x50, 0x6d, 0x12, 0xc7, 0xb8 + + + + + gEfiCustomizedDecompressProtocolGuid + 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f + + + gEfiDebugLevelProtocolGuid + 0x8d4c62e6, 0xcd98, 0x4e1d, 0xad, 0x6e, 0x48, 0xbb, 0x50, 0xd2, 0x9f, 0xf7 + + + gEfiTianoDecompressProtocolGuid + 0xe84cf29c, 0x191f, 0x4eae, 0x96, 0xe1, 0xf4, 0x6a, 0xec, 0xea, 0xea, 0x0b + + + gEfiLoadPeImageProtocolGuid + 0x5cb5c776, 0x60d5, 0x45ee, 0x88, 0x3c, 0x45, 0x27, 0x08, 0xcd, 0x74, 0x3f + + + gEfiPrintProtocolGuid + 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 + + + gEfiGenericMemTestProtocolGuid + 0x309de7f1, 0x7f5e, 0x4ace, 0xb4, 0x9c, 0x53, 0x1b, 0xe5, 0xaa, 0x95, 0xef + + + gEfiDiskInfoProtocolGuid + 0xd432a67f, 0x14dc, 0x484b, 0xb3, 0xbb, 0x3f, 0x02, 0x91, 0x84, 0x93, 0x27 + + + gEfiFvbExtensionProtocolGuid + 0x53a4c71b, 0xb581, 0x4170, 0x91, 0xb3, 0x8d, 0xb8, 0x7a, 0x4b, 0x5c, 0x46 + + + gEfiFaultTolerantWriteLiteProtocolGuid + 0x3f557189, 0x8dae, 0x45ae, 0xa0, 0xb3, 0x2b, 0x99, 0xca, 0x7a, 0xa7, 0xa0 + + + gEfiConsoleControlProtocolGuid + 0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x04, 0xf7, 0x21 + + + gEfiOEMBadgingProtocolGuid + 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc + + + gEfiUgaSplashProtocolGuid + 0xa45b3a0d, 0x2e55, 0x4c03, 0xad, 0x9c, 0x27, 0xd4, 0x82, 0x0b, 0x50, 0x7e + + + gEfiAcpiS3SaveProtocolGuid + 0x125f2de1, 0xfb85, 0x440c, 0xa5, 0x4c, 0x4d, 0x99, 0x35, 0x8a, 0x8d, 0x38 + + + gEfiPerformanceProtocolGuid + 0xFFECFFFF, 0x923C, 0x14d2, 0x9E, 0x3F, 0x22, 0xA0, 0xC9, 0x69, 0x56, 0x3B + + + gEfiPxeDhcp4ProtocolGuid + 0x03c4e624, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x29, 0x3f, 0xc1, 0x4d + + + gEfiPxeDhcp4CallbackProtocolGuid + 0xc1544c01, 0x92a4, 0x4198, 0x8a, 0x84, 0x77, 0x85, 0x83, 0xc2, 0x36, 0x21 + + + gEfiUgaIoProtocolGuid + 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0x0b, 0x07, 0xa2 + + + gEfiDebugAssertProtocolGuid + 0xbe499c92, 0x7d4b, 0x11d4, 0xbc, 0xee, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 + + + gEfiUsbAtapiProtocolGuid + 0x2B2F68DA, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 + + + gEfiPciHotPlugRequestProtocolGuid + 0x19cb87ab, 0x2cb9, 0x4665, 0x83, 0x60, 0xdd, 0xcf, 0x60, 0x54, 0xf7, 0x9d + + + gEfiExtendedSalBootServiceProtocolGuid + 0xde0ee9a4, 0x3c7a, 0x44f2, 0xb7, 0x8b, 0xe3, 0xcc, 0xd6, 0x9c, 0x3a, 0xf7 + + + gEfiExtendedSalVariableServicesProtocolGuid + 0x4ecb6c53, 0xc641, 0x4370, 0x8c, 0xb2, 0x3b, 0x0e, 0x49, 0x6e, 0x83, 0x78 + + + gEfiExtendedSalStatusCodeServicesProtocolGuid + 0x00dbd91d, 0x55e9, 0x420f, 0x96, 0x39, 0x5e, 0x9f, 0x84, 0x37, 0xb4, 0x4f + + + gEfiIsaIoProtocolGuid + 0x7ee2bd44, 0x3da0, 0x11d4, 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d + + + gEfiIsaAcpiProtocolGuid + 0x64a892dc, 0x5561, 0x4536, 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 + + + gPerformanceProtocolGuid + 0x76b6bdfa, 0x2acd, 0x4462, 0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 + + + + + gPeiInMemoryGuid + 0x643b8786, 0xb417, 0x48d2, 0x8f, 0x5e, 0x78, 0x19, 0x93, 0x1c, 0xae, 0xd8 + + + gPeiFlashMapPpiGuid + 0xf34c2fa0, 0xde88, 0x4270, 0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c + + + gPeiBaseMemoryTestPpiGuid + 0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 + + + gPeiStatusCodeMemoryPpiGuid + 0x26f8ab01, 0xd3cd, 0x489c, 0x98, 0x4f, 0xdf, 0xde, 0xf7, 0x68, 0x39, 0x5b + + + + + PcdMaximumUnicodeStringLength + 0x00000001 + UINT32 + 1000000 + + + PcdMaximumAsciiStringLength + 0x00000002 + UINT32 + 1000000 + + + PcdMaximumLinkedListLength + 0x00000003 + UINT32 + 1000000 + + + PcdSpinLockTimeout + 0x00000004 + UINT32 + 10000000 + + + PcdDebugPropertyMask + 0x00000005 + UINT8 + 0x0f + + + PcdDebugPrintErrorLevel + 0x00000006 + UINT32 + 0x80000000 + + + PcdReportStatusCodePropertyMask + 0x00000007 + UINT8 + 0x07 + + + PcdDebugClearMemoryValue + 0x00000008 + UINT8 + 0xAF + + + PcdDebugClearMemoryValue + 0x00000008 + UINT8 + 0xAF + + + PcdPerformanceLibraryPropertyMask + 0x00000009 + UINT8 + 0 + + + diff --git a/EdkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCode.mbd b/EdkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCode.mbd index 923914a..f4030f4 100644 --- a/EdkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCode.mbd +++ b/EdkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCode.mbd @@ -1,55 +1,55 @@ - - - - - StatusCode - 9F455D3B-2B8A-4c06-960B-A71B9714B9CD - 0 - FIX ME! - Copyright (c) 2004-2006, Intel Corporation - - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - 2006-03-12 17:09 - 2006-03-19 15:19 - - - UefiBootServicesTableLib - BaseLib - EdkDxeRuntimeDriverLib - UefiDriverEntryPoint - UefiLib - BasePrintLib - BaseDebugLibReportStatusCode - EdkRtPlatformStatusCodeLib - DxeIoLibCpuIo - BaseMemoryLib - DxeReportStatusCodeLib - EdkRtMemoryStatusCodeLib - EdkBsDataHubStatusCodeLib - DxeHobLib - DxeMemoryAllocationLib - EdkMemoryStatusCodeLib - - - EdkDxeSalLib - - - - _ModuleEntryPoint - - + + + + + StatusCode + 9F455D3B-2B8A-4c06-960B-A71B9714B9CD + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-12 17:09 + 2006-03-19 15:19 + + + UefiBootServicesTableLib + BaseLib + EdkDxeRuntimeDriverLib + UefiDriverEntryPoint + UefiLib + BasePrintLib + BaseDebugLibReportStatusCode + DxeIoLibCpuIo + BaseMemoryLib + DxeReportStatusCodeLib + EdkRtPlatformStatusCodeLib + EdkRtMemoryStatusCodeLib + EdkBsDataHubStatusCodeLib + DxeHobLib + DxeMemoryAllocationLib + EdkMemoryStatusCodeLib + + + EdkDxeSalLib + + + + _ModuleEntryPoint + + diff --git a/EdkModulePkg/Universal/Variable/Pei/Variable.mbd b/EdkModulePkg/Universal/Variable/Pei/Variable.mbd index 036758d..df87f46 100644 --- a/EdkModulePkg/Universal/Variable/Pei/Variable.mbd +++ b/EdkModulePkg/Universal/Variable/Pei/Variable.mbd @@ -1,43 +1,43 @@ - - - - - PeiVariable - 34C8C28F-B61C-45a2-8F2E-89E46BECC63B - 0 - FIX ME! - Copyright (c) 2004-2006, Intel Corporation - - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - 2006-03-12 17:09 - 2006-03-19 15:19 - - - PeiReportStatusCodeLib - BaseDebugLibReportStatusCode - BaseLib - PeiMemoryLib - PeiCoreLib - PeiServicesTablePointerLib - PeiHobLib - PeimEntryPoint - - - _ModuleEntryPoint - - + + + + + PeiVariable + 34C8C28F-B61C-45a2-8F2E-89E46BECC63B + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-12 17:09 + 2006-03-19 15:19 + + + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + PeimEntryPoint + + + _ModuleEntryPoint + + -- cgit v1.1