summaryrefslogtreecommitdiffstats
path: root/EdkNt32Pkg/Pei
diff options
context:
space:
mode:
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-04-21 22:54:32 +0000
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-04-21 22:54:32 +0000
commit878ddf1fc3540a715f63594ed22b6929e881afb4 (patch)
treec56c44dac138137b510e1fba7c3efe5e4d84bea2 /EdkNt32Pkg/Pei
downloadedk2-878ddf1fc3540a715f63594ed22b6929e881afb4.tar.gz
edk2-878ddf1fc3540a715f63594ed22b6929e881afb4.tar.bz2
edk2-878ddf1fc3540a715f63594ed22b6929e881afb4.zip
Initial import.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkNt32Pkg/Pei')
-rw-r--r--EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.mbd43
-rw-r--r--EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.msa68
-rw-r--r--EdkNt32Pkg/Pei/Autoscan/WinNtAutoscan.dxs29
-rw-r--r--EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.c132
-rw-r--r--EdkNt32Pkg/Pei/Autoscan/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/BootMode/BootMode.c85
-rw-r--r--EdkNt32Pkg/Pei/BootMode/BootMode.dxs29
-rw-r--r--EdkNt32Pkg/Pei/BootMode/BootMode.mbd42
-rw-r--r--EdkNt32Pkg/Pei/BootMode/BootMode.msa59
-rw-r--r--EdkNt32Pkg/Pei/BootMode/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.dxs29
-rw-r--r--EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.mbd43
-rw-r--r--EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.msa69
-rw-r--r--EdkNt32Pkg/Pei/FirmwareVolume/WinntFwh.c123
-rw-r--r--EdkNt32Pkg/Pei/FirmwareVolume/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/FlashMap/FlashMap.c273
-rw-r--r--EdkNt32Pkg/Pei/FlashMap/FlashMap.dxs28
-rw-r--r--EdkNt32Pkg/Pei/FlashMap/FlashMap.mbd43
-rw-r--r--EdkNt32Pkg/Pei/FlashMap/FlashMap.msa101
-rw-r--r--EdkNt32Pkg/Pei/FlashMap/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.c150
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.dxs28
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.h111
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.mbd44
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.msa70
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/Nt32/PlatformStatusCode.c162
-rw-r--r--EdkNt32Pkg/Pei/MonoStatusCode/Nt32/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.c657
-rw-r--r--EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.dxs25
-rw-r--r--EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.h53
-rw-r--r--EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.mbd41
-rw-r--r--EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.msa72
-rw-r--r--EdkNt32Pkg/Pei/PcdEmulator/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.dxs29
-rw-r--r--EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.mbd43
-rw-r--r--EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.msa68
-rw-r--r--EdkNt32Pkg/Pei/WinNtStuff/build.xml47
-rw-r--r--EdkNt32Pkg/Pei/WinNtStuff/winntstuff.c73
38 files changed, 3151 insertions, 0 deletions
diff --git a/EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.mbd b/EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.mbd
new file mode 100644
index 0000000000..c6a123ddf9
--- /dev/null
+++ b/EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.mbd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>WinNtAutoScan</BaseName>
+ <Guid>BE0FEABA-3443-4919-9F3A-2D4216329EA9</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-19 15:17</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeimEntryPoint</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiCoreLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiHobLib</Library>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>BaseLib</Library>
+ </Libraries>
+ <BuildOptions ToolChain="MSFT">
+ <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
+ </BuildOptions>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.msa b/EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.msa
new file mode 100644
index 0000000000..5141634516
--- /dev/null
+++ b/EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.msa
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>WinNtAutoScan</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>BE0FEABA-3443-4919-9F3A-2D4216329EA9</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for WinNtAutoScan module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>0</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-19 15:17</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>WinNtAutoScan.c</Filename>
+ <Filename>WinNtAutoscan.dxs</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <Hobs>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="RESOURCE_DESCRIPTOR">
+ <Name>EFI_RESOURCE_SYSTEM_MEMORY</Name>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="CPU"></Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">NtAutoScan</Ppi>
+ <Ppi Usage="ALWAYS_CONSUMED">BaseMemoryTest</Ppi>
+ <Ppi Usage="ALWAYS_PRODUCED">MemoryDiscovered</Ppi>
+ </PPIs>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeWinNtAutoScan</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/Autoscan/WinNtAutoscan.dxs b/EdkNt32Pkg/Pei/Autoscan/WinNtAutoscan.dxs
new file mode 100644
index 0000000000..5b3af0e337
--- /dev/null
+++ b/EdkNt32Pkg/Pei/Autoscan/WinNtAutoscan.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:
+
+ WinNtAutoscan.dxs
+
+Abstract:
+
+ Dependency expression file for WinNtAutoscan.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ PEI_NT_AUTOSCAN_PPI_GUID AND EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI AND PEI_BASE_MEMORY_TEST_GUID
+DEPENDENCY_END
+
+
diff --git a/EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.c b/EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.c
new file mode 100644
index 0000000000..c465ce68ca
--- /dev/null
+++ b/EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.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:
+ WinNtAutoscan.c
+
+Abstract:
+ Tiano PEIM to abstract memory auto-scan in a Windows NT environment.
+
+Revision History
+
+--*/
+
+EFI_STATUS
+EFIAPI
+PeimInitializeWinNtAutoScan (
+ 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_NT_AUTOSCAN_PPI *PeiNtService;
+ 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, "NT 32 Autoscan PEIM Loaded\n"));
+
+ //
+ // Get the PEI NT Autoscan PPI
+ //
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gPeiNtAutoScanPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ &PeiNtService // PPI
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get the Memory Test PPI
+ //
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gPeiBaseMemoryTestPpiGuid,
+ 0,
+ NULL,
+ &MemoryTestPpi
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Index = 0;
+ do {
+ Status = PeiNtService->NtAutoScan (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/EdkNt32Pkg/Pei/Autoscan/build.xml b/EdkNt32Pkg/Pei/Autoscan/build.xml
new file mode 100644
index 0000000000..bdbd4c930e
--- /dev/null
+++ b/EdkNt32Pkg/Pei/Autoscan/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="WinNtAutoScan"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\Autoscan"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="WinNtAutoScan">
+ <GenBuild baseName="WinNtAutoScan" mbdFilename="${MODULE_DIR}\WinNtAutoScan.mbd" msaFilename="${MODULE_DIR}\WinNtAutoScan.msa"/>
+ </target>
+ <target depends="WinNtAutoScan_clean" name="clean"/>
+ <target depends="WinNtAutoScan_cleanall" name="cleanall"/>
+ <target name="WinNtAutoScan_clean">
+ <OutputDirSetup baseName="WinNtAutoScan" mbdFilename="${MODULE_DIR}\WinNtAutoScan.mbd" msaFilename="${MODULE_DIR}\WinNtAutoScan.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\WinNtAutoScan_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\WinNtAutoScan_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="WinNtAutoScan_cleanall">
+ <OutputDirSetup baseName="WinNtAutoScan" mbdFilename="${MODULE_DIR}\WinNtAutoScan.mbd" msaFilename="${MODULE_DIR}\WinNtAutoScan.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\WinNtAutoScan_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\WinNtAutoScan_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**WinNtAutoScan*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/BootMode/BootMode.c b/EdkNt32Pkg/Pei/BootMode/BootMode.c
new file mode 100644
index 0000000000..955c7595dc
--- /dev/null
+++ b/EdkNt32Pkg/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, "NT32 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/EdkNt32Pkg/Pei/BootMode/BootMode.dxs b/EdkNt32Pkg/Pei/BootMode/BootMode.dxs
new file mode 100644
index 0000000000..fd91a09892
--- /dev/null
+++ b/EdkNt32Pkg/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/EdkNt32Pkg/Pei/BootMode/BootMode.mbd b/EdkNt32Pkg/Pei/BootMode/BootMode.mbd
new file mode 100644
index 0000000000..5dd1a6fe20
--- /dev/null
+++ b/EdkNt32Pkg/Pei/BootMode/BootMode.mbd
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>BootMode</BaseName>
+ <Guid>B7611005-1F26-45ba-A3DB-01F39DDB2785</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-19 15:17</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeimEntryPoint</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiCoreLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>BaseLib</Library>
+ </Libraries>
+ <BuildOptions ToolChain="MSFT">
+ <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
+ </BuildOptions>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/BootMode/BootMode.msa b/EdkNt32Pkg/Pei/BootMode/BootMode.msa
new file mode 100644
index 0000000000..accb0b5ba3
--- /dev/null
+++ b/EdkNt32Pkg/Pei/BootMode/BootMode.msa
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>BootMode</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>B7611005-1F26-45ba-A3DB-01F39DDB2785</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for Fwh module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>0</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-19 15:17</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>BootMode.c</Filename>
+ <Filename>BootMode.dxs</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <PPIs>
+ <Ppi Usage="SOMETIMES_PRODUCED">BootInRecoveryMode</Ppi>
+ <Ppi Usage="ALWAYS_PRODUCED">MasterBootMode</Ppi>
+ </PPIs>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>InitializeBootMode</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/BootMode/build.xml b/EdkNt32Pkg/Pei/BootMode/build.xml
new file mode 100644
index 0000000000..cd67235b3a
--- /dev/null
+++ b/EdkNt32Pkg/Pei/BootMode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="BootMode"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\BootMode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="BootMode">
+ <GenBuild baseName="BootMode" mbdFilename="${MODULE_DIR}\BootMode.mbd" msaFilename="${MODULE_DIR}\BootMode.msa"/>
+ </target>
+ <target depends="BootMode_clean" name="clean"/>
+ <target depends="BootMode_cleanall" name="cleanall"/>
+ <target name="BootMode_clean">
+ <OutputDirSetup baseName="BootMode" mbdFilename="${MODULE_DIR}\BootMode.mbd" msaFilename="${MODULE_DIR}\BootMode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\BootMode_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\BootMode_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="BootMode_cleanall">
+ <OutputDirSetup baseName="BootMode" mbdFilename="${MODULE_DIR}\BootMode.mbd" msaFilename="${MODULE_DIR}\BootMode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\BootMode_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\BootMode_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**BootMode*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.dxs b/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.dxs
new file mode 100644
index 0000000000..6270ef0db7
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.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:
+
+ WinNtFwh.dxs
+
+Abstract:
+
+ Dependency expression file for WinNtFwh PEIM.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ NT_FWH_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID
+DEPENDENCY_END
+
+
diff --git a/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.mbd b/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.mbd
new file mode 100644
index 0000000000..3c61664ecc
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.mbd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>WinNtFwh</BaseName>
+ <Guid>F0384FFD-8633-452f-9010-F6B7D2EAE2F1</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-23 10:33</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeimEntryPoint</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiCoreLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiHobLib</Library>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>BaseLib</Library>
+ </Libraries>
+ <BuildOptions ToolChain="MSFT">
+ <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
+ </BuildOptions>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.msa b/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.msa
new file mode 100644
index 0000000000..3101d4866e
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.msa
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>WinNtFwh</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>F0384FFD-8633-452f-9010-F6B7D2EAE2F1</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for WinNtFwh module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>0</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-23 10:33</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>WinNtFwh.c</Filename>
+ <Filename>WinNtFwh.dxs</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <Hobs>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="FIRMWARE_VOLUME">
+ <Name>FvRecovery.fv</Name>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="RESOURCE_DESCRIPTOR">
+ <Name>EFI_RESOURCE_FIRMWARE_DEVICE</Name>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="FIRMWARE_VOLUME">
+ <Name>NVSTORAGE.fv</Name>
+ </Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">NtFwh</Ppi>
+ </PPIs>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeWinNtFwh</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/FirmwareVolume/WinntFwh.c b/EdkNt32Pkg/Pei/FirmwareVolume/WinntFwh.c
new file mode 100644
index 0000000000..3764cb78ca
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FirmwareVolume/WinntFwh.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:
+ WinNtFwh.c
+
+Abstract:
+ PEIM to abstract construction of firmware volume in a Windows NT environment.
+
+Revision History
+
+--*/
+
+
+#include <FlashLayout.h>
+
+
+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/EdkNt32Pkg/Pei/FirmwareVolume/build.xml b/EdkNt32Pkg/Pei/FirmwareVolume/build.xml
new file mode 100644
index 0000000000..7aa147bb9e
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FirmwareVolume/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="WinNtFwh"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\FirmwareVolume"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="WinNtFwh">
+ <GenBuild baseName="WinNtFwh" mbdFilename="${MODULE_DIR}\WinNtFwh.mbd" msaFilename="${MODULE_DIR}\WinNtFwh.msa"/>
+ </target>
+ <target depends="WinNtFwh_clean" name="clean"/>
+ <target depends="WinNtFwh_cleanall" name="cleanall"/>
+ <target name="WinNtFwh_clean">
+ <OutputDirSetup baseName="WinNtFwh" mbdFilename="${MODULE_DIR}\WinNtFwh.mbd" msaFilename="${MODULE_DIR}\WinNtFwh.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\WinNtFwh_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\WinNtFwh_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="WinNtFwh_cleanall">
+ <OutputDirSetup baseName="WinNtFwh" mbdFilename="${MODULE_DIR}\WinNtFwh.mbd" msaFilename="${MODULE_DIR}\WinNtFwh.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\WinNtFwh_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\WinNtFwh_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**WinNtFwh*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/FlashMap/FlashMap.c b/EdkNt32Pkg/Pei/FlashMap/FlashMap.c
new file mode 100644
index 0000000000..a8f7ba06ad
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FlashMap/FlashMap.c
@@ -0,0 +1,273 @@
+/*++
+
+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
+ },
+ //
+ // 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
+ },
+ //
+ // 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
+ },
+ //
+ // Recovery FV
+ //
+ {
+ EFI_WINNT_FIRMWARE_OFFSET,
+ EFI_WINNT_FIRMWARE_LENGTH,
+ EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,
+ EFI_FLASH_AREA_RECOVERY_BIOS
+ },
+ //
+ // 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
+ },
+};
+
+
+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 = PeiCoreInstallPpi (&mPpiListFlashMap);
+ ASSERT_EFI_ERROR (Status);
+
+
+ //
+ // Get the Fwh Information PPI
+ //
+ Status = PeiCoreLocatePpi (
+ &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;
+
+ 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,
+ &gEfiSystemNvDataHobGuid,
+ 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 = PeiCoreGetHobList (&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)) {
+ continue;
+ }
+ }
+
+ *NumEntries = FlashMapEntry->NumEntries;
+ *Entries = FlashMapEntry->Entries;
+ return EFI_SUCCESS;
+ }
+ }
+
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+
+ return EFI_NOT_FOUND;
+}
diff --git a/EdkNt32Pkg/Pei/FlashMap/FlashMap.dxs b/EdkNt32Pkg/Pei/FlashMap/FlashMap.dxs
new file mode 100644
index 0000000000..0c197de817
--- /dev/null
+++ b/EdkNt32Pkg/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
+ TRUE
+DEPENDENCY_END
+
diff --git a/EdkNt32Pkg/Pei/FlashMap/FlashMap.mbd b/EdkNt32Pkg/Pei/FlashMap/FlashMap.mbd
new file mode 100644
index 0000000000..8c38ee9f59
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FlashMap/FlashMap.mbd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>PeiFlashMap</BaseName>
+ <Guid>681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-23 10:43</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeimEntryPoint</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiCoreLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiHobLib</Library>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>BaseLib</Library>
+ </Libraries>
+ <BuildOptions ToolChain="MSFT">
+ <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
+ </BuildOptions>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/FlashMap/FlashMap.msa b/EdkNt32Pkg/Pei/FlashMap/FlashMap.msa
new file mode 100644
index 0000000000..c199978fb6
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FlashMap/FlashMap.msa
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>PeiFlashMap</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for FlashMap PEI module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>0</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-23 10:43</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>FlashMap.c</Filename>
+ <Filename>FlashMap.dxs</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">FirmwareVolumeBlock</Protocol>
+ </Protocols>
+ <Hobs>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>VariableArea</Name>
+ <C_Name>gEfiFlashMapHobGuid</C_Name>
+ <Guid>0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59</Guid>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>FtwBackupBlock</Name>
+ <C_Name>gEfiFlashMapHobGuid</C_Name>
+ <Guid>0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59</Guid>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>FtwStateArea</Name>
+ <C_Name>gEfiFlashMapHobGuid</C_Name>
+ <Guid>0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59</Guid>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>RecoveryBios</Name>
+ <C_Name>gEfiFlashMapHobGuid</C_Name>
+ <Guid>0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59</Guid>
+ </Hob>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>SystemNvDataHob</Name>
+ <C_Name>gEfiFlashMapHobGuid</C_Name>
+ <Guid>0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59</Guid>
+ </Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="ALWAYS_PRODUCED">FlashMap</Ppi>
+ <Ppi Usage="ALWAYS_CONSUMED">NtFwh</Ppi>
+ </PPIs>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>FlashMapHob</C_Name>
+ </GuidEntry>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>FirmwareFileSystem</C_Name>
+ </GuidEntry>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>SystemNvDataHob</C_Name>
+ </GuidEntry>
+ </Guids>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeFlashMap</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/FlashMap/build.xml b/EdkNt32Pkg/Pei/FlashMap/build.xml
new file mode 100644
index 0000000000..b388551a3a
--- /dev/null
+++ b/EdkNt32Pkg/Pei/FlashMap/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="PeiFlashMap"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\FlashMap"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="PeiFlashMap">
+ <GenBuild baseName="PeiFlashMap" mbdFilename="${MODULE_DIR}\FlashMap.mbd" msaFilename="${MODULE_DIR}\FlashMap.msa"/>
+ </target>
+ <target depends="PeiFlashMap_clean" name="clean"/>
+ <target depends="PeiFlashMap_cleanall" name="cleanall"/>
+ <target name="PeiFlashMap_clean">
+ <OutputDirSetup baseName="PeiFlashMap" mbdFilename="${MODULE_DIR}\FlashMap.mbd" msaFilename="${MODULE_DIR}\FlashMap.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\PeiFlashMap_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\PeiFlashMap_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="PeiFlashMap_cleanall">
+ <OutputDirSetup baseName="PeiFlashMap" mbdFilename="${MODULE_DIR}\FlashMap.mbd" msaFilename="${MODULE_DIR}\FlashMap.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\PeiFlashMap_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\PeiFlashMap_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**PeiFlashMap*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.c b/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.c
new file mode 100644
index 0000000000..27c73f576e
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.c
@@ -0,0 +1,150 @@
+/*++
+
+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:
+
+ MonoStatusCode.c
+
+Abstract:
+
+ PEIM to provide the status code functionality, to aid in system debug.
+ It includes output to 0x80 port and/or to serial port.
+ This PEIM is monolithic. Different platform should provide different library.
+
+--*/
+
+#include "MonoStatusCode.h"
+
+//
+// Module globals
+//
+//
+EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi = { PlatformReportStatusCode };
+
+EFI_PEI_PPI_DESCRIPTOR mPpiListStatusCode = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiStatusCodePpiGuid,
+ &mStatusCodePpi
+};
+
+//
+// Function implemenations
+//
+EFI_STATUS
+EFIAPI
+TranslateDxeStatusCodeToPeiStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Translate from a DXE status code interface into a PEI-callable
+ interface, making the PEI the least common denominator..
+
+Arguments:
+
+ Same as DXE ReportStatusCode RT service
+
+Returns:
+
+ None
+
+--*/
+{
+ return PlatformReportStatusCode (NULL, CodeType, Value, Instance, CallerId, Data);
+}
+
+EFI_STATUS
+EFIAPI
+InitializeDxeReportStatusCode (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Build a hob describing the status code listener that has been installed.
+ This will be used by DXE code until a runtime status code listener is
+ installed.
+
+Arguments:
+
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ Status - EFI_SUCCESS if the interface could be successfully
+ installed
+
+--*/
+{
+ VOID *Instance;
+ VOID *HobData;
+
+ Instance = (VOID *) (UINTN) TranslateDxeStatusCodeToPeiStatusCode;
+
+ HobData = BuildGuidDataHob (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ &Instance,
+ sizeof (VOID *)
+ );
+
+ ASSERT (HobData != NULL);
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+InitializeMonoStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Initialize the platform status codes and publish the platform status code
+ PPI.
+
+Arguments:
+
+ FfsHeader - FV this PEIM was loaded from.
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ Status - EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Initialize status code listeners.
+ //
+ PlatformInitializeStatusCode (FfsHeader, PeiServices);
+
+ //
+ // Publish the status code capability to other modules
+ //
+ Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiListStatusCode);
+
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((EFI_D_ERROR, "\nMono Status Code PEIM Loaded\n"));
+
+ return ;
+}
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.dxs b/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.dxs
new file mode 100644
index 0000000000..3c86da0c63
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.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:
+
+ MonoStatusCode.dxs
+
+Abstract:
+
+ Dependency expression file for monolithic Status Code PEIM.
+
+--*/
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ TRUE
+DEPENDENCY_END
+
+
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.h b/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.h
new file mode 100644
index 0000000000..38a9022558
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.h
@@ -0,0 +1,111 @@
+/*++
+
+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:
+
+ MonoStatusCode.h
+
+Abstract:
+
+ Monolithic single PEIM to provide the status code functionality.
+ The PEIM is a blend of libraries that correspond to the different status code
+ listeners that a platform installs.
+
+--*/
+
+#ifndef _MONO_STATUS_CODE_H_
+#define _MONO_STATUS_CODE_H_
+
+//
+// Platform specific function Declarations. These must be implemented in a
+// subdirectory named PlatformName in a file named PlatformStatusCode.c.
+// See D845GRG\PlatformStatusCode.c for an example of a simple status code
+// implementation.
+// See Nt32\PlatformStatusCode.c for an example of a status code implementation
+// that relocates itself into memory.
+//
+//
+// This is the driver entry point and must be defined.
+//
+EFI_STATUS
+EFIAPI
+InstallMonoStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+;
+
+//
+// This is the platform function to initialize the listeners desired by the
+// platform.
+//
+VOID
+PlatformInitializeStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+;
+
+//
+// This is the platform function that calls all of the listeners desired by the
+// platform.
+//
+EFI_STATUS
+EFIAPI
+PlatformReportStatusCode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+;
+
+//
+// Platform independent function Declarations
+//
+//
+// Initialize the status code listeners and publish the status code PPI.
+//
+VOID
+EFIAPI
+InitializeMonoStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+;
+
+//
+// Convert a DXE status code call into a PEI status code call.
+//
+EFI_STATUS
+EFIAPI
+TranslateDxeStatusCodeToPeiStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+;
+
+//
+// Publish a HOB that contains the listener to be used by DXE.
+//
+EFI_STATUS
+EFIAPI
+InitializeDxeReportStatusCode (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+;
+
+#endif
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.mbd b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.mbd
new file mode 100644
index 0000000000..f48b4c7f0e
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.mbd
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>MonoStatusCode</BaseName>
+ <Guid>1501614E-0E6C-4ef4-8B8F-C276CDFB646F</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-19 15:17</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>BaseLib</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiHobLib</Library>
+ <Library>PeimEntryPoint</Library>
+ <Library>EdkMemoryStatusCodeLib</Library>
+ <Library>PeiCoreLib</Library>
+ </Libraries>
+ <BuildOptions ToolChain="MSFT">
+ <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
+ </BuildOptions>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.msa b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.msa
new file mode 100644
index 0000000000..a1e96c7bf9
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.msa
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>MonoStatusCode</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>1501614E-0E6C-4ef4-8B8F-C276CDFB646F</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for DiskIo module.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>0</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-19 15:17</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkMemoryStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>..\MonoStatusCode.c</Filename>
+ <Filename>..\MonoStatusCode.h</Filename>
+ <Filename>PlatformStatusCode.c</Filename>
+ <Filename>..\MonoStatusCode.dxs</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="SOMETIMES_CONSUMED">StatusCode</Protocol>
+ </Protocols>
+ <Hobs>
+ <Hob Usage="SOMETIMES_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>TranslateDxeStatusCodeToPeiStatusCode</Name>
+ <C_Name>gEfiStatusCodeRuntimeProtocolGuid</C_Name>
+ <Guid>0xd2b2b828, 0x826, 0x48a7, 0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0</Guid>
+ </Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">StatusCode</Ppi>
+ <Ppi Usage="SOMETIMES_CONSUMED">FvFileLoader</Ppi>
+ </PPIs>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>InstallMonoStatusCode</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/PlatformStatusCode.c b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/PlatformStatusCode.c
new file mode 100644
index 0000000000..9d1a57b2ee
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/PlatformStatusCode.c
@@ -0,0 +1,162 @@
+/*++
+
+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:
+
+ PlatformStatusCode.c
+
+Abstract:
+
+ Contains NT32 specific implementations required to use status codes.
+
+--*/
+
+#include "../MonoStatusCode.h"
+
+
+BOOLEAN gRunningFromMemory = FALSE;
+//
+// Platform definitions
+//
+EFI_PEI_REPORT_STATUS_CODE mSecReportStatusCode = NULL;
+
+extern EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi;
+
+//
+// Function implementations
+//
+EFI_STATUS
+EFIAPI
+PlatformReportStatusCode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Call all status code listeners in the MonoStatusCode.
+
+Arguments:
+
+ Same as ReportStatusCode service
+
+Returns:
+
+ EFI_SUCCESS Always returns success.
+
+--*/
+{
+ mSecReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data);
+ MemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ return EFI_SUCCESS;
+}
+
+VOID
+PlatformInitializeStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Initialize the status code listeners. This consists of locating the
+ listener produced by SecMain.exe.
+
+Arguments:
+
+ FfsHeader - FV this PEIM was loaded from.
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PROGRESS_CODE_PPI *ReportStatusCodePpi;
+ EFI_PEI_PPI_DESCRIPTOR *ReportStatusCodeDescriptor;
+
+ //
+ // Cache the existing status code listener installed by the SEC core.
+ // We should actually do a heap allocate, install a PPI, etc, but since we
+ // know that we are running from a DLL, we can use global variables, and
+ // directly update the status code PPI descriptor
+ //
+ //
+ // Locate SEC status code PPI
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gEfiPeiStatusCodePpiGuid,
+ 0,
+ &ReportStatusCodeDescriptor,
+ &ReportStatusCodePpi
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ mSecReportStatusCode = ReportStatusCodePpi->ReportStatusCode;
+ ReportStatusCodeDescriptor->Ppi = &mStatusCodePpi;
+
+ //
+ // Always initialize memory status code listener.
+ //
+ MemoryStatusCodeInitialize (FfsHeader, PeiServices);
+
+}
+
+EFI_STATUS
+EFIAPI
+InstallMonoStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Install the PEIM. Publish the DXE callback as well.
+
+Arguments:
+
+ FfsHeader - FV this PEIM was loaded from.
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ EFI_SUCCESS The function always returns success.
+
+--*/
+{
+ if (!gRunningFromMemory) {
+ //
+ // First pass, running from flash, initialize everything
+ //
+ InitializeMonoStatusCode (FfsHeader, PeiServices);
+ } else {
+ //
+ // Second pass, running from memory, initialize memory listener and
+ // publish the DXE listener in a HOB.
+ //
+ MemoryStatusCodeInitialize (FfsHeader, PeiServices);
+ InitializeDxeReportStatusCode (PeiServices);
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/build.xml b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/build.xml
new file mode 100644
index 0000000000..e6c8551241
--- /dev/null
+++ b/EdkNt32Pkg/Pei/MonoStatusCode/Nt32/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="MonoStatusCode"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\MonoStatusCode\Nt32"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="MonoStatusCode">
+ <GenBuild baseName="MonoStatusCode" mbdFilename="${MODULE_DIR}\MonoStatusCode.mbd" msaFilename="${MODULE_DIR}\MonoStatusCode.msa"/>
+ </target>
+ <target depends="MonoStatusCode_clean" name="clean"/>
+ <target depends="MonoStatusCode_cleanall" name="cleanall"/>
+ <target name="MonoStatusCode_clean">
+ <OutputDirSetup baseName="MonoStatusCode" mbdFilename="${MODULE_DIR}\MonoStatusCode.mbd" msaFilename="${MODULE_DIR}\MonoStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\MonoStatusCode_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\MonoStatusCode_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="MonoStatusCode_cleanall">
+ <OutputDirSetup baseName="MonoStatusCode" mbdFilename="${MODULE_DIR}\MonoStatusCode.mbd" msaFilename="${MODULE_DIR}\MonoStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\MonoStatusCode_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\MonoStatusCode_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**MonoStatusCode*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.c b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.c
new file mode 100644
index 0000000000..69261b952b
--- /dev/null
+++ b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.c
@@ -0,0 +1,657 @@
+/*++
+
+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:
+ PcdEmulator.c
+
+Abstract:
+ Platform Configuration Database (PCD) Service PEIM
+
+--*/
+
+#include <PcdEmulator.h>
+
+//
+// BugBug: PEI early phase does not support global variable!!!
+// This is only a temperary solution.
+//
+
+UINTN mSkuId = 0;
+
+
+STATIC EMULATED_PCD_DATABASE_EX *
+GetPcdDataBaseEx (
+ VOID
+) {
+ EFI_HOB_GUID_TYPE *GuidHob;
+ EMULATED_PCD_DATABASE_EX *EmulatedPcdDatabaseEx;
+
+ GuidHob = GetFirstGuidHob (&gPcdHobGuid);
+ EmulatedPcdDatabaseEx = (EMULATED_PCD_DATABASE_EX *) GET_GUID_HOB_DATA(GuidHob);
+
+ return EmulatedPcdDatabaseEx;
+}
+
+STATIC UINTN
+GetPcdDataBaseExEntryCount (
+ EMULATED_PCD_DATABASE_EX * Database
+) {
+ return Database->Count;
+}
+
+STATIC UINTN
+GetPcdDataBaseExSize (
+ EMULATED_PCD_DATABASE_EX * Database
+) {
+ UINTN Size;
+
+ Size = sizeof (Database->Count)
+ + (sizeof (Database->Entry[0]) * Database->Count);
+
+ return Size;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSetSku (
+ IN UINTN SkuId
+ )
+{
+ mSkuId = SkuId;
+ return EFI_SUCCESS;
+}
+
+UINT8
+EFIAPI
+PcdEmulatorGet8 (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ ASSERT (Pcd->DatumSize == 1);
+
+ return (UINT8)Pcd->Datum;
+}
+
+UINT16
+EFIAPI
+PcdEmulatorGet16 (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ ASSERT (Pcd->DatumSize == 2);
+
+ return (UINT16)Pcd->Datum;
+}
+
+UINT32
+EFIAPI
+PcdEmulatorGet32 (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ ASSERT (Pcd->DatumSize == 4);
+
+ return (UINT32)Pcd->Datum;
+}
+
+UINT64
+EFIAPI
+PcdEmulatorGet64 (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ ASSERT (Pcd->DatumSize == sizeof (UINT64));
+
+ return (UINT64)Pcd->Datum;
+}
+
+VOID *
+EFIAPI
+PcdEmulatorGetPtr (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+
+ return (VOID *)(UINTN)Pcd->ExtendedData;
+}
+
+BOOLEAN
+EFIAPI
+PcdEmulatorGetBoolean (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ ASSERT (Pcd->DatumSize == 1);
+
+ return (BOOLEAN)Pcd->Datum;
+}
+
+UINTN
+EFIAPI
+PcdEmulatorGetSize (
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ return Pcd->DatumSize;
+}
+
+UINT8
+EFIAPI
+PcdEmulatorGet8Ex (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+UINT16
+EFIAPI
+PcdEmulatorGet16Ex (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+UINT32
+EFIAPI
+PcdEmulatorGet32Ex (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+UINT64
+EFIAPI
+PcdEmulatorGet64Ex (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+VOID *
+EFIAPI
+PcdEmulatorGetPtrEx (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+BOOLEAN
+EFIAPI
+PcdEmulatorGetBooleanEx (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+UINTN
+EFIAPI
+PcdEmulatorGetSizeEx (
+ IN CONST EFI_GUID *PcdDataBaseName,
+ IN UINTN TokenNumber
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+ return Pcd->DatumSize;
+}
+
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet8 (
+ IN UINTN TokenNumber,
+ IN UINT8 Value
+ )
+{
+
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+
+ ASSERT (Pcd->DatumSize == sizeof (UINT8));
+
+ Pcd->Datum = Value;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet16 (
+ IN UINTN TokenNumber,
+ IN UINT16 Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet32 (
+ IN UINTN TokenNumber,
+ IN UINT32 Value
+ )
+{
+
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+
+ ASSERT (Pcd->DatumSize == sizeof (UINT32));
+
+ Pcd->Datum = Value;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet64 (
+ IN UINTN TokenNumber,
+ IN UINT64 Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSetPtr (
+ IN UINTN TokenNumber,
+ IN CONST VOID *Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSetBoolean (
+ IN UINTN TokenNumber,
+ IN BOOLEAN Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet8Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT8 Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet16Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT16 Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet32Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT32 Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSet64Ex (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN UINT64 Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSetPtrEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN CONST VOID *Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorSetBooleanEx (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN TokenNumber,
+ IN BOOLEAN Value
+ )
+{
+
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorCallBackOnSet (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PPI_CALLBACK CallBackFunction
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+
+ if (Pcd->CallBackListSize == Pcd->CallBackEntries) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Pcd->CallBackList[Pcd->CallBackEntries++] = CallBackFunction;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorUnregisterCallBackOnSet (
+ IN UINTN TokenNumber,
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN PCD_PPI_CALLBACK CallBackfunction
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+ UINT32 Index;
+
+ Pcd = GetPcdEntry (TokenNumber);
+ ASSERT (Pcd != NULL);
+
+ for (Index = 0; Index < Pcd->CallBackListSize; Index++) {
+ if (Pcd->CallBackList[Index] == CallBackfunction) {
+ Pcd->CallBackList[Index] = NULL;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+EFIAPI
+PcdEmulatorGetNextToken (
+ IN CONST EFI_GUID *Guid, OPTIONAL
+ IN UINTN *Token
+ )
+{
+ EMULATED_PCD_ENTRY_EX *Pcd;
+ EMULATED_PCD_ENTRY_EX *LastPcdEntry;
+ EMULATED_PCD_DATABASE_EX *PcdDatabase;
+ EMULATED_PCD_ENTRY_EX *PcdEntry;
+
+ PcdDatabase = GetPcdDataBaseEx ();
+ PcdEntry = PcdDatabase->Entry;
+
+ if (*Token == PCD_INVALID_TOKEN) {
+ //
+ // BugBug: Due to variable size array, ensure we convert this to a reasonable database
+ // that can accomodate array references for simplicity's sake
+ *Token = PcdEntry[0].Token;
+ return EFI_SUCCESS;
+ }
+
+ Pcd = GetPcdEntry (*Token);
+ if (Pcd == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ LastPcdEntry = PcdEntry + GetPcdDataBaseExEntryCount (PcdDatabase);
+ if (++Pcd >= LastPcdEntry) {
+ return EFI_NOT_FOUND;
+ }
+
+ *Token = Pcd->Token;
+ return EFI_SUCCESS;
+}
+
+PCD_PPI mPcdPpiInstance = {
+ PcdEmulatorSetSku,
+
+ PcdEmulatorGet8,
+ PcdEmulatorGet16,
+ PcdEmulatorGet32,
+ PcdEmulatorGet64,
+ PcdEmulatorGetPtr,
+ PcdEmulatorGetBoolean,
+ PcdEmulatorGetSize,
+
+ PcdEmulatorGet8Ex,
+ PcdEmulatorGet16Ex,
+ PcdEmulatorGet32Ex,
+ PcdEmulatorGet64Ex,
+ PcdEmulatorGetPtrEx,
+ PcdEmulatorGetBooleanEx,
+ PcdEmulatorGetSizeEx,
+
+ PcdEmulatorSet8,
+ PcdEmulatorSet16,
+ PcdEmulatorSet32,
+ PcdEmulatorSet64,
+ PcdEmulatorSetPtr,
+ PcdEmulatorSetBoolean,
+
+ PcdEmulatorSet8Ex,
+ PcdEmulatorSet16Ex,
+ PcdEmulatorSet32Ex,
+ PcdEmulatorSet64Ex,
+ PcdEmulatorSetPtrEx,
+ PcdEmulatorSetBooleanEx,
+
+ PcdEmulatorCallBackOnSet,
+ PcdEmulatorUnregisterCallBackOnSet,
+ PcdEmulatorGetNextToken
+};
+
+STATIC EFI_PEI_PPI_DESCRIPTOR mPpiPCD = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gPcdPpiGuid,
+ &mPcdPpiInstance
+};
+
+EFI_STATUS
+EFIAPI
+PeimPcdEmulatorEntry (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Count;
+ UINTN Calculation;
+ UINT8 *AllocatedBuffer;
+ EMULATED_PCD_DATABASE_EX *EmulatedPcdDatabaseEx;
+ EMULATED_PCD_ENTRY_EX *EmulatedPcdEntryEx;
+
+ //
+ // BugBug: Normally, we would read an FFS file for this data
+ // We need to remember, that when we read the FFS file, items such as the VariableName will not be encoded as a pointer
+ // but as an array of content. In this emulation, our init is encoding this data as a pointer.
+ // In the FFS version, we will depend on the proper Entry Count in the FFS data since the structures will
+ // now be variable length.
+ //
+ //
+
+ //
+ // We should now read from the FFS file into the cache - for now, we fake this.
+ //
+ Count = GetPcdDataBaseSize () / sizeof (EMULATED_PCD_ENTRY);
+
+ //
+ // Let's now determine how big of a buffer we need for our database
+ // For the FFS version, we need to calculate/consider the VariableName/ExtendedData size!!!
+ //
+ Calculation = sizeof (UINTN) + (Count * sizeof (EMULATED_PCD_ENTRY_EX));
+
+ EmulatedPcdDatabaseEx = (EMULATED_PCD_DATABASE_EX *) BuildGuidHob (&gPcdHobGuid, Calculation);
+
+ EmulatedPcdDatabaseEx->Count = Count;
+ EmulatedPcdEntryEx = EmulatedPcdDatabaseEx->Entry;
+
+ AllocatedBuffer = AllocatePool (Count * sizeof (PCD_PPI_CALLBACK) * MAX_PCD_CALLBACK);
+ ASSERT (AllocatedBuffer != NULL);
+
+ for (Index = 0; Index < Count; Index++) {
+ //
+ // Copy from source to our own allocated buffer - normally an FFS read
+ //
+ (*PeiServices)->CopyMem (
+ (VOID *) (EmulatedPcdEntryEx + Index),
+ (VOID *) (gEmulatedPcdEntry + Index),
+ sizeof (EMULATED_PCD_ENTRY)
+ );
+
+ //
+ // All the CallBackList worker functions refer to this CallBackList as CallBackList[CallbackEntry]
+ // so we seed the same buffer address here.
+ //
+ EmulatedPcdEntryEx[Index].CallBackList = (PCD_PPI_CALLBACK *)AllocatedBuffer;
+ AllocatedBuffer+= (sizeof (PCD_PPI_CALLBACK) * MAX_PCD_CALLBACK);
+ EmulatedPcdEntryEx[Index].CallBackEntries = 0;
+ EmulatedPcdEntryEx[Index].CallBackListSize = MAX_PCD_CALLBACK;
+ }
+
+ //
+ // Install PCD service PPI
+ //
+ Status = PeiCoreInstallPpi (&mPpiPCD);
+
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+}
+
+
+EMULATED_PCD_ENTRY_EX *
+GetPcdEntry (
+ IN UINTN TokenNumber
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ EMULATED_PCD_DATABASE_EX *EmulatedPcdDatabaseEx;
+ EMULATED_PCD_ENTRY_EX *EmulatedPcdEntryEx;
+
+ CpuBreakpoint ();
+
+ EmulatedPcdDatabaseEx = GetPcdDataBaseEx ();
+ //
+ // BugBug: This Count will change when we flip over to FFS version
+ //
+ Count = EmulatedPcdDatabaseEx->Count;
+ EmulatedPcdEntryEx = EmulatedPcdDatabaseEx->Entry;
+ for (Index = 0; Index < Count; Index++) {
+ if (EmulatedPcdEntryEx[Index].Token == TokenNumber) {
+ return &EmulatedPcdEntryEx[Index];
+ }
+ }
+ return NULL;
+}
+
+
diff --git a/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.dxs b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.dxs
new file mode 100644
index 0000000000..ea579976c8
--- /dev/null
+++ b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.dxs
@@ -0,0 +1,25 @@
+/*++
+
+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:
+
+ PcdEmulator.dxs
+
+Abstract:
+
+ Dependency expression source file.
+
+--*/
+#include <DxeDepex.h>
+
+DEPENDENCY_START
+ TRUE
+DEPENDENCY_END
diff --git a/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.h b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.h
new file mode 100644
index 0000000000..e97c2a1201
--- /dev/null
+++ b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.h
@@ -0,0 +1,53 @@
+/*++
+
+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:
+ PcdEmulator.h
+
+Abstract:
+ Platform Configuration Database (PCD)
+
+--*/
+
+#ifndef __PCD_EMULATOR_H__
+#define __PCD_EMULATOR_H__
+
+
+
+//
+// BugBug: Not very sure, where to put this "extern"
+//
+extern GUID gPcdHobGuid;
+
+//
+// BugBug: Hack max number of callbacks per token
+//
+#define MAX_PCD_CALLBACK 0x10
+
+extern EMULATED_PCD_ENTRY gEmulatedPcdEntry[];
+
+UINTN
+GetPcdDataBaseSize (
+ VOID
+ );
+
+EMULATED_PCD_ENTRY_EX *
+GetPcdEntry (
+ IN UINTN TokenNumber
+ );
+
+EFI_STATUS
+InstallMyHob (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ );
+#endif
diff --git a/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.mbd b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.mbd
new file mode 100644
index 0000000000..816cf6f869
--- /dev/null
+++ b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.mbd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>PcdEmulatorPeim</BaseName>
+ <Guid>9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-24 18:54</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeimEntryPoint</Library>
+ <Library>BaseLib</Library>
+ <Library>PeiCoreLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiHobLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>PeiMemoryAllocationLib</Library>
+ </Libraries>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.msa b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.msa
new file mode 100644
index 0000000000..9a329a2b66
--- /dev/null
+++ b/EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.msa
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>PcdEmulatorPeim</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for PcdEmulator PEIM module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-24 18:54</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>PcdEmulator.dxs</Filename>
+ <Filename>PcdEmulator.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <Hobs>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>PcdDataBase</Name>
+ <C_Name>gPcdHobGuid</C_Name>
+ <Guid>0x582e7ca1, 0x68cd, 0x4d44, 0xb4, 0x3b, 0xf2, 0x98, 0xed, 0x58, 0x7b, 0xa6</Guid>
+ </Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="ALWAYS_PRODUCED">Pcd</Ppi>
+ </PPIs>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>PcdHob</C_Name>
+ </GuidEntry>
+ </Guids>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>PeimPcdEmulatorEntry</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/PcdEmulator/build.xml b/EdkNt32Pkg/Pei/PcdEmulator/build.xml
new file mode 100644
index 0000000000..86e0d1fc8e
--- /dev/null
+++ b/EdkNt32Pkg/Pei/PcdEmulator/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="PcdEmulatorPeim"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\PcdEmulator"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="PcdEmulatorPeim">
+ <GenBuild baseName="PcdEmulatorPeim" mbdFilename="${MODULE_DIR}\PcdEmulator.mbd" msaFilename="${MODULE_DIR}\PcdEmulator.msa"/>
+ </target>
+ <target depends="PcdEmulatorPeim_clean" name="clean"/>
+ <target depends="PcdEmulatorPeim_cleanall" name="cleanall"/>
+ <target name="PcdEmulatorPeim_clean">
+ <OutputDirSetup baseName="PcdEmulatorPeim" mbdFilename="${MODULE_DIR}\PcdEmulator.mbd" msaFilename="${MODULE_DIR}\PcdEmulator.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\PcdEmulatorPeim_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\PcdEmulatorPeim_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="PcdEmulatorPeim_cleanall">
+ <OutputDirSetup baseName="PcdEmulatorPeim" mbdFilename="${MODULE_DIR}\PcdEmulator.mbd" msaFilename="${MODULE_DIR}\PcdEmulator.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\PcdEmulatorPeim_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\PcdEmulatorPeim_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**PcdEmulatorPeim*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.dxs b/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.dxs
new file mode 100644
index 0000000000..107ddee3e1
--- /dev/null
+++ b/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.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:
+
+ WinNtStuff.dxs
+
+Abstract:
+
+ Dependency expression file for WinNtStuff PEIM.
+
+--*/
+
+#include <AutoGen.h>
+#include <PeimDepex.h>
+
+DEPENDENCY_START
+ PEI_NT_THUNK_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID
+DEPENDENCY_END
+
+
diff --git a/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.mbd b/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.mbd
new file mode 100644
index 0000000000..ab862efcae
--- /dev/null
+++ b/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.mbd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdHeader>
+ <BaseName>WinNtStuff</BaseName>
+ <Guid>D3AAD8DC-3A48-46ac-B1C7-28A9D3CF6755</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>
+ <Created>2006-03-14 17:04</Created>
+ <Modified>2006-03-19 15:17</Modified>
+ </MbdHeader>
+ <Libraries>
+ <Library>PeimEntryPoint</Library>
+ <Library>PeiMemoryLib</Library>
+ <Library>PeiCoreLib</Library>
+ <Library>PeiServicesTablePointerLib</Library>
+ <Library>PeiHobLib</Library>
+ <Library>PeiReportStatusCodeLib</Library>
+ <Library>BaseDebugLibReportStatusCode</Library>
+ <Library>BaseLib</Library>
+ </Libraries>
+ <BuildOptions ToolChain="MSFT">
+ <ImageEntryPoint>_ModuleEntryPoint</ImageEntryPoint>
+ </BuildOptions>
+</ModuleBuildDescription>
diff --git a/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.msa b/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.msa
new file mode 100644
index 0000000000..11aa06a21b
--- /dev/null
+++ b/EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.msa
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaHeader>
+ <BaseName>WinNtStuff</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>PE32_PEIM</ComponentType>
+ <Guid>D3AAD8DC-3A48-46ac-B1C7-28A9D3CF6755</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for WinNtStuff module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-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>0</Specification>
+ <Created>2006-03-14 17:04</Created>
+ <Updated>2006-03-19 15:17</Updated>
+ </MsaHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeimEntryPoint</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>WinNtStuff.c</Filename>
+ <Filename>WinNtStuff.dxs</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ <PackageName>EdkNt32Pkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">WinNtThunk</Protocol>
+ </Protocols>
+ <Hobs>
+ <Hob Usage="ALWAYS_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>WinNtThunkProtocol</Name>
+ <C_Name>gEfiWinNtThunkProtocolGuid</C_Name>
+ <Guid>0x58c518b1, 0x76f3, 0x11d4, 0xbc, 0xea, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81</Guid>
+ </Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">NtThunk</Ppi>
+ </PPIs>
+ <Externs>
+ <Extern>
+ <ModuleEntryPoint>PeimInitializeWinNtStuff</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkNt32Pkg/Pei/WinNtStuff/build.xml b/EdkNt32Pkg/Pei/WinNtStuff/build.xml
new file mode 100644
index 0000000000..885bacb1a2
--- /dev/null
+++ b/EdkNt32Pkg/Pei/WinNtStuff/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="WinNtStuff"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Pei\WinNtStuff"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="WinNtStuff">
+ <GenBuild baseName="WinNtStuff" mbdFilename="${MODULE_DIR}\WinNtStuff.mbd" msaFilename="${MODULE_DIR}\WinNtStuff.msa"/>
+ </target>
+ <target depends="WinNtStuff_clean" name="clean"/>
+ <target depends="WinNtStuff_cleanall" name="cleanall"/>
+ <target name="WinNtStuff_clean">
+ <OutputDirSetup baseName="WinNtStuff" mbdFilename="${MODULE_DIR}\WinNtStuff.mbd" msaFilename="${MODULE_DIR}\WinNtStuff.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\WinNtStuff_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\WinNtStuff_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="WinNtStuff_cleanall">
+ <OutputDirSetup baseName="WinNtStuff" mbdFilename="${MODULE_DIR}\WinNtStuff.mbd" msaFilename="${MODULE_DIR}\WinNtStuff.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\WinNtStuff_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\WinNtStuff_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**WinNtStuff*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkNt32Pkg/Pei/WinNtStuff/winntstuff.c b/EdkNt32Pkg/Pei/WinNtStuff/winntstuff.c
new file mode 100644
index 0000000000..46859286ea
--- /dev/null
+++ b/EdkNt32Pkg/Pei/WinNtStuff/winntstuff.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:
+
+ WinNtStuff.c
+
+Abstract:
+
+ Tiano PEIM to abstract construction of firmware volume in a Windows NT environment.
+
+Revision History
+
+--*/
+
+
+
+EFI_STATUS
+EFIAPI
+PeimInitializeWinNtStuff (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Perform a call-back into the SEC simulator to get NT 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_NT_THUNK_PPI *PeiNtService;
+ VOID *Ptr;
+
+ DEBUG ((EFI_D_ERROR, "NT 32 WinNT Stuff PEIM Loaded\n"));
+
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gPeiNtThunkPpiGuid, // GUID
+ 0, // INSTANCE
+ &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ &PeiNtService // PPI
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Ptr = PeiNtService->NtThunk ();
+
+ BuildGuidDataHob (
+ &gEfiWinNtThunkProtocolGuid, // Guid
+ &Ptr, // Buffer
+ sizeof (VOID *) // Sizeof Buffer
+ );
+ return Status;
+}