From 878ddf1fc3540a715f63594ed22b6929e881afb4 Mon Sep 17 00:00:00 2001 From: bbahnsen Date: Fri, 21 Apr 2006 22:54:32 +0000 Subject: Initial import. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524 --- EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.mbd | 43 ++ EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.msa | 68 +++ EdkNt32Pkg/Pei/Autoscan/WinNtAutoscan.dxs | 29 + EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.c | 132 +++++ EdkNt32Pkg/Pei/Autoscan/build.xml | 47 ++ EdkNt32Pkg/Pei/BootMode/BootMode.c | 85 +++ EdkNt32Pkg/Pei/BootMode/BootMode.dxs | 29 + EdkNt32Pkg/Pei/BootMode/BootMode.mbd | 42 ++ EdkNt32Pkg/Pei/BootMode/BootMode.msa | 59 ++ EdkNt32Pkg/Pei/BootMode/build.xml | 47 ++ EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.dxs | 29 + EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.mbd | 43 ++ EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.msa | 69 +++ EdkNt32Pkg/Pei/FirmwareVolume/WinntFwh.c | 123 ++++ EdkNt32Pkg/Pei/FirmwareVolume/build.xml | 47 ++ EdkNt32Pkg/Pei/FlashMap/FlashMap.c | 273 +++++++++ EdkNt32Pkg/Pei/FlashMap/FlashMap.dxs | 28 + EdkNt32Pkg/Pei/FlashMap/FlashMap.mbd | 43 ++ EdkNt32Pkg/Pei/FlashMap/FlashMap.msa | 101 ++++ EdkNt32Pkg/Pei/FlashMap/build.xml | 47 ++ EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.c | 150 +++++ EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.dxs | 28 + EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.h | 111 ++++ .../Pei/MonoStatusCode/Nt32/MonoStatusCode.mbd | 44 ++ .../Pei/MonoStatusCode/Nt32/MonoStatusCode.msa | 70 +++ .../Pei/MonoStatusCode/Nt32/PlatformStatusCode.c | 162 +++++ EdkNt32Pkg/Pei/MonoStatusCode/Nt32/build.xml | 47 ++ EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.c | 657 +++++++++++++++++++++ EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.dxs | 25 + EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.h | 53 ++ EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.mbd | 41 ++ EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.msa | 72 +++ EdkNt32Pkg/Pei/PcdEmulator/build.xml | 47 ++ EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.dxs | 29 + EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.mbd | 43 ++ EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.msa | 68 +++ EdkNt32Pkg/Pei/WinNtStuff/build.xml | 47 ++ EdkNt32Pkg/Pei/WinNtStuff/winntstuff.c | 73 +++ 38 files changed, 3151 insertions(+) create mode 100644 EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.mbd create mode 100644 EdkNt32Pkg/Pei/Autoscan/WinNtAutoScan.msa create mode 100644 EdkNt32Pkg/Pei/Autoscan/WinNtAutoscan.dxs create mode 100644 EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.c create mode 100644 EdkNt32Pkg/Pei/Autoscan/build.xml create mode 100644 EdkNt32Pkg/Pei/BootMode/BootMode.c create mode 100644 EdkNt32Pkg/Pei/BootMode/BootMode.dxs create mode 100644 EdkNt32Pkg/Pei/BootMode/BootMode.mbd create mode 100644 EdkNt32Pkg/Pei/BootMode/BootMode.msa create mode 100644 EdkNt32Pkg/Pei/BootMode/build.xml create mode 100644 EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.dxs create mode 100644 EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.mbd create mode 100644 EdkNt32Pkg/Pei/FirmwareVolume/WinNtFwh.msa create mode 100644 EdkNt32Pkg/Pei/FirmwareVolume/WinntFwh.c create mode 100644 EdkNt32Pkg/Pei/FirmwareVolume/build.xml create mode 100644 EdkNt32Pkg/Pei/FlashMap/FlashMap.c create mode 100644 EdkNt32Pkg/Pei/FlashMap/FlashMap.dxs create mode 100644 EdkNt32Pkg/Pei/FlashMap/FlashMap.mbd create mode 100644 EdkNt32Pkg/Pei/FlashMap/FlashMap.msa create mode 100644 EdkNt32Pkg/Pei/FlashMap/build.xml create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.c create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.dxs create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/MonoStatusCode.h create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.mbd create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/Nt32/MonoStatusCode.msa create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/Nt32/PlatformStatusCode.c create mode 100644 EdkNt32Pkg/Pei/MonoStatusCode/Nt32/build.xml create mode 100644 EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.c create mode 100644 EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.dxs create mode 100644 EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.h create mode 100644 EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.mbd create mode 100644 EdkNt32Pkg/Pei/PcdEmulator/PcdEmulator.msa create mode 100644 EdkNt32Pkg/Pei/PcdEmulator/build.xml create mode 100644 EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.dxs create mode 100644 EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.mbd create mode 100644 EdkNt32Pkg/Pei/WinNtStuff/WinNtStuff.msa create mode 100644 EdkNt32Pkg/Pei/WinNtStuff/build.xml create mode 100644 EdkNt32Pkg/Pei/WinNtStuff/winntstuff.c (limited to 'EdkNt32Pkg/Pei') 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 @@ + + + + + WinNtAutoScan + BE0FEABA-3443-4919-9F3A-2D4216329EA9 + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-19 15:17 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + + + _ModuleEntryPoint + + 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 @@ + + + + + WinNtAutoScan + PEIM + PE32_PEIM + BE0FEABA-3443-4919-9F3A-2D4216329EA9 + 0 + Component description file for WinNtAutoScan module + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-14 17:04 + 2006-03-19 15:17 + + + DebugLib + PeimEntryPoint + BaseLib + BaseMemoryLib + HobLib + PeiCoreLib + PeiServicesTablePointerLib + + + WinNtAutoScan.c + WinNtAutoscan.dxs + + + MdePkg + EdkModulePkg + EdkNt32Pkg + + + + EFI_RESOURCE_SYSTEM_MEMORY + + + + + NtAutoScan + BaseMemoryTest + MemoryDiscovered + + + + PeimInitializeWinNtAutoScan + + + 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 +#include + +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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 +#include + +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 @@ + + + + + BootMode + B7611005-1F26-45ba-A3DB-01F39DDB2785 + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-19 15:17 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + + + _ModuleEntryPoint + + 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 @@ + + + + + BootMode + PEIM + PE32_PEIM + B7611005-1F26-45ba-A3DB-01F39DDB2785 + 0 + Component description file for Fwh module + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-14 17:04 + 2006-03-19 15:17 + + + DebugLib + PeimEntryPoint + BaseLib + PeiCoreLib + PeiServicesTablePointerLib + + + BootMode.c + BootMode.dxs + + + MdePkg + EdkModulePkg + EdkNt32Pkg + + + BootInRecoveryMode + MasterBootMode + + + + InitializeBootMode + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 +#include + +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 @@ + + + + + WinNtFwh + F0384FFD-8633-452f-9010-F6B7D2EAE2F1 + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-23 10:33 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + + + _ModuleEntryPoint + + 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 @@ + + + + + WinNtFwh + PEIM + PE32_PEIM + F0384FFD-8633-452f-9010-F6B7D2EAE2F1 + 0 + Component description file for WinNtFwh module + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-14 17:04 + 2006-03-23 10:33 + + + DebugLib + PeimEntryPoint + HobLib + PeiCoreLib + PeiServicesTablePointerLib + + + WinNtFwh.c + WinNtFwh.dxs + + + MdePkg + EdkModulePkg + EdkNt32Pkg + + + + FvRecovery.fv + + + EFI_RESOURCE_FIRMWARE_DEVICE + + + NVSTORAGE.fv + + + + NtFwh + + + + PeimInitializeWinNtFwh + + + 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 + + +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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 + +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 +#include + +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 @@ + + + + + PeiFlashMap + 681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9 + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-23 10:43 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + + + _ModuleEntryPoint + + 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 @@ + + + + + PeiFlashMap + PEIM + PE32_PEIM + 681F3771-6F1D-42DE-9AA2-F82BBCDBC5F9 + 0 + Component description file for FlashMap PEI module + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-14 17:04 + 2006-03-23 10:43 + + + DebugLib + PeimEntryPoint + HobLib + PeiCoreLib + PeiServicesTablePointerLib + BaseMemoryLib + + + FlashMap.c + FlashMap.dxs + + + MdePkg + EdkModulePkg + EdkNt32Pkg + + + FirmwareVolumeBlock + + + + VariableArea + gEfiFlashMapHobGuid + 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 + + + FtwBackupBlock + gEfiFlashMapHobGuid + 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 + + + FtwStateArea + gEfiFlashMapHobGuid + 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 + + + RecoveryBios + gEfiFlashMapHobGuid + 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 + + + SystemNvDataHob + gEfiFlashMapHobGuid + 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 + + + + FlashMap + NtFwh + + + + FlashMapHob + + + FirmwareFileSystem + + + SystemNvDataHob + + + + + PeimInitializeFlashMap + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 +#include + +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 @@ + + + + + MonoStatusCode + 1501614E-0E6C-4ef4-8B8F-C276CDFB646F + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-19 15:17 + + + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + PeiMemoryLib + PeiServicesTablePointerLib + PeiHobLib + PeimEntryPoint + EdkMemoryStatusCodeLib + PeiCoreLib + + + _ModuleEntryPoint + + 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 @@ + + + + + MonoStatusCode + PEIM + PE32_PEIM + 1501614E-0E6C-4ef4-8B8F-C276CDFB646F + 0 + Component description file for DiskIo module. + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-14 17:04 + 2006-03-19 15:17 + + + DebugLib + PeimEntryPoint + EdkMemoryStatusCodeLib + HobLib + + + ..\MonoStatusCode.c + ..\MonoStatusCode.h + PlatformStatusCode.c + ..\MonoStatusCode.dxs + + + MdePkg + EdkModulePkg + EdkNt32Pkg + + + StatusCode + + + + TranslateDxeStatusCodeToPeiStatusCode + gEfiStatusCodeRuntimeProtocolGuid + 0xd2b2b828, 0x826, 0x48a7, 0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0 + + + + StatusCode + FvFileLoader + + + + InstallMonoStatusCode + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 + +// +// 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 + +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 @@ + + + + + PcdEmulatorPeim + 9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50 + EDK_RELEASE_VERSION 0x00020000 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-24 18:54 + + + PeimEntryPoint + BaseLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + BaseDebugLibReportStatusCode + PeiMemoryLib + PeiReportStatusCodeLib + PeiMemoryAllocationLib + + 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 @@ + + + + + PcdEmulatorPeim + PEIM + PE32_PEIM + 9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50 + EDK_RELEASE_VERSION 0x00020000 + Component description file for PcdEmulator PEIM module + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + EFI_SPECIFICATION_VERSION 0x00000000 + 2006-03-14 17:04 + 2006-03-24 18:54 + + + DebugLib + PeimEntryPoint + BaseLib + HobLib + PeiCoreLib + PcdLib + PeiServicesTablePointerLib + MemoryAllocationLib + + + PcdEmulator.dxs + PcdEmulator.c + + + MdePkg + EdkNt32Pkg + + + + PcdDataBase + gPcdHobGuid + 0x582e7ca1, 0x68cd, 0x4d44, 0xb4, 0x3b, 0xf2, 0x98, 0xed, 0x58, 0x7b, 0xa6 + + + + Pcd + + + + PcdHob + + + + + PeimPcdEmulatorEntry + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 +#include + +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 @@ + + + + + WinNtStuff + D3AAD8DC-3A48-46ac-B1C7-28A9D3CF6755 + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-14 17:04 + 2006-03-19 15:17 + + + PeimEntryPoint + PeiMemoryLib + PeiCoreLib + PeiServicesTablePointerLib + PeiHobLib + PeiReportStatusCodeLib + BaseDebugLibReportStatusCode + BaseLib + + + _ModuleEntryPoint + + 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 @@ + + + + + WinNtStuff + PEIM + PE32_PEIM + D3AAD8DC-3A48-46ac-B1C7-28A9D3CF6755 + 0 + Component description file for WinNtStuff module + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-14 17:04 + 2006-03-19 15:17 + + + DebugLib + PeimEntryPoint + HobLib + PeiCoreLib + PeiServicesTablePointerLib + + + WinNtStuff.c + WinNtStuff.dxs + + + MdePkg + EdkModulePkg + EdkNt32Pkg + + + WinNtThunk + + + + WinNtThunkProtocol + gEfiWinNtThunkProtocolGuid + 0x58c518b1, 0x76f3, 0x11d4, 0xbc, 0xea, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 + + + + NtThunk + + + + PeimInitializeWinNtStuff + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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; +} -- cgit v1.2.3