From: klu2 Date: Thu, 5 Jul 2007 15:27:43 +0000 (+0000) Subject: Porting WinNtFwhPei and WinNtFlashMapPei to produce FvHob. X-Git-Tag: edk2-stable201903~22879 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=56a71b557eda2b1fad72728e0d4d074a4083ac68 Porting WinNtFwhPei and WinNtFlashMapPei to produce FvHob. Help to build DxeCore in Nt32Pkg platform. Fix the wrong DebugLib used in Nt32Pkg platform. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3076 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf index 96e578f0d0..19b2b4991c 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -95,7 +95,7 @@ CustomDecompressLib TianoDecompressLib UefiDecompressLib - EdkPeCoffLoaderLib + PeCoffLoaderLib CacheMaintenanceLib ReportStatusCodeLib PeiServicesLib diff --git a/MdeModulePkg/Include/Guid/FlashMapHob.h b/MdeModulePkg/Include/Guid/FlashMapHob.h new file mode 100644 index 0000000000..a9e9b6736f --- /dev/null +++ b/MdeModulePkg/Include/Guid/FlashMapHob.h @@ -0,0 +1,33 @@ +/*++ + +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: + + FlashMapHob.h + +Abstract: + + GUID used for Flash Map HOB entries in the HOB list. + +--*/ + +#ifndef _FLASH_MAP_HOB_GUID_H_ +#define _FLASH_MAP_HOB_GUID_H_ + +// +// Definitions for Flash Map +// +#define EFI_FLASH_MAP_HOB_GUID \ + { 0xb091e7d2, 0x5a0, 0x4198, {0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 } } + +extern EFI_GUID gEfiFlashMapHobGuid; + +#endif // _FLASH_MAP_HOB_GUID_H_ diff --git a/MdeModulePkg/Include/Ppi/FlashMap.h b/MdeModulePkg/Include/Ppi/FlashMap.h new file mode 100644 index 0000000000..c979978459 --- /dev/null +++ b/MdeModulePkg/Include/Ppi/FlashMap.h @@ -0,0 +1,54 @@ +/*++ + +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: + + FlashMap.h + +Abstract: + + FlashMap PPI defined in Tiano + + This code abstracts FlashMap access + +--*/ + +#ifndef _PEI_FLASH_MAP_PPI_H_ +#define _PEI_FLASH_MAP_PPI_H_ + +#include + +#define PEI_FLASH_MAP_PPI_GUID \ + { 0xf34c2fa0, 0xde88, 0x4270, {0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c } } + +typedef struct _PEI_FLASH_MAP_PPI PEI_FLASH_MAP_PPI; +// +// Functions +// +typedef +EFI_STATUS +(EFIAPI *PEI_GET_FLASH_AREA_INFO) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_FLASH_MAP_PPI *This, + IN EFI_FLASH_AREA_TYPE AreaType, + IN EFI_GUID *AreaTypeGuid, + OUT UINT32 *NumEntries, + OUT EFI_FLASH_SUBAREA_ENTRY **Entries + ); + + +struct _PEI_FLASH_MAP_PPI { + PEI_GET_FLASH_AREA_INFO GetAreaInfo; +}; + +extern EFI_GUID gPeiFlashMapPpiGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index b4b46d9379..76cff821a9 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -69,7 +69,7 @@ gEfiPeiCorePrivateGuid = { 0xd641a0f5, 0xcb7c, 0x4846, { 0xa3, 0x80, 0x1d, 0x01, 0xb4, 0xd9, 0xe3, 0xb9 }} gEfiEndOfPeiSignalPpiGuid = { 0x605EA650, 0xC65C, 0x42e1, { 0xBA, 0x80, 0x91, 0xA5, 0x2A, 0xB6, 0x18, 0xC6 }} gEfiPeiFvFileLoaderPpiGuid = { 0x7e1f0d85, 0x04ff, 0x4bb2, { 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 }} - + ################################################################################ # @@ -107,7 +107,8 @@ [Ppis.common] gPeiBaseMemoryTestPpiGuid = { 0xB6EC423C, 0x21D2, 0x490D, { 0x85, 0xC6, 0xDD, 0x58, 0x64, 0xEA, 0xA6, 0x74 }} gEfiPeiFvFileLoaderPpiGuid = { 0x7e1f0d85, 0x04ff, 0x4bb2, { 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 }} - + ##gPeiFlashMapPpiGuid will be removed in future + gPeiFlashMapPpiGuid = { 0xf34c2fa0, 0xde88, 0x4270, {0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c } } ################################################################################ # diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index 80846fefc5..3ddac7171a 100644 --- a/Nt32Pkg/Nt32Pkg.dsc +++ b/Nt32Pkg/Nt32Pkg.dsc @@ -63,7 +63,7 @@ [LibraryClasses.common] TimerLib|$(WORKSPACE)/MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf PrintLib|$(WORKSPACE)/MdePkg/Library/BasePrintLib/BasePrintLib.inf - DebugLib|$(WORKSPACE)/MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + DebugLib|$(WORKSPACE)/IntelFrameworkPkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf SerialPortLib|$(WORKSPACE)/MdePkg/Library/SerialPortLibNull/SerialPortLibNull.inf BaseMemoryLib|$(WORKSPACE)/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf BaseLib|$(WORKSPACE)/MdePkg/Library/BaseLib/BaseLib.inf @@ -88,9 +88,9 @@ MemoryAllocationLib|$(WORKSPACE)/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf UefiLib|$(WORKSPACE)/MdePkg/Library/UefiLib/UefiLib.inf ReportStatusCodeLib|$(WORKSPACE)/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf - EdkPeCoffLoaderLib|$(WORKSPACE)/Nt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.inf + PeCoffLoaderLib|$(WORKSPACE)/Nt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.inf PcdLib|$(WORKSPACE)/MdePkg/Library/DxePcdLib/DxePcdLib.inf - + UefiRuntimeServicesTableLib|$(WORKSPACE)/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf [LibraryClasses.common.DXE_SMM_DRIVER] @@ -118,7 +118,7 @@ PeiServicesLib|$(WORKSPACE)/MdePkg/Library/PeiServicesLib/PeiServicesLib.inf MemoryAllocationLib|$(WORKSPACE)/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf ReportStatusCodeLib|$(WORKSPACE)/IntelFrameworkPkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - EdkPeCoffLoaderLib|$(WORKSPACE)/Nt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.inf + PeCoffLoaderLib|$(WORKSPACE)/Nt32Pkg/Library/Nt32PeCoffLoaderLib/Nt32PeCoffLoaderLib.inf PeiServicesTablePointerLib|$(WORKSPACE)/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf OemHookStatusCodeLib|$(WORKSPACE)/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/PeiNt32OemHookStatusCodeLib.inf PeCoffGetEntryPointLib|$(WORKSPACE)/Nt32Pkg/Library/EdkNt32PeiPeCoffGetEntryPointLib/EdkNt32PeiPeCoffGetEntryPointLib.inf @@ -243,7 +243,7 @@ PcdReportStatusCodePropertyMask|gEfiMdePkgTokenSpaceGuid|0x06 PcdDebugPropertyMask|gEfiMdePkgTokenSpaceGuid|0x1f PcdDebugClearMemoryValue|gEfiMdePkgTokenSpaceGuid|0xAF - PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000000 + PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000040 PcdPerformanceLibraryPropertyMask|gEfiMdePkgTokenSpaceGuid|0 PcdMaxPeiPcdCallBackNumberPerPcdEntry|gEfiMdeModulePkgTokenSpaceGuid|0x08 PcdVpdBaseAddress|gEfiEdkModulePkgTokenSpaceGuid|0x0 @@ -379,9 +379,12 @@ $(WORKSPACE)/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.inf ##This driver follows UEFI specification definition $(WORKSPACE)/Nt32Pkg/Sec/SecMain.inf $(WORKSPACE)/MdeModulePkg/Core/Pei/PeiMain.inf - ${WORKSPACE}/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.inf - ${WORKSPACE}/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.inf - ${WORKSPACE}/MdeModulePkg/Universal/DevicePathDxe/DevicePath.inf - ${WORKSPACE}/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.inf - ${WORKSPACE}/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf - ${WORKSPACE}/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.inf + $(WORKSPACE)/MdeModulePkg/Core/Dxe/DxeMain.inf + $(WORKSPACE)/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.inf + $(WORKSPACE)/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.inf + $(WORKSPACE)/MdeModulePkg/Universal/DevicePathDxe/DevicePath.inf + $(WORKSPACE)/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.inf + $(WORKSPACE)/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf + $(WORKSPACE)/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.inf + $(WORKSPACE)/Nt32Pkg/WinNtFlashMapPei/FlashMap.inf + $(WORKSPACE)/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.inf \ No newline at end of file diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf index 6b6a62205d..77845759de 100644 --- a/Nt32Pkg/Nt32Pkg.fdf +++ b/Nt32Pkg/Nt32Pkg.fdf @@ -110,6 +110,7 @@ READ_LOCK_STATUS = TRUE # ################################################################################ INF $(WORKSPACE)/MdeModulePkg/Core/Pei/PeiMain.inf +INF $(WORKSPACE)/MdeModulePkg/Core/Dxe/DxeMain.inf INF $(WORKSPACE)/Nt32Pkg/BootModePei/BootMode.inf INF $(WORKSPACE)/Nt32Pkg/WinNtThunkDxe/WinNtThunk.inf #INF $(WORKSPACE)/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.inf @@ -160,6 +161,8 @@ INF $(WORKSPACE)/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.inf ##This driver INF $(WORKSPACE)/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.inf ##This driver follows UEFI specification definition INF $(WORKSPACE)/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf INF $(WORKSPACE)/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.inf +INF $(WORKSPACE)/Nt32Pkg/WinNtFlashMapPei/FlashMap.inf +INF $(WORKSPACE)/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.inf ################################################################################ # diff --git a/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.dxs b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.dxs new file mode 100644 index 0000000000..b69c22716d --- /dev/null +++ b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.dxs @@ -0,0 +1,33 @@ +/*++ + +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: + + WinNtFwh.dxs + +Abstract: + + Dependency expression file for WinNtFwh PEIM. + +--*/ + +// +// Include common header file for this module. +// +#include "CommonHeader.h" + +#include + +DEPENDENCY_START + NT_FWH_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID +DEPENDENCY_END + + diff --git a/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.inf b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.inf new file mode 100644 index 0000000000..d90d81822b --- /dev/null +++ b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.inf @@ -0,0 +1,96 @@ +#/** @file +# Component description file for WinNtFwh module +# +# This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices +# on the NT32 emulator. +# Copyright (c) 2006 - 2007, 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. +# +# +#**/ + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = WinNtFwh + FILE_GUID = F0384FFD-8633-452f-9010-F6B7D2EAE2F1 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + ENTRY_POINT = PeimInitializeWinNtFwh + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +################################################################################ +# +# Sources Section - list of files that are required for the build to succeed. +# +################################################################################ + +[Sources.common] + WinntFwh.c + + +################################################################################ +# +# Includes Section - list of Include locations that are required for +# this module. +# +################################################################################ + +[Includes] + $(WORKSPACE)/MdePkg/Include/Library + +################################################################################ +# +# Package Dependency Section - list of Package files that are required for +# this module. +# +################################################################################ + +[Packages] + Nt32Pkg/Nt32Pkg.dec + MdePkg/MdePkg.dec + + +################################################################################ +# +# Library Class Section - list of Library Classes that are required for +# this module. +# +################################################################################ + +[LibraryClasses] + HobLib + PeimEntryPoint + DebugLib + + +################################################################################ +# +# PPI C Name Section - list of PPI and PPI Notify C Names that this module +# uses or produces. +# +################################################################################ + +[Ppis] + gNtFwhPpiGuid # PPI ALWAYS_CONSUMED + +[depex] + gNtFwhPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid \ No newline at end of file diff --git a/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.msa b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.msa new file mode 100644 index 0000000000..9d600f2f1c --- /dev/null +++ b/Nt32Pkg/WinNtFirmwareVolumePei/WinNtFwh.msa @@ -0,0 +1,56 @@ + + + + WinNtFwh + PEIM + F0384FFD-8633-452f-9010-F6B7D2EAE2F1 + 1.0 + Component description file for WinNtFwh module + This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices + on the NT32 emulator. + Copyright (c) 2006 - 2007, 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. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + WinNtFwh + + + + DebugLib + + + PeimEntryPoint + + + HobLib + + + + WinntFwh.c + WinNtFwh.dxs + + + + + + + + gNtFwhPpiGuid + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00020000 + + PeimInitializeWinNtFwh + + + \ No newline at end of file diff --git a/Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c b/Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c new file mode 100644 index 0000000000..2431133136 --- /dev/null +++ b/Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c @@ -0,0 +1,138 @@ +/*++ + +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: + WinNtFwh.c + +Abstract: + PEIM to abstract construction of firmware volume in a Windows NT environment. + +Revision History + +--*/ + +// +// The package level header files this module uses +// +#include +#include +// +// The protocols, PPI and GUID defintions for this module +// +#include +// +// The Library classes this module consumes +// +#include +#include +#include + +#include + + +EFI_STATUS +EFIAPI +PeimInitializeWinNtFwh ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + Perform a call-back into the SEC simulator to get address of the Firmware Hub + +Arguments: + FfsHeader - Ffs Header availible to every PEIM + PeiServices - General purpose services available to every PEIM. + +Returns: + None + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; + NT_FWH_PPI *FwhPpi; + EFI_PHYSICAL_ADDRESS FdBase; + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + UINT64 FdSize; + UINTN Index; + + DEBUG ((EFI_D_ERROR, "NT 32 Firmware Volume PEIM Loaded\n")); + + // + // Get the Fwh Information PPI + // + Status = (**PeiServices).LocatePpi ( + PeiServices, + &gNtFwhPpiGuid, // GUID + 0, // INSTANCE + &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR + &FwhPpi // PPI + ); + ASSERT_EFI_ERROR (Status); + + Index = 0; + do { + // + // Get information about all the FD's in the system + // + Status = FwhPpi->NtFwh (Index, &FdBase, &FdSize); + if (!EFI_ERROR (Status)) { + // + // Assume the FD starts with an FV header + // + FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase; + + // + // Make an FV Hob for the first FV in the FD + // + BuildFvHob (FdBase, FvHeader->FvLength); + + if (Index == 0) { + // + // Assume the first FD was produced by the NT32.DSC + // All these strange offests are needed to keep in + // sync with the FlashMap and NT32.dsc file + // + BuildResourceDescriptorHob ( + EFI_RESOURCE_FIRMWARE_DEVICE, + (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), + FdBase, + (FvHeader->FvLength + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH) + ); + + // + // Hard code the address of the spare block and variable services. + // Assume it's a hard coded offset from FV0 in FD0. + // + FdBase = FdBase + EFI_WINNT_RUNTIME_UPDATABLE_OFFSET; + FdSize = EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH; + + BuildFvHob (FdBase, FdSize); + } else { + // + // For other FD's just map them in. + // + BuildResourceDescriptorHob ( + EFI_RESOURCE_FIRMWARE_DEVICE, + (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), + FdBase, + FdSize + ); + } + } + + Index++; + } while (!EFI_ERROR (Status)); + + return Status; +} diff --git a/Nt32Pkg/WinNtFlashMapPei/FlashMap.c b/Nt32Pkg/WinNtFlashMapPei/FlashMap.c new file mode 100644 index 0000000000..cc989c6ee3 --- /dev/null +++ b/Nt32Pkg/WinNtFlashMapPei/FlashMap.c @@ -0,0 +1,330 @@ +/*++ + +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: + + FlashMap.c + +Abstract: + + PEIM to build GUIDed HOBs for platform specific flash map + +--*/ + + +// +// The package level header files this module uses +// +#include +#include +// +// The protocols, PPI and GUID defintions for this module +// +#include +#include +#include +#include +#include +#include +// +// The Library classes this module consumes +// +#include +#include +#include +#include +#include +#include + + +#include + +EFI_STATUS +EFIAPI +GetAreaInfo ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_FLASH_MAP_PPI *This, + IN EFI_FLASH_AREA_TYPE AreaType, + IN EFI_GUID *AreaTypeGuid, + OUT UINT32 *NumEntries, + OUT EFI_FLASH_SUBAREA_ENTRY **Entries + ); + +EFI_STATUS +EFIAPI +MemoryDiscoveredPpiNotifyCallback ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ); + +// +// Module globals +// +static PEI_FLASH_MAP_PPI mFlashMapPpi = { GetAreaInfo }; + +static EFI_PEI_PPI_DESCRIPTOR mPpiListFlashMap = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gPeiFlashMapPpiGuid, + &mFlashMapPpi +}; + +static EFI_FLASH_AREA_DATA mFlashAreaData[] = { + // + // Variable area + // + { + EFI_VARIABLE_STORE_OFFSET, + EFI_VARIABLE_STORE_LENGTH, + EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV, + EFI_FLASH_AREA_EFI_VARIABLES, + 0, 0, 0, + { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, + // + // FTW spare (backup) block + // + { + EFI_WINNT_FTW_SPARE_BLOCK_OFFSET, + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH, + EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV, + EFI_FLASH_AREA_FTW_BACKUP, + 0, 0, 0, + { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, + // + // FTW private working (state) area + // + { + EFI_FTW_WORKING_OFFSET, + EFI_FTW_WORKING_LENGTH, + EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV, + EFI_FLASH_AREA_FTW_STATE, + 0, 0, 0, + { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, + // + // Recovery FV + // + { + EFI_WINNT_FIRMWARE_OFFSET, + EFI_WINNT_FIRMWARE_LENGTH, + EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV, + EFI_FLASH_AREA_RECOVERY_BIOS, + 0, 0, 0, + { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } + }, + // + // System Non-Volatile Storage FV + // + { + EFI_WINNT_RUNTIME_UPDATABLE_OFFSET, + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH, + EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV, + EFI_FLASH_AREA_GUID_DEFINED, + 0, 0, 0, + EFI_SYSTEM_NV_DATA_HOB_GUID + }, +}; + + +EFI_STATUS +EFIAPI +PeimInitializeFlashMap ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + Build GUIDed HOBs for platform specific flash map + +Arguments: + FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure. + PeiServices - General purpose services available to every PEIM. + +Returns: + EFI_STATUS + +--*/ +// TODO: EFI_SUCCESS - add return value to function comment +{ + EFI_STATUS Status; + NT_FWH_PPI *NtFwhPpi; + EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; + EFI_PHYSICAL_ADDRESS FdBase; + UINT64 FdSize; + UINTN NumOfHobData; + UINTN Index; + EFI_FLASH_AREA_HOB_DATA FlashHobData; + + DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n")); + + // + // Install FlashMap PPI + // + Status = PeiServicesInstallPpi (&mPpiListFlashMap); + ASSERT_EFI_ERROR (Status); + + + // + // Get the Fwh Information PPI + // + Status = PeiServicesLocatePpi ( + &gNtFwhPpiGuid, // GUID + 0, // INSTANCE + &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR + &NtFwhPpi // PPI + ); + ASSERT_EFI_ERROR (Status); + + // + // Assume that FD0 contains the Flash map. + // + Status = NtFwhPpi->NtFwh (0, &FdBase, &FdSize); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Get number of types + // + NumOfHobData = sizeof (mFlashAreaData) / sizeof (EFI_FLASH_AREA_DATA); + + // + // Build flash area entries as GUIDed HOBs. + // + for (Index = 0; Index < NumOfHobData; Index++) { + (*PeiServices)->SetMem (&FlashHobData, sizeof (EFI_FLASH_AREA_HOB_DATA), 0); + + FlashHobData.AreaType = mFlashAreaData[Index].AreaType; + FlashHobData.NumberOfEntries = 1; + FlashHobData.SubAreaData.Attributes = mFlashAreaData[Index].Attributes; + FlashHobData.SubAreaData.Base = FdBase + (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Base; + FlashHobData.SubAreaData.Length = (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Length; + + // + // We also update a PCD entry so that any driver that depend on + // PCD entry will get the information. + // + if (FlashHobData.AreaType == EFI_FLASH_AREA_EFI_VARIABLES) { + // BUGBUG: Tool team does not enable dynamic PCD so comment out following code + //PcdSet32 (PcdFlashNvStorageVariableBase, (UINT32) FlashHobData.SubAreaData.Base); + //PcdSet32 (PcdFlashNvStorageVariableSize, (UINT32) FlashHobData.SubAreaData.Length); + } + + if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_STATE) { + // BUGBUG: Tool team does not enable dynamic PCD so comment out following code + //PcdSet32 (PcdFlashNvStorageFtwWorkingBase, (UINT32) FlashHobData.SubAreaData.Base); + //PcdSet32 (PcdFlashNvStorageFtwWorkingSize, (UINT32) FlashHobData.SubAreaData.Length); + } + + if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_BACKUP) { + // BUGBUG: Tool team does not enable dynamic PCD so comment out following code + //PcdSet32 (PcdFlashNvStorageFtwSpareBase, (UINT32) FlashHobData.SubAreaData.Base); + //PcdSet32 (PcdFlashNvStorageFtwSpareSize, (UINT32) FlashHobData.SubAreaData.Length); + } + + switch (FlashHobData.AreaType) { + case EFI_FLASH_AREA_RECOVERY_BIOS: + case EFI_FLASH_AREA_MAIN_BIOS: + (*PeiServices)->CopyMem ( + &FlashHobData.AreaTypeGuid, + &gEfiFirmwareFileSystem2Guid, + sizeof (EFI_GUID) + ); + (*PeiServices)->CopyMem ( + &FlashHobData.SubAreaData.FileSystem, + &gEfiFirmwareVolumeBlockProtocolGuid, + sizeof (EFI_GUID) + ); + break; + + case EFI_FLASH_AREA_GUID_DEFINED: + (*PeiServices)->CopyMem ( + &FlashHobData.AreaTypeGuid, + &mFlashAreaData[Index].AreaTypeGuid, + sizeof (EFI_GUID) + ); + (*PeiServices)->CopyMem ( + &FlashHobData.SubAreaData.FileSystem, + &gEfiFirmwareVolumeBlockProtocolGuid, + sizeof (EFI_GUID) + ); + break; + + default: + break; + } + + BuildGuidDataHob ( + &gEfiFlashMapHobGuid, + &FlashHobData, + sizeof (EFI_FLASH_AREA_HOB_DATA) + ); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +GetAreaInfo ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_FLASH_MAP_PPI *This, + IN EFI_FLASH_AREA_TYPE AreaType, + IN EFI_GUID *AreaTypeGuid, + OUT UINT32 *NumEntries, + OUT EFI_FLASH_SUBAREA_ENTRY **Entries + ) +/*++ + + Routine Description: + Implementation of Flash Map PPI + +--*/ +// TODO: function comment is missing 'Arguments:' +// TODO: function comment is missing 'Returns:' +// TODO: PeiServices - add argument and description to function comment +// TODO: This - add argument and description to function comment +// TODO: AreaType - add argument and description to function comment +// TODO: AreaTypeGuid - add argument and description to function comment +// TODO: NumEntries - add argument and description to function comment +// TODO: Entries - add argument and description to function comment +// TODO: EFI_SUCCESS - add return value to function comment +// TODO: EFI_NOT_FOUND - add return value to function comment +{ + EFI_STATUS Status; + EFI_PEI_HOB_POINTERS Hob; + EFI_HOB_FLASH_MAP_ENTRY_TYPE *FlashMapEntry; + + Status = PeiServicesGetHobList (&Hob.Raw); + while (!END_OF_HOB_LIST (Hob)) { + if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION && CompareGuid (&Hob.Guid->Name, &gEfiFlashMapHobGuid)) { + FlashMapEntry = (EFI_HOB_FLASH_MAP_ENTRY_TYPE *) Hob.Raw; + if (AreaType == FlashMapEntry->AreaType) { + if (AreaType == EFI_FLASH_AREA_GUID_DEFINED) { + if (!CompareGuid (AreaTypeGuid, &FlashMapEntry->AreaTypeGuid)) { + goto NextHob; + } + } + + *NumEntries = FlashMapEntry->NumEntries; + *Entries = FlashMapEntry->Entries; + return EFI_SUCCESS; + } + } + NextHob: + Hob.Raw = GET_NEXT_HOB (Hob); + } + + return EFI_NOT_FOUND; +} diff --git a/Nt32Pkg/WinNtFlashMapPei/FlashMap.inf b/Nt32Pkg/WinNtFlashMapPei/FlashMap.inf new file mode 100644 index 0000000000..bcd1367c38 --- /dev/null +++ b/Nt32Pkg/WinNtFlashMapPei/FlashMap.inf @@ -0,0 +1,135 @@ +#/** @file +# Component description file for FlashMap PEI module +# +# This module installs FlashMap PPI which is used to get flash layout information. +# Copyright (c) 2006 - 2007, 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. +# +# +#**/ + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PeiFlashMap + FILE_GUID = 681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + ENTRY_POINT = PeimInitializeFlashMap + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +################################################################################ +# +# Sources Section - list of files that are required for the build to succeed. +# +################################################################################ + +[Sources.common] + FlashMap.c + + +################################################################################ +# +# Includes Section - list of Include locations that are required for +# this module. +# +################################################################################ + +[Includes] + $(WORKSPACE)/MdePkg/Include/Library + +################################################################################ +# +# Package Dependency Section - list of Package files that are required for +# this module. +# +################################################################################ + +[Packages] + Nt32Pkg/Nt32Pkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + + +################################################################################ +# +# Library Class Section - list of Library Classes that are required for +# this module. +# +################################################################################ + +[LibraryClasses] + PcdLib + BaseMemoryLib + PeiServicesLib + HobLib + PeimEntryPoint + DebugLib + + +################################################################################ +# +# Guid C Name Section - list of Guids that this module uses or produces. +# +################################################################################ + +[Guids] + gEfiFlashMapHobGuid # ALWAYS_CONSUMED Hob: GUID_EXTENSION + gEfiFirmwareFileSystem2Guid # ALWAYS_CONSUMED + + +################################################################################ +# +# Protocol C Name Section - list of Protocol and Protocol Notify C Names +# that this module uses or produces. +# +################################################################################ + +[Protocols] + gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_CONSUMED + + +################################################################################ +# +# PPI C Name Section - list of PPI and PPI Notify C Names that this module +# uses or produces. +# +################################################################################ + +[Ppis] + gNtFwhPpiGuid # PPI ALWAYS_CONSUMED + gPeiFlashMapPpiGuid # PPI ALWAYS_PRODUCED + + +################################################################################ +# +# Pcd DYNAMIC - list of PCDs that this module is coded for. +# +################################################################################ + +[PcdsDynamic.common] + PcdFlashNvStorageFtwWorkingSize|gEfiGenericPlatformTokenSpaceGuid + PcdFlashNvStorageFtwWorkingBase|gEfiGenericPlatformTokenSpaceGuid + PcdFlashNvStorageFtwSpareSize|gEfiGenericPlatformTokenSpaceGuid + PcdFlashNvStorageFtwSpareBase|gEfiGenericPlatformTokenSpaceGuid + PcdFlashNvStorageVariableSize|gEfiGenericPlatformTokenSpaceGuid + PcdFlashNvStorageVariableBase|gEfiGenericPlatformTokenSpaceGuid + diff --git a/Nt32Pkg/WinNtFlashMapPei/FlashMap.msa b/Nt32Pkg/WinNtFlashMapPei/FlashMap.msa new file mode 100644 index 0000000000..3bf00a08bc --- /dev/null +++ b/Nt32Pkg/WinNtFlashMapPei/FlashMap.msa @@ -0,0 +1,119 @@ + + + + PeiFlashMap + PEIM + 681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9 + 1.0 + Component description file for FlashMap PEI module + This module installs FlashMap PPI which is used to get flash layout information. + Copyright (c) 2006 - 2007, 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. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + PeiFlashMap + + + + DebugLib + + + PeimEntryPoint + + + HobLib + + + PeiServicesLib + + + BaseMemoryLib + + + PcdLib + + + + FlashMap.c + FlashMap.dxs + + + + + + + + + gEfiFirmwareVolumeBlockProtocolGuid + + + + + GUID_EXTENSION + + + + + gPeiFlashMapPpiGuid + + + gNtFwhPpiGuid + + + + + gEfiFirmwareFileSystemGuid + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00020000 + + PeimInitializeFlashMap + + + + + PcdFlashNvStorageVariableBase + gEfiGenericPlatformTokenSpaceGuid + The driver sets the NV Storage FV base address defined by this PCD. + This base address point to an EFI_FIRMWARE_VOLUMN_HEADER struct. Variable PEIM + will get the base address from this PCD. In NT emulator, this PCD is a DYNAMIC + type, as FD is mapped to process space by WinNT OS. On real platform, it is + normally a FIXED_AT_BUILD type as system memory map is fixed to BIOS. + + + PcdFlashNvStorageVariableSize + gEfiGenericPlatformTokenSpaceGuid + To get the NvStorage Variable size from this PCD. + + + PcdFlashNvStorageFtwSpareBase + gEfiGenericPlatformTokenSpaceGuid + To get base address of the FTW spare block section in NV firmware volume. + + + PcdFlashNvStorageFtwSpareSize + gEfiGenericPlatformTokenSpaceGuid + To get size of the FTW spare block section in NV firmware volume. + + + PcdFlashNvStorageFtwWorkingBase + gEfiGenericPlatformTokenSpaceGuid + To get base address of the FTW working block section in NV firmware volume. + + + PcdFlashNvStorageFtwWorkingSize + gEfiGenericPlatformTokenSpaceGuid + To get size of the FTW working block section in NV firmware volume. + + +