summaryrefslogtreecommitdiff
path: root/EdkUnixPkg/Pei
diff options
context:
space:
mode:
authortgingold <tgingold@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-06 14:59:06 +0000
committertgingold <tgingold@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-06 14:59:06 +0000
commitc9093a06e72ef16d2f3bd7ce0a2b9a172e9d048c (patch)
tree02dfc93be892697bf02f040b6c8429cecc8370ce /EdkUnixPkg/Pei
parent8ba7afaf2e9c682a5d17760e6dd5463b3a2b2d67 (diff)
downloadedk2-platforms-c9093a06e72ef16d2f3bd7ce0a2b9a172e9d048c.tar.xz
Unix version of EFI emulator
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2182 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkUnixPkg/Pei')
-rw-r--r--EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c132
-rw-r--r--EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs29
-rw-r--r--EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa74
-rw-r--r--EdkUnixPkg/Pei/BootMode/BootMode.c85
-rw-r--r--EdkUnixPkg/Pei/BootMode/BootMode.dxs29
-rw-r--r--EdkUnixPkg/Pei/BootMode/BootMode.msa65
-rw-r--r--EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c123
-rw-r--r--EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs29
-rw-r--r--EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa63
-rw-r--r--EdkUnixPkg/Pei/FlashMap/FlashMap.c302
-rw-r--r--EdkUnixPkg/Pei/FlashMap/FlashMap.dxs28
-rw-r--r--EdkUnixPkg/Pei/FlashMap/FlashMap.msa126
-rw-r--r--EdkUnixPkg/Pei/UnixStuff/UnixStuff.c73
-rw-r--r--EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs29
-rw-r--r--EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa69
15 files changed, 1256 insertions, 0 deletions
diff --git a/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c
new file mode 100644
index 0000000000..35c61affda
--- /dev/null
+++ b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c
@@ -0,0 +1,132 @@
+/*++
+
+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:
+ UnixAutoscan.c
+
+Abstract:
+ This PEIM to abstract memory auto-scan in an Unix environment.
+
+Revision History
+
+--*/
+
+EFI_STATUS
+EFIAPI
+PeimInitializeUnixAutoScan (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+ Perform a call-back into the SEC simulator to get a memory value
+
+Arguments:
+ FfsHeader - General purpose data available to every PEIM
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
+ PEI_UNIX_AUTOSCAN_PPI *PeiUnixService;
+ UINT64 MemorySize;
+ EFI_PHYSICAL_ADDRESS MemoryBase;
+ PEI_BASE_MEMORY_TEST_PPI *MemoryTestPpi;
+ EFI_PHYSICAL_ADDRESS ErrorAddress;
+ UINTN Index;
+ EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
+
+
+ DEBUG ((EFI_D_ERROR, "Unix Autoscan PEIM Loaded\n"));
+
+ //
+ // Get the PEI NT Autoscan PPI
+ //
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gPeiUnixAutoScanPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&PeiUnixService // PPI
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get the Memory Test PPI
+ //
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gPeiBaseMemoryTestPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&MemoryTestPpi
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Index = 0;
+ do {
+ Status = PeiUnixService->UnixAutoScan (Index, &MemoryBase, &MemorySize);
+ if (!EFI_ERROR (Status)) {
+ Attributes =
+ (
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+ EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
+ );
+
+ if (Index == 0) {
+ //
+ // For the first area register it as PEI tested memory
+ //
+ Status = MemoryTestPpi->BaseMemoryTest (
+ PeiServices,
+ MemoryTestPpi,
+ MemoryBase,
+ MemorySize,
+ Quick,
+ &ErrorAddress
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register the "tested" memory with the PEI Core
+ //
+ Status = (**PeiServices).InstallPeiMemory (PeiServices, MemoryBase, MemorySize);
+ ASSERT_EFI_ERROR (Status);
+
+ Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
+ }
+
+ BuildResourceDescriptorHob (
+ EFI_RESOURCE_SYSTEM_MEMORY,
+ Attributes,
+ MemoryBase,
+ MemorySize
+ );
+ }
+ Index++;
+ } while (!EFI_ERROR (Status));
+
+ //
+ // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
+ //
+ BuildCpuHob (36, 16);
+
+ return Status;
+}
diff --git a/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs
new file mode 100644
index 0000000000..8ad908860b
--- /dev/null
+++ b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs
@@ -0,0 +1,29 @@
+/*++
+
+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:
+
+ UnixAutoscan.dxs
+
+Abstract:
+
+ Dependency expression file for UnixAutoscan.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ PEI_UNIX_AUTOSCAN_PPI_GUID AND EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI AND PEI_BASE_MEMORY_TEST_GUID
+DEPENDENCY_END
+
+
diff --git a/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa
new file mode 100644
index 0000000000..60830b613c
--- /dev/null
+++ b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <MsaHeader>
+ <ModuleName>UnixAutoScan</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>f3f36cb0-8985-11db-b195-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component description file for UnixAutoScan module</Abstract>
+ <Description>This module abstracts memory auto-scan in a Unix environment.</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>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.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>UnixAutoScan</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeimEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>HobLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesTablePointerLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>UnixAutoScan.c</Filename>
+ <Filename>UnixAutoScan.dxs</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gPeiUnixAutoScanPpiGuid</PpiCName>
+ </Ppi>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gPeiBaseMemoryTestPpiGuid</PpiCName>
+ </Ppi>
+ <Ppi Usage="ALWAYS_PRODUCED">
+ <PpiCName>gEfiPeiMemoryDiscoveredPpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeUnixAutoScan</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/BootMode/BootMode.c b/EdkUnixPkg/Pei/BootMode/BootMode.c
new file mode 100644
index 0000000000..b368dc1f39
--- /dev/null
+++ b/EdkUnixPkg/Pei/BootMode/BootMode.c
@@ -0,0 +1,85 @@
+/*++
+
+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:
+
+ BootMode.c
+
+Abstract:
+
+ Tiano PEIM to provide the platform support functionality within Windows
+
+--*/
+
+
+
+//
+// Module globals
+//
+EFI_PEI_PPI_DESCRIPTOR mPpiListBootMode = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiMasterBootModePpiGuid,
+ NULL
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiBootInRecoveryModePpiGuid,
+ NULL
+};
+
+EFI_STATUS
+EFIAPI
+InitializeBootMode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Peform the boot mode determination logic
+
+Arguments:
+
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ Status - EFI_SUCCESS if the boot mode could be set
+
+--*/
+// TODO: FfsHeader - add argument and description to function comment
+{
+ EFI_STATUS Status;
+ UINTN BootMode;
+
+ DEBUG ((EFI_D_ERROR, "Unix Boot Mode PEIM Loaded\n"));
+
+ //
+ // Let's assume things are OK if not told otherwise
+ // Should we read an environment variable in order to easily change this?
+ //
+ BootMode = BOOT_WITH_FULL_CONFIGURATION;
+
+ Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);
+ ASSERT_EFI_ERROR (Status);
+
+ if (BootMode == BOOT_IN_RECOVERY_MODE) {
+ Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ return Status;
+}
diff --git a/EdkUnixPkg/Pei/BootMode/BootMode.dxs b/EdkUnixPkg/Pei/BootMode/BootMode.dxs
new file mode 100644
index 0000000000..fd91a09892
--- /dev/null
+++ b/EdkUnixPkg/Pei/BootMode/BootMode.dxs
@@ -0,0 +1,29 @@
+/*++
+
+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:
+
+ BootMode.dxs
+
+Abstract:
+
+ Dependency expression file for BootMode.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ TRUE
+DEPENDENCY_END
+
+
diff --git a/EdkUnixPkg/Pei/BootMode/BootMode.msa b/EdkUnixPkg/Pei/BootMode/BootMode.msa
new file mode 100644
index 0000000000..5b2c8d843c
--- /dev/null
+++ b/EdkUnixPkg/Pei/BootMode/BootMode.msa
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>BootMode</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>f3ff9aee-8985-11db-b133-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component description file for BootMode module</Abstract>
+ <Description>This module provides platform specific function to detect boot mode.</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>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.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>BootMode</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeimEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesTablePointerLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>BootMode.c</Filename>
+ <Filename>BootMode.dxs</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <PPIs>
+ <Ppi Usage="SOMETIMES_PRODUCED">
+ <PpiCName>gEfiPeiBootInRecoveryModePpiGuid</PpiCName>
+ </Ppi>
+ <Ppi Usage="ALWAYS_PRODUCED">
+ <PpiCName>gEfiPeiMasterBootModePpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>InitializeBootMode</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c
new file mode 100644
index 0000000000..8bec9f3566
--- /dev/null
+++ b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c
@@ -0,0 +1,123 @@
+/*++
+
+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:
+ UnixFwh.c
+
+Abstract:
+ PEIM to abstract construction of firmware volume in an Unix environment.
+
+Revision History
+
+--*/
+
+
+#include <FlashLayout.h>
+
+
+EFI_STATUS
+EFIAPI
+PeimInitializeUnixFwh (
+ 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;
+ UNIX_FWH_PPI *FwhPpi;
+ EFI_PHYSICAL_ADDRESS FdBase;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
+ UINT64 FdSize;
+ UINTN Index;
+
+ DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));
+
+ //
+ // Get the Fwh Information PPI
+ //
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gUnixFwhPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&FwhPpi // PPI
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Index = 0;
+ do {
+ //
+ // Get information about all the FD's in the system
+ //
+ Status = FwhPpi->UnixFwh (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/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs
new file mode 100644
index 0000000000..3302a5de8e
--- /dev/null
+++ b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs
@@ -0,0 +1,29 @@
+/*++
+
+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:
+
+ UnixFwh.dxs
+
+Abstract:
+
+ Dependency expression file for UnixFwh PEIM.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ UNIX_FWH_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID
+DEPENDENCY_END
+
+
diff --git a/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa
new file mode 100644
index 0000000000..f46801a622
--- /dev/null
+++ b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>UnixFwh</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>f40b7864-8985-11db-af21-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component description file for WinNtFwh module</Abstract>
+ <Description>This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices
+ on the NT32 emulator.</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>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.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>UnixFwh</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeimEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>HobLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesTablePointerLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>UnixFwh.c</Filename>
+ <Filename>UnixFwh.dxs</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gUnixFwhPpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeUnixFwh</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/FlashMap/FlashMap.c b/EdkUnixPkg/Pei/FlashMap/FlashMap.c
new file mode 100644
index 0000000000..9c57f2e9c4
--- /dev/null
+++ b/EdkUnixPkg/Pei/FlashMap/FlashMap.c
@@ -0,0 +1,302 @@
+/*++
+
+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
+
+--*/
+
+
+#include <FlashLayout.h>
+
+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;
+ UNIX_FWH_PPI *UnixFwhPpi;
+ 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 (
+ &gUnixFwhPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&UnixFwhPpi // PPI
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Assume that FD0 contains the Flash map.
+ //
+ Status = UnixFwhPpi->UnixFwh (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) {
+ PcdSet32 (PcdFlashNvStorageVariableBase, (UINT32) FlashHobData.SubAreaData.Base);
+ PcdSet32 (PcdFlashNvStorageVariableSize, (UINT32) FlashHobData.SubAreaData.Length);
+ }
+
+ if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_STATE) {
+ PcdSet32 (PcdFlashNvStorageFtwWorkingBase, (UINT32) FlashHobData.SubAreaData.Base);
+ PcdSet32 (PcdFlashNvStorageFtwWorkingSize, (UINT32) FlashHobData.SubAreaData.Length);
+ }
+
+ if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_BACKUP) {
+ 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,
+ &gEfiFirmwareFileSystemGuid,
+ 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 ((VOID **)&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/EdkUnixPkg/Pei/FlashMap/FlashMap.dxs b/EdkUnixPkg/Pei/FlashMap/FlashMap.dxs
new file mode 100644
index 0000000000..f75e7aa31e
--- /dev/null
+++ b/EdkUnixPkg/Pei/FlashMap/FlashMap.dxs
@@ -0,0 +1,28 @@
+/*++
+
+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.dxs
+
+Abstract:
+
+ Dependency expression file for FindFv.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ PCD_PPI_GUID
+DEPENDENCY_END
+
diff --git a/EdkUnixPkg/Pei/FlashMap/FlashMap.msa b/EdkUnixPkg/Pei/FlashMap/FlashMap.msa
new file mode 100644
index 0000000000..7576795143
--- /dev/null
+++ b/EdkUnixPkg/Pei/FlashMap/FlashMap.msa
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>PeiFlashMap</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>f417814a-8985-11db-8983-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Component description file for FlashMap PEI module</Abstract>
+ <Description>This module installs FlashMap PPI which is used to get flash layout information.</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>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.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>PeiFlashMap</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeimEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>HobLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesTablePointerLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PcdLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>FlashMap.c</Filename>
+ <Filename>FlashMap.dxs</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">
+ <ProtocolCName>gEfiFirmwareVolumeBlockProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <PPIs>
+ <Ppi Usage="ALWAYS_PRODUCED">
+ <PpiCName>gPeiFlashMapPpiGuid</PpiCName>
+ </Ppi>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gUnixFwhPpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Guids>
+ <GuidCNames Usage="ALWAYS_CONSUMED">
+ <GuidCName>gEfiFlashMapHobGuid</GuidCName>
+ </GuidCNames>
+ <GuidCNames Usage="ALWAYS_CONSUMED">
+ <GuidCName>gEfiFirmwareFileSystemGuid</GuidCName>
+ </GuidCNames>
+ <GuidCNames Usage="ALWAYS_CONSUMED">
+ <GuidCName>gEfiSystemNvDataHobGuid</GuidCName>
+ </GuidCNames>
+ </Guids>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeFlashMap</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+ <PcdCoded>
+ <PcdEntry PcdItemType="DYNAMIC">
+ <C_Name>PcdFlashNvStorageVariableBase</C_Name>
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText>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.
+ </HelpText>
+ </PcdEntry>
+ <PcdEntry PcdItemType="DYNAMIC">
+ <C_Name>PcdFlashNvStorageVariableSize</C_Name>
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText>
+ To get the NvStorage Variable size from this PCD.
+ </HelpText>
+ </PcdEntry>
+ <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">
+ <C_Name>PcdFlashNvStorageFtwSpareBase</C_Name>
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText>To get base address of the FTW spare block section in NV firmware volume.</HelpText>
+ </PcdEntry>
+ <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">
+ <C_Name>PcdFlashNvStorageFtwSpareSize</C_Name>
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText>To get size of the FTW spare block section in NV firmware volume.</HelpText>
+ </PcdEntry>
+ <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">
+ <C_Name>PcdFlashNvStorageFtwWorkingBase</C_Name>
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText>To get base address of the FTW working block section in NV firmware volume.</HelpText>
+ </PcdEntry>
+ <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">
+ <C_Name>PcdFlashNvStorageFtwWorkingSize</C_Name>
+ <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText>To get size of the FTW working block section in NV firmware volume.</HelpText>
+ </PcdEntry>
+ </PcdCoded>
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/UnixStuff/UnixStuff.c b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.c
new file mode 100644
index 0000000000..40be01b1c4
--- /dev/null
+++ b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.c
@@ -0,0 +1,73 @@
+/*++
+
+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:
+
+ UnixStuff.c
+
+Abstract:
+
+ Tiano PEIM to abstract construction of firmware volume in a Unix environment.
+
+Revision History
+
+--*/
+
+
+
+EFI_STATUS
+EFIAPI
+PeimInitializeUnixStuff (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Perform a call-back into the SEC simulator to get Unix Stuff
+
+Arguments:
+
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ None
+
+--*/
+// TODO: FfsHeader - add argument and description to function comment
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
+ PEI_UNIX_THUNK_PPI *PeiUnixService;
+ VOID *Ptr;
+
+ DEBUG ((EFI_D_ERROR, "Unix Stuff PEIM Loaded\n"));
+
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gPeiUnixThunkPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&PeiUnixService // PPI
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Ptr = PeiUnixService->UnixThunk ();
+
+ BuildGuidDataHob (
+ &gEfiUnixThunkProtocolGuid, // Guid
+ &Ptr, // Buffer
+ sizeof (VOID *) // Sizeof Buffer
+ );
+ return Status;
+}
diff --git a/EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs
new file mode 100644
index 0000000000..b2e8d04708
--- /dev/null
+++ b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs
@@ -0,0 +1,29 @@
+/*++
+
+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:
+
+ UnixStuff.dxs
+
+Abstract:
+
+ Dependency expression file for UnixStuff PEIM.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ PEI_UNIX_THUNK_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID
+DEPENDENCY_END
+
+
diff --git a/EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa
new file mode 100644
index 0000000000..d7760bc82a
--- /dev/null
+++ b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+ <MsaHeader>
+ <ModuleName>UnixStuff</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>f4239aa2-8985-11db-af82-0040d02b1835</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Stuff driver</Abstract>
+ <Description>
+ Tiano PEIM to abstract construction of firmware volume in a Windows NT environment.
+ </Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>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.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>UnixStuff</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeimEntryPoint</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>HobLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesTablePointerLib</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>UnixStuff.c</Filename>
+ <Filename>UnixStuff.dxs</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+ </PackageDependencies>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">
+ <ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>
+ </Protocol>
+ </Protocols>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gPeiUnixThunkPpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeUnixStuff</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>