]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Unix version of EFI emulator
authortgingold <tgingold@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 6 Jan 2007 14:59:06 +0000 (14:59 +0000)
committertgingold <tgingold@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 6 Jan 2007 14:59:06 +0000 (14:59 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2182 6f19259b-4bc3-4df7-8a09-765794883524

187 files changed:
EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.h.orig [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/Bds.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/Bds.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BdsEntry.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BBSsupport.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BBSsupport.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Bm.vfr [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmString.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootMaint.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootMaint.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/ConsoleOption.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Data.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FE.vfr [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FileExplorer.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FormGuid.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/UpdatePage.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Variable.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManager.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManager.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerStrings.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerVfr.Vfr [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/Capsules.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerStrings.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerVfr.Vfr [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPage.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPage.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageStrings.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageVfr.Vfr [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/Language.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/Language.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/MemoryTest.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/String.c [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/String.h [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/Generic/Strings.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/PlatformBds.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/PlatformBds/PlatformData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturer.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturerData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendor.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendorData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBootInformationData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturer.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturerData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscDevicePath.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscNumberOfInstallableLanguagesData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemString.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemStringData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignator.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignatorData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignatorFunction.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscResetCapabilitiesData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriverDataTable.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriverEntryPoint.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageString.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageStringData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturer.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturerData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturerFunction.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionString.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionStringData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignation.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignationData.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/DriverConfiguration.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/DriverDiagnostics.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ConsoleIn.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ConsoleOut.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Console/UnixConsole.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaInput.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaScreen.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.msa [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Cpu/CpuDriver.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Cpu/CpuIo.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/Cpu/Strings.uni [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.c [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.dxs [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.h [new file with mode: 0644]
EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.msa [new file with mode: 0644]
EdkUnixPkg/EdkUnixPkg.spd [new file with mode: 0644]
EdkUnixPkg/Include/Common/UnixInclude.h [new file with mode: 0644]
EdkUnixPkg/Include/FlashLayout.h [new file with mode: 0644]
EdkUnixPkg/Include/Library/EdkGenericBdsLib.h [new file with mode: 0644]
EdkUnixPkg/Include/Library/UnixLib.h [new file with mode: 0644]
EdkUnixPkg/Include/Ppi/UnixAutoScan.h [new file with mode: 0644]
EdkUnixPkg/Include/Ppi/UnixFwh.h [new file with mode: 0644]
EdkUnixPkg/Include/Ppi/UnixPeiLoadFile.h [new file with mode: 0644]
EdkUnixPkg/Include/Ppi/UnixThunk.h [new file with mode: 0644]
EdkUnixPkg/Include/Protocol/UnixIo.h [new file with mode: 0644]
EdkUnixPkg/Include/Protocol/UnixThunk.h [new file with mode: 0644]
EdkUnixPkg/Include/Protocol/UnixUgaIo.h [new file with mode: 0644]
EdkUnixPkg/Include/UnixDxe.h [new file with mode: 0644]
EdkUnixPkg/Include/UnixPeim.h [new file with mode: 0644]
EdkUnixPkg/Library/DxeUnixLib/DxeUnixLib.msa [new file with mode: 0644]
EdkUnixPkg/Library/DxeUnixLib/UnixLib.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/BdsBoot.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/BdsBoot.c.orig [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/BdsConnect.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/BdsConsole.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c.orig [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/DevicePath.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/EdkGenericBdsLib.msa [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/Ipf/ShadowRom.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/Performance.c [new file with mode: 0644]
EdkUnixPkg/Library/EdkGenericBdsLib/Performance.h [new file with mode: 0644]
EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa [new file with mode: 0644]
EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c [new file with mode: 0644]
EdkUnixPkg/Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.c [new file with mode: 0644]
EdkUnixPkg/Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.msa [new file with mode: 0644]
EdkUnixPkg/Library/UnixPeCoffLoaderLib/UnixPeCoffLoader.c [new file with mode: 0644]
EdkUnixPkg/Library/UnixPeCoffLoaderLib/UnixPeCoffLoaderLib.msa [new file with mode: 0644]
EdkUnixPkg/Library/UnixTimerLibNull/UnixTimerLib.c [new file with mode: 0644]
EdkUnixPkg/Library/UnixTimerLibNull/UnixTimerLib.msa [new file with mode: 0644]
EdkUnixPkg/Logo/Logo.bmp [new file with mode: 0644]
EdkUnixPkg/Logo/Logo.msa [new file with mode: 0644]
EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c [new file with mode: 0644]
EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs [new file with mode: 0644]
EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa [new file with mode: 0644]
EdkUnixPkg/Pei/BootMode/BootMode.c [new file with mode: 0644]
EdkUnixPkg/Pei/BootMode/BootMode.dxs [new file with mode: 0644]
EdkUnixPkg/Pei/BootMode/BootMode.msa [new file with mode: 0644]
EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c [new file with mode: 0644]
EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs [new file with mode: 0644]
EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa [new file with mode: 0644]
EdkUnixPkg/Pei/FlashMap/FlashMap.c [new file with mode: 0644]
EdkUnixPkg/Pei/FlashMap/FlashMap.dxs [new file with mode: 0644]
EdkUnixPkg/Pei/FlashMap/FlashMap.msa [new file with mode: 0644]
EdkUnixPkg/Pei/UnixStuff/UnixStuff.c [new file with mode: 0644]
EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs [new file with mode: 0644]
EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa [new file with mode: 0644]
EdkUnixPkg/RuntimeDxe/FvbServices/FWBlockService.c [new file with mode: 0644]
EdkUnixPkg/RuntimeDxe/FvbServices/FvbInfo.c [new file with mode: 0644]
EdkUnixPkg/RuntimeDxe/FvbServices/FwBlockService.h [new file with mode: 0644]
EdkUnixPkg/RuntimeDxe/FvbServices/UnixFwh.dxs [new file with mode: 0644]
EdkUnixPkg/RuntimeDxe/FvbServices/UnixFwh.msa [new file with mode: 0644]
EdkUnixPkg/Sec/FwVol.c [new file with mode: 0644]
EdkUnixPkg/Sec/SecMain.c [new file with mode: 0644]
EdkUnixPkg/Sec/SecMain.h [new file with mode: 0644]
EdkUnixPkg/Sec/SecMain.msa [new file with mode: 0644]
EdkUnixPkg/Sec/SecMain_build.xml [new file with mode: 0644]
EdkUnixPkg/Sec/UgaX11.c [new file with mode: 0644]
EdkUnixPkg/Sec/UnixThunk.c [new file with mode: 0644]
EdkUnixPkg/Unix.fpd [new file with mode: 0644]

diff --git a/EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.c b/EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.c
new file mode 100644 (file)
index 0000000..d1edef3
--- /dev/null
@@ -0,0 +1,517 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsPlatform.c\r
+\r
+Abstract:\r
+\r
+  This file include all platform action which can be customized\r
+  by IBV/OEM.\r
+\r
+--*/\r
+\r
+#include "Generic/Bds.h"\r
+#include "BdsPlatform.h"\r
+#include "Generic/String.h"\r
+#include "Generic/Language.h"\r
+#include "Generic/FrontPage.h"\r
+\r
+CHAR16  mFirmwareVendor[] = L"TianoCore.org";\r
+\r
+//\r
+// BDS Platform Functions\r
+//\r
+VOID\r
+PlatformBdsInit (\r
+  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Platform Bds init. Incude the platform firmware vendor, revision\r
+  and so crc check.\r
+\r
+Arguments:\r
+\r
+  PrivateData  - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  //\r
+  // set firmwarevendor, here can be IBV/OEM customize\r
+  //\r
+  gST->FirmwareVendor = AllocateRuntimeCopyPool (\r
+                          sizeof (mFirmwareVendor),\r
+                          &mFirmwareVendor\r
+                          );\r
+  ASSERT (gST->FirmwareVendor != NULL);\r
+\r
+  gST->FirmwareRevision = EFI_FIRMWARE_REVISION;\r
+\r
+  //\r
+  // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
+  //\r
+  gBS->CalculateCrc32 ((VOID *) gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
+\r
+  //\r
+  // Initialize the platform specific string and language\r
+  //\r
+  InitializeStringSupport ();\r
+  InitializeLanguage (TRUE);\r
+  InitializeFrontPage (FALSE);\r
+\r
+}\r
+\r
+EFI_STATUS\r
+PlatformBdsConnectConsole (\r
+  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Connect the predefined platform default console device. Always try to find\r
+  and enable the vga device if have.\r
+\r
+Arguments:\r
+\r
+  PlatformConsole         - Predfined platform default console device array.\r
\r
+Returns:\r
+\r
+  EFI_SUCCESS             - Success connect at least one ConIn and ConOut \r
+                            device, there must have one ConOut device is \r
+                            active vga device.\r
+  \r
+  EFI_STATUS              - Return the status of \r
+                            BdsLibConnectAllDefaultConsoles ()\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       Index;\r
+\r
+  Index   = 0;\r
+  Status  = EFI_SUCCESS;\r
+\r
+  //\r
+  // Have chance to connect the platform default console,\r
+  // the platform default console is the minimue device group\r
+  // the platform should support\r
+  //\r
+  while (PlatformConsole[Index].DevicePath != NULL) {\r
+    //\r
+    // Update the console variable with the connect type\r
+    //\r
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
+      BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
+      BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
+      BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    Index++;\r
+  }\r
+  //\r
+  // Connect the all the default console with current cosole variable\r
+  //\r
+  Status = BdsLibConnectAllDefaultConsoles ();\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Connect with predeined platform connect sequence, \r
+  the OEM/IBV can customize with their own connect sequence.\r
+  \r
+Arguments:\r
+\r
+  None.\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+  Index = 0;\r
+\r
+  //\r
+  // Here we can get the customized platform connect sequence\r
+  // Notes: we can connect with new variable which record the\r
+  // last time boots connect device path sequence\r
+  //\r
+  while (gPlatformConnectSequence[Index] != NULL) {\r
+    //\r
+    // Build the platform boot option\r
+    //\r
+    BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
+    Index++;\r
+  }\r
+\r
+}\r
+\r
+VOID\r
+PlatformBdsGetDriverOption (\r
+  IN OUT LIST_ENTRY              *BdsDriverLists\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Load the predefined driver option, OEM/IBV can customize this\r
+  to load their own drivers\r
+  \r
+Arguments:\r
+\r
+  BdsDriverLists  - The header of the driver option link list.\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+--*/\r
+{\r
+  UINTN Index;\r
+\r
+  Index = 0;\r
+\r
+  //\r
+  // Here we can get the customized platform driver option\r
+  //\r
+  while (gPlatformDriverOption[Index] != NULL) {\r
+    //\r
+    // Build the platform boot option\r
+    //\r
+    BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
+    Index++;\r
+  }\r
+\r
+}\r
+\r
+VOID\r
+PlatformBdsDiagnostics (\r
+  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
+  IN BOOLEAN                     QuietBoot\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
+  can customize this fuction to support specific platform diagnostic.\r
+  \r
+Arguments:\r
+\r
+  MemoryTestLevel  - The memory test intensive level\r
+  \r
+  QuietBoot        - Indicate if need to enable the quiet boot\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Here we can decide if we need to show\r
+  // the diagnostics screen\r
+  // Notes: this quiet boot code should be remove\r
+  // from the graphic lib\r
+  //\r
+  if (QuietBoot) {\r
+    EnableQuietBoot (&gEfiUgaSplashProtocolGuid);\r
+    //\r
+    // Perform system diagnostic\r
+    //\r
+    Status = BdsMemoryTest (MemoryTestLevel);\r
+    if (EFI_ERROR (Status)) {\r
+      DisableQuietBoot ();\r
+    }\r
+\r
+    return ;\r
+  }\r
+  //\r
+  // Perform system diagnostic\r
+  //\r
+  Status = BdsMemoryTest (MemoryTestLevel);\r
+}\r
+\r
+VOID\r
+PlatformBdsPolicyBehavior (\r
+  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData,\r
+  IN OUT LIST_ENTRY                  *DriverOptionList,\r
+  IN OUT LIST_ENTRY                  *BootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The function will excute with as the platform policy, current policy\r
+  is driven by boot mode. IBV/OEM can customize this code for their specific\r
+  policy action.\r
+  \r
+Arguments:\r
+\r
+  PrivateData      - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r
+  \r
+  DriverOptionList - The header of the driver option link list\r
+  \r
+  BootOptionList   - The header of the boot option link list\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT16      Timeout;\r
+\r
+  //\r
+  // Init the time out value\r
+  //\r
+  Timeout = BdsLibGetTimeout ();\r
+\r
+  //\r
+  // Load the driver option as the driver option list\r
+  //\r
+  PlatformBdsGetDriverOption (DriverOptionList);\r
+\r
+  //\r
+  // Get current Boot Mode\r
+  //\r
+  Status = BdsLibGetBootMode (&PrivateData->BootMode);\r
+\r
+  //\r
+  // Go the different platform policy with different boot mode\r
+  // Notes: this part code can be change with the table policy\r
+  //\r
+  switch (PrivateData->BootMode) {\r
+\r
+  case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
+  case BOOT_WITH_MINIMAL_CONFIGURATION:\r
+    //\r
+    // In no-configuration boot mode, we can connect the\r
+    // console directly.\r
+    //\r
+    BdsLibConnectAllDefaultConsoles ();\r
+    PlatformBdsDiagnostics (IGNORE, TRUE);\r
+\r
+    //\r
+    // Perform some platform specific connect sequence\r
+    //\r
+    PlatformBdsConnectSequence ();\r
+\r
+    //\r
+    // Notes: current time out = 0 can not enter the\r
+    // front page\r
+    //\r
+    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+\r
+    //\r
+    // Check the boot option with the boot option list\r
+    //\r
+    BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
+    break;\r
+\r
+  case BOOT_ON_FLASH_UPDATE:\r
+    //\r
+    // Boot with the specific configuration\r
+    //\r
+    PlatformBdsConnectConsole (gPlatformConsole);\r
+    PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
+    BdsLibConnectAll ();\r
+    ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
+    break;\r
+\r
+  case BOOT_IN_RECOVERY_MODE:\r
+    //\r
+    // In recovery mode, just connect platform console\r
+    // and show up the front page\r
+    //\r
+    PlatformBdsConnectConsole (gPlatformConsole);\r
+    PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
+\r
+    //\r
+    // In recovery boot mode, we still enter to the\r
+    // frong page now\r
+    //\r
+    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+    break;\r
+\r
+  case BOOT_WITH_FULL_CONFIGURATION:\r
+  case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
+  case BOOT_WITH_DEFAULT_SETTINGS:\r
+  default:\r
+    //\r
+    // Connect platform console\r
+    //\r
+    Status = PlatformBdsConnectConsole (gPlatformConsole);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Here OEM/IBV can customize with defined action\r
+      //\r
+      PlatformBdsNoConsoleAction ();\r
+    }\r
+\r
+    PlatformBdsDiagnostics (IGNORE, TRUE);\r
+\r
+    //\r
+    // Perform some platform specific connect sequence\r
+    //\r
+    PlatformBdsConnectSequence ();\r
+\r
+    //\r
+    // Give one chance to enter the setup if we\r
+    // have the time out\r
+    //\r
+    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+\r
+    //\r
+    // Here we have enough time to do the enumeration of boot device\r
+    //\r
+    BdsLibEnumerateAllBootOption (BootOptionList);\r
+    break;\r
+  }\r
+\r
+  return ;\r
+\r
+}\r
+\r
+VOID\r
+PlatformBdsBootSuccess (\r
+  IN  BDS_COMMON_OPTION *Option\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Hook point after a boot attempt succeeds. We don't expect a boot option to\r
+  return, so the EFI 1.0 specification defines that you will default to an\r
+  interactive mode and stop processing the BootOrder list in this case. This\r
+  is alos a platform implementation and can be customized by IBV/OEM.\r
+\r
+Arguments:\r
+\r
+  Option - Pointer to Boot Option that succeeded to boot.\r
+\r
+Returns:\r
+  \r
+  None.\r
+\r
+--*/\r
+{\r
+  CHAR16  *TmpStr;\r
+\r
+  //\r
+  // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
+  // select loop then we need to pop up a UI and wait for user input.\r
+  //\r
+  TmpStr = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
+  if (TmpStr != NULL) {\r
+    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
+    gBS->FreePool (TmpStr);\r
+  }\r
+}\r
+\r
+VOID\r
+PlatformBdsBootFail (\r
+  IN  BDS_COMMON_OPTION  *Option,\r
+  IN  EFI_STATUS         Status,\r
+  IN  CHAR16             *ExitData,\r
+  IN  UINTN              ExitDataSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Hook point after a boot attempt fails.\r
+\r
+Arguments:\r
+  \r
+  Option - Pointer to Boot Option that failed to boot.\r
+\r
+  Status - Status returned from failed boot.\r
+\r
+  ExitData - Exit data returned from failed boot.\r
+\r
+  ExitDataSize - Exit data size returned from failed boot.\r
+\r
+Returns:\r
+  \r
+  None.\r
+\r
+--*/\r
+{\r
+  CHAR16  *TmpStr;\r
+\r
+  //\r
+  // If Boot returned with failed status then we need to pop up a UI and wait\r
+  // for user input.\r
+  //\r
+  TmpStr = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
+  if (TmpStr != NULL) {\r
+    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
+    gBS->FreePool (TmpStr);\r
+  }\r
+\r
+}\r
+\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This function is remained for IBV/OEM to do some platform action,\r
+  if there no console device can be connected.\r
+\r
+Arguments:\r
+  \r
+  None.\r
+  \r
+Returns:\r
+  \r
+  EFI_SUCCESS      - Direct return success now.\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.h b/EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.h
new file mode 100644 (file)
index 0000000..166f7d1
--- /dev/null
@@ -0,0 +1,145 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  BdsPlatform.h\r
+\r
+Abstract:\r
+\r
+  Head file for BDS Platform specific code\r
+\r
+--*/\r
+\r
+#ifndef _BDS_PLATFORM_H\r
+#define _BDS_PLATFORM_H\r
+\r
+#include "IndustryStandard/pci22.h"\r
+\r
+extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
+extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];\r
+extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];\r
+\r
+#define gEndEntire \\r
+  { \\r
+    END_DEVICE_PATH_TYPE,\\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
+    END_DEVICE_PATH_LENGTH,\\r
+    0\\r
+  }\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH  VendorDevicePath;\r
+  UINT32              Instance;\r
+} UNIX_VENDOR_DEVICE_PATH_NODE;\r
+\r
+//\r
+// Below is the platform console device path\r
+//\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              UnixBus;\r
+  UNIX_VENDOR_DEVICE_PATH_NODE  SerialDevice;\r
+  UART_DEVICE_PATH                Uart;\r
+  VENDOR_DEVICE_PATH              TerminalType;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} UNIX_ISA_SERIAL_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              UnixBus;\r
+  UNIX_VENDOR_DEVICE_PATH_NODE  UnixUgaDevice;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} UNIX_PLATFORM_UGA_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              UnixBus;\r
+  UNIX_VENDOR_DEVICE_PATH_NODE   ConsoleDevice;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} UNIX_CONSOLE_DEVICE_PATH;\r
+//\r
+// Platform BDS Functions\r
+//\r
+VOID\r
+PlatformBdsInit (\r
+  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsPolicyBehavior (\r
+  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData,\r
+  IN LIST_ENTRY                      *DriverOptionList,\r
+  IN LIST_ENTRY                      *BootOptionList\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsGetDriverOption (\r
+  IN LIST_ENTRY               *BdsDriverLists\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+BdsMemoryTest (\r
+  EXTENDMEM_COVERAGE_LEVEL Level\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PlatformBdsShowProgress (\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,\r
+  CHAR16                        *Title,\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,\r
+  UINTN                         Progress,\r
+  UINTN                         PreviousValue\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsBootFail (\r
+  IN  BDS_COMMON_OPTION  *Option,\r
+  IN  EFI_STATUS         Status,\r
+  IN  CHAR16             *ExitData,\r
+  IN  UINTN              ExitDataSize\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsBootSuccess (\r
+  IN  BDS_COMMON_OPTION *Option\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+ProcessCapsules (\r
+  EFI_BOOT_MODE BootMode\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PlatformBdsConnectConsole (\r
+  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+  VOID\r
+  )\r
+;\r
+\r
+#endif // _BDS_PLATFORM_H\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.h.orig b/EdkUnixPkg/Dxe/PlatformBds/BdsPlatform.h.orig
new file mode 100644 (file)
index 0000000..f0dcf22
--- /dev/null
@@ -0,0 +1,145 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  BdsPlatform.h\r
+\r
+Abstract:\r
+\r
+  Head file for BDS Platform specific code\r
+\r
+--*/\r
+\r
+#ifndef _BDS_PLATFORM_H\r
+#define _BDS_PLATFORM_H\r
+\r
+#include "IndustryStandard/pci22.h"\r
+\r
+extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
+extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];\r
+extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];\r
+\r
+#define gEndEntire \\r
+  { \\r
+    END_DEVICE_PATH_TYPE,\\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
+    END_DEVICE_PATH_LENGTH,\\r
+    0\\r
+  }\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH  VendorDevicePath;\r
+  UINT32              Instance;\r
+} UNIX_VENDOR_DEVICE_PATH_NODE;\r
+\r
+//\r
+// Below is the platform console device path\r
+//\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              UnixBus;\r
+  UNIX_VENDOR_DEVICE_PATH_NODE  SerialDevice;\r
+  UART_DEVICE_PATH                Uart;\r
+  VENDOR_DEVICE_PATH              TerminalType;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} UNIX_ISA_SERIAL_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              UnixBus;\r
+  UNIX_VENDOR_DEVICE_PATH_NODE  UnixUgaDevice;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} UNIX_PLATFORM_UGA_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH              UnixBus;\r
+  UNIX_VENDOR_DEVICE_PATH_NODE   ConsoleDevice;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} UNIX_CONSOLE_DEVICE_PATH;\r
+//\r
+// Platform BDS Functions\r
+//\r
+VOID\r
+PlatformBdsInit (\r
+  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsPolicyBehavior (\r
+  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData,\r
+  IN LIST_ENTRY                      *DriverOptionList,\r
+  IN LIST_ENTRY                      *BootOptionList\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsGetDriverOption (\r
+  IN LIST_ENTRY               *BdsDriverLists\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+BdsMemoryTest (\r
+  EXTENDMEM_COVERAGE_LEVEL Level\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PlatformBdsShowProgress (\r
+  EFI_UGA_PIXEL TitleForeground,\r
+  EFI_UGA_PIXEL TitleBackground,\r
+  CHAR16        *Title,\r
+  EFI_UGA_PIXEL ProgressColor,\r
+  UINTN         Progress,\r
+  UINTN         PreviousValue\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsBootFail (\r
+  IN  BDS_COMMON_OPTION  *Option,\r
+  IN  EFI_STATUS         Status,\r
+  IN  CHAR16             *ExitData,\r
+  IN  UINTN              ExitDataSize\r
+  )\r
+;\r
+\r
+VOID\r
+PlatformBdsBootSuccess (\r
+  IN  BDS_COMMON_OPTION *Option\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+ProcessCapsules (\r
+  EFI_BOOT_MODE BootMode\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PlatformBdsConnectConsole (\r
+  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+  VOID\r
+  )\r
+;\r
+\r
+#endif // _BDS_PLATFORM_H\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/Bds.dxs b/EdkUnixPkg/Dxe/PlatformBds/Generic/Bds.dxs
new file mode 100644 (file)
index 0000000..6647561
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bds.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.  This driver produces an arch protocol, so\r
+  must dipatch early.\r
+  \r
+--*/\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  EFI_HII_PROTOCOL_GUID\r
+DEPENDENCY_END
\ No newline at end of file
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/Bds.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/Bds.h
new file mode 100644 (file)
index 0000000..2d9d199
--- /dev/null
@@ -0,0 +1,83 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Bds.h\r
+\r
+Abstract:\r
+\r
+  Head file for BDS Architectural Protocol implementation\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _BDS_H\r
+#define _BDS_H\r
+\r
+//\r
+// Bds AP Context data\r
+//\r
+#define EFI_BDS_ARCH_PROTOCOL_INSTANCE_SIGNATURE  EFI_SIGNATURE_32 ('B', 'd', 's', 'A')\r
+typedef struct {\r
+  UINTN                     Signature;\r
+\r
+  EFI_HANDLE                Handle;\r
+\r
+  EFI_BDS_ARCH_PROTOCOL     Bds;\r
+\r
+  //\r
+  // Save the current boot mode\r
+  //\r
+  EFI_BOOT_MODE             BootMode;\r
+\r
+  //\r
+  // Set true if boot with default settings\r
+  //\r
+  BOOLEAN                   DefaultBoot;\r
+\r
+  //\r
+  // The system default timeout for choose the boot option\r
+  //\r
+  UINT16                    TimeoutDefault;\r
+\r
+  //\r
+  // Memory Test Level\r
+  //\r
+  EXTENDMEM_COVERAGE_LEVEL  MemoryTestLevel;\r
+\r
+} EFI_BDS_ARCH_PROTOCOL_INSTANCE;\r
+\r
+#define EFI_BDS_ARCH_PROTOCOL_INSTANCE_FROM_THIS(_this) \\r
+  CR (_this, \\r
+      EFI_BDS_ARCH_PROTOCOL_INSTANCE, \\r
+      Bds, \\r
+      EFI_BDS_ARCH_PROTOCOL_INSTANCE_SIGNATURE \\r
+      )\r
+\r
+//\r
+// Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+BdsInitialize (\r
+  IN EFI_HANDLE                     ImageHandle,\r
+  IN EFI_SYSTEM_TABLE               *SystemTable\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BdsEntry (\r
+  IN  EFI_BDS_ARCH_PROTOCOL *This\r
+  );\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BdsEntry.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BdsEntry.c
new file mode 100644 (file)
index 0000000..ddd6b4f
--- /dev/null
@@ -0,0 +1,356 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsEntry.c\r
+\r
+Abstract:\r
+\r
+  The entry of the bds\r
+\r
+--*/\r
+\r
+#include "Bds.h"\r
+#include "BdsPlatform.h"\r
+#include "FrontPage.h"\r
+\r
+EFI_BDS_ARCH_PROTOCOL_INSTANCE  gBdsInstanceTemplate = {\r
+  EFI_BDS_ARCH_PROTOCOL_INSTANCE_SIGNATURE,\r
+  NULL,\r
+  BdsEntry,\r
+  0xFFFF,\r
+  TRUE,\r
+  EXTENSIVE\r
+};\r
+\r
+UINT16                          *mBootNext = NULL;\r
+\r
+EFI_HANDLE                      mBdsImageHandle;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BdsInitialize (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Install Boot Device Selection Protocol\r
+\r
+Arguments:\r
+  \r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS - BDS has finished initializing.\r
+                Rerun the \r
+                dispatcher and recall BDS.Entry\r
+\r
+  Other       - Return value from EfiLibAllocatePool()\r
+                or gBS->InstallProtocolInterface\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  mBdsImageHandle = ImageHandle;\r
+\r
+  //\r
+  // Install protocol interface\r
+  //\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &gBdsInstanceTemplate.Handle,\r
+                  &gEfiBdsArchProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &gBdsInstanceTemplate.Bds\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+VOID\r
+BdsBootDeviceSelect (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  In the loop of attempt to boot for the boot order\r
+\r
+Arguments:\r
+  \r
+  None.\r
+\r
+Returns:\r
+\r
+  None.\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  LIST_ENTRY        *Link;\r
+  BDS_COMMON_OPTION *BootOption;\r
+  UINTN             ExitDataSize;\r
+  CHAR16            *ExitData;\r
+  UINT16            Timeout;\r
+  LIST_ENTRY        BootLists;\r
+  CHAR16            Buffer[20];\r
+  BOOLEAN           BootNextExist;\r
+  LIST_ENTRY        *LinkBootNext;\r
+\r
+  //\r
+  // Got the latest boot option\r
+  //\r
+  BootNextExist = FALSE;\r
+  LinkBootNext  = NULL;\r
+  InitializeListHead (&BootLists);\r
+\r
+  //\r
+  // First check the boot next option\r
+  //\r
+  ZeroMem (Buffer, sizeof (Buffer));\r
+\r
+  if (mBootNext != NULL) {\r
+    //\r
+    // Indicate we have the boot next variable, so this time\r
+    // boot will always have this boot option\r
+    //\r
+    BootNextExist = TRUE;\r
+\r
+    //\r
+    // Clear the this variable so it's only exist in this time boot\r
+    //\r
+    gRT->SetVariable (\r
+          L"BootNext",\r
+          &gEfiGlobalVariableGuid,\r
+          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+          0,\r
+          mBootNext\r
+          );\r
+\r
+    //\r
+    // Add the boot next boot option\r
+    //\r
+    UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *mBootNext);\r
+    BootOption = BdsLibVariableToOption (&BootLists, Buffer);\r
+  }\r
+  //\r
+  // Parse the boot order to get boot option\r
+  //\r
+  BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
+  Link = BootLists.ForwardLink;\r
+\r
+  //\r
+  // Parameter check, make sure the loop will be valid\r
+  //\r
+  if (Link == NULL) {\r
+    return ;\r
+  }\r
+  //\r
+  // Here we make the boot in a loop, every boot success will\r
+  // return to the front page\r
+  //\r
+  for (;;) {\r
+    //\r
+    // Check the boot option list first\r
+    //\r
+    if (Link == &BootLists) {\r
+      //\r
+      // There are two ways to enter here:\r
+      // 1. There is no active boot option, give user chance to\r
+      //    add new boot option\r
+      // 2. All the active boot option processed, and there is no\r
+      //    one is success to boot, then we back here to allow user\r
+      //    add new active boot option\r
+      //\r
+      Timeout = 0xffff;\r
+      PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+      InitializeListHead (&BootLists);\r
+      BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
+      Link = BootLists.ForwardLink;\r
+      continue;\r
+    }\r
+    //\r
+    // Get the boot option from the link list\r
+    //\r
+    BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+\r
+    //\r
+    // According to EFI Specification, if a load option is not marked\r
+    // as LOAD_OPTION_ACTIVE, the boot manager will not automatically\r
+    // load the option.\r
+    //\r
+    if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
+      //\r
+      // skip the header of the link list, becuase it has no boot option\r
+      //\r
+      Link = Link->ForwardLink;\r
+      continue;\r
+    }\r
+    //\r
+    // Make sure the boot option device path connected,\r
+    // but ignore the BBS device path\r
+    //\r
+    if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
+      //\r
+      // Notes: the internal shell can not been connected with device path\r
+      // so we do not check the status here\r
+      //\r
+      BdsLibConnectDevicePath (BootOption->DevicePath);\r
+    }\r
+    //\r
+    // All the driver options should have been processed since\r
+    // now boot will be performed.\r
+    //\r
+    PERF_END (0, BDS_TOK, NULL, 0);\r
+    Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Call platform action to indicate the boot fail\r
+      //\r
+      PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);\r
+\r
+      //\r
+      // Check the next boot option\r
+      //\r
+      Link = Link->ForwardLink;\r
+\r
+    } else {\r
+      //\r
+      // Call platform action to indicate the boot success\r
+      //\r
+      PlatformBdsBootSuccess (BootOption);\r
+\r
+      //\r
+      // Boot success, then stop process the boot order, and\r
+      // present the boot manager menu, front page\r
+      //\r
+      Timeout = 0xffff;\r
+      PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+\r
+      //\r
+      // Rescan the boot option list, avoid pertential risk of the boot\r
+      // option change in front page\r
+      //\r
+      if (BootNextExist) {\r
+        LinkBootNext = BootLists.ForwardLink;\r
+      }\r
+\r
+      InitializeListHead (&BootLists);\r
+      if (LinkBootNext != NULL) {\r
+        //\r
+        // Reserve the boot next option\r
+        //\r
+        InsertTailList (&BootLists, LinkBootNext);\r
+      }\r
+\r
+      BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
+      Link = BootLists.ForwardLink;\r
+    }\r
+  }\r
+\r
+  return ;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BdsEntry (\r
+  IN EFI_BDS_ARCH_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Service routine for BdsInstance->Entry(). Devices are connected, the \r
+  consoles are initialized, and the boot options are tried. \r
+\r
+Arguments:\r
+\r
+  This - Protocol Instance structure.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS - BDS->Entry has finished executing. \r
+                \r
+--*/\r
+{\r
+  EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData;\r
+  LIST_ENTRY                      DriverOptionList;\r
+  LIST_ENTRY                      BootOptionList;\r
+  UINTN                           BootNextSize;\r
+\r
+  //\r
+  // Insert the performance probe\r
+  //\r
+  PERF_END (0, DXE_TOK, NULL, 0);\r
+  PERF_START (0, BDS_TOK, NULL, 0);\r
+\r
+  //\r
+  // Initialize the global system boot option and driver option\r
+  //\r
+  InitializeListHead (&DriverOptionList);\r
+  InitializeListHead (&BootOptionList);\r
+\r
+  //\r
+  // Get the BDS private data\r
+  //\r
+  PrivateData = EFI_BDS_ARCH_PROTOCOL_INSTANCE_FROM_THIS (This);\r
+\r
+  //\r
+  // Do the platform init, can be customized by OEM/IBV\r
+  //\r
+  PERF_START (0, "PlatformBds", "BDS", 0);\r
+  PlatformBdsInit (PrivateData);\r
+\r
+  //\r
+  // Set up the device list based on EFI 1.1 variables\r
+  // process Driver#### and Load the driver's in the\r
+  // driver option list\r
+  //\r
+  BdsLibBuildOptionFromVar (&DriverOptionList, L"DriverOrder");\r
+  if (!IsListEmpty (&DriverOptionList)) {\r
+    BdsLibLoadDrivers (&DriverOptionList);\r
+  }\r
+  //\r
+  // Check if we have the boot next option\r
+  //\r
+  mBootNext = BdsLibGetVariableAndSize (\r
+                L"BootNext",\r
+                &gEfiGlobalVariableGuid,\r
+                &BootNextSize\r
+                );\r
+\r
+  //\r
+  // Setup some platform policy here\r
+  //\r
+  PlatformBdsPolicyBehavior (PrivateData, &DriverOptionList, &BootOptionList);\r
+  PERF_END (0, L"PlatformBds", L"BDS", 0);\r
+\r
+  //\r
+  // BDS select the boot device to load OS\r
+  //\r
+  BdsBootDeviceSelect ();\r
+\r
+  //\r
+  // Only assert here since this is the right behavior, we should never\r
+  // return back to DxeCore.\r
+  //\r
+  ASSERT (FALSE);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BBSsupport.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BBSsupport.c
new file mode 100644 (file)
index 0000000..c9f2402
--- /dev/null
@@ -0,0 +1,1601 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                          \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BBSsupport.c\r
+\r
+Abstract:\r
+\r
+  This function deal with the legacy boot option, it create, delete\r
+  and manage the legacy boot option, all legacy boot option is getting from\r
+  the legacy BBS table.\r
+\r
+--*/\r
+\r
+#include "BBSsupport.h"\r
+\r
+EFI_DEVICE_PATH_PROTOCOL  EndDevicePath[] = {\r
+  END_DEVICE_PATH_TYPE,\r
+  END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+  END_DEVICE_PATH_LENGTH,\r
+  0\r
+};\r
+\r
+VOID\r
+AsciiToUnicodeSize (\r
+  IN UINT8              *a,\r
+  IN UINTN              Size,\r
+  OUT UINT16            *u\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Translate the first n characters of an Ascii string to\r
+    Unicode characters. The count n is indicated by parameter\r
+    Size. If Size is greater than the length of string, then\r
+    the entire string is translated.\r
+\r
+  Arguments:\r
+\r
+    a         - Pointer to input Ascii string.\r
+    Size      - The number of characters to translate.\r
+    u         - Pointer to output Unicode string buffer.\r
+\r
+  Returns:\r
+\r
+    None\r
+\r
+--*/\r
+{\r
+  UINTN i;\r
+\r
+  i = 0;\r
+  while (a[i] != 0) {\r
+    u[i] = (CHAR16) a[i];\r
+    if (i == Size) {\r
+      break;\r
+    }\r
+\r
+    i++;\r
+  }\r
+  u[i] = 0;\r
+}\r
+\r
+VOID\r
+BdsBuildLegacyDevNameString (\r
+  IN BBS_TABLE                 *CurBBSEntry,\r
+  IN UINTN                     Index,\r
+  IN UINTN                     BufSize,\r
+  OUT CHAR16                   *BootString\r
+  )\r
+{\r
+  CHAR16  *Fmt;\r
+  CHAR16  *Type;\r
+  UINT8   *StringDesc;\r
+  CHAR16  temp[80];\r
+\r
+  switch (Index) {\r
+  //\r
+  // Primary Master\r
+  //\r
+  case 1:\r
+    Fmt = L"Primary Master %s";\r
+    break;\r
+\r
+ //\r
+ // Primary Slave\r
+ //\r
+  case 2:\r
+    Fmt = L"Primary Slave %s";\r
+    break;\r
+\r
+  //\r
+  // Secondary Master\r
+  //\r
+  case 3:\r
+    Fmt = L"Secondary Master %s";\r
+    break;\r
+\r
+  //\r
+  // Secondary Slave\r
+  //\r
+  case 4:\r
+    Fmt = L"Secondary Slave %s";\r
+    break;\r
+\r
+  default:\r
+    Fmt = L"%s";\r
+    break;\r
+  }\r
+\r
+  switch (CurBBSEntry->DeviceType) {\r
+  case BBS_FLOPPY:\r
+    Type = L"Floppy";\r
+    break;\r
+\r
+  case BBS_HARDDISK:\r
+    Type = L"Harddisk";\r
+    break;\r
+\r
+  case BBS_CDROM:\r
+    Type = L"CDROM";\r
+    break;\r
+\r
+  case BBS_PCMCIA:\r
+    Type = L"PCMCIAe";\r
+    break;\r
+\r
+  case BBS_USB:\r
+    Type = L"USB";\r
+    break;\r
+\r
+  case BBS_EMBED_NETWORK:\r
+    Type = L"Network";\r
+    break;\r
+\r
+  case BBS_BEV_DEVICE:\r
+    Type = L"BEVe";\r
+    break;\r
+\r
+  case BBS_UNKNOWN:\r
+  default:\r
+    Type = L"Unknown";\r
+    break;\r
+  }\r
+  //\r
+  // If current BBS entry has its description then use it.\r
+  //\r
+  StringDesc = (UINT8 *) (UINTN) ((CurBBSEntry->DescStringSegment << 4) + CurBBSEntry->DescStringOffset);\r
+  if (NULL != StringDesc) {\r
+    //\r
+    // Only get fisrt 32 characters, this is suggested by BBS spec\r
+    //\r
+    AsciiToUnicodeSize (StringDesc, 32, temp);\r
+    Fmt   = L"%s";\r
+    Type  = temp;\r
+  }\r
+\r
+  UnicodeSPrint (BootString, BufSize, Fmt, Type);\r
+}\r
+\r
+EFI_STATUS\r
+BdsCreateLegacyBootOption (\r
+  IN BBS_TABLE                        *CurrentBbsEntry,\r
+  IN EFI_DEVICE_PATH_PROTOCOL         *CurrentBbsDevPath,\r
+  IN UINTN                            Index,\r
+  IN OUT UINT16                       **BootOrderList,\r
+  IN OUT UINTN                        *BootOrderListSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Create a legacy boot option for the specified entry of\r
+    BBS table, save it as variable, and append it to the boot\r
+    order list.\r
+\r
+  Arguments:\r
+\r
+    CurrentBbsEntry        - Pointer to current BBS table.\r
+    CurrentBbsDevPath      - Pointer to the Device Path Protocol instance of BBS\r
+    Index                  - Index of the specified entry in BBS table.\r
+    BootOrderList          - On input, the original boot order list.\r
+                             On output, the new boot order list attached with the\r
+                             created node.\r
+    BootOrderListSize      - On input, the original size of boot order list.\r
+                           - On output, the size of new boot order list.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS            - Boot Option successfully created.\r
+    EFI_OUT_OF_RESOURCES   - Fail to allocate necessary memory.\r
+    Other                  - Error occurs while setting variable.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT16      CurrentBootOptionNo;\r
+  UINT16      BootString[10];\r
+  UINT16      BootDesc[100];\r
+  UINT16      *NewBootOrderList;\r
+  UINTN       BufferSize;\r
+  VOID        *Buffer;\r
+  UINT8       *Ptr;\r
+  UINT16      CurrentBbsDevPathSize;\r
+  UINTN       BootOrderIndex;\r
+  UINTN       BootOrderLastIndex;\r
+  UINTN       ArrayIndex;\r
+  BOOLEAN     IndexNotFound;\r
+\r
+  if (NULL == (*BootOrderList)) {\r
+    CurrentBootOptionNo = 0;\r
+  } else {\r
+    for (ArrayIndex = 0; ArrayIndex < (UINTN) (*BootOrderListSize / sizeof (UINT16)); ArrayIndex++) {\r
+      IndexNotFound = TRUE;\r
+      for (BootOrderIndex = 0; BootOrderIndex < (UINTN) (*BootOrderListSize / sizeof (UINT16)); BootOrderIndex++) {\r
+        if ((*BootOrderList)[BootOrderIndex] == ArrayIndex) {\r
+          IndexNotFound = FALSE;\r
+          break;\r
+        }\r
+      }\r
+\r
+      if (!IndexNotFound) {\r
+        continue;\r
+      } else {\r
+        break;\r
+      }\r
+    }\r
+\r
+    CurrentBootOptionNo = (UINT16) ArrayIndex;\r
+  }\r
+\r
+  UnicodeSPrint (\r
+    BootString,\r
+    sizeof (BootString),\r
+    L"Boot%04x",\r
+    CurrentBootOptionNo\r
+    );\r
+\r
+  BdsBuildLegacyDevNameString (CurrentBbsEntry, Index, sizeof (BootDesc), BootDesc);\r
+\r
+  CurrentBbsDevPathSize = (UINT16) (GetDevicePathSize (CurrentBbsDevPath));\r
+\r
+  BufferSize = sizeof (UINT32) +\r
+    sizeof (UINT16) +\r
+    StrSize (BootDesc) +\r
+    CurrentBbsDevPathSize +\r
+    sizeof (BBS_TABLE) +\r
+    sizeof (UINT16);\r
+\r
+  Buffer = AllocateZeroPool (BufferSize);\r
+  if (Buffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Ptr               = (UINT8 *) Buffer;\r
+\r
+  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE;\r
+  Ptr += sizeof (UINT32);\r
+\r
+  *((UINT16 *) Ptr) = CurrentBbsDevPathSize;\r
+  Ptr += sizeof (UINT16);\r
+\r
+  CopyMem (\r
+    Ptr,\r
+    BootDesc,\r
+    StrSize (BootDesc)\r
+    );\r
+  Ptr += StrSize (BootDesc);\r
+\r
+  CopyMem (\r
+    Ptr,\r
+    CurrentBbsDevPath,\r
+    CurrentBbsDevPathSize\r
+    );\r
+  Ptr += CurrentBbsDevPathSize;\r
+\r
+  CopyMem (\r
+    Ptr,\r
+    CurrentBbsEntry,\r
+    sizeof (BBS_TABLE)\r
+    );\r
+\r
+  Ptr += sizeof (BBS_TABLE);\r
+  *((UINT16 *) Ptr) = (UINT16) Index;\r
+\r
+  Status = gRT->SetVariable (\r
+                  BootString,\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  BufferSize,\r
+                  Buffer\r
+                  );\r
+\r
+  SafeFreePool (Buffer);\r
+  Buffer = NULL;\r
+\r
+  NewBootOrderList = AllocateZeroPool (*BootOrderListSize + sizeof (UINT16));\r
+  if (NULL == NewBootOrderList) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  if (NULL != *BootOrderList) {\r
+    CopyMem (NewBootOrderList, *BootOrderList, *BootOrderListSize);\r
+  }\r
+\r
+  SafeFreePool (*BootOrderList);\r
+\r
+  BootOrderLastIndex                    = (UINTN) (*BootOrderListSize / sizeof (UINT16));\r
+  NewBootOrderList[BootOrderLastIndex]  = CurrentBootOptionNo;\r
+  *BootOrderListSize += sizeof (UINT16);\r
+  *BootOrderList = NewBootOrderList;\r
+\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+BdsIsLegacyBootOption (\r
+  IN UINT8                 *BootOptionVar,\r
+  OUT BBS_TABLE            **BbsEntry,\r
+  OUT UINT16               *BbsIndex\r
+  )\r
+{\r
+  UINT8                     *Ptr;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  BOOLEAN                   Ret;\r
+  UINT16                    DevPathLen;\r
+\r
+  Ptr = BootOptionVar;\r
+  Ptr += sizeof (UINT32);\r
+  DevPathLen = *(UINT16 *) Ptr;\r
+  Ptr += sizeof (UINT16);\r
+  Ptr += StrSize ((UINT16 *) Ptr);\r
+  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+  if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {\r
+    Ptr += DevPathLen;\r
+    *BbsEntry = (BBS_TABLE *) Ptr;\r
+    Ptr += sizeof (BBS_TABLE);\r
+    *BbsIndex = *(UINT16 *) Ptr;\r
+    Ret       = TRUE;\r
+  } else {\r
+    *BbsEntry = NULL;\r
+    Ret       = FALSE;\r
+  }\r
+\r
+  return Ret;\r
+}\r
+\r
+EFI_STATUS\r
+BdsDeleteBootOption (\r
+  IN UINTN                       OptionNumber,\r
+  IN OUT UINT16                  *BootOrder,\r
+  IN OUT UINTN                   *BootOrderSize\r
+  )\r
+{\r
+  UINT16      BootOption[100];\r
+  UINTN       Index;\r
+  EFI_STATUS  Status;\r
+  UINTN       Index2Del;\r
+\r
+  Status    = EFI_SUCCESS;\r
+  Index2Del = 0;\r
+\r
+  UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", OptionNumber);\r
+  Status = EfiLibDeleteVariable (BootOption, &gEfiGlobalVariableGuid);\r
+  //\r
+  // adjust boot order array\r
+  //\r
+  for (Index = 0; Index < *BootOrderSize / sizeof (UINT16); Index++) {\r
+    if (BootOrder[Index] == OptionNumber) {\r
+      Index2Del = Index;\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (Index != *BootOrderSize / sizeof (UINT16)) {\r
+    for (Index = 0; Index < *BootOrderSize / sizeof (UINT16) - 1; Index++) {\r
+      if (Index >= Index2Del) {\r
+        BootOrder[Index] = BootOrder[Index + 1];\r
+      }\r
+    }\r
+\r
+    *BootOrderSize -= sizeof (UINT16);\r
+  }\r
+\r
+  return Status;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsDeleteAllInvalidLegacyBootOptions (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Delete all the invalid legacy boot options.\r
+\r
+  Arguments:\r
+\r
+    None.\r
+\r
+  Returns:\r
+\r
+    EFI_SUCCESS            - All invalide legacy boot options are deleted.\r
+    EFI_OUT_OF_RESOURCES   - Fail to allocate necessary memory.\r
+    EFI_NOT_FOUND          - Fail to retrive variable of boot order.\r
+    Other                  - Error occurs while setting variable or locating\r
+                             protocol.\r
+\r
+--*/\r
+{\r
+  UINT16                    *BootOrder;\r
+  UINT8                     *BootOptionVar;\r
+  UINTN                     BootOrderSize;\r
+  UINTN                     BootOptionSize;\r
+  EFI_STATUS                Status;\r
+  UINT16                    HddCount;\r
+  UINT16                    BbsCount;\r
+  HDD_INFO                  *LocalHddInfo;\r
+  BBS_TABLE                 *LocalBbsTable;\r
+  BBS_TABLE                 *BbsEntry;\r
+  UINT16                    BbsIndex;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  UINTN                     Index;\r
+  UINT16                    BootOption[10];\r
+  UINT16                    BootDesc[100];\r
+  BOOLEAN                   DescStringMatch;\r
+\r
+  Status        = EFI_SUCCESS;\r
+  BootOrder     = NULL;\r
+  BootOrderSize = 0;\r
+  HddCount      = 0;\r
+  BbsCount      = 0;\r
+  LocalHddInfo  = NULL;\r
+  LocalBbsTable = NULL;\r
+  BbsEntry      = NULL;\r
+\r
+  Status        = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, &LegacyBios);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  LegacyBios->GetBbsInfo (\r
+                LegacyBios,\r
+                &HddCount,\r
+                &LocalHddInfo,\r
+                &BbsCount,\r
+                &LocalBbsTable\r
+                );\r
+\r
+  BootOrder = BdsLibGetVariableAndSize (\r
+                L"BootOrder",\r
+                &gEfiGlobalVariableGuid,\r
+                &BootOrderSize\r
+                );\r
+  if (NULL == BootOrder) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < BootOrderSize / sizeof (UINT16)) {\r
+    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
+    BootOptionVar = BdsLibGetVariableAndSize (\r
+                      BootOption,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &BootOptionSize\r
+                      );\r
+    if (NULL == BootOptionVar) {\r
+      SafeFreePool (BootOrder);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, &BbsIndex)) {\r
+      SafeFreePool (BootOptionVar);\r
+      Index++;\r
+      continue;\r
+    }\r
\r
+    //\r
+    // Check if BBS Description String is changed\r
+    //\r
+    DescStringMatch = FALSE;\r
+    \r
+    BdsBuildLegacyDevNameString (\r
+      &LocalBbsTable[BbsIndex], \r
+      BbsIndex, \r
+      sizeof(BootDesc), \r
+      BootDesc\r
+      );\r
+    \r
+    if (StrCmp (BootDesc, (UINT16*)(BootOptionVar + sizeof (UINT32) + sizeof (UINT16))) == 0) {\r
+      DescStringMatch = TRUE;\r
+    }\r
+\r
+    if (!((LocalBbsTable[BbsIndex].BootPriority == BBS_IGNORE_ENTRY) ||\r
+          (LocalBbsTable[BbsIndex].BootPriority == BBS_DO_NOT_BOOT_FROM) ||\r
+          (LocalBbsTable[BbsIndex].BootPriority == BBS_LOWEST_PRIORITY)) &&\r
+        (LocalBbsTable[BbsIndex].DeviceType == BbsEntry->DeviceType) &&\r
+        DescStringMatch) {\r
+      Index++;\r
+      continue;\r
+    }\r
+\r
+    SafeFreePool (BootOptionVar);\r
+    //\r
+    // should delete\r
+    //\r
+    BdsDeleteBootOption (\r
+      BootOrder[Index],\r
+      BootOrder,\r
+      &BootOrderSize\r
+      );\r
+  }\r
+\r
+  if (BootOrderSize) {\r
+    Status = gRT->SetVariable (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    BootOrderSize,\r
+                    BootOrder\r
+                    );\r
+  } else {\r
+    EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+  }\r
+\r
+  SafeFreePool (BootOrder);\r
+\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+BdsFindLegacyBootOptionByDevType (\r
+  IN UINT16                 *BootOrder,\r
+  IN UINTN                  BootOptionNum,\r
+  IN UINT16                 DevType,\r
+  OUT UINT32                *Attribute,\r
+  OUT UINT16                *BbsIndex,\r
+  OUT UINTN                 *OptionNumber\r
+  )\r
+{\r
+  UINTN     Index;\r
+  UINTN     BootOrderIndex;\r
+  UINT16    BootOption[100];\r
+  UINTN     BootOptionSize;\r
+  UINT8     *BootOptionVar;\r
+  BBS_TABLE *BbsEntry;\r
+  BOOLEAN   Found;\r
+\r
+  BbsEntry  = NULL;\r
+  Found     = FALSE;\r
+\r
+  if (NULL == BootOrder) {\r
+    return Found;\r
+  }\r
+\r
+  for (BootOrderIndex = 0; BootOrderIndex < BootOptionNum; BootOrderIndex++) {\r
+    Index = (UINTN) BootOrder[BootOrderIndex];\r
+    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", Index);\r
+    BootOptionVar = BdsLibGetVariableAndSize (\r
+                      BootOption,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &BootOptionSize\r
+                      );\r
+    if (NULL == BootOptionVar) {\r
+      continue;\r
+    }\r
+\r
+    if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, BbsIndex)) {\r
+      SafeFreePool (BootOptionVar);\r
+      continue;\r
+    }\r
+\r
+    if (BbsEntry->DeviceType != DevType) {\r
+      SafeFreePool (BootOptionVar);\r
+      continue;\r
+    }\r
+\r
+    *Attribute    = *(UINT32 *) BootOptionVar;\r
+    *OptionNumber = Index;\r
+    Found         = TRUE;\r
+    SafeFreePool (BootOptionVar);\r
+    break;\r
+  }\r
+\r
+  return Found;\r
+}\r
+\r
+EFI_STATUS\r
+BdsCreateOneLegacyBootOption (\r
+  IN BBS_TABLE              *BbsItem,\r
+  IN UINTN                  Index,\r
+  IN OUT UINT16             **BootOrderList,\r
+  IN OUT UINTN              *BootOrderListSize\r
+  )\r
+{\r
+  BBS_BBS_DEVICE_PATH       BbsDevPathNode;\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+\r
+  DevPath                       = NULL;\r
+\r
+  BbsDevPathNode.Header.Type    = BBS_DEVICE_PATH;\r
+  BbsDevPathNode.Header.SubType = BBS_BBS_DP;\r
+  SetDevicePathNodeLength (&BbsDevPathNode.Header, sizeof (BBS_BBS_DEVICE_PATH));\r
+  BbsDevPathNode.DeviceType = BbsItem->DeviceType;\r
+  CopyMem (&BbsDevPathNode.StatusFlag, &BbsItem->StatusFlags, sizeof (UINT16));\r
+\r
+  DevPath = AppendDevicePathNode (\r
+              EndDevicePath,\r
+              (EFI_DEVICE_PATH_PROTOCOL *) &BbsDevPathNode\r
+              );\r
+  if (NULL == DevPath) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = BdsCreateLegacyBootOption (\r
+            BbsItem,\r
+            DevPath,\r
+            Index,\r
+            BootOrderList,\r
+            BootOrderListSize\r
+            );\r
+  BbsItem->BootPriority = 0x00;\r
+\r
+  gBS->FreePool (DevPath);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsAddNonExistingLegacyBootOptions (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add the legacy boot options from BBS table if they do not exist.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - The boot options are added successfully or they are already in boot options.\r
+  others            - An error occurred when creating legacy boot options.\r
+\r
+--*/\r
+{\r
+  UINT16                    *BootOrder;\r
+  UINTN                     BootOrderSize;\r
+  EFI_STATUS                Status;\r
+  UINT16                    HddCount;\r
+  UINT16                    BbsCount;\r
+  HDD_INFO                  *LocalHddInfo;\r
+  BBS_TABLE                 *LocalBbsTable;\r
+  UINT16                    BbsIndex;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  UINTN                     Index;\r
+  UINT32                    Attribute;\r
+  UINTN                     OptionNumber;\r
+  BOOLEAN                   Ret;\r
+\r
+  BootOrder     = NULL;\r
+  HddCount      = 0;\r
+  BbsCount      = 0;\r
+  LocalHddInfo  = NULL;\r
+  LocalBbsTable = NULL;\r
+\r
+  Status        = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, &LegacyBios);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  LegacyBios->GetBbsInfo (\r
+                LegacyBios,\r
+                &HddCount,\r
+                &LocalHddInfo,\r
+                &BbsCount,\r
+                &LocalBbsTable\r
+                );\r
+\r
+  BootOrder = BdsLibGetVariableAndSize (\r
+                L"BootOrder",\r
+                &gEfiGlobalVariableGuid,\r
+                &BootOrderSize\r
+                );\r
+  if (NULL == BootOrder) {\r
+    BootOrderSize = 0;\r
+  }\r
+\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if ((LocalBbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) ||\r
+        (LocalBbsTable[Index].BootPriority == BBS_DO_NOT_BOOT_FROM)\r
+        ) {\r
+      continue;\r
+    }\r
+\r
+    Ret = BdsFindLegacyBootOptionByDevType (\r
+            BootOrder,\r
+            BootOrderSize / sizeof (UINT16),\r
+            LocalBbsTable[Index].DeviceType,\r
+            &Attribute,\r
+            &BbsIndex,\r
+            &OptionNumber\r
+            );\r
+    if (Ret && (Attribute & LOAD_OPTION_ACTIVE) != 0) {\r
+      continue;\r
+    }\r
+\r
+    if (Ret) {\r
+      if (Index != BbsIndex) {\r
+        BdsDeleteBootOption (\r
+          OptionNumber,\r
+          BootOrder,\r
+          &BootOrderSize\r
+          );\r
+      } else {\r
+        continue;\r
+      }\r
+    }\r
+    //\r
+    // Not found such type of legacy device in boot options or we found but it's disabled\r
+    // so we have to create one and put it to the tail of boot order list\r
+    //\r
+    Status = BdsCreateOneLegacyBootOption (\r
+              &LocalBbsTable[Index],\r
+              Index,\r
+              &BootOrder,\r
+              &BootOrderSize\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (BootOrderSize > 0) {\r
+    Status = gRT->SetVariable (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    BootOrderSize,\r
+                    BootOrder\r
+                    );\r
+  } else {\r
+    EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+  }\r
+\r
+  if (BootOrder != NULL) {\r
+    SafeFreePool (BootOrder);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+UINT16 *\r
+BdsFillDevOrderBuf (\r
+  IN BBS_TABLE                    *BbsTable,\r
+  IN BBS_TYPE                     BbsType,\r
+  IN UINTN                        BbsCount,\r
+  IN UINT16                       *Buf\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {\r
+      continue;\r
+    }\r
+\r
+    if (BbsTable[Index].DeviceType != BbsType) {\r
+      continue;\r
+    }\r
+\r
+    *Buf = (UINT16) (Index & 0xFF);\r
+    Buf++;\r
+  }\r
+\r
+  return Buf;\r
+}\r
+\r
+EFI_STATUS\r
+BdsCreateDevOrder (\r
+  IN BBS_TABLE                  *BbsTable,\r
+  IN UINT16                     BbsCount\r
+  )\r
+{\r
+  UINTN       Index;\r
+  UINTN       FDCount;\r
+  UINTN       HDCount;\r
+  UINTN       CDCount;\r
+  UINTN       NETCount;\r
+  UINTN       BEVCount;\r
+  UINTN       TotalSize;\r
+  UINTN       HeaderSize;\r
+  UINT8       *DevOrder;\r
+  UINT8       *Ptr;\r
+  EFI_STATUS  Status;\r
+\r
+  FDCount     = 0;\r
+  HDCount     = 0;\r
+  CDCount     = 0;\r
+  NETCount    = 0;\r
+  BEVCount    = 0;\r
+  TotalSize   = 0;\r
+  HeaderSize  = sizeof (BBS_TYPE) + sizeof (UINT16);\r
+  DevOrder    = NULL;\r
+  Ptr         = NULL;\r
+  Status      = EFI_SUCCESS;\r
+\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {\r
+      continue;\r
+    }\r
+\r
+    switch (BbsTable[Index].DeviceType) {\r
+    case BBS_FLOPPY:\r
+      FDCount++;\r
+      break;\r
+\r
+    case BBS_HARDDISK:\r
+      HDCount++;\r
+      break;\r
+\r
+    case BBS_CDROM:\r
+      CDCount++;\r
+      break;\r
+\r
+    case BBS_EMBED_NETWORK:\r
+      NETCount++;\r
+      break;\r
+\r
+    case BBS_BEV_DEVICE:\r
+      BEVCount++;\r
+      break;\r
+\r
+    default:\r
+      break;\r
+    }\r
+  }\r
+\r
+  TotalSize += (HeaderSize + sizeof (UINT16) * FDCount);\r
+  TotalSize += (HeaderSize + sizeof (UINT16) * HDCount);\r
+  TotalSize += (HeaderSize + sizeof (UINT16) * CDCount);\r
+  TotalSize += (HeaderSize + sizeof (UINT16) * NETCount);\r
+  TotalSize += (HeaderSize + sizeof (UINT16) * BEVCount);\r
+\r
+  DevOrder = AllocateZeroPool (TotalSize);\r
+  if (NULL == DevOrder) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Ptr                 = DevOrder;\r
+\r
+  *((BBS_TYPE *) Ptr) = BBS_FLOPPY;\r
+  Ptr += sizeof (BBS_TYPE);\r
+  *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+  if (FDCount) {\r
+    Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_FLOPPY, BbsCount, (UINT16 *) Ptr);\r
+  }\r
+\r
+  *((BBS_TYPE *) Ptr) = BBS_HARDDISK;\r
+  Ptr += sizeof (BBS_TYPE);\r
+  *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+  if (HDCount) {\r
+    Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_HARDDISK, BbsCount, (UINT16 *) Ptr);\r
+  }\r
+\r
+  *((BBS_TYPE *) Ptr) = BBS_CDROM;\r
+  Ptr += sizeof (BBS_TYPE);\r
+  *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+  if (CDCount) {\r
+    Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_CDROM, BbsCount, (UINT16 *) Ptr);\r
+  }\r
+\r
+  *((BBS_TYPE *) Ptr) = BBS_EMBED_NETWORK;\r
+  Ptr += sizeof (BBS_TYPE);\r
+  *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+  if (NETCount) {\r
+    Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_EMBED_NETWORK, BbsCount, (UINT16 *) Ptr);\r
+  }\r
+\r
+  *((BBS_TYPE *) Ptr) = BBS_BEV_DEVICE;\r
+  Ptr += sizeof (BBS_TYPE);\r
+  *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+  if (BEVCount) {\r
+    Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, (UINT16 *) Ptr);\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  VarLegacyDevOrder,\r
+                  &EfiLegacyDevOrderGuid,\r
+                  VAR_FLAG,\r
+                  TotalSize,\r
+                  DevOrder\r
+                  );\r
+  SafeFreePool (DevOrder);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsUpdateLegacyDevOrder (\r
+  VOID\r
+  )\r
+/*++\r
+Format of LegacyDevOrder variable:\r
+|-----------------------------------------------------------------------------------------------------------------\r
+| BBS_FLOPPY | Length | Index0 | Index1 | ... | BBS_HARDDISK | Length | Index0 | Index1 | ... | BBS_CDROM | Length | Index0 | ...\r
+|-----------------------------------------------------------------------------------------------------------------\r
+\r
+Length is a 16 bit integer, it indicates how many Indexes follows, including the size of itself.\r
+Index# is a 16 bit integer, the low byte of it stands for the index in BBS table\r
+           the high byte of it only have two value 0 and 0xFF, 0xFF means this device has been\r
+           disabled by user.\r
+--*/\r
+{\r
+  UINT8                     *DevOrder;\r
+  UINT8                     *NewDevOrder;\r
+  UINTN                     DevOrderSize;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  EFI_STATUS                Status;\r
+  UINT16                    HddCount;\r
+  UINT16                    BbsCount;\r
+  HDD_INFO                  *LocalHddInfo;\r
+  BBS_TABLE                 *LocalBbsTable;\r
+  UINTN                     Index;\r
+  UINTN                     Index2;\r
+  UINTN                     *Idx;\r
+  UINTN                     FDCount;\r
+  UINTN                     HDCount;\r
+  UINTN                     CDCount;\r
+  UINTN                     NETCount;\r
+  UINTN                     BEVCount;\r
+  UINTN                     TotalSize;\r
+  UINTN                     HeaderSize;\r
+  UINT8                     *Ptr;\r
+  UINT8                     *NewPtr;\r
+  UINT16                    *NewFDPtr;\r
+  UINT16                    *NewHDPtr;\r
+  UINT16                    *NewCDPtr;\r
+  UINT16                    *NewNETPtr;\r
+  UINT16                    *NewBEVPtr;\r
+  UINT16                    *NewDevPtr;\r
+  UINT16                    Length;\r
+  UINT16                    tmp;\r
+  UINTN                     FDIndex;\r
+  UINTN                     HDIndex;\r
+  UINTN                     CDIndex;\r
+  UINTN                     NETIndex;\r
+  UINTN                     BEVIndex;\r
+\r
+  LocalHddInfo  = NULL;\r
+  LocalBbsTable = NULL;\r
+  Idx           = NULL;\r
+  FDCount       = 0;\r
+  HDCount       = 0;\r
+  CDCount       = 0;\r
+  NETCount      = 0;\r
+  BEVCount      = 0;\r
+  TotalSize     = 0;\r
+  HeaderSize    = sizeof (BBS_TYPE) + sizeof (UINT16);\r
+  FDIndex       = 0;\r
+  HDIndex       = 0;\r
+  CDIndex       = 0;\r
+  NETIndex      = 0;\r
+  BEVIndex      = 0;\r
+  NewDevPtr     = NULL;\r
+\r
+  Status        = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, &LegacyBios);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  LegacyBios->GetBbsInfo (\r
+                LegacyBios,\r
+                &HddCount,\r
+                &LocalHddInfo,\r
+                &BbsCount,\r
+                &LocalBbsTable\r
+                );\r
+\r
+  DevOrder = (UINT8 *) BdsLibGetVariableAndSize (\r
+                        VarLegacyDevOrder,\r
+                        &EfiLegacyDevOrderGuid,\r
+                        &DevOrderSize\r
+                        );\r
+  if (NULL == DevOrder) {\r
+    return BdsCreateDevOrder (LocalBbsTable, BbsCount);\r
+  }\r
+  //\r
+  // First we figure out how many boot devices with same device type respectively\r
+  //\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if ((LocalBbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) ||\r
+        (LocalBbsTable[Index].BootPriority == BBS_DO_NOT_BOOT_FROM) ||\r
+        (LocalBbsTable[Index].BootPriority == BBS_LOWEST_PRIORITY)\r
+        ) {\r
+      continue;\r
+    }\r
+\r
+    switch (LocalBbsTable[Index].DeviceType) {\r
+    case BBS_FLOPPY:\r
+      FDCount++;\r
+      break;\r
+\r
+    case BBS_HARDDISK:\r
+      HDCount++;\r
+      break;\r
+\r
+    case BBS_CDROM:\r
+      CDCount++;\r
+      break;\r
+\r
+    case BBS_EMBED_NETWORK:\r
+      NETCount++;\r
+      break;\r
+\r
+    case BBS_BEV_DEVICE:\r
+      BEVCount++;\r
+      break;\r
+\r
+    default:\r
+      break;\r
+    }\r
+  }\r
+\r
+  TotalSize += (HeaderSize + FDCount * sizeof (UINT16));\r
+  TotalSize += (HeaderSize + HDCount * sizeof (UINT16));\r
+  TotalSize += (HeaderSize + CDCount * sizeof (UINT16));\r
+  TotalSize += (HeaderSize + NETCount * sizeof (UINT16));\r
+  TotalSize += (HeaderSize + BEVCount * sizeof (UINT16));\r
+\r
+  NewDevOrder = AllocateZeroPool (TotalSize);\r
+  if (NULL == NewDevOrder) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NewFDPtr  = (UINT16 *) (NewDevOrder + HeaderSize);\r
+  NewHDPtr  = (UINT16 *) ((UINT8 *) NewFDPtr + FDCount * sizeof (UINT16) + HeaderSize);\r
+  NewCDPtr  = (UINT16 *) ((UINT8 *) NewHDPtr + HDCount * sizeof (UINT16) + HeaderSize);\r
+  NewNETPtr = (UINT16 *) ((UINT8 *) NewCDPtr + CDCount * sizeof (UINT16) + HeaderSize);\r
+  NewBEVPtr = (UINT16 *) ((UINT8 *) NewNETPtr + NETCount * sizeof (UINT16) + HeaderSize);\r
+\r
+  //\r
+  // copy FD\r
+  //\r
+  Ptr                     = DevOrder;\r
+  NewPtr                  = NewDevOrder;\r
+  *((BBS_TYPE *) NewPtr)  = *((BBS_TYPE *) Ptr);\r
+  Ptr += sizeof (BBS_TYPE);\r
+  NewPtr += sizeof (BBS_TYPE);\r
+  Length                = *((UINT16 *) Ptr);\r
+  *((UINT16 *) NewPtr)  = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+\r
+  for (Index = 0; Index < Length / sizeof (UINT16) - 1; Index++) {\r
+    if (LocalBbsTable[*Ptr].BootPriority == BBS_IGNORE_ENTRY ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_LOWEST_PRIORITY ||\r
+        LocalBbsTable[*Ptr].DeviceType != BBS_FLOPPY\r
+        ) {\r
+      Ptr += sizeof (UINT16);\r
+      continue;\r
+    }\r
+\r
+    NewFDPtr[FDIndex] = *(UINT16 *) Ptr;\r
+    FDIndex++;\r
+    Ptr += sizeof (UINT16);\r
+  }\r
+  //\r
+  // copy HD\r
+  //\r
+  NewPtr                  = (UINT8 *) NewHDPtr - HeaderSize;\r
+  *((BBS_TYPE *) NewPtr)  = *((BBS_TYPE *) Ptr);\r
+  Ptr += sizeof (BBS_TYPE);\r
+  NewPtr += sizeof (BBS_TYPE);\r
+  Length                = *((UINT16 *) Ptr);\r
+  *((UINT16 *) NewPtr)  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+\r
+  for (Index = 0; Index < Length / sizeof (UINT16) - 1; Index++) {\r
+    if (LocalBbsTable[*Ptr].BootPriority == BBS_IGNORE_ENTRY ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_LOWEST_PRIORITY ||\r
+        LocalBbsTable[*Ptr].DeviceType != BBS_HARDDISK\r
+        ) {\r
+      Ptr += sizeof (UINT16);\r
+      continue;\r
+    }\r
+\r
+    NewHDPtr[HDIndex] = *(UINT16 *) Ptr;\r
+    HDIndex++;\r
+    Ptr += sizeof (UINT16);\r
+  }\r
+  //\r
+  // copy CD\r
+  //\r
+  NewPtr                  = (UINT8 *) NewCDPtr - HeaderSize;\r
+  *((BBS_TYPE *) NewPtr)  = *((BBS_TYPE *) Ptr);\r
+  Ptr += sizeof (BBS_TYPE);\r
+  NewPtr += sizeof (BBS_TYPE);\r
+  Length                = *((UINT16 *) Ptr);\r
+  *((UINT16 *) NewPtr)  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+\r
+  for (Index = 0; Index < Length / sizeof (UINT16) - 1; Index++) {\r
+    if (LocalBbsTable[*Ptr].BootPriority == BBS_IGNORE_ENTRY ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_LOWEST_PRIORITY ||\r
+        LocalBbsTable[*Ptr].DeviceType != BBS_CDROM\r
+        ) {\r
+      Ptr += sizeof (UINT16);\r
+      continue;\r
+    }\r
+\r
+    NewCDPtr[CDIndex] = *(UINT16 *) Ptr;\r
+    CDIndex++;\r
+    Ptr += sizeof (UINT16);\r
+  }\r
+  //\r
+  // copy NET\r
+  //\r
+  NewPtr                  = (UINT8 *) NewNETPtr - HeaderSize;\r
+  *((BBS_TYPE *) NewPtr)  = *((BBS_TYPE *) Ptr);\r
+  Ptr += sizeof (BBS_TYPE);\r
+  NewPtr += sizeof (BBS_TYPE);\r
+  Length                = *((UINT16 *) Ptr);\r
+  *((UINT16 *) NewPtr)  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+\r
+  for (Index = 0; Index < Length / sizeof (UINT16) - 1; Index++) {\r
+    if (LocalBbsTable[*Ptr].BootPriority == BBS_IGNORE_ENTRY ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_LOWEST_PRIORITY ||\r
+        LocalBbsTable[*Ptr].DeviceType != BBS_EMBED_NETWORK\r
+        ) {\r
+      Ptr += sizeof (UINT16);\r
+      continue;\r
+    }\r
+\r
+    NewNETPtr[NETIndex] = *(UINT16 *) Ptr;\r
+    NETIndex++;\r
+    Ptr += sizeof (UINT16);\r
+  }\r
+  //\r
+  // copy BEV\r
+  //\r
+  NewPtr                  = (UINT8 *) NewBEVPtr - HeaderSize;\r
+  *((BBS_TYPE *) NewPtr)  = *((BBS_TYPE *) Ptr);\r
+  Ptr += sizeof (BBS_TYPE);\r
+  NewPtr += sizeof (BBS_TYPE);\r
+  Length                = *((UINT16 *) Ptr);\r
+  *((UINT16 *) NewPtr)  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
+  Ptr += sizeof (UINT16);\r
+\r
+  for (Index = 0; Index < Length / sizeof (UINT16) - 1; Index++) {\r
+    if (LocalBbsTable[*Ptr].BootPriority == BBS_IGNORE_ENTRY ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_DO_NOT_BOOT_FROM ||\r
+        LocalBbsTable[*Ptr].BootPriority == BBS_LOWEST_PRIORITY ||\r
+        LocalBbsTable[*Ptr].DeviceType != BBS_BEV_DEVICE\r
+        ) {\r
+      Ptr += sizeof (UINT16);\r
+      continue;\r
+    }\r
+\r
+    NewBEVPtr[BEVIndex] = *(UINT16 *) Ptr;\r
+    BEVIndex++;\r
+    Ptr += sizeof (UINT16);\r
+  }\r
+\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if ((LocalBbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) ||\r
+        (LocalBbsTable[Index].BootPriority == BBS_DO_NOT_BOOT_FROM) ||\r
+        (LocalBbsTable[Index].BootPriority == BBS_LOWEST_PRIORITY)\r
+        ) {\r
+      continue;\r
+    }\r
+\r
+    switch (LocalBbsTable[Index].DeviceType) {\r
+    case BBS_FLOPPY:\r
+      Idx       = &FDIndex;\r
+      NewDevPtr = NewFDPtr;\r
+      break;\r
+\r
+    case BBS_HARDDISK:\r
+      Idx       = &HDIndex;\r
+      NewDevPtr = NewHDPtr;\r
+      break;\r
+\r
+    case BBS_CDROM:\r
+      Idx       = &CDIndex;\r
+      NewDevPtr = NewCDPtr;\r
+      break;\r
+\r
+    case BBS_EMBED_NETWORK:\r
+      Idx       = &NETIndex;\r
+      NewDevPtr = NewNETPtr;\r
+      break;\r
+\r
+    case BBS_BEV_DEVICE:\r
+      Idx       = &BEVIndex;\r
+      NewDevPtr = NewBEVPtr;\r
+      break;\r
+\r
+    default:\r
+      Idx = NULL;\r
+      break;\r
+    }\r
+    //\r
+    // at this point we have copied those valid indexes to new buffer\r
+    // and we should check if there is any new appeared boot device\r
+    //\r
+    if (Idx) {\r
+      for (Index2 = 0; Index2 < *Idx; Index2++) {\r
+        if ((NewDevPtr[Index2] & 0xFF) == (UINT16) Index) {\r
+          break;\r
+        }\r
+      }\r
+\r
+      if (Index2 == *Idx) {\r
+        //\r
+        // Index2 == *Idx means we didn't find Index\r
+        // so Index is a new appeared device's index in BBS table\r
+        // save it.\r
+        //\r
+        NewDevPtr[*Idx] = (UINT16) (Index & 0xFF);\r
+        (*Idx)++;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (FDCount) {\r
+    //\r
+    // Just to make sure that disabled indexes are all at the end of the array\r
+    //\r
+    for (Index = 0; Index < FDIndex - 1; Index++) {\r
+      if (0xFF00 != (NewFDPtr[Index] & 0xFF00)) {\r
+        continue;\r
+      }\r
+\r
+      for (Index2 = Index + 1; Index2 < FDIndex; Index2++) {\r
+        if (0 == (NewFDPtr[Index2] & 0xFF00)) {\r
+          tmp               = NewFDPtr[Index];\r
+          NewFDPtr[Index]   = NewFDPtr[Index2];\r
+          NewFDPtr[Index2]  = tmp;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (HDCount) {\r
+    //\r
+    // Just to make sure that disabled indexes are all at the end of the array\r
+    //\r
+    for (Index = 0; Index < HDIndex - 1; Index++) {\r
+      if (0xFF00 != (NewHDPtr[Index] & 0xFF00)) {\r
+        continue;\r
+      }\r
+\r
+      for (Index2 = Index + 1; Index2 < HDIndex; Index2++) {\r
+        if (0 == (NewHDPtr[Index2] & 0xFF00)) {\r
+          tmp               = NewHDPtr[Index];\r
+          NewHDPtr[Index]   = NewHDPtr[Index2];\r
+          NewHDPtr[Index2]  = tmp;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (CDCount) {\r
+    //\r
+    // Just to make sure that disabled indexes are all at the end of the array\r
+    //\r
+    for (Index = 0; Index < CDIndex - 1; Index++) {\r
+      if (0xFF00 != (NewCDPtr[Index] & 0xFF00)) {\r
+        continue;\r
+      }\r
+\r
+      for (Index2 = Index + 1; Index2 < CDIndex; Index2++) {\r
+        if (0 == (NewCDPtr[Index2] & 0xFF00)) {\r
+          tmp               = NewCDPtr[Index];\r
+          NewCDPtr[Index]   = NewCDPtr[Index2];\r
+          NewCDPtr[Index2]  = tmp;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (NETCount) {\r
+    //\r
+    // Just to make sure that disabled indexes are all at the end of the array\r
+    //\r
+    for (Index = 0; Index < NETIndex - 1; Index++) {\r
+      if (0xFF00 != (NewNETPtr[Index] & 0xFF00)) {\r
+        continue;\r
+      }\r
+\r
+      for (Index2 = Index + 1; Index2 < NETIndex; Index2++) {\r
+        if (0 == (NewNETPtr[Index2] & 0xFF00)) {\r
+          tmp               = NewNETPtr[Index];\r
+          NewNETPtr[Index]  = NewNETPtr[Index2];\r
+          NewNETPtr[Index2] = tmp;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (BEVCount) {\r
+    //\r
+    // Just to make sure that disabled indexes are all at the end of the array\r
+    //\r
+    for (Index = 0; Index < BEVIndex - 1; Index++) {\r
+      if (0xFF00 != (NewBEVPtr[Index] & 0xFF00)) {\r
+        continue;\r
+      }\r
+\r
+      for (Index2 = Index + 1; Index2 < BEVIndex; Index2++) {\r
+        if (0 == (NewBEVPtr[Index2] & 0xFF00)) {\r
+          tmp               = NewBEVPtr[Index];\r
+          NewBEVPtr[Index]  = NewBEVPtr[Index2];\r
+          NewBEVPtr[Index2] = tmp;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  SafeFreePool (DevOrder);\r
+\r
+  Status = gRT->SetVariable (\r
+                  VarLegacyDevOrder,\r
+                  &EfiLegacyDevOrderGuid,\r
+                  VAR_FLAG,\r
+                  TotalSize,\r
+                  NewDevOrder\r
+                  );\r
+  SafeFreePool (NewDevOrder);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsSetBootPriority4SameTypeDev (\r
+  IN UINT16                                              DeviceType,\r
+  IN OUT BBS_TABLE                                       *LocalBbsTable,\r
+  IN OUT UINT16                                          *Priority\r
+  )\r
+/*++\r
+DeviceType           - BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM and so on\r
+LocalBbsTable       - BBS table instance\r
+Priority                 - As input arg, it is the start point of boot priority, as output arg, it is the start point of boot\r
+                              priority can be used next time.\r
+--*/\r
+{\r
+  UINT8   *DevOrder;\r
+\r
+  UINT8   *OrigBuffer;\r
+  UINT16  *DevIndex;\r
+  UINTN   DevOrderSize;\r
+  UINTN   DevCount;\r
+  UINTN   Index;\r
+\r
+  DevOrder = BdsLibGetVariableAndSize (\r
+              VarLegacyDevOrder,\r
+              &EfiLegacyDevOrderGuid,\r
+              &DevOrderSize\r
+              );\r
+  if (NULL == DevOrder) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  OrigBuffer = DevOrder;\r
+  while (DevOrder < OrigBuffer + DevOrderSize) {\r
+    if (DeviceType == * (BBS_TYPE *) DevOrder) {\r
+      break;\r
+    }\r
+\r
+    DevOrder += sizeof (BBS_TYPE);\r
+    DevOrder += *(UINT16 *) DevOrder;\r
+  }\r
+\r
+  if (DevOrder >= OrigBuffer + DevOrderSize) {\r
+    SafeFreePool (OrigBuffer);\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  DevOrder += sizeof (BBS_TYPE);\r
+  DevCount  = (*((UINT16 *) DevOrder) - sizeof (UINT16)) / sizeof (UINT16);\r
+  DevIndex  = (UINT16 *) (DevOrder + sizeof (UINT16));\r
+  //\r
+  // If the high byte of the DevIndex is 0xFF, it indicates that this device has been disabled.\r
+  //\r
+  for (Index = 0; Index < DevCount; Index++) {\r
+    if ((DevIndex[Index] & 0xFF00) == 0xFF00) {\r
+      //\r
+      // LocalBbsTable[DevIndex[Index] & 0xFF].BootPriority = BBS_DISABLED_ENTRY;\r
+      //\r
+    } else {\r
+      LocalBbsTable[DevIndex[Index] & 0xFF].BootPriority = *Priority;\r
+      (*Priority)++;\r
+    }\r
+  }\r
+\r
+  SafeFreePool (OrigBuffer);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+PrintBbsTable (\r
+  IN BBS_TABLE                      *LocalBbsTable\r
+  )\r
+{\r
+  UINT16  Idx;\r
+\r
+  DEBUG ((EFI_D_ERROR, "\n"));\r
+  DEBUG ((EFI_D_ERROR, " NO  Prio bb/dd/ff cl/sc Type Stat segm:offs\n"));\r
+  DEBUG ((EFI_D_ERROR, "=============================================\n"));\r
+  for (Idx = 0; Idx < MAX_BBS_ENTRIES; Idx++) {\r
+    if ((LocalBbsTable[Idx].BootPriority == BBS_IGNORE_ENTRY) ||\r
+        (LocalBbsTable[Idx].BootPriority == BBS_DO_NOT_BOOT_FROM) ||\r
+        (LocalBbsTable[Idx].BootPriority == BBS_LOWEST_PRIORITY)\r
+        ) {\r
+      continue;\r
+    }\r
+\r
+    DEBUG (\r
+      (EFI_D_ERROR,\r
+      " %02x: %04x %02x/%02x/%02x %02x/02%x %04x %04x %04x:%04x\n",\r
+      (UINTN) Idx,\r
+      (UINTN) LocalBbsTable[Idx].BootPriority,\r
+      (UINTN) LocalBbsTable[Idx].Bus,\r
+      (UINTN) LocalBbsTable[Idx].Device,\r
+      (UINTN) LocalBbsTable[Idx].Function,\r
+      (UINTN) LocalBbsTable[Idx].Class,\r
+      (UINTN) LocalBbsTable[Idx].SubClass,\r
+      (UINTN) LocalBbsTable[Idx].DeviceType,\r
+      (UINTN) * (UINT16 *) &LocalBbsTable[Idx].StatusFlags,\r
+      (UINTN) LocalBbsTable[Idx].BootHandlerSegment,\r
+      (UINTN) LocalBbsTable[Idx].BootHandlerOffset,\r
+      (UINTN) ((LocalBbsTable[Idx].MfgStringSegment << 4) + LocalBbsTable[Idx].MfgStringOffset),\r
+      (UINTN) ((LocalBbsTable[Idx].DescStringSegment << 4) + LocalBbsTable[Idx].DescStringOffset))\r
+      );\r
+  }\r
+\r
+  DEBUG ((EFI_D_ERROR, "\n"));\r
+}\r
+\r
+EFI_STATUS\r
+BdsRefreshBbsTableForBoot (\r
+  IN BDS_COMMON_OPTION        *Entry\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  UINT16                    HddCount;\r
+  UINT16                    BbsCount;\r
+  HDD_INFO                  *LocalHddInfo;\r
+  BBS_TABLE                 *LocalBbsTable;\r
+  UINT16                    DevType;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  UINTN                     Index;\r
+  UINT16                    Priority;\r
+  UINT16                    *BootOrder;\r
+  UINTN                     BootOrderSize;\r
+  UINT8                     *BootOptionVar;\r
+  UINTN                     BootOptionSize;\r
+  UINT16                    BootOption[100];\r
+  UINT8                     *Ptr;\r
+  UINT16                    DevPathLen;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+\r
+  HddCount      = 0;\r
+  BbsCount      = 0;\r
+  LocalHddInfo  = NULL;\r
+  LocalBbsTable = NULL;\r
+  DevType       = BBS_UNKNOWN;\r
+\r
+  Status        = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, &LegacyBios);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  LegacyBios->GetBbsInfo (\r
+                LegacyBios,\r
+                &HddCount,\r
+                &LocalHddInfo,\r
+                &BbsCount,\r
+                &LocalBbsTable\r
+                );\r
+  //\r
+  // First, set all the present devices' boot priority to BBS_UNPRIORITIZED_ENTRY\r
+  // We will set them according to the settings setup by user\r
+  //\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if (!((BBS_IGNORE_ENTRY == LocalBbsTable[Index].BootPriority) ||\r
+        (BBS_DO_NOT_BOOT_FROM == LocalBbsTable[Index].BootPriority) ||\r
+         (BBS_LOWEST_PRIORITY == LocalBbsTable[Index].BootPriority))) {\r
+      LocalBbsTable[Index].BootPriority = BBS_UNPRIORITIZED_ENTRY;\r
+    }\r
+  }\r
+  //\r
+  // boot priority always starts at 0\r
+  //\r
+  Priority = 0;\r
+  if (Entry->LoadOptionsSize == sizeof (BBS_TABLE) + sizeof (UINT16)) {\r
+    //\r
+    // If Entry stands for a legacy boot option, we prioritize the devices with the same type first.\r
+    //\r
+    DevType = ((BBS_TABLE *) Entry->LoadOptions)->DeviceType;\r
+    Status = BdsSetBootPriority4SameTypeDev (\r
+              DevType,\r
+              LocalBbsTable,\r
+              &Priority\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+  //\r
+  // we have to set the boot priority for other BBS entries with different device types\r
+  //\r
+  BootOrder = (UINT16 *) BdsLibGetVariableAndSize (\r
+                          L"BootOrder",\r
+                          &gEfiGlobalVariableGuid,\r
+                          &BootOrderSize\r
+                          );\r
+  for (Index = 0; BootOrder && Index < BootOrderSize / sizeof (UINT16); Index++) {\r
+    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
+    BootOptionVar = BdsLibGetVariableAndSize (\r
+                      BootOption,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &BootOptionSize\r
+                      );\r
+    if (NULL == BootOptionVar) {\r
+      continue;\r
+    }\r
+\r
+    Ptr = BootOptionVar;\r
+\r
+    Ptr += sizeof (UINT32);\r
+    DevPathLen = *(UINT16 *) Ptr;\r
+    Ptr += sizeof (UINT16);\r
+    Ptr += StrSize ((UINT16 *) Ptr);\r
+    DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+    if (BBS_DEVICE_PATH != DevPath->Type || BBS_BBS_DP != DevPath->SubType) {\r
+      SafeFreePool (BootOptionVar);\r
+      continue;\r
+    }\r
+\r
+    Ptr += DevPathLen;\r
+    if (DevType == ((BBS_TABLE *) Ptr)->DeviceType) {\r
+      //\r
+      // We don't want to process twice for a device type\r
+      //\r
+      SafeFreePool (BootOptionVar);\r
+      continue;\r
+    }\r
+\r
+    Status = BdsSetBootPriority4SameTypeDev (\r
+              ((BBS_TABLE *) Ptr)->DeviceType,\r
+              LocalBbsTable,\r
+              &Priority\r
+              );\r
+    SafeFreePool (BootOptionVar);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (BootOrder) {\r
+    SafeFreePool (BootOrder);\r
+  }\r
+  //\r
+  // For debug\r
+  //\r
+  PrintBbsTable (LocalBbsTable);\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BBSsupport.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BBSsupport.h
new file mode 100644 (file)
index 0000000..37778f4
--- /dev/null
@@ -0,0 +1,83 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BBSsupport.h\r
+\r
+Abstract:\r
+\r
+  declares interface functions\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BDS_BBS_SUPPORT_H\r
+#define _EFI_BDS_BBS_SUPPORT_H\r
+\r
+#include "Generic/BootMaint/BootMaint.h"\r
+\r
+#ifdef EFI32\r
+#define REFRESH_LEGACY_BOOT_OPTIONS \\r
+        BdsDeleteAllInvalidLegacyBootOptions ();\\r
+        BdsAddNonExistingLegacyBootOptions (); \\r
+        BdsUpdateLegacyDevOrder ()\r
+#else\r
+#define REFRESH_LEGACY_BOOT_OPTIONS\r
+#endif\r
+\r
+VOID\r
+BdsBuildLegacyDevNameString (\r
+  IN BBS_TABLE                     *CurBBSEntry,\r
+  IN UINTN                         Index,\r
+  IN UINTN                         BufSize,\r
+  OUT CHAR16                       *BootString\r
+  );\r
+\r
+EFI_STATUS\r
+BdsDeleteAllInvalidLegacyBootOptions (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsAddNonExistingLegacyBootOptions (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Add the legacy boot options from BBS table if they do not exist.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - The boot options are added successfully or they are already in boot options.\r
+  others            - An error occurred when creating legacy boot options.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+BdsUpdateLegacyDevOrder (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsRefreshBbsTableForBoot (\r
+  IN BDS_COMMON_OPTION        *Entry\r
+  );\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Bm.vfr b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Bm.vfr
new file mode 100644 (file)
index 0000000..9b6cf5c
--- /dev/null
@@ -0,0 +1,495 @@
+// *++\r
+//\r
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//   bm.vfr \r
+// \r
+// Abstract:\r
+// \r
+//   Boot Maintenance Utility Formset\r
+// \r
+// Revision History: \r
+// \r
+// --*/\r
+\r
+#include "BdsStrDefs.h" \r
+#include "FormGuid.h"\r
+\r
+#pragma pack(1)\r
+\r
+//\r
+// This is the structure that will be used to store the \r
+// question's current value. Use it at initialize time to \r
+// set default value for each question. When using at run\r
+// time, this map is returned by the callback function,\r
+// so dynamically changing the question's value will be\r
+// possible through this mechanism\r
+//\r
+typedef struct {\r
+\r
+//\r
+// Three questions displayed at the main page\r
+// for Timeout, BootNext Variables respectively\r
+//\r
+  UINT16                    BootTimeOut;\r
+  UINT16                    BootNext;\r
+\r
+//\r
+// This is the COM1 Attributes value storage\r
+//\r
+  UINT8                     COM1BaudRate;\r
+  UINT8                     COM1DataRate;\r
+  UINT8                     COM1StopBits;\r
+  UINT8                     COM1Parity;\r
+  UINT8                     COM1TerminalType;\r
+  \r
+//\r
+// This is the COM2 Attributes value storage\r
+//\r
+  UINT8                     COM2BaudRate;\r
+  UINT8                     COM2DataRate;\r
+  UINT8                     COM2StopBits;\r
+  UINT8                     COM2Parity;\r
+  UINT8                     COM2TerminalType;\r
+\r
+// \r
+// Driver Option Add Handle page storage\r
+//\r
+  UINT16                    DriverAddHandleDesc[100];\r
+  UINT16                    DriverAddHandleOptionalData[100];\r
+  UINT8                     DriverAddActive;\r
+  UINT8                     DriverAddForceReconnect;\r
+  \r
+//\r
+// Console Input/Output/Errorout using COM port check storage\r
+//\r
+  UINT8                     ConsoleInputCOM1;\r
+  UINT8                     ConsoleInputCOM2;\r
+  UINT8                     ConsoleOutputCOM1;\r
+  UINT8                     ConsoleOutputCOM2;\r
+  UINT8                     ConsoleErrorCOM1;\r
+  UINT8                     ConsoleErrorCOM2;\r
+\r
+//\r
+// At most 100 input/output/errorout device for console storage\r
+//\r
+  UINT8                     ConsoleCheck[100];\r
+\r
+//\r
+// Boot or Driver Option Order storage\r
+//\r
+  UINT8                     OptionOrder[100];\r
+  UINT8                     DriverOptionToBeDeleted[100];\r
+\r
+//\r
+// Boot Option Delete storage\r
+// \r
+  UINT8                     BootOptionDel[100];\r
+  UINT8                     DriverOptionDel[100];\r
+  \r
+//\r
+// This is the Terminal Attributes value storage\r
+//\r
+  UINT8                     COMBaudRate;\r
+  UINT8                     COMDataRate;\r
+  UINT8                     COMStopBits;\r
+  UINT8                     COMParity;\r
+  UINT8                     COMTerminalType;\r
+  \r
+//\r
+// Legacy Device Order Selection Storage\r
+//\r
+  UINT8                     LegacyFD[100];\r
+  UINT8                     LegacyHD[100];\r
+  UINT8                     LegacyCD[100];\r
+  UINT8                     LegacyNET[100];\r
+  UINT8                     LegacyBEV[100];\r
+} BMM_FAKE_NV_DATA;\r
+#pragma pack()\r
+\r
+\r
+#define FORM_MAIN_ID                         0x0001\r
+#define FORM_BOOT_ADD_ID                     0x0002\r
+#define FORM_BOOT_DEL_ID                     0x0003\r
+#define FORM_BOOT_CHG_ID                     0x0004\r
+#define FORM_DRV_ADD_ID                      0x0005\r
+#define FORM_DRV_DEL_ID                      0x0006\r
+#define FORM_DRV_CHG_ID                      0x0007\r
+#define FORM_CON_MAIN_ID                     0x0008\r
+#define FORM_CON_IN_ID                       0x0009\r
+#define FORM_CON_OUT_ID                      0x000A\r
+#define FORM_CON_ERR_ID                      0x000B\r
+#define FORM_FILE_SEEK_ID                    0x000C\r
+#define FORM_FILE_NEW_SEEK_ID                0x000D\r
+#define FORM_DRV_ADD_FILE_ID                 0x000E\r
+#define FORM_DRV_ADD_HANDLE_ID               0x000F\r
+#define FORM_DRV_ADD_HANDLE_DESC_ID          0x0010\r
+#define FORM_BOOT_NEXT_ID                    0x0011\r
+#define FORM_TIME_OUT_ID                     0x0012\r
+#define FORM_RESET                           0x0013\r
+#define FORM_BOOT_SETUP_ID                   0x0014\r
+#define FORM_DRIVER_SETUP_ID                 0x0015\r
+#define FORM_BOOT_LEGACY_DEVICE_ID           0x0016\r
+#define FORM_CON_COM_ID                      0x0017\r
+#define FORM_CON_COM_SETUP_ID                0x0018\r
+#define FORM_SET_FD_ORDER_ID                 0x0019\r
+#define FORM_SET_HD_ORDER_ID                 0x001A\r
+#define FORM_SET_CD_ORDER_ID                 0x001B\r
+#define FORM_SET_NET_ORDER_ID                0x001C\r
+#define FORM_SET_BEV_ORDER_ID                0x001D\r
+                                                                       \r
+#define KEY_VALUE_BOOT_FROM_FILE             0x0092\r
+\r
+formset \r
+  guid = MAIN_FORMSET_GUID,\r
+  title = STRING_TOKEN(STR_FORM_MAIN_TITLE),  // uint8 opcode, uint8 length, guid Handle, uint16 Title\r
+  help = STRING_TOKEN(STR_NULL_STRING),\r
+  class = 0,      \r
+  subclass = 0,\r
+\r
+  form formid = FORM_MAIN_ID,\r
+       title = STRING_TOKEN(STR_FORM_MAIN_TITLE);\r
+\r
+    goto FORM_BOOT_SETUP_ID,\r
+         prompt = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE),\r
+         help = STRING_TOKEN(STR_FORM_BOOT_SETUP_HELP),\r
+         flags = INTERACTIVE | NV_ACCESS,\r
+         key = FORM_BOOT_SETUP_ID;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
+\r
+    goto FORM_DRIVER_SETUP_ID,\r
+         prompt = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE),\r
+         help = STRING_TOKEN(STR_FORM_DRIVER_SETUP_HELP),\r
+         flags = INTERACTIVE | NV_ACCESS,\r
+         key = FORM_DRIVER_SETUP_ID;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
+\r
+    goto FORM_CON_MAIN_ID,\r
+         prompt = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE),\r
+         help = STRING_TOKEN(STR_FORM_CON_MAIN_HELP),\r
+         flags = INTERACTIVE | NV_ACCESS,\r
+         key = FORM_CON_MAIN_ID;\r
+   \r
+    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
+\r
+    text \r
+         help   = STRING_TOKEN(STR_BOOT_FROM_FILE_HELP),  \r
+         text   = STRING_TOKEN(STR_BOOT_FROM_FILE),\r
+         text   = STRING_TOKEN(STR_NULL_STRING),\r
+         flags  = INTERACTIVE | NV_ACCESS,\r
+         key    = KEY_VALUE_BOOT_FROM_FILE;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
+\r
+//    label FORM_MAIN_ID;\r
+\r
+    goto FORM_BOOT_NEXT_ID,\r
+         prompt = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE),\r
+         help = STRING_TOKEN(STR_FORM_BOOT_NEXT_HELP),\r
+         flags = INTERACTIVE | NV_ACCESS,\r
+         key = FORM_BOOT_NEXT_ID;            \r
+\r
+    goto FORM_TIME_OUT_ID,\r
+         prompt = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE),\r
+         help = STRING_TOKEN(STR_FORM_TIME_OUT_HELP),\r
+         flags = INTERACTIVE | NV_ACCESS,\r
+         key = FORM_TIME_OUT_ID;\r
+         \r
+    subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
+\r
+    goto FORM_MAIN_ID,\r
+         prompt = STRING_TOKEN(STR_RESET),\r
+         help = STRING_TOKEN(STR_RESET),\r
+         flags = INTERACTIVE | NV_ACCESS,\r
+         key = FORM_RESET;\r
+         \r
+  endform;       \r
+\r
+  form formid = FORM_BOOT_SETUP_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_SETUP_TITLE);\r
+\r
+       goto FORM_MAIN_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+            help = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_MAIN_ID;\r
+\r
+       goto FORM_BOOT_ADD_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_BOOT_ADD_HELP),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_BOOT_ADD_ID;\r
+      \r
+       goto FORM_BOOT_DEL_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_BOOT_DEL_ID;\r
+       \r
+       goto FORM_BOOT_CHG_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_BOOT_CHG_ID;\r
+\r
+       subtitle text = STRING_TOKEN(STR_NULL_STRING);\r
+       //\r
+          // We will add "Select Legacy Boot Floppy Drive" and "Select Legacy Boot Hard Drive" \r
+          // here dynamically\r
+          //\r
+       label FORM_BOOT_LEGACY_DEVICE_ID;\r
+\r
+  endform;       \r
+\r
+  form formid = FORM_DRIVER_SETUP_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRIVER_SETUP_TITLE);\r
+\r
+       goto FORM_MAIN_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+            help = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_MAIN_ID;\r
+\r
+       goto FORM_DRV_ADD_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_DRV_ADD_HELP),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_DRV_ADD_ID;\r
+     \r
+       goto FORM_DRV_DEL_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_DRV_DEL_ID;\r
+       \r
+       goto FORM_DRV_CHG_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_NEXT_BOOT_HELP),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_DRV_CHG_ID;\r
+  endform;       \r
+\r
+  form formid = FORM_BOOT_ADD_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);\r
+\r
+       label FORM_BOOT_ADD_ID;\r
+  endform;\r
+\r
+  form formid = FORM_BOOT_DEL_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_DEL_TITLE);\r
+\r
+       label FORM_BOOT_DEL_ID;\r
+  endform;\r
+\r
+  form formid = FORM_BOOT_CHG_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);\r
+\r
+       label FORM_BOOT_CHG_ID;\r
+       \r
+       //\r
+       // This tag is added for bypassing issue of setup browser\r
+       // setup browser could not support dynamic form very well.\r
+       //\r
+       checkbox varid    = BMM_FAKE_NV_DATA.OptionOrder[0],\r
+           prompt   = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),\r
+           help     = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE),  \r
+           flags    = 1,\r
+           key      = 0,\r
+       endcheckbox;\r
+      \r
+  endform;\r
+\r
+  form formid = FORM_BOOT_NEXT_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_NEXT_TITLE);\r
+\r
+       label FORM_BOOT_NEXT_ID;\r
+  endform;\r
+  \r
+  form formid = FORM_TIME_OUT_ID,\r
+       title = STRING_TOKEN(STR_FORM_TIME_OUT_TITLE);\r
+       \r
+       label FORM_TIME_OUT_ID;\r
+  endform;\r
+  \r
+  form formid = FORM_DRV_ADD_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE);\r
+\r
+       goto FORM_MAIN_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+            help = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_MAIN_ID;\r
+              \r
+       goto FORM_DRV_ADD_FILE_ID,\r
+            prompt = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),\r
+            help = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE),\r
+            flags = INTERACTIVE | NV_ACCESS,\r
+            key = FORM_DRV_ADD_FILE_ID;\r
+\r
+  endform;\r
+\r
+  form formid = FORM_DRV_DEL_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE);\r
+\r
+       label FORM_DRV_DEL_ID;\r
+\r
+  endform;\r
+\r
+  form formid = FORM_DRV_CHG_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE);\r
+\r
+       label FORM_DRV_CHG_ID;\r
+      \r
+       //\r
+       // This tag is added for bypassing issue of setup browser\r
+       // setup browser could not support dynamic form very well.\r
+       //\r
+       checkbox varid    = BMM_FAKE_NV_DATA.OptionOrder[0],\r
+           prompt   = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE),\r
+           help     = STRING_TOKEN(STR_FORM_DRV_CHG_TITLE),  \r
+           flags    = 1,\r
+           key      = 0,\r
+       endcheckbox;\r
+       \r
+  endform;\r
+\r
+  form formid = FORM_CON_MAIN_ID,\r
+       title = STRING_TOKEN(STR_FORM_CON_MAIN_TITLE);\r
+\r
+       goto FORM_MAIN_ID,\r
+       prompt = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+       help = STRING_TOKEN(STR_FORM_GOTO_MAIN),\r
+       flags = INTERACTIVE | NV_ACCESS,\r
+       key = FORM_MAIN_ID;\r
+\r
+       goto FORM_CON_IN_ID,\r
+       prompt = STRING_TOKEN(STR_FORM_CON_IN_TITLE),\r
+       help = STRING_TOKEN(STR_FORM_CON_IN_HELP),\r
+       flags = INTERACTIVE | NV_ACCESS,\r
+       key = FORM_CON_IN_ID;\r
+\r
+       goto FORM_CON_OUT_ID,\r
+       prompt = STRING_TOKEN(STR_FORM_CON_OUT_TITLE),\r
+       help = STRING_TOKEN(STR_FORM_CON_OUT_HELP),\r
+       flags = INTERACTIVE | NV_ACCESS,\r
+       key = FORM_CON_OUT_ID;\r
+  \r
+       goto FORM_CON_ERR_ID,\r
+       prompt = STRING_TOKEN(STR_FORM_STD_ERR_TITLE),\r
+       help = STRING_TOKEN(STR_FORM_STD_ERR_HELP),\r
+       flags = INTERACTIVE | NV_ACCESS,\r
+       key = FORM_CON_ERR_ID;\r
+\r
+       goto FORM_CON_COM_ID,\r
+       prompt = STRING_TOKEN(STR_FORM_COM_TITLE),\r
+       help = STRING_TOKEN(STR_FORM_COM_HELP),\r
+       flags = INTERACTIVE | NV_ACCESS,\r
+       key = FORM_CON_COM_ID;\r
+  endform;\r
+\r
+  form formid = FORM_CON_COM_ID,\r
+       title = STRING_TOKEN(STR_FORM_COM_TITLE);\r
+\r
+       label FORM_CON_COM_ID;\r
+  endform;\r
+\r
+  form formid = FORM_CON_COM_SETUP_ID,\r
+       title = STRING_TOKEN(STR_CON_COM_SETUP);\r
+\r
+       label FORM_CON_COM_SETUP_ID;\r
+  endform;\r
+\r
+  form formid = FORM_FILE_SEEK_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);\r
+\r
+       label FORM_FILE_SEEK_ID;\r
+  endform;\r
+\r
+  form formid = FORM_FILE_NEW_SEEK_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_ADD_TITLE);\r
+\r
+       label FORM_FILE_NEW_SEEK_ID;\r
+  endform;\r
+\r
+  form formid = FORM_DRV_ADD_FILE_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_ADD_FILE_TITLE);\r
+\r
+       label FORM_DRV_ADD_FILE_ID;\r
+  endform;\r
+\r
+  form formid = FORM_DRV_ADD_HANDLE_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_ADD_HANDLE_TITLE);\r
+\r
+       label FORM_DRV_ADD_HANDLE_ID;\r
+  endform;     \r
+\r
+  form formid = FORM_DRV_ADD_HANDLE_DESC_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);\r
+\r
+       label FORM_DRV_ADD_HANDLE_DESC_ID;\r
+\r
+  endform;\r
+\r
+  form formid = FORM_CON_IN_ID,\r
+       title = STRING_TOKEN(STR_FORM_CON_IN_TITLE);\r
+\r
+       label FORM_CON_IN_ID;\r
+\r
+  endform;\r
+\r
+  form formid = FORM_CON_OUT_ID,\r
+       title = STRING_TOKEN(STR_FORM_CON_OUT_TITLE);\r
+\r
+       label FORM_CON_OUT_ID;\r
+\r
+  endform;\r
+\r
+  form formid = FORM_CON_ERR_ID,\r
+       title = STRING_TOKEN(STR_FORM_STD_ERR_TITLE);\r
+\r
+       label FORM_CON_ERR_ID;\r
+\r
+  endform;\r
+\r
+  form formid = FORM_SET_FD_ORDER_ID,\r
+       title = STRING_TOKEN(STR_FORM_SET_FD_ORDER_TITLE);\r
+\r
+       label FORM_SET_FD_ORDER_ID;\r
+  endform;\r
+  \r
+  form formid = FORM_SET_HD_ORDER_ID,\r
+       title = STRING_TOKEN(STR_FORM_SET_HD_ORDER_TITLE);\r
+\r
+       label FORM_SET_HD_ORDER_ID;\r
+  endform;\r
+\r
+  form formid = FORM_SET_CD_ORDER_ID,\r
+       title = STRING_TOKEN(STR_FORM_SET_CD_ORDER_TITLE);\r
+\r
+       label FORM_SET_CD_ORDER_ID;\r
+  endform;\r
+\r
+  form formid = FORM_SET_NET_ORDER_ID,\r
+       title = STRING_TOKEN(STR_FORM_SET_NET_ORDER_TITLE);\r
+\r
+       label FORM_SET_NET_ORDER_ID;\r
+  endform;\r
+\r
+  form formid = FORM_SET_BEV_ORDER_ID,\r
+       title = STRING_TOKEN(STR_FORM_SET_BEV_ORDER_TITLE);\r
+\r
+       label FORM_SET_BEV_ORDER_ID;\r
+  endform;\r
+\r
+endformset;\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmLib.c
new file mode 100644 (file)
index 0000000..6f46386
--- /dev/null
@@ -0,0 +1,626 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BmLib.c\r
+    \r
+AgBStract:\r
+\r
+  Boot Maintainence Helper functions\r
+\r
+--*/\r
+\r
+#include "BootMaint.h"\r
+\r
+EFI_STATUS\r
+EfiLibLocateProtocol (\r
+  IN  EFI_GUID    *ProtocolGuid,\r
+  OUT VOID        **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Find the first instance of this Protocol \r
+  in the system and return it's interface\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid    - Provides the protocol to search for\r
+  Interface       - On return, a pointer to the first interface \r
+                    that matches ProtocolGuid\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - A protocol instance matching ProtocolGuid was found\r
+\r
+  EFI_NOT_FOUND   - No protocol instances were found that match ProtocolGuid\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  ProtocolGuid,\r
+                  NULL,\r
+                  Interface\r
+                  );\r
+  return Status;\r
+}\r
+\r
+EFI_FILE_HANDLE\r
+EfiLibOpenRoot (\r
+  IN EFI_HANDLE                   DeviceHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function opens and returns a file handle to the root directory of a volume.\r
+\r
+Arguments:\r
+\r
+  DeviceHandle         - A handle for a device\r
+\r
+Returns:\r
+  \r
+  A valid file handle or NULL is returned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;\r
+  EFI_FILE_HANDLE                 File;\r
+\r
+  File = NULL;\r
+\r
+  //\r
+  // File the file system interface to the device\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  DeviceHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  (VOID *) &Volume\r
+                  );\r
+\r
+  //\r
+  // Open the root directory of the volume\r
+  //\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = Volume->OpenVolume (\r
+                      Volume,\r
+                      &File\r
+                      );\r
+  }\r
+  //\r
+  // Done\r
+  //\r
+  return EFI_ERROR (Status) ? NULL : File;\r
+}\r
+\r
+BOOLEAN\r
+EfiGrowBuffer (\r
+  IN OUT EFI_STATUS   *Status,\r
+  IN OUT VOID         **Buffer,\r
+  IN UINTN            BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Helper function called as part of the code needed\r
+    to allocate the proper sized buffer for various \r
+    EFI interfaces.\r
+\r
+Arguments:\r
+\r
+    Status      - Current status\r
+\r
+    Buffer      - Current allocated buffer, or NULL\r
+\r
+    BufferSize  - Current buffer size needed\r
+    \r
+Returns:\r
+    \r
+    TRUE - if the buffer was reallocated and the caller \r
+    should try the API again.\r
+\r
+--*/\r
+{\r
+  BOOLEAN TryAgain;\r
+\r
+  //\r
+  // If this is an initial request, buffer will be null with a new buffer size\r
+  //\r
+  if (!*Buffer && BufferSize) {\r
+    *Status = EFI_BUFFER_TOO_SMALL;\r
+  }\r
+  //\r
+  // If the status code is "buffer too small", resize the buffer\r
+  //\r
+  TryAgain = FALSE;\r
+  if (*Status == EFI_BUFFER_TOO_SMALL) {\r
+\r
+    SafeFreePool (*Buffer);\r
+\r
+    *Buffer = AllocateZeroPool (BufferSize);\r
+\r
+    if (*Buffer) {\r
+      TryAgain = TRUE;\r
+    } else {\r
+      *Status = EFI_OUT_OF_RESOURCES;\r
+    }\r
+  }\r
+  //\r
+  // If there's an error, free the buffer\r
+  //\r
+  if (!TryAgain && EFI_ERROR (*Status) && *Buffer) {\r
+    SafeFreePool (*Buffer);\r
+    *Buffer = NULL;\r
+  }\r
+\r
+  return TryAgain;\r
+}\r
+\r
+VOID *\r
+EfiLibGetVariable (\r
+  IN CHAR16               *Name,\r
+  IN EFI_GUID             *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function returns the value of the specified variable.\r
+\r
+Arguments:\r
+  Name                - A Null-terminated Unicode string that is \r
+                        the name of the vendor's variable.\r
+\r
+  VendorGuid          - A unique identifier for the vendor.\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINTN VarSize;\r
+\r
+  return BdsLibGetVariableAndSize (Name, VendorGuid, &VarSize);\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibDeleteVariable (\r
+  IN CHAR16   *VarName,\r
+  IN EFI_GUID *VarGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function deletes the variable specified by VarName and VarGuid.\r
+\r
+Arguments:\r
+  VarName              - A Null-terminated Unicode string that is \r
+                         the name of the vendor's variable.\r
+\r
+  VendorGuid           - A unique identifier for the vendor.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - The variable was found and removed\r
+\r
+  EFI_UNSUPPORTED      - The variable store was inaccessible\r
+\r
+  EFI_OUT_OF_RESOURCES - The temporary buffer was not available\r
+\r
+  EFI_NOT_FOUND        - The variable was not found\r
+\r
+--*/\r
+{\r
+  VOID        *VarBuf;\r
+  EFI_STATUS  Status;\r
+\r
+  VarBuf  = EfiLibGetVariable (VarName, VarGuid);\r
+  Status  = EFI_NOT_FOUND;\r
+\r
+  if (VarBuf) {\r
+    //\r
+    // Delete variable from Storage\r
+    //\r
+    Status = gRT->SetVariable (VarName, VarGuid, VAR_FLAG, 0, NULL);\r
+    ASSERT (!EFI_ERROR (Status));\r
+    SafeFreePool (VarBuf);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *\r
+EfiLibFileSystemVolumeLabelInfo (\r
+  IN EFI_FILE_HANDLE      FHand\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function gets the file system information from an open file descriptor, \r
+  and stores it in a buffer allocated from pool.\r
+\r
+Arguments:\r
+\r
+  Fhand         - A file handle\r
+\r
+Returns:\r
+  \r
+  A pointer to a buffer with file information or NULL is returned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *Buffer;\r
+  UINTN                             BufferSize;\r
+  //\r
+  // Initialize for GrowBuffer loop\r
+  //\r
+  Buffer      = NULL;\r
+  BufferSize  = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO + 200;\r
+\r
+  //\r
+  // Call the real function\r
+  //\r
+  while (EfiGrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {\r
+    Status = FHand->GetInfo (\r
+                      FHand,\r
+                      &gEfiFileSystemVolumeLabelInfoIdGuid,\r
+                      &BufferSize,\r
+                      Buffer\r
+                      );\r
+  }\r
+\r
+  return Buffer;\r
+}\r
+\r
+CHAR16 *\r
+EfiStrDuplicate (\r
+  IN CHAR16   *Src\r
+  )\r
+{\r
+  CHAR16  *Dest;\r
+  UINTN   Size;\r
+\r
+  Size  = StrSize (Src);\r
+  Dest  = AllocateZeroPool (Size);\r
+  ASSERT (Dest != NULL);\r
+  if (Dest) {\r
+    CopyMem (Dest, Src, Size);\r
+  }\r
+\r
+  return Dest;\r
+}\r
+\r
+EFI_FILE_INFO *\r
+EfiLibFileInfo (\r
+  IN EFI_FILE_HANDLE      FHand\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function gets the file information from an open file descriptor, and stores it \r
+  in a buffer allocated from pool.\r
+\r
+Arguments:\r
+\r
+  Fhand         - A file handle\r
+\r
+Returns:\r
+  \r
+  A pointer to a buffer with file information or NULL is returned\r
+\r
+--*/\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_FILE_INFO *Buffer;\r
+  UINTN         BufferSize;\r
+\r
+  //\r
+  // Initialize for GrowBuffer loop\r
+  //\r
+  Buffer      = NULL;\r
+  BufferSize  = SIZE_OF_EFI_FILE_INFO + 200;\r
+\r
+  //\r
+  // Call the real function\r
+  //\r
+  while (EfiGrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {\r
+    Status = FHand->GetInfo (\r
+                      FHand,\r
+                      &gEfiFileInfoGuid,\r
+                      &BufferSize,\r
+                      Buffer\r
+                      );\r
+  }\r
+\r
+  return Buffer;\r
+}\r
+\r
+UINTN\r
+EfiDevicePathInstanceCount (\r
+  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function is used to determine the number of device path instances \r
+  that exist in a device path.\r
+\r
+Arguments:\r
+  DevicePath           - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  This function counts and returns the number of device path instances \r
+  in DevicePath.\r
+\r
+--*/\r
+{\r
+  UINTN Count;\r
+  UINTN Size;\r
+\r
+  Count = 0;\r
+  while (GetNextDevicePathInstance (&DevicePath, &Size)) {\r
+    Count += 1;\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+VOID *\r
+EfiReallocatePool (\r
+  IN VOID                 *OldPool,\r
+  IN UINTN                OldSize,\r
+  IN UINTN                NewSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Adjusts the size of a previously allocated buffer.\r
+\r
+Arguments:\r
+  OldPool               - A pointer to the buffer whose size is being adjusted.\r
+  OldSize               - The size of the current buffer.\r
+  NewSize               - The size of the new buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The requested number of bytes were allocated.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.\r
+\r
+  EFI_INVALID_PARAMETER - The buffer was invalid.\r
+\r
+--*/\r
+{\r
+  VOID  *NewPool;\r
+\r
+  NewPool = NULL;\r
+  if (NewSize) {\r
+    NewPool = AllocateZeroPool (NewSize);\r
+  }\r
+\r
+  if (OldPool) {\r
+    if (NewPool) {\r
+      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
+    }\r
+\r
+    SafeFreePool (OldPool);\r
+  }\r
+\r
+  return NewPool;\r
+}\r
+\r
+EFI_STATUS\r
+EfiLibGetStringFromToken (\r
+  IN      EFI_GUID                  *ProducerGuid,\r
+  IN      STRING_REF                Token,\r
+  OUT     CHAR16                    **String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Acquire the string associated with the ProducerGuid and return it.\r
+\r
+Arguments:\r
+  \r
+  ProducerGuid - The Guid to search the HII database for\r
+  Token        - The token value of the string to extract\r
+  String       - The string that is extracted\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS           -  Buffer filled with the requested forms. BufferLength\r
+                           was updated.\r
+  EFI_BUFFER_TOO_SMALL  -  The buffer provided was not large enough to allow the form to be stored.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  UINT16            HandleBufferLength;\r
+  EFI_HII_HANDLE    *HiiHandleBuffer;\r
+  UINTN             StringBufferLength;\r
+  UINTN             NumberOfHiiHandles;\r
+  UINTN             Index;\r
+  UINT16            Length;\r
+  EFI_GUID          HiiGuid;\r
+  EFI_HII_PROTOCOL  *Hii;\r
+\r
+  HandleBufferLength  = 0x1000;\r
+  HiiHandleBuffer     = NULL;\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiHiiProtocolGuid,\r
+                  NULL,\r
+                  &Hii\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    *String = NULL;\r
+    return Status;\r
+  }\r
+  //\r
+  // Get all the Hii handles\r
+  //\r
+  HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
+  ASSERT (HiiHandleBuffer != NULL);\r
+\r
+  Status = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get the Hii Handle that matches the StructureNode->ProducerName\r
+  //\r
+  NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);\r
+  for (Index = 0; Index < NumberOfHiiHandles; Index++) {\r
+    Length = 0;\r
+    Status = ExtractDataFromHiiHandle (\r
+              HiiHandleBuffer[Index],\r
+              &Length,\r
+              NULL,\r
+              &HiiGuid\r
+              );\r
+    if (CompareGuid (ProducerGuid, &HiiGuid)) {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Find the string based on the current language\r
+  //\r
+  StringBufferLength  = 0x100;\r
+  *String             = AllocateZeroPool (0x100);\r
+  ASSERT (*String != NULL);\r
+\r
+  Status = Hii->GetString (\r
+                  Hii,\r
+                  HiiHandleBuffer[Index],\r
+                  Token,\r
+                  FALSE,\r
+                  NULL,\r
+                  &StringBufferLength,\r
+                  *String\r
+                  );\r
+\r
+  gBS->FreePool (HiiHandleBuffer);\r
+\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+TimeCompare (\r
+  IN EFI_TIME               *FirstTime,\r
+  IN EFI_TIME               *SecondTime\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Compare two EFI_TIME data.\r
+\r
+Arguments:\r
+\r
+  FirstTime         - A pointer to the first EFI_TIME data.\r
+  SecondTime        - A pointer to the second EFI_TIME data.\r
+\r
+Returns:\r
+  TRUE              The FirstTime is not later than the SecondTime.\r
+  FALSE             The FirstTime is later than the SecondTime.\r
+  \r
+--*/\r
+{\r
+  if (FirstTime->Year != SecondTime->Year) {\r
+    return (BOOLEAN) (FirstTime->Year < SecondTime->Year);\r
+  } else if (FirstTime->Month != SecondTime->Month) {\r
+    return (BOOLEAN) (FirstTime->Month < SecondTime->Month);\r
+  } else if (FirstTime->Day != SecondTime->Day) {\r
+    return (BOOLEAN) (FirstTime->Day < SecondTime->Day);\r
+  } else if (FirstTime->Hour != SecondTime->Hour) {\r
+    return (BOOLEAN) (FirstTime->Hour < SecondTime->Hour);\r
+  } else if (FirstTime->Minute != SecondTime->Minute) {\r
+    return (BOOLEAN) (FirstTime->Minute < FirstTime->Minute);\r
+  } else if (FirstTime->Second != SecondTime->Second) {\r
+    return (BOOLEAN) (FirstTime->Second < SecondTime->Second);\r
+  }\r
+\r
+  return (BOOLEAN) (FirstTime->Nanosecond <= SecondTime->Nanosecond);\r
+}\r
+\r
+UINT16 *\r
+EfiLibStrFromDatahub (\r
+  IN EFI_DEVICE_PATH_PROTOCOL                 *DevPath\r
+  )\r
+{\r
+  EFI_STATUS                                  Status;\r
+  UINT16                                      *Desc;\r
+  EFI_DATA_HUB_PROTOCOL                       *Datahub;\r
+  UINT64                                      Count;\r
+  EFI_DATA_RECORD_HEADER                      *Record;\r
+  EFI_SUBCLASS_TYPE1_HEADER                   *DataHdr;\r
+  EFI_GUID                                    MiscGuid = EFI_MISC_SUBCLASS_GUID;\r
+  EFI_MISC_ONBOARD_DEVICE_DATA                *ob;\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *Port;\r
+  EFI_TIME                                    CurTime;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDataHubProtocolGuid,\r
+                  NULL,\r
+                  &Datahub\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+\r
+  Status = gRT->GetTime (&CurTime, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+\r
+  Count = 0;\r
+  do {\r
+    Status = Datahub->GetNextRecord (Datahub, &Count, NULL, &Record);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA && CompareGuid (&Record->DataRecordGuid, &MiscGuid)) {\r
+      //\r
+      // This record is what we need\r
+      //\r
+      DataHdr = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);\r
+      if (EFI_MISC_ONBOARD_DEVICE_RECORD_NUMBER == DataHdr->RecordType) {\r
+        ob = (EFI_MISC_ONBOARD_DEVICE_DATA *) (DataHdr + 1);\r
+        if (BdsLibMatchDevicePaths ((EFI_DEVICE_PATH_PROTOCOL *) &ob->OnBoardDevicePath, DevPath)) {\r
+          EfiLibGetStringFromToken (&Record->ProducerName, ob->OnBoardDeviceDescription, &Desc);\r
+          return Desc;\r
+        }\r
+      }\r
+\r
+      if (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER == DataHdr->RecordType) {\r
+        Port = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) (DataHdr + 1);\r
+        if (BdsLibMatchDevicePaths ((EFI_DEVICE_PATH_PROTOCOL *) &Port->PortPath, DevPath)) {\r
+          EfiLibGetStringFromToken (&Record->ProducerName, Port->PortExternalConnectorDesignator, &Desc);\r
+          return Desc;\r
+        }\r
+      }\r
+    }\r
+\r
+  } while (TimeCompare (&Record->LogTime, &CurTime) && Count != 0);\r
+\r
+  return NULL;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmString.uni b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmString.uni
new file mode 100644 (file)
index 0000000..f646d8b
Binary files /dev/null and b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BmString.uni differ
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootMaint.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootMaint.c
new file mode 100644 (file)
index 0000000..7dfad51
--- /dev/null
@@ -0,0 +1,1316 @@
+/*++ \r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMaint.c\r
+    \r
+Abstract:\r
+\r
+  Boot Maintainence Main File\r
+\r
+--*/\r
+\r
+#include "Generic/Bds.h"\r
+#include "BootMaint.h"\r
+#include "BdsStrDefs.h"\r
+#include "FormGuid.h"\r
+\r
+//\r
+// Form binary for Boot Maintenance\r
+//\r
+extern UINT8    BmBin[];\r
+extern UINT8    FEBin[];\r
+extern EFI_GUID gBdsStringPackGuid;\r
+extern BOOLEAN  gConnectAllHappened;\r
+\r
+EFI_GUID        EfiLegacyDevOrderGuid = EFI_LEGACY_DEV_ORDER_VARIABLE_GUID;\r
+\r
+VOID\r
+InitAllMenu (\r
+  IN  BMM_CALLBACK_DATA    *CallbackData\r
+  );\r
+\r
+VOID\r
+FreeAllMenu (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+CreateMenuStringToken (\r
+  IN BMM_CALLBACK_DATA                *CallbackData,\r
+  IN EFI_HII_HANDLE                   HiiHandle,\r
+  IN BM_MENU_OPTION                   *MenuOption\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Create string tokens for a menu from its help strings and display strings\r
+\r
+Arguments:\r
+\r
+  HiiHandle       - Hii Handle of the package to be updated.\r
+  \r
+  MenuOption      - The Menu whose string tokens need to be created\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - string tokens created successfully\r
+  \r
+  others          - contain some errors\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINTN         Index;\r
+\r
+  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index);\r
+    CallbackData->Hii->NewString (\r
+                        CallbackData->Hii,\r
+                        NULL,\r
+                        HiiHandle,\r
+                        &NewMenuEntry->DisplayStringToken,\r
+                        NewMenuEntry->DisplayString\r
+                        );\r
+\r
+    if (NULL == NewMenuEntry->HelpString) {\r
+      NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r
+    } else {\r
+      CallbackData->Hii->NewString (\r
+                          CallbackData->Hii,\r
+                          NULL,\r
+                          HiiHandle,\r
+                          &NewMenuEntry->HelpStringToken,\r
+                          NewMenuEntry->HelpString\r
+                          );\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DriverCallback (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *Data,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Callback Function for boot maintenance utility user interface interaction.\r
+\r
+Arguments:\r
+\r
+  This            - File explorer callback protocol pointer.     \r
+  KeyValue        - Key value to identify the type of data to expect.\r
+  Data            - A pointer to the data being sent to the original exporting driver.\r
+  Packet          - A pointer to a packet of information which a driver passes back to the browser.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - Callback ended successfully.\r
+  Others          - Contain some errors.\r
+  \r
+--*/\r
+{\r
+  BMM_CALLBACK_DATA *Private;\r
+  BM_MENU_ENTRY     *NewMenuEntry;\r
+  BMM_FAKE_NV_DATA  *CurrentFakeNVMap;\r
+  EFI_STATUS        Status;\r
+  UINTN             OldValue;\r
+  UINTN             NewValue;\r
+  UINTN             Number;\r
+  UINTN             Pos;\r
+  UINTN             Bit;\r
+  UINT16            NewValuePos;\r
+  UINT16            Index2;\r
+  UINT16            Index;\r
+  UINT8             *OldLegacyDev;\r
+  UINT8             *NewLegacyDev;\r
+  UINT8             *Location;\r
+  UINT8             *DisMap;\r
+  FORM_ID           FormId;\r
+\r
+  OldValue                        = 0;\r
+  NewValue                        = 0;\r
+  Number                          = 0;\r
+  OldLegacyDev                    = NULL;\r
+  NewLegacyDev                    = NULL;\r
+  NewValuePos                     = 0;\r
+  DisMap                          = NULL;\r
+\r
+  Private                         = BMM_CALLBACK_DATA_FROM_THIS (This);\r
+  UpdateData->FormCallbackHandle  = (EFI_PHYSICAL_ADDRESS) (UINTN) Private->BmmCallbackHandle;\r
+  CurrentFakeNVMap                = (BMM_FAKE_NV_DATA *) Data->NvRamMap;\r
+  Private->BmmFakeNvData          = CurrentFakeNVMap;\r
+  Location                        = (UINT8 *) &UpdateData->Data;\r
+\r
+  UpdatePageId (Private, KeyValue);\r
+\r
+  //\r
+  // need to be subtituded.\r
+  //\r
+  // Update Select FD/HD/CD/NET/BEV Order Form\r
+  //\r
+  if (FORM_SET_FD_ORDER_ID == Private->BmmPreviousPageId ||\r
+      FORM_SET_HD_ORDER_ID == Private->BmmPreviousPageId ||\r
+      FORM_SET_CD_ORDER_ID == Private->BmmPreviousPageId ||\r
+      FORM_SET_NET_ORDER_ID == Private->BmmPreviousPageId ||\r
+      FORM_SET_BEV_ORDER_ID == Private->BmmPreviousPageId ||\r
+      ((FORM_BOOT_SETUP_ID == Private->BmmPreviousPageId) &&\r
+      (KeyValue >= LEGACY_FD_QUESTION_ID) &&\r
+       (KeyValue < (LEGACY_BEV_QUESTION_ID + 100)) )\r
+      ) {\r
+\r
+    DisMap  = Private->BmmOldFakeNVData.DisableMap;\r
+\r
+    FormId  = Private->BmmPreviousPageId;\r
+    if (FormId == FORM_BOOT_SETUP_ID) {\r
+      FormId = Private->BmmCurrentPageId;\r
+    }\r
+\r
+    switch (FormId) {\r
+    case FORM_SET_FD_ORDER_ID:\r
+      Number        = (UINT16) LegacyFDMenu.MenuNumber;\r
+      OldLegacyDev  = Private->BmmOldFakeNVData.LegacyFD;\r
+      NewLegacyDev  = CurrentFakeNVMap->LegacyFD;\r
+      break;\r
+\r
+    case FORM_SET_HD_ORDER_ID:\r
+      Number        = (UINT16) LegacyHDMenu.MenuNumber;\r
+      OldLegacyDev  = Private->BmmOldFakeNVData.LegacyHD;\r
+      NewLegacyDev  = CurrentFakeNVMap->LegacyHD;\r
+      break;\r
+\r
+    case FORM_SET_CD_ORDER_ID:\r
+      Number        = (UINT16) LegacyCDMenu.MenuNumber;\r
+      OldLegacyDev  = Private->BmmOldFakeNVData.LegacyCD;\r
+      NewLegacyDev  = CurrentFakeNVMap->LegacyCD;\r
+      break;\r
+\r
+    case FORM_SET_NET_ORDER_ID:\r
+      Number        = (UINT16) LegacyNETMenu.MenuNumber;\r
+      OldLegacyDev  = Private->BmmOldFakeNVData.LegacyNET;\r
+      NewLegacyDev  = CurrentFakeNVMap->LegacyNET;\r
+      break;\r
+\r
+    case FORM_SET_BEV_ORDER_ID:\r
+      Number        = (UINT16) LegacyBEVMenu.MenuNumber;\r
+      OldLegacyDev  = Private->BmmOldFakeNVData.LegacyBEV;\r
+      NewLegacyDev  = CurrentFakeNVMap->LegacyBEV;\r
+      break;\r
+\r
+    default:\r
+      break;\r
+    }\r
+    //\r
+    //  First, find the different position\r
+    //  if there is change, it should be only one\r
+    //\r
+    for (Index = 0; Index < Number; Index++) {\r
+      if (OldLegacyDev[Index] != NewLegacyDev[Index]) {\r
+        OldValue  = OldLegacyDev[Index];\r
+        NewValue  = NewLegacyDev[Index];\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (Index != Number) {\r
+      //\r
+      // there is change, now process\r
+      //\r
+      if (0xFF == NewValue) {\r
+        //\r
+        // This item will be disable\r
+        // Just move the items behind this forward to overlap it\r
+        //\r
+        Pos = OldValue / 8;\r
+        Bit = 7 - (OldValue % 8);\r
+        DisMap[Pos] |= (UINT8) (1 << Bit);\r
+        for (Index2 = Index; Index2 < Number - 1; Index2++) {\r
+          NewLegacyDev[Index2] = NewLegacyDev[Index2 + 1];\r
+        }\r
+\r
+        NewLegacyDev[Index2] = 0xFF;\r
+      } else {\r
+        for (Index2 = 0; Index2 < Number; Index2++) {\r
+          if (Index2 == Index) {\r
+            continue;\r
+          }\r
+\r
+          if (OldLegacyDev[Index2] == NewValue) {\r
+            //\r
+            // If NewValue is in OldLegacyDev array\r
+            // remember its old position\r
+            //\r
+            NewValuePos = Index2;\r
+            break;\r
+          }\r
+        }\r
+\r
+        if (Index2 != Number) {\r
+          //\r
+          // We will change current item to an existing item\r
+          // (It's hard to describe here, please read code, it's like a cycle-moving)\r
+          //\r
+          for (Index2 = NewValuePos; Index2 != Index;) {\r
+            if (NewValuePos < Index) {\r
+              NewLegacyDev[Index2] = OldLegacyDev[Index2 + 1];\r
+              Index2++;\r
+            } else {\r
+              NewLegacyDev[Index2] = OldLegacyDev[Index2 - 1];\r
+              Index2--;\r
+            }\r
+          }\r
+        } else {\r
+          //\r
+          // If NewValue is not in OldlegacyDev array, we are changing to a disabled item\r
+          // so we should modify DisMap to reflect the change\r
+          //\r
+          Pos = NewValue / 8;\r
+          Bit = 7 - (NewValue % 8);\r
+          DisMap[Pos] &= ~ (UINT8) (1 << Bit);\r
+          if (0xFF != OldValue) {\r
+            //\r
+            // Because NewValue is a item that was disabled before\r
+            // so after changing the OldValue should be disabled\r
+            // actually we are doing a swap of enable-disable states of two items\r
+            //\r
+            Pos = OldValue / 8;\r
+            Bit = 7 - (OldValue % 8);\r
+            DisMap[Pos] |= (UINT8) (1 << Bit);\r
+          }\r
+        }\r
+      }\r
+      //\r
+      // To prevent DISABLE appears in the middle of the list\r
+      // we should perform a re-ordering\r
+      //\r
+      Index = 0;\r
+      while (Index < Number) {\r
+        if (0xFF != NewLegacyDev[Index]) {\r
+          Index++;\r
+          continue;\r
+        }\r
+\r
+        Index2 = Index;\r
+        Index2++;\r
+        while (Index2 < Number) {\r
+          if (0xFF != NewLegacyDev[Index2]) {\r
+            break;\r
+          }\r
+\r
+          Index2++;\r
+        }\r
+\r
+        if (Index2 < Number) {\r
+          NewLegacyDev[Index]   = NewLegacyDev[Index2];\r
+          NewLegacyDev[Index2]  = 0xFF;\r
+        }\r
+\r
+        Index++;\r
+      }\r
+\r
+      CopyMem (\r
+        OldLegacyDev,\r
+        NewLegacyDev,\r
+        Number\r
+        );\r
+    }\r
+  }\r
+\r
+  if (KeyValue < FILE_OPTION_OFFSET) {\r
+    if (KeyValue < NORMAL_GOTO_OFFSET) {\r
+      switch (KeyValue) {\r
+      case KEY_VALUE_BOOT_FROM_FILE:\r
+        Private->FeCurrentState = BOOT_FROM_FILE_STATE;\r
+\r
+        //\r
+        // Exit Bmm main formset to send File Explorer formset.\r
+        //\r
+        CreateCallbackPacket (Packet, EXIT_REQUIRED);\r
+\r
+        break;\r
+\r
+      case FORM_BOOT_ADD_ID:\r
+        Private->FeCurrentState = ADD_BOOT_OPTION_STATE;\r
+\r
+        //\r
+        // Exit Bmm main formset to send File Explorer formset.\r
+        //\r
+        CreateCallbackPacket (Packet, EXIT_REQUIRED);\r
+        break;\r
+\r
+      case FORM_DRV_ADD_FILE_ID:\r
+        Private->FeCurrentState = ADD_DRIVER_OPTION_STATE;\r
+\r
+        //\r
+        // Exit Bmm main formset to send File Explorer formset.\r
+        //\r
+        CreateCallbackPacket (Packet, EXIT_REQUIRED);\r
+\r
+        break;\r
+\r
+      case FORM_DRV_ADD_HANDLE_ID:\r
+        CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);\r
+        UpdateDrvAddHandlePage (Private);\r
+        break;\r
+\r
+      case FORM_BOOT_DEL_ID:\r
+        CleanUpPage (FORM_BOOT_DEL_ID, Private);\r
+        UpdateBootDelPage (Private);\r
+        break;\r
+\r
+      case FORM_BOOT_CHG_ID:\r
+      case FORM_DRV_CHG_ID:\r
+        UpdatePageBody (KeyValue, Private);\r
+        break;\r
+\r
+      case FORM_DRV_DEL_ID:\r
+        CleanUpPage (FORM_DRV_DEL_ID, Private);\r
+        UpdateDrvDelPage (Private);\r
+        break;\r
+\r
+      case FORM_BOOT_NEXT_ID:\r
+        CleanUpPage (FORM_BOOT_NEXT_ID, Private);\r
+        UpdateBootNextPage (Private);\r
+        break;\r
+\r
+      case FORM_TIME_OUT_ID:\r
+        CleanUpPage (FORM_TIME_OUT_ID, Private);\r
+        UpdateTimeOutPage (Private);\r
+        break;\r
+\r
+      case FORM_RESET:\r
+        gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+        return EFI_UNSUPPORTED;\r
+\r
+      case FORM_CON_IN_ID:\r
+      case FORM_CON_OUT_ID:\r
+      case FORM_CON_ERR_ID:\r
+        UpdatePageBody (KeyValue, Private);\r
+        break;\r
+\r
+      case FORM_CON_COM_ID:\r
+        CleanUpPage (FORM_CON_COM_ID, Private);\r
+        UpdateConCOMPage (Private);\r
+        break;\r
+\r
+      case FORM_SET_FD_ORDER_ID:\r
+      case FORM_SET_HD_ORDER_ID:\r
+      case FORM_SET_CD_ORDER_ID:\r
+      case FORM_SET_NET_ORDER_ID:\r
+      case FORM_SET_BEV_ORDER_ID:\r
+        CleanUpPage (KeyValue, Private);\r
+        UpdateSetLegacyDeviceOrderPage (KeyValue, Private);\r
+        break;\r
+\r
+      case KEY_VALUE_SAVE_AND_EXIT:\r
+      case KEY_VALUE_NO_SAVE_AND_EXIT:\r
+\r
+        if (KeyValue == KEY_VALUE_SAVE_AND_EXIT) {\r
+          Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId);\r
+          if (EFI_ERROR (Status)) {\r
+            return Status;\r
+          }\r
+        } else if (KeyValue == KEY_VALUE_NO_SAVE_AND_EXIT) {\r
+          DiscardChangeHandler (Private, CurrentFakeNVMap);\r
+        }\r
+        //\r
+        // Tell browser not to ask for confirmation of changes,\r
+        // since we have already applied or discarded.\r
+        //\r
+        CreateCallbackPacket (Packet, NV_NOT_CHANGED);\r
+        break;\r
+\r
+      default:\r
+        break;\r
+      }\r
+    } else if ((KeyValue >= TERMINAL_OPTION_OFFSET) && (KeyValue < CONSOLE_OPTION_OFFSET)) {\r
+      Index2                    = (UINT16) (KeyValue - TERMINAL_OPTION_OFFSET);\r
+      Private->CurrentTerminal  = Index2;\r
+\r
+      CleanUpPage (FORM_CON_COM_SETUP_ID, Private);\r
+      UpdateTerminalPage (Private);\r
+\r
+    } else if (KeyValue >= HANDLE_OPTION_OFFSET) {\r
+      Index2                  = (UINT16) (KeyValue - HANDLE_OPTION_OFFSET);\r
+\r
+      NewMenuEntry            = BOpt_GetMenuEntry (&DriverMenu, Index2);\r
+      Private->HandleContext  = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+      CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private);\r
+\r
+      Private->MenuEntry                  = NewMenuEntry;\r
+      Private->LoadContext->FilePathList  = Private->HandleContext->DevicePath;\r
+\r
+      UpdateDriverAddHandleDescPage (Private);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ApplyChangeHandler (\r
+  IN  BMM_CALLBACK_DATA               *Private,\r
+  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap,\r
+  IN  FORM_ID                         FormId\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function handling request to apply changes for BMM pages.\r
+\r
+Arguments:\r
+\r
+  Private          - Pointer to callback data buffer.\r
+  CurrentFakeNVMap - Pointer to buffer holding data of various values used by BMM\r
+  FormId           - ID of the form which has sent the request to apply change.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS      - Change successfully applied.\r
+  Other            - Error occurs while trying to apply changes.\r
+\r
+--*/\r
+{\r
+  BM_CONSOLE_CONTEXT  *NewConsoleContext;\r
+  BM_TERMINAL_CONTEXT *NewTerminalContext;\r
+  BM_LOAD_CONTEXT     *NewLoadContext;\r
+  BM_MENU_ENTRY       *NewMenuEntry;\r
+  EFI_STATUS          Status;\r
+  UINT16              Index;\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
+  switch (FormId) {\r
+  case FORM_SET_FD_ORDER_ID:\r
+  case FORM_SET_HD_ORDER_ID:\r
+  case FORM_SET_CD_ORDER_ID:\r
+  case FORM_SET_NET_ORDER_ID:\r
+  case FORM_SET_BEV_ORDER_ID:\r
+    Var_UpdateBBSOption (Private);\r
+    break;\r
+\r
+  case FORM_BOOT_DEL_ID:\r
+    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+      NewMenuEntry            = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
+      NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewLoadContext->Deleted = CurrentFakeNVMap->BootOptionDel[Index];\r
+    }\r
+\r
+    Var_DelBootOption ();\r
+    break;\r
+\r
+  case FORM_DRV_DEL_ID:\r
+    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
+      NewMenuEntry            = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
+      NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewLoadContext->Deleted = CurrentFakeNVMap->DriverOptionDel[Index];\r
+    }\r
+\r
+    Var_DelDriverOption ();\r
+    break;\r
+\r
+  case FORM_BOOT_CHG_ID:\r
+    Status = Var_UpdateBootOrder (Private);\r
+    break;\r
+\r
+  case FORM_DRV_CHG_ID:\r
+    Status = Var_UpdateDriverOrder (Private);\r
+    break;\r
+\r
+  case FORM_TIME_OUT_ID:\r
+    Status = gRT->SetVariable (\r
+                    L"Timeout",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    sizeof (UINT16),\r
+                    &(CurrentFakeNVMap->BootTimeOut)\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
+\r
+    Private->BmmOldFakeNVData.BootTimeOut = CurrentFakeNVMap->BootTimeOut;\r
+    break;\r
+\r
+  case FORM_BOOT_NEXT_ID:\r
+    Status = Var_UpdateBootNext (Private);\r
+    break;\r
+\r
+  case FORM_CON_COM_ID:\r
+    NewMenuEntry                      = BOpt_GetMenuEntry (&TerminalMenu, Private->CurrentTerminal);\r
+\r
+    NewTerminalContext                = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+    NewTerminalContext->BaudRateIndex = CurrentFakeNVMap->COMBaudRate;\r
+    NewTerminalContext->BaudRate      = BaudRateList[CurrentFakeNVMap->COMBaudRate].Value;\r
+    NewTerminalContext->DataBitsIndex = CurrentFakeNVMap->COMDataRate;\r
+    NewTerminalContext->DataBits      = (UINT8) DataBitsList[CurrentFakeNVMap->COMDataRate].Value;\r
+    NewTerminalContext->StopBitsIndex = CurrentFakeNVMap->COMStopBits;\r
+    NewTerminalContext->StopBits      = (UINT8) StopBitsList[CurrentFakeNVMap->COMStopBits].Value;\r
+    NewTerminalContext->ParityIndex   = CurrentFakeNVMap->COMParity;\r
+    NewTerminalContext->Parity        = (UINT8) ParityList[CurrentFakeNVMap->COMParity].Value;\r
+    NewTerminalContext->TerminalType  = CurrentFakeNVMap->COMTerminalType;\r
+\r
+    ChangeTerminalDevicePath (\r
+      NewTerminalContext->DevicePath,\r
+      FALSE\r
+      );\r
+\r
+    Var_UpdateConsoleInpOption ();\r
+    Var_UpdateConsoleOutOption ();\r
+    Var_UpdateErrorOutOption ();\r
+    break;\r
+\r
+  case FORM_CON_IN_ID:\r
+    for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {\r
+      NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);\r
+      NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r
+    }\r
+\r
+    for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+      NewMenuEntry                = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
+      NewTerminalContext          = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber];\r
+    }\r
+\r
+    Var_UpdateConsoleInpOption ();\r
+    break;\r
+\r
+  case FORM_CON_OUT_ID:\r
+    for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {\r
+      NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);\r
+      NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r
+    }\r
+\r
+    for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+      NewMenuEntry                  = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
+      NewTerminalContext            = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewTerminalContext->IsConOut  = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber];\r
+    }\r
+\r
+    Var_UpdateConsoleOutOption ();\r
+    break;\r
+\r
+  case FORM_CON_ERR_ID:\r
+    for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {\r
+      NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);\r
+      NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r
+    }\r
+\r
+    for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+      NewMenuEntry                  = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
+      NewTerminalContext            = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewTerminalContext->IsStdErr  = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber];\r
+    }\r
+\r
+    Var_UpdateErrorOutOption ();\r
+    break;\r
+\r
+  case FORM_DRV_ADD_HANDLE_DESC_ID:\r
+    Status = Var_UpdateDriverOption (\r
+               Private,\r
+               Private->BmmHiiHandle,\r
+               CurrentFakeNVMap->DriverAddHandleDesc,\r
+               CurrentFakeNVMap->DriverAddHandleOptionalData,\r
+               CurrentFakeNVMap->DriverAddForceReconnect\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
+\r
+    BOpt_GetDriverOptions (Private);\r
+    CreateMenuStringToken (Private, Private->BmmHiiHandle, &DriverOptionMenu);\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+Error:\r
+  return Status;\r
+}\r
+\r
+VOID\r
+DiscardChangeHandler (\r
+  IN  BMM_CALLBACK_DATA               *Private,\r
+  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap\r
+  )\r
+{\r
+  UINT16  Index;\r
+\r
+  switch (Private->BmmPreviousPageId) {\r
+  case FORM_BOOT_CHG_ID:\r
+  case FORM_DRV_CHG_ID:\r
+    CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, 100);\r
+    break;\r
+\r
+  case FORM_BOOT_DEL_ID:\r
+    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+      CurrentFakeNVMap->BootOptionDel[Index] = 0x00;\r
+    }\r
+    break;\r
+\r
+  case FORM_DRV_DEL_ID:\r
+    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
+      CurrentFakeNVMap->DriverOptionDel[Index] = 0x00;\r
+    }\r
+    break;\r
+\r
+  case FORM_BOOT_NEXT_ID:\r
+    CurrentFakeNVMap->BootNext = Private->BmmOldFakeNVData.BootNext;\r
+    break;\r
+\r
+  case FORM_TIME_OUT_ID:\r
+    CurrentFakeNVMap->BootTimeOut = Private->BmmOldFakeNVData.BootTimeOut;\r
+    break;\r
+\r
+  case FORM_DRV_ADD_HANDLE_DESC_ID:\r
+  case FORM_DRV_ADD_FILE_ID:\r
+  case FORM_DRV_ADD_HANDLE_ID:\r
+    CurrentFakeNVMap->DriverAddHandleDesc[0]          = 0x0000;\r
+    CurrentFakeNVMap->DriverAddHandleOptionalData[0]  = 0x0000;\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+NvWrite (\r
+  IN     EFI_FORM_CALLBACK_PROTOCOL              *This,\r
+  IN     CHAR16                                  *VariableName,\r
+  IN     EFI_GUID                                *VendorGuid,\r
+  OUT    UINT32                                  Attributes OPTIONAL,\r
+  IN OUT UINTN                                   DataSize,\r
+  OUT    VOID                                    *Buffer,\r
+  OUT    BOOLEAN                                 *ResetRequired\r
+  )\r
+{\r
+  //\r
+  // Do nothing here. Just to catch the F10, we use "Apply Changes" tag to save.\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+InitializeBM (\r
+  VOID\r
+  )\r
+/*++\r
+Routine Description:\r
+\r
+  Initialize the Boot Maintenance Utitliy\r
+\r
+Arguments:\r
+\r
+  ImageHandle     - caller provided handle\r
+  \r
+  SystemTable     - caller provided system tables\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - utility ended successfully\r
+  \r
+  others          - contain some errors\r
+  \r
+--*/\r
+{\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  EFI_HII_PACKAGES          *PackageList;\r
+  BMM_CALLBACK_DATA         *BmmCallbackInfo;\r
+  EFI_HII_PROTOCOL          *Hii;\r
+  EFI_HII_HANDLE            HiiHandle;\r
+  EFI_STATUS                Status;\r
+  EFI_HANDLE                Handle;\r
+  UINT8                     *Ptr;\r
+  UINT8                     *Location;\r
+\r
+  Status      = EFI_SUCCESS;\r
+  UpdateData  = NULL;\r
+  //\r
+  // Initialize EfiUtilityLib and EfiDriverLib\r
+  // Since many functions in UtilityLib must be used and\r
+  // SetupBrowser use DriverLib\r
+  //\r
+  //\r
+  // There should be only one EFI_HII_PROTOCOL Image\r
+  //\r
+  Status = EfiLibLocateProtocol (&gEfiHiiProtocolGuid, &Hii);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Create CallbackData structures for Driver Callback\r
+  //\r
+  BmmCallbackInfo = AllocateZeroPool (sizeof (BMM_CALLBACK_DATA));\r
+  if (!BmmCallbackInfo) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Create LoadOption in BmmCallbackInfo for Driver Callback\r
+  //\r
+  Ptr = AllocateZeroPool (sizeof (BM_LOAD_CONTEXT) + sizeof (BM_FILE_CONTEXT) + sizeof (BM_HANDLE_CONTEXT) + sizeof (BM_MENU_ENTRY));\r
+  if (!Ptr) {\r
+    SafeFreePool (BmmCallbackInfo);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Initialize Bmm callback data.\r
+  //\r
+  BmmCallbackInfo->LoadContext = (BM_LOAD_CONTEXT *) Ptr;\r
+  Ptr += sizeof (BM_LOAD_CONTEXT);\r
+\r
+  BmmCallbackInfo->FileContext = (BM_FILE_CONTEXT *) Ptr;\r
+  Ptr += sizeof (BM_FILE_CONTEXT);\r
+\r
+  BmmCallbackInfo->HandleContext = (BM_HANDLE_CONTEXT *) Ptr;\r
+  Ptr += sizeof (BM_HANDLE_CONTEXT);\r
+\r
+  BmmCallbackInfo->MenuEntry      = (BM_MENU_ENTRY *) Ptr;\r
+\r
+  BmmCallbackInfo->BmmFakeNvData  = &BmmCallbackInfo->BmmOldFakeNVData;\r
+\r
+  ZeroMem (BmmCallbackInfo->BmmFakeNvData, sizeof (BMM_FAKE_NV_DATA));\r
+\r
+  BmmCallbackInfo->Signature                  = BMM_CALLBACK_DATA_SIGNATURE;\r
+  BmmCallbackInfo->Hii                        = Hii;\r
+  BmmCallbackInfo->BmmDriverCallback.NvRead   = NULL;\r
+  BmmCallbackInfo->BmmDriverCallback.NvWrite  = NvWrite;\r
+  BmmCallbackInfo->BmmDriverCallback.Callback = DriverCallback;\r
+  BmmCallbackInfo->BmmPreviousPageId          = FORM_MAIN_ID;\r
+  BmmCallbackInfo->BmmCurrentPageId           = FORM_MAIN_ID;\r
+  BmmCallbackInfo->FeDriverCallback.NvRead    = NULL;\r
+  BmmCallbackInfo->FeDriverCallback.NvWrite   = NvWrite;\r
+  BmmCallbackInfo->FeDriverCallback.Callback  = FileExplorerCallback;\r
+  BmmCallbackInfo->FeCurrentState             = INACTIVE_STATE;\r
+  BmmCallbackInfo->FeDisplayContext           = UNKNOWN_CONTEXT;\r
+\r
+  //\r
+  // Install bmm callback protocol interface\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  &gEfiFormCallbackProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &BmmCallbackInfo->BmmDriverCallback\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  BmmCallbackInfo->BmmCallbackHandle = Handle;\r
+\r
+  //\r
+  // Install file explorer callback protocol interface\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  &gEfiFormCallbackProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &BmmCallbackInfo->FeDriverCallback\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  BmmCallbackInfo->FeCallbackHandle = Handle;\r
+\r
+  //\r
+  // Post our VFR to the HII database.\r
+  //\r
+  PackageList = PreparePackages (1, &gBdsStringPackGuid, BmBin);\r
+  Status      = Hii->NewPack (Hii, PackageList, &HiiHandle);\r
+  gBS->FreePool (PackageList);\r
+\r
+  BmmCallbackInfo->BmmHiiHandle = HiiHandle;\r
+\r
+  PackageList                   = PreparePackages (1, &gBdsStringPackGuid, FEBin);\r
+  Status                        = Hii->NewPack (Hii, PackageList, &HiiHandle);\r
+  gBS->FreePool (PackageList);\r
+\r
+  BmmCallbackInfo->FeHiiHandle = HiiHandle;\r
+\r
+  //\r
+  // Allocate space for creation of Buffer\r
+  //\r
+  UpdateData = AllocateZeroPool (UPDATE_DATA_SIZE);\r
+  if (!UpdateData) {\r
+    SafeFreePool (BmmCallbackInfo->LoadContext);\r
+    SafeFreePool (BmmCallbackInfo);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Initialize UpdateData structure\r
+  //\r
+  RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) BmmCallbackInfo->BmmCallbackHandle, FALSE, 0, 0);\r
+\r
+  Location = (UINT8 *) &UpdateData->Data;\r
+\r
+  InitializeStringDepository ();\r
+\r
+  InitAllMenu (BmmCallbackInfo);\r
+\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleInpMenu);\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleOutMenu);\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleErrMenu);\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &BootOptionMenu);\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverOptionMenu);\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &TerminalMenu);\r
+  CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverMenu);\r
+\r
+  UpdateBootDelPage (BmmCallbackInfo);\r
+  UpdateDrvDelPage (BmmCallbackInfo);\r
+\r
+  if (TerminalMenu.MenuNumber > 0) {\r
+    BmmCallbackInfo->CurrentTerminal = 0;\r
+    UpdateTerminalPage (BmmCallbackInfo);\r
+  }\r
+\r
+  Location  = (UINT8 *) &UpdateData->Data;\r
+  Status    = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, &LegacyBios);\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // If LegacyBios Protocol is installed, add 3 tags about legacy boot option\r
+    // in BootOption form: legacy FD/HD/CD/NET/BEV\r
+    //\r
+    UpdateData->DataCount = 5;\r
+    CreateGotoOpCode (\r
+      FORM_SET_FD_ORDER_ID,\r
+      STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE),\r
+      STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      FORM_SET_FD_ORDER_ID,\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+    CreateGotoOpCode (\r
+      FORM_SET_HD_ORDER_ID,\r
+      STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE),\r
+      STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      FORM_SET_HD_ORDER_ID,\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+    CreateGotoOpCode (\r
+      FORM_SET_CD_ORDER_ID,\r
+      STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE),\r
+      STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      FORM_SET_CD_ORDER_ID,\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+    CreateGotoOpCode (\r
+      FORM_SET_NET_ORDER_ID,\r
+      STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE),\r
+      STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      FORM_SET_NET_ORDER_ID,\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+    CreateGotoOpCode (\r
+      FORM_SET_BEV_ORDER_ID,\r
+      STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE),\r
+      STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      FORM_SET_BEV_ORDER_ID,\r
+      Location\r
+      );\r
+\r
+    Hii->UpdateForm (\r
+          Hii,\r
+          BmmCallbackInfo->BmmHiiHandle,\r
+          (EFI_FORM_LABEL) FORM_BOOT_LEGACY_DEVICE_ID,\r
+          TRUE,\r
+          UpdateData\r
+          );\r
+  }\r
+  //\r
+  // Dispatch BMM main formset and File Explorer formset.\r
+  //\r
+  FormSetDispatcher (BmmCallbackInfo);\r
+\r
+  Hii->ResetStrings (Hii, HiiHandle);\r
+\r
+  CleanUpStringDepository ();\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  FreeAllMenu ();\r
+\r
+  SafeFreePool (BmmCallbackInfo->LoadContext);\r
+  BmmCallbackInfo->LoadContext = NULL;\r
+  SafeFreePool (BmmCallbackInfo);\r
+  BmmCallbackInfo = NULL;\r
+  SafeFreePool (UpdateData);\r
+  UpdateData = NULL;\r
+\r
+  return Status;\r
+}\r
+\r
+VOID\r
+InitAllMenu (\r
+  IN  BMM_CALLBACK_DATA    *CallbackData\r
+  )\r
+{\r
+  InitializeListHead (&BootOptionMenu.Head);\r
+  InitializeListHead (&DriverOptionMenu.Head);\r
+  BOpt_GetBootOptions (CallbackData);\r
+  BOpt_GetDriverOptions (CallbackData);\r
+  BOpt_GetLegacyOptions ();\r
+  InitializeListHead (&FsOptionMenu.Head);\r
+  BOpt_FindDrivers ();\r
+  InitializeListHead (&DirectoryMenu.Head);\r
+  InitializeListHead (&ConsoleInpMenu.Head);\r
+  InitializeListHead (&ConsoleOutMenu.Head);\r
+  InitializeListHead (&ConsoleErrMenu.Head);\r
+  InitializeListHead (&TerminalMenu.Head);\r
+  LocateSerialIo ();\r
+  GetAllConsoles ();\r
+}\r
+\r
+VOID\r
+FreeAllMenu (\r
+  VOID\r
+  )\r
+{\r
+  BOpt_FreeMenu (&DirectoryMenu);\r
+  BOpt_FreeMenu (&FsOptionMenu);\r
+  BOpt_FreeMenu (&BootOptionMenu);\r
+  BOpt_FreeMenu (&DriverOptionMenu);\r
+  BOpt_FreeMenu (&DriverMenu);\r
+  BOpt_FreeLegacyOptions ();\r
+  FreeAllConsoles ();\r
+}\r
+\r
+VOID\r
+InitializeStringDepository (\r
+  VOID\r
+  )\r
+/*++\r
+Routine Description:\r
+  Intialize all the string depositories.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.  \r
+--*/\r
+{\r
+  STRING_DEPOSITORY *StringDepository;\r
+  StringDepository              = AllocateZeroPool (sizeof (STRING_DEPOSITORY) * STRING_DEPOSITORY_NUMBER);\r
+  FileOptionStrDepository       = StringDepository++;\r
+  ConsoleOptionStrDepository    = StringDepository++;\r
+  BootOptionStrDepository       = StringDepository++;\r
+  BootOptionHelpStrDepository   = StringDepository++;\r
+  DriverOptionStrDepository     = StringDepository++;\r
+  DriverOptionHelpStrDepository = StringDepository++;\r
+  TerminalStrDepository         = StringDepository;\r
+}\r
+\r
+STRING_REF\r
+GetStringTokenFromDepository (\r
+  IN   BMM_CALLBACK_DATA     *CallbackData,\r
+  IN   STRING_DEPOSITORY     *StringDepository\r
+  )\r
+/*++\r
+Routine Description:\r
+  Fetch a usable string node from the string depository and return the string token.\r
+\r
+Arguments:\r
+  StringDepository       - Pointer of the string depository.\r
+\r
+Returns:\r
+  STRING_REF             - String token.\r
+--*/\r
+{\r
+  STRING_LIST_NODE  *CurrentListNode;\r
+  STRING_LIST_NODE  *NextListNode;\r
+\r
+  CurrentListNode = StringDepository->CurrentNode;\r
+\r
+  if ((NULL != CurrentListNode) && (NULL != CurrentListNode->Next)) {\r
+    //\r
+    // Fetch one reclaimed node from the list.\r
+    //\r
+    NextListNode = StringDepository->CurrentNode->Next;\r
+  } else {\r
+    //\r
+    // If there is no usable node in the list, update the list.\r
+    //\r
+    NextListNode = AllocateZeroPool (sizeof (STRING_LIST_NODE));\r
+\r
+    CallbackData->Hii->NewString (\r
+                        CallbackData->Hii,\r
+                        NULL,\r
+                        CallbackData->BmmHiiHandle,\r
+                        &(NextListNode->StringToken),\r
+                        L" "\r
+                        );\r
+\r
+    ASSERT (NextListNode->StringToken != 0);\r
+\r
+    StringDepository->TotalNodeNumber++;\r
+\r
+    if (NULL == CurrentListNode) {\r
+      StringDepository->ListHead = NextListNode;\r
+    } else {\r
+      CurrentListNode->Next = NextListNode;\r
+    }\r
+  }\r
+\r
+  StringDepository->CurrentNode = NextListNode;\r
+\r
+  return StringDepository->CurrentNode->StringToken;\r
+}\r
+\r
+VOID\r
+ReclaimStringDepository (\r
+  VOID\r
+  )\r
+/*++\r
+Routine Description:\r
+  Reclaim string depositories by moving the current node pointer to list head..\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+--*/\r
+{\r
+  UINTN             DepositoryIndex;\r
+  STRING_DEPOSITORY *StringDepository;\r
+\r
+  StringDepository = FileOptionStrDepository;\r
+  for (DepositoryIndex = 0; DepositoryIndex < STRING_DEPOSITORY_NUMBER; DepositoryIndex++) {\r
+    StringDepository->CurrentNode = StringDepository->ListHead;\r
+    StringDepository++;\r
+  }\r
+}\r
+\r
+VOID\r
+CleanUpStringDepository (\r
+  VOID\r
+  )\r
+/*++\r
+Routine Description:\r
+  Release resource for all the string depositories.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  None.\r
+--*/\r
+{\r
+  UINTN             NodeIndex;\r
+  UINTN             DepositoryIndex;\r
+  STRING_LIST_NODE  *CurrentListNode;\r
+  STRING_LIST_NODE  *NextListNode;\r
+  STRING_DEPOSITORY *StringDepository;\r
+\r
+  //\r
+  // Release string list nodes.\r
+  //\r
+  StringDepository = FileOptionStrDepository;\r
+  for (DepositoryIndex = 0; DepositoryIndex < STRING_DEPOSITORY_NUMBER; DepositoryIndex++) {\r
+    CurrentListNode = StringDepository->ListHead;\r
+    for (NodeIndex = 0; NodeIndex < StringDepository->TotalNodeNumber; NodeIndex++) {\r
+      NextListNode = CurrentListNode->Next;\r
+      SafeFreePool (CurrentListNode);\r
+      CurrentListNode = NextListNode;\r
+    }\r
+\r
+    StringDepository++;\r
+  }\r
+  //\r
+  // Release string depository.\r
+  //\r
+  SafeFreePool (FileOptionStrDepository);\r
+}\r
+\r
+EFI_STATUS\r
+BdsStartBootMaint (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Start boot maintenance manager\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  LIST_ENTRY  BdsBootOptionList;\r
+\r
+  InitializeListHead (&BdsBootOptionList);\r
+\r
+  //\r
+  // Connect all prior to entering the platform setup menu.\r
+  //\r
+  if (!gConnectAllHappened) {\r
+    BdsLibConnectAllDriversToAllControllers ();\r
+    gConnectAllHappened = TRUE;\r
+  }\r
+  //\r
+  // Have chance to enumerate boot device\r
+  //\r
+  BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r
+\r
+  //\r
+  // Init the BMM\r
+  //\r
+  Status = InitializeBM ();\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+FormSetDispatcher (\r
+  IN  BMM_CALLBACK_DATA    *CallbackData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Dispatch BMM formset and FileExplorer formset.\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_FORM_BROWSER_PROTOCOL *FormConfig;\r
+  UINT8                     *Location;\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_FILE_CONTEXT           *NewFileContext;\r
+  BOOLEAN                       BootMaintMenuResetRequired;\r
+\r
+  Location        = NULL;\r
+  Index           = 0;\r
+  NewMenuEntry    = NULL;\r
+  NewFileContext  = NULL;\r
+\r
+  //\r
+  // There should only be one Form Configuration protocol\r
+  //\r
+  Status = EfiLibLocateProtocol (&gEfiFormBrowserProtocolGuid, &FormConfig);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  while (1) {\r
+    UpdatePageId (CallbackData, FORM_MAIN_ID);\r
+\r
+    BootMaintMenuResetRequired = FALSE;\r
+    Status = FormConfig->SendForm (\r
+                          FormConfig,\r
+                          TRUE,\r
+                          &(CallbackData->BmmHiiHandle),\r
+                          1,\r
+                          NULL,\r
+                          NULL,\r
+                          (UINT8 *) CallbackData->BmmFakeNvData,\r
+                          NULL,\r
+                          &BootMaintMenuResetRequired\r
+                          );\r
+\r
+    if (BootMaintMenuResetRequired) {\r
+      EnableResetRequired ();\r
+    }\r
+\r
+    ReclaimStringDepository ();\r
+\r
+    //\r
+    // When this Formset returns, check if we are going to explore files.\r
+    //\r
+    if (INACTIVE_STATE != CallbackData->FeCurrentState) {\r
+      UpdateFileExplorer (CallbackData, 0);\r
+\r
+      BootMaintMenuResetRequired = FALSE;\r
+      Status = FormConfig->SendForm (\r
+                            FormConfig,\r
+                            TRUE,\r
+                            &(CallbackData->FeHiiHandle),\r
+                            1,\r
+                            NULL,\r
+                            NULL,\r
+                            NULL,\r
+                            NULL,\r
+                            &BootMaintMenuResetRequired\r
+                            );\r
+\r
+      if (BootMaintMenuResetRequired) {\r
+        EnableResetRequired ();\r
+      }\r
+\r
+      CallbackData->FeCurrentState    = INACTIVE_STATE;\r
+      CallbackData->FeDisplayContext  = UNKNOWN_CONTEXT;\r
+      ReclaimStringDepository ();\r
+    } else {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+VOID\r
+CreateCallbackPacket (\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet,\r
+  IN  UINT16                          Flags\r
+  )\r
+{\r
+  *Packet = (EFI_HII_CALLBACK_PACKET *) AllocateZeroPool (sizeof (EFI_HII_CALLBACK_PACKET) + 2);\r
+  ASSERT (*Packet != NULL);\r
+\r
+  (*Packet)->DataArray.EntryCount   = 1;\r
+  (*Packet)->DataArray.NvRamMap     = NULL;\r
+  ((EFI_IFR_DATA_ENTRY *) (&((*Packet)->DataArray) + 1))->Flags  = Flags;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootMaint.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootMaint.h
new file mode 100644 (file)
index 0000000..d2a3e3d
--- /dev/null
@@ -0,0 +1,1161 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMaint.h\r
+\r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _BOOT_MAINT_H\r
+#define _BOOT_MAINT_H\r
+\r
+#include "BdsStrDefs.h"\r
+#include "Generic/BootMaint/BBSsupport.h"\r
+\r
+//\r
+// Constants which are variable names used to access variables\r
+//\r
+#define VarLegacyDevOrder L"LegacyDevOrder"\r
+\r
+//\r
+// Guid of a NV Variable which store the information about the\r
+// FD/HD/CD/NET/BEV order\r
+//\r
+#define EFI_LEGACY_DEV_ORDER_VARIABLE_GUID \\r
+  { \\r
+    0xa56074db, 0x65fe, 0x45f7, {0xbd, 0x21, 0x2d, 0x2b, 0xdd, 0x8e, 0x96, 0x52 } \\r
+  }\r
+\r
+//\r
+// String Contant\r
+//\r
+#define StrFloppy       L"Floppy Drive #%02x"\r
+#define StrHardDisk     L"HardDisk Drive #%02x"\r
+#define StrCDROM        L"ATAPI CDROM Drive #%02x"\r
+#define StrNET          L"NET Drive #%02x"\r
+#define StrBEV          L"BEV Drive #%02x"\r
+#define StrFloppyHelp   L"Select Floppy Drive #%02x"\r
+#define StrHardDiskHelp L"Select HardDisk Drive #%02x"\r
+#define StrCDROMHelp    L"Select ATAPI CDROM Drive #%02x"\r
+#define StrNETHelp      L"NET Drive #%02x"\r
+#define StrBEVHelp      L"BEV Drive #%02x"\r
+\r
+//\r
+// Constant will be used in display and file system navigation\r
+//\r
+#define UPDATE_DATA_SIZE        0x100000\r
+#define MAX_BBS_OFFSET          0xE000\r
+#define NET_OPTION_OFFSET       0xD800\r
+#define BEV_OPTION_OFFSET       0xD000\r
+#define FD_OPTION_OFFSET        0xC000\r
+#define HD_OPTION_OFFSET        0xB000\r
+#define CD_OPTION_OFFSET        0xA000\r
+#define FILE_OPTION_OFFSET      0x8000\r
+#define FILE_OPTION_MASK        0x7FFF\r
+#define HANDLE_OPTION_OFFSET    0x7000\r
+#define CONSOLE_OPTION_OFFSET   0x0A00\r
+#define TERMINAL_OPTION_OFFSET  0x0700\r
+#define NORMAL_GOTO_OFFSET      0x0100\r
+#define MAX_STRING_TOKEN_COUNT  0x00FF\r
+//\r
+// Variable created with this flag will be "Efi:...."\r
+//\r
+#define VAR_FLAG  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE\r
+\r
+//\r
+// Define Maxmim characters that will be accepted\r
+//\r
+#define MAX_CHAR      480\r
+#define MAX_CHAR_SIZE (MAX_CHAR * 2)\r
+\r
+//\r
+// Check to see if current build support option active feature of\r
+// some driver option\r
+//\r
+#ifndef LOAD_OPTION_ACTIVE\r
+#define LOAD_OPTION_ACTIVE  0x00000001\r
+#endif\r
+//\r
+// Check to see if current build support force reconnect feature of\r
+// some driver option\r
+//\r
+#ifndef LOAD_OPTION_FORCE_RECONNECT\r
+#define LOAD_OPTION_FORCE_RECONNECT 0x00000002\r
+#endif\r
+//\r
+// Below are the form ids for display, form id is used as callback key value,\r
+// some key value definitions are also defined here. By defining this enum type,\r
+// We can easy know where we are. The int to UINT16 convertion should be ok because\r
+// there is a MAXIMUM_FORM_ID which in within the range of UINT16.\r
+//\r
+typedef enum {\r
+  IplRelative,\r
+  BcvRelative\r
+} BBS_TYPE;\r
+\r
+typedef enum {\r
+  FORM_RESERVED_ID                    = 0,\r
+  FORM_MAIN_ID,                         // 0x0001\r
+  FORM_BOOT_ADD_ID,                     // 0x0002\r
+  FORM_BOOT_DEL_ID,                     // 0x0003\r
+  FORM_BOOT_CHG_ID,                     // 0x0004\r
+  FORM_DRV_ADD_ID,                      // 0x0005\r
+  FORM_DRV_DEL_ID,                      // 0x0006\r
+  FORM_DRV_CHG_ID,                      // 0x0007\r
+  FORM_CON_MAIN_ID,                     // 0x0008\r
+  FORM_CON_IN_ID,                       // 0x0009\r
+  FORM_CON_OUT_ID,                      // 0x000A\r
+  FORM_CON_ERR_ID,                      // 0x000B\r
+  FORM_FILE_SEEK_ID,                    // 0x000C\r
+  FORM_FILE_NEW_SEEK_ID,                // 0x000D\r
+  FORM_DRV_ADD_FILE_ID,                 // 0x000E\r
+  FORM_DRV_ADD_HANDLE_ID,               // 0x000F\r
+  FORM_DRV_ADD_HANDLE_DESC_ID,          // 0x0010\r
+  FORM_BOOT_NEXT_ID,                    // 0x0011\r
+  FORM_TIME_OUT_ID,                     // 0x0012\r
+  FORM_RESET,                           // 0x0013\r
+  FORM_BOOT_SETUP_ID,                   // 0x0014\r
+  FORM_DRIVER_SETUP_ID,                 // 0x0015\r
+  FORM_BOOT_LEGACY_DEVICE_ID,           // 0x0016\r
+  FORM_CON_COM_ID,                      // 0x0017\r
+  FORM_CON_COM_SETUP_ID,                // 0x0018\r
+  FORM_SET_FD_ORDER_ID,                 // 0x0019\r
+  FORM_SET_HD_ORDER_ID,                 // 0x001A\r
+  FORM_SET_CD_ORDER_ID,                 // 0x001B\r
+  FORM_SET_NET_ORDER_ID,                // 0x001C\r
+  FORM_SET_BEV_ORDER_ID,                // 0x001D\r
+  FORM_FILE_EXPLORER_ID,                // 0x001E\r
+  FORM_BOOT_ADD_DESCRIPTION_ID,         // 0x001F\r
+  FORM_DRIVER_ADD_FILE_DESCRIPTION_ID,  // 0x0020\r
+} FORM_ID;\r
+\r
+#define MAXIMUM_FORM_ID                 0x007F\r
+\r
+#define KEY_VALUE_COM_SET_BAUD_RATE     0x0080\r
+#define KEY_VALUE_COM_SET_DATA_BITS     0x0081\r
+#define KEY_VALUE_COM_SET_STOP_BITS     0x0082\r
+#define KEY_VALUE_COM_SET_PARITY        0x0083\r
+#define KEY_VALUE_COM_SET_TERMI_TYPE    0x0084\r
+#define KEY_VALUE_MAIN_BOOT_NEXT        0x0085\r
+#define KEY_VALUE_BOOT_ADD_DESC_DATA    0x0086\r
+#define KEY_VALUE_BOOT_ADD_OPT_DATA     0x0087\r
+#define KEY_VALUE_DRIVER_ADD_DESC_DATA  0x0088\r
+#define KEY_VALUE_DRIVER_ADD_OPT_DATA   0x0089\r
+#define KEY_VALUE_SAVE_AND_EXIT         0x0090\r
+#define KEY_VALUE_NO_SAVE_AND_EXIT      0x0091\r
+#define KEY_VALUE_BOOT_FROM_FILE        0x0092\r
+\r
+#define MAXIMUM_NORMAL_KEY_VALUE        NORMAL_GOTO_OFFSET\r
+//\r
+// Below are the number of options in Baudrate, Databits,\r
+// Parity and Stopbits selection for serial ports.\r
+//\r
+#define BM_COM_ATTR_BUADRATE  19\r
+#define BM_COM_ATTR_DATABITS  4\r
+#define BM_COM_ATTR_PARITY    5\r
+#define BM_COM_ATTR_STOPBITS  3\r
+\r
+//\r
+// Callback function helper\r
+//\r
+#define BMM_CALLBACK_DATA_SIGNATURE     EFI_SIGNATURE_32 ('C', 'b', 'c', 'k')\r
+#define BMM_CALLBACK_DATA_FROM_THIS(a)  CR (a, BMM_CALLBACK_DATA, BmmDriverCallback, BMM_CALLBACK_DATA_SIGNATURE)\r
+\r
+#define FE_CALLBACK_DATA_FROM_THIS(a)   CR (a, BMM_CALLBACK_DATA, FeDriverCallback, BMM_CALLBACK_DATA_SIGNATURE)\r
+\r
+//\r
+// Enumeration type definition\r
+//\r
+typedef enum {\r
+  PC_ANSI                             = 0,\r
+  VT_100,\r
+  VT_100_PLUS,\r
+  VT_UTF8\r
+} TYPE_OF_TERMINAL;\r
+\r
+typedef enum {\r
+  COM1                                = 0,\r
+  COM2,\r
+  UNKNOW_COM\r
+} TYPE_OF_COM;\r
+\r
+typedef enum {\r
+  CONIN                               = 0,\r
+  CONOUT,\r
+  CONERR,\r
+  UNKNOWN_CON\r
+} TYPE_OF_CON;\r
+\r
+typedef enum {\r
+  BAUDRATE                            = 0,\r
+  DATABITS,\r
+  PARITY,\r
+  STOPBITS,\r
+  UNKNOW_ATTR\r
+} TYPE_OF_ATTRIBUTE;\r
+\r
+typedef enum {\r
+  MANNER_GOTO                         = 0,\r
+  MANNER_CHECK,\r
+  MANNER_ONEOF,\r
+  MANNER_USER_DEFINE\r
+} TYPE_OF_UPATE_MANNER;\r
+\r
+typedef enum {\r
+  INACTIVE_STATE                      = 0,\r
+  BOOT_FROM_FILE_STATE,\r
+  ADD_BOOT_OPTION_STATE,\r
+  ADD_DRIVER_OPTION_STATE,\r
+  UNKNOWN_STATE\r
+} FILE_EXPLORER_STATE;\r
+\r
+typedef enum {\r
+  FILE_SYSTEM,\r
+  DIRECTORY,\r
+  UNKNOWN_CONTEXT\r
+} FILE_EXPLORER_DISPLAY_CONTEXT;\r
+\r
+//\r
+// All of the signatures that will be used in list structure\r
+//\r
+#define BM_MENU_OPTION_SIGNATURE      'menu'\r
+#define BM_LOAD_OPTION_SIGNATURE      'load'\r
+#define BM_CONSOLE_OPTION_SIGNATURE   'cnsl'\r
+#define BM_FILE_OPTION_SIGNATURE      'file'\r
+#define BM_HANDLE_OPTION_SIGNATURE    'hndl'\r
+#define BM_TERMINAL_OPTION_SIGNATURE  'trml'\r
+#define BM_MENU_ENTRY_SIGNATURE       'entr'\r
+\r
+#define BM_LOAD_CONTEXT_SELECT        0x0\r
+#define BM_CONSOLE_CONTEXT_SELECT     0x1\r
+#define BM_FILE_CONTEXT_SELECT        0x2\r
+#define BM_HANDLE_CONTEXT_SELECT      0x3\r
+#define BM_TERMINAL_CONTEXT_SELECT    0x5\r
+\r
+#define BM_CONSOLE_IN_CONTEXT_SELECT  0x6\r
+#define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7\r
+#define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8\r
+#define BM_LEGACY_DEV_CONTEXT_SELECT  0x9\r
+\r
+//\r
+// Question Id that will be used to create question\r
+// all these values are computed from the structure\r
+// defined below\r
+//\r
+#define QUESTION_ID(Field)              ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field))\r
+\r
+#define BOOT_TIME_OUT_QUESTION_ID       QUESTION_ID (BootTimeOut)\r
+#define BOOT_NEXT_QUESTION_ID           QUESTION_ID (BootNext)\r
+#define COM1_BAUD_RATE_QUESTION_ID      QUESTION_ID (COM1BaudRate)\r
+#define COM1_DATA_RATE_QUESTION_ID      QUESTION_ID (COM1DataRate)\r
+#define COM1_STOP_BITS_QUESTION_ID      QUESTION_ID (COM1StopBits)\r
+#define COM1_PARITY_QUESTION_ID         QUESTION_ID (COM1Parity)\r
+#define COM1_TERMINAL_QUESTION_ID       QUESTION_ID (COM2TerminalType)\r
+#define COM2_BAUD_RATE_QUESTION_ID      QUESTION_ID (COM2BaudRate)\r
+#define COM2_DATA_RATE_QUESTION_ID      QUESTION_ID (COM2DataRate)\r
+#define COM2_STOP_BITS_QUESTION_ID      QUESTION_ID (COM2StopBits)\r
+#define COM2_PARITY_QUESTION_ID         QUESTION_ID (COM2Parity)\r
+#define COM2_TERMINAL_QUESTION_ID       QUESTION_ID (COM2TerminalType)\r
+#define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)\r
+#define DRV_ADD_ACTIVE_QUESTION_ID      QUESTION_ID (DriverAddActive)\r
+#define DRV_ADD_RECON_QUESTION_ID       QUESTION_ID (DriverAddForceReconnect)\r
+#define CON_IN_COM1_QUESTION_ID         QUESTION_ID (ConsoleInputCOM1)\r
+#define CON_IN_COM2_QUESTION_ID         QUESTION_ID (ConsoleInputCOM2)\r
+#define CON_OUT_COM1_QUESTION_ID        QUESTION_ID (ConsoleOutputCOM1)\r
+#define CON_OUT_COM2_QUESTION_ID        QUESTION_ID (ConsoleOutputCOM2)\r
+#define CON_ERR_COM1_QUESTION_ID        QUESTION_ID (ConsoleErrorCOM1)\r
+#define CON_ERR_COM2_QUESTION_ID        QUESTION_ID (ConsoleErrorCOM2)\r
+#define CON_DEVICE_QUESTION_ID          QUESTION_ID (ConsoleCheck)\r
+#define OPTION_ORDER_QUESTION_ID        QUESTION_ID (OptionOrder)\r
+#define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionToBeDeleted)\r
+#define BOOT_OPTION_DEL_QUESTION_ID     QUESTION_ID (BootOptionDel)\r
+#define DRIVER_OPTION_DEL_QUESTION_ID   QUESTION_ID (DriverOptionDel)\r
+#define DRIVER_ADD_OPTION_QUESTION_ID   QUESTION_ID (DriverAddHandleOptionalData)\r
+#define COM_BAUD_RATE_QUESTION_ID       QUESTION_ID (COMBaudRate)\r
+#define COM_DATA_RATE_QUESTION_ID       QUESTION_ID (COMDataRate)\r
+#define COM_STOP_BITS_QUESTION_ID       QUESTION_ID (COMStopBits)\r
+#define COM_PARITY_QUESTION_ID          QUESTION_ID (COMParity)\r
+#define COM_TERMINAL_QUESTION_ID        QUESTION_ID (COMTerminalType)\r
+#define LEGACY_FD_QUESTION_ID           QUESTION_ID (LegacyFD)\r
+#define LEGACY_HD_QUESTION_ID           QUESTION_ID (LegacyHD)\r
+#define LEGACY_CD_QUESTION_ID           QUESTION_ID (LegacyCD)\r
+#define LEGACY_NET_QUESTION_ID          QUESTION_ID (LegacyNET)\r
+#define LEGACY_BEV_QUESTION_ID          QUESTION_ID (LegacyBEV)\r
+\r
+#define STRING_DEPOSITORY_NUMBER        8\r
+\r
+//\r
+// #pragma pack(1)\r
+//\r
+// Serial Ports attributes, first one is the value for\r
+// return from callback function, stringtoken is used to\r
+// display the value properly\r
+//\r
+typedef struct {\r
+  UINTN   Value;\r
+  UINT16  StringToken;\r
+} COM_ATTR;\r
+\r
+//\r
+// This is the structure that will be used to store the\r
+// question's current value. Use it at initialize time to\r
+// set default value for each question. When using at run\r
+// time, this map is returned by the callback function,\r
+// so dynamically changing the question's value will be\r
+// possible through this mechanism\r
+//\r
+typedef struct {\r
+  //\r
+  // Three questions displayed at the main page\r
+  // for Timeout, BootNext Variables respectively\r
+  //\r
+  UINT16  BootTimeOut;\r
+  UINT16  BootNext;\r
+\r
+  //\r
+  // This is the COM1 Attributes value storage\r
+  //\r
+  UINT8   COM1BaudRate;\r
+  UINT8   COM1DataRate;\r
+  UINT8   COM1StopBits;\r
+  UINT8   COM1Parity;\r
+  UINT8   COM1TerminalType;\r
+\r
+  //\r
+  // This is the COM2 Attributes value storage\r
+  //\r
+  UINT8   COM2BaudRate;\r
+  UINT8   COM2DataRate;\r
+  UINT8   COM2StopBits;\r
+  UINT8   COM2Parity;\r
+  UINT8   COM2TerminalType;\r
+\r
+  //\r
+  // Driver Option Add Handle page storage\r
+  //\r
+  UINT16  DriverAddHandleDesc[100];\r
+  UINT16  DriverAddHandleOptionalData[100];\r
+  UINT8   DriverAddActive;\r
+  UINT8   DriverAddForceReconnect;\r
+\r
+  //\r
+  // Console Input/Output/Errorout using COM port check storage\r
+  //\r
+  UINT8   ConsoleInputCOM1;\r
+  UINT8   ConsoleInputCOM2;\r
+  UINT8   ConsoleOutputCOM1;\r
+  UINT8   ConsoleOutputCOM2;\r
+  UINT8   ConsoleErrorCOM1;\r
+  UINT8   ConsoleErrorCOM2;\r
+\r
+  //\r
+  // At most 100 input/output/errorout device for console storage\r
+  //\r
+  UINT8   ConsoleCheck[100];\r
+\r
+  //\r
+  // Boot or Driver Option Order storage\r
+  //\r
+  UINT8   OptionOrder[100];\r
+  UINT8   DriverOptionToBeDeleted[100];\r
+\r
+  //\r
+  // Boot Option Delete storage\r
+  //\r
+  UINT8   BootOptionDel[100];\r
+  UINT8   DriverOptionDel[100];\r
+\r
+  //\r
+  // This is the Terminal Attributes value storage\r
+  //\r
+  UINT8   COMBaudRate;\r
+  UINT8   COMDataRate;\r
+  UINT8   COMStopBits;\r
+  UINT8   COMParity;\r
+  UINT8   COMTerminalType;\r
+\r
+  //\r
+  // Legacy Device Order Selection Storage\r
+  //\r
+  UINT8   LegacyFD[100];\r
+  UINT8   LegacyHD[100];\r
+  UINT8   LegacyCD[100];\r
+  UINT8   LegacyNET[100];\r
+  UINT8   LegacyBEV[100];\r
+\r
+  //\r
+  // We use DisableMap array to record the enable/disable state of each boot device\r
+  // It should be taken as a bit array, from left to right there are totally 256 bits\r
+  // the most left one stands for BBS table item 0, and the most right one stands for item 256\r
+  // If the bit is 1, it means the boot device has been disabled.\r
+  //\r
+  UINT8   DisableMap[32];\r
+\r
+  //\r
+  //  UINT16                    PadArea[10];\r
+  //\r
+} BMM_FAKE_NV_DATA;\r
+\r
+typedef struct {\r
+  UINT16  DescriptionData[75];\r
+  UINT16                    OptionalData[127];\r
+  UINT8   Active;\r
+  UINT8   ForceReconnect;\r
+} FILE_EXPLORER_NV_DATA;\r
+\r
+typedef struct {\r
+  BBS_TYPE  BbsType;\r
+  //\r
+  // Length = sizeof (UINT16) + SIZEOF (Data)\r
+  //\r
+  UINT16    Length;\r
+  UINT16    *Data;\r
+} BM_LEGACY_DEV_ORDER_CONTEXT;\r
+\r
+typedef struct {\r
+  UINT64                    BaudRate;\r
+  UINT8                     DataBits;\r
+  UINT8                     Parity;\r
+  UINT8                     StopBits;\r
+\r
+  UINT8                     BaudRateIndex;\r
+  UINT8                     DataBitsIndex;\r
+  UINT8                     ParityIndex;\r
+  UINT8                     StopBitsIndex;\r
+\r
+  UINT8                     IsConIn;\r
+  UINT8                     IsConOut;\r
+  UINT8                     IsStdErr;\r
+  UINT8                     TerminalType;\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+} BM_TERMINAL_CONTEXT;\r
+\r
+typedef struct {\r
+  BOOLEAN                   IsBootNext;\r
+  BOOLEAN                   LoadOptionModified;\r
+  BOOLEAN                   Deleted;\r
+\r
+  BOOLEAN                   IsLegacy;\r
+  BOOLEAN                   IsActive;\r
+  BOOLEAN                   ForceReconnect;\r
+  UINTN                     OptionalDataSize;\r
+\r
+  UINTN                     LoadOptionSize;\r
+  UINT8                     *LoadOption;\r
+\r
+  UINT32                    Attributes;\r
+  UINT16                    FilePathListLength;\r
+  UINT16                    *Description;\r
+  EFI_DEVICE_PATH_PROTOCOL  *FilePathList;\r
+  UINT8                     *OptionalData;\r
+\r
+  UINT16                    BbsIndex;\r
+} BM_LOAD_CONTEXT;\r
+\r
+typedef struct {\r
+  BBS_TABLE *BbsTable;\r
+  UINTN     Index;\r
+  UINTN     BbsCount;\r
+  UINT16    *Description;\r
+} BM_LEGACY_DEVICE_CONTEXT;\r
+\r
+typedef struct {\r
+\r
+  BOOLEAN                   IsActive;\r
+\r
+  BOOLEAN                   IsTerminal;\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+} BM_CONSOLE_CONTEXT;\r
+\r
+typedef struct {\r
+  EFI_HANDLE                        Handle;\r
+  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
+  EFI_FILE_HANDLE                   FHandle;\r
+  UINT16                            *FileName;\r
+  EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *Info;\r
+\r
+  BOOLEAN                           IsRoot;\r
+  BOOLEAN                           IsDir;\r
+  BOOLEAN                           IsRemovableMedia;\r
+  BOOLEAN                           IsLoadFile;\r
+  BOOLEAN                           IsBootLegacy;\r
+} BM_FILE_CONTEXT;\r
+\r
+typedef struct {\r
+  EFI_HANDLE                Handle;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+} BM_HANDLE_CONTEXT;\r
+\r
+typedef struct {\r
+  UINTN           Signature;\r
+  LIST_ENTRY      Head;\r
+  UINTN           MenuNumber;\r
+} BM_MENU_OPTION;\r
+\r
+typedef struct {\r
+  UINTN           Signature;\r
+  LIST_ENTRY      Link;\r
+  UINTN           OptionNumber;\r
+  UINT16          *DisplayString;\r
+  UINT16          *HelpString;\r
+  STRING_REF      DisplayStringToken;\r
+  STRING_REF      HelpStringToken;\r
+  UINTN           ContextSelection;\r
+  VOID            *VariableContext;\r
+} BM_MENU_ENTRY;\r
+\r
+typedef struct {\r
+  //\r
+  // Shared callback data.\r
+  //\r
+  UINTN                         Signature;\r
+  EFI_HII_PROTOCOL              *Hii;\r
+  BM_MENU_ENTRY                 *MenuEntry;\r
+  BM_HANDLE_CONTEXT             *HandleContext;\r
+  BM_FILE_CONTEXT               *FileContext;\r
+  BM_LOAD_CONTEXT               *LoadContext;\r
+  BM_TERMINAL_CONTEXT           *TerminalContext;\r
+  UINTN                         CurrentTerminal;\r
+  BBS_TYPE                      BbsType;\r
+\r
+  //\r
+  // BMM main formset callback data.\r
+  //\r
+  EFI_HII_HANDLE                BmmHiiHandle;\r
+  EFI_HANDLE                    BmmCallbackHandle;\r
+  EFI_FORM_CALLBACK_PROTOCOL    BmmDriverCallback;\r
+  FORM_ID                       BmmCurrentPageId;\r
+  FORM_ID                       BmmPreviousPageId;\r
+  BOOLEAN                       BmmAskSaveOrNot;\r
+  BMM_FAKE_NV_DATA              *BmmFakeNvData;\r
+  BMM_FAKE_NV_DATA              BmmOldFakeNVData;\r
+\r
+  //\r
+  // File explorer formset callback data.\r
+  //\r
+  EFI_HII_HANDLE                FeHiiHandle;\r
+  EFI_HANDLE                    FeCallbackHandle;\r
+  EFI_FORM_CALLBACK_PROTOCOL    FeDriverCallback;\r
+  FILE_EXPLORER_STATE           FeCurrentState;\r
+  FILE_EXPLORER_DISPLAY_CONTEXT FeDisplayContext;\r
+} BMM_CALLBACK_DATA;\r
+\r
+typedef struct _STRING_LIST_NODE {\r
+  STRING_REF                StringToken;\r
+  struct _STRING_LIST_NODE  *Next;\r
+} STRING_LIST_NODE;\r
+\r
+typedef struct _STRING_DEPOSITORY {\r
+  UINTN             TotalNodeNumber;\r
+  STRING_LIST_NODE  *CurrentNode;\r
+  STRING_LIST_NODE  *ListHead;\r
+} STRING_DEPOSITORY;\r
+\r
+//\r
+// #pragma pack()\r
+//\r
+// For initializing File System menu\r
+//\r
+EFI_STATUS\r
+BOpt_FindFileSystem (\r
+  IN BMM_CALLBACK_DATA          *CallbackData\r
+  )\r
+;\r
+\r
+//\r
+// For cleaning up File System menu\r
+//\r
+VOID\r
+BOpt_FreeFileSystem (\r
+  VOID\r
+  )\r
+;\r
+\r
+//\r
+// For initializing File Navigation menu\r
+//\r
+EFI_STATUS\r
+BOpt_FindFiles (\r
+  IN BMM_CALLBACK_DATA          *CallbackData,\r
+  IN BM_MENU_ENTRY              *MenuEntry\r
+  )\r
+;\r
+\r
+//\r
+// For cleaning up File Navigation menu\r
+//\r
+VOID\r
+BOpt_FreeFiles (\r
+  VOID\r
+  )\r
+;\r
+\r
+//\r
+// For Initializing handle navigation menu\r
+//\r
+EFI_STATUS\r
+BOpt_FindDrivers (\r
+  VOID\r
+  )\r
+;\r
+\r
+//\r
+// For Cleaning up handle navigation menu\r
+//\r
+VOID\r
+BOpt_FreeDrivers();\r
+\r
+//\r
+// For initializing Boot Option menu\r
+//\r
+EFI_STATUS\r
+BOpt_GetBootOptions (\r
+  IN  BMM_CALLBACK_DATA         *CallbackData\r
+  );\r
+\r
+//\r
+// For Initializing Driver option menu\r
+//\r
+EFI_STATUS\r
+BOpt_GetDriverOptions (\r
+  IN  BMM_CALLBACK_DATA         *CallbackData\r
+  );\r
+\r
+//\r
+// For Cleaning up boot option menu\r
+//\r
+VOID\r
+BOpt_FreeBootOptions ();\r
+\r
+//\r
+// For cleaning up driver option menu\r
+//\r
+VOID\r
+BOpt_FreeDriverOptions();\r
+\r
+//\r
+// For Initializing HD/FD/CD/NET/BEV option menu\r
+//\r
+EFI_STATUS\r
+BOpt_GetLegacyOptions();\r
+\r
+//\r
+// For cleaning up driver option menu\r
+//\r
+VOID\r
+BOpt_FreeLegacyOptions();\r
+\r
+//\r
+// this function is used to take place of all other free menu actions\r
+//\r
+VOID\r
+BOpt_FreeMenu (\r
+  BM_MENU_OPTION        *FreeMenu\r
+  );\r
+\r
+\r
+//\r
+// Following are the helper functions used\r
+//\r
+CHAR16                            *\r
+BOpt_AppendFileName (\r
+  IN  CHAR16  *Str1,\r
+  IN  CHAR16  *Str2\r
+  );\r
+\r
+BOOLEAN\r
+BOpt_IsEfiImageName (\r
+  IN UINT16  *FileName\r
+  );\r
+\r
+BOOLEAN\r
+BOpt_IsEfiApp (\r
+  IN EFI_FILE_HANDLE Dir,\r
+  IN UINT16          *FileName\r
+  );\r
+\r
+//\r
+// Get current unused boot option number\r
+//\r
+UINT16\r
+BOpt_GetBootOptionNumber ();\r
+\r
+//\r
+// Get current unused driver option number\r
+//\r
+UINT16\r
+BOpt_GetDriverOptionNumber ();\r
+\r
+BM_MENU_ENTRY                     *\r
+BOpt_CreateMenuEntry (\r
+  UINTN           MenuType\r
+  );\r
+\r
+VOID\r
+BOpt_DestroyMenuEntry (\r
+  BM_MENU_ENTRY         *MenuEntry\r
+  );\r
+\r
+BM_MENU_ENTRY                     *\r
+BOpt_GetMenuEntry (\r
+  BM_MENU_OPTION      *MenuOption,\r
+  UINTN               MenuNumber\r
+  );\r
+\r
+//\r
+// a helper function used to free pool type memory\r
+//\r
+VOID\r
+SafeFreePool (\r
+  IN VOID *Buffer\r
+  );\r
+\r
+//\r
+// Locate all serial io devices for console\r
+//\r
+EFI_STATUS\r
+LocateSerialIo ();\r
+\r
+//\r
+// Initializing Console menu\r
+//\r
+EFI_STATUS\r
+GetAllConsoles();\r
+\r
+//\r
+// Cleaning up console menu\r
+//\r
+EFI_STATUS\r
+FreeAllConsoles();\r
+\r
+VOID\r
+ChangeVariableDevicePath (\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+); \r
+\r
+EFI_STATUS\r
+ChangeTerminalDevicePath (\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
+  BOOLEAN                   ChangeTerminal\r
+);\r
+//\r
+// Variable operation by menu selection\r
+//\r
+EFI_STATUS\r
+Var_UpdateBootOption (\r
+  IN  BMM_CALLBACK_DATA                   *CallbackData,\r
+  IN  FILE_EXPLORER_NV_DATA               *NvRamMap\r
+  );\r
+\r
+EFI_STATUS\r
+Var_DelBootOption ();\r
+\r
+EFI_STATUS\r
+Var_ChangeBootOrder ();\r
+\r
+EFI_STATUS\r
+Var_UpdateDriverOption (\r
+  IN  BMM_CALLBACK_DATA         *CallbackData,\r
+  IN  EFI_HII_HANDLE            HiiHandle,\r
+  IN  UINT16                    *DescriptionData,\r
+  IN  UINT16                    *OptionalData,\r
+  IN  UINT8                     ForceReconnect\r
+  );\r
+\r
+EFI_STATUS\r
+Var_DelDriverOption ();\r
+\r
+EFI_STATUS\r
+Var_ChangeDriverOrder ();\r
+\r
+EFI_STATUS\r
+Var_UpdateConsoleInpOption ();\r
+\r
+EFI_STATUS\r
+Var_UpdateConsoleOutOption ();\r
+\r
+EFI_STATUS\r
+Var_UpdateErrorOutOption ();\r
+\r
+VOID\r
+Var_UpdateAllConsoleOption ();\r
+\r
+EFI_STATUS\r
+Var_UpdateBootNext (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  );\r
+\r
+EFI_STATUS\r
+Var_UpdateBootOrder (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  );\r
+\r
+EFI_STATUS\r
+Var_UpdateDriverOrder (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  );\r
+\r
+EFI_STATUS\r
+Var_UpdateBBSOption (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  );\r
+\r
+//\r
+// Following are page create and refresh functions\r
+//\r
+VOID\r
+RefreshUpdateData (\r
+  IN BOOLEAN                          FormSetUpdate,\r
+  IN EFI_PHYSICAL_ADDRESS             FormCallbackHandle,\r
+  IN BOOLEAN                          FormUpdate,\r
+  IN STRING_REF                       FormTitle,\r
+  IN UINT16                           DataCount\r
+  );\r
+\r
+VOID\r
+CleanUpPage (\r
+  IN EFI_FORM_LABEL                   LabelId,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+EFI_STATUS\r
+UpdatePage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData,\r
+  IN BM_MENU_OPTION                   *UpdatingMenu,\r
+  IN UINT16                           UpdatingPage,\r
+  IN UINT16                           UpdatingManner,\r
+  IN UINT16                           QuestionIdStart,\r
+  IN UINT16                           GotoForm,\r
+  IN UINT16                           GotoAlternateForm,\r
+  IN STRING_REF                       DisplayTokenStart,\r
+  IN STRING_REF                       HelpTokenStart,\r
+  IN UINT16                           KeyValueStart\r
+  );\r
+\r
+VOID\r
+UpdateBootAddPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateBootDelPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateDrvAddFilePage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateDrvAddHandlePage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateDrvDelPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateDriverAddHandleDescPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateBootTimeOut (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateConInPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateConOutPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateStdErrPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdatePageBody (\r
+  IN UINT16                           UpdatePageId,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateCOM1Page (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateCOM2Page (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateBootOrderPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateDriverOrderPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateBootNextPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateTimeOutPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateTerminalPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateConCOMPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  );\r
+\r
+VOID\r
+UpdateSetLegacyDeviceOrderPage (\r
+  IN UINT16                           UpdatePageId,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+);\r
+\r
+EFI_STATUS\r
+BootLegacy (\r
+  IN  UINT16  BbsType,\r
+  IN  UINT16  BbsFlag\r
+);\r
+\r
+BM_MENU_ENTRY                     *\r
+GetCurrentTerminal (\r
+  UINTN       TerminalNumber\r
+);\r
+\r
+EFI_FILE_HANDLE\r
+EfiLibOpenRoot (\r
+  IN EFI_HANDLE       DeviceHandle\r
+  );\r
+\r
+EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *\r
+EfiLibFileSystemVolumeLabelInfo (\r
+  IN EFI_FILE_HANDLE      FHand\r
+  );\r
+\r
+EFI_FILE_INFO                     *\r
+EfiLibFileInfo (\r
+  IN EFI_FILE_HANDLE      FHand\r
+  );\r
+\r
+CHAR16                            *\r
+DevicePathToStr (\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  );\r
+\r
+EFI_STATUS\r
+EfiLibLocateProtocol (\r
+  IN  EFI_GUID        *ProtocolGuid,\r
+  OUT VOID            **Interface\r
+  );\r
+\r
+VOID                              *\r
+EfiReallocatePool (\r
+  IN VOID                 *OldPool,\r
+  IN UINTN                OldSize,\r
+  IN UINTN                NewSize\r
+  );\r
+\r
+CHAR16                            *\r
+DevicePathToStr (\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  );\r
+\r
+VOID                              *\r
+BdsLibGetVariableAndSize (\r
+  IN CHAR16               *Name,\r
+  IN EFI_GUID             *VendorGuid,\r
+  OUT UINTN               *VarSize\r
+  );\r
+\r
+EFI_STATUS\r
+EfiLibDeleteVariable (\r
+  IN CHAR16   *VarName,\r
+  IN EFI_GUID *VarGuid\r
+  );\r
+\r
+CHAR16                            *\r
+EfiStrDuplicate (\r
+  IN CHAR16   *Src\r
+  );\r
+\r
+BOOLEAN\r
+EfiLibMatchDevicePaths (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL *Multi,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL *Single\r
+  );\r
+\r
+UINTN\r
+EfiDevicePathInstanceCount (\r
+  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+CreateMenuStringToken (\r
+  IN BMM_CALLBACK_DATA                *CallbackData,\r
+  IN EFI_HII_HANDLE                   HiiHandle,\r
+  IN BM_MENU_OPTION                   *MenuOption\r
+  );\r
+\r
+UINT16                            *\r
+EfiLibStrFromDatahub (\r
+  IN EFI_DEVICE_PATH_PROTOCOL                 *DevPath\r
+  );\r
+\r
+VOID                              *\r
+GetLegacyBootOptionVar (\r
+  IN  UINTN                            DeviceType,\r
+  OUT UINTN                            *OptionIndex,\r
+  OUT UINTN                            *OptionSize\r
+ );\r
+\r
+EFI_STATUS\r
+InitializeBM (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsStartBootMaint (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+InitializeStringDepository ();\r
+\r
+STRING_REF\r
+GetStringTokenFromDepository (\r
+  IN   BMM_CALLBACK_DATA     *CallbackData,\r
+  IN   STRING_DEPOSITORY     *StringDepository\r
+  ) ;\r
+\r
+VOID\r
+ReclaimStringDepository (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+CleanUpStringDepository (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+ApplyChangeHandler (\r
+  IN  BMM_CALLBACK_DATA               *Private,\r
+  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap,\r
+  IN  FORM_ID                         FormId\r
+  );\r
+\r
+VOID\r
+DiscardChangeHandler (\r
+  IN  BMM_CALLBACK_DATA               *Private,\r
+  IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap\r
+  );\r
+\r
+VOID\r
+UpdatePageId (\r
+  BMM_CALLBACK_DATA              *Private,\r
+  UINT16                         NewPageId\r
+  );\r
+\r
+EFI_STATUS\r
+BootThisFile (\r
+  IN BM_FILE_CONTEXT                   *FileContext\r
+  );\r
+\r
+BOOLEAN\r
+UpdateFileExplorer (\r
+  IN BMM_CALLBACK_DATA            *CallbackData,\r
+  IN UINT16                       KeyValue\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FileExplorerCallback (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *Data,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  );\r
+\r
+EFI_STATUS\r
+FormSetDispatcher (\r
+  IN  BMM_CALLBACK_DATA    *CallbackData\r
+  );\r
+\r
+VOID CreateCallbackPacket (\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet,\r
+  IN  UINT16                          Flags\r
+  );\r
+\r
+//\r
+// Global variable in this program (defined in data.c)\r
+//\r
+extern BM_MENU_OPTION             BootOptionMenu;\r
+extern BM_MENU_OPTION             DriverOptionMenu;\r
+extern BM_MENU_OPTION             FsOptionMenu;\r
+extern BM_MENU_OPTION             ConsoleInpMenu;\r
+extern BM_MENU_OPTION             ConsoleOutMenu;\r
+extern BM_MENU_OPTION             ConsoleErrMenu;\r
+extern BM_MENU_OPTION             DirectoryMenu;\r
+extern BM_MENU_OPTION             DriverMenu;\r
+extern BM_MENU_OPTION             TerminalMenu;\r
+extern BM_MENU_OPTION             LegacyFDMenu;\r
+extern BM_MENU_OPTION             LegacyHDMenu;\r
+extern BM_MENU_OPTION             LegacyCDMenu;\r
+extern BM_MENU_OPTION             LegacyNETMenu;\r
+extern BM_MENU_OPTION             LegacyBEVMenu;\r
+extern UINT16                     TerminalType[];\r
+extern COM_ATTR                   BaudRateList[19];\r
+extern COM_ATTR                   DataBitsList[4];\r
+extern COM_ATTR                   ParityList[5];\r
+extern COM_ATTR                   StopBitsList[3];\r
+extern EFI_GUID                   Guid[4];\r
+extern EFI_HII_UPDATE_DATA        *UpdateData;\r
+extern STRING_DEPOSITORY          *FileOptionStrDepository;\r
+extern STRING_DEPOSITORY          *ConsoleOptionStrDepository;\r
+extern STRING_DEPOSITORY          *BootOptionStrDepository;\r
+extern STRING_DEPOSITORY          *BootOptionHelpStrDepository;\r
+extern STRING_DEPOSITORY          *DriverOptionStrDepository;\r
+extern STRING_DEPOSITORY          *DriverOptionHelpStrDepository;\r
+extern STRING_DEPOSITORY          *TerminalStrDepository;\r
+extern EFI_DEVICE_PATH_PROTOCOL   EndDevicePath[];\r
+extern EFI_GUID                   EfiLegacyDevOrderGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c
new file mode 100644 (file)
index 0000000..3fccd99
--- /dev/null
@@ -0,0 +1,1685 @@
+/*++\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootOption.c\r
+  \r
+Abstract:\r
+\r
+  Provide boot option support for Application "BootMaint"\r
+\r
+  Include file system navigation, system handle selection\r
+\r
+  Boot option manipulation\r
+  \r
+Revision History\r
+\r
+--*/\r
+\r
+#include "BootMaint.h"\r
+#include "BBSsupport.h"\r
+\r
+BM_MENU_ENTRY *\r
+BOpt_CreateMenuEntry (\r
+  UINTN           MenuType\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Create Menu Entry for future use, make all types together\r
+  in order to reduce code size\r
+\r
+Arguments:\r
+  MenuType            Use this parameter to identify current\r
+                      Menu type\r
+\r
+Returns:\r
+  NULL                Cannot allocate memory for current menu \r
+                      entry\r
+  Others              A valid pointer pointing to the allocated\r
+                      memory pool for current menu entry\r
+\r
+--*/\r
+{\r
+  BM_MENU_ENTRY *MenuEntry;\r
+  UINTN         ContextSize;\r
+\r
+  switch (MenuType) {\r
+  case BM_LOAD_CONTEXT_SELECT:\r
+    ContextSize = sizeof (BM_LOAD_CONTEXT);\r
+    break;\r
+\r
+  case BM_FILE_CONTEXT_SELECT:\r
+    ContextSize = sizeof (BM_FILE_CONTEXT);\r
+    break;\r
+\r
+  case BM_CONSOLE_CONTEXT_SELECT:\r
+    ContextSize = sizeof (BM_CONSOLE_CONTEXT);\r
+    break;\r
+\r
+  case BM_TERMINAL_CONTEXT_SELECT:\r
+    ContextSize = sizeof (BM_TERMINAL_CONTEXT);\r
+    break;\r
+\r
+  case BM_HANDLE_CONTEXT_SELECT:\r
+    ContextSize = sizeof (BM_HANDLE_CONTEXT);\r
+    break;\r
+\r
+  case BM_LEGACY_DEV_CONTEXT_SELECT:\r
+    ContextSize = sizeof (BM_LEGACY_DEVICE_CONTEXT);\r
+    break;\r
+\r
+  default:\r
+    ContextSize = 0;\r
+    break;\r
+\r
+  }\r
+\r
+  if (0 == ContextSize) {\r
+    return NULL;\r
+  }\r
+\r
+  MenuEntry = AllocateZeroPool (sizeof (BM_MENU_ENTRY));\r
+  if (NULL == MenuEntry) {\r
+    return MenuEntry;\r
+  }\r
+\r
+  MenuEntry->VariableContext = AllocateZeroPool (ContextSize);\r
+  if (NULL == MenuEntry->VariableContext) {\r
+    SafeFreePool (MenuEntry);\r
+    MenuEntry = NULL;\r
+    return MenuEntry;\r
+  }\r
+\r
+  MenuEntry->Signature        = BM_MENU_ENTRY_SIGNATURE;\r
+  MenuEntry->ContextSelection = MenuType;\r
+  return MenuEntry;\r
+}\r
+\r
+VOID\r
+BOpt_DestroyMenuEntry (\r
+  BM_MENU_ENTRY         *MenuEntry\r
+  )\r
+/*++\r
+  Routine Description :\r
+    Destroy the menu entry passed in\r
+\r
+  Arguments :\r
+    The menu entry need to be destroyed\r
+\r
+  Returns :\r
+    None\r
+\r
+--*/\r
+{\r
+  BM_LOAD_CONTEXT           *LoadContext;\r
+  BM_FILE_CONTEXT           *FileContext;\r
+  BM_CONSOLE_CONTEXT        *ConsoleContext;\r
+  BM_TERMINAL_CONTEXT       *TerminalContext;\r
+  BM_HANDLE_CONTEXT         *HandleContext;\r
+  BM_LEGACY_DEVICE_CONTEXT  *LegacyDevContext;\r
+\r
+  //\r
+  //  Select by the type in Menu entry for current context type\r
+  //\r
+  switch (MenuEntry->ContextSelection) {\r
+  case BM_LOAD_CONTEXT_SELECT:\r
+    LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;\r
+    SafeFreePool (LoadContext->FilePathList);\r
+    SafeFreePool (LoadContext->LoadOption);\r
+    SafeFreePool (LoadContext->OptionalData);\r
+    SafeFreePool (LoadContext);\r
+    break;\r
+\r
+  case BM_FILE_CONTEXT_SELECT:\r
+    FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
+\r
+    if (!FileContext->IsRoot) {\r
+      SafeFreePool (FileContext->DevicePath);\r
+    } else {\r
+      if (FileContext->FHandle != NULL) {\r
+        FileContext->FHandle->Close (FileContext->FHandle);\r
+      }\r
+    }\r
+\r
+    SafeFreePool (FileContext->FileName);\r
+    SafeFreePool (FileContext->Info);\r
+    SafeFreePool (FileContext);\r
+    break;\r
+\r
+  case BM_CONSOLE_CONTEXT_SELECT:\r
+    ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;\r
+    SafeFreePool (ConsoleContext->DevicePath);\r
+    SafeFreePool (ConsoleContext);\r
+    break;\r
+\r
+  case BM_TERMINAL_CONTEXT_SELECT:\r
+    TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;\r
+    SafeFreePool (TerminalContext->DevicePath);\r
+    SafeFreePool (TerminalContext);\r
+    break;\r
+\r
+  case BM_HANDLE_CONTEXT_SELECT:\r
+    HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;\r
+    SafeFreePool (HandleContext);\r
+    break;\r
+\r
+  case BM_LEGACY_DEV_CONTEXT_SELECT:\r
+    LegacyDevContext = (BM_LEGACY_DEVICE_CONTEXT *) MenuEntry->VariableContext;\r
+    SafeFreePool (LegacyDevContext);\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+  SafeFreePool (MenuEntry->DisplayString);\r
+  if (NULL != MenuEntry->HelpString) {\r
+    SafeFreePool (MenuEntry->HelpString);\r
+  }\r
+\r
+  SafeFreePool (MenuEntry);\r
+}\r
+\r
+BM_MENU_ENTRY *\r
+BOpt_GetMenuEntry (\r
+  BM_MENU_OPTION      *MenuOption,\r
+  UINTN               MenuNumber\r
+  )\r
+/*++\r
+  Rountine Description :\r
+    Use this routine to get one particular menu entry in specified \r
+    menu\r
+\r
+  Arguments :\r
+    MenuOption        The menu that we will search \r
+\r
+    MenuNumber        The menunubmer that we want\r
+\r
+  Returns :\r
+    The desired menu entry\r
+\r
+--*/\r
+{\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  UINTN           Index;\r
+  LIST_ENTRY      *List;\r
+\r
+  if (MenuNumber >= MenuOption->MenuNumber) {\r
+    return NULL;\r
+  }\r
+\r
+  List = MenuOption->Head.ForwardLink;\r
+  for (Index = 0; Index < MenuNumber; Index++) {\r
+    List = List->ForwardLink;\r
+  }\r
+\r
+  NewMenuEntry = CR (List, BM_MENU_ENTRY, Link, BM_MENU_ENTRY_SIGNATURE);\r
+\r
+  return NewMenuEntry;\r
+}\r
+\r
+EFI_STATUS\r
+BOpt_FindFileSystem (\r
+  IN BMM_CALLBACK_DATA          *CallbackData\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Find file systems for current Extensible Firmware\r
+  Including Handles that support Simple File System\r
+  protocol, Load File protocol.\r
+\r
+  Building up the FileSystem Menu for user selection\r
+  All file system will be stored in FsOptionMenu \r
+  for future use.\r
+\r
+Arguments:\r
+  CallbackData           -   BMM context data\r
+\r
+Returns:\r
+  EFI_SUCCESS            -   Success find the file system\r
+  EFI_OUT_OF_RESOURCES   -   Can not create menu entry\r
+\r
+--*/\r
+{\r
+  UINTN                     NoSimpleFsHandles;\r
+  UINTN                     NoLoadFileHandles;\r
+  EFI_HANDLE                *SimpleFsHandle;\r
+  EFI_HANDLE                *LoadFileHandle;\r
+  UINT16                    *VolumeLabel;\r
+  EFI_BLOCK_IO_PROTOCOL     *BlkIo;\r
+  UINTN                     Index;\r
+  EFI_STATUS                Status;\r
+  BM_MENU_ENTRY             *MenuEntry;\r
+  BM_FILE_CONTEXT           *FileContext;\r
+  UINT16                    *TempStr;\r
+  UINTN                     OptionNumber;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  UINT16                    DeviceType;\r
+  BBS_BBS_DEVICE_PATH       BbsDevicePathNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  BOOLEAN                   RemovableMedia;\r
+\r
+\r
+  NoSimpleFsHandles = 0;\r
+  NoLoadFileHandles = 0;\r
+  OptionNumber      = 0;\r
+  InitializeListHead (&FsOptionMenu.Head);\r
+\r
+  //\r
+  // Locate Handles that support Simple File System protocol\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  NULL,\r
+                  &NoSimpleFsHandles,\r
+                  &SimpleFsHandle\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Find all the instances of the File System prototocol\r
+    //\r
+    for (Index = 0; Index < NoSimpleFsHandles; Index++) {\r
+      Status = gBS->HandleProtocol (\r
+                      SimpleFsHandle[Index],\r
+                      &gEfiBlockIoProtocolGuid,\r
+                      &BlkIo\r
+                      );\r
+      if (EFI_ERROR (Status)) {\r
+        //\r
+        // If no block IO exists assume it's NOT a removable media\r
+        //\r
+        RemovableMedia = FALSE;\r
+      } else {\r
+        //\r
+        // If block IO exists check to see if it's remobable media\r
+        //\r
+        RemovableMedia = BlkIo->Media->RemovableMedia; \r
+      }\r
+\r
+      //\r
+      // Allocate pool for this load option\r
+      //\r
+      MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
+      if (NULL == MenuEntry) {\r
+        SafeFreePool (SimpleFsHandle);    \r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
+            \r
+      FileContext->Handle     = SimpleFsHandle[Index];\r
+      MenuEntry->OptionNumber = Index;\r
+      FileContext->FHandle    = EfiLibOpenRoot (FileContext->Handle);\r
+      if (!FileContext->FHandle) {\r
+        BOpt_DestroyMenuEntry (MenuEntry);\r
+        continue;\r
+      }\r
+\r
+      MenuEntry->HelpString = DevicePathToStr (DevicePathFromHandle (FileContext->Handle));\r
+      FileContext->Info = EfiLibFileSystemVolumeLabelInfo (FileContext->FHandle);\r
+      FileContext->FileName = EfiStrDuplicate (L"\\");\r
+      FileContext->DevicePath = FileDevicePath (\r
+                                  FileContext->Handle,\r
+                                  FileContext->FileName\r
+                                  );\r
+      FileContext->IsDir            = TRUE;\r
+      FileContext->IsRoot           = TRUE;\r
+      FileContext->IsRemovableMedia = FALSE;\r
+      FileContext->IsLoadFile       = FALSE;\r
+\r
+      //\r
+      // Get current file system's Volume Label\r
+      //\r
+      if (FileContext->Info == NULL) {\r
+        VolumeLabel = L"NO FILE SYSTEM INFO";\r
+      } else {\r
+        if (FileContext->Info->VolumeLabel == NULL) {\r
+          VolumeLabel = L"NULL VOLUME LABEL";\r
+        } else {\r
+          VolumeLabel = FileContext->Info->VolumeLabel;\r
+          if (*VolumeLabel == 0x0000) {\r
+            VolumeLabel = L"NO VOLUME LABEL";\r
+          }\r
+        }\r
+      }\r
+\r
+      TempStr                   = MenuEntry->HelpString;\r
+      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
+      ASSERT (MenuEntry->DisplayString != NULL);\r
+      UnicodeSPrint (\r
+        MenuEntry->DisplayString,\r
+        MAX_CHAR,\r
+        L"%s, [%s]",\r
+        VolumeLabel,\r
+        TempStr\r
+        );\r
+      OptionNumber++;\r
+      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);      \r
+    }\r
+  }\r
+\r
+  if (NoSimpleFsHandles != 0) {\r
+    SafeFreePool (SimpleFsHandle);\r
+  }\r
+  //\r
+  // Searching for handles that support Load File protocol\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiLoadFileProtocolGuid,\r
+                  NULL,\r
+                  &NoLoadFileHandles,\r
+                  &LoadFileHandle\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < NoLoadFileHandles; Index++) {\r
+      MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
+      if (NULL == MenuEntry) {\r
+        SafeFreePool (LoadFileHandle);    \r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      FileContext                   = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
+      FileContext->IsRemovableMedia = FALSE;\r
+      FileContext->IsLoadFile       = TRUE;\r
+      FileContext->Handle           = LoadFileHandle[Index];\r
+      FileContext->IsRoot           = TRUE;\r
+\r
+      FileContext->DevicePath = DevicePathFromHandle (FileContext->Handle);\r
+\r
+      MenuEntry->HelpString     = DevicePathToStr (FileContext->DevicePath);\r
+\r
+      TempStr                   = MenuEntry->HelpString;\r
+      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
+      ASSERT (MenuEntry->DisplayString != NULL);\r
+      UnicodeSPrint (\r
+        MenuEntry->DisplayString,\r
+        MAX_CHAR,\r
+        L"Load File [%s]",\r
+        TempStr\r
+        );\r
+\r
+      MenuEntry->OptionNumber = OptionNumber;\r
+      OptionNumber++;\r
+      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);\r
+    }\r
+  }\r
+\r
+  if (NoLoadFileHandles != 0) {\r
+    SafeFreePool (LoadFileHandle);\r
+  }\r
+\r
+  //\r
+  // Add Legacy Boot Option Support Here\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiLegacyBiosProtocolGuid,\r
+                  NULL,\r
+                  &LegacyBios\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+\r
+    for (Index = BBS_TYPE_FLOPPY; Index <= BBS_TYPE_EMBEDDED_NETWORK; Index++) {\r
+      MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
+      if (NULL == MenuEntry) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      FileContext                       = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
+\r
+      FileContext->IsRemovableMedia     = FALSE;\r
+      FileContext->IsLoadFile           = TRUE;\r
+      FileContext->IsBootLegacy         = TRUE;\r
+      DeviceType                        = (UINT16) Index;\r
+      BbsDevicePathNode.Header.Type     = BBS_DEVICE_PATH;\r
+      BbsDevicePathNode.Header.SubType  = BBS_BBS_DP;\r
+      SetDevicePathNodeLength (\r
+        &BbsDevicePathNode.Header,\r
+        sizeof (BBS_BBS_DEVICE_PATH)\r
+        );\r
+      BbsDevicePathNode.DeviceType  = DeviceType;\r
+      BbsDevicePathNode.StatusFlag  = 0;\r
+      BbsDevicePathNode.String[0]   = 0;\r
+      DevicePath = AppendDevicePathNode (\r
+                    EndDevicePath,\r
+                    (EFI_DEVICE_PATH_PROTOCOL *) &BbsDevicePathNode\r
+                    );\r
+\r
+      FileContext->DevicePath   = DevicePath;\r
+      MenuEntry->HelpString     = DevicePathToStr (FileContext->DevicePath);\r
+\r
+      TempStr                   = MenuEntry->HelpString;\r
+      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
+      ASSERT (MenuEntry->DisplayString != NULL);\r
+      UnicodeSPrint (\r
+        MenuEntry->DisplayString,\r
+        MAX_CHAR,\r
+        L"Boot Legacy [%s]",\r
+        TempStr\r
+        );\r
+      MenuEntry->OptionNumber = OptionNumber;\r
+      OptionNumber++;\r
+      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);\r
+    }\r
+  }\r
+  //\r
+  // Remember how many file system options are here\r
+  //\r
+  FsOptionMenu.MenuNumber = OptionNumber;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+BOpt_FreeMenu (\r
+  BM_MENU_OPTION        *FreeMenu\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Free resources allocated in Allocate Rountine\r
+\r
+Arguments:\r
+  FreeMenu        Menu to be freed\r
+\r
+Returns:\r
+  VOID\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY *MenuEntry;\r
+  while (!IsListEmpty (&FreeMenu->Head)) {\r
+    MenuEntry = CR (\r
+                  FreeMenu->Head.ForwardLink,\r
+                  BM_MENU_ENTRY,\r
+                  Link,\r
+                  BM_MENU_ENTRY_SIGNATURE\r
+                  );\r
+    RemoveEntryList (&MenuEntry->Link);\r
+    BOpt_DestroyMenuEntry (MenuEntry);\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+BOpt_FindFiles (\r
+  IN BMM_CALLBACK_DATA          *CallbackData,\r
+  IN BM_MENU_ENTRY              *MenuEntry\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Find files under current directory\r
+  All files and sub-directories in current directory\r
+  will be stored in DirectoryMenu for future use.\r
+\r
+Arguments:\r
+  FileOption   -- Pointer for Dir to explore\r
+\r
+Returns:\r
+  TRUE         -- Get files from current dir successfully\r
+  FALSE        -- Can't get files from current dir\r
+\r
+--*/\r
+{\r
+  EFI_FILE_HANDLE NewDir;\r
+  EFI_FILE_HANDLE Dir;\r
+  EFI_FILE_INFO   *DirInfo;\r
+  UINTN           BufferSize;\r
+  UINTN           DirBufferSize;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_FILE_CONTEXT *FileContext;\r
+  BM_FILE_CONTEXT *NewFileContext;\r
+  UINTN           Pass;\r
+  EFI_STATUS      Status;\r
+  UINTN           OptionNumber;\r
+\r
+  FileContext   = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;\r
+  Dir           = FileContext->FHandle;\r
+  OptionNumber  = 0;\r
+  //\r
+  // Open current directory to get files from it\r
+  //\r
+  Status = Dir->Open (\r
+                  Dir,\r
+                  &NewDir,\r
+                  FileContext->FileName,\r
+                  EFI_FILE_READ_ONLY,\r
+                  0\r
+                  );\r
+  if (!FileContext->IsRoot) {\r
+    Dir->Close (Dir);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  DirInfo = EfiLibFileInfo (NewDir);\r
+  if (!DirInfo) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (!(DirInfo->Attribute & EFI_FILE_DIRECTORY)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  FileContext->DevicePath = FileDevicePath (\r
+                              FileContext->Handle,\r
+                              FileContext->FileName\r
+                              );\r
+\r
+  DirBufferSize = sizeof (EFI_FILE_INFO) + 1024;\r
+  DirInfo       = AllocateZeroPool (DirBufferSize);\r
+  if (!DirInfo) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Get all files in current directory\r
+  // Pass 1 to get Directories\r
+  // Pass 2 to get files that are EFI images\r
+  //\r
+  for (Pass = 1; Pass <= 2; Pass++) {\r
+    NewDir->SetPosition (NewDir, 0);\r
+    for (;;) {\r
+      BufferSize  = DirBufferSize;\r
+      Status      = NewDir->Read (NewDir, &BufferSize, DirInfo);\r
+      if (EFI_ERROR (Status) || BufferSize == 0) {\r
+        break;\r
+      }\r
+\r
+      if ((DirInfo->Attribute & EFI_FILE_DIRECTORY && Pass == 2) ||\r
+          (!(DirInfo->Attribute & EFI_FILE_DIRECTORY) && Pass == 1)\r
+          ) {\r
+        //\r
+        // Pass 1 is for Directories\r
+        // Pass 2 is for file names\r
+        //\r
+        continue;\r
+      }\r
+\r
+      if (!(BOpt_IsEfiImageName (DirInfo->FileName) || DirInfo->Attribute & EFI_FILE_DIRECTORY)) {\r
+        //\r
+        // Slip file unless it is a directory entry or a .EFI file\r
+        //\r
+        continue;\r
+      }\r
+\r
+      NewMenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);\r
+      if (NULL == NewMenuEntry) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      NewFileContext          = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      NewFileContext->Handle  = FileContext->Handle;\r
+      NewFileContext->FileName = BOpt_AppendFileName (\r
+                                  FileContext->FileName,\r
+                                  DirInfo->FileName\r
+                                  );\r
+      NewFileContext->FHandle = NewDir;\r
+      NewFileContext->DevicePath = FileDevicePath (\r
+                                    NewFileContext->Handle,\r
+                                    NewFileContext->FileName\r
+                                    );\r
+      NewMenuEntry->HelpString = NULL;\r
+\r
+      MenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
+                                        CallbackData,\r
+                                        FileOptionStrDepository\r
+                                        );\r
+\r
+      NewFileContext->IsDir = (BOOLEAN) ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY);\r
+\r
+      if (NewFileContext->IsDir) {\r
+        BufferSize                  = StrLen (DirInfo->FileName) * 2 + 6;\r
+        NewMenuEntry->DisplayString = AllocateZeroPool (BufferSize);\r
+\r
+        UnicodeSPrint (\r
+          NewMenuEntry->DisplayString,\r
+          BufferSize,\r
+          L"<%s>",\r
+          DirInfo->FileName\r
+          );\r
+\r
+      } else {\r
+        NewMenuEntry->DisplayString = EfiStrDuplicate (DirInfo->FileName);\r
+      }\r
+\r
+      NewFileContext->IsRoot            = FALSE;\r
+      NewFileContext->IsLoadFile        = FALSE;\r
+      NewFileContext->IsRemovableMedia  = FALSE;\r
+\r
+      NewMenuEntry->OptionNumber        = OptionNumber;\r
+      OptionNumber++;\r
+      InsertTailList (&DirectoryMenu.Head, &NewMenuEntry->Link);\r
+    }\r
+  }\r
+\r
+  DirectoryMenu.MenuNumber = OptionNumber;\r
+  SafeFreePool (DirInfo);\r
+  return TRUE;\r
+}\r
+\r
+EFI_STATUS\r
+BOpt_GetLegacyOptions (\r
+  VOID\r
+  )\r
+/*++\r
+Routine Description:\r
+  \r
+  Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().\r
+    \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  The device info of legacy device.\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_LEGACY_DEVICE_CONTEXT  *NewLegacyDevContext;\r
+  EFI_STATUS                Status;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  UINT16                    HddCount;\r
+  HDD_INFO                  *HddInfo;\r
+  UINT16                    BbsCount;\r
+  BBS_TABLE                 *BbsTable;\r
+  UINTN                     Index;\r
+  CHAR16                    DescString[100];\r
+  UINTN                     FDNum;\r
+  UINTN                     HDNum;\r
+  UINTN                     CDNum;\r
+  UINTN                     NETNum;\r
+  UINTN                     BEVNum;\r
+\r
+  NewMenuEntry  = NULL;\r
+  HddInfo       = NULL;\r
+  BbsTable      = NULL;\r
+  BbsCount      = 0;\r
+\r
+  //\r
+  // Initialize Bbs Table Context from BBS info data\r
+  //\r
+  InitializeListHead (&LegacyFDMenu.Head);\r
+  InitializeListHead (&LegacyHDMenu.Head);\r
+  InitializeListHead (&LegacyCDMenu.Head);\r
+  InitializeListHead (&LegacyNETMenu.Head);\r
+  InitializeListHead (&LegacyBEVMenu.Head);\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiLegacyBiosProtocolGuid,\r
+                  NULL,\r
+                  &LegacyBios\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = LegacyBios->GetBbsInfo (\r
+                          LegacyBios,\r
+                          &HddCount,\r
+                          &HddInfo,\r
+                          &BbsCount,\r
+                          &BbsTable\r
+                          );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  FDNum   = 0;\r
+  HDNum   = 0;\r
+  CDNum   = 0;\r
+  NETNum  = 0;\r
+  BEVNum  = 0;\r
+\r
+  for (Index = 0; Index < BbsCount; Index++) {\r
+    if ((BBS_IGNORE_ENTRY == BbsTable[Index].BootPriority) ||\r
+        (BBS_DO_NOT_BOOT_FROM == BbsTable[Index].BootPriority) ||\r
+        (BBS_LOWEST_PRIORITY == BbsTable[Index].BootPriority)\r
+        ) {\r
+      continue;\r
+    }\r
+\r
+    NewMenuEntry = BOpt_CreateMenuEntry (BM_LEGACY_DEV_CONTEXT_SELECT);\r
+    if (NULL == NewMenuEntry) {\r
+      break;\r
+    }\r
+\r
+    NewLegacyDevContext           = (BM_LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext;\r
+    NewLegacyDevContext->BbsTable = &BbsTable[Index];\r
+    NewLegacyDevContext->Index    = Index;\r
+    NewLegacyDevContext->BbsCount = BbsCount;\r
+    BdsBuildLegacyDevNameString (\r
+      &BbsTable[Index],\r
+      Index,\r
+      sizeof (DescString),\r
+      DescString\r
+      );\r
+    NewLegacyDevContext->Description = AllocateZeroPool (StrSize (DescString));\r
+    if (NULL == NewLegacyDevContext->Description) {\r
+      break;\r
+    }\r
+\r
+    CopyMem (NewLegacyDevContext->Description, DescString, StrSize (DescString));\r
+    NewMenuEntry->DisplayString = NewLegacyDevContext->Description;\r
+    NewMenuEntry->HelpString    = NULL;\r
+\r
+    switch (BbsTable[Index].DeviceType) {\r
+    case BBS_FLOPPY:\r
+      InsertTailList (&LegacyFDMenu.Head, &NewMenuEntry->Link);\r
+      FDNum++;\r
+      break;\r
+\r
+    case BBS_HARDDISK:\r
+      InsertTailList (&LegacyHDMenu.Head, &NewMenuEntry->Link);\r
+      HDNum++;\r
+      break;\r
+\r
+    case BBS_CDROM:\r
+      InsertTailList (&LegacyCDMenu.Head, &NewMenuEntry->Link);\r
+      CDNum++;\r
+      break;\r
+\r
+    case BBS_EMBED_NETWORK:\r
+      InsertTailList (&LegacyNETMenu.Head, &NewMenuEntry->Link);\r
+      NETNum++;\r
+      break;\r
+\r
+    case BBS_BEV_DEVICE:\r
+      InsertTailList (&LegacyBEVMenu.Head, &NewMenuEntry->Link);\r
+      BEVNum++;\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (Index != BbsCount) {\r
+    BOpt_FreeLegacyOptions ();\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  LegacyFDMenu.MenuNumber   = FDNum;\r
+  LegacyHDMenu.MenuNumber   = HDNum;\r
+  LegacyCDMenu.MenuNumber   = CDNum;\r
+  LegacyNETMenu.MenuNumber  = NETNum;\r
+  LegacyBEVMenu.MenuNumber  = BEVNum;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+BOpt_FreeLegacyOptions (\r
+  VOID\r
+  )\r
+{\r
+  BOpt_FreeMenu (&LegacyFDMenu);\r
+  BOpt_FreeMenu (&LegacyHDMenu);\r
+  BOpt_FreeMenu (&LegacyCDMenu);\r
+  BOpt_FreeMenu (&LegacyNETMenu);\r
+  BOpt_FreeMenu (&LegacyBEVMenu);\r
+}\r
+\r
+EFI_STATUS\r
+BOpt_GetBootOptions (\r
+  IN  BMM_CALLBACK_DATA         *CallbackData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Build the BootOptionMenu according to BootOrder Variable.\r
+  This Routine will access the Boot#### to get EFI_LOAD_OPTION \r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  The number of the Var Boot####\r
+  \r
+--*/\r
+{\r
+  UINTN                     Index;\r
+  UINT16                    BootString[10];\r
+  UINT8                     *LoadOptionFromVar;\r
+  UINT8                     *LoadOption;\r
+  UINTN                     BootOptionSize;\r
+  BOOLEAN                   BootNextFlag;\r
+  UINT16                    *BootOrderList;\r
+  UINTN                     BootOrderListSize;\r
+  UINT16                    *BootNext;\r
+  UINTN                     BootNextSize;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_LOAD_CONTEXT           *NewLoadContext;\r
+  UINT8                     *LoadOptionPtr;\r
+  UINTN                     StringSize;\r
+  UINTN                     OptionalDataSize;\r
+  UINT8                     *LoadOptionEnd;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINTN                     MenuCount;\r
+  UINT8                     *Ptr;\r
+\r
+  MenuCount         = 0;\r
+  BootOrderListSize = 0;\r
+  BootNextSize      = 0;\r
+  BootOrderList     = NULL;\r
+  BootNext          = NULL;\r
+  LoadOptionFromVar = NULL;\r
+  BOpt_FreeMenu (&BootOptionMenu);\r
+  InitializeListHead (&BootOptionMenu.Head);\r
+\r
+  //\r
+  // Get the BootOrder from the Var\r
+  //\r
+  BootOrderList = BdsLibGetVariableAndSize (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    &BootOrderListSize\r
+                    );\r
+\r
+  //\r
+  // Get the BootNext from the Var\r
+  //\r
+  BootNext = BdsLibGetVariableAndSize (\r
+              L"BootNext",\r
+              &gEfiGlobalVariableGuid,\r
+              &BootNextSize\r
+              );\r
+\r
+  if (BootNext) {\r
+    if (BootNextSize != sizeof (UINT16)) {\r
+      SafeFreePool (BootNext);\r
+      BootNext = NULL;\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {\r
+    UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", BootOrderList[Index]);\r
+    //\r
+    //  Get all loadoptions from the VAR\r
+    //\r
+    LoadOptionFromVar = BdsLibGetVariableAndSize (\r
+                          BootString,\r
+                          &gEfiGlobalVariableGuid,\r
+                          &BootOptionSize\r
+                          );\r
+    if (!LoadOptionFromVar) {\r
+      continue;\r
+    }\r
+\r
+    LoadOption = AllocateZeroPool (BootOptionSize);\r
+    if (!LoadOption) {\r
+      continue;\r
+    }\r
+\r
+    CopyMem (LoadOption, LoadOptionFromVar, BootOptionSize);\r
+    SafeFreePool (LoadOptionFromVar);\r
+\r
+    if (BootNext) {\r
+      BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);\r
+    } else {\r
+      BootNextFlag = FALSE;\r
+    }\r
+\r
+    if (0 == (*((UINT32 *) LoadOption) & LOAD_OPTION_ACTIVE)) {\r
+      SafeFreePool (LoadOption);\r
+      continue;\r
+    }\r
+    //\r
+    // BUGBUG: could not return EFI_OUT_OF_RESOURCES here directly.\r
+    // the buffer allocated already should be freed before returning.\r
+    //\r
+    NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+    LoadOptionPtr                       = LoadOption;\r
+    LoadOptionEnd                       = LoadOption + BootOptionSize;\r
+\r
+    NewMenuEntry->OptionNumber          = BootOrderList[Index];\r
+    NewLoadContext->LoadOptionModified  = FALSE;\r
+    NewLoadContext->Deleted             = FALSE;\r
+    NewLoadContext->IsBootNext          = BootNextFlag;\r
+\r
+    //\r
+    // Is a Legacy Device?\r
+    //\r
+    Ptr = (UINT8 *) LoadOption;\r
+\r
+    //\r
+    // Attribute = *(UINT32 *)Ptr;\r
+    //\r
+    Ptr += sizeof (UINT32);\r
+\r
+    //\r
+    // FilePathSize = *(UINT16 *)Ptr;\r
+    //\r
+    Ptr += sizeof (UINT16);\r
+\r
+    //\r
+    // Description = (CHAR16 *)Ptr;\r
+    //\r
+    Ptr += StrSize ((CHAR16 *) Ptr);\r
+\r
+    //\r
+    // Now Ptr point to Device Path\r
+    //\r
+    DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+    if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {\r
+      NewLoadContext->IsLegacy = TRUE;\r
+    } else {\r
+      NewLoadContext->IsLegacy = FALSE;\r
+    }\r
+    //\r
+    // LoadOption is a pointer type of UINT8\r
+    // for easy use with following LOAD_OPTION\r
+    // embedded in this struct\r
+    //\r
+    NewLoadContext->LoadOption      = LoadOption;\r
+    NewLoadContext->LoadOptionSize  = BootOptionSize;\r
+\r
+    NewLoadContext->Attributes      = *(UINT32 *) LoadOptionPtr;\r
+    NewLoadContext->IsActive        = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);\r
+\r
+    NewLoadContext->ForceReconnect  = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
+\r
+    LoadOptionPtr += sizeof (UINT32);\r
+\r
+    NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;\r
+    LoadOptionPtr += sizeof (UINT16);\r
+\r
+    StringSize                  = StrSize ((UINT16 *) LoadOptionPtr);\r
+    NewLoadContext->Description = AllocateZeroPool (StringSize);\r
+    ASSERT (NewLoadContext->Description != NULL);\r
+    CopyMem (\r
+      NewLoadContext->Description,\r
+      (UINT16 *) LoadOptionPtr,\r
+      StringSize\r
+      );\r
+    NewMenuEntry->DisplayString = NewLoadContext->Description;\r
+\r
+    LoadOptionPtr += StringSize;\r
+\r
+    NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);\r
+    ASSERT (NewLoadContext->FilePathList != NULL);\r
+    CopyMem (\r
+      NewLoadContext->FilePathList,\r
+      (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,\r
+      NewLoadContext->FilePathListLength\r
+      );\r
+\r
+    NewMenuEntry->HelpString = DevicePathToStr (NewLoadContext->FilePathList);\r
+    NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
+                                        CallbackData,\r
+                                        BootOptionStrDepository\r
+                                        );\r
+    NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
+                                      CallbackData,\r
+                                      BootOptionHelpStrDepository\r
+                                      );\r
+    LoadOptionPtr += NewLoadContext->FilePathListLength;\r
+\r
+    if (LoadOptionPtr < LoadOptionEnd) {\r
+      OptionalDataSize = BootOptionSize -\r
+        sizeof (UINT32) -\r
+        sizeof (UINT16) -\r
+        StringSize -\r
+        NewLoadContext->FilePathListLength;\r
+\r
+      NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);\r
+      ASSERT (NewLoadContext->OptionalData != NULL);\r
+      CopyMem (\r
+        NewLoadContext->OptionalData,\r
+        LoadOptionPtr,\r
+        OptionalDataSize\r
+        );\r
+\r
+      NewLoadContext->OptionalDataSize = OptionalDataSize;\r
+    }\r
+\r
+    InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
+    MenuCount++;\r
+  }\r
+\r
+  SafeFreePool (BootNext);\r
+  SafeFreePool (BootOrderList);\r
+  BootOptionMenu.MenuNumber = MenuCount;\r
+  return MenuCount;\r
+}\r
+\r
+CHAR16 *\r
+BdsStrCpy (\r
+  OUT     CHAR16                    *Destination,\r
+  IN      CONST CHAR16              *Source\r
+  )\r
+{\r
+  CHAR16                            *ReturnValue;\r
+\r
+  //\r
+  // Destination cannot be NULL\r
+  //\r
+  ASSERT (Destination != NULL);\r
+\r
+  ReturnValue = Destination;\r
+  while (*Source) {\r
+    *(Destination++) = *(Source++);\r
+  }\r
+  *Destination = 0;\r
+  return ReturnValue;\r
+}\r
+\r
+CHAR16 *\r
+BOpt_AppendFileName (\r
+  IN  CHAR16  *Str1,\r
+  IN  CHAR16  *Str2\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Append file name to existing file name.\r
+\r
+Arguments:\r
+  Str1  -   existing file name\r
+  Str2  -   file name to be appended\r
+\r
+Returns:\r
+  Allocate a new string to hold the appended result.\r
+  Caller is responsible to free the returned string.\r
+\r
+--*/\r
+{\r
+  UINTN   Size1;\r
+  UINTN   Size2;\r
+  CHAR16  *Str;\r
+  CHAR16  *Ptr;\r
+  CHAR16  *LastSlash;\r
+\r
+  Size1 = StrSize (Str1);\r
+  Size2 = StrSize (Str2);\r
+  Str   = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
+  ASSERT (Str != NULL);\r
+\r
+  StrCat (Str, Str1);\r
+  if (!((*Str == '\\') && (*(Str + 1) == 0))) {\r
+    StrCat (Str, L"\\");\r
+  }\r
+\r
+  StrCat (Str, Str2);\r
+\r
+  Ptr       = Str;\r
+  LastSlash = Str;\r
+  while (*Ptr != 0) {\r
+    if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '.' && *(Ptr + 3) != 0) {\r
+      //\r
+      // Convert \Name\..\ to \\r
+      // DO NOT convert the .. if it is at the end of the string. This will\r
+      // break the .. behavior in changing directories.\r
+      //\r
+      BdsStrCpy (LastSlash, Ptr + 3);\r
+      Ptr = LastSlash;\r
+    } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
+      //\r
+      // Convert a \.\ to a \\r
+      //\r
+      BdsStrCpy (Ptr, Ptr + 2);\r
+      Ptr = LastSlash;\r
+    } else if (*Ptr == '\\') {\r
+      LastSlash = Ptr;\r
+    }\r
+\r
+    Ptr++;\r
+  }\r
+\r
+  return Str;\r
+}\r
+\r
+BOOLEAN\r
+BOpt_IsEfiImageName (\r
+  IN UINT16  *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Check whether current FileName point to a valid \r
+  Efi Image File.\r
+\r
+Arguments:\r
+  FileName  -   File need to be checked.\r
+\r
+Returns:\r
+  TRUE  -   Is Efi Image\r
+  FALSE -   Not a valid Efi Image\r
+  \r
+--*/\r
+{\r
+  //\r
+  // Search for ".efi" extension\r
+  //\r
+  while (*FileName) {\r
+    if (FileName[0] == '.') {\r
+      if (FileName[1] == 'e' || FileName[1] == 'E') {\r
+        if (FileName[2] == 'f' || FileName[2] == 'F') {\r
+          if (FileName[3] == 'i' || FileName[3] == 'I') {\r
+            return TRUE;\r
+          } else if (FileName[3] == 0x0000) {\r
+            return FALSE;\r
+          }\r
+        } else if (FileName[2] == 0x0000) {\r
+          return FALSE;\r
+        }\r
+      } else if (FileName[1] == 0x0000) {\r
+        return FALSE;\r
+      }\r
+    }\r
+\r
+    FileName += 1;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+IsEfiAppReadFromFile (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINTN   *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_FILE_HANDLE   File;\r
+    \r
+  File = (EFI_FILE_HANDLE)FileHandle;\r
+  Status = File->SetPosition (File, FileOffset);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return File->Read (File, ReadSize, Buffer);\r
+}\r
+\r
+\r
+\r
+BOOLEAN\r
+BOpt_IsEfiApp (\r
+  IN EFI_FILE_HANDLE Dir,\r
+  IN UINT16          *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check whether current FileName point to a valid Efi Application\r
+  \r
+Arguments:\r
+  Dir       -   Pointer to current Directory\r
+  FileName  -   Pointer to current File name.\r
+  \r
+Returns:\r
+  TRUE      -   Is a valid Efi Application\r
+  FALSE     -   not a valid Efi Application\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT          ImageContext;\r
+  EFI_FILE_HANDLE                       File;\r
+\r
+  Status = Dir->Open (Dir, &File, FileName, EFI_FILE_MODE_READ, 0);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  ZeroMem (&ImageContext, sizeof (ImageContext));\r
+  ImageContext.Handle    = (VOID *)File;\r
+  ImageContext.ImageRead = IsEfiAppReadFromFile;\r
+\r
+  Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
+  File->Close (File);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+ }\r
+\r
+\r
+EFI_STATUS\r
+BOpt_FindDrivers (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description\r
+  Find drivers that will be added as Driver#### variables from handles\r
+  in current system environment\r
+  All valid handles in the system except those consume SimpleFs, LoadFile\r
+  are stored in DriverMenu for future use.\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  Others\r
+\r
+--*/\r
+{\r
+  UINTN                           NoDevicePathHandles;\r
+  EFI_HANDLE                      *DevicePathHandle;\r
+  UINTN                           Index;\r
+  EFI_STATUS                      Status;\r
+  BM_MENU_ENTRY                   *NewMenuEntry;\r
+  BM_HANDLE_CONTEXT               *NewHandleContext;\r
+  EFI_HANDLE                      CurHandle;\r
+  UINTN                           OptionNumber;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;\r
+  EFI_LOAD_FILE_PROTOCOL          *LoadFile;\r
+\r
+  SimpleFs  = NULL;\r
+  LoadFile  = NULL;\r
+\r
+  InitializeListHead (&DriverMenu.Head);\r
+\r
+  //\r
+  // At first, get all handles that support Device Path\r
+  // protocol which is the basic requirement for\r
+  // Driver####\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  NULL,\r
+                  &NoDevicePathHandles,\r
+                  &DevicePathHandle\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  OptionNumber = 0;\r
+  for (Index = 0; Index < NoDevicePathHandles; Index++) {\r
+    CurHandle = DevicePathHandle[Index];\r
+\r
+    //\r
+    //  Check whether this handle support\r
+    //  driver binding\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                    CurHandle,\r
+                    &gEfiSimpleFileSystemProtocolGuid,\r
+                    &SimpleFs\r
+                    );\r
+    if (Status == EFI_SUCCESS) {\r
+      continue;\r
+    }\r
+\r
+    Status = gBS->HandleProtocol (\r
+                    CurHandle,\r
+                    &gEfiLoadFileProtocolGuid,\r
+                    &LoadFile\r
+                    );\r
+    if (Status == EFI_SUCCESS) {\r
+      continue;\r
+    }\r
+\r
+    NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    NewHandleContext              = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+    NewHandleContext->Handle      = CurHandle;\r
+    NewHandleContext->DevicePath  = DevicePathFromHandle (CurHandle);\r
+    NewMenuEntry->DisplayString = DevicePathToStr (NewHandleContext->DevicePath);\r
+    NewMenuEntry->HelpString    = NULL;\r
+    NewMenuEntry->OptionNumber  = OptionNumber;\r
+    OptionNumber++;\r
+    InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);\r
+\r
+  }\r
+\r
+  DriverMenu.MenuNumber = OptionNumber;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINT16\r
+BOpt_GetBootOptionNumber (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the Option Number that does not used \r
+  \r
+Arguments:\r
+\r
+Returns:\r
+  The Option Number\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        *BootOrderList;\r
+  UINTN         BootOrderListSize;\r
+  UINT16        Number;\r
+  UINTN         Index;\r
+  UINTN         Index2;\r
+  BOOLEAN       Found;\r
+  CHAR16        StrTemp[100];\r
+  UINT16        *OptionBuffer;\r
+  UINTN         OptionSize;\r
+\r
+  BootOrderListSize = 0;\r
+  BootOrderList     = NULL;\r
+\r
+  BootOrderList = BdsLibGetVariableAndSize (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    &BootOrderListSize\r
+                    );\r
+  if (BootOrderList) {\r
+    //\r
+    // already have Boot####\r
+    //\r
+    // AlreadyBootNumbers = BootOrderListSize / sizeof(UINT16);\r
+    //\r
+    for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {\r
+      Found = TRUE;\r
+      for (Index2 = 0; Index2 < BootOptionMenu.MenuNumber; Index2++) {\r
+        NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index2);\r
+        if (Index == NewMenuEntry->OptionNumber) {\r
+          Found = FALSE;\r
+          break;\r
+        }\r
+      }\r
+\r
+      if (Found) {\r
+          UnicodeSPrint (StrTemp, 100, L"Boot%04x", Index);\r
+          DEBUG((EFI_D_ERROR,"INdex= %s\n", StrTemp));\r
+       OptionBuffer = BdsLibGetVariableAndSize (\r
+                StrTemp,\r
+                &gEfiGlobalVariableGuid,\r
+                &OptionSize\r
+                );\r
+      if (NULL == OptionBuffer) \r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // end for Index\r
+    //\r
+    Number = (UINT16) Index;\r
+  } else {\r
+    //\r
+    // No Boot####\r
+    //\r
+    Number = 0;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+UINT16\r
+BOpt_GetDriverOptionNumber (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the Option Number that does not used \r
+  \r
+Arguments:\r
+\r
+Returns:\r
+  The Option Number\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        *DriverOrderList;\r
+  UINTN         DriverOrderListSize;\r
+  UINT16        Number;\r
+  UINTN         Index;\r
+  UINTN         Index2;\r
+  BOOLEAN       Found;\r
+\r
+  DriverOrderListSize = 0;\r
+  DriverOrderList     = NULL;\r
+\r
+  DriverOrderList = BdsLibGetVariableAndSize (\r
+                      L"DriverOrder",\r
+                      &gEfiGlobalVariableGuid,\r
+                      &DriverOrderListSize\r
+                      );\r
+  if (DriverOrderList) {\r
+    //\r
+    // already have Driver####\r
+    //\r
+    // AlreadyDriverNumbers = DriverOrderListSize / sizeof(UINT16);\r
+    //\r
+    for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {\r
+      Found = TRUE;\r
+      for (Index2 = 0; Index2 < DriverOptionMenu.MenuNumber; Index2++) {\r
+        NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index2);\r
+        if (Index == NewMenuEntry->OptionNumber) {\r
+          Found = FALSE;\r
+          break;\r
+        }\r
+      }\r
+\r
+      if (Found) {\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // end for Index\r
+    //\r
+    Number = (UINT16) Index;\r
+  } else {\r
+    //\r
+    // No Driver####\r
+    //\r
+    Number = 0;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+EFI_STATUS\r
+BOpt_GetDriverOptions (\r
+  IN  BMM_CALLBACK_DATA         *CallbackData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Build up all DriverOptionMenu\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+  The Option Number\r
+  \r
+--*/\r
+{\r
+  UINTN           Index;\r
+  UINT16          DriverString[12];\r
+  UINT8           *LoadOptionFromVar;\r
+  UINT8           *LoadOption;\r
+  UINTN           DriverOptionSize;\r
+\r
+  UINT16          *DriverOrderList;\r
+  UINTN           DriverOrderListSize;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+  UINT8           *LoadOptionPtr;\r
+  UINTN           StringSize;\r
+  UINTN           OptionalDataSize;\r
+  UINT8           *LoadOptionEnd;\r
+\r
+  DriverOrderListSize = 0;\r
+  DriverOrderList     = NULL;\r
+  DriverOptionSize    = 0;\r
+  LoadOptionFromVar   = NULL;\r
+  BOpt_FreeMenu (&DriverOptionMenu);\r
+  InitializeListHead (&DriverOptionMenu.Head);\r
+  //\r
+  // Get the DriverOrder from the Var\r
+  //\r
+  DriverOrderList = BdsLibGetVariableAndSize (\r
+                      L"DriverOrder",\r
+                      &gEfiGlobalVariableGuid,\r
+                      &DriverOrderListSize\r
+                      );\r
+\r
+  for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {\r
+    UnicodeSPrint (\r
+      DriverString,\r
+      sizeof (DriverString),\r
+      L"Driver%04x",\r
+      DriverOrderList[Index]\r
+      );\r
+    //\r
+    //  Get all loadoptions from the VAR\r
+    //\r
+    LoadOptionFromVar = BdsLibGetVariableAndSize (\r
+                          DriverString,\r
+                          &gEfiGlobalVariableGuid,\r
+                          &DriverOptionSize\r
+                          );\r
+    if (!LoadOptionFromVar) {\r
+      continue;\r
+    }\r
+\r
+    LoadOption = AllocateZeroPool (DriverOptionSize);\r
+    if (!LoadOption) {\r
+      continue;\r
+    }\r
+\r
+    CopyMem (LoadOption, LoadOptionFromVar, DriverOptionSize);\r
+    SafeFreePool (LoadOptionFromVar);\r
+\r
+    NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+    LoadOptionPtr                       = LoadOption;\r
+    LoadOptionEnd                       = LoadOption + DriverOptionSize;\r
+    NewMenuEntry->OptionNumber          = DriverOrderList[Index];\r
+    NewLoadContext->LoadOptionModified  = FALSE;\r
+    NewLoadContext->Deleted             = FALSE;\r
+    NewLoadContext->IsLegacy            = FALSE;\r
+\r
+    //\r
+    // LoadOption is a pointer type of UINT8\r
+    // for easy use with following LOAD_OPTION\r
+    // embedded in this struct\r
+    //\r
+    NewLoadContext->LoadOption      = LoadOption;\r
+    NewLoadContext->LoadOptionSize  = DriverOptionSize;\r
+\r
+    NewLoadContext->Attributes      = *(UINT32 *) LoadOptionPtr;\r
+    NewLoadContext->IsActive        = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);\r
+\r
+    NewLoadContext->ForceReconnect  = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
+\r
+    LoadOptionPtr += sizeof (UINT32);\r
+\r
+    NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;\r
+    LoadOptionPtr += sizeof (UINT16);\r
+\r
+    StringSize                  = StrSize ((UINT16 *) LoadOptionPtr);\r
+    NewLoadContext->Description = AllocateZeroPool (StringSize);\r
+    ASSERT (NewLoadContext->Description != NULL);\r
+    CopyMem (\r
+      NewLoadContext->Description,\r
+      (UINT16 *) LoadOptionPtr,\r
+      StringSize\r
+      );\r
+    NewMenuEntry->DisplayString = NewLoadContext->Description;\r
+\r
+    LoadOptionPtr += StringSize;\r
+\r
+    NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);\r
+    ASSERT (NewLoadContext->FilePathList != NULL);\r
+    CopyMem (\r
+      NewLoadContext->FilePathList,\r
+      (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,\r
+      NewLoadContext->FilePathListLength\r
+      );\r
+\r
+    NewMenuEntry->HelpString = DevicePathToStr (NewLoadContext->FilePathList);\r
+    NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
+                                        CallbackData,\r
+                                        DriverOptionStrDepository\r
+                                        );\r
+    NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
+                                      CallbackData,\r
+                                      DriverOptionHelpStrDepository\r
+                                      );\r
+    LoadOptionPtr += NewLoadContext->FilePathListLength;\r
+\r
+    if (LoadOptionPtr < LoadOptionEnd) {\r
+      OptionalDataSize = DriverOptionSize -\r
+        sizeof (UINT32) -\r
+        sizeof (UINT16) -\r
+        StringSize -\r
+        NewLoadContext->FilePathListLength;\r
+\r
+      NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);\r
+      ASSERT (NewLoadContext->OptionalData != NULL);\r
+      CopyMem (\r
+        NewLoadContext->OptionalData,\r
+        LoadOptionPtr,\r
+        OptionalDataSize\r
+        );\r
+\r
+      NewLoadContext->OptionalDataSize = OptionalDataSize;\r
+    }\r
+\r
+    InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
+\r
+  }\r
+\r
+  SafeFreePool (DriverOrderList);\r
+  DriverOptionMenu.MenuNumber = Index;\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+VOID\r
+SafeFreePool (\r
+  IN VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Wrap original FreePool gBS call\r
+  in order to decrease code length\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  if (Buffer != NULL) {\r
+    gBS->FreePool (Buffer);\r
+    Buffer = NULL;\r
+  }\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/ConsoleOption.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/ConsoleOption.c
new file mode 100644 (file)
index 0000000..c77fa0a
--- /dev/null
@@ -0,0 +1,840 @@
+/*++\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    ConsoleOption.c\r
+    \r
+Abstract:\r
+\r
+    handles console redirection from boot manager\r
+\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "BootMaint.h"\r
+\r
+EFI_DEVICE_PATH_PROTOCOL  *\r
+DevicePathInstanceDup (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  );\r
+\r
+EFI_STATUS\r
+UpdateComAttributeFromVariable (\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+ChangeTerminalDevicePath (\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
+  BOOLEAN                   ChangeTerminal\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Node1;\r
+  ACPI_HID_DEVICE_PATH      *Acpi;\r
+  UART_DEVICE_PATH          *Uart;\r
+  UART_DEVICE_PATH          *Uart1;\r
+  UINTN                     Com;\r
+  UINT32                    Match;\r
+  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+\r
+  Match = EISA_PNP_ID (0x0501);\r
+  Node  = DevicePath;\r
+  Node  = NextDevicePathNode (Node);\r
+  Com   = 0;\r
+  while (!IsDevicePathEnd (Node)) {\r
+    if ((DevicePathType (Node) == ACPI_DEVICE_PATH) && (DevicePathSubType (Node) == ACPI_DP)) {\r
+      Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
+      if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {\r
+        CopyMem (&Com, &Acpi->UID, sizeof (UINT32));\r
+      }\r
+    }\r
+\r
+    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Com);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
+      Uart = (UART_DEVICE_PATH *) Node;\r
+      CopyMem (\r
+        &Uart->BaudRate,\r
+        &NewTerminalContext->BaudRate,\r
+        sizeof (UINT64)\r
+        );\r
+\r
+      CopyMem (\r
+        &Uart->DataBits,\r
+        &NewTerminalContext->DataBits,\r
+        sizeof (UINT8)\r
+        );\r
+\r
+      CopyMem (\r
+        &Uart->Parity,\r
+        &NewTerminalContext->Parity,\r
+        sizeof (UINT8)\r
+        );\r
+\r
+      CopyMem (\r
+        &Uart->StopBits,\r
+        &NewTerminalContext->StopBits,\r
+        sizeof (UINT8)\r
+        );\r
+      //\r
+      // Change the device path in the ComPort\r
+      //\r
+      if (ChangeTerminal) {\r
+        Node1 = NewTerminalContext->DevicePath;\r
+        Node1 = NextDevicePathNode (Node1);\r
+        while (!IsDevicePathEnd (Node1)) {\r
+          if ((DevicePathType (Node1) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node1) == MSG_UART_DP)) {\r
+            Uart1 = (UART_DEVICE_PATH *) Node1;\r
+            CopyMem (\r
+              &Uart1->BaudRate,\r
+              &NewTerminalContext->BaudRate,\r
+              sizeof (UINT64)\r
+              );\r
+\r
+            CopyMem (\r
+              &Uart1->DataBits,\r
+              &NewTerminalContext->DataBits,\r
+              sizeof (UINT8)\r
+              );\r
+\r
+            CopyMem (\r
+              &Uart1->Parity,\r
+              &NewTerminalContext->Parity,\r
+              sizeof (UINT8)\r
+              );\r
+\r
+            CopyMem (\r
+              &Uart1->StopBits,\r
+              &NewTerminalContext->StopBits,\r
+              sizeof (UINT8)\r
+              );\r
+            break;\r
+          }\r
+          //\r
+          // end if\r
+          //\r
+          Node1 = NextDevicePathNode (Node1);\r
+        }\r
+        //\r
+        // end while\r
+        //\r
+        break;\r
+      }\r
+    }\r
+\r
+    Node = NextDevicePathNode (Node);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+VOID\r
+ChangeVariableDevicePath (\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
+  ACPI_HID_DEVICE_PATH      *Acpi;\r
+  UART_DEVICE_PATH          *Uart;\r
+  UINTN                     Com;\r
+  UINT32                    Match;\r
+  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+\r
+  Match = EISA_PNP_ID (0x0501);\r
+  Node  = DevicePath;\r
+  Node  = NextDevicePathNode (Node);\r
+  Com   = 0;\r
+  while (!IsDevicePathEnd (Node)) {\r
+    if ((DevicePathType (Node) == ACPI_DEVICE_PATH) && (DevicePathSubType (Node) == ACPI_DP)) {\r
+      Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
+      if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {\r
+        CopyMem (&Com, &Acpi->UID, sizeof (UINT32));\r
+      }\r
+    }\r
+\r
+    if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
+      NewMenuEntry = BOpt_GetMenuEntry (\r
+                      &TerminalMenu,\r
+                      Com\r
+                      );\r
+      NewTerminalContext  = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      Uart                = (UART_DEVICE_PATH *) Node;\r
+      CopyMem (\r
+        &Uart->BaudRate,\r
+        &NewTerminalContext->BaudRate,\r
+        sizeof (UINT64)\r
+        );\r
+\r
+      CopyMem (\r
+        &Uart->DataBits,\r
+        &NewTerminalContext->DataBits,\r
+        sizeof (UINT8)\r
+        );\r
+\r
+      CopyMem (\r
+        &Uart->Parity,\r
+        &NewTerminalContext->Parity,\r
+        sizeof (UINT8)\r
+        );\r
+\r
+      CopyMem (\r
+        &Uart->StopBits,\r
+        &NewTerminalContext->StopBits,\r
+        sizeof (UINT8)\r
+        );\r
+    }\r
+\r
+    Node = NextDevicePathNode (Node);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+BOOLEAN\r
+IsTerminalDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+  OUT TYPE_OF_TERMINAL         *Termi,\r
+  OUT UINTN                    *Com\r
+  );\r
+\r
+EFI_STATUS\r
+LocateSerialIo (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Build a list containing all serial devices \r
+  \r
+Arguments:\r
+  \r
+Returns:\r
+  \r
+--*/\r
+{\r
+  UINT8                     *Ptr;\r
+  UINTN                     Index;\r
+  UINTN                     Index2;\r
+  UINTN                     NoHandles;\r
+  EFI_HANDLE                *Handles;\r
+  EFI_STATUS                Status;\r
+  ACPI_HID_DEVICE_PATH      *Acpi;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINT32                    Match;\r
+  EFI_SERIAL_IO_PROTOCOL    *SerialIo;\r
+  EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  VENDOR_DEVICE_PATH        Vendor;\r
+  //\r
+  // Get all handles that have SerialIo protocol installed\r
+  //\r
+  InitializeListHead (&TerminalMenu.Head);\r
+  TerminalMenu.MenuNumber = 0;\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiSerialIoProtocolGuid,\r
+                  NULL,\r
+                  &NoHandles,\r
+                  &Handles\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // No serial ports present\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  for (Index = 0; Index < NoHandles; Index++) {\r
+    //\r
+    // Check to see whether the handle has DevicePath Protocol installed\r
+    //\r
+    gBS->HandleProtocol (\r
+          Handles[Index],\r
+          &gEfiDevicePathProtocolGuid,\r
+          &DevicePath\r
+          );\r
+    Ptr = (UINT8 *) DevicePath;\r
+    while (*Ptr != END_DEVICE_PATH_TYPE) {\r
+      Ptr++;\r
+    }\r
+\r
+    Ptr   = Ptr - sizeof (UART_DEVICE_PATH) - sizeof (ACPI_HID_DEVICE_PATH);\r
+    Acpi  = (ACPI_HID_DEVICE_PATH *) Ptr;\r
+    Match = EISA_PNP_ID (0x0501);\r
+\r
+    if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {\r
+      NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);\r
+      if (!NewMenuEntry) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));\r
+      NewTerminalContext->DevicePath = DevicePathInstanceDup (DevicePath);\r
+      //\r
+      // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!\r
+      // coz' the misc data for each platform is not correct, actually it's the device path stored in\r
+      // datahub which is not completed, so a searching for end of device path will enter a\r
+      // dead-loop.\r
+      //\r
+      NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);\r
+      if (NULL == NewMenuEntry->DisplayString) {\r
+        NewMenuEntry->DisplayString = DevicePathToStr (DevicePath);\r
+      }\r
+\r
+      NewMenuEntry->HelpString = NULL;\r
+\r
+      gBS->HandleProtocol (\r
+            Handles[Index],\r
+            &gEfiSerialIoProtocolGuid,\r
+            &SerialIo\r
+            );\r
+\r
+      CopyMem (\r
+        &NewTerminalContext->BaudRate,\r
+        &SerialIo->Mode->BaudRate,\r
+        sizeof (UINT64)\r
+        );\r
+\r
+      CopyMem (\r
+        &NewTerminalContext->DataBits,\r
+        &SerialIo->Mode->DataBits,\r
+        sizeof (UINT8)\r
+        );\r
+\r
+      CopyMem (\r
+        &NewTerminalContext->Parity,\r
+        &SerialIo->Mode->Parity,\r
+        sizeof (UINT8)\r
+        );\r
+\r
+      CopyMem (\r
+        &NewTerminalContext->StopBits,\r
+        &SerialIo->Mode->StopBits,\r
+        sizeof (UINT8)\r
+        );\r
+      InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link);\r
+      TerminalMenu.MenuNumber++;\r
+    }\r
+  }\r
+  //\r
+  // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var\r
+  //\r
+  OutDevicePath = EfiLibGetVariable (L"ConOut", &gEfiGlobalVariableGuid);\r
+  InpDevicePath = EfiLibGetVariable (L"ConIn", &gEfiGlobalVariableGuid);\r
+  ErrDevicePath = EfiLibGetVariable (L"ErrOut", &gEfiGlobalVariableGuid);\r
+  if (OutDevicePath) {\r
+    UpdateComAttributeFromVariable (OutDevicePath);\r
+  }\r
+\r
+  if (InpDevicePath) {\r
+    UpdateComAttributeFromVariable (InpDevicePath);\r
+  }\r
+\r
+  if (ErrDevicePath) {\r
+    UpdateComAttributeFromVariable (ErrDevicePath);\r
+  }\r
+\r
+  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewTerminalContext                = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+    NewTerminalContext->TerminalType  = 0;\r
+    NewTerminalContext->IsConIn       = FALSE;\r
+    NewTerminalContext->IsConOut      = FALSE;\r
+    NewTerminalContext->IsStdErr      = FALSE;\r
+\r
+    Vendor.Header.Type                = MESSAGING_DEVICE_PATH;\r
+    Vendor.Header.SubType             = MSG_VENDOR_DP;\r
+\r
+    for (Index2 = 0; Index2 < 4; Index2++) {\r
+      CopyMem (&Vendor.Guid, &Guid[Index2], sizeof (EFI_GUID));\r
+      SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));\r
+      NewDevicePath = AppendDevicePathNode (\r
+                        NewTerminalContext->DevicePath,\r
+                        (EFI_DEVICE_PATH_PROTOCOL *) &Vendor\r
+                        );\r
+      SafeFreePool (NewMenuEntry->HelpString);\r
+      //\r
+      // NewMenuEntry->HelpString = DevicePathToStr (NewDevicePath);\r
+      // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;\r
+      //\r
+      NewMenuEntry->HelpString = NULL;\r
+\r
+      if (BdsLibMatchDevicePaths (OutDevicePath, NewDevicePath)) {\r
+        NewTerminalContext->IsConOut      = TRUE;\r
+        NewTerminalContext->TerminalType  = (UINT8) Index2;\r
+      }\r
+\r
+      if (BdsLibMatchDevicePaths (InpDevicePath, NewDevicePath)) {\r
+        NewTerminalContext->IsConIn       = TRUE;\r
+        NewTerminalContext->TerminalType  = (UINT8) Index2;\r
+      }\r
+\r
+      if (BdsLibMatchDevicePaths (ErrDevicePath, NewDevicePath)) {\r
+        NewTerminalContext->IsStdErr      = TRUE;\r
+        NewTerminalContext->TerminalType  = (UINT8) Index2;\r
+      }\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UpdateComAttributeFromVariable (\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Update Com Ports attributes from DevicePath\r
+  \r
+Arguments:\r
+  DevicePath  -   DevicePath that contains Com ports\r
+  \r
+Returns:\r
+  \r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL  *SerialNode;\r
+  ACPI_HID_DEVICE_PATH      *Acpi;\r
+  UART_DEVICE_PATH          *Uart;\r
+  UART_DEVICE_PATH          *Uart1;\r
+  UINT32                    Match;\r
+  UINTN                     TerminalNumber;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
+  UINTN                     Index;\r
+\r
+  Match           = EISA_PNP_ID (0x0501);\r
+  Node            = DevicePath;\r
+  Node            = NextDevicePathNode (Node);\r
+  TerminalNumber  = 0;\r
+  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+    while (!IsDevicePathEnd (Node)) {\r
+      if ((DevicePathType (Node) == ACPI_DEVICE_PATH) && (DevicePathSubType (Node) == ACPI_DP)) {\r
+        Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r
+        if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {\r
+          CopyMem (&TerminalNumber, &Acpi->UID, sizeof (UINT32));\r
+        }\r
+      }\r
+\r
+      if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r
+        Uart          = (UART_DEVICE_PATH *) Node;\r
+        NewMenuEntry  = BOpt_GetMenuEntry (&TerminalMenu, TerminalNumber);\r
+        if (NULL == NewMenuEntry) {\r
+          return EFI_NOT_FOUND;\r
+        }\r
+\r
+        NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+        CopyMem (\r
+          &NewTerminalContext->BaudRate,\r
+          &Uart->BaudRate,\r
+          sizeof (UINT64)\r
+          );\r
+\r
+        CopyMem (\r
+          &NewTerminalContext->DataBits,\r
+          &Uart->DataBits,\r
+          sizeof (UINT8)\r
+          );\r
+\r
+        CopyMem (\r
+          &NewTerminalContext->Parity,\r
+          &Uart->Parity,\r
+          sizeof (UINT8)\r
+          );\r
+\r
+        CopyMem (\r
+          &NewTerminalContext->StopBits,\r
+          &Uart->StopBits,\r
+          sizeof (UINT8)\r
+          );\r
+\r
+        SerialNode  = NewTerminalContext->DevicePath;\r
+        SerialNode  = NextDevicePathNode (SerialNode);\r
+        while (!IsDevicePathEnd (SerialNode)) {\r
+          if ((DevicePathType (SerialNode) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (SerialNode) == MSG_UART_DP)) {\r
+            //\r
+            // Update following device paths according to\r
+            // previous acquired uart attributes\r
+            //\r
+            Uart1 = (UART_DEVICE_PATH *) SerialNode;\r
+            CopyMem (\r
+              &Uart1->BaudRate,\r
+              &NewTerminalContext->BaudRate,\r
+              sizeof (UINT64)\r
+              );\r
+\r
+            CopyMem (\r
+              &Uart1->DataBits,\r
+              &NewTerminalContext->DataBits,\r
+              sizeof (UINT8)\r
+              );\r
+            CopyMem (\r
+              &Uart1->Parity,\r
+              &NewTerminalContext->Parity,\r
+              sizeof (UINT8)\r
+              );\r
+            CopyMem (\r
+              &Uart1->StopBits,\r
+              &NewTerminalContext->StopBits,\r
+              sizeof (UINT8)\r
+              );\r
+\r
+            break;\r
+          }\r
+\r
+          SerialNode = NextDevicePathNode (SerialNode);\r
+        }\r
+        //\r
+        // end while\r
+        //\r
+      }\r
+\r
+      Node = NextDevicePathNode (Node);\r
+    }\r
+    //\r
+    // end while\r
+    //\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevicePathInstanceDup (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Function creates a device path data structure that identically matches the \r
+  device path passed in.\r
+\r
+Arguments:\r
+  DevPath      - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  The new copy of DevPath is created to identically match the input.  \r
+  Otherwise, NULL is returned.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Temp;\r
+  UINT8                     *Ptr;\r
+  UINTN                     Size;\r
+\r
+  //\r
+  // get the size of an instance from the input\r
+  //\r
+  Temp            = DevPath;\r
+  DevicePathInst  = GetNextDevicePathInstance (&Temp, &Size);\r
+\r
+  //\r
+  // Make a copy and set proper end type\r
+  //\r
+  NewDevPath = NULL;\r
+  if (Size) {\r
+    NewDevPath = AllocateZeroPool (Size);\r
+    ASSERT (NewDevPath != NULL);\r
+  }\r
+\r
+  if (NewDevPath) {\r
+    CopyMem (NewDevPath, DevicePathInst, Size);\r
+    Ptr = (UINT8 *) NewDevPath;\r
+    Ptr += Size - sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+    Temp = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+    SetDevicePathEndNode (Temp);\r
+  }\r
+\r
+  return NewDevPath;\r
+}\r
+\r
+EFI_STATUS\r
+GetConsoleMenu (\r
+  IN UINTN              ConsoleMenuType\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *AllDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *MultiDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
+  UINTN                     Size;\r
+  UINTN                     AllCount;\r
+  UINTN                     Index;\r
+  UINTN                     Index2;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_CONSOLE_CONTEXT        *NewConsoleContext;\r
+  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
+  TYPE_OF_TERMINAL          Terminal;\r
+  BM_MENU_ENTRY             *NewTerminalMenuEntry;\r
+  UINTN                     Com;\r
+  BM_MENU_OPTION            *ConsoleMenu;\r
+\r
+  DevicePath    = NULL;\r
+  AllDevicePath = NULL;\r
+  AllCount      = 0;\r
+  switch (ConsoleMenuType) {\r
+  case BM_CONSOLE_IN_CONTEXT_SELECT:\r
+    ConsoleMenu = &ConsoleInpMenu;\r
+    DevicePath = EfiLibGetVariable (\r
+                  L"ConIn",\r
+                  &gEfiGlobalVariableGuid\r
+                  );\r
+\r
+    AllDevicePath = EfiLibGetVariable (\r
+                      L"ConInDev",\r
+                      &gEfiGlobalVariableGuid\r
+                      );\r
+    break;\r
+\r
+  case BM_CONSOLE_OUT_CONTEXT_SELECT:\r
+    ConsoleMenu = &ConsoleOutMenu;\r
+    DevicePath = EfiLibGetVariable (\r
+                  L"ConOut",\r
+                  &gEfiGlobalVariableGuid\r
+                  );\r
+\r
+    AllDevicePath = EfiLibGetVariable (\r
+                      L"ConOutDev",\r
+                      &gEfiGlobalVariableGuid\r
+                      );\r
+    break;\r
+\r
+  case BM_CONSOLE_ERR_CONTEXT_SELECT:\r
+    ConsoleMenu = &ConsoleErrMenu;\r
+    DevicePath = EfiLibGetVariable (\r
+                  L"ErrOut",\r
+                  &gEfiGlobalVariableGuid\r
+                  );\r
+\r
+    AllDevicePath = EfiLibGetVariable (\r
+                      L"ErrOutDev",\r
+                      &gEfiGlobalVariableGuid\r
+                      );\r
+    break;\r
+\r
+  default:\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (NULL == AllDevicePath) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  InitializeListHead (&ConsoleMenu->Head);\r
+\r
+  AllCount                = EfiDevicePathInstanceCount (AllDevicePath);\r
+  ConsoleMenu->MenuNumber = 0;\r
+  //\r
+  // Following is menu building up for Console Out Devices\r
+  //\r
+  MultiDevicePath = AllDevicePath;\r
+  Index2          = 0;\r
+  for (Index = 0; Index < AllCount; Index++) {\r
+    DevicePathInst  = GetNextDevicePathInstance (&MultiDevicePath, &Size);\r
+\r
+    NewMenuEntry    = BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    NewConsoleContext             = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+    NewMenuEntry->OptionNumber    = Index2;\r
+\r
+    NewConsoleContext->DevicePath = DevicePathInstanceDup (DevicePathInst);\r
+    NewMenuEntry->DisplayString   = EfiLibStrFromDatahub (NewConsoleContext->DevicePath);\r
+    if (NULL == NewMenuEntry->DisplayString) {\r
+      NewMenuEntry->DisplayString = DevicePathToStr (NewConsoleContext->DevicePath);\r
+    }\r
+\r
+    NewConsoleContext->IsTerminal = IsTerminalDevicePath (\r
+                                      NewConsoleContext->DevicePath,\r
+                                      &Terminal,\r
+                                      &Com\r
+                                      );\r
+\r
+    NewConsoleContext->IsActive = BdsLibMatchDevicePaths (\r
+                                    DevicePath,\r
+                                    NewConsoleContext->DevicePath\r
+                                    );\r
+    NewTerminalMenuEntry  = NULL;\r
+    NewTerminalContext    = NULL;\r
+\r
+    if (NewConsoleContext->IsTerminal) {\r
+      BOpt_DestroyMenuEntry (NewMenuEntry);\r
+    } else {\r
+      Index2++;\r
+      ConsoleMenu->MenuNumber++;\r
+      InsertTailList (&ConsoleMenu->Head, &NewMenuEntry->Link);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetAllConsoles (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r
+\r
+Arguments:\r
+  \r
+Returns:\r
+  EFI_SUCCESS \r
+  Others\r
+  \r
+--*/\r
+{\r
+  GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT);\r
+  GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT);\r
+  GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FreeAllConsoles (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r
+\r
+Arguments:\r
+  \r
+Returns:\r
+  EFI_SUCCESS \r
+  Others\r
+  \r
+--*/\r
+{\r
+  BOpt_FreeMenu (&ConsoleOutMenu);\r
+  BOpt_FreeMenu (&ConsoleInpMenu);\r
+  BOpt_FreeMenu (&ConsoleErrMenu);\r
+  BOpt_FreeMenu (&TerminalMenu);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+IsTerminalDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+  OUT TYPE_OF_TERMINAL         *Termi,\r
+  OUT UINTN                    *Com\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Test whether DevicePath is a valid Terminal\r
+\r
+Arguments:\r
+  DevicePath  -   DevicePath to be checked\r
+  Termi       -   If is terminal, give its type\r
+  Com         -   If is Com Port, give its type\r
+  \r
+Returns:\r
+  TRUE        -   If DevicePath point to a Terminal\r
+  FALSE\r
+  \r
+--*/\r
+{\r
+  UINT8                 *Ptr;\r
+  BOOLEAN               IsTerminal;\r
+  VENDOR_DEVICE_PATH    *Vendor;\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+  UINT32                Match;\r
+  EFI_GUID              TempGuid;\r
+\r
+  IsTerminal = FALSE;\r
+\r
+  //\r
+  // Parse the Device Path, should be change later!!!\r
+  //\r
+  Ptr = (UINT8 *) DevicePath;\r
+  while (*Ptr != END_DEVICE_PATH_TYPE) {\r
+    Ptr++;\r
+  }\r
+\r
+  Ptr     = Ptr - sizeof (VENDOR_DEVICE_PATH);\r
+  Vendor  = (VENDOR_DEVICE_PATH *) Ptr;\r
+\r
+  //\r
+  // There are four kinds of Terminal types\r
+  // check to see whether this devicepath\r
+  // is one of that type\r
+  //\r
+  CopyMem (&TempGuid, &Vendor->Guid, sizeof (EFI_GUID));\r
+\r
+  if (CompareGuid (&TempGuid, &Guid[0])) {\r
+    *Termi      = PC_ANSI;\r
+    IsTerminal  = TRUE;\r
+  } else {\r
+    if (CompareGuid (&TempGuid, &Guid[1])) {\r
+      *Termi      = VT_100;\r
+      IsTerminal  = TRUE;\r
+    } else {\r
+      if (CompareGuid (&TempGuid, &Guid[2])) {\r
+        *Termi      = VT_100_PLUS;\r
+        IsTerminal  = TRUE;\r
+      } else {\r
+        if (CompareGuid (&TempGuid, &Guid[3])) {\r
+          *Termi      = VT_UTF8;\r
+          IsTerminal  = TRUE;\r
+        } else {\r
+          IsTerminal = FALSE;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  if (!IsTerminal) {\r
+    return FALSE;\r
+  }\r
+\r
+  Ptr   = Ptr - sizeof (UART_DEVICE_PATH) - sizeof (ACPI_HID_DEVICE_PATH);\r
+  Acpi  = (ACPI_HID_DEVICE_PATH *) Ptr;\r
+  Match = EISA_PNP_ID (0x0501);\r
+  if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {\r
+    CopyMem (Com, &Acpi->UID, sizeof (UINT32));\r
+  } else {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Data.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Data.c
new file mode 100644 (file)
index 0000000..4b169c9
--- /dev/null
@@ -0,0 +1,324 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Data.c\r
+    \r
+Abstract:\r
+\r
+  Define some data used for Boot Maint\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "BootMaint.h"\r
+\r
+EFI_HII_UPDATE_DATA *UpdateData;\r
+STRING_DEPOSITORY   *FileOptionStrDepository;\r
+STRING_DEPOSITORY   *ConsoleOptionStrDepository;\r
+STRING_DEPOSITORY   *BootOptionStrDepository;\r
+STRING_DEPOSITORY   *BootOptionHelpStrDepository;\r
+STRING_DEPOSITORY   *DriverOptionStrDepository;\r
+STRING_DEPOSITORY   *DriverOptionHelpStrDepository;\r
+STRING_DEPOSITORY   *TerminalStrDepository;\r
+\r
+//\r
+// Terminal type string token storage\r
+//\r
+UINT16              TerminalType[] = {\r
+  STRING_TOKEN(STR_COM_TYPE_0),\r
+  STRING_TOKEN(STR_COM_TYPE_1),\r
+  STRING_TOKEN(STR_COM_TYPE_2),\r
+  STRING_TOKEN(STR_COM_TYPE_3),\r
+};\r
+\r
+//\r
+// File system selection menu\r
+//\r
+BM_MENU_OPTION      FsOptionMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Console Input Device Selection Menu\r
+//\r
+BM_MENU_OPTION      ConsoleInpMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Console Output Device Selection Menu\r
+//\r
+BM_MENU_OPTION      ConsoleOutMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Error Output Device Selection Menu\r
+//\r
+BM_MENU_OPTION      ConsoleErrMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Boot Option from variable Menu\r
+//\r
+BM_MENU_OPTION      BootOptionMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Driver Option from variable menu\r
+//\r
+BM_MENU_OPTION      DriverOptionMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Legacy FD Info from LegacyBios.GetBbsInfo()\r
+//\r
+BM_MENU_OPTION      LegacyFDMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Legacy HD Info from LegacyBios.GetBbsInfo()\r
+//\r
+BM_MENU_OPTION      LegacyHDMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Legacy CD Info from LegacyBios.GetBbsInfo()\r
+//\r
+BM_MENU_OPTION      LegacyCDMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Legacy NET Info from LegacyBios.GetBbsInfo()\r
+//\r
+BM_MENU_OPTION      LegacyNETMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Legacy NET Info from LegacyBios.GetBbsInfo()\r
+//\r
+BM_MENU_OPTION      LegacyBEVMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Files and sub-directories in current directory menu\r
+//\r
+BM_MENU_OPTION      DirectoryMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Handles in current system selection menu\r
+//\r
+BM_MENU_OPTION      DriverMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+BM_MENU_OPTION      TerminalMenu = {\r
+  BM_MENU_OPTION_SIGNATURE,\r
+  NULL,\r
+  0\r
+};\r
+\r
+//\r
+// Value and string token correspondency for BaudRate\r
+//\r
+COM_ATTR            BaudRateList[19] = {\r
+  {\r
+    115200,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_0)\r
+  },\r
+  {\r
+    57600,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_1)\r
+  },\r
+  {\r
+    38400,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_2)\r
+  },\r
+  {\r
+    19200,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_3)\r
+  },\r
+  {\r
+    9600,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_4)\r
+  },\r
+  {\r
+    7200,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_5)\r
+  },\r
+  {\r
+    4800,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_6)\r
+  },\r
+  {\r
+    3600,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_7)\r
+  },\r
+  {\r
+    2400,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_8)\r
+  },\r
+  {\r
+    2000,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_9)\r
+  },\r
+  {\r
+    1800,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_10)\r
+  },\r
+  {\r
+    1200,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_11)\r
+  },\r
+  {\r
+    600,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_12)\r
+  },\r
+  {\r
+    300,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_13)\r
+  },\r
+  {\r
+    150,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_14)\r
+  },\r
+  {\r
+    134,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_15)\r
+  },\r
+  {\r
+    110,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_16)\r
+  },\r
+  {\r
+    75,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_17)\r
+  },\r
+  {\r
+    50,\r
+    STRING_TOKEN(STR_COM_BAUD_RATE_18)\r
+  }\r
+};\r
+\r
+//\r
+// Value and string token correspondency for DataBits\r
+//\r
+COM_ATTR            DataBitsList[4] = {\r
+  {\r
+    5,\r
+    STRING_TOKEN(STR_COM_DATA_BITS_0)\r
+  },\r
+  {\r
+    6,\r
+    STRING_TOKEN(STR_COM_DATA_BITS_1)\r
+  },\r
+  {\r
+    7,\r
+    STRING_TOKEN(STR_COM_DATA_BITS_2)\r
+  },\r
+  {\r
+    8,\r
+    STRING_TOKEN(STR_COM_DATA_BITS_3)\r
+  }\r
+};\r
+\r
+//\r
+// Value and string token correspondency for Parity\r
+//\r
+COM_ATTR            ParityList[5] = {\r
+  {\r
+    NoParity,\r
+    STRING_TOKEN(STR_COM_PAR_0)\r
+  },\r
+  {\r
+    EvenParity,\r
+    STRING_TOKEN(STR_COM_PAR_1)\r
+  },\r
+  {\r
+    OddParity,\r
+    STRING_TOKEN(STR_COM_PAR_2)\r
+  },\r
+  {\r
+    MarkParity,\r
+    STRING_TOKEN(STR_COM_PAR_3)\r
+  },\r
+  {\r
+    SpaceParity,\r
+    STRING_TOKEN(STR_COM_PAR_4)\r
+  }\r
+};\r
+\r
+//\r
+// Value and string token correspondency for Baudreate\r
+//\r
+COM_ATTR            StopBitsList[3] = {\r
+  {\r
+    OneStopBit,\r
+    STRING_TOKEN(STR_COM_STOP_BITS_0)\r
+  },\r
+  {\r
+    OneFiveStopBits,\r
+    STRING_TOKEN(STR_COM_STOP_BITS_1)\r
+  },\r
+  {\r
+    TwoStopBits,\r
+    STRING_TOKEN(STR_COM_STOP_BITS_2)\r
+  }\r
+};\r
+\r
+//\r
+// Guid for messaging path, used in Serial port setting.\r
+//\r
+EFI_GUID            Guid[4] = {\r
+  DEVICE_PATH_MESSAGING_PC_ANSI,\r
+  DEVICE_PATH_MESSAGING_VT_100,\r
+  DEVICE_PATH_MESSAGING_VT_100_PLUS,\r
+  DEVICE_PATH_MESSAGING_VT_UTF8\r
+};\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FE.vfr b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FE.vfr
new file mode 100644 (file)
index 0000000..a10553a
--- /dev/null
@@ -0,0 +1,138 @@
+// *++\r
+//\r
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//   FE.vfr \r
+// \r
+// Abstract:\r
+// \r
+//   File Explorer Formset\r
+// \r
+// Revision History: \r
+// \r
+// --*/\r
+\r
+#include "BdsStrDefs.h" \r
+#include "FormGuid.h"\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT16                    DescriptionData[75];\r
+  UINT16                    OptionalData[127];\r
+  UINT8                     Active;\r
+  UINT8                     ForceReconnect;  \r
+} FILE_EXPLORER_NV_DATA;\r
+#pragma pack()\r
+\r
+#define FORM_FILE_EXPLORER_ID                 0x001E\r
+#define FORM_BOOT_ADD_DESCRIPTION_ID          0x001F\r
+#define FORM_DRIVER_ADD_FILE_DESCRIPTION_ID   0x0020\r
+#define KEY_VALUE_SAVE_AND_EXIT               0x0090\r
+#define KEY_VALUE_NO_SAVE_AND_EXIT            0x0091\r
+\r
+\r
+\r
+formset \r
+  guid = FILE_EXPLORE_FORMSET_GUID,\r
+  title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE),\r
+  help = STRING_TOKEN(STR_NULL_STRING),\r
+  class = 0,\r
+  subclass = 0,\r
+\r
+  form formid = FORM_FILE_EXPLORER_ID,\r
+       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
+\r
+       label FORM_FILE_EXPLORER_ID;\r
+  endform;\r
+  \r
+  form formid = FORM_BOOT_ADD_DESCRIPTION_ID,\r
+       title = STRING_TOKEN(STR_FORM_BOOT_ADD_DESC_TITLE);\r
+       \r
+       label FORM_BOOT_ADD_DESCRIPTION_ID;\r
+\r
+       subtitle  text = STRING_TOKEN(STR_NULL_STRING);\r
+       \r
+       string    varid    = FILE_EXPLORER_NV_DATA.DescriptionData,\r
+                 prompt   = STRING_TOKEN(STR_LOAD_OPTION_DESC),\r
+                 help     = STRING_TOKEN(STR_NULL_STRING),\r
+                 minsize  = 6,\r
+                 maxsize  = 75,\r
+       endstring;\r
+\r
+       string    varid    = FILE_EXPLORER_NV_DATA.OptionalData,\r
+                       prompt   = STRING_TOKEN(STR_OPTIONAL_DATA),\r
+                       help     = STRING_TOKEN(STR_NULL_STRING),\r
+                       minsize  = 0,\r
+                       maxsize  = 120,\r
+       endstring;\r
+\r
+       text \r
+         help   = STRING_TOKEN(STR_SAVE_AND_EXIT),  \r
+         text   = STRING_TOKEN(STR_SAVE_AND_EXIT), \r
+         text   = STRING_TOKEN(STR_NULL_STRING),\r
+         flags  = INTERACTIVE | NV_ACCESS,\r
+         key    = KEY_VALUE_SAVE_AND_EXIT;\r
+             \r
+       text \r
+         help   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),  \r
+         text   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT), \r
+         text   = STRING_TOKEN(STR_NULL_STRING),\r
+         flags  = INTERACTIVE | NV_ACCESS,\r
+         key    = KEY_VALUE_NO_SAVE_AND_EXIT;\r
+    \r
+  endform;\r
+\r
+  form formid = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID,\r
+       title = STRING_TOKEN(STR_FORM_DRV_ADD_DESC_TITLE);\r
+       \r
+       label FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r
+       \r
+       subtitle  text = STRING_TOKEN(STR_NULL_STRING);\r
+\r
+       string    varid    = FILE_EXPLORER_NV_DATA.DescriptionData,\r
+                 prompt   = STRING_TOKEN(STR_LOAD_OPTION_DESC),\r
+                 help     = STRING_TOKEN(STR_NULL_STRING),\r
+                 minsize  = 6,\r
+                 maxsize  = 75,\r
+       endstring;\r
+\r
+       string    varid    = FILE_EXPLORER_NV_DATA.OptionalData,\r
+                 prompt   = STRING_TOKEN(STR_OPTIONAL_DATA),\r
+                 help     = STRING_TOKEN(STR_NULL_STRING),\r
+                 minsize  = 0,\r
+                 maxsize  = 120,\r
+       endstring; \r
+       \r
+       checkbox varid    = FILE_EXPLORER_NV_DATA.ForceReconnect,\r
+               prompt   = STRING_TOKEN(STR_LOAD_OPTION_FORCE_RECON),\r
+               help     = STRING_TOKEN(STR_LOAD_OPTION_FORCE_RECON),  \r
+               flags    = 1,\r
+               key      = 0,\r
+       endcheckbox;\r
+\r
+       text \r
+         help   = STRING_TOKEN(STR_SAVE_AND_EXIT),  \r
+         text   = STRING_TOKEN(STR_SAVE_AND_EXIT), \r
+         text   = STRING_TOKEN(STR_NULL_STRING),\r
+         flags  = INTERACTIVE | NV_ACCESS,\r
+         key    = KEY_VALUE_SAVE_AND_EXIT;\r
+      \r
+       text \r
+         help   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),  \r
+         text   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT), \r
+         text   = STRING_TOKEN(STR_NULL_STRING),\r
+         flags  = INTERACTIVE | NV_ACCESS,\r
+         key    = KEY_VALUE_NO_SAVE_AND_EXIT;\r
+               \r
+  endform;\r
+  \r
+endformset;
\ No newline at end of file
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FileExplorer.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FileExplorer.c
new file mode 100644 (file)
index 0000000..db835cf
--- /dev/null
@@ -0,0 +1,340 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FileExplorer.c\r
+    \r
+AgBStract:\r
+\r
+  File explorer related functions.\r
+\r
+--*/\r
+\r
+#include "Generic/Bds.h"\r
+#include "BootMaint.h"\r
+#include "BdsPlatform.h"\r
+\r
+VOID\r
+UpdateFileExplorePage (\r
+  IN BMM_CALLBACK_DATA            *CallbackData,\r
+  BM_MENU_OPTION                  *MenuOption\r
+  )\r
+/*++\r
+Routine Description:\r
+  Update the File Explore page.\r
+\r
+Arguments:\r
+  MenuOption      - Pointer to menu options to display.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  UINT8           *Location;\r
+  UINTN           Index;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_FILE_CONTEXT *NewFileContext;\r
+  FORM_ID         FormId;\r
+\r
+  NewMenuEntry    = NULL;\r
+  NewFileContext  = NULL;\r
+  FormId          = 0;\r
+\r
+  //\r
+  // Clean up file explore page.\r
+  //\r
+  RefreshUpdateData (FALSE, 0, FALSE, 0, 0xff);\r
+\r
+  //\r
+  // Remove all op-codes from dynamic page\r
+  //\r
+  CallbackData->Hii->UpdateForm (\r
+                      CallbackData->Hii,\r
+                      CallbackData->FeHiiHandle,\r
+                      FORM_FILE_EXPLORER_ID,\r
+                      FALSE,\r
+                      UpdateData\r
+                      );\r
+\r
+  RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackData->FeCallbackHandle, FALSE, 0, 0);\r
+\r
+  Location = (UINT8 *) &UpdateData->Data;\r
+\r
+  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
+    NewMenuEntry    = BOpt_GetMenuEntry (MenuOption, Index);\r
+    NewFileContext  = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+    if (NewFileContext->IsBootLegacy) {\r
+      continue;\r
+    }\r
+\r
+    if ((NewFileContext->IsDir) || (BOOT_FROM_FILE_STATE == CallbackData->FeCurrentState)) {\r
+      //\r
+      // Create Text opcode for directory, also create Text opcode for file in BOOT_FROM_FILE_STATE.\r
+      //\r
+      CreateTextOpCode (\r
+        NewMenuEntry->DisplayStringToken,\r
+        STR_NULL_STRING,\r
+        STR_NULL_STRING,\r
+        EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+        (UINT16) (FILE_OPTION_OFFSET + Index),\r
+        Location\r
+        );\r
+    } else {\r
+      //\r
+      // Create Goto opcode for file in ADD_BOOT_OPTION_STATE or ADD_DRIVER_OPTION_STATE.\r
+      //\r
+      if (ADD_BOOT_OPTION_STATE == CallbackData->FeCurrentState) {\r
+        FormId = FORM_BOOT_ADD_DESCRIPTION_ID;\r
+      } else if (ADD_DRIVER_OPTION_STATE == CallbackData->FeCurrentState) {\r
+        FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r
+      }\r
+\r
+      CreateGotoOpCode (\r
+        FormId,\r
+        NewMenuEntry->DisplayStringToken,\r
+        STRING_TOKEN (STR_NULL_STRING),\r
+        EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+        (UINT16) (FILE_OPTION_OFFSET + Index),\r
+        Location\r
+        );\r
+    }\r
+\r
+    UpdateData->DataCount++;\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  }\r
+\r
+  CallbackData->Hii->UpdateForm (\r
+                      CallbackData->Hii,\r
+                      CallbackData->FeHiiHandle,\r
+                      FORM_FILE_EXPLORER_ID,\r
+                      TRUE,\r
+                      UpdateData\r
+                      );\r
+}\r
+\r
+BOOLEAN\r
+UpdateFileExplorer (\r
+  IN BMM_CALLBACK_DATA            *CallbackData,\r
+  IN UINT16                       KeyValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Update the file explower page with the refershed file system.\r
+\r
+Arguments:\r
+  CallbackData  -   BMM context data\r
+  KeyValue        - Key value to identify the type of data to expect.\r
+\r
+Returns:\r
+  TRUE          - Inform the caller to create a callback packet to exit file explorer.\r
+  FALSE         - Indicate that there is no need to exit file explorer.\r
+\r
+--*/\r
+{\r
+  UINT16          FileOptionMask;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_FILE_CONTEXT *NewFileContext;\r
+  FORM_ID         FormId;\r
+  BOOLEAN         ExitFileExplorer;\r
+  EFI_STATUS      Status;\r
+  \r
+  NewMenuEntry      = NULL;\r
+  NewFileContext    = NULL;\r
+  ExitFileExplorer  = FALSE;\r
+\r
+  FileOptionMask    = (UINT16) (FILE_OPTION_MASK & KeyValue);\r
+\r
+  if (UNKNOWN_CONTEXT == CallbackData->FeDisplayContext) {\r
+    //\r
+    // First in, display file system.\r
+    //\r
+    BOpt_FreeMenu (&FsOptionMenu);\r
+    BOpt_FindFileSystem (CallbackData);\r
+    CreateMenuStringToken (CallbackData, CallbackData->FeHiiHandle, &FsOptionMenu);\r
+\r
+    UpdateFileExplorePage (CallbackData, &FsOptionMenu);\r
+\r
+    CallbackData->FeDisplayContext = FILE_SYSTEM;\r
+  } else {\r
+    if (FILE_SYSTEM == CallbackData->FeDisplayContext) {\r
+      NewMenuEntry = BOpt_GetMenuEntry (&FsOptionMenu, FileOptionMask);\r
+    } else if (DIRECTORY == CallbackData->FeDisplayContext) {\r
+      NewMenuEntry = BOpt_GetMenuEntry (&DirectoryMenu, FileOptionMask);\r
+    }\r
+\r
+    CallbackData->FeDisplayContext  = DIRECTORY;\r
+\r
+    NewFileContext                  = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+    if (NewFileContext->IsDir ) {\r
+      RemoveEntryList (&NewMenuEntry->Link);\r
+      BOpt_FreeMenu (&DirectoryMenu);\r
+      Status = BOpt_FindFiles (CallbackData, NewMenuEntry);\r
+       if (EFI_ERROR (Status)) {\r
+         ExitFileExplorer = TRUE;\r
+         goto exit;\r
+       }\r
+      CreateMenuStringToken (CallbackData, CallbackData->FeHiiHandle, &DirectoryMenu);\r
+      BOpt_DestroyMenuEntry (NewMenuEntry);\r
+\r
+      UpdateFileExplorePage (CallbackData, &DirectoryMenu);\r
+\r
+    } else {\r
+      switch (CallbackData->FeCurrentState) {\r
+      case BOOT_FROM_FILE_STATE:\r
+        //\r
+        // Here boot from file\r
+        //\r
+        BootThisFile (NewFileContext);\r
+        ExitFileExplorer = TRUE;\r
+        break;\r
+\r
+      case ADD_BOOT_OPTION_STATE:\r
+      case ADD_DRIVER_OPTION_STATE:\r
+        if (ADD_BOOT_OPTION_STATE == CallbackData->FeCurrentState) {\r
+          FormId = FORM_BOOT_ADD_DESCRIPTION_ID;\r
+        } else {\r
+          FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r
+        }\r
+\r
+        CallbackData->MenuEntry = NewMenuEntry;\r
+        CallbackData->LoadContext->FilePathList = ((BM_FILE_CONTEXT *) (CallbackData->MenuEntry->VariableContext))->DevicePath;\r
+\r
+        //\r
+        // Clean up file explore page.\r
+        //\r
+        RefreshUpdateData (FALSE, 0, FALSE, 0, 1);\r
+\r
+        //\r
+        // Remove the Subtitle op-code.\r
+        //\r
+        CallbackData->Hii->UpdateForm (\r
+                            CallbackData->Hii,\r
+                            CallbackData->FeHiiHandle,\r
+                            FormId,\r
+                            FALSE,\r
+                            UpdateData\r
+                            );\r
+\r
+        //\r
+        // Create Subtitle op-code for the display string of the option.\r
+        //\r
+        RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackData->FeCallbackHandle, FALSE, 0, 1);\r
+\r
+        CreateSubTitleOpCode (\r
+          NewMenuEntry->DisplayStringToken,\r
+          &UpdateData->Data\r
+          );\r
+\r
+        CallbackData->Hii->UpdateForm (\r
+                            CallbackData->Hii,\r
+                            CallbackData->FeHiiHandle,\r
+                            FormId,\r
+                            TRUE,\r
+                            UpdateData\r
+                            );\r
+        break;\r
+\r
+      default:\r
+        break;\r
+      }\r
+    }\r
+  }\r
+exit:\r
+  return ExitFileExplorer;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FileExplorerCallback (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *Data,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  )\r
+/*++\r
+Routine Description:\r
+  Callback Function for file exploration and file interaction.\r
+\r
+Arguments:\r
+  This            - File explorer callback protocol pointer.     \r
+  KeyValue        - Key value to identify the type of data to expect.\r
+  Data            - A pointer to the data being sent to the original exporting driver.\r
+  Packet          - A pointer to a packet of information which a driver passes back to the browser.\r
+\r
+Returns:\r
+  EFI_SUCCESS     - Callback ended successfully.\r
+  Others          - Contain some errors.\r
+  \r
+--*/\r
+{\r
+  BMM_CALLBACK_DATA     *Private;\r
+  FILE_EXPLORER_NV_DATA *NvRamMap;\r
+  EFI_STATUS            Status;\r
+\r
+  Status                          = EFI_SUCCESS;\r
+  Private                         = FE_CALLBACK_DATA_FROM_THIS (This);\r
+  UpdateData->FormCallbackHandle  = (EFI_PHYSICAL_ADDRESS) (UINTN) Private->FeCallbackHandle;\r
+  NvRamMap                        = (FILE_EXPLORER_NV_DATA *) Data->NvRamMap;\r
+\r
+  if (KEY_VALUE_SAVE_AND_EXIT == KeyValue) {\r
+    //\r
+    // Apply changes and exit formset.\r
+    //\r
+    if (ADD_BOOT_OPTION_STATE == Private->FeCurrentState) {\r
+      Status = Var_UpdateBootOption (Private, NvRamMap);\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      BOpt_GetBootOptions (Private);\r
+      CreateMenuStringToken (Private, Private->FeHiiHandle, &BootOptionMenu);\r
+    } else if (ADD_DRIVER_OPTION_STATE == Private->FeCurrentState) {\r
+      Status = Var_UpdateDriverOption (\r
+                Private,\r
+                Private->FeHiiHandle,\r
+                NvRamMap->DescriptionData,\r
+                NvRamMap->OptionalData,\r
+                NvRamMap->ForceReconnect\r
+                );\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      BOpt_GetDriverOptions (Private);\r
+      CreateMenuStringToken (Private, Private->FeHiiHandle, &DriverOptionMenu);\r
+    }\r
+\r
+    CreateCallbackPacket (Packet, EXIT_REQUIRED | NV_NOT_CHANGED);\r
+  } else if (KEY_VALUE_NO_SAVE_AND_EXIT == KeyValue) {\r
+    //\r
+    // Discard changes and exit formset.\r
+    //\r
+    NvRamMap->OptionalData[0]     = 0x0000;\r
+    NvRamMap->DescriptionData[0]  = 0x0000;\r
+    CreateCallbackPacket (Packet, EXIT_REQUIRED | NV_NOT_CHANGED);\r
+  } else if (KeyValue < FILE_OPTION_OFFSET) {\r
+    //\r
+    // Exit File Explorer formset.\r
+    //\r
+    CreateCallbackPacket (Packet, EXIT_REQUIRED);\r
+  } else {\r
+    if (UpdateFileExplorer (Private, KeyValue)) {\r
+      CreateCallbackPacket (Packet, EXIT_REQUIRED);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FormGuid.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/FormGuid.h
new file mode 100644 (file)
index 0000000..8b55159
--- /dev/null
@@ -0,0 +1,32 @@
+// *++\r
+//\r
+// Copyright (c) 2006, Intel Corporation\r
+// All rights reserved. This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution.  The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+//\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// Module Name:\r
+//\r
+//   FormGuid.h\r
+//\r
+// Abstract:\r
+//\r
+//   Formset guids for Boot Maintenance Manager\r
+//\r
+// Revision History:\r
+//\r
+// --*/\r
+//\r
+#define MAIN_FORMSET_GUID \\r
+  { \\r
+    0x642237c7, 0x35d4, 0x472d, { 0x83, 0x65, 0x12, 0xe0, 0xcc, 0xf2, 0x7a, 0x22 } \\r
+  }\r
+\r
+#define FILE_EXPLORE_FORMSET_GUID \\r
+  { \\r
+    0x1f2d63e1, 0xfebd, 0x4dc7, { 0x9c, 0xc5, 0xba, 0x2b, 0x1c, 0xef, 0x9c, 0x5b } \\r
+  }\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/UpdatePage.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/UpdatePage.c
new file mode 100644 (file)
index 0000000..9c72f23
--- /dev/null
@@ -0,0 +1,1275 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UpdatePage.c\r
+    \r
+AgBStract:\r
+\r
+  Dynamically Update the pages\r
+\r
+--*/\r
+\r
+#include "Generic/Bds.h"\r
+#include "BootMaint.h"\r
+#include "BdsPlatform.h"\r
+\r
+EFI_GUID gTerminalDriverGuid = {\r
+  0x10634d8e, 0x1c05, 0x46cb, 0xbb, 0xc, 0x5a, 0xfd, 0xc8, 0x29, 0xa8, 0xc8\r
+};\r
+\r
+VOID\r
+RefreshUpdateData (\r
+  IN BOOLEAN                      FormSetUpdate,\r
+  IN EFI_PHYSICAL_ADDRESS         FormCallbackHandle,\r
+  IN BOOLEAN                      FormUpdate,\r
+  IN STRING_REF                   FormTitle,\r
+  IN UINT16                       DataCount\r
+  )\r
+/*++\r
+Routine Description:\r
+  Refresh the global UpdateData structure.\r
+\r
+Arguments:\r
+  FormSetUpdate      - If TRUE, next variable is significant\r
+  FormCallbackHandle - If not 0, will update FormSet with this info\r
+  FormUpdate         - If TRUE, next variable is significant\r
+  FormTitle          - If not 0, will update Form with this info\r
+  DataCount          - The number of Data entries in this structure\r
+\r
+Returns:\r
+  None.\r
+--*/\r
+{\r
+  UpdateData->FormSetUpdate = FormSetUpdate;\r
+  if (FormSetUpdate) {\r
+    ASSERT (0 != FormCallbackHandle);\r
+    UpdateData->FormCallbackHandle = FormCallbackHandle;\r
+  }\r
+\r
+  UpdateData->FormUpdate  = FALSE;\r
+  UpdateData->FormTitle   = FormTitle;\r
+  UpdateData->DataCount   = DataCount;\r
+}\r
+\r
+VOID\r
+UpdatePageStart (\r
+  IN BMM_CALLBACK_DATA                *CallbackData,\r
+  IN OUT UINT8                        **CurrentLocation\r
+  )\r
+{\r
+  RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackData->BmmCallbackHandle, FALSE, 0, 0);\r
+\r
+  if (!(CallbackData->BmmAskSaveOrNot)) {\r
+    //\r
+    // Add a "Go back to main page" tag in front of the form when there are no\r
+    // "Apply changes" and "Discard changes" tags in the end of the form.\r
+    //\r
+    CreateGotoOpCode (\r
+      FORM_MAIN_ID,\r
+      STRING_TOKEN (STR_FORM_GOTO_MAIN),\r
+      STRING_TOKEN (STR_FORM_GOTO_MAIN),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      FORM_MAIN_ID,\r
+      *CurrentLocation\r
+      );\r
+\r
+    UpdateData->DataCount++;\r
+\r
+    *CurrentLocation = *CurrentLocation + ((EFI_IFR_OP_HEADER *) (*CurrentLocation))->Length;\r
+  }\r
+\r
+}\r
+\r
+VOID\r
+UpdatePageEnd (\r
+  IN BMM_CALLBACK_DATA                *CallbackData,\r
+  IN UINT8                            *CurrentLocation\r
+  )\r
+{\r
+  //\r
+  // Create the "Apply changes" and "Discard changes" tags.\r
+  //\r
+  if (CallbackData->BmmAskSaveOrNot) {\r
+    CreateGotoOpCode (\r
+      FORM_MAIN_ID,\r
+      STRING_TOKEN (STR_SAVE_AND_EXIT),\r
+      STRING_TOKEN (STR_NULL_STRING),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      KEY_VALUE_SAVE_AND_EXIT,\r
+      CurrentLocation\r
+      );\r
+\r
+    UpdateData->DataCount++;\r
+\r
+    CurrentLocation = CurrentLocation + ((EFI_IFR_OP_HEADER *) CurrentLocation)->Length;\r
+\r
+    CreateGotoOpCode (\r
+      FORM_MAIN_ID,\r
+      STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
+      STRING_TOKEN (STR_NULL_STRING),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      KEY_VALUE_NO_SAVE_AND_EXIT,\r
+      CurrentLocation\r
+      );\r
+\r
+    UpdateData->DataCount++;\r
+  }\r
+  //\r
+  // Ensure user can return to the main page.\r
+  //\r
+  if (0 == UpdateData->DataCount) {\r
+    CreateGotoOpCode (\r
+      FORM_MAIN_ID,\r
+      STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
+      STRING_TOKEN (STR_NULL_STRING),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      KEY_VALUE_NO_SAVE_AND_EXIT,\r
+      CurrentLocation\r
+      );\r
+\r
+    UpdateData->DataCount++;\r
+  }\r
+\r
+  CallbackData->Hii->UpdateForm (\r
+                      CallbackData->Hii,\r
+                      CallbackData->BmmHiiHandle,\r
+                      CallbackData->BmmCurrentPageId,\r
+                      TRUE,\r
+                      UpdateData\r
+                      );\r
+}\r
+\r
+VOID\r
+CleanUpPage (\r
+  IN EFI_FORM_LABEL                   LabelId,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  RefreshUpdateData (FALSE, 0, FALSE, 0, 0xff);\r
+\r
+  //\r
+  // Remove all op-codes from dynamic page\r
+  //\r
+  CallbackData->Hii->UpdateForm (\r
+                      CallbackData->Hii,\r
+                      CallbackData->BmmHiiHandle,\r
+                      LabelId,\r
+                      FALSE,\r
+                      UpdateData\r
+                      );\r
+}\r
+\r
+EFI_STATUS\r
+BootThisFile (\r
+  IN BM_FILE_CONTEXT                   *FileContext\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  UINTN             ExitDataSize;\r
+  CHAR16            *ExitData;\r
+  BDS_COMMON_OPTION *Option;\r
+\r
+  Status                  = gBS->AllocatePool (EfiBootServicesData, sizeof (BDS_COMMON_OPTION), &Option);\r
+  Option->Description     = FileContext->FileName;\r
+  Option->DevicePath      = FileContext->DevicePath;\r
+  Option->LoadOptionsSize = 0;\r
+  Option->LoadOptions     = NULL;\r
+\r
+  //\r
+  // Since current no boot from removable media directly is allowed */\r
+  //\r
+  gST->ConOut->ClearScreen (gST->ConOut);\r
+\r
+  ExitDataSize  = 0;\r
+\r
+  Status        = BdsLibBootViaBootOption (Option, Option->DevicePath, &ExitDataSize, &ExitData);\r
+\r
+  return Status;\r
+\r
+}\r
+\r
+VOID\r
+UpdateConCOMPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        Index;\r
+  UINT8         *Location;\r
+  EFI_STATUS    Status;\r
+  VOID         *Interface;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = FALSE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  Status = EfiLibLocateProtocol (&gTerminalDriverGuid, &Interface);\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+      NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
\r
+      CreateGotoOpCode (\r
+        FORM_CON_COM_SETUP_ID,\r
+        NewMenuEntry->DisplayStringToken,\r
+        STRING_TOKEN (STR_NULL_STRING),\r
+        EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+        (UINT16) (TERMINAL_OPTION_OFFSET + Index),\r
+        Location\r
+        );\r
+      Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+      UpdateData->DataCount++;\r
+    }\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateBootDelPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+  UINT16          Index;\r
+  UINT8           *Location;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
+\r
+  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+    NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
+    NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if (NewLoadContext->IsLegacy) {\r
+      continue;\r
+    }\r
+\r
+    NewLoadContext->Deleted = FALSE;\r
+    CallbackData->BmmFakeNvData->BootOptionDel[Index] = 0x00;\r
+\r
+    CreateCheckBoxOpCode (\r
+      (UINT16) (BOOT_OPTION_DEL_QUESTION_ID + Index),\r
+      (UINT8) 1,\r
+      NewMenuEntry->DisplayStringToken,\r
+      NewMenuEntry->HelpStringToken,\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      (UINT16) BOOT_OPTION_DEL_QUESTION_ID,\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+    UpdateData->DataCount++;\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateDrvAddHandlePage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        Index;\r
+  UINT8         *Location;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = FALSE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  for (Index = 0; Index < DriverMenu.MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index);\r
+\r
+    CreateGotoOpCode (\r
+      FORM_DRV_ADD_HANDLE_DESC_ID,\r
+      NewMenuEntry->DisplayStringToken,\r
+      STRING_TOKEN (STR_NULL_STRING),\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      (UINT16) (HANDLE_OPTION_OFFSET + Index),\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+    UpdateData->DataCount++;\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateDrvDelPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+  UINT16          Index;\r
+  UINT8           *Location;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &DriverOptionMenu);\r
+\r
+  for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
+    NewMenuEntry            = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
+\r
+    NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+    NewLoadContext->Deleted = FALSE;\r
+    CallbackData->BmmFakeNvData->DriverOptionDel[Index] = 0x00;\r
+\r
+    CreateCheckBoxOpCode (\r
+      (UINT16) (DRIVER_OPTION_DEL_QUESTION_ID + Index),\r
+      (UINT8) 1,\r
+      NewMenuEntry->DisplayStringToken,\r
+      NewMenuEntry->HelpStringToken,\r
+      EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+      (UINT16) DRIVER_OPTION_DEL_QUESTION_ID,\r
+      Location\r
+      );\r
+\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+    UpdateData->DataCount++;\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateDriverAddHandleDescPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT8         *Location;\r
+\r
+  Location  = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmFakeNvData->DriverAddActive          = 0x01;\r
+  CallbackData->BmmFakeNvData->DriverAddForceReconnect  = 0x00;\r
+  CallbackData->BmmAskSaveOrNot                         = TRUE;\r
+  NewMenuEntry = CallbackData->MenuEntry;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  UpdateData->DataCount += (UINT16) 4;\r
+\r
+  CreateSubTitleOpCode (\r
+    NewMenuEntry->DisplayStringToken,\r
+    Location\r
+    );\r
+\r
+  Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+  CreateStringOpCode (\r
+    DRV_ADD_HANDLE_DESC_QUESTION_ID,\r
+    (UINT8) 150,\r
+    STRING_TOKEN (STR_LOAD_OPTION_DESC),\r
+    STRING_TOKEN (STR_NULL_STRING),\r
+    6,\r
+    75,\r
+    EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+    KEY_VALUE_DRIVER_ADD_DESC_DATA,\r
+    Location\r
+    );\r
+\r
+  Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+  CreateCheckBoxOpCode (\r
+    DRV_ADD_RECON_QUESTION_ID,\r
+    (UINT8) 1,\r
+    STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),\r
+    STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),\r
+    EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+    DRV_ADD_RECON_QUESTION_ID,\r
+    Location\r
+    );\r
+  Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+  CreateStringOpCode (\r
+    DRIVER_ADD_OPTION_QUESTION_ID,\r
+    (UINT8) 150,\r
+    STRING_TOKEN (STR_OPTIONAL_DATA),\r
+    STRING_TOKEN (STR_NULL_STRING),\r
+    6,\r
+    75,\r
+    EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+    KEY_VALUE_DRIVER_ADD_OPT_DATA,\r
+    Location\r
+    );\r
+\r
+  Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateConsolePage (\r
+  IN UINT16                           UpdatePageId,\r
+  IN BM_MENU_OPTION                   *ConsoleMenu,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY       *NewMenuEntry;\r
+  BM_CONSOLE_CONTEXT  *NewConsoleContext;\r
+  BM_TERMINAL_CONTEXT *NewTerminalContext;\r
+  UINT16              Index;\r
+  UINT16              Index2;\r
+  UINT8               *Location;\r
+  UINT8               CheckFlags;\r
+  EFI_STATUS          Status;\r
+  VOID               *Interface;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {\r
+    NewMenuEntry      = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
+    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+    CheckFlags        = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (NewConsoleContext->IsActive) {\r
+      CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+      CallbackData->BmmFakeNvData->ConsoleCheck[Index] = TRUE;\r
+    } else {\r
+      CallbackData->BmmFakeNvData->ConsoleCheck[Index] = FALSE;\r
+    }\r
+\r
+    CreateCheckBoxOpCode (\r
+      (UINT16) (CON_DEVICE_QUESTION_ID + Index),\r
+      (UINT8) 1,\r
+      NewMenuEntry->DisplayStringToken,\r
+      NewMenuEntry->HelpStringToken,\r
+      CheckFlags,\r
+      (UINT16) (CONSOLE_OPTION_OFFSET + Index),\r
+      Location\r
+      );\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+    UpdateData->DataCount++;\r
+  }\r
+\r
+  Status = EfiLibLocateProtocol (&gTerminalDriverGuid, &Interface);\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index2 = 0; Index2 < TerminalMenu.MenuNumber; Index2++) {\r
+      CheckFlags          = EFI_IFR_FLAG_INTERACTIVE;\r
+      NewMenuEntry        = BOpt_GetMenuEntry (&TerminalMenu, Index2);\r
+      NewTerminalContext  = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+      if ((NewTerminalContext->IsConIn && (UpdatePageId == FORM_CON_IN_ID)) ||\r
+          (NewTerminalContext->IsConOut && (UpdatePageId == FORM_CON_OUT_ID)) ||\r
+          (NewTerminalContext->IsStdErr && (UpdatePageId == FORM_CON_ERR_ID))\r
+          ) {\r
+        CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+        CallbackData->BmmFakeNvData->ConsoleCheck[Index] = TRUE;\r
+      } else {\r
+        CallbackData->BmmFakeNvData->ConsoleCheck[Index] = FALSE;\r
+      }\r
+\r
+      CreateCheckBoxOpCode (\r
+        (UINT16) (CON_DEVICE_QUESTION_ID + Index),\r
+        (UINT8) 1,\r
+        NewMenuEntry->DisplayStringToken,\r
+        NewMenuEntry->HelpStringToken,\r
+        CheckFlags,\r
+        (UINT16) (CONSOLE_OPTION_OFFSET + Index),\r
+        Location\r
+        );\r
+      Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+      UpdateData->DataCount++;\r
+      Index++;\r
+    }\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateOrderPage (\r
+  IN UINT16                           UpdatePageId,\r
+  IN BM_MENU_OPTION                   *OptionMenu,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        Index;\r
+  UINT8         *Location;\r
+  IFR_OPTION    *IfrOptionList;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r
+\r
+  ZeroMem (CallbackData->BmmFakeNvData->OptionOrder, 100);\r
+\r
+  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * OptionMenu->MenuNumber);\r
+  if (NULL == IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (OptionMenu, Index);\r
+    IfrOptionList[Index].StringToken = NewMenuEntry->DisplayStringToken;\r
+    IfrOptionList[Index].Value = (UINT16) (NewMenuEntry->OptionNumber + 1);\r
+    IfrOptionList[Index].OptionString = NULL;\r
+    CallbackData->BmmFakeNvData->OptionOrder[Index] = (UINT8) (IfrOptionList[Index].Value);\r
+  }\r
+\r
+  if (OptionMenu->MenuNumber > 0) {\r
+    CreateOrderedListOpCode (\r
+      (UINT16) OPTION_ORDER_QUESTION_ID,\r
+      (UINT8) 100,\r
+      STRING_TOKEN (STR_CHANGE_ORDER),\r
+      STRING_TOKEN (STR_CHANGE_ORDER),\r
+      IfrOptionList,\r
+      OptionMenu->MenuNumber,\r
+      Location\r
+      );\r
+\r
+    for (Index = 0; Index < OptionMenu->MenuNumber + 2; Index++) {\r
+      Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+    }\r
+\r
+    UpdateData->DataCount = (UINT16) (UpdateData->DataCount + OptionMenu->MenuNumber + 2);\r
+  }\r
+\r
+  SafeFreePool (IfrOptionList);\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+\r
+  CopyMem (\r
+    CallbackData->BmmOldFakeNVData.OptionOrder,\r
+    CallbackData->BmmFakeNvData->OptionOrder,\r
+    100\r
+    );\r
+}\r
+\r
+VOID\r
+UpdateBootNextPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  UINT8           *Location;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+  IFR_OPTION      *IfrOptionList;\r
+  UINTN           NumberOfOptions;\r
+  UINT16          Index;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  IfrOptionList                 = NULL;\r
+  NumberOfOptions               = BootOptionMenu.MenuNumber;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
+\r
+  if (NumberOfOptions > 0) {\r
+    UpdateData->DataCount = (UINT8) (UpdateData->DataCount + NumberOfOptions);\r
+    IfrOptionList = AllocateZeroPool ((NumberOfOptions + 1) * sizeof (IFR_OPTION));\r
+\r
+    ASSERT (IfrOptionList);\r
+\r
+    CallbackData->BmmFakeNvData->BootNext = (UINT16) (BootOptionMenu.MenuNumber);\r
+\r
+    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+      NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
+      NewLoadContext  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+      if (NewLoadContext->IsBootNext) {\r
+        IfrOptionList[Index].Flags            = EFI_IFR_FLAG_DEFAULT | EFI_IFR_FLAG_INTERACTIVE;\r
+        CallbackData->BmmFakeNvData->BootNext = Index;\r
+      } else {\r
+        IfrOptionList[Index].Flags = EFI_IFR_FLAG_INTERACTIVE;\r
+      }\r
+\r
+      IfrOptionList[Index].Key          = (UINT16) KEY_VALUE_MAIN_BOOT_NEXT;\r
+      IfrOptionList[Index].Value        = Index;\r
+      IfrOptionList[Index].StringToken  = NewMenuEntry->DisplayStringToken;\r
+      IfrOptionList[Index].OptionString = NULL;\r
+    }\r
+\r
+    IfrOptionList[Index].Key          = (UINT16) KEY_VALUE_MAIN_BOOT_NEXT;\r
+    IfrOptionList[Index].Value        = Index;\r
+    IfrOptionList[Index].StringToken  = STRING_TOKEN (STR_NONE);\r
+    IfrOptionList[Index].Flags        = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (CallbackData->BmmFakeNvData->BootNext == Index) {\r
+      IfrOptionList[Index].Flags |= EFI_IFR_FLAG_DEFAULT;\r
+    }\r
+\r
+    IfrOptionList[Index].OptionString = NULL;\r
+\r
+    CreateOneOfOpCode (\r
+      (UINT16) BOOT_NEXT_QUESTION_ID,\r
+      (UINT8) 2,\r
+      STRING_TOKEN (STR_BOOT_NEXT),\r
+      STRING_TOKEN (STR_BOOT_NEXT_HELP),\r
+      IfrOptionList,\r
+      (UINTN) (NumberOfOptions + 1),\r
+      Location\r
+      );\r
+    Location  = Location + (NumberOfOptions + 2) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+    Location  = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+    UpdateData->DataCount += 3;\r
+    SafeFreePool (IfrOptionList);\r
+    IfrOptionList = NULL;\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateTimeOutPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  UINT8   *Location;\r
+  UINT16  BootTimeOut;\r
+\r
+  Location                      = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  BootTimeOut = BdsLibGetTimeout ();\r
+\r
+  CreateNumericOpCode (\r
+    (UINT16) BOOT_TIME_OUT_QUESTION_ID,\r
+    (UINT8) 2,\r
+    STRING_TOKEN (STR_NUM_AUTO_BOOT),\r
+    STRING_TOKEN (STR_HLP_AUTO_BOOT),\r
+    0,\r
+    65535,\r
+    0,\r
+    10,\r
+    0,\r
+    0,\r
+    Location\r
+    );\r
+\r
+  CallbackData->BmmFakeNvData->BootTimeOut = (UINT16) BootTimeOut;\r
+  UpdateData->DataCount++;\r
+  Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdateTerminalPage (\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  UINT16              Index;\r
+  UINT8               *Location;\r
+  UINT8               CheckFlags;\r
+  IFR_OPTION          *IfrOptionList;\r
+  BM_MENU_ENTRY       *NewMenuEntry;\r
+  BM_TERMINAL_CONTEXT *NewTerminalContext;\r
+\r
+  ZeroMem (UpdateData, UPDATE_DATA_SIZE);\r
+  Location = (UINT8 *) &UpdateData->Data;\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  NewMenuEntry = BOpt_GetMenuEntry (\r
+                  &TerminalMenu,\r
+                  CallbackData->CurrentTerminal\r
+                  );\r
+\r
+  if (!NewMenuEntry) {\r
+    return ;\r
+  }\r
+\r
+  NewTerminalContext  = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+\r
+  IfrOptionList       = AllocateZeroPool (sizeof (IFR_OPTION) * 19);\r
+  if (!IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < 19; Index++) {\r
+    CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (NewTerminalContext->BaudRate == (UINT64) (BaudRateList[Index].Value)) {\r
+      CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+      NewTerminalContext->BaudRateIndex         = (UINT8) Index;\r
+      CallbackData->BmmFakeNvData->COMBaudRate  = NewTerminalContext->BaudRateIndex;\r
+    }\r
+\r
+    IfrOptionList[Index].Flags        = CheckFlags;\r
+    IfrOptionList[Index].Key          = KEY_VALUE_COM_SET_BAUD_RATE;\r
+    IfrOptionList[Index].StringToken  = BaudRateList[Index].StringToken;\r
+    IfrOptionList[Index].Value        = Index;\r
+  }\r
+\r
+  CreateOneOfOpCode (\r
+    (UINT16) COM_BAUD_RATE_QUESTION_ID,\r
+    (UINT8) 1,\r
+    STRING_TOKEN (STR_COM_BAUD_RATE),\r
+    STRING_TOKEN (STR_COM_BAUD_RATE),\r
+    IfrOptionList,\r
+    19,\r
+    Location\r
+    );\r
+\r
+  Location              = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  Location              = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
+  UpdateData->DataCount += 2;\r
+\r
+  SafeFreePool (IfrOptionList);\r
+\r
+  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 4);\r
+  if (!IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < 4; Index++) {\r
+    CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
+\r
+    if (NewTerminalContext->DataBits == DataBitsList[Index].Value) {\r
+      NewTerminalContext->DataBitsIndex         = (UINT8) Index;\r
+      CallbackData->BmmFakeNvData->COMDataRate  = NewTerminalContext->DataBitsIndex;\r
+      CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+    }\r
+\r
+    IfrOptionList[Index].Flags        = CheckFlags;\r
+    IfrOptionList[Index].Key          = KEY_VALUE_COM_SET_DATA_BITS;\r
+    IfrOptionList[Index].StringToken  = DataBitsList[Index].StringToken;\r
+    IfrOptionList[Index].Value        = Index;\r
+  }\r
+\r
+  CreateOneOfOpCode (\r
+    (UINT16) COM_DATA_RATE_QUESTION_ID,\r
+    (UINT8) 1,\r
+    STRING_TOKEN (STR_COM_DATA_BITS),\r
+    STRING_TOKEN (STR_COM_DATA_BITS),\r
+    IfrOptionList,\r
+    4,\r
+    Location\r
+    );\r
+\r
+  Location              = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  Location              = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
+  UpdateData->DataCount += 2;\r
+\r
+  SafeFreePool (IfrOptionList);\r
+\r
+  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 5);\r
+  if (!IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < 5; Index++) {\r
+    CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (NewTerminalContext->Parity == ParityList[Index].Value) {\r
+      CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+      NewTerminalContext->ParityIndex         = (UINT8) Index;\r
+      CallbackData->BmmFakeNvData->COMParity  = NewTerminalContext->ParityIndex;\r
+    }\r
+\r
+    IfrOptionList[Index].Flags        = CheckFlags;\r
+    IfrOptionList[Index].Key          = KEY_VALUE_COM_SET_PARITY;\r
+    IfrOptionList[Index].StringToken  = ParityList[Index].StringToken;\r
+    IfrOptionList[Index].Value        = Index;\r
+  }\r
+\r
+  CreateOneOfOpCode (\r
+    (UINT16) COM_PARITY_QUESTION_ID,\r
+    (UINT8) 1,\r
+    STRING_TOKEN (STR_COM_PARITY),\r
+    STRING_TOKEN (STR_COM_PARITY),\r
+    IfrOptionList,\r
+    5,\r
+    Location\r
+    );\r
+\r
+  Location              = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  Location              = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
+  UpdateData->DataCount += 2;\r
+\r
+  SafeFreePool (IfrOptionList);\r
+\r
+  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 3);\r
+  if (!IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < 3; Index++) {\r
+    CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (NewTerminalContext->StopBits == StopBitsList[Index].Value) {\r
+      CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+      NewTerminalContext->StopBitsIndex         = (UINT8) Index;\r
+      CallbackData->BmmFakeNvData->COMStopBits  = NewTerminalContext->StopBitsIndex;\r
+    }\r
+\r
+    IfrOptionList[Index].Flags        = CheckFlags;\r
+    IfrOptionList[Index].Key          = KEY_VALUE_COM_SET_STOP_BITS;\r
+    IfrOptionList[Index].StringToken  = StopBitsList[Index].StringToken;\r
+    IfrOptionList[Index].Value        = Index;\r
+  }\r
+\r
+  CreateOneOfOpCode (\r
+    (UINT16) COM_STOP_BITS_QUESTION_ID,\r
+    (UINT8) 1,\r
+    STRING_TOKEN (STR_COM_STOP_BITS),\r
+    STRING_TOKEN (STR_COM_STOP_BITS),\r
+    IfrOptionList,\r
+    3,\r
+    Location\r
+    );\r
+\r
+  Location              = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  Location              = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
+  UpdateData->DataCount += 2;\r
+\r
+  SafeFreePool (IfrOptionList);\r
+\r
+  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 4);\r
+  if (!IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < 4; Index++) {\r
+    CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (NewTerminalContext->TerminalType == Index) {\r
+      CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
+      CallbackData->BmmFakeNvData->COMTerminalType = NewTerminalContext->TerminalType;\r
+    }\r
+\r
+    IfrOptionList[Index].Flags        = CheckFlags;\r
+    IfrOptionList[Index].Key          = KEY_VALUE_COM_SET_TERMI_TYPE;\r
+    IfrOptionList[Index].StringToken  = (STRING_REF) TerminalType[Index];\r
+    IfrOptionList[Index].Value        = Index;\r
+  }\r
+\r
+  CreateOneOfOpCode (\r
+    (UINT16) COM_TERMINAL_QUESTION_ID,\r
+    (UINT8) 1,\r
+    STRING_TOKEN (STR_COM_TERMI_TYPE),\r
+    STRING_TOKEN (STR_COM_TERMI_TYPE),\r
+    IfrOptionList,\r
+    4,\r
+    Location\r
+    );\r
+\r
+  Location              = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  Location              = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
+  UpdateData->DataCount += 2;\r
+\r
+  SafeFreePool (IfrOptionList);\r
+\r
+  CreateGotoOpCode (\r
+    FORM_MAIN_ID,\r
+    STRING_TOKEN (STR_SAVE_AND_EXIT),\r
+    STRING_TOKEN (STR_NULL_STRING),\r
+    EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+    KEY_VALUE_SAVE_AND_EXIT,\r
+    Location\r
+    );\r
+\r
+  Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+  UpdateData->DataCount++;\r
+\r
+  CreateGotoOpCode (\r
+    FORM_MAIN_ID,\r
+    STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
+    STRING_TOKEN (STR_NULL_STRING),\r
+    EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
+    KEY_VALUE_NO_SAVE_AND_EXIT,\r
+    Location\r
+    );\r
+\r
+  UpdateData->DataCount++;\r
+\r
+  CallbackData->Hii->UpdateForm (\r
+                      CallbackData->Hii,\r
+                      CallbackData->BmmHiiHandle,\r
+                      (EFI_FORM_LABEL) FORM_CON_COM_SETUP_ID,\r
+                      TRUE,\r
+                      UpdateData\r
+                      );\r
+\r
+}\r
+\r
+VOID\r
+UpdatePageBody (\r
+  IN UINT16                           UpdatePageId,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  CleanUpPage (UpdatePageId, CallbackData);\r
+  switch (UpdatePageId) {\r
+  case FORM_CON_IN_ID:\r
+    UpdateConsolePage (UpdatePageId, &ConsoleInpMenu, CallbackData);\r
+    break;\r
+\r
+  case FORM_CON_OUT_ID:\r
+    UpdateConsolePage (UpdatePageId, &ConsoleOutMenu, CallbackData);\r
+    break;\r
+\r
+  case FORM_CON_ERR_ID:\r
+    UpdateConsolePage (UpdatePageId, &ConsoleErrMenu, CallbackData);\r
+    break;\r
+\r
+  case FORM_BOOT_CHG_ID:\r
+    UpdateOrderPage (UpdatePageId, &BootOptionMenu, CallbackData);\r
+    break;\r
+\r
+  case FORM_DRV_CHG_ID:\r
+    UpdateOrderPage (UpdatePageId, &DriverOptionMenu, CallbackData);\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+}\r
+\r
+VOID *\r
+GetLegacyBootOptionVar (\r
+  IN  UINTN                            DeviceType,\r
+  OUT UINTN                            *OptionIndex,\r
+  OUT UINTN                            *OptionSize\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  VOID                      *OptionBuffer;\r
+  UINTN                     OrderSize;\r
+  UINTN                     Index;\r
+  UINT32                    Attribute;\r
+  UINT16                    *OrderBuffer;\r
+  CHAR16                    StrTemp[100];\r
+  UINT16                    FilePathSize;\r
+  CHAR16                    *Description;\r
+  UINT8                     *Ptr;\r
+  UINT8                     *OptionalData;\r
+\r
+  //\r
+  // Get Boot Option number from the size of BootOrder\r
+  //\r
+  OrderBuffer = BdsLibGetVariableAndSize (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  &OrderSize\r
+                  );\r
+\r
+  for (Index = 0; Index < OrderSize / sizeof (UINT16); Index++) {\r
+    UnicodeSPrint (StrTemp, 100, L"Boot%04x", OrderBuffer[Index]);\r
+    OptionBuffer = BdsLibGetVariableAndSize (\r
+                    StrTemp,\r
+                    &gEfiGlobalVariableGuid,\r
+                    OptionSize\r
+                    );\r
+    if (NULL == OptionBuffer) {\r
+      continue;\r
+    }\r
+\r
+    Ptr       = (UINT8 *) OptionBuffer;\r
+    Attribute = *(UINT32 *) Ptr;\r
+    Ptr += sizeof (UINT32);\r
+\r
+    FilePathSize = *(UINT16 *) Ptr;\r
+    Ptr += sizeof (UINT16);\r
+\r
+    Description = (CHAR16 *) Ptr;\r
+    Ptr += StrSize ((CHAR16 *) Ptr);\r
+\r
+    //\r
+    // Now Ptr point to Device Path\r
+    //\r
+    DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
+    Ptr += FilePathSize;\r
+\r
+    //\r
+    // Now Ptr point to Optional Data\r
+    //\r
+    OptionalData = Ptr;\r
+\r
+    if ((DeviceType == ((BBS_TABLE *) OptionalData)->DeviceType) &&\r
+        (BBS_DEVICE_PATH == DevicePath->Type) &&\r
+        (BBS_BBS_DP == DevicePath->SubType)\r
+        ) {\r
+      *OptionIndex = OrderBuffer[Index];\r
+      SafeFreePool (OrderBuffer);\r
+      return OptionBuffer;\r
+    } else {\r
+      SafeFreePool (OptionBuffer);\r
+    }\r
+  }\r
+\r
+  SafeFreePool (OrderBuffer);\r
+  return NULL;\r
+}\r
+\r
+VOID\r
+UpdateSetLegacyDeviceOrderPage (\r
+  IN UINT16                           UpdatePageId,\r
+  IN BMM_CALLBACK_DATA                *CallbackData\r
+  )\r
+{\r
+  BM_LEGACY_DEV_ORDER_CONTEXT *DevOrder;\r
+  BM_MENU_OPTION              *OptionMenu;\r
+  BM_MENU_ENTRY               *NewMenuEntry;\r
+  IFR_OPTION                  *IfrOptionList;\r
+  STRING_REF                  StrRef;\r
+  STRING_REF                  StrRefHelp;\r
+  BBS_TYPE                    BbsType;\r
+  UINTN                       VarSize;\r
+  UINTN                       Pos;\r
+  UINTN                       Bit;\r
+  UINT16                      Index;\r
+  UINT16                      Index2;\r
+  UINT16                      Key;\r
+  CHAR16                      String[100];\r
+  CHAR16                      *TypeStr;\r
+  CHAR16                      *TypeStrHelp;\r
+  UINT16                      VarDevOrder;\r
+  UINT8                       *Location;\r
+  UINT8                       *VarData;\r
+  UINT8                       *OriginalPtr;\r
+  UINT8                       *LegacyOrder;\r
+  UINT8                       *OldData;\r
+  UINT8                       *DisMap;\r
+\r
+  OptionMenu                    = NULL;\r
+  Key = 0;\r
+  StrRef = 0;\r
+  StrRefHelp = 0;\r
+  TypeStr = NULL;\r
+  TypeStrHelp = NULL;\r
+  BbsType = BBS_FLOPPY;\r
+  LegacyOrder = NULL;\r
+  OldData = NULL;\r
+  DisMap = NULL;\r
+\r
+  Location = (UINT8 *) &UpdateData->Data;\r
+  CallbackData->BmmAskSaveOrNot = TRUE;\r
+\r
+  UpdatePageStart (CallbackData, &Location);\r
+\r
+  DisMap = CallbackData->BmmOldFakeNVData.DisableMap;\r
+\r
+  SetMem (DisMap, 32, 0);\r
+  //\r
+  // Create oneof option list\r
+  //\r
+  switch (UpdatePageId) {\r
+  case FORM_SET_FD_ORDER_ID:\r
+    OptionMenu  = (BM_MENU_OPTION *) &LegacyFDMenu;\r
+    Key         = LEGACY_FD_QUESTION_ID;\r
+    TypeStr     = StrFloppy;\r
+    TypeStrHelp = StrFloppyHelp;\r
+    BbsType     = BBS_FLOPPY;\r
+    LegacyOrder = CallbackData->BmmFakeNvData->LegacyFD;\r
+    OldData     = CallbackData->BmmOldFakeNVData.LegacyFD;\r
+    break;\r
+\r
+  case FORM_SET_HD_ORDER_ID:\r
+    OptionMenu  = (BM_MENU_OPTION *) &LegacyHDMenu;\r
+    Key         = LEGACY_HD_QUESTION_ID;\r
+    TypeStr     = StrHardDisk;\r
+    TypeStrHelp = StrHardDiskHelp;\r
+    BbsType     = BBS_HARDDISK;\r
+    LegacyOrder = CallbackData->BmmFakeNvData->LegacyHD;\r
+    OldData     = CallbackData->BmmOldFakeNVData.LegacyHD;\r
+    break;\r
+\r
+  case FORM_SET_CD_ORDER_ID:\r
+    OptionMenu  = (BM_MENU_OPTION *) &LegacyCDMenu;\r
+    Key         = LEGACY_CD_QUESTION_ID;\r
+    TypeStr     = StrCDROM;\r
+    TypeStrHelp = StrCDROMHelp;\r
+    BbsType     = BBS_CDROM;\r
+    LegacyOrder = CallbackData->BmmFakeNvData->LegacyCD;\r
+    OldData     = CallbackData->BmmOldFakeNVData.LegacyCD;\r
+    break;\r
+\r
+  case FORM_SET_NET_ORDER_ID:\r
+    OptionMenu  = (BM_MENU_OPTION *) &LegacyNETMenu;\r
+    Key         = LEGACY_NET_QUESTION_ID;\r
+    TypeStr     = StrNET;\r
+    TypeStrHelp = StrNETHelp;\r
+    BbsType     = BBS_EMBED_NETWORK;\r
+    LegacyOrder = CallbackData->BmmFakeNvData->LegacyNET;\r
+    OldData     = CallbackData->BmmOldFakeNVData.LegacyNET;\r
+    break;\r
+\r
+  case FORM_SET_BEV_ORDER_ID:\r
+    OptionMenu  = (BM_MENU_OPTION *) &LegacyBEVMenu;\r
+    Key         = LEGACY_BEV_QUESTION_ID;\r
+    TypeStr     = StrBEV;\r
+    TypeStrHelp = StrBEVHelp;\r
+    BbsType     = BBS_BEV_DEVICE;\r
+    LegacyOrder = CallbackData->BmmFakeNvData->LegacyBEV;\r
+    OldData     = CallbackData->BmmOldFakeNVData.LegacyBEV;\r
+    break;\r
+\r
+  }\r
+\r
+  CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r
+\r
+  IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * (OptionMenu->MenuNumber + 1));\r
+  if (NULL == IfrOptionList) {\r
+    return ;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
+    NewMenuEntry                = BOpt_GetMenuEntry (OptionMenu, Index);\r
+    IfrOptionList[Index].Flags  = EFI_IFR_FLAG_INTERACTIVE;\r
+    if (0 == Index) {\r
+      IfrOptionList[Index].Flags |= EFI_IFR_FLAG_DEFAULT;\r
+    }\r
+\r
+    IfrOptionList[Index].Key          = Key;\r
+    IfrOptionList[Index].StringToken  = NewMenuEntry->DisplayStringToken;\r
+    IfrOptionList[Index].Value        = (UINT16) ((BM_LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext)->Index;\r
+    IfrOptionList[Index].OptionString = NULL;\r
+  }\r
+  //\r
+  // for item "Disabled"\r
+  //\r
+  IfrOptionList[Index].Flags        = EFI_IFR_FLAG_INTERACTIVE;\r
+  IfrOptionList[Index].Key          = Key;\r
+  IfrOptionList[Index].StringToken  = STRING_TOKEN (STR_DISABLE_LEGACY_DEVICE);\r
+  IfrOptionList[Index].Value        = 0xFF;\r
+  IfrOptionList[Index].OptionString = NULL;\r
+\r
+  //\r
+  // Get Device Order from variable\r
+  //\r
+  VarData = BdsLibGetVariableAndSize (\r
+              VarLegacyDevOrder,\r
+              &EfiLegacyDevOrderGuid,\r
+              &VarSize\r
+              );\r
+\r
+  if (NULL != VarData) {\r
+    OriginalPtr = VarData;\r
+    DevOrder    = (BM_LEGACY_DEV_ORDER_CONTEXT *) VarData;\r
+    while (VarData < VarData + VarSize) {\r
+      if (DevOrder->BbsType == BbsType) {\r
+        break;\r
+      }\r
+\r
+      VarData += sizeof (BBS_TYPE);\r
+      VarData += *(UINT16 *) VarData;\r
+      DevOrder = (BM_LEGACY_DEV_ORDER_CONTEXT *) VarData;\r
+    }\r
+    //\r
+    // Create oneof tag here for FD/HD/CD #1 #2\r
+    //\r
+    for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
+      for (Index2 = 0; Index2 <= OptionMenu->MenuNumber; Index2++) {\r
+        IfrOptionList[Index2].Key = (UINT16) (Key + Index);\r
+      }\r
+      //\r
+      // Create the string for oneof tag\r
+      //\r
+      UnicodeSPrint (String, sizeof (String), TypeStr, Index);\r
+      StrRef = 0;\r
+      CallbackData->Hii->NewString (\r
+                          CallbackData->Hii,\r
+                          NULL,\r
+                          CallbackData->BmmHiiHandle,\r
+                          &StrRef,\r
+                          String\r
+                          );\r
+\r
+      UnicodeSPrint (String, sizeof (String), TypeStrHelp, Index);\r
+      StrRefHelp = 0;\r
+      CallbackData->Hii->NewString (\r
+                          CallbackData->Hii,\r
+                          NULL,\r
+                          CallbackData->BmmHiiHandle,\r
+                          &StrRefHelp,\r
+                          String\r
+                          );\r
+\r
+      CreateOneOfOpCode (\r
+        (UINT16) (Key + Index),\r
+        (UINT8) 1,\r
+        StrRef,\r
+        StrRefHelp,\r
+        IfrOptionList,\r
+        OptionMenu->MenuNumber + 1,\r
+        Location\r
+        );\r
+\r
+      VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof (UINT16));\r
+\r
+      if (0xFF00 == (VarDevOrder & 0xFF00)) {\r
+        LegacyOrder[Index]  = 0xFF;\r
+        Pos                 = (VarDevOrder & 0xFF) / 8;\r
+        Bit                 = 7 - ((VarDevOrder & 0xFF) % 8);\r
+        DisMap[Pos] |= (UINT8) (1 << Bit);\r
+      } else {\r
+        LegacyOrder[Index] = (UINT8) (VarDevOrder & 0xFF);\r
+      }\r
+\r
+      Location              = Location + (OptionMenu->MenuNumber + 2) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+      Location              = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+      UpdateData->DataCount = (UINT16) (UpdateData->DataCount + (OptionMenu->MenuNumber + 3));\r
+    }\r
+  }\r
+\r
+  CopyMem (\r
+    OldData,\r
+    LegacyOrder,\r
+    100\r
+    );\r
+\r
+  if (IfrOptionList != NULL) {\r
+    SafeFreePool (IfrOptionList);\r
+    IfrOptionList = NULL;\r
+  }\r
+\r
+  UpdatePageEnd (CallbackData, Location);\r
+}\r
+\r
+VOID\r
+UpdatePageId (\r
+  BMM_CALLBACK_DATA              *Private,\r
+  UINT16                         NewPageId\r
+  )\r
+{\r
+  UINT16  FileOptionMask;\r
+\r
+  FileOptionMask = (UINT16) (FILE_OPTION_MASK & NewPageId);\r
+\r
+  if ((NewPageId < FILE_OPTION_OFFSET) && (NewPageId >= HANDLE_OPTION_OFFSET)) {\r
+    //\r
+    // If we select a handle to add driver option, advance to the add handle description page.\r
+    //\r
+    NewPageId = FORM_DRV_ADD_HANDLE_DESC_ID;\r
+  } else if ((NewPageId == KEY_VALUE_SAVE_AND_EXIT) || (NewPageId == KEY_VALUE_NO_SAVE_AND_EXIT)) {\r
+    //\r
+    // Return to main page after "Save Changes" or "Discard Changes".\r
+    //\r
+    NewPageId = FORM_MAIN_ID;\r
+  }\r
+\r
+  if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {\r
+    Private->BmmPreviousPageId  = Private->BmmCurrentPageId;\r
+    Private->BmmCurrentPageId   = NewPageId;\r
+  }\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Variable.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMaint/Variable.c
new file mode 100644 (file)
index 0000000..c660e40
--- /dev/null
@@ -0,0 +1,1279 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  Variable operation that will be used by BootMaint\r
+\r
+--*/\r
+\r
+#include "Generic/Bds.h"\r
+#include "BootMaint.h"\r
+#include "BdsPlatform.h"\r
+\r
+EFI_STATUS\r
+Var_DelBootOption (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Delete Boot Option that represent a Deleted state in BootOptionMenu.\r
+  After deleting this boot option, call Var_ChangeBootOrder to\r
+  make sure BootOrder is in valid state.\r
+  \r
+Arguments:\r
+  LoadOption -- Pointer to the boot option that to be deleted\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  Others\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+\r
+  UINT16          BootString[10];\r
+  EFI_STATUS      Status;\r
+  UINTN           Index;\r
+  UINTN           Index2;\r
+\r
+  Status  = EFI_SUCCESS;\r
+  Index2  = 0;\r
+  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, (Index - Index2));\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if (!NewLoadContext->Deleted) {\r
+      continue;\r
+    }\r
+\r
+    UnicodeSPrint (\r
+      BootString,\r
+      sizeof (BootString),\r
+      L"Boot%04x",\r
+      NewMenuEntry->OptionNumber\r
+      );\r
+\r
+    EfiLibDeleteVariable (BootString, &gEfiGlobalVariableGuid);\r
+    Index2++;\r
+    //\r
+    // If current Load Option is the same as BootNext,\r
+    // must delete BootNext in order to make sure\r
+    // there will be no panic on next boot\r
+    //\r
+    if (NewLoadContext->IsBootNext) {\r
+      EfiLibDeleteVariable (L"BootNext", &gEfiGlobalVariableGuid);\r
+    }\r
+\r
+    RemoveEntryList (&NewMenuEntry->Link);\r
+    BOpt_DestroyMenuEntry (NewMenuEntry);\r
+    NewMenuEntry = NULL;\r
+  }\r
+\r
+  BootOptionMenu.MenuNumber -= Index2;\r
+\r
+  Status = Var_ChangeBootOrder ();\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+Var_ChangeBootOrder (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  After any operation on Boot####, there will be a discrepancy in BootOrder.\r
+  Since some are missing but in BootOrder, while some are present but are \r
+  not reflected by BootOrder. Then a function rebuild BootOrder from \r
+  scratch by content from BootOptionMenu is needed.\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  Others\r
+  \r
+--*/\r
+{\r
+\r
+  EFI_STATUS    Status;\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        *BootOrderList;\r
+  UINT16        *BootOrderListPtr;\r
+  UINTN         BootOrderListSize;\r
+  UINTN         Index;\r
+\r
+  BootOrderList     = NULL;\r
+  BootOrderListSize = 0;\r
+\r
+  //\r
+  // First check whether BootOrder is present in current configuration\r
+  //\r
+  BootOrderList = BdsLibGetVariableAndSize (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    &BootOrderListSize\r
+                    );\r
+\r
+  //\r
+  // If exists, delete it to hold new BootOrder\r
+  //\r
+  if (BootOrderList) {\r
+    EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+    SafeFreePool (BootOrderList);\r
+    BootOrderList = NULL;\r
+  }\r
+  //\r
+  // Maybe here should be some check method to ensure that\r
+  // no new added boot options will be added\r
+  // but the setup engine now will give only one callback\r
+  // that is to say, user are granted only one chance to\r
+  // decide whether the boot option will be added or not\r
+  // there should be no indictor to show whether this\r
+  // is a "new" boot option\r
+  //\r
+  BootOrderListSize = BootOptionMenu.MenuNumber;\r
+\r
+  if (BootOrderListSize > 0) {\r
+    BootOrderList = AllocateZeroPool (BootOrderListSize * sizeof (UINT16));\r
+    ASSERT (BootOrderList != NULL);\r
+    BootOrderListPtr = BootOrderList;\r
+\r
+    //\r
+    // Get all current used Boot#### from BootOptionMenu.\r
+    // OptionNumber in each BM_LOAD_OPTION is really its\r
+    // #### value.\r
+    //\r
+    for (Index = 0; Index < BootOrderListSize; Index++) {\r
+      NewMenuEntry    = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
+      *BootOrderList  = (UINT16) NewMenuEntry->OptionNumber;\r
+      BootOrderList++;\r
+    }\r
+\r
+    BootOrderList = BootOrderListPtr;\r
+\r
+    //\r
+    // After building the BootOrderList, write it back\r
+    //\r
+    Status = gRT->SetVariable (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    BootOrderListSize * sizeof (UINT16),\r
+                    BootOrderList\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Var_DelDriverOption (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Delete Load Option that represent a Deleted state in BootOptionMenu.\r
+  After deleting this Driver option, call Var_ChangeDriverOrder to\r
+  make sure DriverOrder is in valid state.\r
+  \r
+Arguments:\r
+  LoadOption -- Pointer to the Driver option that to be deleted\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  Others\r
+  \r
+--*/\r
+{\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+\r
+  UINT16          DriverString[12];\r
+  EFI_STATUS      Status;\r
+  UINTN           Index;\r
+  UINTN           Index2;\r
+\r
+  Status  = EFI_SUCCESS;\r
+  Index2  = 0;\r
+  for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, (Index - Index2));\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if (!NewLoadContext->Deleted) {\r
+      continue;\r
+    }\r
+\r
+    UnicodeSPrint (\r
+      DriverString,\r
+      sizeof (DriverString),\r
+      L"Driver%04x",\r
+      NewMenuEntry->OptionNumber\r
+      );\r
+\r
+    EfiLibDeleteVariable (DriverString, &gEfiGlobalVariableGuid);\r
+    Index2++;\r
+\r
+    RemoveEntryList (&NewMenuEntry->Link);\r
+    BOpt_DestroyMenuEntry (NewMenuEntry);\r
+    NewMenuEntry = NULL;\r
+  }\r
+\r
+  DriverOptionMenu.MenuNumber -= Index2;\r
+\r
+  Status = Var_ChangeDriverOrder ();\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+Var_ChangeDriverOrder (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  After any operation on Driver####, there will be a discrepancy in \r
+  DriverOrder. Since some are missing but in DriverOrder, while some \r
+  are present but are not reflected by DriverOrder. Then a function \r
+  rebuild DriverOrder from scratch by content from DriverOptionMenu is \r
+  needed.\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+  EFI_SUCCESS\r
+  Others\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS    Status;\r
+  BM_MENU_ENTRY *NewMenuEntry;\r
+  UINT16        *DriverOrderList;\r
+  UINT16        *DriverOrderListPtr;\r
+  UINTN         DriverOrderListSize;\r
+  UINTN         Index;\r
+\r
+  DriverOrderList     = NULL;\r
+  DriverOrderListSize = 0;\r
+\r
+  //\r
+  // First check whether DriverOrder is present in current configuration\r
+  //\r
+  DriverOrderList = BdsLibGetVariableAndSize (\r
+                      L"DriverOrder",\r
+                      &gEfiGlobalVariableGuid,\r
+                      &DriverOrderListSize\r
+                      );\r
+\r
+  //\r
+  // If exists, delete it to hold new DriverOrder\r
+  //\r
+  if (DriverOrderList) {\r
+    EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
+    SafeFreePool (DriverOrderList);\r
+    DriverOrderList = NULL;\r
+  }\r
+\r
+  DriverOrderListSize = DriverOptionMenu.MenuNumber;\r
+\r
+  if (DriverOrderListSize > 0) {\r
+    DriverOrderList = AllocateZeroPool (DriverOrderListSize * sizeof (UINT16));\r
+    ASSERT (DriverOrderList != NULL);\r
+    DriverOrderListPtr = DriverOrderList;\r
+\r
+    //\r
+    // Get all current used Driver#### from DriverOptionMenu.\r
+    // OptionNumber in each BM_LOAD_OPTION is really its\r
+    // #### value.\r
+    //\r
+    for (Index = 0; Index < DriverOrderListSize; Index++) {\r
+      NewMenuEntry      = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
+      *DriverOrderList  = (UINT16) NewMenuEntry->OptionNumber;\r
+      DriverOrderList++;\r
+    }\r
+\r
+    DriverOrderList = DriverOrderListPtr;\r
+\r
+    //\r
+    // After building the DriverOrderList, write it back\r
+    //\r
+    Status = gRT->SetVariable (\r
+                    L"DriverOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    DriverOrderListSize * sizeof (UINT16),\r
+                    DriverOrderList\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+Var_UpdateAllConsoleOption (\r
+  VOID\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;\r
+  EFI_STATUS                Status;\r
+\r
+  OutDevicePath = EfiLibGetVariable (L"ConOut", &gEfiGlobalVariableGuid);\r
+  InpDevicePath = EfiLibGetVariable (L"ConIn", &gEfiGlobalVariableGuid);\r
+  ErrDevicePath = EfiLibGetVariable (L"ErrOut", &gEfiGlobalVariableGuid);\r
+  if (OutDevicePath) {\r
+    ChangeVariableDevicePath (OutDevicePath);\r
+    Status = gRT->SetVariable (\r
+                    L"ConOut",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    GetDevicePathSize (OutDevicePath),\r
+                    OutDevicePath\r
+                    );\r
+    ASSERT (!EFI_ERROR (Status));\r
+  }\r
+\r
+  if (InpDevicePath) {\r
+    ChangeVariableDevicePath (InpDevicePath);\r
+    Status = gRT->SetVariable (\r
+                    L"ConIn",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    GetDevicePathSize (InpDevicePath),\r
+                    InpDevicePath\r
+                    );\r
+    ASSERT (!EFI_ERROR (Status));\r
+  }\r
+\r
+  if (ErrDevicePath) {\r
+    ChangeVariableDevicePath (ErrDevicePath);\r
+    Status = gRT->SetVariable (\r
+                    L"ErrOut",\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    GetDevicePathSize (ErrDevicePath),\r
+                    ErrDevicePath\r
+                    );\r
+    ASSERT (!EFI_ERROR (Status));\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateConsoleOption (\r
+  IN UINT16                     *ConsoleName,\r
+  IN BM_MENU_OPTION             *ConsoleMenu,\r
+  IN UINT16                     UpdatePageId\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *ConDevicePath;\r
+  BM_MENU_ENTRY             *NewMenuEntry;\r
+  BM_CONSOLE_CONTEXT        *NewConsoleContext;\r
+  BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
+  EFI_STATUS                Status;\r
+  VENDOR_DEVICE_PATH        Vendor;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TerminalDevicePath;\r
+  UINTN                     Index;\r
+  UINT16                    *Temp;\r
+\r
+  ConDevicePath = EfiLibGetVariable (ConsoleName, &gEfiGlobalVariableGuid);\r
+  if (ConDevicePath != NULL) {\r
+    EfiLibDeleteVariable (ConsoleName, &gEfiGlobalVariableGuid);\r
+    SafeFreePool (ConDevicePath);\r
+    ConDevicePath = NULL;\r
+  };\r
+\r
+  //\r
+  // First add all console input device to it from console input menu\r
+  //\r
+  for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if (NewConsoleContext->IsActive) {\r
+      ConDevicePath = AppendDevicePathInstance (\r
+                        ConDevicePath,\r
+                        NewConsoleContext->DevicePath\r
+                        );\r
+    }\r
+  }\r
+\r
+  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if ((NewTerminalContext->IsConIn && (UpdatePageId == FORM_CON_IN_ID)) ||\r
+        (NewTerminalContext->IsConOut && (UpdatePageId == FORM_CON_OUT_ID)) ||\r
+        (NewTerminalContext->IsStdErr && (UpdatePageId == FORM_CON_ERR_ID))\r
+        ) {\r
+      Vendor.Header.Type    = MESSAGING_DEVICE_PATH;\r
+      Vendor.Header.SubType = MSG_VENDOR_DP;\r
+      CopyMem (\r
+        &Vendor.Guid,\r
+        &Guid[NewTerminalContext->TerminalType],\r
+        sizeof (EFI_GUID)\r
+        );\r
+      SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));\r
+      TerminalDevicePath = AppendDevicePathNode (\r
+                            NewTerminalContext->DevicePath,\r
+                            (EFI_DEVICE_PATH_PROTOCOL *) &Vendor\r
+                            );\r
+      ChangeTerminalDevicePath (TerminalDevicePath, TRUE);\r
+      Temp = DevicePathToStr (TerminalDevicePath);\r
+      ConDevicePath = AppendDevicePathInstance (\r
+                        ConDevicePath,\r
+                        TerminalDevicePath\r
+                        );\r
+    }\r
+  }\r
+\r
+  if (ConDevicePath) {\r
+    Status = gRT->SetVariable (\r
+                    ConsoleName,\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    GetDevicePathSize (ConDevicePath),\r
+                    ConDevicePath\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateConsoleInpOption (\r
+  VOID\r
+  )\r
+{\r
+  return Var_UpdateConsoleOption (L"ConIn", &ConsoleInpMenu, FORM_CON_IN_ID);\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateConsoleOutOption (\r
+  VOID\r
+  )\r
+{\r
+  return Var_UpdateConsoleOption (L"ConOut", &ConsoleOutMenu, FORM_CON_OUT_ID);\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateErrorOutOption (\r
+  VOID\r
+  )\r
+{\r
+  return Var_UpdateConsoleOption (L"ErrOut", &ConsoleErrMenu, FORM_CON_ERR_ID);\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateDriverOption (\r
+  IN  BMM_CALLBACK_DATA         *CallbackData,\r
+  IN  EFI_HII_HANDLE            HiiHandle,\r
+  IN  UINT16                    *DescriptionData,\r
+  IN  UINT16                    *OptionalData,\r
+  IN  UINT8                     ForceReconnect\r
+  )\r
+{\r
+  UINT16          Index;\r
+  UINT16          *DriverOrderList;\r
+  UINT16          *NewDriverOrderList;\r
+  UINT16          DriverString[12];\r
+  UINTN           DriverOrderListSize;\r
+  VOID            *Buffer;\r
+  UINTN           BufferSize;\r
+  UINT8           *Ptr;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+  BOOLEAN         OptionalDataExist;\r
+  EFI_STATUS      Status;\r
+\r
+  OptionalDataExist = FALSE;\r
+\r
+  Index             = BOpt_GetDriverOptionNumber ();\r
+  UnicodeSPrint (\r
+    DriverString,\r
+    sizeof (DriverString),\r
+    L"Driver%04x",\r
+    Index\r
+    );\r
+\r
+  if (*DescriptionData == 0x0000) {\r
+    StrCpy (DescriptionData, DriverString);\r
+  }\r
+\r
+  BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescriptionData) + GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
+\r
+  if (*OptionalData != 0x0000) {\r
+    OptionalDataExist = TRUE;\r
+    BufferSize += StrSize (OptionalData);\r
+  }\r
+\r
+  Buffer = AllocateZeroPool (BufferSize);\r
+  if (NULL == Buffer) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
+  if (NULL == NewMenuEntry) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+  NewLoadContext->Deleted         = FALSE;\r
+  NewLoadContext->LoadOptionSize  = BufferSize;\r
+  Ptr = (UINT8 *) Buffer;\r
+  NewLoadContext->LoadOption = Ptr;\r
+  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE | (ForceReconnect << 1);\r
+  NewLoadContext->Attributes = *((UINT32 *) Ptr);\r
+  NewLoadContext->IsActive = TRUE;\r
+  NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
+\r
+  Ptr += sizeof (UINT32);\r
+  *((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
+  NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);\r
+\r
+  Ptr += sizeof (UINT16);\r
+  CopyMem (\r
+    Ptr,\r
+    DescriptionData,\r
+    StrSize (DescriptionData)\r
+    );\r
+\r
+  NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData));\r
+  ASSERT (NewLoadContext->Description != NULL);\r
+  NewMenuEntry->DisplayString = NewLoadContext->Description;\r
+  CopyMem (\r
+    NewLoadContext->Description,\r
+    (VOID *) Ptr,\r
+    StrSize (DescriptionData)\r
+    );\r
+\r
+  Ptr += StrSize (DescriptionData);\r
+  CopyMem (\r
+    Ptr,\r
+    CallbackData->LoadContext->FilePathList,\r
+    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
+    );\r
+\r
+  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
+  ASSERT (NewLoadContext->FilePathList != NULL);\r
+\r
+  CopyMem (\r
+    NewLoadContext->FilePathList,\r
+    (VOID *) Ptr,\r
+    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
+    );\r
+\r
+  NewMenuEntry->HelpString    = DevicePathToStr (NewLoadContext->FilePathList);\r
+  NewMenuEntry->OptionNumber  = Index;\r
+  NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
+                                      CallbackData,\r
+                                      DriverOptionStrDepository\r
+                                      );\r
+  CallbackData->Hii->NewString (\r
+                      CallbackData->Hii,\r
+                      NULL,\r
+                      HiiHandle,\r
+                      &NewMenuEntry->DisplayStringToken,\r
+                      NewMenuEntry->DisplayString\r
+                      );\r
+\r
+  NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
+                                    CallbackData,\r
+                                    DriverOptionHelpStrDepository\r
+                                    );\r
+  CallbackData->Hii->NewString (\r
+                      CallbackData->Hii,\r
+                      NULL,\r
+                      HiiHandle,\r
+                      &NewMenuEntry->HelpStringToken,\r
+                      NewMenuEntry->HelpString\r
+                      );\r
+\r
+  if (OptionalDataExist) {\r
+    Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
+\r
+    CopyMem (\r
+      Ptr,\r
+      OptionalData,\r
+      StrSize (OptionalData)\r
+      );\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  DriverString,\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  BufferSize,\r
+                  Buffer\r
+                  );\r
+  DriverOrderList = BdsLibGetVariableAndSize (\r
+                      L"DriverOrder",\r
+                      &gEfiGlobalVariableGuid,\r
+                      &DriverOrderListSize\r
+                      );\r
+  NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));\r
+  ASSERT (NewDriverOrderList != NULL);\r
+  CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);\r
+  NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;\r
+  if (DriverOrderList != NULL) {\r
+    EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  L"DriverOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  DriverOrderListSize + sizeof (UINT16),\r
+                  NewDriverOrderList\r
+                  );\r
+  SafeFreePool (DriverOrderList);\r
+  DriverOrderList = NULL;\r
+  SafeFreePool (NewDriverOrderList);\r
+  NewDriverOrderList = NULL;\r
+  InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
+  DriverOptionMenu.MenuNumber++;\r
+\r
+  *DescriptionData  = 0x0000;\r
+  *OptionalData     = 0x0000;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateBootOption (\r
+  IN  BMM_CALLBACK_DATA                   *CallbackData,\r
+  IN  FILE_EXPLORER_NV_DATA               *NvRamMap\r
+  )\r
+{\r
+  UINT16          *BootOrderList;\r
+  UINT16          *NewBootOrderList;\r
+  UINTN           BootOrderListSize;\r
+  UINT16          BootString[10];\r
+  VOID            *Buffer;\r
+  UINTN           BufferSize;\r
+  UINT8           *Ptr;\r
+  UINT16          Index;\r
+  BM_MENU_ENTRY   *NewMenuEntry;\r
+  BM_LOAD_CONTEXT *NewLoadContext;\r
+  BOOLEAN         OptionalDataExist;\r
+  EFI_STATUS      Status;\r
+\r
+  OptionalDataExist = FALSE;\r
+\r
+  Index             = BOpt_GetBootOptionNumber ();\r
+  UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);\r
+\r
+  if (NvRamMap->DescriptionData[0] == 0x0000) {\r
+    StrCpy (NvRamMap->DescriptionData, BootString);\r
+  }\r
+\r
+  BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->DescriptionData) + GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
+\r
+  if (NvRamMap->OptionalData[0] != 0x0000) {\r
+    OptionalDataExist = TRUE;\r
+    BufferSize += StrSize (NvRamMap->OptionalData);\r
+  }\r
+\r
+  Buffer = AllocateZeroPool (BufferSize);\r
+  if (NULL == Buffer) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
+  if (NULL == NewMenuEntry) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+  NewLoadContext->Deleted         = FALSE;\r
+  NewLoadContext->LoadOptionSize  = BufferSize;\r
+  Ptr = (UINT8 *) Buffer;\r
+  NewLoadContext->LoadOption = Ptr;\r
+  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE;\r
+  NewLoadContext->Attributes = *((UINT32 *) Ptr);\r
+  NewLoadContext->IsActive = TRUE;\r
+  NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);\r
+\r
+  Ptr += sizeof (UINT32);\r
+  *((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
+  NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);\r
+  Ptr += sizeof (UINT16);\r
+\r
+  CopyMem (\r
+    Ptr,\r
+    NvRamMap->DescriptionData,\r
+    StrSize (NvRamMap->DescriptionData)\r
+    );\r
+\r
+  NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->DescriptionData));\r
+  ASSERT (NewLoadContext->Description != NULL);\r
+\r
+  NewMenuEntry->DisplayString = NewLoadContext->Description;\r
+  CopyMem (\r
+    NewLoadContext->Description,\r
+    (VOID *) Ptr,\r
+    StrSize (NvRamMap->DescriptionData)\r
+    );\r
+\r
+  Ptr += StrSize (NvRamMap->DescriptionData);\r
+  CopyMem (\r
+    Ptr,\r
+    CallbackData->LoadContext->FilePathList,\r
+    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
+    );\r
+\r
+  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
+  ASSERT (NewLoadContext->FilePathList != NULL);\r
+\r
+  CopyMem (\r
+    NewLoadContext->FilePathList,\r
+    (VOID *) Ptr,\r
+    GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
+    );\r
+\r
+  NewMenuEntry->HelpString    = DevicePathToStr (NewLoadContext->FilePathList);\r
+  NewMenuEntry->OptionNumber  = Index;\r
+  NewMenuEntry->DisplayStringToken = GetStringTokenFromDepository (\r
+                                      CallbackData,\r
+                                      BootOptionStrDepository\r
+                                      );\r
+  CallbackData->Hii->NewString (\r
+                      CallbackData->Hii,\r
+                      NULL,\r
+                      CallbackData->FeHiiHandle,\r
+                      &NewMenuEntry->DisplayStringToken,\r
+                      NewMenuEntry->DisplayString\r
+                      );\r
+\r
+  NewMenuEntry->HelpStringToken = GetStringTokenFromDepository (\r
+                                    CallbackData,\r
+                                    BootOptionHelpStrDepository\r
+                                    );\r
+\r
+  CallbackData->Hii->NewString (\r
+                      CallbackData->Hii,\r
+                      NULL,\r
+                      CallbackData->FeHiiHandle,\r
+                      &NewMenuEntry->HelpStringToken,\r
+                      NewMenuEntry->HelpString\r
+                      );\r
+\r
+  if (OptionalDataExist) {\r
+    Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
+\r
+    CopyMem (Ptr, NvRamMap->OptionalData, StrSize (NvRamMap->OptionalData));\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  BootString,\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  BufferSize,\r
+                  Buffer\r
+                  );\r
+\r
+  BootOrderList = BdsLibGetVariableAndSize (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    &BootOrderListSize\r
+                    );\r
+\r
+  NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));\r
+  ASSERT (NewBootOrderList != NULL);\r
+  CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);\r
+  NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;\r
+\r
+  if (BootOrderList != NULL) {\r
+    EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  BootOrderListSize + sizeof (UINT16),\r
+                  NewBootOrderList\r
+                  );\r
+\r
+  SafeFreePool (BootOrderList);\r
+  BootOrderList = NULL;\r
+  SafeFreePool (NewBootOrderList);\r
+  NewBootOrderList = NULL;\r
+  InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
+  BootOptionMenu.MenuNumber++;\r
+\r
+  NvRamMap->DescriptionData[0]  = 0x0000;\r
+  NvRamMap->OptionalData[0]     = 0x0000;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateBootNext (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  )\r
+{\r
+  BM_MENU_ENTRY     *NewMenuEntry;\r
+  BM_LOAD_CONTEXT   *NewLoadContext;\r
+  BMM_FAKE_NV_DATA  *CurrentFakeNVMap;\r
+  UINT16            Index;\r
+  EFI_STATUS        Status;\r
+\r
+  Status            = EFI_SUCCESS;\r
+  CurrentFakeNVMap  = CallbackData->BmmFakeNvData;\r
+  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+    NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
+    if (NULL == NewMenuEntry) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    NewLoadContext              = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+    NewLoadContext->IsBootNext  = FALSE;\r
+  }\r
+\r
+  if (CurrentFakeNVMap->BootNext == BootOptionMenu.MenuNumber) {\r
+    EfiLibDeleteVariable (L"BootNext", &gEfiGlobalVariableGuid);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  NewMenuEntry = BOpt_GetMenuEntry (\r
+                  &BootOptionMenu,\r
+                  CurrentFakeNVMap->BootNext\r
+                  );\r
+  if (NULL == NewMenuEntry) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
+  Status = gRT->SetVariable (\r
+                  L"BootNext",\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  sizeof (UINT16),\r
+                  &NewMenuEntry->OptionNumber\r
+                  );\r
+  NewLoadContext->IsBootNext              = TRUE;\r
+  CallbackData->BmmOldFakeNVData.BootNext = CurrentFakeNVMap->BootNext;\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateBootOrder (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT16      Index;\r
+  UINT16      *BootOrderList;\r
+  UINT16      *NewBootOrderList;\r
+  UINTN       BootOrderListSize;\r
+  UINT8       *Map;\r
+\r
+  BootOrderList     = NULL;\r
+  BootOrderListSize = 0;\r
+\r
+  //\r
+  // First check whether BootOrder is present in current configuration\r
+  //\r
+  BootOrderList = BdsLibGetVariableAndSize (\r
+                    L"BootOrder",\r
+                    &gEfiGlobalVariableGuid,\r
+                    &BootOrderListSize\r
+                    );\r
+\r
+  NewBootOrderList = AllocateZeroPool (BootOrderListSize);\r
+  if (!NewBootOrderList) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Map = AllocateZeroPool (BootOrderListSize / sizeof (UINT16));\r
+  if (!Map) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // If exists, delete it to hold new BootOrder\r
+  //\r
+  if (BootOrderList) {\r
+    EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+  }\r
+\r
+  for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+    NewBootOrderList[Index] = CallbackData->BmmFakeNvData->OptionOrder[Index] - 1;\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  BootOrderListSize,\r
+                  NewBootOrderList\r
+                  );\r
+  SafeFreePool (BootOrderList);\r
+  SafeFreePool (NewBootOrderList);\r
+  SafeFreePool (Map);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  BOpt_FreeMenu (&BootOptionMenu);\r
+  BOpt_GetBootOptions (CallbackData);\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateDriverOrder (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT16      Index;\r
+  UINT16      *DriverOrderList;\r
+  UINT16      *NewDriverOrderList;\r
+  UINTN       DriverOrderListSize;\r
+\r
+  DriverOrderList     = NULL;\r
+  DriverOrderListSize = 0;\r
+\r
+  //\r
+  // First check whether DriverOrder is present in current configuration\r
+  //\r
+  DriverOrderList = BdsLibGetVariableAndSize (\r
+                      L"DriverOrder",\r
+                      &gEfiGlobalVariableGuid,\r
+                      &DriverOrderListSize\r
+                      );\r
+\r
+  NewDriverOrderList = AllocateZeroPool (DriverOrderListSize);\r
+\r
+  if (!NewDriverOrderList) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // If exists, delete it to hold new DriverOrder\r
+  //\r
+  if (DriverOrderList) {\r
+    EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
+  }\r
+\r
+  for (Index = 0; Index < DriverOrderListSize; Index++) {\r
+    NewDriverOrderList[Index] = CallbackData->BmmFakeNvData->OptionOrder[Index] - 1;\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  L"DriverOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  VAR_FLAG,\r
+                  DriverOrderListSize,\r
+                  NewDriverOrderList\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  SafeFreePool (DriverOrderList);\r
+\r
+  BOpt_FreeMenu (&DriverOptionMenu);\r
+  BOpt_GetDriverOptions (CallbackData);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+Var_UpdateBBSOption (\r
+  IN BMM_CALLBACK_DATA            *CallbackData\r
+  )\r
+{\r
+  UINTN                       Index;\r
+  UINTN                       Index2;\r
+  VOID                        *BootOptionVar;\r
+  CHAR16                      VarName[100];\r
+  UINTN                       OptionSize;\r
+  UINT16                      FilePathSize;\r
+  UINT8                       *Ptr;\r
+  EFI_STATUS                  Status;\r
+  CHAR16                      DescString[100];\r
+  UINTN                       NewOptionSize;\r
+  UINT8                       *NewOptionPtr;\r
+  UINT8                       *TempPtr;\r
+  UINT32                      *Attribute;\r
+\r
+  BM_MENU_OPTION              *OptionMenu;\r
+  BM_LEGACY_DEVICE_CONTEXT    *LegacyDeviceContext;\r
+  UINT8                       *LegacyDev;\r
+  UINT8                       *VarData;\r
+  UINTN                       VarSize;\r
+  BM_MENU_ENTRY               *NewMenuEntry;\r
+  BM_LEGACY_DEV_ORDER_CONTEXT *DevOrder;\r
+  UINT8                       *OriginalPtr;\r
+  UINT8                       *DisMap;\r
+  UINTN                       Pos;\r
+  UINTN                       Bit;\r
+  UINT16                      *NewOrder;\r
+  UINT16                      Tmp;\r
+\r
+  LegacyDeviceContext = NULL;\r
+  DisMap              = NULL;\r
+  NewOrder            = NULL;\r
+\r
+  if (FORM_SET_FD_ORDER_ID == CallbackData->BmmPreviousPageId) {\r
+    OptionMenu            = (BM_MENU_OPTION *) &LegacyFDMenu;\r
+    LegacyDev             = CallbackData->BmmFakeNvData->LegacyFD;\r
+    CallbackData->BbsType = BBS_FLOPPY;\r
+  } else {\r
+    if (FORM_SET_HD_ORDER_ID == CallbackData->BmmPreviousPageId) {\r
+      OptionMenu            = (BM_MENU_OPTION *) &LegacyHDMenu;\r
+      LegacyDev             = CallbackData->BmmFakeNvData->LegacyHD;\r
+      CallbackData->BbsType = BBS_HARDDISK;\r
+    } else {\r
+      if (FORM_SET_CD_ORDER_ID == CallbackData->BmmPreviousPageId) {\r
+        OptionMenu            = (BM_MENU_OPTION *) &LegacyCDMenu;\r
+        LegacyDev             = CallbackData->BmmFakeNvData->LegacyCD;\r
+        CallbackData->BbsType = BBS_CDROM;\r
+      } else {\r
+        if (FORM_SET_NET_ORDER_ID == CallbackData->BmmPreviousPageId) {\r
+          OptionMenu            = (BM_MENU_OPTION *) &LegacyNETMenu;\r
+          LegacyDev             = CallbackData->BmmFakeNvData->LegacyNET;\r
+          CallbackData->BbsType = BBS_EMBED_NETWORK;\r
+        } else {\r
+          OptionMenu            = (BM_MENU_OPTION *) &LegacyBEVMenu;\r
+          LegacyDev             = CallbackData->BmmFakeNvData->LegacyBEV;\r
+          CallbackData->BbsType = BBS_BEV_DEVICE;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  DisMap  = CallbackData->BmmOldFakeNVData.DisableMap;\r
+  Status  = EFI_SUCCESS;\r
+\r
+  //\r
+  // Find the first device's context\r
+  // If all devices are disabled( 0xFF == LegacyDev[0]), LegacyDeviceContext can be set to any VariableContext\r
+  // because we just use it to fill the desc string, and user can not see the string in UI\r
+  //\r
+  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
+    NewMenuEntry        = BOpt_GetMenuEntry (OptionMenu, Index);\r
+    LegacyDeviceContext = (BM_LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext;\r
+    if (0xFF != LegacyDev[0] && LegacyDev[0] == LegacyDeviceContext->Index) {\r
+      DEBUG ((EFI_D_ERROR, "DescStr: %s\n", LegacyDeviceContext->Description));\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Update the Variable "LegacyDevOrder"\r
+  //\r
+  VarData = (UINT8 *) BdsLibGetVariableAndSize (\r
+                        VarLegacyDevOrder,\r
+                        &EfiLegacyDevOrderGuid,\r
+                        &VarSize\r
+                        );\r
+\r
+  if (NULL == VarData) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  OriginalPtr = VarData;\r
+  DevOrder    = (BM_LEGACY_DEV_ORDER_CONTEXT *) VarData;\r
+\r
+  while (VarData < VarData + VarSize) {\r
+    if (DevOrder->BbsType == CallbackData->BbsType) {\r
+      break;\r
+    }\r
+\r
+    VarData += sizeof (BBS_TYPE);\r
+    VarData += *(UINT16 *) VarData;\r
+    DevOrder = (BM_LEGACY_DEV_ORDER_CONTEXT *) VarData;\r
+  }\r
+\r
+  if (VarData >= VarData + VarSize) {\r
+    SafeFreePool (OriginalPtr);\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  NewOrder = (UINT16 *) AllocateZeroPool (DevOrder->Length - sizeof (UINT16));\r
+  if (NULL == NewOrder) {\r
+    SafeFreePool (VarData);\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
+    if (0xFF == LegacyDev[Index]) {\r
+      break;\r
+    }\r
+\r
+    NewOrder[Index] = LegacyDev[Index];\r
+  }\r
+  //\r
+  // Only the enable/disable state of each boot device with same device type can be changed,\r
+  // so we can count on the index information in DevOrder.\r
+  // DisMap bit array is the only reliable source to check a device's en/dis state,\r
+  // so we use DisMap to set en/dis state of each item in NewOrder array\r
+  //\r
+  for (Index2 = 0; Index2 < OptionMenu->MenuNumber; Index2++) {\r
+    Tmp = *(UINT16 *) ((UINT8 *) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16) + Index2 * sizeof (UINT16));\r
+    Tmp &= 0xFF;\r
+    Pos = Tmp / 8;\r
+    Bit = 7 - (Tmp % 8);\r
+    if (DisMap[Pos] & (1 << Bit)) {\r
+      NewOrder[Index] = (UINT16) (0xFF00 | Tmp);\r
+      Index++;\r
+    }\r
+  }\r
+\r
+  CopyMem (\r
+    (UINT8 *) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16),\r
+    NewOrder,\r
+    DevOrder->Length - sizeof (UINT16)\r
+    );\r
+  SafeFreePool (NewOrder);\r
+\r
+  Status = gRT->SetVariable (\r
+                  VarLegacyDevOrder,\r
+                  &EfiLegacyDevOrderGuid,\r
+                  VAR_FLAG,\r
+                  VarSize,\r
+                  OriginalPtr\r
+                  );\r
+\r
+  SafeFreePool (OriginalPtr);\r
+\r
+  //\r
+  // Update Optional Data of Boot####\r
+  //\r
+  BootOptionVar = GetLegacyBootOptionVar (CallbackData->BbsType, &Index, &OptionSize);\r
+\r
+  if (NULL != BootOptionVar) {\r
+    CopyMem (\r
+      DescString,\r
+      LegacyDeviceContext->Description,\r
+      StrSize (LegacyDeviceContext->Description)\r
+      );\r
+\r
+    NewOptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescString) + sizeof (BBS_TABLE) + sizeof (UINT16);\r
+\r
+    UnicodeSPrint (VarName, 100, L"Boot%04x", Index);\r
+\r
+    Ptr       = BootOptionVar;\r
+\r
+    Attribute = (UINT32 *) Ptr;\r
+    *Attribute |= LOAD_OPTION_ACTIVE;\r
+    if (0xFF == LegacyDev[0]) {\r
+      //\r
+      // Disable this legacy boot option\r
+      //\r
+      *Attribute &= ~LOAD_OPTION_ACTIVE;\r
+    }\r
+\r
+    Ptr += sizeof (UINT32);\r
+\r
+    FilePathSize = *(UINT16 *) Ptr;\r
+    Ptr += sizeof (UINT16);\r
+\r
+    NewOptionSize += FilePathSize;\r
+\r
+    NewOptionPtr = AllocateZeroPool (NewOptionSize);\r
+    if (NULL == NewOptionPtr) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    TempPtr = NewOptionPtr;\r
+\r
+    //\r
+    // Copy previous option data to new option except the description string\r
+    //\r
+    CopyMem (\r
+      TempPtr,\r
+      BootOptionVar,\r
+      sizeof (UINT32) + sizeof (UINT16)\r
+      );\r
+\r
+    TempPtr += (sizeof (UINT32) + sizeof (UINT16));\r
+\r
+    CopyMem (\r
+      TempPtr,\r
+      DescString,\r
+      StrSize (DescString)\r
+      );\r
+\r
+    TempPtr += StrSize (DescString);\r
+\r
+    //\r
+    // Description = (CHAR16 *)Ptr;\r
+    //\r
+    Ptr += StrSize ((CHAR16 *) Ptr);\r
+\r
+    CopyMem (\r
+      TempPtr,\r
+      Ptr,\r
+      FilePathSize\r
+      );\r
+\r
+    TempPtr += FilePathSize;\r
+\r
+    //\r
+    // DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Ptr;\r
+    //\r
+    Ptr += FilePathSize;\r
+\r
+    //\r
+    // Now Ptr point to optional data, i.e. Bbs Table\r
+    //\r
+    CopyMem (\r
+      TempPtr,\r
+      LegacyDeviceContext->BbsTable,\r
+      sizeof (BBS_TABLE)\r
+      );\r
+\r
+    TempPtr += sizeof (BBS_TABLE);\r
+    *((UINT16 *) TempPtr) = (UINT16) LegacyDeviceContext->Index;\r
+\r
+    Status = gRT->SetVariable (\r
+                    VarName,\r
+                    &gEfiGlobalVariableGuid,\r
+                    VAR_FLAG,\r
+                    NewOptionSize,\r
+                    NewOptionPtr\r
+                    );\r
+\r
+    SafeFreePool (NewOptionPtr);\r
+    SafeFreePool (BootOptionVar);\r
+  }\r
+\r
+  BOpt_GetBootOptions (CallbackData);\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManager.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManager.c
new file mode 100644 (file)
index 0000000..23b8789
--- /dev/null
@@ -0,0 +1,355 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  BootManager.c\r
+\r
+Abstract:\r
+\r
+  The platform boot manager reference implement\r
+\r
+--*/\r
+#include "BootManager.h"\r
+\r
+UINT16                            mKeyInput;\r
+LIST_ENTRY                        *mBootOptionsList;\r
+BDS_COMMON_OPTION                 *gOption;\r
+EFI_HII_HANDLE                    gBootManagerHandle;\r
+EFI_HANDLE                        BootManagerCallbackHandle;\r
+EFI_FORM_CALLBACK_PROTOCOL        BootManagerCallback;\r
+EFI_GUID                          gBmGuid = BOOT_MANAGER_GUID;\r
+\r
+extern EFI_FORM_BROWSER_PROTOCOL  *gBrowser;\r
+extern UINT8                      BootManagerVfrBin[];\r
+extern UINT8                      BdsStrings[];\r
+extern BOOLEAN                    gConnectAllHappened;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootManagerCallbackRoutine (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *DataArray,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the function that is called to provide results data to the driver.  This data\r
+  consists of a unique key which is used to identify what data is either being passed back\r
+  or being asked for. \r
+\r
+Arguments:\r
+\r
+  KeyValue -        A unique value which is sent to the original exporting driver so that it\r
+                    can identify the type of data to expect.  The format of the data tends to\r
+                    vary based on the op-code that geerated the callback.\r
+\r
+  Data -            A pointer to the data being sent to the original exporting driver.\r
+\r
+Returns: \r
+\r
+--*/\r
+{\r
+  BDS_COMMON_OPTION       *Option;\r
+  LIST_ENTRY              *Link;\r
+  UINT16                  KeyCount;\r
+  EFI_HII_CALLBACK_PACKET *DataPacket;\r
+\r
+  //\r
+  // Initialize the key count\r
+  //\r
+  KeyCount = 0;\r
+\r
+  for (Link = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) {\r
+    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+\r
+    KeyCount++;\r
+\r
+    gOption = Option;\r
+\r
+    //\r
+    // Is this device the one chosen?\r
+    //\r
+    if (KeyCount == KeyValue) {\r
+      //\r
+      // Assigning the returned Key to a global allows the original routine to know what was chosen\r
+      //\r
+      mKeyInput = KeyValue;\r
+\r
+      *Packet   = AllocateZeroPool (sizeof (EFI_HII_CALLBACK_PACKET) + 2);\r
+      ASSERT (*Packet != NULL);\r
+\r
+      //\r
+      // Assign the buffer address to DataPacket\r
+      //\r
+      DataPacket                        = *Packet;\r
+\r
+      DataPacket->DataArray.EntryCount  = 1;\r
+      DataPacket->DataArray.NvRamMap    = NULL;\r
+      ((EFI_IFR_DATA_ENTRY *) (((EFI_IFR_DATA_ARRAY *)DataPacket) + 1))->Flags = EXIT_REQUIRED | NV_NOT_CHANGED;\r
+      return EFI_SUCCESS;\r
+    } else {\r
+      continue;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+CallBootManager (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Hook to enable UI timeout override behavior.\r
+\r
+Arguments:\r
+  BdsDeviceList - Device List that BDS needs to connect.\r
+\r
+  Entry - Pointer to current Boot Entry.\r
+\r
+Returns:\r
+  NONE\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_HII_PACKAGES    *PackageList;\r
+  BDS_COMMON_OPTION   *Option;\r
+  LIST_ENTRY          *Link;\r
+  EFI_HII_UPDATE_DATA *UpdateData;\r
+  CHAR16              *ExitData;\r
+  UINTN               ExitDataSize;\r
+  STRING_REF          Token;\r
+  STRING_REF          LastToken;\r
+  EFI_INPUT_KEY       Key;\r
+  UINT8               *Location;\r
+  EFI_GUID            BmGuid;\r
+  LIST_ENTRY          BdsBootOptionList;\r
+  BOOLEAN                BootMngrMenuResetRequired;\r
+\r
+  gOption = NULL;\r
+  InitializeListHead (&BdsBootOptionList);\r
+\r
+  //\r
+  // Connect all prior to entering the platform setup menu.\r
+  //\r
+  if (!gConnectAllHappened) {\r
+    BdsLibConnectAllDriversToAllControllers ();\r
+    gConnectAllHappened = TRUE;\r
+  }\r
+  //\r
+  // BugBug: Here we can not remove the legacy refresh macro, so we need\r
+  // get the boot order every time from "BootOrder" variable.\r
+  // Recreate the boot option list base on the BootOrder variable\r
+  //\r
+  BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r
+\r
+  //\r
+  // This GUID must be the same as what is defined in BootManagerVfr.vfr\r
+  //\r
+  BmGuid            = gBmGuid;\r
+\r
+  mBootOptionsList  = &BdsBootOptionList;\r
+\r
+  //\r
+  // Post our VFR to the HII database\r
+  //\r
+  PackageList = PreparePackages (2, &BmGuid, BootManagerVfrBin, BdsStrings);\r
+  Status      = Hii->NewPack (Hii, PackageList, &gBootManagerHandle);\r
+  gBS->FreePool (PackageList);\r
+\r
+  //\r
+  // This example does not implement worker functions\r
+  // for the NV accessor functions.  Only a callback evaluator\r
+  //\r
+  BootManagerCallback.NvRead    = NULL;\r
+  BootManagerCallback.NvWrite   = NULL;\r
+  BootManagerCallback.Callback  = BootManagerCallbackRoutine;\r
+\r
+  //\r
+  // Install protocol interface\r
+  //\r
+  BootManagerCallbackHandle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &BootManagerCallbackHandle,\r
+                  &gEfiFormCallbackProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &BootManagerCallback\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  LastToken = 0;\r
+  Hii->NewString (Hii, NULL, gBootManagerHandle, &LastToken, L" ");\r
+\r
+  //\r
+  // Allocate space for creation of UpdateData Buffer\r
+  //\r
+  UpdateData = AllocateZeroPool (0x1000);\r
+  ASSERT (UpdateData != NULL);\r
+\r
+  //\r
+  // Flag update pending in FormSet\r
+  //\r
+  UpdateData->FormSetUpdate = TRUE;\r
+  //\r
+  // Register CallbackHandle data for FormSet\r
+  //\r
+  UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) BootManagerCallbackHandle;\r
+  UpdateData->FormUpdate  = FALSE;\r
+  UpdateData->FormTitle   = 0;\r
+  UpdateData->DataCount   = 1;\r
+\r
+  //\r
+  // Create blank space.  Since when we update the contents of IFR data at a label, it is\r
+  // inserted at the location of the label.  So if you want to add a string with an empty\r
+  // space afterwards, you need to add the space first and then the string like below.\r
+  //\r
+  Status = CreateSubTitleOpCode (\r
+            LastToken,        // Token Value for the string\r
+            &UpdateData->Data // Buffer containing created op-code\r
+            );\r
+\r
+  Hii->UpdateForm (Hii, gBootManagerHandle, (EFI_FORM_LABEL) 0x0000, TRUE, UpdateData);\r
+\r
+  //\r
+  // Create "Boot Option Menu" title\r
+  //\r
+  Status = CreateSubTitleOpCode (\r
+            STRING_TOKEN (STR_BOOT_OPTION_BANNER),  // Token Value for the string\r
+            &UpdateData->Data                       // Buffer containing created op-code\r
+            );\r
+\r
+  Hii->UpdateForm (Hii, gBootManagerHandle, (EFI_FORM_LABEL) 0x0000, TRUE, UpdateData);\r
+\r
+  Token                 = LastToken;\r
+  mKeyInput             = 0;\r
+\r
+  UpdateData->DataCount = 0;\r
+  Location              = (UINT8 *) &UpdateData->Data;\r
+\r
+  for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) {\r
+    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+\r
+    //\r
+    // At this stage we are creating a menu entry, thus the Keys are reproduceable\r
+    //\r
+    mKeyInput++;\r
+    Token++;\r
+\r
+    Status = Hii->NewString (Hii, NULL, gBootManagerHandle, &Token, Option->Description);\r
+\r
+    //\r
+    // If we got an error it is almost certainly due to the token value being invalid.\r
+    // Therefore we will set the Token to 0 to automatically add a token.\r
+    //\r
+    if (EFI_ERROR (Status)) {\r
+      Token   = 0;\r
+      Status  = Hii->NewString (Hii, NULL, gBootManagerHandle, &Token, Option->Description);\r
+    }\r
+\r
+    Status = CreateGotoOpCode (\r
+              0x1000, // Form ID\r
+              Token,  // Token Value for the string\r
+              0,      // Help String (none)\r
+              EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,  // The Op-Code flags\r
+              mKeyInput,                                          // The Key to get a callback on\r
+              Location  // Buffer containing created op-code\r
+              );\r
+\r
+    UpdateData->DataCount++;\r
+    Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
+\r
+  }\r
+\r
+  Hii->UpdateForm (Hii, gBootManagerHandle, (EFI_FORM_LABEL) 0x0001, TRUE, UpdateData);\r
+\r
+  UpdateData->DataCount = 1;\r
+\r
+  //\r
+  // Create "Boot Option Menu" title\r
+  //\r
+  Status = CreateSubTitleOpCode (\r
+            STRING_TOKEN (STR_HELP_FOOTER), // Token Value for the string\r
+            &UpdateData->Data               // Buffer containing created op-code\r
+            );\r
+\r
+  Hii->UpdateForm (Hii, gBootManagerHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);\r
+\r
+  Status = CreateSubTitleOpCode (\r
+            LastToken,                      // Token Value for the string\r
+            &UpdateData->Data               // Buffer containing created op-code\r
+            );\r
+\r
+  Hii->UpdateForm (Hii, gBootManagerHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);\r
+\r
+  gBS->FreePool (UpdateData);\r
+\r
+  ASSERT (gBrowser);\r
+\r
+  BootMngrMenuResetRequired = FALSE;\r
+  gBrowser->SendForm (\r
+              gBrowser, \r
+              TRUE, \r
+              &gBootManagerHandle, \r
+              1, \r
+              NULL, \r
+              NULL, \r
+              NULL, \r
+              NULL, \r
+              &BootMngrMenuResetRequired\r
+              );\r
+\r
+  if (BootMngrMenuResetRequired) {\r
+    EnableResetRequired ();\r
+  }\r
+\r
+  Hii->ResetStrings (Hii, gBootManagerHandle);\r
+\r
+  if (gOption == NULL) {\r
+    return ;\r
+  }\r
+  \r
+  //\r
+  //Will leave browser, check any reset required change is applied? if yes, reset system\r
+  //\r
+  SetupResetReminder ();\r
+  \r
+  //\r
+  // BugBug: This code looks repeated from the BDS. Need to save code space.\r
+  //\r
+\r
+  //\r
+  // parse the selected option\r
+  //\r
+  Status = BdsLibBootViaBootOption (gOption, gOption->DevicePath, &ExitDataSize, &ExitData);\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    PlatformBdsBootSuccess (gOption);\r
+  } else {\r
+    PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize);\r
+    gST->ConOut->OutputString (\r
+                  gST->ConOut,\r
+                  GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))\r
+                  );\r
+\r
+    //\r
+    // BdsLibUiWaitForSingleEvent (gST->ConIn->WaitForKey, 0);\r
+    //\r
+\r
+    gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+  }\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManager.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManager.h
new file mode 100644 (file)
index 0000000..3a90932
--- /dev/null
@@ -0,0 +1,50 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  BootManager.h\r
+\r
+Abstract:\r
+\r
+  The platform boot manager reference implement\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _EFI_BOOT_MANAGER_H\r
+#define _EFI_BOOT_MANAGER_H\r
+\r
+#include "Generic/Bds.h"\r
+#include "BdsPlatform.h"\r
+#include "Generic/String.h"\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+BootManagerCallbackRoutine (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *DataArray,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  );\r
+\r
+VOID\r
+CallBootManager (\r
+  VOID\r
+);\r
+\r
+#define BOOT_MANAGER_GUID \\r
+  { \\r
+    0x847bc3fe, 0xb974, 0x446d, {0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b } \\r
+  }\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerStrings.uni b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerStrings.uni
new file mode 100644 (file)
index 0000000..684ac2f
Binary files /dev/null and b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerStrings.uni differ
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerVfr.Vfr b/EdkUnixPkg/Dxe/PlatformBds/Generic/BootMngr/BootManagerVfr.Vfr
new file mode 100644 (file)
index 0000000..7fb193a
--- /dev/null
@@ -0,0 +1,55 @@
+// *++\r
+//\r
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//   BootManager.vfr \r
+// \r
+// Abstract:\r
+// \r
+//   Browser formset.\r
+// \r
+// Revision History: \r
+// \r
+// --*/\r
+\r
+#include "BdsStrDefs.h"\r
+\r
+#define FORMSET_GUID  { 0x847bc3fe, 0xb974, 0x446d, { 0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b } } \r
+\r
+#define BOOT_MANAGER_HEADER             0x00\r
+#define BOOT_MANAGER_LABEL              0x01\r
+#define BOOT_MANAGER_TAIL               0x02\r
+\r
+\r
+#define BOOT_MANAGER_CLASS       0x00\r
+#define BOOT_MANAGER_SUBCLASS    0x01\r
+\r
+formset \r
+  guid     = FORMSET_GUID,\r
+  title    = STRING_TOKEN(STR_BM_BANNER),  \r
+  help     = STRING_TOKEN(STR_LAST_STRING),\r
+  class    = BOOT_MANAGER_CLASS,      \r
+  subclass = BOOT_MANAGER_SUBCLASS,\r
+\r
+  form formid = 0x1000,\r
+       title  = STRING_TOKEN(STR_BM_BANNER);\r
+\r
+    label BOOT_MANAGER_HEADER;\r
+    label BOOT_MANAGER_LABEL;\r
+    //\r
+    // This is where we will dynamically add choices for the Boot Manager\r
+    //\r
+\r
+    label BOOT_MANAGER_TAIL;\r
+  endform;\r
+\r
+endformset;\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/Capsules.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/Capsules.c
new file mode 100644 (file)
index 0000000..b253166
--- /dev/null
@@ -0,0 +1,213 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Capsules.c\r
+\r
+Abstract:\r
+\r
+  BDS routines to handle capsules.\r
+\r
+--*/\r
+\r
+\r
+#include <Common/FlashMap.h>\r
+\r
+VOID\r
+BdsLockFv (\r
+  IN EFI_CPU_IO_PROTOCOL          *CpuIo,\r
+  IN EFI_FLASH_SUBAREA_ENTRY      *FlashEntry\r
+  );\r
+\r
+VOID\r
+BdsLockFv (\r
+  IN EFI_CPU_IO_PROTOCOL          *CpuIo,\r
+  IN EFI_FLASH_SUBAREA_ENTRY      *FlashEntry\r
+  )\r
+{\r
+  EFI_FV_BLOCK_MAP_ENTRY      *BlockMap;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  UINT64                      BaseAddress;\r
+  UINT8                       Data;\r
+  UINT32                      BlockLength;\r
+  UINTN                       Index;\r
+\r
+  BaseAddress = FlashEntry->Base - 0x400000 + 2;\r
+  FvHeader    = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) (FlashEntry->Base));\r
+  BlockMap    = &(FvHeader->FvBlockMap[0]);\r
+\r
+  while ((BlockMap->NumBlocks != 0) && (BlockMap->BlockLength != 0)) {\r
+    BlockLength = BlockMap->BlockLength;\r
+    for (Index = 0; Index < BlockMap->NumBlocks; Index++) {\r
+      CpuIo->Mem.Read (\r
+                  CpuIo,\r
+                  EfiCpuIoWidthUint8,\r
+                  BaseAddress,\r
+                  1,\r
+                  &Data\r
+                  );\r
+      Data = (UINT8) (Data | 0x3);\r
+      CpuIo->Mem.Write (\r
+                  CpuIo,\r
+                  EfiCpuIoWidthUint8,\r
+                  BaseAddress,\r
+                  1,\r
+                  &Data\r
+                  );\r
+      BaseAddress += BlockLength;\r
+    }\r
+\r
+    BlockMap++;\r
+  }\r
+}\r
+\r
+VOID\r
+BdsLockNonUpdatableFlash (\r
+  VOID\r
+  )\r
+{\r
+  EFI_FLASH_MAP_ENTRY_DATA  *FlashMapEntryData;\r
+  EFI_PEI_HOB_POINTERS      GuidHob;\r
+  EFI_STATUS                Status;\r
+  EFI_CPU_IO_PROTOCOL       *CpuIo;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &CpuIo);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  GuidHob.Raw = GetHobList ();\r
+  while ((GuidHob.Raw = GetNextGuidHob (&gEfiFlashMapHobGuid, GuidHob.Raw)) != NULL) {\r
+    FlashMapEntryData = (EFI_FLASH_MAP_ENTRY_DATA *) GET_GUID_HOB_DATA (GuidHob.Guid);\r
+\r
+    //\r
+    // Get the variable store area\r
+    //\r
+    if ((FlashMapEntryData->AreaType == EFI_FLASH_AREA_RECOVERY_BIOS) ||\r
+        (FlashMapEntryData->AreaType == EFI_FLASH_AREA_MAIN_BIOS)\r
+        ) {\r
+      BdsLockFv (CpuIo, &(FlashMapEntryData->Entries[0]));\r
+    }\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+EFI_STATUS\r
+ProcessCapsules (\r
+  EFI_BOOT_MODE BootMode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine is called to see if there are any capsules we need to process.\r
+  If the boot mode is not UPDATE, then we do nothing. Otherwise find the\r
+  capsule HOBS and produce firmware volumes for them via the DXE service.\r
+  Then call the dispatcher to dispatch drivers from them. Finally, check\r
+  the status of the updates.\r
+\r
+Arguments:\r
+\r
+  BootMode - the current boot mode\r
+\r
+Returns:\r
+  \r
+  EFI_INVALID_PARAMETER - boot mode is not correct for an update\r
+\r
+Note:\r
\r
+ This function should be called by BDS in case we need to do some\r
+ sort of processing even if there is no capsule to process. We\r
+ need to do this if an earlier update went awry and we need to\r
+ clear the capsule variable so on the next reset PEI does not see it and \r
+ think there is a capsule available.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_HOB_CAPSULE_VOLUME      *CvHob;\r
+  EFI_PHYSICAL_ADDRESS        BaseAddress;\r
+  UINT64                      Length;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;\r
+  EFI_HANDLE                  FvProtocolHandle;\r
+\r
+  //\r
+  // We don't do anything else if the boot mode is not flash-update\r
+  //\r
+  if (BootMode != BOOT_ON_FLASH_UPDATE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Only one capsule HOB allowed.\r
+  //\r
+  CvHob = GetFirstHob (EFI_HOB_TYPE_CV);\r
+  if (CvHob == NULL) {\r
+    //\r
+    // We didn't find a hob, so had no errors.\r
+    //\r
+    BdsLockNonUpdatableFlash ();\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  BaseAddress = CvHob->BaseAddress;\r
+  Length      = CvHob->Length;\r
+\r
+  Status      = EFI_SUCCESS;\r
+  //\r
+  // Now walk the capsule and call the core to process each\r
+  // firmware volume in it.\r
+  //\r
+  while (Length != 0) {\r
+    //\r
+    // Point to the next firmware volume header, and then\r
+    // call the DXE service to process it.\r
+    //\r
+    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
+    if (FwVolHeader->FvLength > Length) {\r
+      //\r
+      // Notes: need to stuff this status somewhere so that the\r
+      // error can be detected at OS runtime\r
+      //\r
+      Status = EFI_VOLUME_CORRUPTED;\r
+      break;\r
+    }\r
+\r
+    Status = gDS->ProcessFirmwareVolume (\r
+                    (VOID *) (UINTN) BaseAddress,\r
+                    (UINTN) FwVolHeader->FvLength,\r
+                    &FvProtocolHandle\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+    //\r
+    // Call the dispatcher to dispatch any drivers from the produced firmware volume\r
+    //\r
+    gDS->Dispatch ();\r
+    //\r
+    // On to the next FV in the capsule\r
+    //\r
+    Length -= FwVolHeader->FvLength;\r
+    BaseAddress = (EFI_PHYSICAL_ADDRESS) ((UINTN) BaseAddress + FwVolHeader->FvLength);\r
+    //\r
+    // Notes: when capsule spec is finalized, if the requirement is made to\r
+    // have each FV in a capsule aligned, then we will need to align the\r
+    // BaseAddress and Length here.\r
+    //\r
+  }\r
+   \r
+\r
+  BdsLockNonUpdatableFlash ();\r
+\r
+  return Status;\r
+}\r
+\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.c
new file mode 100644 (file)
index 0000000..3f648b7
--- /dev/null
@@ -0,0 +1,492 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  DeviceManager.c\r
+\r
+Abstract:\r
+\r
+  The platform device manager reference implement\r
+\r
+--*/\r
+#include "DeviceManager.h"\r
+\r
+STATIC UINT16                     mTokenCount;\r
+EFI_FRONTPAGE_CALLBACK_INFO       FPCallbackInfo;\r
+extern UINTN                      gCallbackKey;\r
+extern EFI_FORM_BROWSER_PROTOCOL  *gBrowser;\r
+extern EFI_GUID                   gBdsStringPackGuid;\r
+extern BOOLEAN                    gConnectAllHappened;\r
+\r
+STRING_REF                        gStringTokenTable[] = {\r
+  STR_VIDEO_DEVICE,\r
+  STR_NETWORK_DEVICE,\r
+  STR_INPUT_DEVICE,\r
+  STR_ON_BOARD_DEVICE,\r
+  STR_OTHER_DEVICE,\r
+  STR_EMPTY_STRING,\r
+  0xFFFF\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DeviceManagerCallbackRoutine (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *DataArray,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the function that is called to provide results data to the driver.  This data\r
+  consists of a unique key which is used to identify what data is either being passed back\r
+  or being asked for. \r
+\r
+Arguments:\r
+\r
+  KeyValue -        A unique value which is sent to the original exporting driver so that it\r
+                    can identify the type of data to expect.  The format of the data tends to\r
+                    vary based on the op-code that geerated the callback.\r
+\r
+  Data -            A pointer to the data being sent to the original exporting driver.\r
+\r
+Returns: \r
+\r
+--*/\r
+{\r
+  //\r
+  // The KeyValue corresponds in this case to the handle which was requested to be displayed\r
+  //\r
+  EFI_FRONTPAGE_CALLBACK_INFO *CallbackInfo;\r
+\r
+  CallbackInfo = EFI_FP_CALLBACK_DATA_FROM_THIS (This);\r
+  switch (KeyValue) {\r
+  case 0x2000:\r
+    CallbackInfo->Data.VideoBIOS = (UINT8) (UINTN) (((EFI_IFR_DATA_ENTRY *)(DataArray + 1))->Data);\r
+    gRT->SetVariable (\r
+          L"VBIOS",\r
+          &gEfiGlobalVariableGuid,\r
+          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+          sizeof (UINT8),\r
+          &CallbackInfo->Data.VideoBIOS\r
+          );\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+  gCallbackKey = KeyValue;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+InitializeDeviceManager (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize HII information for the FrontPage\r
+\r
+Arguments:\r
+  None\r
+            \r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_HII_PACKAGES    *PackageList;\r
+  EFI_HII_UPDATE_DATA *UpdateData;\r
+\r
+  //\r
+  // Allocate space for creation of UpdateData Buffer\r
+  //\r
+  UpdateData = AllocateZeroPool (0x1000);\r
+  ASSERT (UpdateData != NULL);\r
+\r
+  PackageList = PreparePackages (1, &gBdsStringPackGuid, DeviceManagerVfrBin);\r
+  Status      = Hii->NewPack (Hii, PackageList, &FPCallbackInfo.DevMgrHiiHandle);\r
+  gBS->FreePool (PackageList);\r
+\r
+  //\r
+  // This example does not implement worker functions for the NV accessor functions.  Only a callback evaluator\r
+  //\r
+  FPCallbackInfo.Signature                = EFI_FP_CALLBACK_DATA_SIGNATURE;\r
+  FPCallbackInfo.DevMgrCallback.NvRead    = NULL;\r
+  FPCallbackInfo.DevMgrCallback.NvWrite   = NULL;\r
+  FPCallbackInfo.DevMgrCallback.Callback  = DeviceManagerCallbackRoutine;\r
+\r
+  //\r
+  // Install protocol interface\r
+  //\r
+  FPCallbackInfo.CallbackHandle = NULL;\r
+\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &FPCallbackInfo.CallbackHandle,\r
+                  &gEfiFormCallbackProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &FPCallbackInfo.DevMgrCallback\r
+                  );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Flag update pending in FormSet\r
+  //\r
+  UpdateData->FormSetUpdate = TRUE;\r
+  //\r
+  // Register CallbackHandle data for FormSet\r
+  //\r
+  UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) FPCallbackInfo.CallbackHandle;\r
+  //\r
+  // Simply registering the callback handle\r
+  //\r
+  Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) 0x0000, TRUE, UpdateData);\r
+\r
+  gBS->FreePool (UpdateData);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+CallDeviceManager (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Call the browser and display the device manager\r
+\r
+Arguments:\r
+  \r
+  None\r
+  \r
+Returns:\r
+  EFI_SUCCESS            - Operation is successful.\r
+  EFI_INVALID_PARAMETER  - If the inputs to SendForm function is not valid.\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  UINTN               BufferSize;\r
+  UINTN               Count;\r
+  EFI_HII_HANDLE      Index;\r
+  UINT8               *Buffer;\r
+  EFI_IFR_FORM_SET    *FormSetData;\r
+  CHAR16              *String;\r
+  UINTN               StringLength;\r
+  EFI_HII_UPDATE_DATA *UpdateData;\r
+  STRING_REF          Token;\r
+  STRING_REF          TokenHelp;\r
+  IFR_OPTION          *IfrOptionList;\r
+  UINT8               *VideoOption;\r
+  UINTN               VideoOptionSize;\r
+  EFI_HII_HANDLE      *HiiHandles;\r
+  UINT16              HandleBufferLength;\r
+  BOOLEAN                BootDeviceMngrMenuResetRequired;\r
+\r
+  IfrOptionList       = NULL;\r
+  VideoOption         = NULL;\r
+  HandleBufferLength  = 0;\r
+\r
+  //\r
+  // Connect all prior to entering the platform setup menu.\r
+  //\r
+  if (!gConnectAllHappened) {\r
+    BdsLibConnectAllDriversToAllControllers ();\r
+    gConnectAllHappened = TRUE;\r
+  }\r
+  //\r
+  // Allocate space for creation of UpdateData Buffer\r
+  //\r
+  UpdateData = AllocateZeroPool (0x1000);\r
+  ASSERT (UpdateData != NULL);\r
+\r
+  Status        = EFI_SUCCESS;\r
+  Buffer        = NULL;\r
+  FormSetData   = NULL;\r
+  gCallbackKey  = 0;\r
+  if (mTokenCount == 0) {\r
+    Hii->NewString (Hii, NULL, FPCallbackInfo.DevMgrHiiHandle, &mTokenCount, L" ");\r
+  }\r
+\r
+  Token     = mTokenCount;\r
+  TokenHelp = (UINT16) (Token + 1);\r
+\r
+  //\r
+  // Reset the menu\r
+  //\r
+  for (Index = 0, Count = 1; Count < 0x10000; Count <<= 1, Index++) {\r
+    //\r
+    // We will strip off all previous menu entries\r
+    //\r
+    UpdateData->DataCount = 0xFF;\r
+\r
+    //\r
+    // Erase entries on this label\r
+    //\r
+    Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, FALSE, UpdateData);\r
+\r
+    //\r
+    // Did we reach the end of the Token Table?\r
+    //\r
+    if (gStringTokenTable[Index] == 0xFFFF) {\r
+      break;\r
+    }\r
+\r
+    CreateSubTitleOpCode (gStringTokenTable[Index], &UpdateData->Data);\r
+    //\r
+    // Add a single menu item - in this case a subtitle for the device type\r
+    //\r
+    UpdateData->DataCount = 1;\r
+\r
+    //\r
+    // Add default title for this label\r
+    //\r
+    Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);\r
+  }\r
+  //\r
+  // Add a space and an exit string.  Remember since we add things at the label and push other things beyond the\r
+  // label down, we add this in reverse order\r
+  //\r
+  CreateSubTitleOpCode (STRING_TOKEN (STR_EXIT_STRING), &UpdateData->Data);\r
+  Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);\r
+  CreateSubTitleOpCode (STR_EMPTY_STRING, &UpdateData->Data);\r
+  Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) Count, TRUE, UpdateData);\r
+\r
+  HiiHandles = AllocateZeroPool (HandleBufferLength);\r
+  Hii->FindHandles (Hii, &HandleBufferLength, HiiHandles);\r
+\r
+  for (Index = 1, BufferSize = 0; Index < HandleBufferLength; Index++) {\r
+    //\r
+    // Am not initializing Buffer since the first thing checked is the size\r
+    // this way I can get the real buffersize in the smallest code size\r
+    //\r
+    Status = Hii->GetForms (Hii, Index, 0, &BufferSize, Buffer);\r
+\r
+    if (Status != EFI_NOT_FOUND) {\r
+      //\r
+      // BufferSize should have the real size of the forms now\r
+      //\r
+      Buffer = AllocateZeroPool (BufferSize);\r
+      ASSERT (Buffer != NULL);\r
+\r
+      //\r
+      // Am not initializing Buffer since the first thing checked is the size\r
+      // this way I can get the real buffersize in the smallest code size\r
+      //\r
+      Status = Hii->GetForms (Hii, Index, 0, &BufferSize, Buffer);\r
+\r
+      //\r
+      // Skip EFI_HII_PACK_HEADER, advance to EFI_IFR_FORM_SET data.\r
+      //\r
+      FormSetData = (EFI_IFR_FORM_SET *) (Buffer + sizeof (EFI_HII_PACK_HEADER));\r
+\r
+      //\r
+      // If this formset belongs in the device manager, add it to the menu\r
+      //\r
+      if (FormSetData->Class != EFI_NON_DEVICE_CLASS) {\r
+\r
+        StringLength  = 0x1000;\r
+        String        = AllocateZeroPool (StringLength);\r
+        ASSERT (String != NULL);\r
+\r
+        Status  = Hii->GetString (Hii, Index, FormSetData->FormSetTitle, TRUE, NULL, &StringLength, String);\r
+        Status  = Hii->NewString (Hii, NULL, FPCallbackInfo.DevMgrHiiHandle, &Token, String);\r
+\r
+        //\r
+        // If token value exceeded real token value - we need to add a new token values\r
+        //\r
+        if (Status == EFI_INVALID_PARAMETER) {\r
+          Token     = 0;\r
+          TokenHelp = 0;\r
+          Status    = Hii->NewString (Hii, NULL, FPCallbackInfo.DevMgrHiiHandle, &Token, String);\r
+        }\r
+\r
+        StringLength = 0x1000;\r
+        if (FormSetData->Help == 0) {\r
+          TokenHelp = 0;\r
+        } else {\r
+          Status = Hii->GetString (Hii, Index, FormSetData->Help, TRUE, NULL, &StringLength, String);\r
+          if (StringLength == 0x02) {\r
+            TokenHelp = 0;\r
+          } else {\r
+            Status = Hii->NewString (Hii, NULL, FPCallbackInfo.DevMgrHiiHandle, &TokenHelp, String);\r
+            if (Status == EFI_INVALID_PARAMETER) {\r
+              TokenHelp = 0;\r
+              Status    = Hii->NewString (Hii, NULL, FPCallbackInfo.DevMgrHiiHandle, &TokenHelp, String);\r
+            }\r
+          }\r
+        }\r
+\r
+        gBS->FreePool (String);\r
+\r
+        CreateGotoOpCode (\r
+          0x1000,     // Device Manager Page\r
+          Token,      // Description String Token\r
+          TokenHelp,  // Description Help String Token\r
+          EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,  // Flag designating callback is active\r
+          (UINT16) Index,                                     // Callback key value\r
+          &UpdateData->Data                                   // Buffer to fill with op-code\r
+          );\r
+\r
+        //\r
+        // In the off-chance that we have lots of extra tokens allocated to the DeviceManager\r
+        // this ensures we are fairly re-using the tokens instead of constantly growing the token\r
+        // storage for this one handle.  If we incremented the token value beyond what it normally\r
+        // would use, we will fall back into the error path which seeds the token value with a 0\r
+        // so that we can correctly add a token value.\r
+        //\r
+        if (TokenHelp == 0) {\r
+          //\r
+          // Since we didn't add help, only advance Token by 1\r
+          //\r
+          Token++;\r
+        } else {\r
+          Token     = (UINT16) (Token + 2);\r
+          TokenHelp = (UINT16) (TokenHelp + 2);\r
+        }\r
+        //\r
+        // This for loop basically will take the Class value which is a bitmask and\r
+        // update the form for every active bit.  There will be a label at each bit\r
+        // location.  So if someone had a device which a class of EFI_DISK_DEVICE_CLASS |\r
+        // EFI_ON_BOARD_DEVICE_CLASS, this routine will unwind that mask and drop the menu entry\r
+        // on each corresponding label.\r
+        //\r
+        for (Count = 1; Count < 0x10000; Count <<= 1) {\r
+          //\r
+          // This is an active bit, so update the form\r
+          //\r
+          if (FormSetData->Class & Count) {\r
+            Hii->UpdateForm (\r
+                  Hii,\r
+                  FPCallbackInfo.DevMgrHiiHandle,\r
+                  (EFI_FORM_LABEL) (FormSetData->Class & Count),\r
+                  TRUE,\r
+                  UpdateData\r
+                  );\r
+          }\r
+        }\r
+      }\r
+\r
+      BufferSize = 0;\r
+      //\r
+      // Reset Buffer pointer to original location\r
+      //\r
+      gBS->FreePool (Buffer);\r
+    }\r
+  }\r
+  //\r
+  // Add oneof for video BIOS selection\r
+  //\r
+  VideoOption = BdsLibGetVariableAndSize (\r
+                  L"VBIOS",\r
+                  &gEfiGlobalVariableGuid,\r
+                  &VideoOptionSize\r
+                  );\r
+  if (NULL == VideoOption) {\r
+    FPCallbackInfo.Data.VideoBIOS = 0;\r
+  } else {\r
+    FPCallbackInfo.Data.VideoBIOS = VideoOption[0];\r
+    gBS->FreePool (VideoOption);\r
+  }\r
+\r
+  ASSERT (FPCallbackInfo.Data.VideoBIOS <= 1);\r
+\r
+  Status = gBS->AllocatePool (EfiBootServicesData, 2 * sizeof (IFR_OPTION), &IfrOptionList);\r
+  if (IfrOptionList != NULL) {\r
+    IfrOptionList[0].Flags        = EFI_IFR_FLAG_INTERACTIVE;\r
+    IfrOptionList[0].Key          = SET_VIDEO_BIOS_TYPE_QUESTION_ID + 0x2000;\r
+    IfrOptionList[0].StringToken  = STRING_TOKEN (STR_ONE_OF_PCI);\r
+    IfrOptionList[0].Value        = 0;\r
+    IfrOptionList[0].OptionString = NULL;\r
+    IfrOptionList[1].Flags        = EFI_IFR_FLAG_INTERACTIVE;\r
+    IfrOptionList[1].Key          = SET_VIDEO_BIOS_TYPE_QUESTION_ID + 0x2000;\r
+    IfrOptionList[1].StringToken  = STRING_TOKEN (STR_ONE_OF_AGP);\r
+    IfrOptionList[1].Value        = 1;\r
+    IfrOptionList[1].OptionString = NULL;\r
+    IfrOptionList[FPCallbackInfo.Data.VideoBIOS].Flags |= EFI_IFR_FLAG_DEFAULT;\r
+\r
+    CreateOneOfOpCode (\r
+      SET_VIDEO_BIOS_TYPE_QUESTION_ID,\r
+      (UINT8) 1,\r
+      STRING_TOKEN (STR_ONE_OF_VBIOS),\r
+      STRING_TOKEN (STR_ONE_OF_VBIOS_HELP),\r
+      IfrOptionList,\r
+      2,\r
+      &UpdateData->Data\r
+      );\r
+\r
+    UpdateData->DataCount = 4;\r
+    Hii->UpdateForm (Hii, FPCallbackInfo.DevMgrHiiHandle, (EFI_FORM_LABEL) EFI_VBIOS_CLASS, TRUE, UpdateData);\r
+    gBS->FreePool (IfrOptionList);\r
+  }\r
+\r
+  BootDeviceMngrMenuResetRequired = FALSE;\r
+  Status = gBrowser->SendForm (\r
+                      gBrowser,\r
+                      TRUE,                             // Use the database\r
+                      &FPCallbackInfo.DevMgrHiiHandle,  // The HII Handle\r
+                      1,\r
+                      NULL,\r
+                      FPCallbackInfo.CallbackHandle,\r
+                      (UINT8 *) &FPCallbackInfo.Data,\r
+                      NULL,\r
+                      &BootDeviceMngrMenuResetRequired\r
+                      );\r
+\r
+  if (BootDeviceMngrMenuResetRequired) {\r
+    EnableResetRequired ();\r
+  }\r
+\r
+  Hii->ResetStrings (Hii, FPCallbackInfo.DevMgrHiiHandle);\r
+\r
+  //\r
+  // We will have returned from processing a callback - user either hit ESC to exit, or selected\r
+  // a target to display\r
+  //\r
+  if (gCallbackKey != 0 && gCallbackKey < 0x2000) {\r
+    BootDeviceMngrMenuResetRequired = FALSE;\r
+    Status = gBrowser->SendForm (\r
+                        gBrowser,\r
+                        TRUE,                             // Use the database\r
+                        (EFI_HII_HANDLE *) &gCallbackKey, // The HII Handle\r
+                        1,\r
+                        NULL,\r
+                        NULL,                             // This is the handle that the interface to the callback was installed on\r
+                        NULL,\r
+                        NULL,\r
+                        &BootDeviceMngrMenuResetRequired\r
+                        );\r
+\r
+    if (BootDeviceMngrMenuResetRequired) {\r
+      EnableResetRequired ();\r
+    }\r
+    //\r
+    // Force return to Device Manager\r
+    //\r
+    gCallbackKey = 4;\r
+  }\r
+\r
+  if (gCallbackKey >= 0x2000) {\r
+    gCallbackKey = 4;\r
+  }\r
+\r
+  gBS->FreePool (UpdateData);\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManager.h
new file mode 100644 (file)
index 0000000..dd6d935
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  DeviceManager.c\r
+\r
+Abstract:\r
+\r
+  The platform device manager reference implement\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _DEVICE_MANAGER_H\r
+#define _DEVICE_MANAGER_H\r
+\r
+#include "Generic/FrontPage.h"\r
+\r
+#define EFI_NON_DEVICE_CLASS              0x00  // Useful when you do not want something in the Device Manager\r
+#define EFI_DISK_DEVICE_CLASS             0x01\r
+#define EFI_VIDEO_DEVICE_CLASS            0x02\r
+#define EFI_NETWORK_DEVICE_CLASS          0x04\r
+#define EFI_INPUT_DEVICE_CLASS            0x08\r
+#define EFI_ON_BOARD_DEVICE_CLASS         0x10\r
+#define EFI_OTHER_DEVICE_CLASS            0x20\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+DeviceManagerCallbackRoutine (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *DataArray,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+InitializeDeviceManager (\r
+  VOID\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+CallDeviceManager (\r
+  VOID\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerStrings.uni b/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerStrings.uni
new file mode 100644 (file)
index 0000000..f549ff2
Binary files /dev/null and b/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerStrings.uni differ
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerVfr.Vfr b/EdkUnixPkg/Dxe/PlatformBds/Generic/DeviceMngr/DeviceManagerVfr.Vfr
new file mode 100644 (file)
index 0000000..5497c6d
--- /dev/null
@@ -0,0 +1,75 @@
+// *++\r
+//\r
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//   DeviceManagerVfr.vfr \r
+// \r
+// Abstract:\r
+// \r
+//   Device Manager formset.\r
+// \r
+// Revision History: \r
+// \r
+// --*/\r
+\r
+#include "BdsStrDefs.h"\r
+\r
+#define FORMSET_GUID  { 0x3ebfa8e6, 0x511d, 0x4b5b, { 0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27 } }\r
+\r
+#define EFI_DISK_DEVICE_CLASS              0x01\r
+#define EFI_VIDEO_DEVICE_CLASS             0x02\r
+#define EFI_NETWORK_DEVICE_CLASS           0x04\r
+#define EFI_INPUT_DEVICE_CLASS             0x08\r
+#define EFI_ON_BOARD_DEVICE_CLASS          0x10\r
+#define EFI_OTHER_DEVICE_CLASS             0x20\r
+#define EFI_VBIOS_CLASS                    0x40\r
+\r
+#define DEVICE_MANAGER_CLASS               0x0000\r
+#define FRONT_PAGE_SUBCLASS                         0x0003\r
+\r
+formset \r
+  guid     = FORMSET_GUID,\r
+  title    = STRING_TOKEN(STR_DEVICE_MANAGER_TITLE),  \r
+  help     = STRING_TOKEN(STR_EMPTY_STRING),\r
+  class    = DEVICE_MANAGER_CLASS,      \r
+  subclass = FRONT_PAGE_SUBCLASS,\r
+\r
+  form formid = 0x1000,\r
+       title  = STRING_TOKEN(STR_DEVICE_MANAGER_TITLE);\r
+\r
+    //\r
+    // This is where devices get added to the device manager hierarchy\r
+    //\r
+    subtitle text = STRING_TOKEN(STR_DISK_DEVICE);\r
+    label EFI_DISK_DEVICE_CLASS;\r
+\r
+    subtitle text = STRING_TOKEN(STR_VIDEO_DEVICE);\r
+    label EFI_VIDEO_DEVICE_CLASS;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NETWORK_DEVICE);\r
+    label EFI_NETWORK_DEVICE_CLASS;\r
+\r
+    subtitle text = STRING_TOKEN(STR_INPUT_DEVICE);\r
+    label EFI_INPUT_DEVICE_CLASS;\r
+\r
+    subtitle text = STRING_TOKEN(STR_ON_BOARD_DEVICE);\r
+    label EFI_ON_BOARD_DEVICE_CLASS;\r
+\r
+    subtitle text = STRING_TOKEN(STR_OTHER_DEVICE);\r
+    label EFI_OTHER_DEVICE_CLASS;\r
+    \r
+    subtitle text = STRING_TOKEN(STR_EMPTY_STRING);\r
+    label EFI_VBIOS_CLASS;\r
+    \r
+  endform;\r
+endformset;\r
+\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPage.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPage.c
new file mode 100644 (file)
index 0000000..a31e8a9
--- /dev/null
@@ -0,0 +1,901 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FrontPage.c\r
+\r
+Abstract:\r
+\r
+  FrontPage routines to handle the callbacks and browser calls\r
+  \r
+--*/\r
+\r
+#include "Bds.h"\r
+#include "BdsPlatform.h"\r
+#include "FrontPage.h"\r
+#include "String.h"\r
+\r
+EFI_GUID                    mProcessorSubClass  = EFI_PROCESSOR_SUBCLASS_GUID;\r
+EFI_GUID                    mMemorySubClass     = EFI_MEMORY_SUBCLASS_GUID;\r
+EFI_GUID                    mMiscSubClass       = EFI_MISC_SUBCLASS_GUID;\r
+\r
+UINT16                      mLastSelection;\r
+EFI_HII_HANDLE              gFrontPageHandle;\r
+EFI_HANDLE                  FrontPageCallbackHandle;\r
+EFI_FORM_CALLBACK_PROTOCOL  FrontPageCallback;\r
+EFI_FORM_BROWSER_PROTOCOL   *gBrowser;\r
+UINTN                       gCallbackKey;\r
+BOOLEAN                     gConnectAllHappened = FALSE;\r
+\r
+extern EFI_HII_HANDLE       gFrontPageHandle;\r
+extern EFI_GUID             gBdsStringPackGuid;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FrontPageCallbackRoutine (\r
+  IN EFI_FORM_CALLBACK_PROTOCOL       *This,\r
+  IN UINT16                           KeyValue,\r
+  IN EFI_IFR_DATA_ARRAY               *DataArray,\r
+  OUT EFI_HII_CALLBACK_PACKET         **Packet\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This is the function that is called to provide results data to the driver.  This data\r
+  consists of a unique key which is used to identify what data is either being passed back\r
+  or being asked for. \r
+\r
+Arguments:\r
+\r
+  KeyValue -        A unique value which is sent to the original exporting driver so that it\r
+                    can identify the type of data to expect.  The format of the data tends to\r
+                    vary based on the op-code that geerated the callback.\r
+\r
+  Data -            A pointer to the data being sent to the original exporting driver.\r
+\r
+Returns: \r
+\r
+--*/\r
+{\r
+  CHAR16        *LanguageString;\r
+  UINTN         Count;\r
+  CHAR16        UnicodeLang[3];\r
+  CHAR8         Lang[3];\r
+  EFI_STATUS    Status;\r
+  UINTN         Index;\r
+  CHAR16        *TmpStr;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
+\r
+  SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
+  SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
+  SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
+\r
+  Count = 0;\r
+\r
+  //\r
+  // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
+  // describe to their customers in documentation how to find their setup information (namely\r
+  // under the device manager and specific buckets)\r
+  //\r
+  switch (KeyValue) {\r
+  case 0x0001:\r
+    //\r
+    // This is the continue - clear the screen and return an error to get out of FrontPage loop\r
+    //\r
+    gCallbackKey = 1;\r
+    break;\r
+\r
+  case 0x1234:\r
+    //\r
+    // Collect the languages from what our current Language support is based on our VFR\r
+    //\r
+    Hii->GetPrimaryLanguages (Hii, gFrontPageHandle, &LanguageString);\r
+\r
+    //\r
+    // Based on the DataArray->Data->Data value, we can determine\r
+    // which language was chosen by the user\r
+    //\r
+    for (Index = 0; Count != (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray + 1))->Data); Index += 3) {\r
+      Count++;\r
+    }\r
+    //\r
+    // Preserve the choice the user made\r
+    //\r
+    mLastSelection = (UINT16) Count;\r
+\r
+    //\r
+    // The Language (in Unicode format) the user chose\r
+    //\r
+    CopyMem (UnicodeLang, &LanguageString[Index], 6);\r
+\r
+    //\r
+    // Convert Unicode to ASCII (Since the ISO standard assumes ASCII equivalent abbreviations\r
+    // we can be safe in converting this Unicode stream to ASCII without any loss in meaning.\r
+    //\r
+    for (Index = 0; Index < 3; Index++) {\r
+      Lang[Index] = (CHAR8) UnicodeLang[Index];\r
+    }\r
+\r
+    Status = gRT->SetVariable (\r
+                    L"Lang",\r
+                    &gEfiGlobalVariableGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    3,\r
+                    Lang\r
+                    );\r
+\r
+    gBS->FreePool (LanguageString);\r
+    gCallbackKey = 2;\r
+    break;\r
+\r
+  case 0x1064:\r
+    //\r
+    // Boot Manager\r
+    //\r
+    gCallbackKey = 3;\r
+    break;\r
+\r
+  case 0x8567:\r
+    //\r
+    // Device Manager\r
+    //\r
+    gCallbackKey = 4;\r
+    break;\r
+\r
+  case 0x9876:\r
+    //\r
+    // Boot Maintenance Manager\r
+    //\r
+    gCallbackKey = 5;\r
+    break;\r
+\r
+  case 0xFFFE:\r
+\r
+    break;\r
+\r
+  case 0xFFFF:\r
+    //\r
+    // FrontPage TimeOut Callback\r
+    //\r
+    TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));\r
+    if (TmpStr != NULL) {\r
+      PlatformBdsShowProgress (\r
+        Foreground,\r
+        Background,\r
+        TmpStr,\r
+        Color,\r
+        (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray+1))->Data),\r
+        0\r
+        );\r
+      gBS->FreePool (TmpStr);\r
+    }\r
+    break;\r
+\r
+  default:\r
+    gCallbackKey = 0;\r
+    break;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+InitializeFrontPage (\r
+  BOOLEAN                         ReInitializeStrings\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Initialize HII information for the FrontPage\r
+\r
+Arguments:\r
+  None\r
+            \r
+Returns:\r
+  EFI_SUCCESS       - The operation is successful.\r
+  EFI_DEVICE_ERROR  - If the dynamic opcode creation failed.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_HII_PACKAGES    *PackageList;\r
+  EFI_HII_UPDATE_DATA *UpdateData;\r
+  IFR_OPTION          *OptionList;\r
+  CHAR16              *LanguageString;\r
+  UINTN               OptionCount;\r
+  UINTN               Index;\r
+  STRING_REF          Token;\r
+  UINT16              Key;\r
+  CHAR8               AsciiLang[4];\r
+  CHAR16              UnicodeLang[4];\r
+  CHAR16              Lang[4];\r
+  CHAR16              *StringBuffer;\r
+  UINTN               BufferSize;\r
+  UINT8               *TempBuffer;\r
+\r
+  UpdateData  = NULL;\r
+  OptionList  = NULL;\r
+\r
+  if (ReInitializeStrings) {\r
+    //\r
+    // BugBug: Dont' use a goto\r
+    //\r
+    goto ReInitStrings;\r
+  }\r
+  //\r
+  // Go ahead and initialize the Device Manager\r
+  //\r
+  InitializeDeviceManager ();\r
+\r
+  //\r
+  // BugBug: if FrontPageVfrBin is generated by a tool, why are we patching it here\r
+  //\r
+  TempBuffer    = (UINT8 *) FrontPageVfrBin;\r
+  TempBuffer    = TempBuffer + sizeof (EFI_HII_PACK_HEADER);\r
+  TempBuffer    = (UINT8 *) &((EFI_IFR_FORM_SET *) TempBuffer)->NvDataSize;\r
+  *TempBuffer   = 1;\r
+\r
+  gCallbackKey  = 0;\r
+\r
+  PackageList   = PreparePackages (1, &gBdsStringPackGuid, FrontPageVfrBin);\r
+\r
+  Status        = Hii->NewPack (Hii, PackageList, &gFrontPageHandle);\r
+\r
+  gBS->FreePool (PackageList);\r
+\r
+  //\r
+  // There will be only one FormConfig in the system\r
+  // If there is another out there, someone is trying to install us\r
+  // again.  Fail that scenario.\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiFormBrowserProtocolGuid,\r
+                  NULL,\r
+                  &gBrowser\r
+                  );\r
+\r
+  //\r
+  // This example does not implement worker functions\r
+  // for the NV accessor functions.  Only a callback evaluator\r
+  //\r
+  FrontPageCallback.NvRead    = NULL;\r
+  FrontPageCallback.NvWrite   = NULL;\r
+  FrontPageCallback.Callback  = FrontPageCallbackRoutine;\r
+\r
+  //\r
+  // Install protocol interface\r
+  //\r
+  FrontPageCallbackHandle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &FrontPageCallbackHandle,\r
+                  &gEfiFormCallbackProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &FrontPageCallback\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+ReInitStrings:\r
+  //\r
+  // BugBug: This logic is in BdsInitLanguage. It should not be in two places!\r
+  //\r
+  BufferSize = 4;\r
+  Status = gRT->GetVariable (\r
+                  L"Lang",\r
+                  &gEfiGlobalVariableGuid,\r
+                  NULL,\r
+                  &BufferSize,\r
+                  AsciiLang\r
+                  );\r
+\r
+  for (Index = 0; Index < 3; Index++) {\r
+    UnicodeLang[Index] = (CHAR16) AsciiLang[Index];\r
+  }\r
+\r
+  UnicodeLang[3] = 0;\r
+\r
+  //\r
+  // Allocate space for creation of UpdateData Buffer\r
+  //\r
+  UpdateData = AllocateZeroPool (0x1000);\r
+  ASSERT (UpdateData != NULL);\r
+\r
+  OptionList = AllocateZeroPool (0x1000);\r
+  ASSERT (OptionList != NULL);\r
+\r
+  //\r
+  // Flag update pending in FormSet\r
+  //\r
+  UpdateData->FormSetUpdate = TRUE;\r
+  //\r
+  // Register CallbackHandle data for FormSet\r
+  //\r
+  UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) FrontPageCallbackHandle;\r
+  UpdateData->FormUpdate  = FALSE;\r
+  UpdateData->FormTitle   = 0;\r
+  UpdateData->DataCount   = 1;\r
+\r
+  //\r
+  // Collect the languages from what our current Language support is based on our VFR\r
+  //\r
+  Hii->GetPrimaryLanguages (Hii, gFrontPageHandle, &LanguageString);\r
+\r
+  OptionCount = 0;\r
+\r
+  //\r
+  // Try for a 512 byte Buffer\r
+  //\r
+  BufferSize = 0x200;\r
+\r
+  //\r
+  // Allocate memory for our Form binary\r
+  //\r
+  StringBuffer = AllocateZeroPool (BufferSize);\r
+  ASSERT (StringBuffer != NULL);\r
+\r
+  for (Index = 0; LanguageString[Index] != 0; Index += 3) {\r
+    Token = 0;\r
+    CopyMem (Lang, &LanguageString[Index], 6);\r
+    Lang[3] = 0;\r
+\r
+    if (!StrCmp (Lang, UnicodeLang)) {\r
+      mLastSelection = (UINT16) OptionCount;\r
+    }\r
+\r
+    Status = Hii->GetString (Hii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, StringBuffer);\r
+    Hii->NewString (Hii, NULL, gStringPackHandle, &Token, StringBuffer);\r
+    CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));\r
+    CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));\r
+    Key = 0x1234;\r
+    CopyMem (&OptionList[OptionCount].Key, &Key, sizeof (UINT16));\r
+    OptionList[OptionCount].Flags = EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS;\r
+    OptionCount++;\r
+  }\r
+\r
+  gBS->FreePool (LanguageString);\r
+\r
+  if (ReInitializeStrings) {\r
+    gBS->FreePool (StringBuffer);\r
+    gBS->FreePool (OptionList);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  Status = CreateOneOfOpCode (\r
+            FRONT_PAGE_QUESTION_ID,                               // Question ID\r
+            FRONT_PAGE_DATA_WIDTH,                                // Data Width\r
+            (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT),      // Prompt Token\r
+            (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), // Help Token\r
+            OptionList,       // List of Options\r
+            OptionCount,      // Number of Options\r
+            &UpdateData->Data // Data Buffer\r
+            );\r
+\r
+  //\r
+  // Assign the number of options and the oneof and endoneof op-codes to count\r
+  //\r
+  UpdateData->DataCount = (UINT8) (OptionCount + 2);\r
+\r
+  Hii->UpdateForm (Hii, gFrontPageHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);\r
+\r
+  gBS->FreePool (UpdateData);\r
+  //\r
+  // gBS->FreePool (OptionList);\r
+  //\r
+  gBS->FreePool (StringBuffer);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+CallFrontPage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Call the browser and display the front page\r
+\r
+Arguments:\r
+  \r
+  None\r
+  \r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT8       FakeNvRamMap[1];\r
+  BOOLEAN     FrontPageMenuResetRequired;\r
+\r
+  //\r
+  // Begin waiting for USER INPUT\r
+  //\r
+  REPORT_STATUS_CODE (\r
+        EFI_PROGRESS_CODE,\r
+        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r
+        );\r
+\r
+  FakeNvRamMap[0] = (UINT8) mLastSelection;\r
+  FrontPageMenuResetRequired = FALSE;\r
+  Status = gBrowser->SendForm (\r
+                      gBrowser,\r
+                      TRUE,                     // Use the database\r
+                      &gFrontPageHandle,        // The HII Handle\r
+                      1,\r
+                      NULL,\r
+                      FrontPageCallbackHandle,  // This is the handle that the interface to the callback was installed on\r
+                      FakeNvRamMap,\r
+                      NULL,\r
+                      &FrontPageMenuResetRequired\r
+                      );\r
+  //\r
+  // Check whether user change any option setting which needs a reset to be effective\r
+  //                      \r
+  if (FrontPageMenuResetRequired) {\r
+    EnableResetRequired ();\r
+  }\r
+\r
+  Hii->ResetStrings (Hii, gFrontPageHandle);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+GetStringFromToken (\r
+  IN      EFI_GUID                  *ProducerGuid,\r
+  IN      STRING_REF                Token,\r
+  OUT     CHAR16                    **String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Acquire the string associated with the ProducerGuid and return it.\r
+\r
+Arguments:\r
+  \r
+  ProducerGuid - The Guid to search the HII database for\r
+  Token - The token value of the string to extract\r
+  String - The string that is extracted\r
+  \r
+Returns:\r
+\r
+  EFI_SUCCESS - The function returns EFI_SUCCESS always.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS      Status;\r
+  UINT16          HandleBufferLength;\r
+  EFI_HII_HANDLE  *HiiHandleBuffer;\r
+  UINTN           StringBufferLength;\r
+  UINTN           NumberOfHiiHandles;\r
+  UINTN           Index;\r
+  UINT16          Length;\r
+  EFI_GUID        HiiGuid;\r
+\r
+  HandleBufferLength  = 0x1000;\r
+  HiiHandleBuffer     = NULL;\r
+\r
+  //\r
+  // Get all the Hii handles\r
+  //\r
+  HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
+\r
+  Status          = Hii->FindHandles (Hii, &HandleBufferLength, HiiHandleBuffer);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get the Hii Handle that matches the StructureNode->ProducerName\r
+  //\r
+  NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);\r
+  for (Index = 0; Index < NumberOfHiiHandles; Index++) {\r
+    Length = 0;\r
+    Status = ExtractDataFromHiiHandle (\r
+              HiiHandleBuffer[Index],\r
+              &Length,\r
+              NULL,\r
+              &HiiGuid\r
+              );\r
+    if (CompareGuid (ProducerGuid, &HiiGuid)) {\r
+      break;\r
+    }\r
+  }\r
+  //\r
+  // Find the string based on the current language\r
+  //\r
+  StringBufferLength  = 0x100;\r
+  *String             = AllocateZeroPool (0x100);\r
+  Status = Hii->GetString (\r
+                  Hii,\r
+                  HiiHandleBuffer[Index],\r
+                  Token,\r
+                  FALSE,\r
+                  NULL,\r
+                  &StringBufferLength,\r
+                  *String\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (*String);\r
+    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
+  }\r
+\r
+  gBS->FreePool (HiiHandleBuffer);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+ConvertProcessorToString (\r
+  IN  EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency,\r
+  OUT CHAR16                            **String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Convert Processor Frequency Data to a string\r
+\r
+Arguments:\r
+  \r
+  ProcessorFrequency - The frequency data to process\r
+  String - The string that is created\r
+  \r
+Returns:\r
+\r
+--*/\r
+{\r
+  CHAR16  *StringBuffer;\r
+  UINTN   Index;\r
+  UINT32  FreqMhz;\r
+\r
+  if (ProcessorFrequency->Exponent >= 6) {\r
+    FreqMhz = ProcessorFrequency->Value;\r
+    for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) {\r
+      FreqMhz *= 10;\r
+    }\r
+  } else {\r
+    FreqMhz = 0;\r
+  }\r
+\r
+  StringBuffer = AllocateZeroPool (0x20);\r
+  ASSERT (StringBuffer != NULL);\r
+  Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
+  StrCat (StringBuffer, L".");\r
+  UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);\r
+  StrCat (StringBuffer, L" GHz");\r
+\r
+  *String = (CHAR16 *) StringBuffer;\r
+\r
+  return ;\r
+}\r
+\r
+VOID\r
+ConvertMemorySizeToString (\r
+  IN  UINT32          MemorySize,\r
+  OUT CHAR16          **String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Convert Memory Size to a string\r
+\r
+Arguments:\r
+  \r
+  MemorySize - The size of the memory to process\r
+  String - The string that is created\r
+  \r
+Returns:\r
+\r
+--*/\r
+{\r
+  CHAR16  *StringBuffer;\r
+\r
+  StringBuffer = AllocateZeroPool (0x20);\r
+  ASSERT (StringBuffer != NULL);\r
+  UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);\r
+  StrCat (StringBuffer, L" MB RAM");\r
+\r
+  *String = (CHAR16 *) StringBuffer;\r
+\r
+  return ;\r
+}\r
+\r
+VOID\r
+UpdateFrontPageStrings (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Update the banner information for the Front Page based on DataHub information\r
+\r
+Arguments:\r
+  \r
+  None\r
+  \r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  STRING_REF                        TokenToUpdate;\r
+  CHAR16                            *NewString;\r
+  UINT64                            MonotonicCount;\r
+  EFI_DATA_HUB_PROTOCOL             *DataHub;\r
+  EFI_DATA_RECORD_HEADER            *Record;\r
+  EFI_SUBCLASS_TYPE1_HEADER         *DataHeader;\r
+  EFI_MISC_BIOS_VENDOR_DATA         *BiosVendor;\r
+  EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer;\r
+  EFI_PROCESSOR_VERSION_DATA        *ProcessorVersion;\r
+  EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency;\r
+  EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray;\r
+  CHAR8                             LangCode[3];\r
+  CHAR16                            Lang[3];\r
+  UINTN                             Size;\r
+  UINTN                             Index;\r
+  BOOLEAN                           Find[5];\r
+\r
+  ZeroMem (Find, sizeof (Find));\r
+\r
+  //\r
+  // Update Front Page strings\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDataHubProtocolGuid,\r
+                  NULL,\r
+                  &DataHub\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Size = 3;\r
+\r
+  Status = gRT->GetVariable (\r
+                  L"Lang",\r
+                  &gEfiGlobalVariableGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  LangCode\r
+                  );\r
+\r
+  for (Index = 0; Index < 3; Index++) {\r
+    Lang[Index] = (CHAR16) LangCode[Index];\r
+  }\r
+\r
+  MonotonicCount  = 0;\r
+  Record          = NULL;\r
+  do {\r
+    Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);\r
+    if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {\r
+      DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);\r
+      if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&\r
+          (DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER)\r
+          ) {\r
+        BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);\r
+        GetStringFromToken (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);\r
+        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_BIOS_VERSION;\r
+        Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
+        gBS->FreePool (NewString);\r
+        Find[0] = TRUE;\r
+      }\r
+\r
+      if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&\r
+          (DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER)\r
+          ) {\r
+        SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1);\r
+        GetStringFromToken (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString);\r
+        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_COMPUTER_MODEL;\r
+        Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
+        gBS->FreePool (NewString);\r
+        Find[1] = TRUE;\r
+      }\r
+\r
+      if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&\r
+          (DataHeader->RecordType == ProcessorVersionRecordType)\r
+          ) {\r
+        ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1);\r
+        GetStringFromToken (&Record->ProducerName, *ProcessorVersion, &NewString);\r
+        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_MODEL;\r
+        Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
+        gBS->FreePool (NewString);\r
+        Find[2] = TRUE;\r
+      }\r
+\r
+      if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&\r
+          (DataHeader->RecordType == ProcessorCoreFrequencyRecordType)\r
+          ) {\r
+        ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);\r
+        ConvertProcessorToString (ProcessorFrequency, &NewString);\r
+        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_SPEED;\r
+        Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
+        gBS->FreePool (NewString);\r
+        Find[3] = TRUE;\r
+      }\r
+\r
+      if (CompareGuid (&Record->DataRecordGuid, &mMemorySubClass) &&\r
+          (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)\r
+          ) {\r
+        MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1);\r
+        ConvertMemorySizeToString((UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress - \r
+                                  MemoryArray->MemoryArrayStartAddress + 1), 20)),\r
+                                  &NewString);\r
+        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_MEMORY_SIZE;\r
+        Hii->NewString (Hii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
+        gBS->FreePool (NewString);\r
+        Find[4] = TRUE;\r
+      }\r
+    }\r
+  } while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));\r
+\r
+  return ;\r
+}\r
+\r
+VOID\r
+PlatformBdsEnterFrontPage (\r
+  IN UINT16                       TimeoutDefault,\r
+  IN BOOLEAN                      ConnectAllHappened\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function is the main entry of the platform setup entry.\r
+  The function will present the main menu of the system setup, \r
+  this is the platform reference part and can be customize.\r
+  \r
+Arguments:\r
+  TimeoutDefault     - The fault time out value before the system\r
+                       continue to boot.\r
+  ConnectAllHappened - The indicater to check if the connect all have\r
+                       already happended.\r
+  \r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_HII_UPDATE_DATA           *UpdateData;\r
+  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
+\r
+  //\r
+  // Indicate if we need connect all in the platform setup\r
+  //\r
+  if (ConnectAllHappened) {\r
+    gConnectAllHappened = TRUE;\r
+  }\r
+  //\r
+  // Allocate space for creation of Buffer\r
+  //\r
+  UpdateData = AllocateZeroPool (0x1000);\r
+  ASSERT (UpdateData != NULL);\r
+\r
+  UpdateData->FormSetUpdate       = FALSE;\r
+  UpdateData->FormCallbackHandle  = 0;\r
+  UpdateData->FormUpdate          = FALSE;\r
+  UpdateData->FormTitle           = 0;\r
+  UpdateData->DataCount           = 1;\r
+\r
+  //\r
+  // Remove Banner Op-code if any at this label\r
+  //\r
+  Hii->UpdateForm (Hii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, FALSE, UpdateData);\r
+\r
+  //\r
+  // Create Banner Op-code which reflects correct timeout value\r
+  //\r
+  CreateBannerOpCode (\r
+    STRING_TOKEN (STR_TIME_OUT_PROMPT),\r
+    TimeoutDefault,\r
+    (UINT8) EFI_IFR_BANNER_TIMEOUT,\r
+    &UpdateData->Data\r
+    );\r
+\r
+  //\r
+  // Add Banner Op-code at this label\r
+  //\r
+  Hii->UpdateForm (Hii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, TRUE, UpdateData);\r
+\r
+  do {\r
+\r
+    InitializeFrontPage (TRUE);\r
+\r
+    //\r
+    // Update Front Page strings\r
+    //\r
+    UpdateFrontPageStrings ();\r
+\r
+    gCallbackKey = 0;\r
+    PERF_START (0, "BdsTimeOut", "BDS", 0);\r
+    Status = CallFrontPage ();\r
+    PERF_END (0, "BdsTimeOut", "BDS", 0);\r
+\r
+    //\r
+    // If gCallbackKey is greater than 1 and less or equal to 5,\r
+    // it will lauch configuration utilities.\r
+    // 2 = set language\r
+    // 3 = boot manager\r
+    // 4 = device manager\r
+    // 5 = boot maintainenance manager\r
+    //\r
+    if ((gCallbackKey > 0x0001) && (gCallbackKey <= 0x0005)) {\r
+      REPORT_STATUS_CODE (\r
+            EFI_PROGRESS_CODE,\r
+            (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r
+            );\r
+    }\r
+    //\r
+    // Based on the key that was set, we can determine what to do\r
+    //\r
+    switch (gCallbackKey) {\r
+    //\r
+    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
+    // describe to their customers in documentation how to find their setup information (namely\r
+    // under the device manager and specific buckets)\r
+    //\r
+    // These entries consist of the Continue, Select language, Boot Manager, and Device Manager\r
+    //\r
+    case 0x0001:\r
+      //\r
+      // User hit continue\r
+      //\r
+      break;\r
+\r
+    case 0x0002:\r
+      //\r
+      // User made a language setting change - display front page again\r
+      //\r
+      break;\r
+\r
+    case 0x0003:\r
+      //\r
+      // User chose to run the Boot Manager\r
+      //\r
+      CallBootManager ();\r
+      break;\r
+\r
+    case 0x0004:\r
+      //\r
+      // Display the Device Manager\r
+      //\r
+      do {\r
+        CallDeviceManager();\r
+      } while (gCallbackKey == 4);\r
+      break;\r
+\r
+    case 0x0005:\r
+      //\r
+      // Display the Boot Maintenance Manager\r
+      //\r
+      BdsStartBootMaint ();\r
+      break;\r
+    }\r
+\r
+  } while ((Status == EFI_SUCCESS) && (gCallbackKey != 1));\r
+\r
+  //\r
+  //Will leave browser, check any reset required change is applied? if yes, reset system\r
+  //\r
+  SetupResetReminder ();\r
+  \r
+  //\r
+  // Automatically load current entry\r
+  // Note: The following lines of code only execute when Auto boot\r
+  // takes affect\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);\r
+  ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
+\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPage.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPage.h
new file mode 100644 (file)
index 0000000..5c33252
--- /dev/null
@@ -0,0 +1,100 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FrontPage.h\r
+\r
+Abstract:\r
+\r
+  FrontPage routines to handle the callbacks and browser calls\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _FRONT_PAGE_H\r
+#define _FRONT_PAGE_H\r
+\r
+#include "Generic/DeviceMngr/DeviceManager.h"\r
+#include "Generic/BootMaint/BootMaint.h"\r
+#include "Generic/BootMngr/BootManager.h"\r
+\r
+//\r
+// This is the VFR compiler generated header file which defines the\r
+// string identifiers.\r
+//\r
+#include "BdsStrDefs.h"\r
+#define EFI_DISK_DEVICE_CLASS           0x01\r
+#define EFI_VIDEO_DEVICE_CLASS          0x02\r
+#define EFI_NETWORK_DEVICE_CLASS        0x04\r
+#define EFI_INPUT_DEVICE_CLASS          0x08\r
+#define EFI_ON_BOARD_DEVICE_CLASS       0x10\r
+#define EFI_OTHER_DEVICE_CLASS          0x20\r
+#define EFI_VBIOS_CLASS                 0x40\r
+\r
+#define SET_VIDEO_BIOS_TYPE_QUESTION_ID 0x00\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT8 VideoBIOS;\r
+} MyDevMgrIfrNVData;\r
+#pragma pack()\r
+\r
+#define EFI_FP_CALLBACK_DATA_SIGNATURE  EFI_SIGNATURE_32 ('F', 'P', 'C', 'B')\r
+#define EFI_FP_CALLBACK_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      EFI_FRONTPAGE_CALLBACK_INFO, \\r
+      DevMgrCallback, \\r
+      EFI_FP_CALLBACK_DATA_SIGNATURE \\r
+      )\r
+\r
+typedef struct {\r
+  UINTN                       Signature;\r
+  MyDevMgrIfrNVData           Data;\r
+  EFI_HII_HANDLE              DevMgrHiiHandle;\r
+  EFI_HANDLE                  CallbackHandle;\r
+  EFI_FORM_CALLBACK_PROTOCOL  DevMgrCallback;\r
+} EFI_FRONTPAGE_CALLBACK_INFO;\r
+\r
+//\r
+// These are the VFR compiler generated data representing our VFR data.\r
+//\r
+// BugBug: we should put g in front of these tool generated globals.\r
+//         maybe even gVrf would be a better prefix\r
+//\r
+extern UINT8  FrontPageVfrBin[];\r
+extern UINT8  FrontPageStringsStr[];\r
+extern UINT8  DeviceManagerVfrBin[];\r
+extern UINT8  DeviceManagerStringsStr[];\r
+\r
+#define FRONT_PAGE_QUESTION_ID  0x0000\r
+#define FRONT_PAGE_DATA_WIDTH   0x01\r
+\r
+EFI_STATUS\r
+InitializeFrontPage (\r
+  IN BOOLEAN    ReInitializeStrings\r
+  );\r
+\r
+BOOLEAN\r
+TimeCompare (\r
+  IN EFI_TIME               *FirstTime,\r
+  IN EFI_TIME               *SecondTime\r
+  );\r
+\r
+VOID\r
+PlatformBdsEnterFrontPage (\r
+  IN UINT16                 TimeoutDefault,\r
+  IN BOOLEAN                ConnectAllHappened\r
+  );\r
+\r
+#endif // _FRONT_PAGE_H_\r
+\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageStrings.uni b/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageStrings.uni
new file mode 100644 (file)
index 0000000..76dbdcf
Binary files /dev/null and b/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageStrings.uni differ
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageVfr.Vfr b/EdkUnixPkg/Dxe/PlatformBds/Generic/FrontPageVfr.Vfr
new file mode 100644 (file)
index 0000000..77efd2d
--- /dev/null
@@ -0,0 +1,159 @@
+// *++\r
+//\r
+// Copyright (c) 2006, Intel Corporation                                                         \r
+// All rights reserved. This program and the accompanying materials                          \r
+// are licensed and made available under the terms and conditions of the BSD License         \r
+// which accompanies this distribution.  The full text of the license may be found at        \r
+// http://opensource.org/licenses/bsd-license.php                                            \r
+//                                                                                           \r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+// \r
+// Module Name:\r
+//\r
+//   FrontPageVfr.vfr \r
+// \r
+// Abstract:\r
+// \r
+//   Browser formset.\r
+// \r
+// Revision History: \r
+// \r
+// --*/\r
+\r
+#include "BdsStrDefs.h"\r
+\r
+#define FORMSET_GUID  { 0x9e0c30bc, 0x3f06, 0x4ba6, { 0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe } }\r
+\r
+#define FRONT_PAGE_ITEM_ONE    0x0001\r
+#define FRONT_PAGE_ITEM_TWO    0x0002\r
+#define FRONT_PAGE_ITEM_THREE  0x0003\r
+#define FRONT_PAGE_ITEM_FOUR   0x0004\r
+#define FRONT_PAGE_ITEM_FIVE   0x0005\r
+\r
+#define FRONT_PAGE_TIMEOUT     0xFFFF\r
+#define FRONT_PAGE_CLASS       0x0000\r
+#define FRONT_PAGE_SUBCLASS    0x0002\r
+\r
+formset \r
+  guid     = FORMSET_GUID,\r
+  title    = STRING_TOKEN(STR_FRONT_PAGE_TITLE),  \r
+  help     = STRING_TOKEN(STR_NULL_STRING),\r
+  class    = FRONT_PAGE_CLASS,      \r
+  subclass = FRONT_PAGE_SUBCLASS,\r
+\r
+  form formid = 0x1000,\r
+       title  = STRING_TOKEN(STR_FRONT_PAGE_TITLE);\r
+\r
+    banner \r
+      title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),\r
+      line  0,\r
+      align left;\r
+    \r
+    banner \r
+      title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL),\r
+      line  1,\r
+      align left;\r
+    \r
+    banner \r
+      title = STRING_TOKEN(STR_FRONT_PAGE_CPU_SPEED),\r
+      line  1,\r
+      align right;\r
+    \r
+    banner \r
+      title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION),\r
+      line  2,\r
+      align left;\r
+    \r
+    banner \r
+      title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE),\r
+      line  2,\r
+      align right;\r
+\r
+//    banner \r
+//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_LEFT),\r
+//      line  0,\r
+//      align left;\r
+    \r
+//    banner \r
+//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_0_RIGHT),\r
+//      line  0,\r
+//      align right;\r
+    \r
+//    banner \r
+//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_LEFT),\r
+//      line  1,\r
+//      align left;\r
+    \r
+//    banner \r
+//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_1_RIGHT),\r
+//      line  1,\r
+//      align right;\r
+    \r
+//    banner \r
+//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_2_LEFT),\r
+//      line  2,\r
+//      align left;\r
+    \r
+//    banner \r
+//      title = STRING_TOKEN(STR_FRONT_PAGE_BANNER_3_LEFT),\r
+//      line  3,\r
+//      align left;\r
+\r
+    goto FRONT_PAGE_ITEM_ONE, \r
+      prompt  = STRING_TOKEN(STR_CONTINUE_PROMPT), \r
+      help    = STRING_TOKEN(STR_CONTINUE_HELP),\r
+      flags   = INTERACTIVE | NV_ACCESS, \r
+      key     = 0x0001;\r
+\r
+    label FRONT_PAGE_ITEM_TWO;\r
+    //\r
+    // This is where we will dynamically add a OneOf type op-code to select Languages from the\r
+    // currently available choices\r
+    //\r
+\r
+    goto FRONT_PAGE_ITEM_THREE, \r
+      prompt  = STRING_TOKEN(STR_BOOT_MANAGER), \r
+      help    = STRING_TOKEN(STR_BOOT_MANAGER_HELP),\r
+      flags   = INTERACTIVE | NV_ACCESS, \r
+      key     = 0x1064;\r
+\r
+    goto FRONT_PAGE_ITEM_FOUR, \r
+      prompt  = STRING_TOKEN(STR_DEVICE_MANAGER), \r
+      help    = STRING_TOKEN(STR_DEVICE_MANAGER_HELP),\r
+      flags   = INTERACTIVE | NV_ACCESS, \r
+      key     = 0x8567;\r
+\r
+    goto FRONT_PAGE_ITEM_FIVE, \r
+      prompt  = STRING_TOKEN(STR_BOOT_MAINT_MANAGER), \r
+      help    = STRING_TOKEN(STR_BOOT_MAINT_MANAGER_HELP),\r
+      flags   = INTERACTIVE | NV_ACCESS, \r
+      key     = 0x9876;\r
+\r
+    label FRONT_PAGE_TIMEOUT;\r
+//  If one wanted to hard-code a value one could do it below, but our implementation follows EFI architecture\r
+//  and honors the TimeOut NV variable\r
+//\r
+//    banner\r
+//      title = STRING_TOKEN(STR_TIME_OUT_PROMPT),\r
+//      timeout = 0x000A;\r
+    \r
+  endform;\r
+\r
+  form formid = FRONT_PAGE_ITEM_ONE,\r
+       title  = STRING_TOKEN(STR_FRONT_PAGE_TITLE);  \r
+  endform;\r
+\r
+  form formid = FRONT_PAGE_ITEM_THREE,\r
+       title  = STRING_TOKEN(STR_FRONT_PAGE_TITLE);  \r
+  endform;\r
+\r
+  form formid = FRONT_PAGE_ITEM_FOUR,\r
+       title  = STRING_TOKEN(STR_FRONT_PAGE_TITLE);  \r
+  endform;\r
+\r
+  form formid = FRONT_PAGE_ITEM_FIVE,\r
+       title  = STRING_TOKEN(STR_FRONT_PAGE_TITLE);  \r
+  endform;\r
+\r
+endformset;\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/Language.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/Language.c
new file mode 100644 (file)
index 0000000..21d61f1
--- /dev/null
@@ -0,0 +1,431 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  language.c\r
+\r
+Abstract:\r
+\r
+ Language settings\r
+  \r
+Revision History\r
+\r
+--*/\r
+\r
+#include "String.h"\r
+#include "Language.h"\r
+\r
+#define NARROW_GLYPH_NUMBER 8\r
+#define WIDE_GLYPH_NUMBER   75\r
+\r
+//\r
+// Default language code, currently is English\r
+//\r
+CHAR8 *mDefaultLangCode = "eng";\r
+\r
+typedef struct {\r
+  EFI_HII_FONT_PACK FixedLength;\r
+  EFI_NARROW_GLYPH  NarrowArray[NARROW_GLYPH_NUMBER];\r
+  EFI_WIDE_GLYPH    WideArray[WIDE_GLYPH_NUMBER];\r
+} FONT_PACK;\r
+\r
+FONT_PACK mFontPack = {\r
+  sizeof (EFI_HII_FONT_PACK) + (NARROW_GLYPH_NUMBER * sizeof (EFI_NARROW_GLYPH)) + (WIDE_GLYPH_NUMBER * sizeof (EFI_WIDE_GLYPH)),\r
+  EFI_HII_FONT,\r
+  NARROW_GLYPH_NUMBER,\r
+  WIDE_GLYPH_NUMBER,\r
+  {     // Narrow Glyphs\r
+    {\r
+      0x05d0,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x4E,\r
+        0x6E,\r
+        0x62,\r
+        0x32,\r
+        0x32,\r
+        0x3C,\r
+        0x68,\r
+        0x4C,\r
+        0x4C,\r
+        0x46,\r
+        0x76,\r
+        0x72,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x05d1,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x78,\r
+        0x7C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x7E,\r
+        0x7E,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x05d2,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x78,\r
+        0x7C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x1C,\r
+        0x3E,\r
+        0x66,\r
+        0x66,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x05d3,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x7E,\r
+        0x7E,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x05d4,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x7C,\r
+        0x7E,\r
+        0x06,\r
+        0x06,\r
+        0x06,\r
+        0x06,\r
+        0x66,\r
+        0x66,\r
+        0x66,\r
+        0x66,\r
+        0x66,\r
+        0x66,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x05d5,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x3C,\r
+        0x3C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x0C,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x05d6,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x38,\r
+        0x38,\r
+        0x1E,\r
+        0x1E,\r
+        0x18,\r
+        0x18,\r
+        0x18,\r
+        0x18,\r
+        0x18,\r
+        0x18,\r
+        0x18,\r
+        0x18,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },\r
+    {\r
+      0x0000,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    }\r
+  },\r
+  {     // Wide Glyphs\r
+    {\r
+      0x0020,\r
+      0x00,\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      },\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      },\r
+      {\r
+        0x00,\r
+        0x00,\r
+        0x00\r
+      }\r
+    },  //\r
+  }\r
+};\r
+\r
+VOID\r
+ExportFonts (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Routine to export glyphs to the HII database.  This is in addition to whatever is defined in the Graphics Console driver.\r
+\r
+Arguments:\r
+  None\r
+            \r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_HII_HANDLE    HiiHandle;\r
+  EFI_HII_PACKAGES  *PackageList;\r
+\r
+  PackageList = PreparePackages (1, NULL, &mFontPack);\r
+  //\r
+  // Register our Fonts into the global database\r
+  //\r
+  HiiHandle = 0;\r
+  Hii->NewPack (Hii, PackageList, &HiiHandle);\r
+\r
+  gBS->FreePool (PackageList);\r
+}\r
+\r
+VOID\r
+InitializeLanguage (\r
+  BOOLEAN LangCodesSettingRequired\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Determine the current language that will be used \r
+  based on language related EFI Variables\r
+\r
+Arguments:\r
+  LangCodesSettingRequired - If required to set LangCode variable\r
+            \r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       Index;\r
+  UINTN       Size;\r
+  CHAR8       LangCode[ISO_639_2_ENTRY_SIZE];\r
+  CHAR8       *LangCodes;\r
+  CHAR16      *LanguageString;\r
+\r
+  LanguageString  = NULL;\r
+  LangCodes       = NULL;\r
+\r
+  ExportFonts ();\r
+\r
+  //\r
+  // Collect the languages from what our current Language support is based on our VFR\r
+  //\r
+  Hii->GetPrimaryLanguages (Hii, gStringPackHandle, &LanguageString);\r
+\r
+  LangCodes = AllocatePool (StrLen (LanguageString));\r
+  ASSERT (LangCodes);\r
+\r
+  //\r
+  // Convert LanguageString from Unicode to EFI defined ASCII LangCodes\r
+  //\r
+  for (Index = 0; LanguageString[Index] != 0x0000; Index++) {\r
+    LangCodes[Index] = (CHAR8) LanguageString[Index];\r
+  }\r
+\r
+  LangCodes[Index] = 0;\r
+\r
+  if (LangCodesSettingRequired) {\r
+    Status = gRT->SetVariable (\r
+                    L"LangCodes",\r
+                    &gEfiGlobalVariableGuid,\r
+                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    AsciiStrLen (LangCodes),\r
+                    LangCodes\r
+                    );\r
+  }\r
+  //\r
+  // Find current LangCode from Lang NV Variable\r
+  //\r
+  Size = ISO_639_2_ENTRY_SIZE;\r
+  Status = gRT->GetVariable (\r
+                  L"Lang",\r
+                  &gEfiGlobalVariableGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  &LangCode\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = EFI_NOT_FOUND;\r
+    for (Index = 0; LangCodes[Index] != 0; Index += ISO_639_2_ENTRY_SIZE) {\r
+      if (CompareMem (&LangCodes[Index], LangCode, ISO_639_2_ENTRY_SIZE) == 0) {\r
+        Status = EFI_SUCCESS;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // If we cannot get language code from Lang variable,\r
+  // or LangCode cannot be found from language table,\r
+  // set the mDefaultLangCode to Lang variable.\r
+  //\r
+  if (EFI_ERROR (Status)) {\r
+    Status = gRT->SetVariable (\r
+                    L"Lang",\r
+                    &gEfiGlobalVariableGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    ISO_639_2_ENTRY_SIZE,\r
+                    mDefaultLangCode\r
+                    );\r
+  }\r
+\r
+  if (LangCodes) {\r
+    gBS->FreePool (LangCodes);\r
+  }\r
+\r
+  if (LanguageString != NULL) {\r
+    gBS->FreePool (LanguageString);\r
+  }\r
+\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/Language.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/Language.h
new file mode 100644 (file)
index 0000000..6b6d887
--- /dev/null
@@ -0,0 +1,36 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Language.h\r
+\r
+Abstract:\r
+  \r
+  Language setting\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _LANGUAGE_H\r
+#define _LANGUAGE_H\r
+\r
+#ifndef ISO_639_2_ENTRY_SIZE\r
+#define ISO_639_2_ENTRY_SIZE  3\r
+#endif\r
+\r
+VOID\r
+InitializeLanguage (\r
+  BOOLEAN LangCodesSettingRequired\r
+  );\r
+\r
+#endif // _LANGUAGE_H_\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/MemoryTest.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/MemoryTest.c
new file mode 100644 (file)
index 0000000..360a26f
--- /dev/null
@@ -0,0 +1,431 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MemoryTest.c\r
+\r
+Abstract:\r
+\r
+  Perform the platform memory test\r
+\r
+--*/\r
+\r
+#include "Bds.h"\r
+#include "BdsPlatform.h"\r
+#include "String.h"\r
+\r
+//\r
+// BDS Platform Functions\r
+//\r
+EFI_STATUS\r
+PlatformBdsShowProgress (\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,\r
+  IN CHAR16        *Title,\r
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,\r
+  IN UINTN         Progress,\r
+  IN UINTN         PreviousValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Show progress bar with title above it. It only works in UGA mode.\r
+\r
+Arguments:\r
+  \r
+  TitleForeground - Foreground color for Title.\r
+  TitleBackground - Background color for Title.\r
+  Title           - Title above progress bar.\r
+  ProgressColor   - Progress bar color.\r
+  Progress        - Progress (0-100)\r
+\r
+Returns: \r
+  \r
+  EFI_STATUS      - Success update the progress bar\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL   *GraphicsOutput;\r
+  EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+  UINT32                SizeOfX;\r
+  UINT32                SizeOfY;\r
+  UINT32                ColorDepth;\r
+  UINT32                RefreshRate;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;\r
+  UINTN                 BlockHeight;\r
+  UINTN                 BlockWidth;\r
+  UINTN                 BlockNum;\r
+  UINTN                 PosX;\r
+  UINTN                 PosY;\r
+  UINTN                 Index;\r
+\r
+  if (Progress > 100) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  UgaDraw = NULL;\r
+  Status = gBS->HandleProtocol (\r
+                  gST->ConsoleOutHandle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  &GraphicsOutput\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    GraphicsOutput = NULL;\r
+\r
+    Status = gBS->HandleProtocol (\r
+                    gST->ConsoleOutHandle,\r
+                    &gEfiUgaDrawProtocolGuid,\r
+                    &UgaDraw\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  if (GraphicsOutput != NULL) {\r
+    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
+  } else {\r
+    Status = UgaDraw->GetMode (\r
+                        UgaDraw,\r
+                        &SizeOfX,\r
+                        &SizeOfY,\r
+                        &ColorDepth,\r
+                        &RefreshRate\r
+                        );\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  BlockWidth  = SizeOfX / 100;\r
+  BlockHeight = SizeOfY / 50;\r
+\r
+  BlockNum    = Progress;\r
+\r
+  PosX        = 0;\r
+  PosY        = SizeOfY * 48 / 50;\r
+\r
+  if (BlockNum == 0) {\r
+    //\r
+    // Clear progress area\r
+    //\r
+    SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
+\r
+    if (GraphicsOutput != NULL) {\r
+      Status = GraphicsOutput->Blt (\r
+                          GraphicsOutput,\r
+                          &Color,\r
+                          EfiBltVideoFill,\r
+                          0,\r
+                          0,\r
+                          0,\r
+                          PosY - GLYPH_HEIGHT - 1,\r
+                          SizeOfX,\r
+                          SizeOfY - (PosY - GLYPH_HEIGHT - 1),\r
+                          SizeOfX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                          );\r
+    } else {\r
+      Status = UgaDraw->Blt (\r
+                          UgaDraw,\r
+                          (EFI_UGA_PIXEL *) &Color,\r
+                          EfiUgaVideoFill,\r
+                          0,\r
+                          0,\r
+                          0,\r
+                          PosY - GLYPH_HEIGHT - 1,\r
+                          SizeOfX,\r
+                          SizeOfY - (PosY - GLYPH_HEIGHT - 1),\r
+                          SizeOfX * sizeof (EFI_UGA_PIXEL)\r
+                          );\r
+    }\r
+  }\r
+  //\r
+  // Show progress by drawing blocks\r
+  //\r
+  for (Index = PreviousValue; Index < BlockNum; Index++) {\r
+    PosX = Index * BlockWidth;\r
+    if (GraphicsOutput != NULL) {\r
+      Status = GraphicsOutput->Blt (\r
+                          GraphicsOutput,\r
+                          &ProgressColor,\r
+                          EfiBltVideoFill,\r
+                          0,\r
+                          0,\r
+                          PosX,\r
+                          PosY,\r
+                          BlockWidth - 1,\r
+                          BlockHeight,\r
+                          (BlockWidth) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+                          );\r
+    } else {\r
+      Status = UgaDraw->Blt (\r
+                          UgaDraw,\r
+                          (EFI_UGA_PIXEL *) &ProgressColor,\r
+                          EfiUgaVideoFill,\r
+                          0,\r
+                          0,\r
+                          PosX,\r
+                          PosY,\r
+                          BlockWidth - 1,\r
+                          BlockHeight,\r
+                          (BlockWidth) * sizeof (EFI_UGA_PIXEL)\r
+                          );\r
+    }\r
+  }\r
+\r
+  PrintXY (\r
+    (SizeOfX - StrLen (Title) * GLYPH_WIDTH) / 2,\r
+    PosY - GLYPH_HEIGHT - 1,\r
+    &TitleForeground,\r
+    &TitleBackground,\r
+    Title\r
+    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BdsMemoryTest (\r
+  IN EXTENDMEM_COVERAGE_LEVEL Level\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Perform the memory test base on the memory test intensive level, \r
+  and update the memory resource.\r
+\r
+Arguments:\r
+  \r
+  Level  - The memory test intensive level.\r
+\r
+Returns: \r
+  \r
+  EFI_STATUS      - Success test all the system memory and update\r
+                    the memory resource\r
+                    \r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_STATUS                        InitStatus;\r
+  EFI_STATUS                        KeyStatus;\r
+  EFI_STATUS                        ReturnStatus;\r
+  BOOLEAN                           RequireSoftECCInit;\r
+  EFI_GENERIC_MEMORY_TEST_PROTOCOL  *GenMemoryTest;\r
+  UINT64                            TestedMemorySize;\r
+  UINT64                            TotalMemorySize;\r
+  UINTN                             TestPercent;\r
+  UINT64                            PreviousValue;\r
+  BOOLEAN                           ErrorOut;\r
+  BOOLEAN                           TestAbort;\r
+  EFI_INPUT_KEY                     Key;\r
+  CHAR16                            StrPercent[16];\r
+  CHAR16                            *StrTotalMemory;\r
+  CHAR16                            *Pos;\r
+  CHAR16                            *TmpStr;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Foreground;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Background;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     Color;\r
+  UINT8                             Value;\r
+  UINTN                             DataSize;\r
+\r
+  ReturnStatus = EFI_SUCCESS;\r
+  ZeroMem (&Key, sizeof (EFI_INPUT_KEY));\r
+\r
+  Pos = AllocatePool (128);\r
+\r
+  if (Pos == NULL) {\r
+    return ReturnStatus;\r
+  }\r
+\r
+  StrTotalMemory    = Pos;\r
+\r
+  TestedMemorySize  = 0;\r
+  TotalMemorySize   = 0;\r
+  PreviousValue     = 0;\r
+  ErrorOut          = FALSE;\r
+  TestAbort         = FALSE;\r
+\r
+  SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
+  SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
+  SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
+\r
+  RequireSoftECCInit = FALSE;\r
+\r
+  gST->ConOut->ClearScreen (gST->ConOut);\r
+  gST->ConOut->SetAttribute (gST->ConOut, EFI_YELLOW | EFI_BRIGHT);\r
+  gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiGenericMemTestProtocolGuid,\r
+                  NULL,\r
+                  &GenMemoryTest\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (Pos);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  InitStatus = GenMemoryTest->MemoryTestInit (\r
+                                GenMemoryTest,\r
+                                Level,\r
+                                &RequireSoftECCInit\r
+                                );\r
+  if (InitStatus == EFI_NO_MEDIA) {\r
+    //\r
+    // The PEI codes also have the relevant memory test code to check the memory,\r
+    // it can select to test some range of the memory or all of them. If PEI code\r
+    // checks all the memory, this BDS memory test will has no not-test memory to\r
+    // do the test, and then the status of EFI_NO_MEDIA will be returned by\r
+    // "MemoryTestInit". So it does not need to test memory again, just return.\r
+    //\r
+    gBS->FreePool (Pos);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  gST->ConOut->SetCursorPosition (gST->ConOut, 0, 2);\r
+  TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST));\r
+\r
+  if (TmpStr != NULL) {\r
+    gST->ConOut->OutputString (gST->ConOut, TmpStr);\r
+    gBS->FreePool (TmpStr);\r
+  }\r
+\r
+  do {\r
+    Status = GenMemoryTest->PerformMemoryTest (\r
+                              GenMemoryTest,\r
+                              &TestedMemorySize,\r
+                              &TotalMemorySize,\r
+                              &ErrorOut,\r
+                              TestAbort\r
+                              );\r
+    if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {\r
+      TmpStr = GetStringById (STRING_TOKEN (STR_SYSTEM_MEM_ERROR));\r
+      if (TmpStr != NULL) {\r
+        PrintXY (10, 10, NULL, NULL, TmpStr);\r
+        gST->ConOut->SetCursorPosition (gST->ConOut, 0, 4);\r
+        gST->ConOut->OutputString (gST->ConOut, TmpStr);\r
+        gBS->FreePool (TmpStr);\r
+      }\r
+\r
+      ASSERT (0);\r
+    }\r
+\r
+    TestPercent = (UINTN) DivU64x32 (\r
+                            DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16),\r
+                            (UINTN)DivU64x32 (TotalMemorySize, 16)\r
+                            );\r
+    if (TestPercent != PreviousValue) {\r
+      UnicodeValueToString (StrPercent, 0, TestPercent, 0);\r
+      gST->ConOut->SetCursorPosition (gST->ConOut, 0, 0);\r
+      TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));\r
+      if (TmpStr != NULL) {\r
+        BdsLibOutputStrings (gST->ConOut, StrPercent, TmpStr, NULL);\r
+        gBS->FreePool (TmpStr);\r
+      }\r
+\r
+      TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
+      if (TmpStr != NULL) {\r
+        PlatformBdsShowProgress (\r
+          Foreground,\r
+          Background,\r
+          TmpStr,\r
+          Color,\r
+          TestPercent,\r
+          (UINTN) PreviousValue\r
+          );\r
+        gBS->FreePool (TmpStr);\r
+      }\r
+    }\r
+\r
+    PreviousValue = TestPercent;\r
+\r
+    KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+    if (Key.ScanCode == SCAN_ESC) {\r
+      if (!RequireSoftECCInit) {\r
+        TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
+        if (TmpStr != NULL) {\r
+          PlatformBdsShowProgress (\r
+            Foreground,\r
+            Background,\r
+            TmpStr,\r
+            Color,\r
+            100,\r
+            (UINTN) PreviousValue\r
+            );\r
+          gBS->FreePool (TmpStr);\r
+        }\r
+\r
+        gST->ConOut->SetCursorPosition (gST->ConOut, 0, 0);\r
+        gST->ConOut->OutputString (gST->ConOut, L"100");\r
+        Status = GenMemoryTest->Finished (GenMemoryTest);\r
+        goto Done;\r
+      }\r
+\r
+      TestAbort = TRUE;\r
+    }\r
+  } while (Status != EFI_NOT_FOUND);\r
+\r
+  Status = GenMemoryTest->Finished (GenMemoryTest);\r
+\r
+Done:\r
+  UnicodeValueToString (StrTotalMemory, COMMA_TYPE, (UINTN) TotalMemorySize, 0);\r
+  if (StrTotalMemory[0] == L',') {\r
+    StrTotalMemory++;\r
+  }\r
+\r
+  TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));\r
+  if (TmpStr != NULL) {\r
+    StrCat (StrTotalMemory, TmpStr);\r
+    gBS->FreePool (TmpStr);\r
+  }\r
+\r
+  gST->ConOut->ClearScreen (gST->ConOut);\r
+  gST->ConOut->SetAttribute (gST->ConOut, EFI_YELLOW | EFI_BRIGHT);\r
+  gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
+  gST->ConOut->OutputString (gST->ConOut, StrTotalMemory);\r
+  PlatformBdsShowProgress (\r
+    Foreground,\r
+    Background,\r
+    StrTotalMemory,\r
+    Color,\r
+    100,\r
+    (UINTN) PreviousValue\r
+    );\r
+\r
+  gBS->FreePool (Pos);\r
+\r
+  DataSize = sizeof (Value);\r
+  Status = gRT->GetVariable (\r
+                  L"BootState",\r
+                  &gEfiBootStateGuid,\r
+                  NULL,\r
+                  &DataSize,\r
+                  &Value\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Value = 1;\r
+    gRT->SetVariable (\r
+          L"BootState",\r
+          &gEfiBootStateGuid,\r
+          EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+          sizeof (Value),\r
+          &Value\r
+          );\r
+  }\r
+\r
+  return ReturnStatus;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/String.c b/EdkUnixPkg/Dxe/PlatformBds/Generic/String.c
new file mode 100644 (file)
index 0000000..435665e
--- /dev/null
@@ -0,0 +1,136 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  string.c\r
+\r
+Abstract:\r
+\r
+  String support\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Bds.h"\r
+#include "String.h"\r
+#include "Language.h"\r
+\r
+extern UINT8  BdsStrings[];\r
+\r
+EFI_GUID      gBdsStringPackGuid = { 0x7bac95d3, 0xddf, 0x42f3, 0x9e, 0x24, 0x7c, 0x64, 0x49, 0x40, 0x37, 0x9a };\r
+\r
+EFI_HII_HANDLE    gStringPackHandle;\r
+EFI_HII_PROTOCOL  *Hii;\r
+\r
+EFI_STATUS\r
+InitializeStringSupport (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Initialize HII global accessor for string support\r
+\r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+  String from ID.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_HII_PACKAGES  *PackageList;\r
+  //\r
+  // There should only ever be one HII protocol\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiHiiProtocolGuid,\r
+                  NULL,\r
+                  &Hii\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    PackageList = PreparePackages (1, &gBdsStringPackGuid, BdsStrings);\r
+    Status      = Hii->NewPack (Hii, PackageList, &gStringPackHandle);\r
+    gBS->FreePool (PackageList);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+CHAR16 *\r
+GetStringById (\r
+  IN  STRING_REF   Id\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get string by string id from HII Interface\r
+\r
+Arguments:\r
+\r
+  Id       - String ID.\r
+           \r
+Returns:\r
+\r
+  CHAR16 * - String from ID.\r
+  NULL     - If error occurs.\r
+\r
+--*/\r
+{\r
+  CHAR16      *String;\r
+  UINTN       StringLength;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Set default string size assumption at no more than 256 bytes\r
+  //\r
+  StringLength  = 0x100;\r
+\r
+  String        = AllocateZeroPool (StringLength);\r
+  if (String == NULL) {\r
+    //\r
+    // If this happens, we are oh-so-dead, but return a NULL in any case.\r
+    //\r
+    return NULL;\r
+  }\r
+  //\r
+  // Get the current string for the current Language\r
+  //\r
+  Status = Hii->GetString (Hii, gStringPackHandle, Id, FALSE, NULL, &StringLength, String);\r
+  if (EFI_ERROR (Status)) {\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      //\r
+      // Free the old pool\r
+      //\r
+      gBS->FreePool (String);\r
+\r
+      //\r
+      // Allocate new pool with correct value\r
+      //\r
+      String = AllocatePool (StringLength);\r
+      ASSERT (String != NULL);\r
+\r
+      Status = Hii->GetString (Hii, gStringPackHandle, Id, FALSE, NULL, &StringLength, String);\r
+      if (!EFI_ERROR (Status)) {\r
+        return String;\r
+      }\r
+    }\r
+\r
+    return NULL;\r
+  }\r
+\r
+  return String;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/String.h b/EdkUnixPkg/Dxe/PlatformBds/Generic/String.h
new file mode 100644 (file)
index 0000000..b79df19
--- /dev/null
@@ -0,0 +1,59 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  string.h\r
+\r
+Abstract:\r
+  \r
+  String support\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _STRING_H_\r
+#define _STRING_H_\r
+\r
+//\r
+// This is the VFR compiler generated header file which defines the\r
+// string identifiers.\r
+//\r
+#include "BdsStrDefs.h"\r
+\r
+//\r
+// String Definition Guid for BDS Platform\r
+//\r
+#define EFI_BDS_PLATFORM_GUID \\r
+  { \\r
+    0x7777E939, 0xD57E, 0x4DCB, {0xA0, 0x8E, 0x64, 0xD7, 0x98, 0x57, 0x1E, 0x0F } \\r
+  }\r
+\r
+extern EFI_HII_HANDLE    gStringPackHandle;\r
+extern EFI_HII_PROTOCOL  *Hii;\r
+\r
+CHAR16            *\r
+GetStringById (\r
+  IN  STRING_REF   Id\r
+  );\r
+\r
+EFI_STATUS\r
+InitializeStringSupport (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+CallFrontPage (\r
+  VOID\r
+  );\r
+\r
+#endif // _STRING_H_\r
diff --git a/EdkUnixPkg/Dxe/PlatformBds/Generic/Strings.uni b/EdkUnixPkg/Dxe/PlatformBds/Generic/Strings.uni
new file mode 100644 (file)
index 0000000..41a6b9a
Binary files /dev/null and b/EdkUnixPkg/Dxe/PlatformBds/Generic/Strings.uni differ
diff --git a/EdkUnixPkg/Dxe/PlatformBds/PlatformBds.msa b/EdkUnixPkg/Dxe/PlatformBds/PlatformBds.msa
new file mode 100644 (file)
index 0000000..98de30f
--- /dev/null
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>Bds</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f392b762-8985-11db-be87-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Platfrom BDS driver</Abstract>\r
+    <Description>\r
+      Do platform action customized by IBV/OEM.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>Bds</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>EdkGraphicsLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DxeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PerformanceLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>EdkIfrSupportLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>EdkGenericBdsLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiRuntimeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DevicePathLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HiiLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>PlatformData.c</Filename>\r
+    <Filename>BdsPlatform.h</Filename>\r
+    <Filename>BdsPlatform.c</Filename>\r
+    <Filename>Generic/Bds.h</Filename>\r
+    <Filename>Generic/BdsEntry.c</Filename>\r
+    <Filename>Generic/FrontPage.h</Filename>\r
+    <Filename>Generic/FrontPage.c</Filename>\r
+    <Filename>Generic/FrontPageStrings.uni</Filename>\r
+    <Filename>Generic/FrontPageVfr.Vfr</Filename>\r
+    <Filename>Generic/Language.h</Filename>\r
+    <Filename>Generic/Language.c</Filename>\r
+    <Filename>Generic/String.h</Filename>\r
+    <Filename>Generic/String.c</Filename>\r
+    <Filename>Generic/Strings.uni</Filename>\r
+    <Filename>Generic/Capsules.c</Filename>\r
+    <Filename>Generic/MemoryTest.c</Filename>\r
+    <Filename>Generic/BootMaint/BmString.uni</Filename>\r
+    <Filename>Generic/BootMaint/Bm.vfr</Filename>\r
+    <Filename>Generic/BootMaint/BBSsupport.h</Filename>\r
+    <Filename>Generic/BootMaint/BootMaint.h</Filename>\r
+    <Filename>Generic/BootMaint/FormGuid.h</Filename>\r
+    <Filename>Generic/BootMaint/BmLib.c</Filename>\r
+    <Filename>Generic/BootMaint/BootOption.c</Filename>\r
+    <Filename>Generic/BootMaint/ConsoleOption.c</Filename>\r
+    <Filename>Generic/BootMaint/Data.c</Filename>\r
+    <Filename>Generic/BootMaint/Variable.c</Filename>\r
+    <Filename>Generic/BootMaint/UpdatePage.c</Filename>\r
+    <Filename>Generic/BootMaint/BBSsupport.c</Filename>\r
+    <Filename>Generic/BootMaint/BootMaint.c</Filename>\r
+    <Filename>Generic/BootMaint/FileExplorer.c</Filename>\r
+    <Filename>Generic/BootMaint/FE.vfr</Filename>\r
+    <Filename>Generic/BootMngr/BootManager.h</Filename>\r
+    <Filename>Generic/BootMngr/BootManager.c</Filename>\r
+    <Filename>Generic/BootMngr/BootManagerStrings.uni</Filename>\r
+    <Filename>Generic/BootMngr/BootManagerVfr.Vfr</Filename>\r
+    <Filename>Generic/DeviceMngr/DeviceManager.h</Filename>\r
+    <Filename>Generic/DeviceMngr/DeviceManager.c</Filename>\r
+    <Filename>Generic/DeviceMngr/DeviceManagerStrings.uni</Filename>\r
+    <Filename>Generic/DeviceMngr/DeviceManagerVfr.Vfr</Filename>\r
+    <Filename>Generic/Bds.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiBdsArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiLegacyBiosProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiUgaSplashProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiFormCallbackProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiFormBrowserProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiConsoleControlProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiCpuIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiLoadFileProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiSimpleFileSystemProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiSerialIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiGenericMemTestProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="SOMETIMES_CONSUMED">\r
+      <ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="SOMETIMES_CONSUMED">\r
+      <ProtocolCName>gEfiDriverBindingProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <DataHubs>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>BiosVendor</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>SystemManufacturer</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>ProcessorVersion</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>ProcessorFrequency</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>MemoryArray</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>SerialIoDevice</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>SerialIoPort</DataHubCName>\r
+    </DataHubRecord>\r
+  </DataHubs>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiBootStateGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiGlobalVariableGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiFlashMapHobGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiFileSystemVolumeLabelInfoIdGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiFileInfoGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>BdsInitialize</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/PlatformBds/PlatformData.c b/EdkUnixPkg/Dxe/PlatformBds/PlatformData.c
new file mode 100644 (file)
index 0000000..6bb9cca
--- /dev/null
@@ -0,0 +1,119 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name: \r
+\r
+  PlatformData.c\r
+\r
+Abstract:\r
+  \r
+  Defined the platform specific device path which will be used by\r
+  platform Bbd to perform the platform policy connect.\r
+\r
+--*/\r
+\r
+#include "Generic/Bds.h"\r
+#include "BdsPlatform.h"\r
+\r
+//\r
+// Predefined platform default time out value\r
+//\r
+UINT16                      gPlatformBootTimeOutDefault = 10;\r
+\r
+//\r
+// Platform specific keyboard device path\r
+//\r
+UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 = {\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+    (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
+    EFI_UNIX_THUNK_PROTOCOL_GUID\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
+    (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),\r
+    EFI_UNIX_UGA_GUID,\r
+    0\r
+  },\r
+  gEndEntire\r
+};\r
+\r
+UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+    (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
+    EFI_UNIX_THUNK_PROTOCOL_GUID\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
+    (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),\r
+    EFI_UNIX_UGA_GUID,\r
+    1\r
+  },\r
+  gEndEntire\r
+};\r
+\r
+UNIX_CONSOLE_DEVICE_PATH   gUnixConsoleDevicePath = {\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+    (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
+    EFI_UNIX_THUNK_PROTOCOL_GUID\r
+  },\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
+    (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),\r
+    EFI_UNIX_CONSOLE_GUID\r
+  },\r
+  gEndEntire\r
+};\r
+//\r
+// Predefined platform default console device path\r
+//\r
+BDS_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {\r
+  {\r
+    (EFI_DEVICE_PATH_PROTOCOL *) &gUnixConsoleDevicePath,\r
+    (CONSOLE_OUT | CONSOLE_IN)\r
+  },\r
+  {\r
+    (EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath0,\r
+    (CONSOLE_OUT | CONSOLE_IN)\r
+  },\r
+  {\r
+    (EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath1,\r
+    (CONSOLE_OUT | CONSOLE_IN)\r
+  },\r
+  {\r
+    NULL,\r
+    0\r
+  }\r
+};\r
+\r
+//\r
+// Predefined platform specific driver option\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL    *gPlatformDriverOption[] = { NULL };\r
+\r
+//\r
+// Predefined platform connect sequence\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL    *gPlatformConnectSequence[] = { NULL };\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturer.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturer.uni
new file mode 100644 (file)
index 0000000..14a6893
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturer.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturerData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBaseBoardManufacturerData.c
new file mode 100644 (file)
index 0000000..9536c88
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscBaseBoardManufacturerData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer) = {\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_VERSION),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_SERIAL_NUMBER),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_ASSET_TAG),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_CHASSIS_LOCATION),\r
+  {                         // BaseBoardFeatureFlags\r
+    1,                      // Motherboard\r
+    0,                      // RequiresDaughterCard\r
+    0,                      // Removable\r
+    1,                      // Replaceable,\r
+    0,                      // HotSwappable\r
+    0,                      // Reserved\r
+  },\r
+  EfiBaseBoardTypeUnknown,  // BaseBoardType\r
+  {                         // BaseBoardChassisLink\r
+    EFI_MISC_SUBCLASS_GUID, // ProducerName\r
+    1,                      // Instance\r
+    1,                      // SubInstance\r
+  },\r
+  0,                        // BaseBoardNumberLinks\r
+  {                         // LinkN\r
+    EFI_MISC_SUBCLASS_GUID, // ProducerName\r
+    1,                      // Instance\r
+    1,                      // SubInstance\r
+  },\r
+};\r
+\r
+/* eof - MiscBaseBoardManufacturerData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendor.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendor.uni
new file mode 100644 (file)
index 0000000..b1e7e52
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendor.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendorData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBiosVendorData.c
new file mode 100644 (file)
index 0000000..3187aba
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscBiosVendorData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor) = {\r
+  STRING_TOKEN(STR_MISC_BIOS_VENDOR),       // BiosVendor\r
+  STRING_TOKEN(STR_MISC_BIOS_VERSION),      // BiosVersion\r
+  STRING_TOKEN(STR_MISC_BIOS_RELEASE_DATE), // BiosReleaseDate\r
+  0xBABE, // BiosStartingAddress\r
+  {       // BiosPhysicalDeviceSize\r
+    2,    // Value\r
+    3,    // Exponent\r
+  },\r
+  {       // BiosCharacteristics1\r
+    0,    // Reserved1                         :2\r
+    0,    // Unknown                           :1\r
+    1,    // BiosCharacteristicsNotSupported   :1\r
+    0,    // IsaIsSupported                    :1\r
+    0,    // McaIsSupported                    :1\r
+    0,    // EisaIsSupported                   :1\r
+    0,    // PciIsSupported                    :1\r
+    0,    // PcmciaIsSupported                 :1\r
+    0,    // PlugAndPlayIsSupported            :1\r
+    0,    // ApmIsSupported                    :1\r
+    0,    // BiosIsUpgradable                  :1\r
+    0,    // BiosShadowingAllowed              :1\r
+    0,    // VlVesaIsSupported                 :1\r
+    0,    // EscdSupportIsAvailable            :1\r
+    0,    // BootFromCdIsSupported             :1\r
+    0,    // SelectableBootIsSupported         :1\r
+    0,    // RomBiosIsSocketed                 :1\r
+    0,    // BootFromPcmciaIsSupported         :1\r
+    0,    // EDDSpecificationIsSupported       :1\r
+    0,    // JapaneseNecFloppyIsSupported      :1\r
+    0,    // JapaneseToshibaFloppyIsSupported  :1\r
+    0,    // Floppy525_360IsSupported          :1\r
+    0,    // Floppy525_12IsSupported           :1\r
+    0,    // Floppy35_720IsSupported           :1\r
+    0,    // Floppy35_288IsSupported           :1\r
+    0,    // PrintScreenIsSupported            :1\r
+    0,    // Keyboard8042IsSupported           :1\r
+    0,    // SerialIsSupported                 :1\r
+    0,    // PrinterIsSupported                :1\r
+    0,    // CgaMonoIsSupported                :1\r
+    0,    // NecPc98                           :1\r
+    0,    // AcpiIsSupported                   :1\r
+    0,    // UsbLegacyIsSupported              :1\r
+    0,    // AgpIsSupported                    :1\r
+    0,    // I20BootIsSupported                :1\r
+    0,    // Ls120BootIsSupported              :1\r
+    0,    // AtapiZipDriveBootIsSupported      :1\r
+    0,    // Boot1394IsSupported               :1\r
+    0,    // SmartBatteryIsSupported           :1\r
+    0,    // BiosBootSpecIsSupported           :1\r
+    0,    // FunctionKeyNetworkBootIsSupported :1\r
+    0     // Reserved                          :22\r
+  },\r
+  {       // BiosCharacteristics2\r
+    0,    // BiosReserved                      :16\r
+    0,    // SystemReserved                    :16\r
+    0     // Reserved                          :32\r
+  },\r
+};\r
+\r
+/* eof - MiscBiosVendorData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBootInformationData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscBootInformationData.c
new file mode 100644 (file)
index 0000000..1bf280b
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscBootInformationData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus) = {\r
+  EfiBootInformationStatusNoError,  // BootInformationStatus\r
+  0                                 // BootInformationData\r
+};\r
+\r
+/* eof - MiscBootInformationData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturer.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturer.uni
new file mode 100644 (file)
index 0000000..67bee85
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturer.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturerData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscChassisManufacturerData.c
new file mode 100644 (file)
index 0000000..5c657ee
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscChassisManufacturerData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Chassis Manufacturer data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer) = {\r
+  STRING_TOKEN(STR_MISC_CHASSIS_MANUFACTURER),  // ChassisManufactrurer\r
+  STRING_TOKEN(STR_MISC_CHASSIS_VERSION),       // ChassisVersion\r
+  STRING_TOKEN(STR_MISC_CHASSIS_SERIAL_NUMBER), // ChassisSerialNumber\r
+  STRING_TOKEN(STR_MISC_CHASSIS_ASSET_TAG),     // ChassisAssetTag\r
+  {                               // ChassisTypeStatus\r
+    EfiMiscChassisTypeOther,      // ChassisType\r
+    0,                            // ChassisLockPresent\r
+    0                             // Reserved\r
+  },\r
+  EfiChassisStateOther,           // ChassisBootupState\r
+  EfiChassisStateOther,           // ChassisPowerSupplyState\r
+  EfiChassisStateOther,           // ChassisThermalState\r
+  EfiChassisSecurityStatusOther,  // ChassisSecurityState\r
+  0                               // ChassisOemDefined\r
+};\r
+\r
+/* eof - MiscChassisManufacaturerData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscDevicePath.h b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscDevicePath.h
new file mode 100644 (file)
index 0000000..dd78a7a
--- /dev/null
@@ -0,0 +1,175 @@
+/*++\r
\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscDevicePath.h\r
+\r
+Abstract:\r
+\r
+  Misc class required EFI Device Path definitions (Ports, slots & \r
+  onboard devices)\r
+\r
+--*/\r
+\r
+#ifndef _MISC_DEVICE_PATH_H\r
+#define _MISC_DEVICE_PATH_H\r
+\r
+\r
+#pragma pack(1)\r
+//\r
+// USB\r
+//\r
+\r
+/* For reference:\r
+#define USB1_1_STR  "ACPI(PNP0A03,0)/PCI(1D,0)."\r
+#define USB1_2_STR  "ACPI(PNP0A03,0)/PCI(1D,1)."\r
+#define USB1_3_STR  "ACPI(PNP0A03,0)/PCI(1D,2)."\r
+#define USB2_1_STR  "ACPI(PNP0A03,0)/PCI(1D,7)." \r
+*/\r
+\r
+//\r
+// #define acpi { 0x02, 0x01, 0x00, 0x0C, 0x0a0341d0, 0x00000000 }\r
+// #define pci( device,function)  { 0x01, 0x01, 0x00, 0x06, device, function }\r
+// #define end  { 0xFF, 0xFF, 0x00, 0x04 }\r
+//\r
+#define DP_ACPI \\r
+  { \\r
+    ACPI_DEVICE_PATH, ACPI_DP, (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \\r
+      ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8), EISA_PNP_ID (0x0A03), 0 \\r
+  }\r
+#define DP_PCI(device, function) \\r
+  { \\r
+    HARDWARE_DEVICE_PATH, HW_PCI_DP, (UINT8) (sizeof (PCI_DEVICE_PATH)), (UINT8) \\r
+      ((sizeof (PCI_DEVICE_PATH)) >> 8), function, device \\r
+  }\r
+#define DP_END \\r
+  { \\r
+    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, END_DEVICE_PATH_LENGTH, 0 \\r
+  }\r
+\r
+#define DP_LPC(eisaid, function) \\r
+  { \\r
+    ACPI_DEVICE_PATH, ACPI_DP, (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \\r
+      ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8), EISA_PNP_ID (eisaid), function \\r
+  }\r
+\r
+//\r
+// Shanmu >> moved to TianoDevicePath.h\r
+//\r
+\r
+/*\r
+typedef struct _USB_PORT_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} USB_PORT_DEVICE_PATH;\r
+\r
+\r
+//IDE ??I am not sure. Should this be ATAPI_DEVICE_PATH\r
+typedef struct _IDE_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} IDE_DEVICE_PATH;\r
+\r
+//RMC Connector\r
+typedef struct _RMC_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} RMC_CONN_DEVICE_PATH;\r
+\r
+//static RMC_CONN_DEVICE_PATH mRmcConnDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x0A,0x00 ), end };\r
+\r
+//RIDE\r
+typedef struct _RIDE_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} RIDE_DEVICE_PATH;\r
+\r
+//static RIDE_DEVICE_PATH mRideDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x02,0x00 ), end };\r
+\r
+//Gigabit NIC\r
+//typedef struct _GB_NIC_DEVICE_PATH\r
+//{\r
+//  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+//  PCI_DEVICE_PATH            PciBridgeDevicePath;\r
+//  PCI_DEVICE_PATH            PciXBridgeDevicePath;\r
+//  PCI_DEVICE_PATH            PciXBusDevicePath;\r
+//  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+//} GB_NIC_DEVICE_PATH;\r
+\r
+//static GB_NIC_DEVICE_PATH mGbNicDevicePath = { acpi, pci( 0x03,0x00 ),pci( 0x1F,0x00 ),pci( 0x07,0x00 ), end };\r
+\r
+\r
+//P/S2 Connector\r
+typedef struct _PS2_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} PS2_CONN_DEVICE_PATH;\r
+\r
+//static PS2_CONN_DEVICE_PATH mPs2KeyboardDevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,0 ), end };\r
+//static PS2_CONN_DEVICE_PATH mPs2MouseDevicePath      = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,1 ), end };\r
+\r
+//Serial Port Connector\r
+typedef struct _SERIAL_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} SERIAL_CONN_DEVICE_PATH;\r
+\r
+//static SERIAL_CONN_DEVICE_PATH mCom1DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,0 ), end };\r
+//static SERIAL_CONN_DEVICE_PATH mCom2DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,1 ), end };\r
+\r
+//Parallel Port Connector\r
+typedef struct _PARALLEL_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} PARALLEL_CONN_DEVICE_PATH;\r
+\r
+//static PARALLEL_CONN_DEVICE_PATH mLpt1DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0401,0 ), end };\r
+\r
+//Floopy Connector\r
+typedef struct _FLOOPY_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} FLOOPY_CONN_DEVICE_PATH;\r
+\r
+//static FLOOPY_CONN_DEVICE_PATH mFloopyADevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,0 ), end };\r
+//static FLOOPY_CONN_DEVICE_PATH mFloopyBDevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,1 ), end };\r
+\r
+*/\r
+\r
+//\r
+// End Shanmu\r
+//\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscNumberOfInstallableLanguagesData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscNumberOfInstallableLanguagesData.c
new file mode 100644 (file)
index 0000000..0084259
--- /dev/null
@@ -0,0 +1,37 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscNumberOfInstallableLanguagesData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA, NumberOfInstallableLanguages) = {\r
+  1,    // NumberOfInstallableLanguages\r
+  {     // LanguageFlags\r
+    0,  // AbbreviatedLanguageFormat\r
+    0   // Reserved\r
+  },\r
+  0,    // CurrentLanguageNumber\r
+};\r
+\r
+/* eof - MiscNumberOfInstallableLanguagesData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemString.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemString.uni
new file mode 100644 (file)
index 0000000..fb79bdb
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemString.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemStringData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscOemStringData.c
new file mode 100644 (file)
index 0000000..fdfbd1f
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MiscOemStringData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_OEM_STRING_DATA, OemString) = {\r
+  STRING_TOKEN(STR_MISC_OEM_STRING)\r
+};\r
+\r
+/* eof - MiscOemStringData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignator.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignator.uni
new file mode 100644 (file)
index 0000000..b6a617b
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignator.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignatorData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignatorData.c
new file mode 100644 (file)
index 0000000..d886a9d
--- /dev/null
@@ -0,0 +1,99 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscPortInternalConnectorDesignatorData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR),  // PortInternalConnectorDesignator\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR),  // PortExternalConnectorDesignator\r
+  EfiPortConnectorTypeOther,  // PortInternalConnectorType\r
+  EfiPortConnectorTypeOther,  // PortExternalConnectorType\r
+  EfiPortTypeNone,            // PortType\r
+  0                           // PortPath\r
+};\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard) = {\r
+  STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD),   // PortInternalConnectorDesignator\r
+  STRING_TOKEN (STR_MISC_PORT_EXTERNAL_KEYBOARD),   // PortExternalConnectorDesignator\r
+  EfiPortConnectorTypeNone, // PortInternalConnectorType\r
+  EfiPortConnectorTypePS2,  // PortExternalConnectorType\r
+  EfiPortTypeKeyboard,      // PortType\r
+  // mPs2KbyboardDevicePath                          // PortPath\r
+  //\r
+  0\r
+};\r
+\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse) = {\r
+  STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE),      // PortInternalConnectorDesignator\r
+  STRING_TOKEN (STR_MISC_PORT_EXTERNAL_MOUSE),      // PortExternalConnectorDesignator\r
+  EfiPortConnectorTypeNone, // PortInternalConnectorType\r
+  EfiPortConnectorTypePS2,  // PortExternalConnectorType\r
+  EfiPortTypeMouse,         // PortType\r
+  // mPs2MouseDevicePath                // PortPath\r
+  //\r
+  0\r
+};\r
+\r
+\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM1),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1),\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortConnectorTypeDB9Female,\r
+  EfiPortTypeSerial16550ACompatible,\r
+  0\r
+};\r
+\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM2),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2),\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortConnectorTypeDB9Female,\r
+  EfiPortTypeSerial16550ACompatible,\r
+  0\r
+};\r
+\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_EXTENSION_POWER),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER),\r
+  EfiPortConnectorTypeOther,\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortTypeOther,\r
+  0\r
+};\r
+\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_FLOPPY),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY),\r
+  EfiPortConnectorTypeOnboardFloppy,\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortTypeOther,\r
+  0\r
+};\r
+\r
+/* eof - MiscPortInternalConnectorDesignatorData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignatorFunction.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscPortInternalConnectorDesignatorFunction.c
new file mode 100644 (file)
index 0000000..35351aa
--- /dev/null
@@ -0,0 +1,266 @@
+/*++\r
\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscPortInternalConnectorDesignatorFunction.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+//\r
+//\r
+MISC_SUBCLASS_TABLE_FUNCTION (\r
+  MiscPortInternalConnectorDesignator\r
+  )\r
+/*++\r
+Description:\r
+\r
+  This function makes boot time changes to the contents of the\r
+  MiscPortConnectorInformation (Type 8).\r
+\r
+Parameters:\r
+\r
+  RecordType\r
+    Type of record to be processed from the Data Table.\r
+    mMiscSubclassDataTable[].RecordType\r
+\r
+  RecordLen\r
+    Size of static RecordData from the Data Table.\r
+    mMiscSubclassDataTable[].RecordLen\r
+\r
+  RecordData\r
+    Pointer to copy of RecordData from the Data Table.  Changes made\r
+    to this copy will be written to the Data Hub but will not alter\r
+    the contents of the static Data Table.\r
+\r
+  LogRecordData\r
+    Set *LogRecordData to TRUE to log RecordData to Data Hub.\r
+    Set *LogRecordData to FALSE when there is no more data to log.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+    All parameters were valid and *RecordData and *LogRecordData have\r
+    been set.\r
+\r
+  EFI_UNSUPPORTED\r
+    Unexpected RecordType value.\r
+\r
+  EFI_INVALID_PARAMETER\r
+    One of the following parameter conditions was true:\r
+      RecordLen was zero.\r
+      RecordData was NULL.\r
+      LogRecordData was NULL.\r
+--*/\r
+{\r
+  STATIC BOOLEAN                    Done                    = FALSE;\r
+  STATIC PS2_CONN_DEVICE_PATH       mPs2KeyboardDevicePath  = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 0), DP_END };\r
+  STATIC PS2_CONN_DEVICE_PATH       mPs2MouseDevicePath     = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 1), DP_END };\r
+  STATIC SERIAL_CONN_DEVICE_PATH    mCom1DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 0), DP_END };\r
+  STATIC SERIAL_CONN_DEVICE_PATH    mCom2DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 1), DP_END };\r
+  STATIC PARALLEL_CONN_DEVICE_PATH  mLpt1DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0401, 0), DP_END };\r
+  STATIC FLOOPY_CONN_DEVICE_PATH    mFloopyADevicePath      = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 0), DP_END };\r
+  STATIC FLOOPY_CONN_DEVICE_PATH    mFloopyBDevicePath      = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 1), DP_END };\r
+  STATIC USB_PORT_DEVICE_PATH       mUsb0DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x00), DP_END };\r
+  STATIC USB_PORT_DEVICE_PATH       mUsb1DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x01), DP_END };\r
+  STATIC USB_PORT_DEVICE_PATH       mUsb2DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x02), DP_END };\r
+  STATIC USB_PORT_DEVICE_PATH       mUsb3DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x07), DP_END };\r
+  STATIC IDE_DEVICE_PATH            mIdeDevicePath          = { DP_ACPI, DP_PCI (0x1F, 0x01), DP_END };\r
+  STATIC GB_NIC_DEVICE_PATH         mGbNicDevicePath        = { DP_ACPI, DP_PCI( 0x03,0x00 ),DP_PCI( 0x1F,0x00 ),DP_PCI( 0x07,0x00 ), DP_END };\r
+  EFI_DEVICE_PATH_PROTOCOL          EndDevicePath           = DP_END;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  // Shanmu >> to fix the Device Path Issue...\r
+  // if (RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {\r
+  //\r
+  if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {\r
+    //\r
+    // End Shanmu\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Then check for unsupported RecordType.\r
+  //\r
+  if (RecordType != EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Is this the first time through this function?\r
+  //\r
+  if (!Done) {\r
+    //\r
+    // Yes, this is the first time.  Inspect/Change the contents of the\r
+    // RecordData structure.\r
+    //\r
+    //\r
+    // Device path is only updated here as it was not taking that in static data\r
+    //\r
+    // Shanmu >> to fix the Device Path Issue...\r
+    //\r
+\r
+    /*\r
+    switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortInternalConnectorDesignator) \r
+    {\r
+      case STR_MISC_PORT_INTERNAL_MOUSE:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2MouseDevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2KeyboardDevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_COM1:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom1DevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_COM2:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom2DevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_LPT1:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mLpt1DevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_USB1:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb0DevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_USB2:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb1DevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_USB3:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb2DevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_NETWORK:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mGbNicDevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_FLOPPY:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mFloopyADevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_IDE1:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);          \r
+        }break;\r
+      case STR_MISC_PORT_INTERNAL_IDE2:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);          \r
+        }break;\r
+      default:\r
+        {\r
+          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = EndDevicePath;\r
+        }break;    \r
+    }\r
+    */\r
+    switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortInternalConnectorDesignator) {\r
+    case STR_MISC_PORT_INTERNAL_MOUSE:\r
+      {\r
+        CopyMem (\r
+          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
+          &mPs2MouseDevicePath,\r
+          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath)\r
+          );\r
+        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath);\r
+      }\r
+      break;\r
+\r
+    case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
+      {\r
+        CopyMem (\r
+          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
+          &mPs2KeyboardDevicePath,\r
+          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath)\r
+          );\r
+        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath);\r
+      }\r
+      break;\r
+\r
+    case STR_MISC_PORT_INTERNAL_COM1:\r
+      {\r
+        CopyMem (\r
+          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
+          &mCom1DevicePath,\r
+          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath)\r
+          );\r
+        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath);\r
+      }\r
+      break;\r
+\r
+    case STR_MISC_PORT_INTERNAL_COM2:\r
+      {\r
+        CopyMem (\r
+          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
+          &mCom2DevicePath,\r
+          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath)\r
+          );\r
+        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath);\r
+      }\r
+      break;\r
+\r
+    case STR_MISC_PORT_INTERNAL_FLOPPY:\r
+      {\r
+        CopyMem (\r
+          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
+          &mFloopyADevicePath,\r
+          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath)\r
+          );\r
+        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath);\r
+      }\r
+      break;\r
+\r
+    default:\r
+      {\r
+        CopyMem (\r
+          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
+          &EndDevicePath,\r
+          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath)\r
+          );\r
+        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath);\r
+      }\r
+      break;\r
+    }\r
+    //\r
+    // End Shanmu\r
+    //\r
+    // Set Done flag to TRUE for next pass through this function.\r
+    // Set *LogRecordData to TRUE so data will get logged to Data Hub.\r
+    //\r
+    Done            = TRUE;\r
+    *LogRecordData  = TRUE;\r
+  } else {\r
+    //\r
+    // No, this is the second time.  Reset the state of the Done flag\r
+    // to FALSE and tell the data logger that there is no more data\r
+    // to be logged for this record type.  If any memory allocations\r
+    // were made by earlier passes, they must be released now.\r
+    //\r
+    Done            = FALSE;\r
+    *LogRecordData  = FALSE;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/* eof - MiscSystemManufacturerFunction.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscResetCapabilitiesData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscResetCapabilitiesData.c
new file mode 100644 (file)
index 0000000..6e0c1bb
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MiscResetCapabilitiesData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities) = {\r
+  {     // ResetCapabilities\r
+    0,  // Status\r
+    0,  // BootOption\r
+    0,  // BootOptionOnLimit\r
+    0,  // WatchdogTimerPresent\r
+    0   // Reserved\r
+  },\r
+  0,    // ResetCount\r
+  0,    // ResetLimit\r
+  0,    // ResetTimerInterval\r
+  0     // ResetTimeout\r
+};\r
+\r
+/* eof - MiscResetCapabilities.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.dxs b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.dxs
new file mode 100644 (file)
index 0000000..8698317
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriver.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression file for MiscSubclass Driver.\r
+  \r
+--*/\r
+\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  EFI_DATA_HUB_PROTOCOL_GUID AND EFI_HII_PROTOCOL_GUID\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.h b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.h
new file mode 100644 (file)
index 0000000..32f591f
--- /dev/null
@@ -0,0 +1,104 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriver.h\r
+\r
+Abstract:\r
+\r
+  Header file for MiscSubclass Driver.\r
+\r
+--*/\r
+\r
+#ifndef _MISC_SUBCLASS_DRIVER_H\r
+#define _MISC_SUBCLASS_DRIVER_H\r
+\r
+\r
+#include <MiscDevicePath.h>\r
+\r
+//\r
+// Autogen string file\r
+//\r
+#include <MiscSubclassStrDefs.h>\r
+\r
+//\r
+// Data table entry update function.\r
+//\r
+typedef \r
+EFI_STATUS \r
+(EFIAPI EFI_MISC_SUBCLASS_DATA_FUNCTION) (\r
+  IN UINT16                         RecordType,\r
+  IN UINT32                         *RecordLen,\r
+  IN OUT EFI_MISC_SUBCLASS_RECORDS  *RecordData,\r
+  OUT BOOLEAN                       *LogRecordData\r
+  );\r
+\r
+//\r
+// Data table entry definition.\r
+//\r
+typedef struct {\r
+  UINT16                          RecordType;\r
+  UINT32                          RecordLen;\r
+  VOID                            *RecordData;\r
+  EFI_MISC_SUBCLASS_DATA_FUNCTION *Function;\r
+} EFI_MISC_SUBCLASS_DATA_TABLE;\r
+\r
+//\r
+// Data Table extern definitions.\r
+//\r
+#define MISC_SUBCLASS_TABLE_EXTERNS(NAME1, NAME2) \\r
+  extern NAME1 NAME2 ## Data; \\r
+  extern EFI_MISC_SUBCLASS_DATA_FUNCTION NAME2 ## Function\r
+\r
+//\r
+// Data Table entries\r
+//\r
+#define MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(NAME1, NAME2) { \\r
+         NAME1 ##  _RECORD_NUMBER, sizeof (NAME1 ## _DATA), &NAME2 ## Data, NULL \\r
+  }\r
+\r
+#define MISC_SUBCLASS_TABLE_ENTRY_FUNCTION_ONLY(NAME1, NAME2) \\r
+  { \\r
+    NAME1 ##  _RECORD_NUMBER, 0, NULL, &NAME2 ## Function \\r
+  }\r
+\r
+#define MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2, NAME3) \\r
+  { \\r
+    NAME1 ##  _RECORD_NUMBER, sizeof (NAME1 ## _DATA), &NAME2 ## Data, &NAME3 ## Function \\r
+  }\r
+\r
+//\r
+// Global definition macros.\r
+//\r
+#define MISC_SUBCLASS_TABLE_DATA(NAME1, NAME2)  NAME1 NAME2 ## Data\r
+\r
+#define MISC_SUBCLASS_TABLE_FUNCTION(NAME2) \\r
+  EFI_STATUS EFIAPI NAME2 ## Function ( \\r
+  IN UINT16 RecordType, \\r
+  IN UINT32 *RecordLen, \\r
+  IN OUT EFI_MISC_SUBCLASS_RECORDS * RecordData, \\r
+  OUT BOOLEAN *LogRecordData \\r
+  )\r
+\r
+//\r
+// Data Table Array\r
+//\r
+extern EFI_MISC_SUBCLASS_DATA_TABLE mMiscSubclassDataTable[];\r
+\r
+//\r
+// Data Table Array Entries\r
+//\r
+extern UINTN  mMiscSubclassDataTableEntries;\r
+\r
+#endif /* _MISC_SUBCLASS_DRIVER_H */\r
+\r
+/* eof - MiscSubclassDriver.h */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.msa b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.msa
new file mode 100644 (file)
index 0000000..b9f0992
--- /dev/null
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>MiscSubclass</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f2fbd108-8985-11db-b06a-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Misc Sub class driver</Abstract>\r
+    <Description>\r
+      Parses the MiscSubclassDataTable and reports any generated data to the DataHub.\r
+      All .uni file who tagged with "ToolCode="DUMMY"" in following file list is included by\r
+      MiscSubclassDriver.uni file, the StrGather tool will expand MiscSubclassDriver.uni file \r
+      and parse all .uni file.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>MiscSubclass</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HiiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DevicePathLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename ToolCode="DUMMY">MiscBaseBoardManufacturer.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscBiosVendor.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscChassisManufacturer.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscOemString.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscPortInternalConnectorDesignator.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscSystemLanguageString.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscSystemManufacturer.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscSystemOptionString.uni</Filename>\r
+    <Filename ToolCode="DUMMY">MiscSystemSlotDesignation.uni</Filename>\r
+    <Filename>MiscSubclassDriver.uni</Filename>\r
+    <Filename>MiscDevicePath.h</Filename>\r
+    <Filename>MiscSubclassDriver.h</Filename>\r
+    <Filename>MiscSubclassDriverEntryPoint.c</Filename>\r
+    <Filename>MiscSubclassDriverDataTable.c</Filename>\r
+    <Filename>MiscBaseBoardManufacturerData.c</Filename>\r
+    <Filename>MiscBiosVendorData.c</Filename>\r
+    <Filename>MiscBootInformationData.c</Filename>\r
+    <Filename>MiscChassisManufacturerData.c</Filename>\r
+    <Filename>MiscNumberOfInstallableLanguagesData.c</Filename>\r
+    <Filename>MiscOemStringData.c</Filename>\r
+    <Filename>MiscPortInternalConnectorDesignatorData.c</Filename>\r
+    <Filename>MiscResetCapabilitiesData.c</Filename>\r
+    <Filename>MiscSystemLanguageStringData.c</Filename>\r
+    <Filename>MiscSystemManufacturerData.c</Filename>\r
+    <Filename>MiscSystemManufacturerFunction.c</Filename>\r
+    <Filename>MiscSystemOptionStringData.c</Filename>\r
+    <Filename>MiscSystemSlotDesignationData.c</Filename>\r
+    <Filename>MiscPortInternalConnectorDesignatorFunction.c</Filename>\r
+    <Filename>MiscSubclassDriver.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <ProtocolNotify Usage="SOMETIMES_CONSUMED">\r
+      <ProtocolNotifyCName>gEfiUnixIoProtocolGuid</ProtocolNotifyCName>\r
+    </ProtocolNotify>\r
+  </Protocols>\r
+  <DataHubs>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscPortKeyboard</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscPortMouse</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscPortCom1</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscPortCom2</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscBiosVendor</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscSystemManufacturer</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscBaseBoardManufacturer</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscChassisManufacturer</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>MiscSystemSlotDesignation</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>OemString</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="ALWAYS_PRODUCED">\r
+      <DataHubCName>SystemOptionString</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_CONSUMED">\r
+      <DataHubCName>ProcessorSubClassData</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_PRODUCED">\r
+      <DataHubCName>MemorySubClassData</DataHubCName>\r
+    </DataHubRecord>\r
+  </DataHubs>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiMiscSubClassGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiProcessorSubClassGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiMemoryProducerGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiMemorySubClassGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiUnixMemoryGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>MiscSubclassDriverEntryPoint</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.uni
new file mode 100644 (file)
index 0000000..bae6862
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriverDataTable.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriverDataTable.c
new file mode 100644 (file)
index 0000000..bbade9b
--- /dev/null
@@ -0,0 +1,99 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriverDataTable.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// External definitions referenced by Data Table entries.\r
+//\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_CHASSIS_MANUFACTURER_DATA,\r
+  MiscChassisManufacturer\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_BIOS_VENDOR_DATA,\r
+  MiscBiosVendor\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_SYSTEM_MANUFACTURER_DATA,\r
+  MiscSystemManufacturer\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_BASE_BOARD_MANUFACTURER_DATA,\r
+  MiscBaseBoardManufacturer\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,\r
+  MiscPortInternalConnectorDesignator\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,\r
+  MiscPortKeyboard\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,\r
+  MiscPortMouse\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,\r
+  MiscPortCom1\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA,\r
+  MiscPortCom2\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA,\r
+  MiscSystemSlotDesignation\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_OEM_STRING_DATA,\r
+  OemString\r
+  );\r
+MISC_SUBCLASS_TABLE_EXTERNS (\r
+  EFI_MISC_SYSTEM_OPTION_STRING_DATA,\r
+  SystemOptionString\r
+  );\r
+\r
+//\r
+// Data Table.\r
+//\r
+EFI_MISC_SUBCLASS_DATA_TABLE  mMiscSubclassDataTable[] = {\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortKeyboard, MiscPortInternalConnectorDesignator),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortMouse, MiscPortInternalConnectorDesignator),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortCom1, MiscPortInternalConnectorDesignator),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_AND_FUNCTION(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR, MiscPortCom2, MiscPortInternalConnectorDesignator),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_BIOS_VENDOR, MiscBiosVendor),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_SYSTEM_MANUFACTURER, MiscSystemManufacturer),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_BASE_BOARD_MANUFACTURER, MiscBaseBoardManufacturer),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_CHASSIS_MANUFACTURER, MiscChassisManufacturer),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_SYSTEM_SLOT_DESIGNATION, MiscSystemSlotDesignation),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_OEM_STRING, OemString),\r
+  MISC_SUBCLASS_TABLE_ENTRY_DATA_ONLY(EFI_MISC_SYSTEM_OPTION_STRING, SystemOptionString),\r
+};\r
+\r
+//\r
+// Number of Data Table entries.\r
+//\r
+UINTN mMiscSubclassDataTableEntries = (sizeof mMiscSubclassDataTable) / sizeof (EFI_MISC_SUBCLASS_DATA_TABLE);\r
+\r
+/* eof - MiscSubclassDriverDataTable.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriverEntryPoint.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriverEntryPoint.c
new file mode 100644 (file)
index 0000000..bddc041
--- /dev/null
@@ -0,0 +1,518 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriverEntryPoint.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+\r
+extern UINT8  MiscSubclassStrings[];\r
+\r
+VOID\r
+EFIAPI\r
+UnixIoProtocolNotifyFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  );\r
+\r
+//\r
+//\r
+//\r
+EFI_STATUS\r
+LogRecordDataToDataHub (\r
+  EFI_DATA_HUB_PROTOCOL *DataHub,\r
+  UINT32                RecordType,\r
+  UINT32                RecordLen,\r
+  VOID                  *RecordData\r
+  )\r
+/*++\r
+Description:\r
+\r
+Parameters:\r
+\r
+  DataHub\r
+    %%TBD\r
+\r
+  RecordType\r
+    %%TBD\r
+\r
+  RecordLen\r
+    %%TBD\r
+\r
+  RecordData\r
+    %%TBD\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER\r
+\r
+  EFI_SUCCESS\r
+\r
+  Other Data Hub errors\r
+\r
+--*/\r
+{\r
+  EFI_MISC_SUBCLASS_DRIVER_DATA MiscSubclass;\r
+  EFI_STATUS                    EfiStatus;\r
+\r
+  //\r
+  // Do nothing if data parameters are not valid.\r
+  //\r
+  if (RecordLen == 0 || RecordData == NULL) {\r
+    DEBUG (\r
+      (EFI_D_ERROR,\r
+      "RecordLen == %d  RecordData == %xh\n",\r
+      RecordLen,\r
+      RecordData)\r
+      );\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Assemble Data Hub record.\r
+  //\r
+  MiscSubclass.Header.Version     = EFI_MISC_SUBCLASS_VERSION;\r
+  MiscSubclass.Header.HeaderSize  = sizeof (EFI_SUBCLASS_TYPE1_HEADER);\r
+  MiscSubclass.Header.Instance    = 1;\r
+  MiscSubclass.Header.SubInstance = 1;\r
+  MiscSubclass.Header.RecordType  = RecordType;\r
+\r
+  CopyMem (\r
+    &MiscSubclass.Record,\r
+    RecordData,\r
+    RecordLen\r
+    );\r
+\r
+  //\r
+  // Log Data Hub record.\r
+  //\r
+  EfiStatus = DataHub->LogData (\r
+                        DataHub,\r
+                        &gEfiMiscSubClassGuid,\r
+                        &gEfiMiscSubClassGuid,\r
+                        EFI_DATA_RECORD_CLASS_DATA,\r
+                        &MiscSubclass,\r
+                        sizeof (EFI_SUBCLASS_TYPE1_HEADER) + RecordLen\r
+                        );\r
+\r
+  if (EFI_ERROR (EfiStatus)) {\r
+    DEBUG (\r
+      (EFI_D_ERROR,\r
+      "LogData(%d bytes) == %r\n",\r
+      sizeof (EFI_SUBCLASS_TYPE1_HEADER) + RecordLen,\r
+      EfiStatus)\r
+      );\r
+  }\r
+\r
+  return EfiStatus;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MiscSubclassDriverEntryPoint (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+/*++\r
+Description:\r
+\r
+  Standard EFI driver point.  This driver parses the mMiscSubclassDataTable\r
+  structure and reports any generated data to the DataHub.\r
+\r
+Arguments:\r
+\r
+  ImageHandle\r
+    Handle for the image of this driver\r
+\r
+  SystemTable\r
+    Pointer to the EFI System Table\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+    The data was successfully reported to the Data Hub.\r
+\r
+--*/\r
+{\r
+  EFI_MISC_SUBCLASS_DRIVER_DATA RecordData;\r
+  EFI_DATA_HUB_PROTOCOL         *DataHub;\r
+  EFI_HII_PROTOCOL              *Hii;\r
+  EFI_HII_PACKAGES              *PackageList;\r
+  EFI_HII_HANDLE                HiiHandle;\r
+  EFI_STATUS                    EfiStatus;\r
+  UINTN                         Index;\r
+  BOOLEAN                       LogRecordData;\r
+  EFI_EVENT                     Event;\r
+  VOID                          *Registration;\r
+\r
+\r
+  //\r
+  // Initialize constant portion of subclass header.\r
+  //\r
+  RecordData.Header.Version     = EFI_MISC_SUBCLASS_VERSION;\r
+  RecordData.Header.HeaderSize  = sizeof (EFI_SUBCLASS_TYPE1_HEADER);\r
+  RecordData.Header.Instance    = 1;\r
+  RecordData.Header.SubInstance = 1;\r
+\r
+  //\r
+  // Locate data hub protocol.\r
+  //\r
+  EfiStatus = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub);\r
+\r
+  if (EFI_ERROR (EfiStatus)) {\r
+    DEBUG ((EFI_D_ERROR, "Could not locate DataHub protocol.  %r\n", EfiStatus));\r
+    return EfiStatus;\r
+  } else if (DataHub == NULL) {\r
+    DEBUG ((EFI_D_ERROR, "LocateProtocol(DataHub) returned NULL pointer!\n"));\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Locate hii protocol.\r
+  //\r
+  EfiStatus = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, &Hii);\r
+\r
+  if (EFI_ERROR (EfiStatus)) {\r
+    DEBUG ((EFI_D_ERROR, "Could not locate Hii protocol.  %r\n", EfiStatus));\r
+    return EfiStatus;\r
+  } else if (Hii == NULL) {\r
+    DEBUG ((EFI_D_ERROR, "LocateProtocol(Hii) returned NULL pointer!\n"));\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // Add our default strings to the HII database. They will be modified later.\r
+  //\r
+  PackageList = PreparePackages (1, &gEfiMiscSubClassGuid, MiscSubclassStrings);\r
+  EfiStatus   = Hii->NewPack (Hii, PackageList, &HiiHandle);\r
+  gBS->FreePool (PackageList);\r
+\r
+  if (EFI_ERROR (EfiStatus)) {\r
+    DEBUG ((EFI_D_ERROR, "Could not log default strings to Hii.  %r\n", EfiStatus));\r
+    return EfiStatus;\r
+  }\r
+  //\r
+  //\r
+  //\r
+  for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
+    //\r
+    // Stupidity check!  Do nothing if RecordLen is zero.\r
+    // %%TBD - Should this be an error or a mechanism for ignoring\r
+    // records in the Data Table?\r
+    //\r
+    if (mMiscSubclassDataTable[Index].RecordLen == 0) {\r
+      DEBUG (\r
+        (EFI_D_ERROR,\r
+        "mMiscSubclassDataTable[%d].RecordLen == 0\n",\r
+        Index)\r
+        );\r
+\r
+      continue;\r
+    }\r
+    //\r
+    // Initialize per-record portion of subclass header and\r
+    // copy static data into data portion of subclass record.\r
+    //\r
+    RecordData.Header.RecordType = mMiscSubclassDataTable[Index].RecordType;\r
+\r
+    if (mMiscSubclassDataTable[Index].RecordData == NULL) {\r
+      ZeroMem (\r
+        &RecordData.Record,\r
+        mMiscSubclassDataTable[Index].RecordLen\r
+        );\r
+    } else {\r
+      CopyMem (\r
+        &RecordData.Record,\r
+        mMiscSubclassDataTable[Index].RecordData,\r
+        mMiscSubclassDataTable[Index].RecordLen\r
+        );\r
+    }\r
+    //\r
+    // If the entry does not have a function pointer, just log the data.\r
+    //\r
+    if (mMiscSubclassDataTable[Index].Function == NULL) {\r
+      //\r
+      // Log RecordData to Data Hub.\r
+      //\r
+      EfiStatus = DataHub->LogData (\r
+                            DataHub,\r
+                            &gEfiMiscSubClassGuid,\r
+                            &gEfiMiscSubClassGuid,\r
+                            EFI_DATA_RECORD_CLASS_DATA,\r
+                            &RecordData,\r
+                            sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen\r
+                            );\r
+\r
+      if (EFI_ERROR (EfiStatus)) {\r
+        DEBUG (\r
+          (EFI_D_ERROR,\r
+          "LogData(%d bytes) == %r\n",\r
+          sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,\r
+          EfiStatus)\r
+          );\r
+      }\r
+\r
+      continue;\r
+    }\r
+    //\r
+    // The entry has a valid function pointer.\r
+    // Keep calling the function and logging data until there\r
+    // is no more data to log.\r
+    //\r
+    for (;;) {\r
+      //\r
+      //\r
+      //\r
+      EfiStatus = (*mMiscSubclassDataTable[Index].Function)\r
+        (\r
+          mMiscSubclassDataTable[Index].RecordType, &mMiscSubclassDataTable[Index].RecordLen, &RecordData.Record, &\r
+            LogRecordData\r
+        );\r
+\r
+      //\r
+      //\r
+      //\r
+      if (EFI_ERROR (EfiStatus)) {\r
+        break;\r
+      }\r
+\r
+      if (!LogRecordData) {\r
+        break;\r
+      }\r
+      //\r
+      //\r
+      //\r
+      EfiStatus = DataHub->LogData (\r
+                            DataHub,\r
+                            &gEfiMiscSubClassGuid,\r
+                            &gEfiMiscSubClassGuid,\r
+                            EFI_DATA_RECORD_CLASS_DATA,\r
+                            &RecordData,\r
+                            sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen\r
+                            );\r
+\r
+      if (EFI_ERROR (EfiStatus)) {\r
+        DEBUG (\r
+          (EFI_D_ERROR,\r
+          "LogData(%d bytes) == %r\n",\r
+          sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,\r
+          EfiStatus)\r
+          );\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Install notify function to fetch memory data through UnixIo protocol and store to data hub.\r
+  //\r
+  EfiStatus = gBS->CreateEvent (\r
+                    EFI_EVENT_NOTIFY_SIGNAL,\r
+                    EFI_TPL_CALLBACK,\r
+                    UnixIoProtocolNotifyFunction,\r
+                    ImageHandle,\r
+                    &Event\r
+                    );\r
+  ASSERT (!EFI_ERROR (EfiStatus));\r
+\r
+  EfiStatus = gBS->RegisterProtocolNotify (\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    Event,\r
+                    &Registration\r
+                    );\r
+  ASSERT (!EFI_ERROR (EfiStatus));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINTN\r
+Atoi (\r
+  CHAR16  *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Convert a unicode string to a UINTN\r
+\r
+Arguments:\r
+  String - Unicode string.\r
+\r
+Returns: \r
+  UINTN of the number represented by String.  \r
+\r
+--*/\r
+{\r
+  UINTN   Number;\r
+  CHAR16  *Str;\r
+\r
+  //\r
+  // skip preceeding white space\r
+  //\r
+  Str = String;\r
+  while ((*Str) && (*Str == ' ' || *Str == '"')) {\r
+    Str++;\r
+  }\r
+  //\r
+  // Convert ot a Number\r
+  //\r
+  Number = 0;\r
+  while (*Str != '\0') {\r
+    if ((*Str >= '0') && (*Str <= '9')) {\r
+      Number = (Number * 10) +*Str - '0';\r
+    } else {\r
+      break;\r
+    }\r
+\r
+    Str++;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+UnixIoProtocolNotifyFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function will log memory size data to data hub.\r
+\r
+Arguments:\r
+Event        - Event whose notification function is being invoked.\r
+Context      - Pointer to the notification function's context.\r
+\r
+Returns:\r
+    EFI_STATUS.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_MEMORY_SUBCLASS_DRIVER_DATA MemorySubClassData;\r
+  EFI_DATA_RECORD_HEADER          *Record;\r
+  EFI_SUBCLASS_TYPE1_HEADER       *DataHeader;\r
+  UINTN                           HandleCount;\r
+  UINTN                           HandleIndex;\r
+  UINT64                          MonotonicCount;\r
+  BOOLEAN                         RecordFound;\r
+  EFI_HANDLE                      *HandleBuffer;\r
+  EFI_UNIX_IO_PROTOCOL           *UnixIo;\r
+  EFI_DATA_HUB_PROTOCOL           *DataHub;\r
+  UINT64                          TotalMemorySize;\r
+\r
+  DataHub         = NULL;\r
+  MonotonicCount  = 0;\r
+  RecordFound     = FALSE;\r
+\r
+  //\r
+  // Retrieve the list of all handles from the handle database.\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+  //\r
+  // Locate DataHub protocol.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub);\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+  //\r
+  // Search the Handle array to find the meory size information.\r
+  //\r
+  for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {\r
+    Status = gBS->OpenProtocol (\r
+                    HandleBuffer[HandleIndex],\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    &UnixIo,\r
+                    Context,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    if ((UnixIo->UnixThunk->Signature == EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) &&\r
+        CompareGuid (UnixIo->TypeGuid, &gEfiUnixMemoryGuid)\r
+          ) {\r
+      //\r
+      // Check if this record has been stored in data hub.\r
+      //\r
+      do {\r
+        Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);\r
+        if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {\r
+          DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);\r
+          if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) &&\r
+              (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)\r
+              ) {\r
+            RecordFound = TRUE;\r
+          }\r
+        }\r
+      } while (MonotonicCount != 0);\r
+\r
+      if (RecordFound) {\r
+        RecordFound = FALSE;\r
+        continue;\r
+      }\r
+      //\r
+      // Initialize data record.\r
+      //\r
+      MemorySubClassData.Header.Instance    = 1;\r
+      MemorySubClassData.Header.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;\r
+      MemorySubClassData.Header.RecordType  = EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER;\r
+\r
+      TotalMemorySize                       = (UINT64) Atoi (UnixIo->EnvString);\r
+\r
+      MemorySubClassData.Record.ArrayStartAddress.MemoryArrayStartAddress               = 0;\r
+      MemorySubClassData.Record.ArrayStartAddress.MemoryArrayEndAddress                 = LShiftU64 (TotalMemorySize, 20) - 1;\r
+      MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.ProducerName  = gEfiMemoryProducerGuid;\r
+      MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.Instance      = 1;\r
+      MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;\r
+      MemorySubClassData.Record.ArrayStartAddress.MemoryArrayPartitionWidth = 0;\r
+\r
+      //\r
+      // Store memory size data record to data hub.\r
+      //\r
+      Status = DataHub->LogData (\r
+                          DataHub,\r
+                          &gEfiMemorySubClassGuid,\r
+                          &gEfiMemoryProducerGuid,\r
+                          EFI_DATA_RECORD_CLASS_DATA,\r
+                          &MemorySubClassData,\r
+                          sizeof (EFI_SUBCLASS_TYPE1_HEADER) + sizeof (EFI_MEMORY_ARRAY_START_ADDRESS_DATA)\r
+                          );\r
+    }\r
+\r
+    gBS->CloseProtocol (\r
+          HandleBuffer[HandleIndex],\r
+          &gEfiUnixIoProtocolGuid,\r
+          Context,\r
+          NULL\r
+          );\r
+  }\r
+}\r
+\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageString.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageString.uni
new file mode 100644 (file)
index 0000000..36dacf0
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageString.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageStringData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemLanguageStringData.c
new file mode 100644 (file)
index 0000000..ef52513
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemLanguageStringData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA, SystemLanguageString) = {\r
+  0,\r
+  STRING_TOKEN(STR_MISC_SYSTEM_LANGUAGE_STRING)\r
+};\r
+\r
+/* eof - MiscSystemLanguageStringData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturer.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturer.uni
new file mode 100644 (file)
index 0000000..204588e
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturer.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturerData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturerData.c
new file mode 100644 (file)
index 0000000..be53e39
--- /dev/null
@@ -0,0 +1,55 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemManufacturerData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) System Manufacturer data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer)\r
+= {\r
+  STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER),\r
+  // SystemManufactrurer\r
+  STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME),\r
+  // SystemProductName\r
+  STRING_TOKEN(STR_MISC_SYSTEM_VERSION),\r
+  // SystemVersion\r
+  STRING_TOKEN(STR_MISC_SYSTEM_SERIAL_NUMBER),\r
+  // SystemSerialNumber\r
+  {\r
+    0xbadfaced,\r
+    0xdead,\r
+    0xbeef,\r
+    0x13,\r
+    0x13,\r
+    0x13,\r
+    0x13,\r
+    0x13,\r
+    0x13,\r
+    0x13,\r
+    0x13\r
+  },\r
+  // SystemUuid\r
+  EfiSystemWakeupTypePowerSwitch  // SystemWakeupType\r
+};\r
+\r
+/* eof - MiscSystemManufacturerData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturerFunction.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemManufacturerFunction.c
new file mode 100644 (file)
index 0000000..ddd749b
--- /dev/null
@@ -0,0 +1,122 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemManufacturerFunction.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+//\r
+//\r
+MISC_SUBCLASS_TABLE_FUNCTION (\r
+  MiscSystemManufacturer\r
+  )\r
+/*++\r
+Description:\r
+\r
+  This function makes boot time changes to the contents of the\r
+  MiscSystemManufacturer (Type 13).\r
+\r
+Parameters:\r
+\r
+  RecordType\r
+    Type of record to be processed from the Data Table.\r
+    mMiscSubclassDataTable[].RecordType\r
+\r
+  RecordLen\r
+    Size of static RecordData from the Data Table.\r
+    mMiscSubclassDataTable[].RecordLen\r
+\r
+  RecordData\r
+    Pointer to copy of RecordData from the Data Table.  Changes made\r
+    to this copy will be written to the Data Hub but will not alter\r
+    the contents of the static Data Table.\r
+\r
+  LogRecordData\r
+    Set *LogRecordData to TRUE to log RecordData to Data Hub.\r
+    Set *LogRecordData to FALSE when there is no more data to log.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+    All parameters were valid and *RecordData and *LogRecordData have\r
+    been set.\r
+\r
+  EFI_UNSUPPORTED\r
+    Unexpected RecordType value.\r
+\r
+  EFI_INVALID_PARAMETER\r
+    One of the following parameter conditions was true:\r
+      RecordLen was zero.\r
+      RecordData was NULL.\r
+      LogRecordData was NULL.\r
+--*/\r
+{\r
+  STATIC BOOLEAN  Done = FALSE;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Then check for unsupported RecordType.\r
+  //\r
+  if (RecordType != EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Is this the first time through this function?\r
+  //\r
+  if (!Done) {\r
+    //\r
+    // Yes, this is the first time.  Inspect/Change the contents of the\r
+    // RecordData structure.\r
+    //\r
+    //\r
+    // Set system GUID.\r
+    //\r
+    // ((EFI_MISC_SYSTEM_MANUFACTURER_DATA *)RecordData)->SystemUuid = %%TBD\r
+    //\r
+    // Set power-on type.\r
+    //\r
+    // ((EFI_MISC_SYSTEM_MANUFACTURER_DATA *)RecordData)->SystemWakeupType = %%TBD\r
+    //\r
+    // Set Done flag to TRUE for next pass through this function.\r
+    // Set *LogRecordData to TRUE so data will get logged to Data Hub.\r
+    //\r
+    Done            = TRUE;\r
+    *LogRecordData  = TRUE;\r
+  } else {\r
+    //\r
+    // No, this is the second time.  Reset the state of the Done flag\r
+    // to FALSE and tell the data logger that there is no more data\r
+    // to be logged for this record type.  If any memory allocations\r
+    // were made by earlier passes, they must be released now.\r
+    //\r
+    Done            = FALSE;\r
+    *LogRecordData  = FALSE;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/* eof - MiscSystemManufacturerFunction.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionString.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionString.uni
new file mode 100644 (file)
index 0000000..617578d
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionString.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionStringData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemOptionStringData.c
new file mode 100644 (file)
index 0000000..8c00350
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemOptionStringData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString) = {\r
+  STRING_TOKEN(STR_MISC_SYSTEM_OPTION_STRING)\r
+};\r
+\r
+/* eof - MiscSystemOptionStringData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignation.uni b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignation.uni
new file mode 100644 (file)
index 0000000..f279ff9
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignation.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignationData.c b/EdkUnixPkg/Dxe/UnixPlatform/MiscSubclass/MiscSystemSlotDesignationData.c
new file mode 100644 (file)
index 0000000..d5e1474
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MiscSystemSlotDesignationData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+--*/\r
+\r
+#include "MiscSubclassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SUBCLASS_TABLE_DATA(EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation) = {\r
+  STRING_TOKEN(STR_MISC_SYSTEM_SLOT_DESIGNATION),   // SlotDesignation\r
+  EfiSlotTypeOther,         // SlotType\r
+  EfiSlotDataBusWidthOther, // SlotDataBusWidth\r
+  EfiSlotUsageOther,        // SlotUsage\r
+  EfiSlotLengthOther,       // SlotLength\r
+  0,                        // SlotId\r
+  {                         // SlotCharacteristics\r
+    0,                      // CharacteristicsUnknown  :1;\r
+    0,                      // Provides50Volts         :1;\r
+    0,                      // Provides33Volts         :1;\r
+    0,                      // SharedSlot              :1;\r
+    0,                      // PcCard16Supported       :1;\r
+    0,                      // CardBusSupported        :1;\r
+    0,                      // ZoomVideoSupported      :1;\r
+    0,                      // ModemRingResumeSupported:1;\r
+    0,                      // PmeSignalSupported      :1;\r
+    0,                      // HotPlugDevicesSupported :1;\r
+    0,                      // SmbusSignalSupported    :1;\r
+    0                       // Reserved                :21;\r
+  },\r
+  0                         // SlotDevicePath\r
+};\r
+\r
+/* eof - MiscSystemSlotsData.c */\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/ComponentName.c
new file mode 100644 (file)
index 0000000..fd4b75e
--- /dev/null
@@ -0,0 +1,187 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "UnixBlockIo.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gUnixBlockIoComponentName = {\r
+  UnixBlockIoComponentNameGetDriverName,\r
+  UnixBlockIoComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mUnixBlockIoDriverNameTable[] = {\r
+  { "eng", L"Unix Block I/O Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixBlockIoComponentName.SupportedLanguages,\r
+          mUnixBlockIoDriverNameTable,\r
+          DriverName\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
+  UNIX_BLOCK_IO_PRIVATE *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);\r
+\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixBlockIoComponentName.SupportedLanguages,\r
+          Private->ControllerNameTable,\r
+          ControllerName\r
+          );\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/DriverConfiguration.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/DriverConfiguration.c
new file mode 100644 (file)
index 0000000..d06b5fb
--- /dev/null
@@ -0,0 +1,338 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DriverConfiguration.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "UnixBlockIo.h"\r
+\r
+//\r
+// EFI Driver Configuration Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverConfigurationSetOptions (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  CHAR8                                                  *Language,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverConfigurationOptionsValid (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle  OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverConfigurationForceDefaults (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  UINT32                                                 DefaultType,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  );\r
+\r
+//\r
+// EFI Driver Configuration Protocol\r
+//\r
+EFI_DRIVER_CONFIGURATION_PROTOCOL gUnixBlockIoDriverConfiguration = {\r
+  UnixBlockIoDriverConfigurationSetOptions,\r
+  UnixBlockIoDriverConfigurationOptionsValid,\r
+  UnixBlockIoDriverConfigurationForceDefaults,\r
+  LANGUAGESUPPORTED\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverConfigurationSetOptions (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  CHAR8                                                  *Language,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Allows the user to set controller specific options for a controller that a \r
+    driver is currently managing.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to set options on.\r
+    ChildHandle      - The handle of the child controller to set options on.  This\r
+                       is an optional parameter that may be NULL.  It will be NULL \r
+                       for device drivers, and for a bus drivers that wish to set \r
+                       options for the bus controller.  It will not be NULL for a \r
+                       bus driver that wishes to set options for one of its child \r
+                       controllers.\r
+    Language         - A pointer to a three character ISO 639-2 language identifier.\r
+                       This is the language of the user interface that should be \r
+                       presented to the user, and it must match one of the languages \r
+                       specified in SupportedLanguages.  The number of languages \r
+                       supported by a driver is up to the driver writer.\r
+    ActionRequired   - A pointer to the action that the calling agent is required \r
+                       to perform when this function returns.  See "Related \r
+                       Definitions" for a list of the actions that the calling \r
+                       agent is required to perform prior to accessing \r
+                       ControllerHandle again.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The driver specified by This successfully set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle..\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support setting \r
+                            configuration options for the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempt to set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+    EFI_OUT_RESOURCES     - There are not enough resources available to set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+  CHAR8                 *SupportedLanguage;\r
+\r
+  SupportedLanguage = This->SupportedLanguages;\r
+\r
+  Status            = EFI_UNSUPPORTED;\r
+  while (*SupportedLanguage != 0) {\r
+    if (AsciiStrnCmp (Language, SupportedLanguage, 3)) {\r
+      Status = EFI_SUCCESS;\r
+    }\r
+\r
+    SupportedLanguage += 3;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (ActionRequired == NULL || ControllerHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *ActionRequired = EfiDriverConfigurationActionNone;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverConfigurationOptionsValid (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle  OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Tests to see if a controller's current configuration options are valid.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to test if it's current \r
+                       configuration options are valid.\r
+    ChildHandle      - The handle of the child controller to test if it's current\r
+                       configuration options are valid.  This is an optional \r
+                       parameter that may be NULL.  It will be NULL for device \r
+                       drivers.  It will also be NULL for a bus drivers that wish\r
+                       to test the configuration options for the bus controller.\r
+                       It will not be NULL for a bus driver that wishes to test \r
+                       configuration options for one of its child controllers.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
+                            ChildHandle that is being managed by the driver \r
+                            specified by This has a valid set of  configuration\r
+                            options.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by ControllerHandle \r
+                            and ChildHandle.\r
+    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
+                            ChildHandle that is being managed by the driver \r
+                            specified by This has an invalid set of configuration \r
+                            options.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (ControllerHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverConfigurationForceDefaults (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  UINT32                                                 DefaultType,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Forces a driver to set the default configuration options for a controller.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to force default configuration options on.\r
+    ChildHandle      - The handle of the child controller to force default configuration options on  This is an optional parameter that may be NULL.  It will be NULL for device drivers.  It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller.  It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.\r
+    DefaultType      - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle.  See Table 9-1 for legal values.  A DefaultType of 0x00000000 must be supported by this protocol.\r
+    ActionRequired   - A pointer to the action that the calling agent is required to perform when this function returns.  See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the configuration type specified by DefaultType.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempt to force the default configuration options on the controller specified by  ControllerHandle and ChildHandle.\r
+    EFI_OUT_RESOURCES     - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (ActionRequired == NULL || ControllerHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *ActionRequired = EfiDriverConfigurationActionNone;\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/DriverDiagnostics.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/DriverDiagnostics.c
new file mode 100644 (file)
index 0000000..0e9a32c
--- /dev/null
@@ -0,0 +1,187 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DriverDiagnostics.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "UnixBlockIo.h"\r
+\r
+//\r
+// EFI Driver Diagnostics Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverDiagnosticsRunDiagnostics (\r
+  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                    ControllerHandle,\r
+  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
+  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
+  IN  CHAR8                                         *Language,\r
+  OUT EFI_GUID                                      **ErrorType,\r
+  OUT UINTN                                         *BufferSize,\r
+  OUT CHAR16                                        **Buffer\r
+  );\r
+\r
+//\r
+// EFI Driver Diagnostics Protocol\r
+//\r
+EFI_DRIVER_DIAGNOSTICS_PROTOCOL gUnixBlockIoDriverDiagnostics = {\r
+  UnixBlockIoDriverDiagnosticsRunDiagnostics,\r
+  LANGUAGESUPPORTED\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverDiagnosticsRunDiagnostics (\r
+  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                    ControllerHandle,\r
+  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
+  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
+  IN  CHAR8                                         *Language,\r
+  OUT EFI_GUID                                      **ErrorType,\r
+  OUT UINTN                                         *BufferSize,\r
+  OUT CHAR16                                        **Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Runs diagnostics on a controller.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to run diagnostics on.\r
+    ChildHandle      - The handle of the child controller to run diagnostics on  \r
+                       This is an optional parameter that may be NULL.  It will \r
+                       be NULL for device drivers.  It will also be NULL for a \r
+                       bus drivers that wish to run diagnostics on the bus \r
+                       controller.  It will not be NULL for a bus driver that \r
+                       wishes to run diagnostics on one of its child controllers.\r
+    DiagnosticType   - Indicates type of diagnostics to perform on the controller \r
+                       specified by ControllerHandle and ChildHandle.   See \r
+                       "Related Definitions" for the list of supported types.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language in which the optional \r
+                       error message should be returned in Buffer, and it must \r
+                       match one of the languages specified in SupportedLanguages.\r
+                       The number of languages supported by a driver is up to \r
+                       the driver writer.  \r
+    ErrorType        - A GUID that defines the format of the data returned in \r
+                       Buffer.  \r
+    BufferSize       - The size, in bytes, of the data returned in Buffer.  \r
+    Buffer           - A buffer that contains a Null-terminated Unicode string \r
+                       plus some additional data whose format is defined by \r
+                       ErrorType.  Buffer is allocated by this function with \r
+                       AllocatePool(), and it is the caller's responsibility \r
+                       to free it with a call to FreePool().  \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
+                            ChildHandle passed the diagnostic.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ErrorType is NULL.\r
+    EFI_INVALID_PARAMETER - BufferType is NULL.\r
+    EFI_INVALID_PARAMETER - Buffer is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support \r
+                            running diagnostics for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            type of diagnostic specified by DiagnosticType.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources available to complete\r
+                            the diagnostics.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources available to return\r
+                            the status information in ErrorType, BufferSize, \r
+                            and Buffer.\r
+    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
+                            ChildHandle did not pass the diagnostic.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+  CHAR8                 *SupportedLanguage;\r
+\r
+  if (Language         == NULL ||\r
+      ErrorType        == NULL ||\r
+      Buffer           == NULL ||\r
+      ControllerHandle == NULL ||\r
+      BufferSize       == NULL) {\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  SupportedLanguage = This->SupportedLanguages;\r
+\r
+  Status            = EFI_UNSUPPORTED;\r
+  while (*SupportedLanguage != 0) {\r
+    if (AsciiStrnCmp (Language, SupportedLanguage, 3)) {\r
+      Status = EFI_SUCCESS;\r
+      break;\r
+    }\r
+\r
+    SupportedLanguage += 3;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  *ErrorType  = NULL;\r
+  *BufferSize = 0;\r
+  if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {\r
+    *ErrorType  = &gEfiBlockIoProtocolGuid;\r
+    *BufferSize = 0x60;\r
+    gBS->AllocatePool (EfiBootServicesData, (UINTN) (*BufferSize),
+                      (void *)Buffer);\r
+    CopyMem (*Buffer, L"Unix Block I/O Driver Diagnostics Failed\n", *BufferSize);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          gUnixBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.c
new file mode 100644 (file)
index 0000000..ca4a5f2
--- /dev/null
@@ -0,0 +1,1287 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixBlockIo.c\r
+\r
+Abstract:\r
+\r
+  Produce block IO abstractions for real devices on your PC using Win32 APIs.\r
+  The configuration of what devices to mount or emulate comes from NT \r
+  environment variables. The variables must be visible to the Microsoft* \r
+  Developer Studio for them to work.\r
+\r
+  <F>ixed       - Fixed disk like a hard drive.\r
+  <R>emovable   - Removable media like a floppy or CD-ROM.\r
+  Read <O>nly   - Write protected device.\r
+  Read <W>rite  - Read write device.\r
+  <block count> - Decimal number of blocks a device supports.\r
+  <block size>  - Decimal number of bytes per block.\r
+\r
+  NT envirnonment variable contents. '<' and '>' are not part of the variable, \r
+  they are just used to make this help more readable. There should be no \r
+  spaces between the ';'. Extra spaces will break the variable. A '!' is \r
+  used to seperate multiple devices in a variable.\r
+\r
+  EFI_UNIX_VIRTUAL_DISKS = \r
+    <F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+  EFI_UNIX_PHYSICAL_DISKS =\r
+    <drive letter>:<F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+  Virtual Disks: These devices use a file to emulate a hard disk or removable\r
+                 media device. \r
+                 \r
+    Thus a 20 MB emulated hard drive would look like:\r
+    EFI_UNIX_VIRTUAL_DISKS=FW;40960;512\r
+\r
+    A 1.44MB emulated floppy with a block size of 1024 would look like:\r
+    EFI_UNIX_VIRTUAL_DISKS=RW;1440;1024\r
+\r
+  Physical Disks: These devices use NT to open a real device in your system\r
+\r
+    Thus a 120 MB floppy would look like:\r
+    EFI_UNIX_PHYSICAL_DISKS=B:RW;245760;512\r
+\r
+    Thus a standard CD-ROM floppy would look like:\r
+    EFI_UNIX_PHYSICAL_DISKS=Z:RO;307200;2048\r
+\r
+\r
+  * Other names and brands may be claimed as the property of others.\r
+\r
+--*/\r
+\r
+#include <fcntl.h>
+#include <unistd.h>
+#include "UnixBlockIo.h"\r
+\r
+//\r
+// Block IO protocol member functions\r
+//\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoReadBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN UINT32                 MediaId,\r
+  IN EFI_LBA                Lba,\r
+  IN UINTN                  BufferSize,\r
+  OUT VOID                  *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  MediaId     - TODO: add argument description\r
+  Lba         - TODO: add argument description\r
+  BufferSize  - TODO: add argument description\r
+  Buffer      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoWriteBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN UINT32                 MediaId,\r
+  IN EFI_LBA                Lba,\r
+  IN UINTN                  BufferSize,\r
+  IN VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  MediaId     - TODO: add argument description\r
+  Lba         - TODO: add argument description\r
+  BufferSize  - TODO: add argument description\r
+  Buffer      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoFlushBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoResetBlock (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN BOOLEAN                ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - TODO: add argument description\r
+  ExtendedVerification  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Private Worker functions\r
+//\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoCreateMapping (\r
+  IN EFI_UNIX_IO_PROTOCOL             *UnixIo,\r
+  IN EFI_HANDLE                         EfiDeviceHandle,\r
+  IN CHAR16                             *Filename,\r
+  IN BOOLEAN                            ReadOnly,\r
+  IN BOOLEAN                            RemovableMedia,\r
+  IN UINTN                              NumberOfBlocks,\r
+  IN UINTN                              BlockSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  UnixIo         - TODO: add argument description\r
+  EfiDeviceHandle - TODO: add argument description\r
+  Filename        - TODO: add argument description\r
+  ReadOnly        - TODO: add argument description\r
+  RemovableMedia  - TODO: add argument description\r
+  NumberOfBlocks  - TODO: add argument description\r
+  BlockSize       - TODO: add argument description\r
+  DeviceType      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoReadWriteCommon (\r
+  IN  UNIX_BLOCK_IO_PRIVATE *Private,\r
+  IN UINT32                   MediaId,\r
+  IN EFI_LBA                  Lba,\r
+  IN UINTN                    BufferSize,\r
+  IN VOID                     *Buffer,\r
+  IN CHAR8                    *CallerName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private     - TODO: add argument description\r
+  MediaId     - TODO: add argument description\r
+  Lba         - TODO: add argument description\r
+  BufferSize  - TODO: add argument description\r
+  Buffer      - TODO: add argument description\r
+  CallerName  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoError (\r
+  IN UNIX_BLOCK_IO_PRIVATE      *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoOpenDevice (\r
+  UNIX_BLOCK_IO_PRIVATE         *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+CHAR16                                    *\r
+GetNextElementPastTerminator (\r
+  IN  CHAR16  *EnvironmentVariable,\r
+  IN  CHAR16  Terminator\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  EnvironmentVariable - TODO: add argument description\r
+  Terminator          - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+EFI_DRIVER_BINDING_PROTOCOL gUnixBlockIoDriverBinding = {\r
+  UnixBlockIoDriverBindingSupported,\r
+  UnixBlockIoDriverBindingStart,\r
+  UnixBlockIoDriverBindingStop,\r
+  0x10,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_UNIX_IO_PROTOCOL  *UnixIo;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (VOID **)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure the UnixThunkProtocol is valid\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (UnixIo->UnixThunk->Signature == EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) {\r
+\r
+    //\r
+    // Check the GUID to see if this is a handle type the driver supports\r
+    //\r
+    if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixVirtualDisksGuid) ) {
+      Status = EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEfiUnixIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_UNIX_IO_PROTOCOL       *UnixIo;\r
+  CHAR16                      Buffer[FILENAME_BUFFER_SIZE];\r
+  CHAR16                      *Str;\r
+  BOOLEAN                     RemovableMedia;\r
+  BOOLEAN                     WriteProtected;\r
+  UINTN                       NumberOfBlocks;\r
+  UINTN                       BlockSize;\r
+  INTN                       i;
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Set DiskType\r
+  //\r
+  if (!CompareGuid (UnixIo->TypeGuid, &gEfiUnixVirtualDisksGuid)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+\r
+  Status  = EFI_NOT_FOUND;\r
+  //  Extract filename.
+  Str     = UnixIo->EnvString;\r
+  i = 0;
+  while (*Str && *Str != ':')
+    Buffer[i++] = *Str++;
+  Buffer[i] = 0;
+  if (*Str != ':') {\r
+    goto Done;\r
+  }\r
+\r
+  Str++;\r
+\r
+  RemovableMedia = FALSE;
+  WriteProtected = TRUE;
+  NumberOfBlocks = 0;
+  BlockSize = 512;
+  do {
+    if (*Str == 'R' || *Str == 'F') {\r
+      RemovableMedia = (BOOLEAN) (*Str == 'R');\r
+      Str++;\r
+    }
+    if (*Str == 'O' || *Str == 'W') {\r
+      WriteProtected  = (BOOLEAN) (*Str == 'O');\r
+      Str++;
+    }
+    if (*Str == 0)
+      break;
+    if (*Str != ';')
+      goto Done;
+    Str++;
+
+    NumberOfBlocks  = Atoi (Str);\r
+    Str       = GetNextElementPastTerminator (Str, ';');\r
+    if (NumberOfBlocks == 0)
+      break;
+
+    BlockSize = Atoi (Str);\r
+    if (BlockSize != 0)
+      Str       = GetNextElementPastTerminator (Str, ';');\r
+  } while (0);
+
+  //\r
+  // If we get here the variable is valid so do the work.\r
+  //\r
+  Status = UnixBlockIoCreateMapping (\r
+                                     UnixIo,\r
+                                     Handle,\r
+                                     Buffer,\r
+                                     WriteProtected,\r
+                                     RemovableMedia,\r
+                                     NumberOfBlocks,\r
+                                     BlockSize\r
+                                     );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          Handle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Handle\r
+          );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Handle            - TODO: add argument description\r
+  NumberOfChildren  - TODO: add argument description\r
+  ChildHandleBuffer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
+  EFI_STATUS              Status;\r
+  UNIX_BLOCK_IO_PRIVATE *Private;\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);\r
+\r
+  //\r
+  // BugBug: If we need to kick people off, we need to make Uninstall Close the handles.\r
+  //         We could pass in our image handle or FLAG our open to be closed via\r
+  //         Unistall (== to saying any CloseProtocol will close our open)\r
+  //\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  Private->EfiHandle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  &Private->BlockIo,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+\r
+    Status = gBS->CloseProtocol (\r
+                    Handle,\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    Handle\r
+                    );\r
+\r
+    //\r
+    // Shut down our device\r
+    //\r
+    Private->UnixThunk->Close (Private->fd);\r
+\r
+    //\r
+    // Free our instance data\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+\r
+    gBS->FreePool (Private);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+CHAR16 *\r
+GetNextElementPastTerminator (\r
+  IN  CHAR16  *EnvironmentVariable,\r
+  IN  CHAR16  Terminator\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Worker function to parse environment variables.\r
+\r
+Arguments:\r
+  EnvironmentVariable - Envirnment variable to parse.\r
+\r
+  Terminator          - Terminator to parse for.\r
+\r
+Returns: \r
+\r
+  Pointer to next eliment past the first occurence of Terminator or the '\0'\r
+  at the end of the string.\r
+\r
+--*/\r
+{\r
+  CHAR16  *Ptr;\r
+\r
+  for (Ptr = EnvironmentVariable; *Ptr != '\0'; Ptr++) {\r
+    if (*Ptr == Terminator) {\r
+      Ptr++;\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Ptr;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoCreateMapping (\r
+  IN EFI_UNIX_IO_PROTOCOL             *UnixIo,\r
+  IN EFI_HANDLE                         EfiDeviceHandle,\r
+  IN CHAR16                             *Filename,\r
+  IN BOOLEAN                            ReadOnly,\r
+  IN BOOLEAN                            RemovableMedia,\r
+  IN UINTN                              NumberOfBlocks,\r
+  IN UINTN                              BlockSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  UnixIo         - TODO: add argument description\r
+  EfiDeviceHandle - TODO: add argument description\r
+  Filename        - TODO: add argument description\r
+  ReadOnly        - TODO: add argument description\r
+  RemovableMedia  - TODO: add argument description\r
+  NumberOfBlocks  - TODO: add argument description\r
+  BlockSize       - TODO: add argument description\r
+  DeviceType      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
+  UNIX_BLOCK_IO_PRIVATE *Private;\r
+  UINTN                   Index;\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (UNIX_BLOCK_IO_PRIVATE),\r
+                  (void *)&Private\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  EfiInitializeLock (&Private->Lock, EFI_TPL_NOTIFY);\r
+\r
+  Private->UnixThunk = UnixIo->UnixThunk;\r
+\r
+  Private->Signature  = UNIX_BLOCK_IO_PRIVATE_SIGNATURE;\r
+  Private->LastBlock  = NumberOfBlocks - 1;\r
+  Private->BlockSize  = BlockSize;\r
+\r
+  for (Index = 0; Filename[Index] != 0; Index++) {\r
+    Private->Filename[Index] = Filename[Index];\r
+  }\r
+\r
+  Private->Filename[Index]      = 0;\r
+\r
+  Private->Mode                 = (ReadOnly ? O_RDONLY : O_RDWR);
+\r
+  Private->NumberOfBlocks       = NumberOfBlocks;\r
+  Private->fd                   = -1;
+\r
+  Private->ControllerNameTable  = NULL;\r
+\r
+  AddUnicodeString (\r
+    "eng",\r
+    gUnixBlockIoComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    Filename\r
+    );\r
+\r
+  BlockIo = &Private->BlockIo;\r
+  BlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;\r
+  BlockIo->Media = &Private->Media;\r
+  BlockIo->Media->BlockSize = Private->BlockSize;\r
+  BlockIo->Media->LastBlock = Private->NumberOfBlocks - 1;\r
+  BlockIo->Media->MediaId = 0;;\r
+\r
+  BlockIo->Reset = UnixBlockIoResetBlock;\r
+  BlockIo->ReadBlocks = UnixBlockIoReadBlocks;\r
+  BlockIo->WriteBlocks = UnixBlockIoWriteBlocks;\r
+  BlockIo->FlushBlocks = UnixBlockIoFlushBlocks;\r
+\r
+  BlockIo->Media->ReadOnly = ReadOnly;\r
+  BlockIo->Media->RemovableMedia = RemovableMedia;\r
+  BlockIo->Media->LogicalPartition = FALSE;\r
+  BlockIo->Media->MediaPresent = TRUE;\r
+  BlockIo->Media->WriteCaching = FALSE;\r
+\r
+  BlockIo->Media->IoAlign = 1;\r
+\r
+  Private->EfiHandle  = EfiDeviceHandle;\r
+  Status              = UnixBlockIoOpenDevice (Private);\r
+  if (!EFI_ERROR (Status)) {\r
+\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &Private->EfiHandle,\r
+                    &gEfiBlockIoProtocolGuid,\r
+                    &Private->BlockIo,\r
+                    NULL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      FreeUnicodeStringTable (Private->ControllerNameTable);\r
+      gBS->FreePool (Private);\r
+    }\r
+\r
+    DEBUG ((EFI_D_INIT, "BlockDevice added: %s\n", Filename));\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoOpenDevice (\r
+  UNIX_BLOCK_IO_PRIVATE                 *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  UINT64                FileSize;\r
+  UINT64                EndOfFile;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+\r
+  BlockIo = &Private->BlockIo;\r
+  EfiAcquireLock (&Private->Lock);\r
+\r
+  //\r
+  // If the device is already opened, close it\r
+  //\r
+  if (Private->fd >= 0) {
+    BlockIo->Reset (BlockIo, FALSE);\r
+  }\r
+\r
+  //\r
+  // Open the device\r
+  //\r
+  Private->fd = Private->UnixThunk->Open
+    (Private->Filename, Private->Mode, 0644);
+\r
+  if (Private->fd < 0) {
+    DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s\n",
+           Private->Filename));
+    BlockIo->Media->MediaPresent  = FALSE;\r
+    Status                        = EFI_NO_MEDIA;\r
+    goto Done;\r
+  }\r
+\r
+  if (!BlockIo->Media->MediaPresent) {\r
+    //\r
+    // BugBug: try to emulate if a CD appears - notify drivers to check it out\r
+    //\r
+    BlockIo->Media->MediaPresent = TRUE;\r
+    EfiReleaseLock (&Private->Lock);\r
+    EfiAcquireLock (&Private->Lock);\r
+  }\r
+\r
+  //\r
+  // get the size of the file\r
+  //\r
+  Status = SetFilePointer64 (Private, 0, &FileSize, SEEK_END);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    FileSize = MultU64x32 (Private->NumberOfBlocks, Private->BlockSize);\r
+    DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n", Private->Filename));\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+\r
+  if (Private->NumberOfBlocks == 0) {\r
+    Private->NumberOfBlocks = DivU64x32 (FileSize, Private->BlockSize);\r
+  }\r
+\r
+  EndOfFile = MultU64x32 (Private->NumberOfBlocks, Private->BlockSize);\r
+\r
+  if (FileSize != EndOfFile) {\r
+    //\r
+    // file is not the proper size, change it\r
+    //\r
+    DEBUG ((EFI_D_INIT, "PlOpenBlock: Initializing block device: %a\n", Private->Filename));\r
+\r
+    //\r
+    // first set it to 0\r
+    //\r
+    Private->UnixThunk->FTruncate (Private->fd, 0);
+\r
+    //\r
+    // then set it to the needed file size (OS will zero fill it)\r
+    //\r
+    Private->UnixThunk->FTruncate (Private->fd, EndOfFile);
+  }\r
+\r
+  DEBUG ((EFI_D_INIT, "%HPlOpenBlock: opened %s%N\n", Private->Filename));\r
+  Status = EFI_SUCCESS;\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private->fd >= 0) {\r
+      BlockIo->Reset (BlockIo, FALSE);\r
+    }\r
+  }\r
+\r
+  EfiReleaseLock (&Private->Lock);\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoError (\r
+  IN UNIX_BLOCK_IO_PRIVATE      *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  return EFI_DEVICE_ERROR;\r
+
+#if 0
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+  EFI_STATUS            Status;\r
+  BOOLEAN               ReinstallBlockIoFlag;\r
+\r
+
+  BlockIo = &Private->BlockIo;\r
+\r
+  switch (Private->UnixThunk->GetLastError ()) {\r
+\r
+  case ERROR_NOT_READY:\r
+    Status                        = EFI_NO_MEDIA;\r
+    BlockIo->Media->ReadOnly      = FALSE;\r
+    BlockIo->Media->MediaPresent  = FALSE;\r
+    ReinstallBlockIoFlag          = FALSE;\r
+    break;\r
+\r
+  case ERROR_WRONG_DISK:\r
+    BlockIo->Media->ReadOnly      = FALSE;\r
+    BlockIo->Media->MediaPresent  = TRUE;\r
+    BlockIo->Media->MediaId += 1;\r
+    ReinstallBlockIoFlag  = TRUE;\r
+    Status                = EFI_MEDIA_CHANGED;\r
+    break;\r
+\r
+  case ERROR_WRITE_PROTECT:\r
+    BlockIo->Media->ReadOnly  = TRUE;\r
+    ReinstallBlockIoFlag      = FALSE;\r
+    Status                    = EFI_WRITE_PROTECTED;\r
+    break;\r
+\r
+  default:\r
+    ReinstallBlockIoFlag  = FALSE;\r
+    Status                = EFI_DEVICE_ERROR;\r
+    break;\r
+  }\r
+\r
+  if (ReinstallBlockIoFlag) {\r
+    BlockIo->Reset (BlockIo, FALSE);\r
+\r
+    gBS->ReinstallProtocolInterface (\r
+          Private->EfiHandle,\r
+          &gEfiBlockIoProtocolGuid,\r
+          BlockIo,\r
+          BlockIo\r
+          );\r
+  }\r
+\r
+  return Status;\r
+#endif
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixBlockIoReadWriteCommon (\r
+  IN  UNIX_BLOCK_IO_PRIVATE     *Private,\r
+  IN UINT32                       MediaId,\r
+  IN EFI_LBA                      Lba,\r
+  IN UINTN                        BufferSize,\r
+  IN VOID                         *Buffer,\r
+  IN CHAR8                        *CallerName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private     - TODO: add argument description\r
+  MediaId     - TODO: add argument description\r
+  Lba         - TODO: add argument description\r
+  BufferSize  - TODO: add argument description\r
+  Buffer      - TODO: add argument description\r
+  CallerName  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_NO_MEDIA - TODO: Add description for return value\r
+  EFI_MEDIA_CHANGED - TODO: Add description for return value\r
+  EFI_INVALID_PARAMETER - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+  EFI_BAD_BUFFER_SIZE - TODO: Add description for return value\r
+  EFI_INVALID_PARAMETER - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       BlockSize;\r
+  UINT64      LastBlock;\r
+  INT64       DistanceToMove;\r
+  UINT64      DistanceMoved;\r
+\r
+  if (Private->fd < 0) {\r
+    Status = UnixBlockIoOpenDevice (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  if (!Private->Media.MediaPresent) {\r
+    DEBUG ((EFI_D_INIT, "%s: No Media\n", CallerName));\r
+    return EFI_NO_MEDIA;\r
+  }\r
+\r
+  if (Private->Media.MediaId != MediaId) {\r
+    return EFI_MEDIA_CHANGED;\r
+  }\r
+\r
+  if ((UINT32) Buffer % Private->Media.IoAlign != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // Verify buffer size\r
+  //\r
+  BlockSize = Private->BlockSize;\r
+  if (BufferSize == 0) {\r
+    DEBUG ((EFI_D_INIT, "%s: Zero length read\n", CallerName));\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if ((BufferSize % BlockSize) != 0) {\r
+    DEBUG ((EFI_D_INIT, "%s: Invalid read size\n", CallerName));\r
+    return EFI_BAD_BUFFER_SIZE;\r
+  }\r
+\r
+  LastBlock = Lba + (BufferSize / BlockSize) - 1;\r
+  if (LastBlock > Private->LastBlock) {\r
+    DEBUG ((EFI_D_INIT, "ReadBlocks: Attempted to read off end of device\n"));\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Seek to End of File\r
+  //\r
+  DistanceToMove = MultU64x32 (Lba, BlockSize);\r
+  Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_INIT, "WriteBlocks: SetFilePointer failed\n"));\r
+    return UnixBlockIoError (Private);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoReadBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN UINT32                 MediaId,\r
+  IN EFI_LBA                Lba,\r
+  IN UINTN                  BufferSize,\r
+  OUT VOID                  *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Read BufferSize bytes from Lba into Buffer.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MediaId    - Id of the media, changes every time the media is replaced.\r
+    Lba        - The starting Logical Block Address to read from\r
+    BufferSize - Size of Buffer, must be a multiple of device block size.\r
+    Buffer     - Buffer containing read data\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The data was read correctly from the device.\r
+    EFI_DEVICE_ERROR      - The device reported an error while performing the read.\r
+    EFI_NO_MEDIA          - There is no media in the device.\r
+    EFI_MEDIA_CHANGED     - The MediaId does not matched the current device.\r
+    EFI_BAD_BUFFER_SIZE   - The Buffer was not a multiple of the block size of the \r
+                            device.\r
+    EFI_INVALID_PARAMETER - The read request contains device addresses that are not \r
+                            valid for the device.\r
+\r
+--*/\r
+{\r
+  UNIX_BLOCK_IO_PRIVATE *Private;\r
+  ssize_t                 len;
+  EFI_STATUS              Status;\r
+\r
+  Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status  = UnixBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "UnixReadBlocks");\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  len = Private->UnixThunk->Read (Private->fd, Buffer, BufferSize);
+  if (len != BufferSize) {\r
+    DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));
+    return UnixBlockIoError (Private);\r
+  }\r
+\r
+  //\r
+  // If we wrote then media is present.\r
+  //\r
+  This->Media->MediaPresent = TRUE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoWriteBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN UINT32                 MediaId,\r
+  IN EFI_LBA                Lba,\r
+  IN UINTN                  BufferSize,\r
+  IN VOID                   *Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Write BufferSize bytes from Lba into Buffer.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    MediaId    - Id of the media, changes every time the media is replaced.\r
+    Lba        - The starting Logical Block Address to read from\r
+    BufferSize - Size of Buffer, must be a multiple of device block size.\r
+    Buffer     - Buffer containing read data\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The data was written correctly to the device.\r
+    EFI_WRITE_PROTECTED   - The device can not be written to.\r
+    EFI_DEVICE_ERROR      - The device reported an error while performing the write.\r
+    EFI_NO_MEDIA          - There is no media in the device.\r
+    EFI_MEDIA_CHNAGED     - The MediaId does not matched the current device.\r
+    EFI_BAD_BUFFER_SIZE   - The Buffer was not a multiple of the block size of the \r
+                            device.\r
+    EFI_INVALID_PARAMETER - The write request contains a LBA that is not \r
+                            valid for the device.\r
+\r
+--*/\r
+{\r
+  UNIX_BLOCK_IO_PRIVATE *Private;\r
+  ssize_t                 len;
+  EFI_STATUS              Status;\r
+\r
+  Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status  = UnixBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "UnixWriteBlocks");\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  len = Private->UnixThunk->Write (Private->fd, Buffer, BufferSize);
+  if (len != BufferSize) {\r
+    DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));
+    return UnixBlockIoError (Private);\r
+  }\r
+\r
+  //\r
+  // If the write succeeded, we are not write protected and media is present.\r
+  //\r
+  This->Media->MediaPresent = TRUE;\r
+  This->Media->ReadOnly     = FALSE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoFlushBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Flush the Block Device.\r
+\r
+  Arguments:\r
+    This             - Protocol instance pointer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS      - All outstanding data was written to the device\r
+    EFI_DEVICE_ERROR - The device reported an error while writting back the data\r
+    EFI_NO_MEDIA     - There is no media in the device.\r
+\r
+--*/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoResetBlock (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This,\r
+  IN BOOLEAN                ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the Block Device.\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+                            not be reset.\r
+\r
+--*/\r
+{\r
+  UNIX_BLOCK_IO_PRIVATE *Private;\r
+\r
+  Private = UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->fd >= 0) {\r
+    Private->UnixThunk->Close (Private->fd);\r
+    Private->fd = -1;
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINTN\r
+Atoi (\r
+  CHAR16  *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert a unicode string to a UINTN\r
+\r
+Arguments:\r
+\r
+  String - Unicode string.\r
+\r
+Returns: \r
+\r
+  UINTN of the number represented by String.  \r
+\r
+--*/\r
+{\r
+  UINTN   Number;\r
+  CHAR16  *Str;\r
+\r
+  //\r
+  // skip preceeding white space\r
+  //\r
+  Str = String;\r
+  while ((*Str) && (*Str == ' ')) {\r
+    Str++;\r
+  }\r
+  //\r
+  // Convert ot a Number\r
+  //\r
+  Number = 0;\r
+  while (*Str != '\0') {\r
+    if ((*Str >= '0') && (*Str <= '9')) {\r
+      Number = (Number * 10) +*Str - '0';\r
+    } else {\r
+      break;\r
+    }\r
+\r
+    Str++;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+EFI_STATUS\r
+SetFilePointer64 (\r
+  IN  UNIX_BLOCK_IO_PRIVATE    *Private,\r
+  IN  INT64                      DistanceToMove,\r
+  OUT UINT64                     *NewFilePointer,\r
+  IN  INTN                      MoveMethod\r
+  )\r
+/*++\r
+\r
+This function extends the capability of SetFilePointer to accept 64 bit parameters\r
+\r
+--*/\r
+// TODO: function comment is missing 'Routine Description:'\r
+// TODO: function comment is missing 'Arguments:'\r
+// TODO: function comment is missing 'Returns:'\r
+// TODO:    Private - add argument and description to function comment\r
+// TODO:    DistanceToMove - add argument and description to function comment\r
+// TODO:    NewFilePointer - add argument and description to function comment\r
+// TODO:    MoveMethod - add argument and description to function comment\r
+{\r
+  EFI_STATUS    Status;\r
+  off_t         res;
+\r
+  res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);
+  if (res == -1) {
+    Status = EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (NewFilePointer != NULL) {\r
+    *NewFilePointer = res;
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.h b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.h
new file mode 100644 (file)
index 0000000..70d8571
--- /dev/null
@@ -0,0 +1,207 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixBlockIo.h\r
+\r
+Abstract:\r
+\r
+  Produce block IO abstractions for real devices on your PC using Win32 APIs.\r
+  The configuration of what devices to mount or emulate comes from NT \r
+  environment variables. The variables must be visible to the Microsoft* \r
+  Developer Studio for them to work.\r
+\r
+  * Other names and brands may be claimed as the property of others.\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_BLOCK_IO_H_\r
+#define _UNIX_BLOCK_IO_H_\r
+\r
+#define FILENAME_BUFFER_SIZE  80\r
+\r
+//\r
+// Language supported for driverconfiguration protocol\r
+//\r
+#define LANGUAGESUPPORTED "eng"\r
+\r
+#define UNIX_BLOCK_IO_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('L', 'X', 'b', 'k')\r
+typedef struct {\r
+  UINTN                       Signature;\r
+\r
+  EFI_LOCK                    Lock;\r
+\r
+  char                        Filename[FILENAME_BUFFER_SIZE];\r
+  UINTN                       ReadMode;\r
+  UINTN                       Mode;\r
+\r
+  int                         fd;
+\r
+  UINT64                      LastBlock;\r
+  UINTN                       BlockSize;\r
+  UINT64                      NumberOfBlocks;\r
+\r
+  EFI_HANDLE                  EfiHandle;\r
+  EFI_BLOCK_IO_PROTOCOL       BlockIo;\r
+  EFI_BLOCK_IO_MEDIA          Media;\r
+\r
+  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
+\r
+  EFI_UNIX_THUNK_PROTOCOL   *UnixThunk;\r
+\r
+} UNIX_BLOCK_IO_PRIVATE;\r
+\r
+#define UNIX_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, UNIX_BLOCK_IO_PRIVATE, BlockIo, UNIX_BLOCK_IO_PRIVATE_SIGNATURE)\r
+\r
+#define LIST_BUFFER_SIZE  512\r
+\r
+//\r
+// Block I/O Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL        gUnixBlockIoDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL        gUnixBlockIoComponentName;\r
+extern EFI_DRIVER_CONFIGURATION_PROTOCOL  gUnixBlockIoDriverConfiguration;\r
+extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL    gUnixBlockIoDriverDiagnostics;\r
+\r
+//\r
+// EFI Driver Binding Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN  EFI_HANDLE                    Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  Handle              - TODO: add argument description\r
+  RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN  EFI_HANDLE                    Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  Handle              - TODO: add argument description\r
+  RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBlockIoDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Handle,\r
+  IN  UINTN                         NumberOfChildren,\r
+  IN  EFI_HANDLE                    *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Handle            - TODO: add argument description\r
+  NumberOfChildren  - TODO: add argument description\r
+  ChildHandleBuffer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SetFilePointer64 (\r
+  IN  UNIX_BLOCK_IO_PRIVATE    *Private,\r
+  IN  INT64                      DistanceToMove,\r
+  OUT UINT64                     *NewFilePointer,\r
+  IN  INT32                      MoveMethod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private         - TODO: add argument description\r
+  DistanceToMove  - TODO: add argument description\r
+  NewFilePointer  - TODO: add argument description\r
+  MoveMethod      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+Atoi (\r
+  CHAR16  *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  String  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.msa b/EdkUnixPkg/Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.msa
new file mode 100644 (file)
index 0000000..4933490
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixBlockIo</ModuleName>\r
+    <ModuleType>UEFI_DRIVER</ModuleType>\r
+    <GuidValue>f3085888-8985-11db-9c93-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Block Io driver</Abstract>\r
+    <Description>\r
+      Produce block IO abstractions for real devices on your PC using Unix APIs.\r
+      The configuration of what devices to mount or emulate comes from\r
+      environment variables.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixBlockIo</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixBlockIo.h</Filename>\r
+    <Filename>UnixBlockIo.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+    <Filename>DriverConfiguration.c</Filename>\r
+    <Filename>DriverDiagnostics.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixVirtualDisksGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiUnixPhysicalDisksGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gUnixBlockIoDriverBinding</DriverBinding>\r
+      <ComponentName>gUnixBlockIoComponentName</ComponentName>\r
+      <DriverDiag>gUnixBlockIoDriverDiagnostics</DriverDiag>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ComponentName.c
new file mode 100644 (file)
index 0000000..abfb328
--- /dev/null
@@ -0,0 +1,187 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "Console.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gUnixConsoleComponentName = {\r
+  UnixConsoleComponentNameGetDriverName,\r
+  UnixConsoleComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mUnixConsoleDriverNameTable[] = {\r
+  { "eng", L"Unix Text Console Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixConsoleComponentName.SupportedLanguages,\r
+          mUnixConsoleDriverNameTable,\r
+          DriverName\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL    *SimpleTextOut;\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Get out context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  (void *)&SimpleTextOut,\r
+                  gUnixConsoleDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (SimpleTextOut);\r
+\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixConsoleComponentName.SupportedLanguages,\r
+          Private->ControllerNameTable,\r
+          ControllerName\r
+          );\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.c
new file mode 100644 (file)
index 0000000..cd4870d
--- /dev/null
@@ -0,0 +1,310 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Console.c\r
+\r
+Abstract:\r
+\r
+  Console based on Win32 APIs. \r
+\r
+--*/\r
+\r
+#include "Console.h"\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  );\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gUnixConsoleDriverBinding = {\r
+  UnixConsoleDriverBindingSupported,\r
+  UnixConsoleDriverBindingStart,\r
+  UnixConsoleDriverBindingStop,\r
+  0x10,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_UNIX_IO_PROTOCOL  *UnixIo;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure that the Unix Thunk Protocol is valid\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (UnixIo->UnixThunk->Signature == EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) {\r
+\r
+    //\r
+    // Check the GUID to see if this is a handle type the driver supports\r
+    //\r
+    if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixConsoleGuid)) {\r
+      Status = EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEfiUnixIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_UNIX_IO_PROTOCOL          *UnixIo;\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  //\r
+  // Grab the IO abstraction we need to get any work done\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (void *)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (UNIX_SIMPLE_TEXT_PRIVATE_DATA),\r
+                  (void *)&Private\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  ZeroMem (Private, sizeof (UNIX_SIMPLE_TEXT_PRIVATE_DATA));\r
+\r
+  Private->Signature  = UNIX_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE;\r
+  Private->Handle     = Handle;\r
+  Private->UnixIo    = UnixIo;\r
+  Private->UnixThunk = UnixIo->UnixThunk;\r
+\r
+  UnixSimpleTextOutOpenWindow (Private);\r
+  UnixSimpleTextInAttachToWindow (Private);\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  &Private->SimpleTextOut,\r
+                  &gEfiSimpleTextInProtocolGuid,\r
+                  &Private->SimpleTextIn,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+Done:\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEfiUnixIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+  if (Private != NULL) {\r
+\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+\r
+#if 0
+    if (Private->NtOutHandle != NULL) {\r
+      Private->UnixThunk->CloseHandle (Private->NtOutHandle);\r
+    }\r
+#endif
+\r
+    if (Private->SimpleTextIn.WaitForKey != NULL) {\r
+      gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);\r
+    }\r
+\r
+    gBS->FreePool (Private);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixConsoleDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Handle            - TODO: add argument description\r
+  NumberOfChildren  - TODO: add argument description\r
+  ChildHandleBuffer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL    *SimpleTextOut;\r
+  EFI_STATUS                      Status;\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  //\r
+  // Kick people off our interface???\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  (void *)&SimpleTextOut,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (SimpleTextOut);\r
+\r
+  ASSERT (Private->Handle == Handle);\r
+\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  Handle,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  &Private->SimpleTextOut,\r
+                  &gEfiSimpleTextInProtocolGuid,\r
+                  &Private->SimpleTextIn,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+\r
+    //\r
+    // Shut down our device\r
+    //\r
+    Status = gBS->CloseProtocol (\r
+                    Handle,\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    Handle\r
+                    );\r
+\r
+    Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+#if 0
+    Private->UnixThunk->CloseHandle (Private->NtOutHandle);\r
+#endif
+    //\r
+    // DO NOT close Private->NtInHandle. It points to StdIn and not\r
+    //  the Private->NtOutHandle is StdIn and should not be closed!\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+\r
+    gBS->FreePool (Private);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.h b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/Console.h
new file mode 100644 (file)
index 0000000..3f0b4eb
--- /dev/null
@@ -0,0 +1,513 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Console.h\r
+\r
+Abstract:\r
+\r
+  Console based on Win32 APIs.\r
+\r
+  This file attaches a SimpleTextIn protocol to a previously open window.\r
+  \r
+  The constructor for this protocol depends on an open window. Currently\r
+  the SimpleTextOut protocol creates a window when it's constructor is called.\r
+  Thus this code must run after the constructor for the SimpleTextOut \r
+  protocol\r
+  \r
+--*/\r
+\r
+#ifndef _CONSOLE_H_\r
+#define _CONSOLE_H_\r
+\r
+#define UNIX_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE \\r
+          EFI_SIGNATURE_32('U','X','s','c')\r
+\r
+typedef struct {\r
+  UINT64                        Signature;\r
+\r
+  EFI_HANDLE                    Handle;\r
+\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL  SimpleTextOut;\r
+  EFI_SIMPLE_TEXT_OUTPUT_MODE   SimpleTextOutMode;\r
+\r
+  EFI_UNIX_IO_PROTOCOL        *UnixIo;\r
+  EFI_UNIX_THUNK_PROTOCOL     *UnixThunk;\r
+\r
+  //\r
+  // SimpleTextOut Private Data including Win32 types.\r
+  //\r
+  //  HANDLE                        NtOutHandle;\r
+  //  HANDLE                        NtInHandle;\r
+\r
+  //COORD                         MaxScreenSize;\r
+  //COORD                         Position;\r
+  //WORD                          Attribute;\r
+  BOOLEAN                       CursorEnable;\r
+\r
+  EFI_SIMPLE_TEXT_IN_PROTOCOL   SimpleTextIn;\r
+\r
+  EFI_UNICODE_STRING_TABLE      *ControllerNameTable;\r
+\r
+} UNIX_SIMPLE_TEXT_PRIVATE_DATA;\r
+\r
+#define UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, UNIX_SIMPLE_TEXT_PRIVATE_DATA, SimpleTextOut, UNIX_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE)\r
+\r
+#define UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, UNIX_SIMPLE_TEXT_PRIVATE_DATA, SimpleTextIn, UNIX_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE)\r
+\r
+//\r
+// Console Globale Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gUnixConsoleDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gUnixConsoleComponentName;\r
+\r
+typedef struct {\r
+  UINTN ColumnsX;\r
+  UINTN RowsY;\r
+} UNIX_SIMPLE_TEXT_OUT_MODE;\r
+\r
+#if 0
+//\r
+// Simple Text Out protocol member functions\r
+//\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutReset (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL     *This,\r
+  IN BOOLEAN                          ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - TODO: add argument description\r
+  ExtendedVerification  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutOutputString (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN CHAR16                         *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  String  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutTestString (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN CHAR16                         *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  String  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutQueryMode (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN UINTN                          ModeNumber,\r
+  OUT UINTN                         *Columns,\r
+  OUT UINTN                         *Rows\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  ModeNumber  - TODO: add argument description\r
+  Columns     - TODO: add argument description\r
+  Rows        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetMode (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN UINTN                          ModeNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  ModeNumber  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetAttribute (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN UINTN                          Attribute\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This      - TODO: add argument description\r
+  Attribute - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutClearScreen (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetCursorPosition (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN UINTN                          Column,\r
+  IN UINTN                          Row\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  Column  - TODO: add argument description\r
+  Row     - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutEnableCursor (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN BOOLEAN                        Enable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  Enable  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif
+//\r
+// Simple Text Out constructor and destructor.\r
+//\r
+EFI_STATUS\r
+UnixSimpleTextOutOpenWindow (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UnixSimpleTextOutCloseWindow (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Console - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#if 0
+//\r
+// Simple Text In protocol member functions.\r
+//\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextInReset (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          *This,\r
+  IN BOOLEAN                              ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - TODO: add argument description\r
+  ExtendedVerification  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextInReadKeyStroke (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          *This,\r
+  OUT EFI_INPUT_KEY                       *Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+  Key   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+UnixSimpleTextInWaitForKey (\r
+  IN EFI_EVENT          Event,\r
+  IN VOID               *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Event   - TODO: add argument description\r
+  Context - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif
+//\r
+// Simple Text In constructor\r
+//\r
+EFI_STATUS\r
+UnixSimpleTextInAttachToWindow (\r
+  IN  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Main Entry Point\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeUnixConsole (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - TODO: add argument description\r
+  SystemTable - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+AppendDevicePathInstanceToVar (\r
+  IN  CHAR16                    *VariableName,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  VariableName        - TODO: add argument description\r
+  DevicePathInstance  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ConsoleIn.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ConsoleIn.c
new file mode 100644 (file)
index 0000000..ff70a5f
--- /dev/null
@@ -0,0 +1,246 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleIn.c\r
+\r
+Abstract:\r
+\r
+  Console based on Win32 APIs. \r
+\r
+  This file attaches a SimpleTextIn protocol to a previously open window.\r
+  \r
+  The constructor for this protocol depends on an open window. Currently\r
+  the SimpleTextOut protocol creates a window when it's constructor is called.\r
+  Thus this code must run after the constructor for the SimpleTextOut \r
+  protocol\r
+  \r
+--*/\r
+\r
+#include "Console.h"\r
+#include <sys/poll.h>
+\r
+//\r
+// Private worker functions\r
+//\r
+STATIC\r
+EFI_STATUS\r
+UnixSimpleTextInCheckKey (\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA  *Private\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextInReset (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          *This,\r
+  IN BOOLEAN                              ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - TODO: add argument description\r
+  ExtendedVerification  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixConvertInputRecordToEfiKey (\r
+  IN  char c,
+  OUT EFI_INPUT_KEY   *Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  InputRecord - TODO: add argument description\r
+  Key         - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_NOT_READY - TODO: Add description for return value\r
+  EFI_NOT_READY - TODO: Add description for return value\r
+  EFI_NOT_READY - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  Key->ScanCode     = 0;\r
+  if (c == '\n')
+    c = '\r';
+  Key->UnicodeChar  = c;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextInReadKeyStroke (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          *This,\r
+  OUT EFI_INPUT_KEY                       *Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+  Key   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_DEVICE_ERROR - TODO: Add description for return value\r
+  EFI_NOT_READY - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+  char c;
+\r
+  Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status  = UnixSimpleTextInCheckKey (Private);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (Private->UnixThunk->Read (0, &c, 1) != 1)
+    return EFI_NOT_READY;\r
+  Status = UnixConvertInputRecordToEfiKey (c, Key);\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+UnixSimpleTextInWaitForKey (\r
+  IN EFI_EVENT          Event,\r
+  IN VOID               *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Event   - TODO: add argument description\r
+  Context - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+  EFI_STATUS                      Status;\r
+\r
+  Private = (UNIX_SIMPLE_TEXT_PRIVATE_DATA *) Context;\r
+  Status  = UnixSimpleTextInCheckKey (Private);\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->SignalEvent (Event);\r
+  }\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixSimpleTextInCheckKey (\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA   *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  struct pollfd pfd;
+\r
+  pfd.fd = 0;
+  pfd.events = POLLIN;
+  if (Private->UnixThunk->Poll (&pfd, 1, 0) <= 0) {
+    return EFI_NOT_READY;\r
+  }\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UnixSimpleTextInAttachToWindow (\r
+  IN  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Private->SimpleTextIn.Reset         = UnixSimpleTextInReset;\r
+  Private->SimpleTextIn.ReadKeyStroke = UnixSimpleTextInReadKeyStroke;\r
+\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_WAIT,\r
+                  EFI_TPL_NOTIFY,\r
+                  UnixSimpleTextInWaitForKey,\r
+                  Private,\r
+                  &Private->SimpleTextIn.WaitForKey\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ConsoleOut.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/ConsoleOut.c
new file mode 100644 (file)
index 0000000..bd9d4e2
--- /dev/null
@@ -0,0 +1,635 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ConsoleOut.c\r
+\r
+Abstract:\r
+\r
+  Console based on Win32 APIs. \r
+\r
+  This file creates an Win32 window and attaches a SimpleTextOut protocol.\r
+\r
+--*/\r
+\r
+#include "Console.h"\r
+//\r
+// Private worker functions.\r
+//\r
+\r
+#if 0
+STATIC\r
+VOID\r
+UnixSimpleTextOutScrollScreen (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
+  );\r
+\r
+#endif
+STATIC\r
+VOID\r
+UnixSimpleTextOutPutChar (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA     *Console,\r
+  IN      CHAR16                              Char\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetAttribute (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN UINTN                          Attribute\r
+  );\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetMode (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           *This,\r
+  IN UINTN                                  ModeNumber\r
+  );\r
+
+//\r
+// Modeule Global for Simple Text Out Mode.\r
+//\r
+#define MAX_SIMPLE_TEXT_OUT_MODE  \\r
+        (sizeof(mUnixSimpleTextOutSupportedModes)/sizeof(UNIX_SIMPLE_TEXT_OUT_MODE))\r
+\r
+STATIC UNIX_SIMPLE_TEXT_OUT_MODE  mUnixSimpleTextOutSupportedModes[] = {\r
+  { 80, 25 },         \r
+#if 0
+  { 80, 50 },         \r
+  { 80, 43 },         \r
+  { 100, 100 },       \r
+  { 100, 999 }         \r
+#endif
+};\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutReset (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL         *This,\r
+  IN BOOLEAN                              ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - TODO: add argument description\r
+  ExtendedVerification  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  UnixSimpleTextOutSetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
+\r
+  UnixSimpleTextOutSetMode (This, 0);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutOutputString (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           *This,\r
+  IN CHAR16                                 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  String  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+  CHAR16                          *Str;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  for (Str = String; *Str != '\0'; Str++) {\r
+    switch (*Str) {\r
+#if 0
+    case '\n':\r
+      if (Private->Position.Y == (Private->MaxScreenSize.Y - 1)) {\r
+        UnixSimpleTextOutScrollScreen (Private);\r
+      }\r
+\r
+      if (Private->Position.Y < (Private->MaxScreenSize.Y - 1)) {\r
+        Private->Position.Y++;\r
+        This->Mode->CursorRow++;\r
+      }\r
+      break;\r
+\r
+    case '\r':\r
+      Private->Position.X      = 0;\r
+      This->Mode->CursorColumn  = 0;\r
+      break;\r
+\r
+    case '\b':\r
+      if (Private->Position.X > 0) {\r
+        Private->Position.X--;\r
+        This->Mode->CursorColumn--;\r
+      }\r
+      break;\r
+\r
+#endif
+    default:\r
+      UnixSimpleTextOutPutChar (Private, *Str);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+UnixSimpleTextOutPutChar (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA   *Console,\r
+  IN      CHAR16                            Char\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Console - TODO: add argument description\r
+  Char    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  char c = Char;
+  Console->UnixThunk->Write (1, &c, 1);
+}\r
+\r
+#if 0
+STATIC\r
+VOID\r
+UnixSimpleTextOutScrollScreen (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Console - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+}\r
+#endif
+
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutTestString (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           *This,\r
+  IN CHAR16                                 *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  String  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  //\r
+  // BugBug: The correct answer would be a function of what code pages\r
+  //         are currently loaded? For now we will just return success.\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutQueryMode (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           *This,\r
+  IN UINTN                                  ModeNumber,\r
+  OUT UINTN                                 *Columns,\r
+  OUT UINTN                                 *Rows\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  ModeNumber  - TODO: add argument description\r
+  Columns     - TODO: add argument description\r
+  Rows        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (ModeNumber > MAX_SIMPLE_TEXT_OUT_MODE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *Columns  = mUnixSimpleTextOutSupportedModes[ModeNumber].ColumnsX;\r
+  *Rows     = mUnixSimpleTextOutSupportedModes[ModeNumber].RowsY;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetMode (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           *This,\r
+  IN UINTN                                  ModeNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  ModeNumber  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (ModeNumber > MAX_SIMPLE_TEXT_OUT_MODE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+\r
+  This->Mode->Mode = (INT32) ModeNumber;\r
+\r
+  This->EnableCursor (This, TRUE);\r
+  This->ClearScreen (This);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetAttribute (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN UINTN                          Attribute\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This      - TODO: add argument description\r
+  Attribute - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private               = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+#if 0
+  Private->Attribute    = (WORD) Attribute;\r
+#endif
+  This->Mode->Attribute = (INT32) Attribute;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutClearScreen (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+  //  DWORD                           ConsoleWindow;\r
+\r
+  Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  This->SetCursorPosition (This, 0, 0);\r
+  Private->UnixThunk->Write (1, "\e[2J", 4);
+
+\r
+#if 0
+  Private->UnixThunk->FillConsoleOutputCharacter (\r
+                        Private->NtOutHandle,\r
+                        ' ',\r
+                        Private->MaxScreenSize.X * Private->MaxScreenSize.Y,\r
+                        Private->Possition,\r
+                        &ConsoleWindow\r
+                        );\r
+  Private->UnixThunk->FillConsoleOutputAttribute (\r
+                        Private->NtOutHandle,\r
+                        Private->Attribute,\r
+                        Private->MaxScreenSize.X * Private->MaxScreenSize.Y,\r
+                        Private->Possition,\r
+                        &ConsoleWindow\r
+                        );\r
+#endif
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutSetCursorPosition (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL           *This,\r
+  IN UINTN                                  Column,\r
+  IN UINTN                                  Row\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  Column  - TODO: add argument description\r
+  Row     - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  char buf[12];
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+\r
+  Private                   = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+#if 0
+  Private->Position.X      = (WORD) Column;\r
+#endif
+  This->Mode->CursorColumn  = (INT32) Column;\r
+\r
+#if 0
+  Private->Position.Y      = (WORD) Row;\r
+#endif
+  This->Mode->CursorRow     = (INT32) Row;\r
+#if 0
+  Private->UnixThunk->SetConsoleCursorPosition (Private->NtOutHandle, Private->Possition);\r
+#endif
+\r
+  buf[0] = '\e';
+  buf[1] = '[';
+  buf[2] = '0' + ((Row / 100) % 10);
+  buf[3] = '0' + ((Row / 10) % 10);
+  buf[4] = '0' + ((Row / 1) % 10);
+  buf[5] = ';';
+  buf[6] = '0' + ((Column / 100) % 10);
+  buf[7] = '0' + ((Column / 10) % 10);
+  buf[8] = '0' + ((Column / 1) % 10);
+  buf[9] = 'H';
+  Private->UnixThunk->Write (1, buf, 10);
+
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleTextOutEnableCursor (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *This,\r
+  IN BOOLEAN                        Enable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This    - TODO: add argument description\r
+  Enable  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
+#if 0
+  CONSOLE_CURSOR_INFO             Info;\r
+#endif
+\r
+  Private                   = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
+  Private->CursorEnable     = Enable;\r
+  This->Mode->CursorVisible = Enable;\r
+\r
+#if 0
+  Private->UnixThunk->GetConsoleCursorInfo (Private->NtOutHandle, &Info);\r
+  Info.bVisible = Enable;\r
+  Private->UnixThunk->SetConsoleCursorInfo (Private->NtOutHandle, &Info);\r
+#endif
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UnixSimpleTextOutOpenWindow (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *SimpleTextOut;\r
+  CHAR16                        *WindowName;\r
+\r
+  //WindowName          = Private->UnixIo->EnvString;\r
+#if 0
+  Private->Attribute  = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;\r
+  if (*WindowName == '?') {\r
+    Private->Attribute  = BACKGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN;\r
+    WindowName          = L"EFI Emulator Error Console";\r
+  }\r
+#endif
+    WindowName          = L"EFI Emulator Error Console";\r
+\r
+  AddUnicodeString (\r
+    "eng",\r
+    gUnixConsoleComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    WindowName\r
+    );\r
+\r
+  //\r
+  // Fill in protocol member functions\r
+  //\r
+  SimpleTextOut                     = &Private->SimpleTextOut;\r
+  SimpleTextOut->Reset              = UnixSimpleTextOutReset;\r
+  SimpleTextOut->OutputString       = UnixSimpleTextOutOutputString;\r
+  SimpleTextOut->TestString         = UnixSimpleTextOutTestString;\r
+  SimpleTextOut->QueryMode          = UnixSimpleTextOutQueryMode;\r
+  SimpleTextOut->SetMode            = UnixSimpleTextOutSetMode;\r
+  SimpleTextOut->SetAttribute       = UnixSimpleTextOutSetAttribute;\r
+  SimpleTextOut->ClearScreen        = UnixSimpleTextOutClearScreen;\r
+  SimpleTextOut->SetCursorPosition  = UnixSimpleTextOutSetCursorPosition;\r
+  SimpleTextOut->EnableCursor       = UnixSimpleTextOutEnableCursor;\r
+\r
+  //\r
+  // Initialize SimpleTextOut protocol mode structure\r
+  //\r
+  SimpleTextOut->Mode             = &Private->SimpleTextOutMode;\r
+  SimpleTextOut->Mode->MaxMode    = MAX_SIMPLE_TEXT_OUT_MODE;\r
+  SimpleTextOut->Mode->Attribute  = 0; //FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;\r
+\r
+#if 0
+  //\r
+  // Open the window an initialize it!\r
+  //\r
+  Private->NtOutHandle = Private->UnixThunk->CreateConsoleScreenBuffer (\r
+                                                GENERIC_WRITE | GENERIC_READ,\r
+                                                FILE_SHARE_WRITE | FILE_SHARE_READ,\r
+                                                NULL,\r
+                                                CONSOLE_TEXTMODE_BUFFER,\r
+                                                NULL\r
+                                                );\r
+  Private->UnixThunk->SetConsoleTitle (WindowName);\r
+#endif
+\r
+  return SimpleTextOut->SetMode (SimpleTextOut, 0);\r
+}\r
+\r
+EFI_STATUS\r
+UnixSimpleTextOutCloseWindow (\r
+  IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Console - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+#if 0
+  Console->UnixThunk->CloseHandle (Console->NtOutHandle);\r
+#endif
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/UnixConsole.msa b/EdkUnixPkg/Dxe/UnixThunk/Bus/Console/UnixConsole.msa
new file mode 100644 (file)
index 0000000..839eed7
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixConsole</ModuleName>\r
+    <ModuleType>UEFI_DRIVER</ModuleType>\r
+    <GuidValue>f314a8cc-8985-11db-9f69-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Console Dxe driver</Abstract>\r
+    <Description>Simulate console with Unix API</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixConsole</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Console.h</Filename>\r
+    <Filename>Console.c</Filename>\r
+    <Filename>ConsoleIn.c</Filename>\r
+    <Filename>ConsoleOut.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixConsoleGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gUnixConsoleDriverBinding</DriverBinding>\r
+      <ComponentName>gUnixConsoleComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/ComponentName.c
new file mode 100644 (file)
index 0000000..0db3b1c
--- /dev/null
@@ -0,0 +1,193 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "UnixSimpleFileSystem.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                                        *This,\r
+  IN  EFI_HANDLE                                                         ControllerHandle,\r
+  IN  EFI_HANDLE                                                         ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                                              *Language,\r
+  OUT CHAR16                                                             **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gUnixSimpleFileSystemComponentName = {\r
+  UnixSimpleFileSystemComponentNameGetDriverName,\r
+  UnixSimpleFileSystemComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mUnixSimpleFileSystemDriverNameTable[] = {\r
+  {\r
+    "eng",\r
+    L"Unix Simple File System Driver"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixSimpleFileSystemComponentName.SupportedLanguages,\r
+          mUnixSimpleFileSystemDriverNameTable,\r
+          DriverName\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                                        *This,\r
+  IN  EFI_HANDLE                                                         ControllerHandle,\r
+  IN  EFI_HANDLE                                                         ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                                              *Language,\r
+  OUT CHAR16                                                             **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *SimpleFileSystem;\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  &SimpleFileSystem,\r
+                  gUnixSimpleFileSystemDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);\r
+\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixSimpleFileSystemComponentName.SupportedLanguages,\r
+          Private->ControllerNameTable,\r
+          ControllerName\r
+          );\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.c
new file mode 100644 (file)
index 0000000..a1b5b32
--- /dev/null
@@ -0,0 +1,2106 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixSimpleFileSystem.c\r
+\r
+Abstract:\r
+\r
+  Produce Simple File System abstractions for directories on your PC using Win32 APIs.\r
+  The configuration of what devices to mount or emulate comes from NT \r
+  environment variables. The variables must be visible to the Microsoft* \r
+  Developer Studio for them to work.\r
+\r
+  * Other names and brands may be claimed as the property of others.\r
+\r
+--*/\r
+\r
+#include "UnixSimpleFileSystem.h"\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gUnixSimpleFileSystemDriverBinding = {\r
+  UnixSimpleFileSystemDriverBindingSupported,\r
+  UnixSimpleFileSystemDriverBindingStart,\r
+  UnixSimpleFileSystemDriverBindingStop,\r
+  0x10,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+CHAR16 *\r
+EfiStrChr (\r
+  IN CHAR16   *Str,\r
+  IN CHAR16   Chr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Locate the first occurance of a character in a string.\r
+\r
+Arguments:\r
+\r
+  Str - Pointer to NULL terminated unicode string.\r
+  Chr - Character to locate.\r
+\r
+Returns:\r
+\r
+  If Str is NULL, then NULL is returned.\r
+  If Chr is not contained in Str, then NULL is returned.\r
+  If Chr is contained in Str, then a pointer to the first occurance of Chr in Str is returned.\r
+\r
+--*/\r
+{\r
+  if (Str == NULL) {\r
+    return Str;\r
+  }\r
+\r
+  while (*Str != '\0' && *Str != Chr) {\r
+    ++Str;\r
+  }\r
+\r
+  return (*Str == Chr) ? Str : NULL;\r
+}\r
+\r
+BOOLEAN\r
+IsZero (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Length\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Buffer  - TODO: add argument description\r
+  Length  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  if (Buffer == NULL || Length == 0) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (*(UINT8 *) Buffer != 0) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (Length > 1) {\r
+    if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+VOID\r
+CutPrefix (\r
+  IN  CHAR8  *Str,\r
+  IN  UINTN   Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Str   - TODO: add argument description\r
+  Count - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  CHAR8  *Pointer;\r
+\r
+  if (AsciiStrLen (Str) < Count) {\r
+    ASSERT (0);\r
+  }\r
+\r
+  for (Pointer = Str; *(Pointer + Count); Pointer++) {\r
+    *Pointer = *(Pointer + Count);\r
+  }\r
+\r
+  *Pointer = *(Pointer + Count);\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check to see if the driver supports a given controller.\r
+\r
+Arguments:\r
+\r
+  This                - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+  ControllerHandle    - EFI handle of the controller to test.\r
+\r
+  RemainingDevicePath - Pointer to remaining portion of a device path.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS         - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver\r
+                        specified by This.\r
+\r
+  EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r
+                        the driver specified by This.\r
+\r
+  EFI_ACCESS_DENIED   - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r
+                        a different driver or an application that requires exclusive access.\r
+\r
+  EFI_UNSUPPORTED     - The device specified by ControllerHandle and RemainingDevicePath is not supported by the\r
+                        driver specified by This.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_UNIX_IO_PROTOCOL  *UnixIo;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (VOID **)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure GUID is for a File System handle.\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (CompareGuid (UnixIo->TypeGuid, &gEfiUnixFileSystemGuid)) {\r
+    Status = EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiUnixIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Starts a device controller or a bus controller.\r
+\r
+Arguments:\r
+\r
+  This                - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+  ControllerHandle    - EFI handle of the controller to start.\r
+\r
+  RemainingDevicePath - Pointer to remaining portion of a device path.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The device or bus controller has been started.\r
+\r
+  EFI_DEVICE_ERROR      - The device could not be started due to a device failure.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The request could not be completed due to lack of resources.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_UNIX_IO_PROTOCOL            *UnixIo;\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *Private;\r
+  INTN i;
+\r
+  Private = NULL;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (VOID **)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Validate GUID\r
+  //\r
+  if (!CompareGuid (UnixIo->TypeGuid, &gEfiUnixFileSystemGuid)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (UNIX_SIMPLE_FILE_SYSTEM_PRIVATE),\r
+                  (VOID **)&Private\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  Private->Signature  = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;\r
+  Private->UnixThunk = UnixIo->UnixThunk;\r
+  Private->FilePath   = NULL;
+  Private->VolumeLabel = NULL;
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  StrLen (UnixIo->EnvString) + 1,\r
+                  (VOID **)&Private->FilePath\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+
+  for (i = 0; UnixIo->EnvString[i] != 0; i++)
+    Private->FilePath[i] = UnixIo->EnvString[i];\r
+  Private->FilePath[i] = 0;
+\r
+  Private->VolumeLabel      = NULL;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  StrSize (L"EFI_EMULATED"),\r
+                  (VOID **)&Private->VolumeLabel\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  StrCpy (Private->VolumeLabel, L"EFI_EMULATED");\r
+\r
+  Private->SimpleFileSystem.Revision    = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;\r
+  Private->SimpleFileSystem.OpenVolume  = UnixSimpleFileSystemOpenVolume;\r
+\r
+  Private->ControllerNameTable = NULL;\r
+\r
+  AddUnicodeString (\r
+    "eng",\r
+    gUnixSimpleFileSystemComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    UnixIo->EnvString\r
+    );\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  &Private->SimpleFileSystem,\r
+                  NULL\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+\r
+    if (Private != NULL) {\r
+\r
+      if (Private->VolumeLabel != NULL)
+       gBS->FreePool (Private->VolumeLabel);
+      if (Private->FilePath != NULL)
+       gBS->FreePool (Private->FilePath);
+      FreeUnicodeStringTable (Private->ControllerNameTable);\r
+\r
+      gBS->FreePool (Private);\r
+    }\r
+\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+  ControllerHandle  - A handle to the device to be stopped.\r
+\r
+  NumberOfChildren  - The number of child device handles in ChildHandleBuffer.\r
+\r
+  ChildHandleBuffer - An array of child device handles to be freed.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - The device has been stopped.\r
+\r
+  EFI_DEVICE_ERROR  - The device could not be stopped due to a device failure.\r
+\r
+--*/\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *SimpleFileSystem;\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *Private;\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  (VOID **)&SimpleFileSystem,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);\r
+\r
+  //\r
+  // Uninstall the Simple File System Protocol from ControllerHandle\r
+  //\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  &Private->SimpleFileSystem,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = gBS->CloseProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle\r
+                    );\r
+  }\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Free our instance data\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+\r
+    gBS->FreePool (Private);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemOpenVolume (\r
+  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL  *This,\r
+  OUT EFI_FILE                        **Root\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Open the root directory on a volume.\r
+\r
+Arguments:\r
+\r
+  This  - A pointer to the volume to open.\r
+\r
+  Root  - A pointer to storage for the returned opened file handle of the root directory.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The volume was opened.\r
+\r
+  EFI_UNSUPPORTED       - The volume does not support the requested file system type.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupted.\r
+\r
+  EFI_ACCESS_DENIED     - The service denied access to the file.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The file volume could not be opened due to lack of resources.\r
+\r
+  EFI_MEDIA_CHANGED     - The device has new media or the media is no longer supported.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  EFI_STATUS                        Status;\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *Private;\r
+  UNIX_EFI_FILE_PRIVATE           *PrivateFile;\r
+\r
+  if (This == NULL || Root == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Private     = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  PrivateFile = NULL;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (UNIX_EFI_FILE_PRIVATE),\r
+                  (VOID **)&PrivateFile\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  PrivateFile->FileName = NULL;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  AsciiStrSize (Private->FilePath),\r
+                  (VOID **)&PrivateFile->FileName\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  AsciiStrCpy (PrivateFile->FileName, Private->FilePath);\r
+  PrivateFile->Signature            = UNIX_EFI_FILE_PRIVATE_SIGNATURE;\r
+  PrivateFile->UnixThunk           = Private->UnixThunk;\r
+  PrivateFile->SimpleFileSystem     = This;\r
+  PrivateFile->IsRootDirectory      = TRUE;\r
+  PrivateFile->IsDirectoryPath      = TRUE;\r
+  PrivateFile->IsOpenedByRead       = TRUE;\r
+  PrivateFile->EfiFile.Revision     = EFI_FILE_HANDLE_REVISION;\r
+  PrivateFile->EfiFile.Open         = UnixSimpleFileSystemOpen;\r
+  PrivateFile->EfiFile.Close        = UnixSimpleFileSystemClose;\r
+  PrivateFile->EfiFile.Delete       = UnixSimpleFileSystemDelete;\r
+  PrivateFile->EfiFile.Read         = UnixSimpleFileSystemRead;\r
+  PrivateFile->EfiFile.Write        = UnixSimpleFileSystemWrite;\r
+  PrivateFile->EfiFile.GetPosition  = UnixSimpleFileSystemGetPosition;\r
+  PrivateFile->EfiFile.SetPosition  = UnixSimpleFileSystemSetPosition;\r
+  PrivateFile->EfiFile.GetInfo      = UnixSimpleFileSystemGetInfo;\r
+  PrivateFile->EfiFile.SetInfo      = UnixSimpleFileSystemSetInfo;\r
+  PrivateFile->EfiFile.Flush        = UnixSimpleFileSystemFlush;\r
+  PrivateFile->fd                   = -1;
+  PrivateFile->Dir                  = NULL;
+  PrivateFile->Dirent               = NULL;
+  \r
+  *Root = &PrivateFile->EfiFile;\r
+\r
+  PrivateFile->Dir = PrivateFile->UnixThunk->OpenDir(PrivateFile->FileName);
+\r
+  if (PrivateFile->Dir == NULL) {
+    Status = EFI_ACCESS_DENIED;\r
+  }
+  else {
+    Status = EFI_SUCCESS;\r
+  }
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (PrivateFile) {\r
+      if (PrivateFile->FileName) {\r
+        gBS->FreePool (PrivateFile->FileName);\r
+      }\r
+\r
+      gBS->FreePool (PrivateFile);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemOpen (\r
+  IN  EFI_FILE  *This,\r
+  OUT EFI_FILE  **NewHandle,\r
+  IN  CHAR16    *FileName,\r
+  IN  UINT64    OpenMode,\r
+  IN  UINT64    Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Open a file relative to the source file location.\r
+\r
+Arguments:\r
+\r
+  This        - A pointer to the source file location.\r
+\r
+  NewHandle   - Pointer to storage for the new file handle.\r
+\r
+  FileName    - Pointer to the file name to be opened.\r
+\r
+  OpenMode    - File open mode information.\r
+\r
+  Attributes  - File creation attributes.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The file was opened.\r
+\r
+  EFI_NOT_FOUND         - The file could not be found in the volume.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_MEDIA_CHANGED     - The device has new media or the media is no longer supported.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupted.\r
+\r
+  EFI_WRITE_PROTECTED   - The volume or file is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The service denied access to the file.\r
+\r
+  EFI_OUT_OF_RESOURCES  - Not enough resources were available to open the file.\r
+\r
+  EFI_VOLUME_FULL       - There is not enough space left to create the new file.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  EFI_FILE                          *Root;\r
+  UNIX_EFI_FILE_PRIVATE           *PrivateFile;\r
+  UNIX_EFI_FILE_PRIVATE           *NewPrivateFile;\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;\r
+  EFI_STATUS                        Status;\r
+  CHAR16                            *Src;
+  char                              *Dst;
+  CHAR8                             *RealFileName;\r
+  CHAR16                            *TempFileName;\r
+  char                              *ParseFileName;\r
+  char                              *GuardPointer;\r
+  CHAR8                             TempChar;\r
+  UINTN                             Count;\r
+  BOOLEAN                           TrailingDash;\r
+  BOOLEAN                           LoopFinish;\r
+  UINTN                             InfoSize;\r
+  EFI_FILE_INFO                     *Info;\r
+\r
+  TrailingDash = FALSE;\r
+\r
+  //\r
+  // Check for obvious invalid parameters.\r
+  //\r
+  if (This == NULL || NewHandle == NULL || FileName == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  switch (OpenMode) {\r
+  case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:\r
+    if (Attributes &~EFI_FILE_VALID_ATTR) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if (Attributes & EFI_FILE_READ_ONLY) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+  //\r
+  // fall through\r
+  //\r
+  case EFI_FILE_MODE_READ:\r
+  case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:\r
+    break;\r
+\r
+  default:\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  //\r
+  //\r
+  PrivateFile     = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+  PrivateRoot     = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);\r
+  NewPrivateFile  = NULL;\r
+\r
+  //\r
+  // BUGBUG: assume an open of root\r
+  // if current location, return current data\r
+  //\r
+  if (StrCmp (FileName, L"\\") == 0
+      || (StrCmp (FileName, L".") == 0 && PrivateFile->IsRootDirectory)) {\r
+    //\r
+    // BUGBUG: assume an open root\r
+    //\r
+OpenRoot:\r
+    Status          = UnixSimpleFileSystemOpenVolume (PrivateFile->SimpleFileSystem, &Root);\r
+    NewPrivateFile  = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root);\r
+    goto Done;\r
+  }\r
+\r
+  if (FileName[StrLen (FileName) - 1] == L'\\') {\r
+    TrailingDash                        = TRUE;\r
+    FileName[StrLen (FileName) - 1]  = 0;\r
+  }\r
+\r
+  //\r
+  // Attempt to open the file\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (UNIX_EFI_FILE_PRIVATE),\r
+                  (VOID **)&NewPrivateFile\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  CopyMem (NewPrivateFile, PrivateFile, sizeof (UNIX_EFI_FILE_PRIVATE));\r
+\r
+  NewPrivateFile->FileName = NULL;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  AsciiStrSize (PrivateFile->FileName) + 1 + StrLen (FileName) + 1,\r
+                  (VOID **)&NewPrivateFile->FileName\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  if (*FileName == L'\\') {\r
+    AsciiStrCpy (NewPrivateFile->FileName, PrivateRoot->FilePath);\r
+    // Skip first '\'.
+    Src = FileName + 1;
+  } else {\r
+    AsciiStrCpy (NewPrivateFile->FileName, PrivateFile->FileName);\r
+    Src = FileName;
+  }\r
+  Dst = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName);
+  GuardPointer = NewPrivateFile->FileName + AsciiStrLen(PrivateRoot->FilePath);
+  *Dst++ = '/';
+  // Convert unicode to ascii and '\' to '/'
+  while (*Src) {
+    if (*Src == '\\')
+      *Dst++ = '/';
+    else
+      *Dst++ = *Src;
+    Src++;
+  }
+  *Dst = 0;
+      
+\r
+  //\r
+  // Get rid of . and .., except leading . or ..\r
+  //\r
+\r
+  //\r
+  // GuardPointer protect simplefilesystem root path not be destroyed\r
+  //\r
+\r
+  LoopFinish    = FALSE;\r
+\r
+  while (!LoopFinish) {\r
+\r
+    LoopFinish = TRUE;\r
+\r
+    for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {\r
+      if (*ParseFileName == '.' &&\r
+          (*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == '/') &&\r
+          *(ParseFileName - 1) == '/'\r
+          ) {\r
+\r
+        //\r
+        // cut /.\r
+        //\r
+        CutPrefix (ParseFileName - 1, 2);\r
+        LoopFinish = FALSE;\r
+        break;\r
+      }\r
+\r
+      if (*ParseFileName == '.' &&\r
+          *(ParseFileName + 1) == '.' &&\r
+          (*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == '/') &&\r
+          *(ParseFileName - 1) == '/'\r
+          ) {\r
+\r
+        ParseFileName--;\r
+        Count = 3;\r
+\r
+        while (ParseFileName != GuardPointer) {\r
+          ParseFileName--;\r
+          Count++;\r
+          if (*ParseFileName == '/') {\r
+            break;\r
+          }\r
+        }\r
+\r
+        //\r
+        // cut /.. and its left directory\r
+        //\r
+        CutPrefix (ParseFileName, Count);\r
+        LoopFinish = FALSE;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (AsciiStrCmp (NewPrivateFile->FileName, PrivateRoot->FilePath) == 0) {\r
+    NewPrivateFile->IsRootDirectory = TRUE;\r
+    gBS->FreePool (NewPrivateFile->FileName);\r
+    gBS->FreePool (NewPrivateFile);\r
+    goto OpenRoot;\r
+  }\r
+\r
+  RealFileName = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName) - 1;\r
+  while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/')
+    RealFileName--;
+\r
+  TempChar            = *(RealFileName - 1);\r
+  *(RealFileName - 1) = 0;\r
+\r
+  *(RealFileName - 1)             = TempChar;\r
+\r
+
+
+  //\r
+  // Test whether file or directory\r
+  //\r
+  NewPrivateFile->IsRootDirectory = FALSE;\r
+  NewPrivateFile->fd = -1;
+  NewPrivateFile->Dir = NULL;
+  if (OpenMode & EFI_FILE_MODE_CREATE) {\r
+    if (Attributes & EFI_FILE_DIRECTORY) {\r
+      NewPrivateFile->IsDirectoryPath = TRUE;\r
+    } else {\r
+      NewPrivateFile->IsDirectoryPath = FALSE;\r
+    }\r
+  } else {\r
+    struct stat finfo;
+    int res = NewPrivateFile->UnixThunk->Stat (NewPrivateFile->FileName, &finfo);
+    if (res == 0 && S_ISDIR(finfo.st_mode))
+      NewPrivateFile->IsDirectoryPath = TRUE;\r
+    else
+      NewPrivateFile->IsDirectoryPath = FALSE;\r
+  }\r
+\r
+  if (OpenMode & EFI_FILE_MODE_WRITE) {\r
+    NewPrivateFile->IsOpenedByRead = FALSE;\r
+  } else {\r
+    NewPrivateFile->IsOpenedByRead = TRUE;\r
+  }\r
+\r
+  Status = EFI_SUCCESS;\r
+\r
+  //\r
+  // deal with directory\r
+  //\r
+  if (NewPrivateFile->IsDirectoryPath) {\r
+\r
+    if ((OpenMode & EFI_FILE_MODE_CREATE)) {\r
+      //\r
+      // Create a directory\r
+      //\r
+      if (NewPrivateFile->UnixThunk->MkDir (NewPrivateFile->FileName, 0777) != 0) {\r
+       INTN LastError;
+\r
+        LastError = PrivateFile->UnixThunk->GetErrno ();\r
+        if (LastError != EEXIST) {
+          gBS->FreePool (TempFileName);\r
+          Status = EFI_ACCESS_DENIED;\r
+          goto Done;\r
+        }\r
+      }\r
+    }\r
+\r
+    NewPrivateFile->Dir = NewPrivateFile->UnixThunk->OpenDir
+      (NewPrivateFile->FileName);
+\r
+    if (NewPrivateFile->Dir == NULL) {
+      if (PrivateFile->UnixThunk->GetErrno () == EACCES) {
+        Status                    = EFI_ACCESS_DENIED;\r
+      } else {\r
+        Status = EFI_NOT_FOUND;\r
+      }\r
+\r
+      goto Done;\r
+    }\r
+\r
+  } else {\r
+    //\r
+    // deal with file\r
+    //\r
+    NewPrivateFile->fd = NewPrivateFile->UnixThunk->Open
+      (NewPrivateFile->FileName,\r
+       ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0)
+       | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR),
+       0666);
+    if (NewPrivateFile->fd < 0) {
+      if (PrivateFile->UnixThunk->GetErrno () == ENOENT) {
+       Status = EFI_NOT_FOUND;\r
+      } else {\r
+       Status = EFI_ACCESS_DENIED;\r
+      }\r
+    }\r
+  }\r
+\r
+  if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) {\r
+    //\r
+    // Set the attribute\r
+    //\r
+    InfoSize  = 0;\r
+    Info      = NULL;\r
+\r
+    Status    = UnixSimpleFileSystemGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);\r
+\r
+    if (Status != EFI_BUFFER_TOO_SMALL) {\r
+      Status = EFI_DEVICE_ERROR;\r
+      goto Done;\r
+    }\r
+\r
+    Status = gBS->AllocatePool (\r
+                    EfiBootServicesData,\r
+                    InfoSize,\r
+                    (VOID **)&Info\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto Done;\r
+    }\r
+\r
+    Status = UnixSimpleFileSystemGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto Done;\r
+    }\r
+\r
+    Info->Attribute = Attributes;\r
+\r
+    UnixSimpleFileSystemSetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, InfoSize, Info);\r
+  }\r
+\r
+Done: ;\r
+  if (TrailingDash) {\r
+    FileName[StrLen (FileName) + 1]  = 0;\r
+    FileName[StrLen (FileName)]      = L'\\';\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    if (NewPrivateFile) {\r
+      if (NewPrivateFile->FileName) {\r
+        gBS->FreePool (NewPrivateFile->FileName);\r
+      }\r
+\r
+      gBS->FreePool (NewPrivateFile);\r
+    }\r
+  } else {\r
+    *NewHandle = &NewPrivateFile->EfiFile;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemClose (\r
+  IN EFI_FILE  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Close the specified file handle.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to a returned opened file handle.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - The file handle has been closed.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  UNIX_EFI_FILE_PRIVATE *PrivateFile;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (PrivateFile->fd >= 0) {
+    PrivateFile->UnixThunk->Close (PrivateFile->fd);\r
+  }
+  if (PrivateFile->Dir != NULL) {
+    PrivateFile->UnixThunk->CloseDir (PrivateFile->Dir);\r
+  }
+\r
+  PrivateFile->fd = -1;
+  PrivateFile->Dir = NULL;
+\r
+  if (PrivateFile->FileName) {\r
+    gBS->FreePool (PrivateFile->FileName);\r
+  }\r
+\r
+  gBS->FreePool (PrivateFile);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDelete (\r
+  IN EFI_FILE  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Close and delete a file.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to a returned opened file handle.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The file handle was closed and deleted.\r
+\r
+  EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  UNIX_EFI_FILE_PRIVATE *PrivateFile;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status      = EFI_WARN_DELETE_FAILURE;\r
+\r
+  if (PrivateFile->IsDirectoryPath) {\r
+    if (PrivateFile->Dir != NULL) {\r
+      PrivateFile->UnixThunk->CloseDir (PrivateFile->Dir);\r
+      PrivateFile->Dir = NULL;
+    }\r
+\r
+    if (PrivateFile->UnixThunk->RmDir (PrivateFile->FileName) == 0) {\r
+      Status = EFI_SUCCESS;\r
+    }\r
+  } else {\r
+    PrivateFile->UnixThunk->Close (PrivateFile->fd);\r
+    PrivateFile->fd = -1;
+\r
+    if (!PrivateFile->IsOpenedByRead) {\r
+      if (!PrivateFile->UnixThunk->UnLink (PrivateFile->FileName)) {\r
+        Status = EFI_SUCCESS;\r
+      }\r
+    }\r
+  }\r
+\r
+  gBS->FreePool (PrivateFile->FileName);\r
+  gBS->FreePool (PrivateFile);\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+VOID\r
+UnixSystemTimeToEfiTime (\r
+  EFI_UNIX_THUNK_PROTOCOL        *UnixThunk,\r
+  IN time_t                 SystemTime,
+  OUT EFI_TIME              *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SystemTime  - TODO: add argument description\r
+  TimeZone    - TODO: add argument description\r
+  Time        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  struct tm *tm;
+  tm = UnixThunk->GmTime (&SystemTime);
+  Time->Year   = tm->tm_year;
+  Time->Month  = tm->tm_mon;
+  Time->Day    = tm->tm_mday;
+  Time->Hour   = tm->tm_hour;
+  Time->Minute = tm->tm_min;
+  Time->Second = tm->tm_sec;
+  Time->Nanosecond  = 0;
+
+  Time->TimeZone    = UnixThunk->GetTimeZone ();
+\r
+  if (UnixThunk->GetDayLight ()) {
+    Time->Daylight = EFI_TIME_ADJUST_DAYLIGHT;\r
+  }\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+UnixSimpleFileSystemFileInfo (\r
+  UNIX_EFI_FILE_PRIVATE          *PrivateFile,\r
+  IN     CHAR8                    *FileName,
+  IN OUT UINTN                    *BufferSize,\r
+  OUT    VOID                     *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  PrivateFile - TODO: add argument description\r
+  BufferSize  - TODO: add argument description\r
+  Buffer      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  UINTN                       Size;\r
+  UINTN                       NameSize;\r
+  UINTN                       ResultSize;\r
+  EFI_FILE_INFO               *Info;\r
+  CHAR8                      *RealFileName;\r
+  CHAR8                      *TempPointer;\r
+  CHAR16                      *BufferFileName;
+  struct stat                 buf;
+\r
+  if (FileName != NULL) {
+    RealFileName = FileName;
+  }
+  else if (PrivateFile->IsRootDirectory) {\r
+    RealFileName = "";
+  } else {\r
+    RealFileName  = PrivateFile->FileName;\r
+  }
+
+  TempPointer   = RealFileName;\r
+  while (*TempPointer) {\r
+    if (*TempPointer == '/') {\r
+      RealFileName = TempPointer + 1;\r
+    }\r
+\r
+    TempPointer++;\r
+  }\r
+
+  Size        = SIZE_OF_EFI_FILE_INFO;\r
+  NameSize    = AsciiStrSize (RealFileName) * 2;\r
+  ResultSize  = Size + NameSize;\r
+\r
+  if (*BufferSize < ResultSize) {\r
+    *BufferSize = ResultSize;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }
+  if (PrivateFile->UnixThunk->Stat (
+          FileName == NULL ? PrivateFile->FileName : FileName,
+         &buf) < 0)
+    return EFI_DEVICE_ERROR;
+
+  Status  = EFI_SUCCESS;\r
+\r
+  Info    = Buffer;\r
+  ZeroMem (Info, ResultSize);\r
+\r
+  Info->Size = ResultSize;\r
+  Info->FileSize      = buf.st_size;
+  Info->PhysicalSize  = MultU64x32 (buf.st_blocks, buf.st_blksize);
+\r
+  UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_ctime, &Info->CreateTime);
+  UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_atime, &Info->LastAccessTime);
+  UnixSystemTimeToEfiTime (PrivateFile->UnixThunk, buf.st_mtime, &Info->ModificationTime);
+
+  if (!(buf.st_mode & S_IWUSR)) {
+    Info->Attribute |= EFI_FILE_READ_ONLY;\r
+  }\r
+\r
+  if (S_ISDIR(buf.st_mode)) {
+    Info->Attribute |= EFI_FILE_DIRECTORY;\r
+  }\r
+\r
+\r
+  BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size);
+  while (*RealFileName)
+    *BufferFileName++ = *RealFileName++;
+  *BufferFileName = 0;
+
+  *BufferSize = ResultSize;\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemRead (\r
+  IN     EFI_FILE  *This,\r
+  IN OUT UINTN     *BufferSize,\r
+  OUT    VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read data from a file.\r
+\r
+Arguments:\r
+\r
+  This        - Pointer to a returned open file handle.\r
+\r
+  BufferSize  - On input, the size of the Buffer.  On output, the number of bytes stored in the Buffer.\r
+\r
+  Buffer      - Pointer to the first byte of the read Buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data was read.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupted.\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The supplied buffer size was too small to store the current directory entry.\r
+                          *BufferSize has been updated with the size needed to complete the request.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  UNIX_EFI_FILE_PRIVATE *PrivateFile;\r
+  EFI_STATUS              Status;\r
+  INTN                    Res;
+  UINTN                   Size;\r
+  UINTN                   NameSize;\r
+  UINTN                   ResultSize;\r
+  CHAR8                   *FullFileName;
+\r
+  if (This == NULL || BufferSize == NULL || Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (!PrivateFile->IsDirectoryPath) {\r
+\r
+    if (PrivateFile->fd < 0) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    Res = PrivateFile->UnixThunk->Read (\r
+                                        PrivateFile->fd,\r
+                                        Buffer,\r
+                                        *BufferSize);
+    if (Res < 0)
+      return EFI_DEVICE_ERROR;
+    *BufferSize = Res;
+    return EFI_SUCCESS;
+  }\r
+\r
+  //\r
+  // Read on a directory.
+  //\r
+  if (PrivateFile->Dir == NULL) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+
+  if (PrivateFile->Dirent == NULL) {
+    PrivateFile->Dirent = PrivateFile->UnixThunk->ReadDir (PrivateFile->Dir);
+    if (PrivateFile->Dirent == NULL) {
+      *BufferSize = 0;\r
+      return EFI_SUCCESS;\r
+    }
+  }
+
+  Size        = SIZE_OF_EFI_FILE_INFO;\r
+  NameSize    = AsciiStrLen (PrivateFile->Dirent->d_name) + 1;
+  ResultSize  = Size + 2 * NameSize;\r
+\r
+  if (*BufferSize < ResultSize) {\r
+    *BufferSize = ResultSize;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }
+  Status  = EFI_SUCCESS;\r
+\r
+  *BufferSize = ResultSize;\r
+
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  AsciiStrLen(PrivateFile->FileName) + 1 + NameSize,
+                  (VOID **)&FullFileName
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;
+  }\r
+                 
+  AsciiStrCpy(FullFileName, PrivateFile->FileName);
+  AsciiStrCat(FullFileName, "/");
+  AsciiStrCat(FullFileName, PrivateFile->Dirent->d_name);
+  Status = UnixSimpleFileSystemFileInfo (PrivateFile,
+                                         FullFileName,
+                                         BufferSize,
+                                         Buffer);
+  gBS->FreePool (FullFileName);
+\r
+  PrivateFile->Dirent = NULL;
+\r
+  return Status;
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemWrite (\r
+  IN     EFI_FILE  *This,\r
+  IN OUT UINTN     *BufferSize,\r
+  IN     VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Write data to a file.\r
+\r
+Arguments:\r
+\r
+  This        - Pointer to an opened file handle.\r
+\r
+  BufferSize  - On input, the number of bytes in the Buffer to write to the file.  On output, the number of bytes\r
+                of data written to the file.\r
+\r
+  Buffer      - Pointer to the first by of data in the buffer to write to the file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data was written to the file.\r
+\r
+  EFI_UNSUPPORTED       - Writes to an open directory are not supported.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupt.\r
+\r
+  EFI_WRITE_PROTECTED   - The file, directory, volume, or device is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The file was opened read-only.\r
+\r
+  EFI_VOLUME_FULL       - The volume is full.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  UNIX_EFI_FILE_PRIVATE *PrivateFile;\r
+  UINTN Res;
+\r
+  if (This == NULL || BufferSize == NULL || Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (PrivateFile->fd < 0) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (PrivateFile->IsDirectoryPath) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (PrivateFile->IsOpenedByRead) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  Res = PrivateFile->UnixThunk->Write (\r
+                                       PrivateFile->fd,\r
+                                       Buffer,\r
+                                       *BufferSize);
+  if (Res == (UINTN)-1)
+    return EFI_DEVICE_ERROR;
+  *BufferSize = Res;
+  return EFI_SUCCESS;
+\r
+  //\r
+  // bugbug: need to access windows error reporting\r
+  //\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemSetPosition (\r
+  IN EFI_FILE  *This,\r
+  IN UINT64    Position\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set a file's current position.\r
+\r
+Arguments:\r
+\r
+  This      - Pointer to an opened file handle.\r
+\r
+  Position  - The byte position from the start of the file to set.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - The file position has been changed.\r
+\r
+  EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  UNIX_EFI_FILE_PRIVATE *PrivateFile;\r
+  UINT64                  Pos;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (PrivateFile->IsDirectoryPath) {\r
+    if (Position != 0) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+\r
+    if (PrivateFile->Dir == NULL) {
+      return EFI_DEVICE_ERROR;
+    }
+    PrivateFile->UnixThunk->RewindDir (PrivateFile->Dir);
+    return EFI_SUCCESS;\r
+  } else {\r
+    if (Position == (UINT64) -1) {\r
+      Pos = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, 0, SEEK_END);\r
+    } else {\r
+      Pos = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, Position, SEEK_SET);\r
+    }
+    Status = (Pos == (UINT64) -1) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
+\r
+    return Status;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemGetPosition (\r
+  IN  EFI_FILE  *This,\r
+  OUT UINT64    *Position\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get a file's current position.\r
+\r
+Arguments:\r
+\r
+  This      - Pointer to an opened file handle.\r
+\r
+  Position  - Pointer to storage for the current position.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - The file position has been reported.\r
+\r
+  EFI_UNSUPPORTED - Not valid for directories.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  UNIX_EFI_FILE_PRIVATE *PrivateFile;\r
+\r
+  if (This == NULL || Position == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile   = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (PrivateFile->IsDirectoryPath) {\r
+    return EFI_UNSUPPORTED;\r
+  } else {\r
+    *Position = PrivateFile->UnixThunk->Lseek (PrivateFile->fd, 0, SEEK_CUR);
+    return (*Position == (UINT64) -1) ? EFI_DEVICE_ERROR : EFI_SUCCESS;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemGetInfo (\r
+  IN     EFI_FILE  *This,\r
+  IN     EFI_GUID  *InformationType,\r
+  IN OUT UINTN     *BufferSize,\r
+  OUT    VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return information about a file or volume.\r
+\r
+Arguments:\r
+\r
+  This            - Pointer to an opened file handle.\r
+\r
+  InformationType - GUID describing the type of information to be returned.\r
+\r
+  BufferSize      - On input, the size of the information buffer.  On output, the number of bytes written to the\r
+                    information buffer.\r
+\r
+  Buffer          - Pointer to the first byte of the information buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The requested information has been written into the buffer.\r
+\r
+  EFI_UNSUPPORTED       - The InformationType is not known.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupt.\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The buffer size was too small to contain the requested information.  The buffer size has\r
+                          been updated with the size needed to complete the requested operation.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  EFI_STATUS                        Status;\r
+  UNIX_EFI_FILE_PRIVATE           *PrivateFile;\r
+  EFI_FILE_SYSTEM_INFO              *FileSystemInfoBuffer;\r
+  INTN                              UnixStatus;\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;\r
+  struct statfs                     buf;
+\r
+  if (This == NULL || InformationType == NULL || BufferSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+  PrivateRoot = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);\r
+\r
+  Status      = EFI_UNSUPPORTED;\r
+\r
+  if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {\r
+    Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, BufferSize, Buffer);\r
+  }\r
+  else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {\r
+    if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {\r
+      *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);\r
+      return EFI_BUFFER_TOO_SMALL;\r
+    }\r
+\r
+    UnixStatus = PrivateFile->UnixThunk->StatFs (PrivateFile->FileName, &buf);
+    if (UnixStatus < 0)
+        return EFI_DEVICE_ERROR;\r
+
+    FileSystemInfoBuffer            = (EFI_FILE_SYSTEM_INFO *) Buffer;\r
+    FileSystemInfoBuffer->Size      = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);\r
+    FileSystemInfoBuffer->ReadOnly  = FALSE;\r
+\r
+    //\r
+    // Succeeded\r
+    //\r
+    FileSystemInfoBuffer->VolumeSize  = MultU64x32 (buf.f_blocks, buf.f_bsize);
+    FileSystemInfoBuffer->FreeSpace   = MultU64x32 (buf.f_bavail, buf.f_bsize);
+    FileSystemInfoBuffer->BlockSize   = buf.f_bsize;
+\r
+\r
+    StrCpy ((CHAR16 *) FileSystemInfoBuffer->VolumeLabel, PrivateRoot->VolumeLabel);\r
+    *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);\r
+    Status      = EFI_SUCCESS;\r
+  }\r
+\r
+  else if (CompareGuid (InformationType,
+                       &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
+    if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {\r
+      *BufferSize = StrSize (PrivateRoot->VolumeLabel);\r
+      return EFI_BUFFER_TOO_SMALL;\r
+    }\r
+\r
+    StrCpy ((CHAR16 *) Buffer, PrivateRoot->VolumeLabel);\r
+    *BufferSize = StrSize (PrivateRoot->VolumeLabel);\r
+    Status      = EFI_SUCCESS;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemSetInfo (\r
+  IN EFI_FILE         *This,\r
+  IN EFI_GUID         *InformationType,\r
+  IN UINTN            BufferSize,\r
+  IN VOID             *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set information about a file or volume.\r
+\r
+Arguments:\r
+\r
+  This            - Pointer to an opened file handle.\r
+\r
+  InformationType - GUID identifying the type of information to set.\r
+\r
+  BufferSize      - Number of bytes of data in the information buffer.\r
+\r
+  Buffer          - Pointer to the first byte of data in the information buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The file or volume information has been updated.\r
+\r
+  EFI_UNSUPPORTED       - The information identifier is not recognised.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupt.\r
+\r
+  EFI_WRITE_PROTECTED   - The file, directory, volume, or device is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The file was opened read-only.\r
+\r
+  EFI_VOLUME_FULL       - The volume is full.\r
+\r
+  EFI_BAD_BUFFER_SIZE   - The buffer size is smaller than the type indicated by InformationType.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  UNIX_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;\r
+  UNIX_EFI_FILE_PRIVATE           *PrivateFile;\r
+  EFI_FILE_INFO                     *OldFileInfo;\r
+  EFI_FILE_INFO                     *NewFileInfo;\r
+  EFI_STATUS                        Status;\r
+  UINTN                             OldInfoSize;\r
+  mode_t                            NewAttr;\r
+  struct stat                       OldAttr;\r
+  CHAR8                             *OldFileName;\r
+  CHAR8                             *NewFileName;\r
+  CHAR8                             *CharPointer;\r
+  BOOLEAN                           AttrChangeFlag;\r
+  BOOLEAN                           NameChangeFlag;\r
+  BOOLEAN                           SizeChangeFlag;\r
+  BOOLEAN                           TimeChangeFlag;\r
+  struct tm                         NewLastAccessSystemTime;\r
+  struct tm                         NewLastWriteSystemTime;\r
+  EFI_FILE_SYSTEM_INFO              *NewFileSystemInfo;\r
+  CHAR8                             *AsciiFilePtr;
+  CHAR16                            *UnicodeFilePtr;
+  INTN                              UnixStatus;
+\r
+  //\r
+  // Check for invalid parameters.\r
+  //\r
+  if (This == NULL || InformationType == NULL || BufferSize == 0 || Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Initialise locals.\r
+  //\r
+  PrivateFile               = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+  PrivateRoot               = UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);\r
+\r
+  Status                    = EFI_UNSUPPORTED;\r
+  OldFileInfo               = NewFileInfo = NULL;\r
+  OldFileName               = NewFileName = NULL;\r
+  AttrChangeFlag = NameChangeFlag = SizeChangeFlag = TimeChangeFlag = FALSE;\r
+\r
+  //\r
+  // Set file system information.\r
+  //\r
+  if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {\r
+    if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {\r
+      return EFI_BAD_BUFFER_SIZE;\r
+    }\r
+\r
+    NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;\r
+\r
+    gBS->FreePool (PrivateRoot->VolumeLabel);\r
+\r
+    PrivateRoot->VolumeLabel = NULL;\r
+    Status = gBS->AllocatePool (\r
+                    EfiBootServicesData,\r
+                    StrSize (NewFileSystemInfo->VolumeLabel),\r
+                    (VOID **)&PrivateRoot->VolumeLabel\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto Done;\r
+    }\r
+\r
+    StrCpy (PrivateRoot->VolumeLabel, NewFileSystemInfo->VolumeLabel);\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Set volume label information.\r
+  //\r
+  if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
+    if (BufferSize < StrSize (PrivateRoot->VolumeLabel)) {\r
+      return EFI_BAD_BUFFER_SIZE;\r
+    }\r
+\r
+    StrCpy (PrivateRoot->VolumeLabel, (CHAR16 *) Buffer);\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (!CompareGuid (InformationType, &gEfiFileInfoGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (BufferSize < SIZE_OF_EFI_FILE_INFO) {\r
+    return EFI_BAD_BUFFER_SIZE;\r
+  }\r
+\r
+  //\r
+  // Set file/directory information.\r
+  //\r
+\r
+  //\r
+  // Check for invalid set file information parameters.\r
+  //\r
+  NewFileInfo = (EFI_FILE_INFO *) Buffer;\r
+\r
+  if (NewFileInfo->Size <= sizeof (EFI_FILE_INFO) ||\r
+      (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||\r
+      (sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // bugbug: - This is not safe.  We need something like EfiStrMaxSize()\r
+  // that would have an additional parameter that would be the size\r
+  // of the string array just in case there are no NULL characters in\r
+  // the string array.\r
+  //\r
+  //\r
+  // Get current file information so we can determine what kind\r
+  // of change request this is.\r
+  //\r
+  OldInfoSize = 0;\r
+  Status      = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, NULL);\r
+\r
+  if (Status != EFI_BUFFER_TOO_SMALL) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Done;\r
+  }\r
+\r
+  Status = gBS->AllocatePool (EfiBootServicesData, OldInfoSize,
+                             (VOID **)&OldFileInfo);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, OldFileInfo);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  AsciiStrSize (PrivateFile->FileName),\r
+                  (VOID **)&OldFileName\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  AsciiStrCpy (OldFileName, PrivateFile->FileName);\r
+\r
+  //\r
+  // Make full pathname from new filename and rootpath.\r
+  //\r
+  if (NewFileInfo->FileName[0] == '\\') {\r
+    Status = gBS->AllocatePool (\r
+                    EfiBootServicesData,\r
+                    AsciiStrLen (PrivateRoot->FilePath) + 1 + StrLen (NewFileInfo->FileName) + 1,\r
+                    (VOID **)&NewFileName\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto Done;\r
+    }\r
+\r
+    AsciiStrCpy (NewFileName, PrivateRoot->FilePath);\r
+    AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+    UnicodeFilePtr = NewFileInfo->FileName + 1;
+    *AsciiFilePtr++ ='/';
+  } else {\r
+    Status = gBS->AllocatePool (\r
+                    EfiBootServicesData,\r
+                    AsciiStrLen (PrivateFile->FileName) + 1 + StrLen (NewFileInfo->FileName) + 1,\r
+                    (VOID **)&NewFileName\r
+                    );\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      goto Done;\r
+    }\r
+\r
+    AsciiStrCpy (NewFileName, PrivateRoot->FilePath);\r
+    AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+    while (AsciiFilePtr > NewFileName && AsciiFilePtr[-1] != '/') {
+      AsciiFilePtr--;
+    }
+    UnicodeFilePtr = NewFileInfo->FileName;
+  }\r
+  // Convert to ascii.
+  while (*UnicodeFilePtr) {
+    *AsciiFilePtr++ = *UnicodeFilePtr++;
+  }
+  *AsciiFilePtr = 0;
+
+\r
+  //\r
+  // Is there an attribute change request?\r
+  //\r
+  if (NewFileInfo->Attribute != OldFileInfo->Attribute) {\r
+    if ((NewFileInfo->Attribute & EFI_FILE_DIRECTORY) != (OldFileInfo->Attribute & EFI_FILE_DIRECTORY)) {\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto Done;\r
+    }\r
+\r
+    AttrChangeFlag = TRUE;\r
+  }\r
+\r
+  //\r
+  // Is there a name change request?\r
+  // bugbug: - Need EfiStrCaseCmp()\r
+  //\r
+  if (StrCmp (NewFileInfo->FileName, OldFileInfo->FileName)) {\r
+    NameChangeFlag = TRUE;\r
+  }\r
+\r
+  //\r
+  // Is there a size change request?\r
+  //\r
+  if (NewFileInfo->FileSize != OldFileInfo->FileSize) {\r
+    SizeChangeFlag = TRUE;\r
+  }\r
+\r
+  //\r
+  // Is there a time stamp change request?\r
+  //\r
+  if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) &&\r
+      CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME))\r
+        ) {\r
+    TimeChangeFlag = TRUE;\r
+  } else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) &&\r
+           CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME))\r
+            ) {\r
+    TimeChangeFlag = TRUE;\r
+  } else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) &&\r
+           CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME))\r
+            ) {\r
+    TimeChangeFlag = TRUE;\r
+  }\r
+\r
+  //\r
+  // All done if there are no change requests being made.\r
+  //\r
+  if (!(AttrChangeFlag || NameChangeFlag || SizeChangeFlag || TimeChangeFlag)) {\r
+    Status = EFI_SUCCESS;\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Set file or directory information.\r
+  //\r
+  if (PrivateFile->UnixThunk->Stat (OldFileName, &OldAttr) != 0) {
+    Status = EFI_DEVICE_ERROR;
+    goto Done;
+  }
+\r
+  //\r
+  // Name change.\r
+  //\r
+  if (NameChangeFlag) {\r
+    //\r
+    // Close the handles first\r
+    //\r
+    if (PrivateFile->IsOpenedByRead) {\r
+      Status = EFI_ACCESS_DENIED;\r
+      goto Done;\r
+    }\r
+\r
+    for (CharPointer = NewFileName; *CharPointer != 0 && *CharPointer != L'/'; CharPointer++) {\r
+    }\r
+\r
+    if (*CharPointer != 0) {\r
+      Status = EFI_ACCESS_DENIED;\r
+      goto Done;\r
+    }\r
+\r
+    UnixStatus = PrivateFile->UnixThunk->Rename (OldFileName, NewFileName);\r
+\r
+    if (UnixStatus == 0) {\r
+      //\r
+      // modify file name\r
+      //\r
+      gBS->FreePool (PrivateFile->FileName);\r
+\r
+      Status = gBS->AllocatePool (\r
+                      EfiBootServicesData,\r
+                      AsciiStrSize (NewFileName),\r
+                      (VOID **)&PrivateFile->FileName\r
+                      );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        goto Done;\r
+      }\r
+\r
+      AsciiStrCpy (PrivateFile->FileName, NewFileName);\r
+    } else {\r
+      Status    = EFI_DEVICE_ERROR;\r
+      goto Done;\r
+    }\r
+  }\r
+\r
+  //\r
+  //  Size change\r
+  //\r
+  if (SizeChangeFlag) {\r
+    if (PrivateFile->IsDirectoryPath) {\r
+      Status = EFI_UNSUPPORTED;\r
+      goto Done;\r
+    }\r
+\r
+    if (PrivateFile->IsOpenedByRead || OldFileInfo->Attribute & EFI_FILE_READ_ONLY) {\r
+      Status = EFI_ACCESS_DENIED;\r
+      goto Done;\r
+    }\r
+\r
+    if (PrivateFile->UnixThunk->FTruncate (PrivateFile->fd, NewFileInfo->FileSize) != 0) {\r
+      Status = EFI_DEVICE_ERROR;\r
+      goto Done;\r
+    }\r
+\r
+  }\r
+\r
+  //\r
+  // Time change\r
+  //\r
+  if (TimeChangeFlag) {\r
+    struct utimbuf utime;
+\r
+    NewLastAccessSystemTime.tm_year    = NewFileInfo->LastAccessTime.Year;\r
+    NewLastAccessSystemTime.tm_mon     = NewFileInfo->LastAccessTime.Month;\r
+    NewLastAccessSystemTime.tm_mday    = NewFileInfo->LastAccessTime.Day;\r
+    NewLastAccessSystemTime.tm_hour    = NewFileInfo->LastAccessTime.Hour;\r
+    NewLastAccessSystemTime.tm_min     = NewFileInfo->LastAccessTime.Minute;\r
+    NewLastAccessSystemTime.tm_sec     = NewFileInfo->LastAccessTime.Second;\r
+    NewLastAccessSystemTime.tm_isdst   = 0;
+\r
+    utime.actime = PrivateFile->UnixThunk->MkTime (&NewLastAccessSystemTime);
+
+    NewLastWriteSystemTime.tm_year    = NewFileInfo->ModificationTime.Year;\r
+    NewLastWriteSystemTime.tm_mon     = NewFileInfo->ModificationTime.Month;\r
+    NewLastWriteSystemTime.tm_mday    = NewFileInfo->ModificationTime.Day;\r
+    NewLastWriteSystemTime.tm_hour    = NewFileInfo->ModificationTime.Hour;\r
+    NewLastWriteSystemTime.tm_min     = NewFileInfo->ModificationTime.Minute;\r
+    NewLastWriteSystemTime.tm_sec     = NewFileInfo->ModificationTime.Second;\r
+    NewLastWriteSystemTime.tm_isdst   = 0;
+\r
+    utime.modtime = PrivateFile->UnixThunk->MkTime (&NewLastWriteSystemTime);
+
+    if (utime.actime == (time_t)-1 || utime.modtime == (time_t)-1) {
+      goto Done;\r
+    }\r
+\r
+    if (PrivateFile->UnixThunk->UTime (PrivateFile->FileName, &utime) == -1) {
+      goto Done;\r
+    }\r
+  }\r
+\r
+  //\r
+  // No matter about AttrChangeFlag, Attribute must be set.\r
+  // Because operation before may cause attribute change.\r
+  //\r
+  NewAttr = OldAttr.st_mode;\r
+\r
+  if (NewFileInfo->Attribute & EFI_FILE_READ_ONLY) {\r
+    NewAttr &= ~(S_IRUSR | S_IRGRP | S_IROTH);
+  } else {\r
+    NewAttr |= S_IRUSR;
+  }\r
+\r
+  UnixStatus = PrivateFile->UnixThunk->Chmod (NewFileName, NewAttr);\r
+\r
+  if (UnixStatus != 0) {\r
+    Status    = EFI_DEVICE_ERROR;\r
+  }\r
+\r
+Done:\r
+  if (OldFileInfo != NULL) {\r
+    gBS->FreePool (OldFileInfo);\r
+  }\r
+\r
+  if (OldFileName != NULL) {\r
+    gBS->FreePool (OldFileName);\r
+  }\r
+\r
+  if (NewFileName != NULL) {\r
+    gBS->FreePool (NewFileName);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemFlush (\r
+  IN EFI_FILE  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush all modified data to the media.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to an opened file handle.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data has been flushed.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures have been corrupted.\r
+\r
+  EFI_WRITE_PROTECTED   - The file, directory, volume, or device is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The file was opened read-only.\r
+\r
+  EFI_VOLUME_FULL       - The volume is full.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  UNIX_EFI_FILE_PRIVATE     *PrivateFile;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+\r
+  if (PrivateFile->IsDirectoryPath) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (PrivateFile->IsOpenedByRead) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+\r
+  if (PrivateFile->fd < 0) {
+    return EFI_DEVICE_ERROR;\r
+  }\r
+
+  return PrivateFile->UnixThunk->FSync (PrivateFile->fd) == 0 ? EFI_SUCCESS : EFI_DEVICE_ERROR;\r
+\r
+  //\r
+  // bugbug: - Use Windows error reporting.\r
+  //\r
+}\r
+\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.h b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.h
new file mode 100644 (file)
index 0000000..aa1f135
--- /dev/null
@@ -0,0 +1,582 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixSimpleFileSystem.h\r
+\r
+Abstract:\r
+\r
+  Produce Simple File System abstractions for a directory on your PC using Unix APIs.\r
+  The configuration of what devices to mount or emulate comes from  \r
+  environment variables.\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_SIMPLE_FILE_SYSTEM_H_\r
+#define _UNIX_SIMPLE_FILE_SYSTEM_H_\r
+\r
+\r
+\r
+#define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('L', 'X', 'f', 's')\r
+\r
+typedef struct {\r
+  UINTN                           Signature;\r
+  EFI_UNIX_THUNK_PROTOCOL        *UnixThunk;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;\r
+  CHAR8                           *FilePath;\r
+  CHAR16                          *VolumeLabel;\r
+  EFI_UNICODE_STRING_TABLE        *ControllerNameTable;\r
+} UNIX_SIMPLE_FILE_SYSTEM_PRIVATE;\r
+\r
+#define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      UNIX_SIMPLE_FILE_SYSTEM_PRIVATE, \\r
+      SimpleFileSystem, \\r
+      UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \\r
+      )\r
+\r
+#define UNIX_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')\r
+\r
+typedef struct {\r
+  UINTN                           Signature;\r
+  EFI_UNIX_THUNK_PROTOCOL        *UnixThunk;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
+  EFI_FILE                        EfiFile;\r
+  INTN                            fd;
+  DIR                             *Dir;
+  BOOLEAN                         IsRootDirectory;\r
+  BOOLEAN                         IsDirectoryPath;\r
+  BOOLEAN                         IsOpenedByRead;\r
+  char                            *FileName;\r
+  struct dirent                   *Dirent;
+} UNIX_EFI_FILE_PRIVATE;\r
+\r
+#define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      UNIX_EFI_FILE_PRIVATE, \\r
+      EfiFile, \\r
+      UNIX_EFI_FILE_PRIVATE_SIGNATURE \\r
+      )\r
+\r
+//\r
+// Global Protocol Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gUnixSimpleFileSystemDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gUnixSimpleFileSystemComponentName;\r
+\r
+//\r
+// Driver Binding protocol member functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check to see if the driver supports a given controller.\r
+\r
+Arguments:\r
+\r
+  This                - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+  ControllerHandle    - EFI handle of the controller to test.\r
+\r
+  RemainingDevicePath - Pointer to remaining portion of a device path.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS         - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver\r
+                        specified by This.\r
+\r
+  EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r
+                        the driver specified by This.\r
+\r
+  EFI_ACCESS_DENIED   - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r
+                        a different driver or an application that requires exclusive access.\r
+\r
+  EFI_UNSUPPORTED     - The device specified by ControllerHandle and RemainingDevicePath is not supported by the\r
+                        driver specified by This.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Starts a device controller or a bus controller.\r
+\r
+Arguments:\r
+\r
+  This                - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+  ControllerHandle    - EFI handle of the controller to start.\r
+\r
+  RemainingDevicePath - Pointer to remaining portion of a device path.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The device or bus controller has been started.\r
+\r
+  EFI_DEVICE_ERROR      - The device could not be started due to a device failure.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The request could not be completed due to lack of resources.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+  ControllerHandle  - A handle to the device to be stopped.\r
+\r
+  NumberOfChildren  - The number of child device handles in ChildHandleBuffer.\r
+\r
+  ChildHandleBuffer - An array of child device handles to be freed.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - The device has been stopped.\r
+\r
+  EFI_DEVICE_ERROR  - The device could not be stopped due to a device failure.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Simple File System protocol member functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemOpenVolume (\r
+  IN  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r
+  OUT EFI_FILE                        **Root\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Open the root directory on a volume.\r
+\r
+Arguments:\r
+\r
+  This  - A pointer to the volume to open.\r
+\r
+  Root  - A pointer to storage for the returned opened file handle of the root directory.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The volume was opened.\r
+\r
+  EFI_UNSUPPORTED       - The volume does not support the requested file system type.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupted.\r
+\r
+  EFI_ACCESS_DENIED     - The service denied access to the file.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The file volume could not be opened due to lack of resources.\r
+\r
+  EFI_MEDIA_CHANGED     - The device has new media or the media is no longer supported.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemOpen (\r
+  IN  EFI_FILE  *This,\r
+  OUT EFI_FILE  **NewHandle,\r
+  IN  CHAR16    *FileName,\r
+  IN  UINT64    OpenMode,\r
+  IN  UINT64    Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Open a file relative to the source file location.\r
+\r
+Arguments:\r
+\r
+  This        - A pointer to the source file location.\r
+\r
+  NewHandle   - Pointer to storage for the new file handle.\r
+\r
+  FileName    - Pointer to the file name to be opened.\r
+\r
+  OpenMode    - File open mode information.\r
+\r
+  Attributes  - File creation attributes.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The file was opened.\r
+\r
+  EFI_NOT_FOUND         - The file could not be found in the volume.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_MEDIA_CHANGED     - The device has new media or the media is no longer supported.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupted.\r
+\r
+  EFI_WRITE_PROTECTED   - The volume or file is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The service denied access to the file.\r
+\r
+  EFI_OUT_OF_RESOURCES  - Not enough resources were available to open the file.\r
+\r
+  EFI_VOLUME_FULL       - There is not enough space left to create the new file.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemClose (\r
+  IN EFI_FILE  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Close the specified file handle.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to a returned opened file handle.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - The file handle has been closed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDelete (\r
+  IN EFI_FILE  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Close and delete a file.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to a returned opened file handle.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             - The file handle was closed and deleted.\r
+\r
+  EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemRead (\r
+  IN     EFI_FILE  *This,\r
+  IN OUT UINTN     *BufferSize,\r
+  OUT    VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read data from a file.\r
+\r
+Arguments:\r
+\r
+  This        - Pointer to a returned open file handle.\r
+\r
+  BufferSize  - On input, the size of the Buffer.  On output, the number of bytes stored in the Buffer.\r
+\r
+  Buffer      - Pointer to the first byte of the read Buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data was read.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupted.\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The supplied buffer size was too small to store the current directory entry.\r
+                          *BufferSize has been updated with the size needed to complete the request.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemWrite (\r
+  IN     EFI_FILE  *This,\r
+  IN OUT UINTN     *BufferSize,\r
+  IN     VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Write data to a file.\r
+\r
+Arguments:\r
+\r
+  This        - Pointer to an opened file handle.\r
+\r
+  BufferSize  - On input, the number of bytes in the Buffer to write to the file.  On output, the number of bytes\r
+                of data written to the file.\r
+\r
+  Buffer      - Pointer to the first by of data in the buffer to write to the file.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data was written to the file.\r
+\r
+  EFI_UNSUPPORTED       - Writes to an open directory are not supported.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupt.\r
+\r
+  EFI_WRITE_PROTECTED   - The file, directory, volume, or device is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The file was opened read-only.\r
+\r
+  EFI_VOLUME_FULL       - The volume is full.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemSetPosition (\r
+  IN EFI_FILE  *This,\r
+  IN UINT64    Position\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set a file's current position.\r
+\r
+Arguments:\r
+\r
+  This      - Pointer to an opened file handle.\r
+\r
+  Position  - The byte position from the start of the file to set.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - The file position has been changed.\r
+\r
+  EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemGetPosition (\r
+  IN  EFI_FILE  *This,\r
+  OUT UINT64    *Position\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get a file's current position.\r
+\r
+Arguments:\r
+\r
+  This      - Pointer to an opened file handle.\r
+\r
+  Position  - Pointer to storage for the current position.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS     - The file position has been reported.\r
+\r
+  EFI_UNSUPPORTED - Not valid for directories.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemGetInfo (\r
+  IN     EFI_FILE  *This,\r
+  IN     EFI_GUID  *InformationType,\r
+  IN OUT UINTN     *BufferSize,\r
+  OUT    VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return information about a file or volume.\r
+\r
+Arguments:\r
+\r
+  This            - Pointer to an opened file handle.\r
+\r
+  InformationType - GUID describing the type of information to be returned.\r
+\r
+  BufferSize      - On input, the size of the information buffer.  On output, the number of bytes written to the\r
+                    information buffer.\r
+\r
+  Buffer          - Pointer to the first byte of the information buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The requested information has been written into the buffer.\r
+\r
+  EFI_UNSUPPORTED       - The InformationType is not known.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupt.\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The buffer size was too small to contain the requested information.  The buffer size has\r
+                          been updated with the size needed to complete the requested operation.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemSetInfo (\r
+  IN EFI_FILE  *This,\r
+  IN EFI_GUID  *InformationType,\r
+  IN UINTN     BufferSize,\r
+  IN VOID      *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set information about a file or volume.\r
+\r
+Arguments:\r
+\r
+  This            - Pointer to an opened file handle.\r
+\r
+  InformationType - GUID identifying the type of information to set.\r
+\r
+  BufferSize      - Number of bytes of data in the information buffer.\r
+\r
+  Buffer          - Pointer to the first byte of data in the information buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The file or volume information has been updated.\r
+\r
+  EFI_UNSUPPORTED       - The information identifier is not recognised.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures are corrupt.\r
+\r
+  EFI_WRITE_PROTECTED   - The file, directory, volume, or device is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The file was opened read-only.\r
+\r
+  EFI_VOLUME_FULL       - The volume is full.\r
+\r
+  EFI_BAD_BUFFER_SIZE   - The buffer size is smaller than the type indicated by InformationType.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemFlush (\r
+  IN EFI_FILE  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Flush all modified data to the media.\r
+\r
+Arguments:\r
+\r
+  This  - Pointer to an opened file handle.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The data has been flushed.\r
+\r
+  EFI_NO_MEDIA          - The device has no media.\r
+\r
+  EFI_DEVICE_ERROR      - The device reported an error.\r
+\r
+  EFI_VOLUME_CORRUPTED  - The file system structures have been corrupted.\r
+\r
+  EFI_WRITE_PROTECTED   - The file, directory, volume, or device is write protected.\r
+\r
+  EFI_ACCESS_DENIED     - The file was opened read-only.\r
+\r
+  EFI_VOLUME_FULL       - The volume is full.\r
+\r
+--*/\r
+;\r
+\r
+#endif /* _UNIX_SIMPLE_FILE_SYSTEM_H_ */\r
+\r
+/* eof - UnixSimpleFileSystem.h */\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.msa b/EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.msa
new file mode 100644 (file)
index 0000000..c57aa71
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixSimpleFileSystem</ModuleName>\r
+    <ModuleType>UEFI_DRIVER</ModuleType>\r
+    <GuidValue>f330834e-8985-11db-a295-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Simple filesystem driver</Abstract>\r
+    <Description>\r
+      Produce Simple File System abstractions for directories on your PC using Unix APIs.\r
+      The configuration of what devices to mount or emulate comes from\r
+      environment variables.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixSimpleFileSystem</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixSimpleFileSystem.h</Filename>\r
+    <Filename>UnixSimpleFileSystem.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiSimpleFileSystemProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixFileSystemGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiFileSystemInfoGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiFileInfoGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiFileSystemVolumeLabelInfoIdGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gUnixSimpleFileSystemDriverBinding</DriverBinding>\r
+      <ComponentName>gUnixSimpleFileSystemComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/ComponentName.c
new file mode 100644 (file)
index 0000000..e6e5ebe
--- /dev/null
@@ -0,0 +1,187 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "UnixUga.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gUnixUgaComponentName = {\r
+  UnixUgaComponentNameGetDriverName,\r
+  UnixUgaComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mUnixUgaDriverNameTable[] = {\r
+  { "eng", L"Unix Universal Graphics Adapter Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixUgaComponentName.SupportedLanguages,\r
+          mUnixUgaDriverNameTable,\r
+          DriverName\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+  UGA_PRIVATE_DATA      *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUgaDrawProtocolGuid,\r
+                  (VOID **)&UgaDraw,\r
+                  gUnixUgaDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw);\r
+\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixUgaComponentName.SupportedLanguages,\r
+          Private->ControllerNameTable,\r
+          ControllerName\r
+          );\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.h b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.h
new file mode 100644 (file)
index 0000000..c34768d
--- /dev/null
@@ -0,0 +1,289 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixUga.h\r
+\r
+Abstract:\r
+\r
+  Private data for the Uga driver that is bound to the Unix Thunk protocol \r
+\r
+--*/\r
+\r
+#ifndef _UNIX_UGA_H_\r
+#define _UNIX_UGA_H_\r
+\r
+#include "Protocol/UnixUgaIo.h"
+
+#define UNIX_UGA_CLASS_NAME       L"UnixUgaWindow"\r
+\r
+#define UGA_PRIVATE_DATA_SIGNATURE  EFI_SIGNATURE_32 ('S', 'g', 'o', 'N')\r
+typedef struct {\r
+  UINT64                      Signature;\r
+\r
+  EFI_HANDLE                  Handle;\r
+  EFI_UGA_DRAW_PROTOCOL       UgaDraw;\r
+  EFI_SIMPLE_TEXT_IN_PROTOCOL SimpleTextIn;\r
+\r
+  EFI_UNIX_THUNK_PROTOCOL   *UnixThunk;\r
+\r
+  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
+\r
+  //\r
+  // UGA Private Data for GetMode ()\r
+  //\r
+  UINT32                      HorizontalResolution;\r
+  UINT32                      VerticalResolution;\r
+  UINT32                      ColorDepth;\r
+  UINT32                      RefreshRate;\r
+\r
+  //\r
+  // UGA Private Data knowing when to start hardware\r
+  //\r
+  BOOLEAN                     HardwareNeedsStarting;\r
+\r
+  CHAR16                      *WindowName;\r
+\r
+  EFI_UNIX_UGA_IO_PROTOCOL    *UgaIo;
+\r
+} UGA_PRIVATE_DATA;\r
+\r
+#define UGA_DRAW_PRIVATE_DATA_FROM_THIS(a)  \\r
+         CR(a, UGA_PRIVATE_DATA, UgaDraw, UGA_PRIVATE_DATA_SIGNATURE)\r
+\r
+#define UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS(a)  \\r
+         CR(a, UGA_PRIVATE_DATA, SimpleTextIn, UGA_PRIVATE_DATA_SIGNATURE)\r
+\r
+//\r
+// Global Protocol Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gUnixUgaDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gUnixUgaComponentName;\r
+\r
+//\r
+// Uga Hardware abstraction internal worker functions\r
+//\r
+EFI_STATUS\r
+UnixUgaSupported (\r
+  IN  EFI_UNIX_IO_PROTOCOL  *UnixIo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  UnixIo - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UnixUgaConstructor (\r
+  IN  UGA_PRIVATE_DATA    *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UnixUgaDestructor (\r
+  IN  UGA_PRIVATE_DATA    *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// EFI 1.1 driver model prototypes for Win NT UGA\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaInitialize (\r
+  IN EFI_HANDLE            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - TODO: add argument description\r
+  SystemTable - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  Handle              - TODO: add argument description\r
+  RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  Handle              - TODO: add argument description\r
+  RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Handle            - TODO: add argument description\r
+  NumberOfChildren  - TODO: add argument description\r
+  ChildHandleBuffer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UgaPrivateAddQ (\r
+  IN  UGA_PRIVATE_DATA    *Private,\r
+  IN  EFI_INPUT_KEY       Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+  Key     - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UnixUgaInitializeSimpleTextInForWindow (\r
+  IN  UGA_PRIVATE_DATA    *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.msa b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.msa
new file mode 100644 (file)
index 0000000..864576f
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixUga</ModuleName>\r
+    <ModuleType>UEFI_DRIVER</ModuleType>\r
+    <GuidValue>f33cad86-8985-11db-8040-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Uga driver</Abstract>\r
+    <Description>\r
+      UGA is short hand for Universal Graphics Abstraction protocol.\r
+      This file is a verision of UgaIo the uses UnixThunk system calls as an IO\r
+      abstraction. For a PCI device UnixIo would be replaced with\r
+      a PCI IO abstraction that abstracted a specific PCI device.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixUga</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixUga.h</Filename>\r
+    <Filename>UnixUgaInput.c</Filename>\r
+    <Filename>UnixUgaDriver.c</Filename>\r
+    <Filename>UnixUgaScreen.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiUnixUgaIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Events>\r
+    <CreateEvents>\r
+      <EventTypes EventGuidCName="gEfiEventExitBootServicesGuid" Usage="SOMETIMES_CONSUMED">\r
+        <EventType>EVENT_GROUP_GUID</EventType>\r
+      </EventTypes>\r
+    </CreateEvents>\r
+  </Events>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixUgaGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gUnixUgaDriverBinding</DriverBinding>\r
+      <ComponentName>gUnixUgaComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaDriver.c
new file mode 100644 (file)
index 0000000..5e08fe8
--- /dev/null
@@ -0,0 +1,296 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixUgaDriver.c\r
+\r
+Abstract:\r
+\r
+  This file implements the EFI 1.1 Device Driver model requirements for UGA\r
+\r
+  UGA is short hand for Universal Graphics Abstraction protocol.\r
+\r
+  This file is a verision of UgaIo the uses UnixThunk system calls as an IO \r
+  abstraction. For a PCI device UnixIo would be replaced with\r
+  a PCI IO abstraction that abstracted a specific PCI device. \r
+\r
+--*/\r
+\r
+#include "UnixUga.h"\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding = {\r
+  UnixUgaDriverBindingSupported,\r
+  UnixUgaDriverBindingStart,\r
+  UnixUgaDriverBindingStop,\r
+  0x10,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_UNIX_IO_PROTOCOL  *UnixIo;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (VOID **)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = UnixUgaSupported (UnixIo);\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEfiUnixIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+{\r
+  EFI_UNIX_IO_PROTOCOL  *UnixIo;\r
+  EFI_STATUS              Status;\r
+  UGA_PRIVATE_DATA        *Private;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  (VOID **)&UnixIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Allocate Private context data for SGO inteface.\r
+  //\r
+  Private = NULL;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (UGA_PRIVATE_DATA),\r
+                  (VOID **)&Private\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Set up context record\r
+  //\r
+  Private->Signature            = UGA_PRIVATE_DATA_SIGNATURE;\r
+  Private->Handle               = Handle;\r
+  Private->UnixThunk           = UnixIo->UnixThunk;\r
+\r
+  Private->ControllerNameTable  = NULL;\r
+\r
+  AddUnicodeString (\r
+    "eng",\r
+    gUnixUgaComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    UnixIo->EnvString\r
+    );\r
+\r
+  Private->WindowName = UnixIo->EnvString;\r
+\r
+  Status              = UnixUgaConstructor (Private);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Publish the Uga interface to the world\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Private->Handle,\r
+                  &gEfiUgaDrawProtocolGuid,\r
+                  &Private->UgaDraw,\r
+                  &gEfiSimpleTextInProtocolGuid,\r
+                  &Private->SimpleTextIn,\r
+                  NULL\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+\r
+    gBS->CloseProtocol (\r
+          Handle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Handle\r
+          );\r
+\r
+    if (Private != NULL) {\r
+      //\r
+      // On Error Free back private data\r
+      //\r
+      if (Private->ControllerNameTable != NULL) {\r
+        FreeUnicodeStringTable (Private->ControllerNameTable);\r
+      }\r
+\r
+      gBS->FreePool (Private);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    Handle - add argument and description to function comment\r
+// TODO:    NumberOfChildren - add argument and description to function comment\r
+// TODO:    ChildHandleBuffer - add argument and description to function comment\r
+// TODO:    EFI_NOT_STARTED - add return value to function comment\r
+// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+{\r
+  EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+  EFI_STATUS            Status;\r
+  UGA_PRIVATE_DATA      *Private;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiUgaDrawProtocolGuid,\r
+                  (VOID **)&UgaDraw,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If the UGA interface does not exist the driver is not started\r
+    //\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  //\r
+  // Get our private context information\r
+  //\r
+  Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw);\r
+\r
+  //\r
+  // Remove the SGO interface from the system\r
+  //\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  Private->Handle,\r
+                  &gEfiUgaDrawProtocolGuid,\r
+                  &Private->UgaDraw,\r
+                  &gEfiSimpleTextInProtocolGuid,\r
+                  &Private->SimpleTextIn,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Shutdown the hardware\r
+    //\r
+    Status = UnixUgaDestructor (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    gBS->CloseProtocol (\r
+          Handle,\r
+          &gEfiUnixIoProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Handle\r
+          );\r
+\r
+    //\r
+    // Free our instance data\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+\r
+    gBS->FreePool (Private);\r
+\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaInput.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaInput.c
new file mode 100644 (file)
index 0000000..babfa4b
--- /dev/null
@@ -0,0 +1,221 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixUgaInput.c\r
+\r
+Abstract:\r
+\r
+  This file produces the Simple Text In for an Uga window. \r
+\r
+  This stuff is linked at the hip to the Window, since the window\r
+  processing is done in a thread kicked off in UnixUgaImplementation.c\r
+\r
+  Since the window information is processed in an other thread we need\r
+  a keyboard Queue to pass data about. The Simple Text In code just \r
+  takes data off the Queue. The WinProc message loop takes keyboard input\r
+  and places it in the Queue.\r
+\r
+--*/\r
+\r
+#include "UnixUga.h"\r
+\r
+//\r
+// Simple Text In implementation.\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaSimpleTextInReset (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          *This,\r
+  IN BOOLEAN                              ExtendedVerification\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                  - TODO: add argument description\r
+  ExtendedVerification  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UGA_PRIVATE_DATA  *Private;\r
+  EFI_INPUT_KEY     Key;\r
+  EFI_TPL           OldTpl;\r
+\r
+  Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);\r
+  if (Private->UgaIo == NULL) {
+    return EFI_SUCCESS;\r
+  }
+\r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+  //\r
+  // A reset is draining the Queue\r
+  //\r
+  while (Private->UgaIo->UgaGetKey(Private->UgaIo, &Key) == EFI_SUCCESS)\r
+    ;\r
+\r
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaSimpleTextInReadKeyStroke (\r
+  IN EFI_SIMPLE_TEXT_IN_PROTOCOL          *This,\r
+  OUT EFI_INPUT_KEY                       *Key\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+  Key   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  UGA_PRIVATE_DATA  *Private;\r
+  EFI_STATUS        Status;\r
+  EFI_TPL           OldTpl;\r
+\r
+  Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);\r
+  if (Private->UgaIo == NULL) {
+    return EFI_NOT_READY;\r
+  }
+\r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl  = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+  Status  = Private->UgaIo->UgaGetKey(Private->UgaIo, Key);
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+UnixUgaSimpleTextInWaitForKey (\r
+  IN EFI_EVENT          Event,\r
+  IN VOID               *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Event   - TODO: add argument description\r
+  Context - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  UGA_PRIVATE_DATA  *Private;\r
+  EFI_STATUS        Status;\r
+  EFI_TPL           OldTpl;\r
+\r
+  Private = (UGA_PRIVATE_DATA *) Context;\r
+  if (Private->UgaIo == NULL) {
+    return;
+  }
+\r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl  = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+  Status  = Private->UgaIo->UgaCheckKey(Private->UgaIo);
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // If a there is a key in the queue signal our event.\r
+    //\r
+    gBS->SignalEvent (Event);\r
+  }
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
+}\r
+\r
+EFI_STATUS\r
+UnixUgaInitializeSimpleTextInForWindow (\r
+  IN  UGA_PRIVATE_DATA    *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Initialize Simple Text In protoocol\r
+  //\r
+  Private->SimpleTextIn.Reset         = UnixUgaSimpleTextInReset;\r
+  Private->SimpleTextIn.ReadKeyStroke = UnixUgaSimpleTextInReadKeyStroke;\r
+\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_WAIT,\r
+                  EFI_TPL_NOTIFY,\r
+                  UnixUgaSimpleTextInWaitForKey,\r
+                  Private,\r
+                  &Private->SimpleTextIn.WaitForKey\r
+                  );\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaScreen.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUgaScreen.c
new file mode 100644 (file)
index 0000000..85c23f0
--- /dev/null
@@ -0,0 +1,446 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    UnixUgaScreen.c\r
+\r
+Abstract:\r
+\r
+  This file produces the graphics abstration of UGA. It is called by \r
+  UnixUgaDriver.c file which deals with the EFI 1.1 driver model. \r
+  This file just does graphics.\r
+\r
+--*/\r
+\r
+#include "UnixUga.h"\r
+\r
+EFI_UNIX_THUNK_PROTOCOL *mUnix;\r
+static EFI_EVENT          mUgaScreenExitBootServicesEvent;\r
+\r
+STATIC
+EFI_STATUS\r
+UnixUgaStartWindow (\r
+  IN  UGA_PRIVATE_DATA    *Private,\r
+  IN  UINT32              HorizontalResolution,\r
+  IN  UINT32              VerticalResolution,\r
+  IN  UINT32              ColorDepth,\r
+  IN  UINT32              RefreshRate\r
+  );\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+KillNtUgaThread (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  );\r
+\r
+//\r
+// UGA Protocol Member Functions\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaGetMode (\r
+  EFI_UGA_DRAW_PROTOCOL *This,\r
+  UINT32                *HorizontalResolution,\r
+  UINT32                *VerticalResolution,\r
+  UINT32                *ColorDepth,\r
+  UINT32                *RefreshRate\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    HorizontalResolution  - Current video horizontal resolution in pixels\r
+    VerticalResolution    - Current video Vertical resolution in pixels\r
+    ColorDepth            - Current video color depth in bits per pixel\r
+    RefreshRate           - Current video refresh rate in Hz.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Mode information returned.\r
+    EFI_NOT_STARTED - Video display is not initialized. Call SetMode () \r
+    EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+--*/\r
+// TODO:    ADD IN/OUT description here\r
+{\r
+  UGA_PRIVATE_DATA  *Private;\r
+\r
+  Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->HardwareNeedsStarting) {\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  if ((HorizontalResolution == NULL) ||\r
+      (VerticalResolution   == NULL) ||\r
+      (ColorDepth           == NULL) ||\r
+      (RefreshRate          == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *HorizontalResolution = Private->HorizontalResolution;\r
+  *VerticalResolution   = Private->VerticalResolution;\r
+  *ColorDepth           = Private->ColorDepth;\r
+  *RefreshRate          = Private->RefreshRate;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaSetMode (\r
+  EFI_UGA_DRAW_PROTOCOL *This,\r
+  UINT32                HorizontalResolution,\r
+  UINT32                VerticalResolution,\r
+  UINT32                ColorDepth,\r
+  UINT32                RefreshRate\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Return the current video mode information.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    HorizontalResolution  - Current video horizontal resolution in pixels\r
+    VerticalResolution    - Current video Vertical resolution in pixels\r
+    ColorDepth            - Current video color depth in bits per pixel\r
+    RefreshRate           - Current video refresh rate in Hz.\r
+\r
+  Returns:\r
+    EFI_SUCCESS     - Mode information returned.\r
+    EFI_NOT_STARTED - Video display is not initialized. Call SetMode () \r
+    EFI_INVALID_PARAMETER - One of the input args was NULL.\r
+\r
+--*/\r
+// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// TODO:    ADD IN/OUT description here\r
+{\r
+  EFI_STATUS        Status;\r
+  UGA_PRIVATE_DATA  *Private;\r
+  EFI_UGA_PIXEL     Fill;\r
+\r
+  Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->HardwareNeedsStarting) {\r
+    Status = UnixUgaStartWindow (\r
+              Private,\r
+              HorizontalResolution,\r
+              VerticalResolution,\r
+              ColorDepth,\r
+              RefreshRate\r
+              );\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    Private->HardwareNeedsStarting = FALSE;\r
+  }
+  Status = Private->UgaIo->UgaSize(Private->UgaIo,
+                                  HorizontalResolution,
+                                  VerticalResolution);
+\r
+  Private->HorizontalResolution = HorizontalResolution;\r
+  Private->VerticalResolution   = VerticalResolution;\r
+  Private->ColorDepth           = ColorDepth;\r
+  Private->RefreshRate          = RefreshRate;\r
+\r
+  Fill.Red                      = 0x00;\r
+  Fill.Green                    = 0x00;\r
+  Fill.Blue                     = 0x00;\r
+  This->Blt (\r
+          This,\r
+          &Fill,\r
+          EfiUgaVideoFill,\r
+          0,\r
+          0,\r
+          0,\r
+          0,\r
+          HorizontalResolution,\r
+          VerticalResolution,\r
+          HorizontalResolution * sizeof (EFI_UGA_PIXEL)\r
+          );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaBlt (\r
+  IN  EFI_UGA_DRAW_PROTOCOL                   *This,\r
+  IN  EFI_UGA_PIXEL                           *BltBuffer, OPTIONAL\r
+  IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
+  IN  UINTN                                   SourceX,\r
+  IN  UINTN                                   SourceY,\r
+  IN  UINTN                                   DestinationX,\r
+  IN  UINTN                                   DestinationY,\r
+  IN  UINTN                                   Width,\r
+  IN  UINTN                                   Height,\r
+  IN  UINTN                                   Delta         OPTIONAL\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Blt pixels from the rectangle (Width X Height) formed by the BltBuffer\r
+    onto the graphics screen starting a location (X, Y). (0, 0) is defined as\r
+    the upper left hand side of the screen. (X, Y) can be outside of the \r
+    current screen geometry and the BltBuffer will be cliped when it is \r
+    displayed. X and Y can be negative or positive. If Width or Height is \r
+    bigger than the current video screen the image will be clipped.\r
+\r
+  Arguments:\r
+    This          - Protocol instance pointer.\r
+    X             - X location on graphics screen. \r
+    Y             - Y location on the graphics screen.\r
+    Width         - Width of BltBuffer.\r
+    Height        - Hight of BltBuffer\r
+    BltOperation  - Operation to perform on BltBuffer and video memory\r
+    BltBuffer     - Buffer containing data to blt into video buffer. This \r
+                    buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)\r
+    SourceX       - If the BltOperation is a EfiCopyBlt this is the source\r
+                    of the copy. For other BLT operations this argument is not\r
+                    used.\r
+    SourceX       - If the BltOperation is a EfiCopyBlt this is the source\r
+                    of the copy. For other BLT operations this argument is not\r
+                    used.\r
+      \r
+  Returns:\r
+    EFI_SUCCESS           - The palette is updated with PaletteArray.\r
+    EFI_INVALID_PARAMETER - BltOperation is not valid.\r
+    EFI_DEVICE_ERROR      - A hardware error occured writting to the video \r
+                             buffer.\r
+\r
+--*/\r
+// TODO:    SourceY - add argument and description to function comment\r
+// TODO:    DestinationX - add argument and description to function comment\r
+// TODO:    DestinationY - add argument and description to function comment\r
+// TODO:    Delta - add argument and description to function comment\r
+{\r
+  UGA_PRIVATE_DATA  *Private;\r
+  EFI_TPL           OriginalTPL;\r
+  EFI_STATUS        Status;\r
+\r
+  Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if ((BltOperation < 0) || (BltOperation >= EfiUgaBltMax)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (Width == 0 || Height == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // If Delta is zero, then the entire BltBuffer is being used, so Delta\r
+  // is the number of bytes in each row of BltBuffer.  Since BltBuffer is Width pixels size,\r
+  // the number of bytes in each row can be computed.\r
+  //\r
+  if (Delta == 0) {\r
+    Delta = Width * sizeof (EFI_UGA_PIXEL);\r
+  }\r
+\r
+  //\r
+  // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r
+  // We would not want a timer based event (Cursor, ...) to come in while we are\r
+  // doing this operation.\r
+  //\r
+  OriginalTPL = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+  Status = Private->UgaIo->UgaBlt (Private->UgaIo,
+                                  BltBuffer,
+                                  BltOperation,
+                                  SourceX, SourceY,
+                                  DestinationX, DestinationY,
+                                  Width, Height,
+                                  Delta);
+\r
+  gBS->RestoreTPL (OriginalTPL);\r
+\r
+  return Status;
+}\r
+\r
+\r
+//\r
+// Construction and Destruction functions\r
+//\r
+\r
+EFI_STATUS\r
+UnixUgaSupported (\r
+  IN  EFI_UNIX_IO_PROTOCOL  *UnixIo\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    UnixIo - add argument and description to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  //\r
+  // Check to see if the IO abstraction represents a device type we support.\r
+  //\r
+  // This would be replaced a check of PCI subsystem ID, etc.\r
+  //\r
+  if (!CompareGuid (UnixIo->TypeGuid, &gEfiUnixUgaGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+STATIC
+EFI_STATUS\r
+UnixUgaStartWindow (\r
+  IN  UGA_PRIVATE_DATA    *Private,\r
+  IN  UINT32              HorizontalResolution,\r
+  IN  UINT32              VerticalResolution,\r
+  IN  UINT32              ColorDepth,\r
+  IN  UINT32              RefreshRate\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Private               - TODO: add argument description\r
+  HorizontalResolution  - TODO: add argument description\r
+  VerticalResolution    - TODO: add argument description\r
+  ColorDepth            - TODO: add argument description\r
+  RefreshRate           - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+\r
+  mUnix  = Private->UnixThunk;\r
+\r
+  Private->HorizontalResolution = HorizontalResolution;\r
+  Private->VerticalResolution   = VerticalResolution;\r
+\r
+  //\r
+  // Register to be notified on exit boot services so we can destroy the window.\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                  EFI_TPL_CALLBACK,\r
+                  KillNtUgaThread,\r
+                  Private,\r
+                  &mUgaScreenExitBootServicesEvent\r
+                  );\r
+\r
+  Status = Private->UnixThunk->UgaCreate(&Private->UgaIo, Private->WindowName);
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+UnixUgaConstructor (\r
+  UGA_PRIVATE_DATA    *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    Private - add argument and description to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+\r
+  Private->UgaDraw.GetMode        = UnixUgaGetMode;\r
+  Private->UgaDraw.SetMode        = UnixUgaSetMode;\r
+  Private->UgaDraw.Blt            = UnixUgaBlt;\r
+\r
+  Private->HardwareNeedsStarting  = TRUE;\r
+  Private->UgaIo = NULL;
+\r
+  UnixUgaInitializeSimpleTextInForWindow (Private);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UnixUgaDestructor (\r
+  UGA_PRIVATE_DATA     *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    Private - add argument and description to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  if (!Private->HardwareNeedsStarting) {\r
+    Private->UgaIo->UgaClose(Private->UgaIo);
+    Private->UgaIo = NULL;
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+KillNtUgaThread (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This is the UGA screen's callback notification function for exit-boot-services. \r
+  All we do here is call UnixUgaDestructor().\r
+\r
+Arguments:\r
+\r
+  Event   - not used\r
+  Context - pointer to the Private structure.\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  Status = UnixUgaDestructor (Context);\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/ComponentName.c
new file mode 100644 (file)
index 0000000..b52a471
--- /dev/null
@@ -0,0 +1,187 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#include "UnixBusDriver.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gUnixBusDriverComponentName = {\r
+  UnixBusDriverComponentNameGetDriverName,\r
+  UnixBusDriverComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+static EFI_UNICODE_STRING_TABLE mUnixBusDriverNameTable[] = {\r
+  { "eng", L"Unix Bus Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
+\r
+  Arguments:\r
+    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    Language   - A pointer to a three character ISO 639-2 language identifier.\r
+                 This is the language of the driver name that that the caller \r
+                 is requesting, and it must match one of the languages specified\r
+                 in SupportedLanguages.  The number of languages supported by a \r
+                 driver is up to the driver writer.\r
+    DriverName - A pointer to the Unicode string to return.  This Unicode string\r
+                 is the name of the driver specified by This in the language \r
+                 specified by Language.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the Driver specified by This\r
+                            and the language specified by Language was returned \r
+                            in DriverName.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - DriverName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixBusDriverComponentName.SupportedLanguages,\r
+          mUnixBusDriverNameTable,\r
+          DriverName\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Retrieves a Unicode string that is the user readable name of the controller\r
+    that is being managed by an EFI Driver.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    ControllerHandle - The handle of a controller that the driver specified by \r
+                       This is managing.  This handle specifies the controller \r
+                       whose name is to be returned.\r
+    ChildHandle      - The handle of the child controller to retrieve the name \r
+                       of.  This is an optional parameter that may be NULL.  It \r
+                       will be NULL for device drivers.  It will also be NULL \r
+                       for a bus drivers that wish to retrieve the name of the \r
+                       bus controller.  It will not be NULL for a bus driver \r
+                       that wishes to retrieve the name of a child controller.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier.  This is the language of the controller name \r
+                       that that the caller is requesting, and it must match one\r
+                       of the languages specified in SupportedLanguages.  The \r
+                       number of languages supported by a driver is up to the \r
+                       driver writer.\r
+    ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
+                       string is the name of the controller specified by \r
+                       ControllerHandle and ChildHandle in the language specified\r
+                       by Language from the point of view of the driver specified\r
+                       by This. \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The Unicode string for the user readable name in the \r
+                            language specified by Language for the driver \r
+                            specified by This was returned in DriverName.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ControllerName is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently managing \r
+                            the controller specified by ControllerHandle and \r
+                            ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_UNIX_IO_PROTOCOL  *UnixIo;\r
+  UNIX_IO_DEVICE        *Private;\r
+\r
+  //\r
+  // This is a bus driver, so ChildHandle can not be NULL.\r
+  //\r
+  if (ChildHandle == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ChildHandle,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  &UnixIo,\r
+                  gUnixBusDriverBinding.DriverBindingHandle,\r
+                  ChildHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = UNIX_IO_DEVICE_FROM_THIS (UnixIo);\r
+\r
+  return LookupUnicodeString (\r
+          Language,\r
+          gUnixBusDriverComponentName.SupportedLanguages,\r
+          Private->ControllerNameTable,\r
+          ControllerName\r
+          );\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.c
new file mode 100644 (file)
index 0000000..038c71a
--- /dev/null
@@ -0,0 +1,717 @@
+/*+++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixBusDriver.c\r
+\r
+Abstract:\r
+\r
+This following section documents the envirnoment variables for the Win NT \r
+build.  These variables are used to define the (virtual) hardware \r
+configuration of the NT environment\r
+\r
+A ! can be used to seperate multiple instances in a variable. Each \r
+instance represents a seperate hardware device. \r
+\r
+EFI_UNIX_PHYSICAL_DISKS - maps to drives on your system\r
+EFI_UNIX_VIRTUAL_DISKS  - maps to a device emulated by a file\r
+EFI_UNIX_FILE_SYSTEM    - mouts a directory as a file system\r
+EFI_UNIX_CONSOLE        - make a logical comand line window (only one!)\r
+EFI_UNIX_UGA            - Builds UGA Windows of Width and Height\r
+\r
+ <F>ixed       - Fixed disk like a hard drive.\r
+ <R>emovable   - Removable media like a floppy or CD-ROM.\r
+ Read <O>nly   - Write protected device.\r
+ Read <W>rite  - Read write device.\r
+ <block count> - Decimal number of blocks a device supports.\r
+ <block size>  - Decimal number of bytes per block.\r
+\r
+ NT envirnonment variable contents. '<' and '>' are not part of the variable, \r
+ they are just used to make this help more readable. There should be no \r
+ spaces between the ';'. Extra spaces will break the variable. A '!' is  \r
+ used to seperate multiple devices in a variable.\r
+\r
+ EFI_UNIX_VIRTUAL_DISKS = \r
+   <F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ EFI_UNIX_PHYSICAL_DISKS =\r
+   <drive letter>:<F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ Virtual Disks: These devices use a file to emulate a hard disk or removable\r
+                media device. \r
+                \r
+   Thus a 20 MB emulated hard drive would look like:\r
+   EFI_UNIX_VIRTUAL_DISKS=FW;40960;512\r
+\r
+   A 1.44MB emulated floppy with a block size of 1024 would look like:\r
+   EFI_UNIX_VIRTUAL_DISKS=RW;1440;1024\r
+\r
+ Physical Disks: These devices use NT to open a real device in your system\r
+\r
+   Thus a 120 MB floppy would look like:\r
+   EFI_UNIX_PHYSICAL_DISKS=B:RW;245760;512\r
+\r
+   Thus a standard CD-ROM floppy would look like:\r
+   EFI_UNIX_PHYSICAL_DISKS=Z:RO;307200;2048\r
+\r
+ EFI_UNIX_FILE_SYSTEM = \r
+   <directory path>[!...]\r
+\r
+   Mounting the two directories C:\FOO and C:\BAR would look like:\r
+   EFI_UNIX_FILE_SYSTEM=c:\foo!c:\bar\r
+\r
+ EFI_UNIX_CONSOLE = \r
+   <window title>\r
+\r
+   Declaring a text console window with the title "My EFI Console" woild look like:\r
+   EFI_UNIX_CONSOLE=My EFI Console\r
+\r
+ EFI_UNIX_UGA = \r
+   <width> <height>[!...]\r
+\r
+   Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:\r
+   Example : EFI_UNIX_UGA=800 600!1024 768\r
+\r
+ EFI_UNIX_PASS_THROUGH =\r
+   <BaseAddress>;<Bus#>;<Device#>;<Function#>\r
+\r
+   Declaring a base address of 0xE0000000 (used for PCI Express devices)\r
+   and having NT32 talk to a device located at bus 0, device 1, function 0:\r
+   Example : EFI_UNIX_PASS_THROUGH=E000000;0;1;0\r
+\r
+---*/\r
+\r
+#include "UnixBusDriver.h"\r
+//#include "PciHostBridge.h"\r
+\r
+//\r
+// Define GUID for the Unix Bus Driver\r
+//\r
+static EFI_GUID gUnixBusDriverGuid = {\r
+  0x419f582, 0x625, 0x4531, 0x8a, 0x33, 0x85, 0xa9, 0x96, 0x5c, 0x95, 0xbc\r
+};\r
+\r
+//\r
+// DriverBinding protocol global\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL           gUnixBusDriverBinding = {\r
+  UnixBusDriverBindingSupported,\r
+  UnixBusDriverBindingStart,\r
+  UnixBusDriverBindingStop,\r
+  0x10,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+#define UNIX_PCD_ARRAY_SIZE (sizeof(mPcdEnvironment)/sizeof(UNIX_PCD_ENTRY))\r
+\r
+//\r
+// Table to map NT Environment variable to the GUID that should be in\r
+// device path.\r
+//\r
+static UNIX_PCD_ENTRY  mPcdEnvironment[] = {\r
+  {PcdToken(PcdUnixConsole),       &gEfiUnixConsoleGuid},\r
+  {PcdToken(PcdUnixUga),           &gEfiUnixUgaGuid},\r
+  {PcdToken(PcdUnixFileSystem),    &gEfiUnixFileSystemGuid},\r
+  {PcdToken(PcdUnixVirtualDisk),   &gEfiUnixVirtualDisksGuid},\r
+  {PcdToken(PcdUnixPhysicalDisk),  &gEfiUnixPhysicalDisksGuid},\r
+  {PcdToken(PcdUnixCpuModel),      &gEfiUnixCPUModelGuid},\r
+  {PcdToken(PcdUnixCpuSpeed),      &gEfiUnixCPUSpeedGuid},\r
+  {PcdToken(PcdUnixMemorySize),    &gEfiUnixMemoryGuid}\r
+};\r
+\r
+VOID *\r
+AllocateMemory (\r
+  IN  UINTN   Size\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  VOID        *Buffer;\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  Size,\r
+                  (VOID *)&Buffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    ASSERT (FALSE);\r
+    return NULL;\r
+  }\r
+  return Buffer;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    ControllerHandle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+  EFI_UNIX_THUNK_PROTOCOL *UnixThunk;\r
+  UINTN                     Index;\r
+\r
+  //\r
+  // Check the contents of the first Device Path Node of RemainingDevicePath to make sure\r
+  // it is a legal Device Path Node for this bus driver's children.\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
+        RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
+        DevicePathNodeLength(RemainingDevicePath) != sizeof(UNIX_VENDOR_DEVICE_PATH_NODE)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+\r
+    for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {\r
+      if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) {\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (Index >= UNIX_PCD_ARRAY_SIZE) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **)&ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixThunkProtocolGuid,\r
+                  (VOID **)&UnixThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Since we call through UnixThunk we need to make sure it's valid\r
+  //\r
+  Status = EFI_SUCCESS;\r
+  if (UnixThunk->Signature != EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) {\r
+    Status = EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiUnixThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    ControllerHandle - add argument and description to function comment\r
+// TODO:    RemainingDevicePath - add argument and description to function comment\r
+// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment\r
+// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_STATUS                      InstallStatus;\r
+  EFI_UNIX_THUNK_PROTOCOL       *UnixThunk;\r
+  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
+  UNIX_BUS_DEVICE               *UnixBusDevice;\r
+  UNIX_IO_DEVICE                *UnixDevice;\r
+  UINTN                           Index;\r
+  CHAR16                          *StartString;\r
+  CHAR16                          *SubString;\r
+  UINT16                          Count;\r
+  UINTN                           StringSize;\r
+  UINT16                          ComponentName[MAX_UNIX_ENVIRNMENT_VARIABLE_LENGTH];\r
+  UNIX_VENDOR_DEVICE_PATH_NODE  *Node;\r
+  BOOLEAN                         CreateDevice;\r
+  CHAR16                          *TempStr;\r
+  CHAR16                          *PcdTempStr;\r
+  UINTN                           TempStrSize;\r
+\r
+  Status = EFI_UNSUPPORTED;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **)&ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiUnixThunkProtocolGuid,\r
+                  (VOID **)&UnixThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    return Status;\r
+  }\r
+\r
+  if (Status != EFI_ALREADY_STARTED) {\r
+    Status = gBS->AllocatePool (\r
+                    EfiBootServicesData,\r
+                    sizeof (UNIX_BUS_DEVICE),\r
+                    (VOID *) &UnixBusDevice\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    UnixBusDevice->Signature           = UNIX_BUS_DEVICE_SIGNATURE;\r
+    UnixBusDevice->ControllerNameTable = NULL;\r
+\r
+    AddUnicodeString (\r
+      "eng",\r
+      gUnixBusDriverComponentName.SupportedLanguages,\r
+      &UnixBusDevice->ControllerNameTable,\r
+      L"Unix Bus Controller"\r
+      );\r
+\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &ControllerHandle,\r
+                    &gUnixBusDriverGuid,\r
+                    UnixBusDevice,\r
+                    NULL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      FreeUnicodeStringTable (UnixBusDevice->ControllerNameTable);\r
+      gBS->FreePool (UnixBusDevice);\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Loop on the Variable list. Parse each variable to produce a set of handles that\r
+  // represent virtual hardware devices.\r
+  //\r
+  InstallStatus   = EFI_NOT_FOUND;\r
+  for (Index = 0; Index < UNIX_PCD_ARRAY_SIZE; Index++) {\r
+    PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token);\r
+    ASSERT (PcdTempStr != NULL);\r
+\r
+    TempStrSize = StrLen (PcdTempStr);\r
+    TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1);\r
+    StrCpy (TempStr, PcdTempStr);\r
+\r
+    StartString = TempStr;\r
+\r
+    //\r
+    // Parse the envirnment variable into sub strings using '!' as a delimator.\r
+    // Each substring needs it's own handle to be added to the system. This code\r
+    // does not understand the sub string. Thats the device drivers job.\r
+    //\r
+    Count = 0;\r
+    while (*StartString != '\0') {\r
+\r
+      //\r
+      // Find the end of the sub string\r
+      //\r
+      SubString = StartString;\r
+      while (*SubString != '\0' && *SubString != '!') {\r
+        SubString++;\r
+      }\r
+\r
+      if (*SubString == '!') {\r
+        //\r
+        // Replace token with '\0' to make sub strings. If this is the end\r
+        //  of the string SubString will already point to NULL.\r
+        //\r
+        *SubString = '\0';\r
+        SubString++;\r
+      }\r
+\r
+      CreateDevice = TRUE;\r
+      if (RemainingDevicePath != NULL) {\r
+        CreateDevice  = FALSE;\r
+        Node          = (UNIX_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
+        if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
+            Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
+            DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)\r
+            ) {\r
+          if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) &&\r
+              Node->Instance == Count\r
+              ) {\r
+            CreateDevice = TRUE;\r
+          }\r
+        }\r
+      }\r
+\r
+      if (CreateDevice) {\r
+\r
+        //\r
+        // Allocate instance structure, and fill in parent information.\r
+        //\r
+        UnixDevice = AllocateMemory (sizeof (UNIX_IO_DEVICE));\r
+        if (UnixDevice == NULL) {\r
+          return EFI_OUT_OF_RESOURCES;\r
+        }\r
+\r
+        UnixDevice->Handle             = NULL;\r
+        UnixDevice->ControllerHandle   = ControllerHandle;\r
+        UnixDevice->ParentDevicePath   = ParentDevicePath;\r
+\r
+        UnixDevice->UnixIo.UnixThunk = UnixThunk;\r
+\r
+        //\r
+        // Plus 2 to account for the NULL at the end of the Unicode string\r
+        //\r
+        StringSize = (UINTN) ((UINT8 *) SubString - (UINT8 *) StartString) + sizeof (CHAR16);\r
+        UnixDevice->UnixIo.EnvString = AllocateMemory (StringSize);\r
+        if (UnixDevice->UnixIo.EnvString != NULL) {\r
+          CopyMem (UnixDevice->UnixIo.EnvString, StartString, StringSize);\r
+        }\r
+\r
+        UnixDevice->ControllerNameTable = NULL;\r
+\r
+       //  FIXME: check size
+        StrCpy(ComponentName, UnixDevice->UnixIo.EnvString);\r
+\r
+        UnixDevice->DevicePath = UnixBusCreateDevicePath (\r
+                                    ParentDevicePath,\r
+                                    mPcdEnvironment[Index].DevicePathGuid,\r
+                                    Count\r
+                                    );\r
+        if (UnixDevice->DevicePath == NULL) {\r
+          gBS->FreePool (UnixDevice);\r
+          return EFI_OUT_OF_RESOURCES;\r
+        }\r
+\r
+        AddUnicodeString (\r
+          "eng",\r
+          gUnixBusDriverComponentName.SupportedLanguages,\r
+          &UnixDevice->ControllerNameTable,\r
+          ComponentName\r
+          );\r
+\r
+        UnixDevice->UnixIo.TypeGuid       = mPcdEnvironment[Index].DevicePathGuid;\r
+        UnixDevice->UnixIo.InstanceNumber = Count;\r
+\r
+        UnixDevice->Signature              = UNIX_IO_DEVICE_SIGNATURE;\r
+\r
+        Status = gBS->InstallMultipleProtocolInterfaces (\r
+                        &UnixDevice->Handle,\r
+                        &gEfiDevicePathProtocolGuid,\r
+                        UnixDevice->DevicePath,\r
+                        &gEfiUnixIoProtocolGuid,\r
+                        &UnixDevice->UnixIo,\r
+                        NULL\r
+                        );\r
+        if (EFI_ERROR (Status)) {\r
+          FreeUnicodeStringTable (UnixDevice->ControllerNameTable);\r
+          gBS->FreePool (UnixDevice);\r
+        } else {\r
+          //\r
+          // Open For Child Device\r
+          //\r
+          Status = gBS->OpenProtocol (\r
+                          ControllerHandle,\r
+                          &gEfiUnixThunkProtocolGuid,\r
+                          (VOID **)&UnixThunk,\r
+                          This->DriverBindingHandle,\r
+                          UnixDevice->Handle,\r
+                          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                          );\r
+          if (!EFI_ERROR (Status)) {\r
+            InstallStatus = EFI_SUCCESS;\r
+          }\r
+        }\r
+      }\r
+\r
+      //\r
+      // Parse Next sub string. This will point to '\0' if we are at the end.\r
+      //\r
+      Count++;\r
+      StartString = SubString;\r
+    }\r
+\r
+    gBS->FreePool (TempStr);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+    None\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    ControllerHandle - add argument and description to function comment\r
+// TODO:    NumberOfChildren - add argument and description to function comment\r
+// TODO:    ChildHandleBuffer - add argument and description to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  BOOLEAN                   AllChildrenStopped;\r
+  EFI_UNIX_IO_PROTOCOL    *UnixIo;\r
+  UNIX_BUS_DEVICE         *UnixBusDevice;\r
+  UNIX_IO_DEVICE          *UnixDevice;\r
+  EFI_UNIX_THUNK_PROTOCOL *UnixThunk;\r
+\r
+  //\r
+  // Complete all outstanding transactions to Controller.\r
+  // Don't allow any new transaction to Controller to be started.\r
+  //\r
+\r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the bus driver\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    ControllerHandle,\r
+                    &gUnixBusDriverGuid,\r
+                    (VOID **)&UnixBusDevice,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    gBS->UninstallMultipleProtocolInterfaces (\r
+          ControllerHandle,\r
+          &gUnixBusDriverGuid,\r
+          UnixBusDevice,\r
+          NULL\r
+          );\r
+\r
+    FreeUnicodeStringTable (UnixBusDevice->ControllerNameTable);\r
+\r
+    gBS->FreePool (UnixBusDevice);\r
+\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiUnixThunkProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiDevicePathProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  AllChildrenStopped = TRUE;\r
+\r
+  for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+    Status = gBS->OpenProtocol (\r
+                    ChildHandleBuffer[Index],\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    (VOID **)&UnixIo,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+\r
+      UnixDevice = UNIX_IO_DEVICE_FROM_THIS (UnixIo);\r
+\r
+      Status = gBS->CloseProtocol (\r
+                      ControllerHandle,\r
+                      &gEfiUnixThunkProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      UnixDevice->Handle\r
+                      );\r
+\r
+      Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                      UnixDevice->Handle,\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      UnixDevice->DevicePath,\r
+                      &gEfiUnixIoProtocolGuid,\r
+                      &UnixDevice->UnixIo,\r
+                      NULL\r
+                      );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        gBS->OpenProtocol (\r
+              ControllerHandle,\r
+              &gEfiUnixThunkProtocolGuid,\r
+              (VOID **) &UnixThunk,\r
+              This->DriverBindingHandle,\r
+              UnixDevice->Handle,\r
+              EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+              );\r
+      } else {\r
+        //\r
+        // Close the child handle\r
+        //\r
+        FreeUnicodeStringTable (UnixDevice->ControllerNameTable);\r
+        gBS->FreePool (UnixDevice);\r
+      }\r
+    }\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      AllChildrenStopped = FALSE;\r
+    }\r
+  }\r
+\r
+  if (!AllChildrenStopped) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+UnixBusCreateDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDevicePath,\r
+  IN  EFI_GUID                  *Guid,\r
+  IN  UINT16                    InstanceNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Create a device path node using Guid and InstanceNumber and append it to\r
+  the passed in RootDevicePath\r
+\r
+Arguments:\r
+  RootDevicePath - Root of the device path to return.\r
+\r
+  Guid           - GUID to use in vendor device path node.\r
+\r
+  InstanceNumber - Instance number to use in the vendor device path. This\r
+                    argument is needed to make sure each device path is unique.\r
+\r
+Returns:\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL \r
+\r
+--*/\r
+{\r
+  UNIX_VENDOR_DEVICE_PATH_NODE  DevicePath;\r
+\r
+  DevicePath.VendorDevicePath.Header.Type     = HARDWARE_DEVICE_PATH;\r
+  DevicePath.VendorDevicePath.Header.SubType  = HW_VENDOR_DP;\r
+  SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (UNIX_VENDOR_DEVICE_PATH_NODE));\r
+\r
+  //\r
+  // The GUID defines the Class\r
+  //\r
+  CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID));\r
+\r
+  //\r
+  // Add an instance number so we can make sure there are no Device Path\r
+  // duplication.\r
+  //\r
+  DevicePath.Instance = InstanceNumber;\r
+\r
+  return AppendDevicePathNode (\r
+          RootDevicePath,\r
+          (EFI_DEVICE_PATH_PROTOCOL *) &DevicePath\r
+          );\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.h b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.h
new file mode 100644 (file)
index 0000000..4d8530b
--- /dev/null
@@ -0,0 +1,297 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixBusDriver.h\r
+\r
+Abstract:\r
+\r
+This following section documents the PCD for the Unix \r
+build.  These variables are used to define the (virtual) hardware \r
+configuration of the Unix environment\r
+\r
+A ! can be used to seperate multiple instances in a variable. Each \r
+instance represents a seperate hardware device. \r
+\r
+EFI_UNIX_PHYSICAL_DISKS - maps to drives on your system\r
+EFI_UNIX_VIRTUAL_DISKS  - maps to a device emulated by a file\r
+EFI_UNIX_FILE_SYSTEM    - mouts a directory as a file system\r
+EFI_UNIX_CONSOLE        - make a logical comand line window (only one!)\r
+EFI_UNIX_UGA            - Builds UGA Windows of Width and Height\r
+EFI_UNIX_SERIAL_PORT    - maps physical serial ports\r
+EFI_UNIX_PASS_THRU      - associates a device with our PCI support\r
+\r
+ <F>ixed       - Fixed disk like a hard drive.\r
+ <R>emovable   - Removable media like a floppy or CD-ROM.\r
+ Read <O>nly   - Write protected device.\r
+ Read <W>rite  - Read write device.\r
+ <block count> - Decimal number of blocks a device supports.\r
+ <block size>  - Decimal number of bytes per block.\r
+\r
+ NT envirnonment variable contents. '<' and '>' are not part of the variable, \r
+ they are just used to make this help more readable. There should be no \r
+ spaces between the ';'. Extra spaces will break the variable. A '!' is  \r
+ used to seperate multiple devices in a variable.\r
+\r
+ EFI_UNIX_VIRTUAL_DISKS = \r
+   <F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ EFI_UNIX_PHYSICAL_DISKS =\r
+   <drive letter>:<F | R><O | W>;<block count>;<block size>[!...]\r
+\r
+ Virtual Disks: These devices use a file to emulate a hard disk or removable\r
+                media device. \r
+                \r
+   Thus a 20 MB emulated hard drive would look like:\r
+   EFI_UNIX_VIRTUAL_DISKS=FW;40960;512\r
+\r
+   A 1.44MB emulated floppy with a block size of 1024 would look like:\r
+   EFI_UNIX_VIRTUAL_DISKS=RW;1440;1024\r
+\r
+ Physical Disks: These devices use NT to open a real device in your system\r
+\r
+   Thus a 120 MB floppy would look like:\r
+   EFI_UNIX_PHYSICAL_DISKS=B:RW;245760;512\r
+\r
+   Thus a standard CD-ROM floppy would look like:\r
+   EFI_UNIX_PHYSICAL_DISKS=Z:RO;307200;2048\r
+\r
+ EFI_UNIX_FILE_SYSTEM = \r
+   <directory path>[!...]\r
+\r
+   Mounting the two directories C:\FOO and C:\BAR would look like:\r
+   EFI_UNIX_FILE_SYSTEM=c:\foo!c:\bar\r
+\r
+ EFI_UNIX_CONSOLE = \r
+   <window title>\r
+\r
+   Declaring a text console window with the title "My EFI Console" woild look like:\r
+   EFI_UNIX_CONSOLE=My EFI Console\r
+\r
+ EFI_UNIX_UGA = \r
+   <width> <height>[!...]\r
+\r
+   Declaring a two UGA windows with resolutions of 800x600 and 1024x768 would look like:\r
+   Example : EFI_UNIX_UGA=800 600!1024 768\r
+\r
+ EFI_UNIX_SERIAL_PORT = \r
+   <port name>[!...]\r
+\r
+   Declaring two serial ports on COM1 and COM2 would look like:\r
+   Example : EFI_UNIX_SERIAL_PORT=COM1!COM2\r
+\r
+ EFI_UNIX_PASS_THROUGH =\r
+   <BaseAddress>;<Bus#>;<Device#>;<Function#>\r
+\r
+   Declaring a base address of 0xE0000000 (used for PCI Express devices)\r
+   and having NT32 talk to a device located at bus 0, device 1, function 0:\r
+   Example : EFI_UNIX_PASS_THROUGH=E000000;0;1;0\r
+\r
+---*/\r
+\r
+#ifndef __UNIX_BUS_DRIVER_H__\r
+#define __UNIX_BUS_DRIVER_H__\r
+\r
+\r
+\r
+//\r
+// Unix Bus Driver Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gUnixBusDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gUnixBusDriverComponentName;\r
+\r
+//\r
+// Unix Bus Controller Structure\r
+//\r
+#define UNIX_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('L', 'X', 'B', 'D')\r
+\r
+typedef struct {\r
+  UINT64                    Signature;\r
+  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
+} UNIX_BUS_DEVICE;\r
+\r
+//\r
+// Unix Child Device Controller Structure\r
+//\r
+#define UNIX_IO_DEVICE_SIGNATURE  EFI_SIGNATURE_32 ('L', 'X', 'V', 'D')\r
+\r
+typedef struct {\r
+  UINT64                    Signature;\r
+  EFI_HANDLE                Handle;\r
+  EFI_UNIX_IO_PROTOCOL     UnixIo;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  //\r
+  // Private data about the parent\r
+  //\r
+  EFI_HANDLE                ControllerHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+\r
+  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
+\r
+} UNIX_IO_DEVICE;\r
+\r
+#define UNIX_IO_DEVICE_FROM_THIS(a) \\r
+  CR(a, UNIX_IO_DEVICE, UnixIo, UNIX_IO_DEVICE_SIGNATURE)\r
+\r
+//\r
+// This is the largest env variable we can parse\r
+//\r
+#define MAX_UNIX_ENVIRNMENT_VARIABLE_LENGTH 512\r
+\r
+typedef struct {\r
+  UINTN               Token;\r
+  EFI_GUID            *DevicePathGuid;\r
+} UNIX_PCD_ENTRY;\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH  VendorDevicePath;\r
+  UINT32              Instance;\r
+} UNIX_VENDOR_DEVICE_PATH_NODE;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoInitialize (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - TODO: add argument description\r
+  SystemTable - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Driver Binding Protocol function prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Handle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  Handle              - TODO: add argument description\r
+  RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     ParentHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This                - TODO: add argument description\r
+  ParentHandle        - TODO: add argument description\r
+  RemainingDevicePath - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixBusDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This              - TODO: add argument description\r
+  Handle            - TODO: add argument description\r
+  NumberOfChildren  - TODO: add argument description\r
+  ChildHandleBuffer - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Unix Bus Driver private worker functions\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL  *\r
+UnixBusCreateDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDevicePath,\r
+  IN  EFI_GUID                  *Guid,\r
+  IN  UINT16                    InstanceNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  RootDevicePath  - TODO: add argument description\r
+  Guid            - TODO: add argument description\r
+  InstanceNumber  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.msa b/EdkUnixPkg/Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.msa
new file mode 100644 (file)
index 0000000..2ca466c
--- /dev/null
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixBusDriver</ModuleName>\r
+    <ModuleType>UEFI_DRIVER</ModuleType>\r
+    <GuidValue>f320d656-8985-11db-90e0-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Unix Bus driver</Abstract>\r
+    <Description>\r
+      This following section documents the envirnoment variables for the Win NT\r
+      build.  These variables are used to define the (virtual) hardware\r
+      configuration of the NT environment\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixBusDriver</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverModelLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DevicePathLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixBusDriver.h</Filename>\r
+    <Filename>UnixBusDriver.c</Filename>\r
+    <Filename>ComponentName.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="BY_START">\r
+      <ProtocolCName>gEfiUnixIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="TO_START">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gPcdProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixVirtualDisksGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixPhysicalDisksGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixFileSystemGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixUgaGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixConsoleGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixMemoryGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixCPUModelGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiUnixCPUSpeedGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <DriverBinding>gUnixBusDriverBinding</DriverBinding>\r
+      <ComponentName>gUnixBusDriverComponentName</ComponentName>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixConsole</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD declares the title string of the text console window.\r
+        such as "My EFI Console".\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixUga</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD declares the resolutions for the UGA windows.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixFileSystem</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines the windows directory who will be mounted as\r
+        harddisk in simulator.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixVirtualDisk</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines the devices which use a file to emulate a hard disk or\r
+        removable media device\r
+        The item type if this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixPhysicalDisk</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines physical disk which will be simualted as a\r
+        harddisk in simulator.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixCpuModel</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines simulated CPU model string.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixCpuSpeed</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines simulated CPU speed string.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixMemorySize</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines the size of simulated memory size.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.c b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.c
new file mode 100644 (file)
index 0000000..be5d87d
--- /dev/null
@@ -0,0 +1,129 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  Metronome.c\r
+\r
+Abstract:\r
+\r
+  NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS\r
+\r
+--*/\r
+\r
+#include "Metronome.h"\r
+\r
+//\r
+// Global Variables\r
+//\r
+EFI_METRONOME_ARCH_PROTOCOL mMetronome = {\r
+  UnixMetronomeDriverWaitForTick,\r
+  TICK_PERIOD\r
+};\r
+\r
+//\r
+// Worker Functions\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixMetronomeDriverWaitForTick (\r
+  IN EFI_METRONOME_ARCH_PROTOCOL  *This,\r
+  IN UINT32                       TickNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The WaitForTick() function waits for the number of ticks specified by\r
+  TickNumber from a known time source in the platform.  If TickNumber of\r
+  ticks are detected, then EFI_SUCCESS is returned.  The actual time passed\r
+  between entry of this function and the first tick is between 0 and\r
+  TickPeriod 100 nS units.  If you want to guarantee that at least TickPeriod\r
+  time has elapsed, wait for two ticks.  This function waits for a hardware\r
+  event to determine when a tick occurs.  It is possible for interrupt\r
+  processing, or exception processing to interrupt the execution of the\r
+  WaitForTick() function.  Depending on the hardware source for the ticks, it\r
+  is possible for a tick to be missed.  This function cannot guarantee that\r
+  ticks will not be missed.  If a timeout occurs waiting for the specified\r
+  number of ticks, then EFI_TIMEOUT is returned.\r
+\r
+Arguments:\r
+\r
+  This       - The EFI_METRONOME_ARCH_PROTOCOL instance.\r
+  TickNumber - Number of ticks to wait.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - The wait for the number of ticks specified by TickNumber\r
+                succeeded.\r
+\r
+--*/\r
+{\r
+  UINT64  SleepTime;\r
+\r
+  //\r
+  // Calculate the time to sleep.  Win API smallest unit to sleep is 1 millisec\r
+  // Tick Period is in 100ns units, divide by 10000 to convert to ms\r
+  //\r
+  SleepTime = DivU64x32 (MultU64x32 ((UINT64) TickNumber, TICK_PERIOD) + 9999, 10000);\r
+  gUnix->Sleep ((UINT32) SleepTime);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixMetronomeDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize the Metronome Architectural Protocol driver\r
+\r
+Arguments:\r
+\r
+  ImageHandle - ImageHandle of the loaded driver\r
+\r
+\r
+  SystemTable - Pointer to the System Table\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Metronome Architectural Protocol created\r
+\r
+  EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.\r
+\r
+  EFI_DEVICE_ERROR      - A device error occured attempting to initialize the driver.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+\r
+  //\r
+  // Install the Metronome Architectural Protocol onto a new handle\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  &gEfiMetronomeArchProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mMetronome\r
+                  );\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.dxs b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.dxs
new file mode 100644 (file)
index 0000000..d11f48a
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Metronome.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.h b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.h
new file mode 100644 (file)
index 0000000..d82c825
--- /dev/null
@@ -0,0 +1,84 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Metronome.h\r
+\r
+Abstract:\r
+\r
+  NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_THUNK_METRONOME_H_\r
+#define _UNIX_THUNK_METRONOME_H_\r
+\r
+\r
+\r
+//\r
+// Period of on tick in 100 nanosecond units\r
+//\r
+#define TICK_PERIOD 2000\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixMetronomeDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - TODO: add argument description\r
+  SystemTable - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixMetronomeDriverWaitForTick (\r
+  IN EFI_METRONOME_ARCH_PROTOCOL  *This,\r
+  IN UINT32                       TickNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  TickNumber  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.msa b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Metronome/Metronome.msa
new file mode 100644 (file)
index 0000000..a64f1ea
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>Metronome</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f348f6fe-8985-11db-b4c3-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Unix Emulation Metronome Architectural Protocol Driver as defined in DXE CIS</Abstract>\r
+    <Description>\r
+      This metronome module simulates metronome by Sleep WinAPI.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>Metronome</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Metronome.c</Filename>\r
+    <Filename>Metronome.h</Filename>\r
+    <Filename>Metronome.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiMetronomeArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>UnixMetronomeDriverInitialize</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.c b/EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.c
new file mode 100644 (file)
index 0000000..8cf60eb
--- /dev/null
@@ -0,0 +1,345 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RealTimeClock.c\r
+\r
+Abstract:\r
+\r
+  NT Emulation Architectural Protocol Driver as defined in Tiano\r
+\r
+--*/\r
+\r
+BOOLEAN\r
+DayValid (\r
+  IN  EFI_TIME  *Time\r
+  );\r
+\r
+BOOLEAN\r
+IsLeapYear (\r
+  IN EFI_TIME   *Time\r
+  );\r
+\r
+EFI_STATUS\r
+RtcTimeFieldsValid (\r
+  IN EFI_TIME *Time\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeRealTimeClock (\r
+  IN EFI_HANDLE                          ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                    *SystemTable\r
+  );\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixGetTime (\r
+  OUT EFI_TIME                                 * Time,\r
+  OUT EFI_TIME_CAPABILITIES                    * Capabilities OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->GetTime \r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage that will receive a snapshot of the current time.\r
+\r
+  Capabilities  - A pointer to storage that will receive the capabilities of the real time clock\r
+                  in the platform. This includes the real time clock's resolution and accuracy.  \r
+                  All reported device capabilities are rounded up.  This is an OPTIONAL argument.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS   - The underlying GetSystemTime call occurred and returned\r
+                  Note that in the NT32 emulation, the GetSystemTime call has no return value\r
+                  thus you will always receive a EFI_SUCCESS on this.\r
+\r
+--*/\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+\r
+  //\r
+  // Check parameter for null pointer\r
+  //\r
+  if (Time == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+\r
+  }\r
+\r
+  gUnix->GetLocalTime (Time);
+\r
+  if (Capabilities != NULL) {\r
+    Capabilities->Resolution  = 1;\r
+    Capabilities->Accuracy    = 50000000;\r
+    Capabilities->SetsToZero  = FALSE;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSetTime (\r
+  IN EFI_TIME   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->SetTime \r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage containing the time and date information to\r
+                  program into the real time clock.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The operation completed successfully.\r
+                  \r
+  EFI_INVALID_PARAMETER - One of the fields in Time is out of range.\r
+\r
+  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
+\r
+--*/\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS            Status;\r
+\r
+  if (Time == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Make sure that the time fields are valid\r
+  //\r
+  Status = RtcTimeFieldsValid (Time);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixGetWakeupTime (\r
+  OUT BOOLEAN        *Enabled,\r
+  OUT BOOLEAN        *Pending,\r
+  OUT EFI_TIME       *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->GetWakeupTime\r
+\r
+Arguments:\r
+  This          - Indicates the protocol instance structure.\r
+\r
+  Enabled       - Indicates if the alarm is currently enabled or disabled.\r
+\r
+  Pending       - Indicates if the alarm signal is pending and requires\r
+                  acknowledgement.\r
+\r
+  Time          - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The operation completed successfully.\r
+                  \r
+  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
+\r
+  EFI_UNSUPPORTED       - The operation is not supported on this platform.\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSetWakeupTime (\r
+  IN BOOLEAN      Enable,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->SetWakeupTime\r
+\r
+Arguments:\r
+\r
+  Enabled       - Enable or disable the wakeup alarm.\r
+\r
+  Time          - If enable is TRUE, the time to set the wakup alarm for.\r
+                  If enable is FALSE, then this parameter is optional, and\r
+                  may be NULL.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The operation completed successfully.\r
+                  \r
+  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
+\r
+  EFI_INVALID_PARAMETER - A field in Time is out of range.\r
+\r
+  EFI_UNSUPPORTED       - The operation is not supported on this platform.\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeRealTimeClock (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Install Real Time Clock Protocol \r
+\r
+Arguments:\r
+  ImageHandle - Image Handle\r
+  SystemTable - Pointer to system table\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  SystemTable->RuntimeServices->GetTime       = UnixGetTime;\r
+  SystemTable->RuntimeServices->SetTime       = UnixSetTime;\r
+  SystemTable->RuntimeServices->GetWakeupTime = UnixGetWakeupTime;\r
+  SystemTable->RuntimeServices->SetWakeupTime = UnixSetWakeupTime;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiRealTimeClockArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+RtcTimeFieldsValid (\r
+  IN EFI_TIME *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Arguments:\r
\r
+  Returns: \r
+--*/\r
+// TODO:    Time - add argument and description to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  if (Time->Year < 1998 ||\r
+      Time->Year > 2099 ||\r
+      Time->Month < 1 ||\r
+      Time->Month > 12 ||\r
+      (!DayValid (Time)) ||\r
+      Time->Hour > 23 ||\r
+      Time->Minute > 59 ||\r
+      Time->Second > 59 ||\r
+      Time->Nanosecond > 999999999 ||\r
+      (!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||\r
+      (Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT)))\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+DayValid (\r
+  IN  EFI_TIME  *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Time  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+\r
+  static const INTN  DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\r
+\r
+  if (Time->Day < 1 ||\r
+      Time->Day > DayOfMonth[Time->Month - 1] ||\r
+      (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))\r
+      ) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+IsLeapYear (\r
+  IN EFI_TIME   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Time  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  if (Time->Year % 4 == 0) {\r
+    if (Time->Year % 100 == 0) {\r
+      if (Time->Year % 400 == 0) {\r
+        return TRUE;\r
+      } else {\r
+        return FALSE;\r
+      }\r
+    } else {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.dxs b/EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.dxs
new file mode 100644 (file)
index 0000000..01f441c
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  RealTimeClock.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.msa b/EdkUnixPkg/Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.msa
new file mode 100644 (file)
index 0000000..d9a7166
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>RealTimeClock</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f3552032-8985-11db-8429-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Unix Emulation Real time clock Architectural Protocol Driver as defined in TIANO</Abstract>\r
+    <Description>\r
+      This real time clock module simulates virtual device by time WinAPI.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>RealTimeClock</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>RealTimeClock.c</Filename>\r
+    <Filename>RealTimeClock.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiRealTimeClockArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>InitializeRealTimeClock</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.c b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.c
new file mode 100644 (file)
index 0000000..8739d6c
--- /dev/null
@@ -0,0 +1,119 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2005, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ Reset.c\r
+\r
+Abstract:\r
+\r
+  Reset Architectural Protocol as defined in Tiano under NT Emulation\r
+\r
+--*/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeUnixReset (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+STATIC\r
+VOID
+EFIAPI\r
+UnixResetSystem (\r
+  IN EFI_RESET_TYPE   ResetType,\r
+  IN EFI_STATUS       ResetStatus,\r
+  IN UINTN            DataSize,\r
+  IN CHAR16           *ResetData OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeUnixReset (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+Arguments:\r
+\r
+  ImageHandle of the loaded driver\r
+  Pointer to the System Table\r
+\r
+Returns:\r
+\r
+  Status\r
+--*/\r
+// TODO:    SystemTable - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  SystemTable->RuntimeServices->ResetSystem = UnixResetSystem;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiResetArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+VOID
+EFIAPI\r
+UnixResetSystem (\r
+  IN EFI_RESET_TYPE   ResetType,\r
+  IN EFI_STATUS       ResetStatus,\r
+  IN UINTN            DataSize,\r
+  IN CHAR16           *ResetData OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ResetType   - TODO: add argument description\r
+  ResetStatus - TODO: add argument description\r
+  DataSize    - TODO: add argument description\r
+  ResetData   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  //\r
+  // BUGBUG Need to kill all console windows later\r
+  //\r
+  //\r
+  // Discard ResetType, always return 0 as exit code\r
+  //\r
+  gUnix->Exit (0);\r
+\r
+  //\r
+  // Should never go here\r
+  //\r
+  while (1)
+    ;
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.dxs b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.dxs
new file mode 100644 (file)
index 0000000..5dfb191
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Reset.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.msa b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Reset/Reset.msa
new file mode 100644 (file)
index 0000000..133a901
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>Reset</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f3613084-8985-11db-8c26-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Unix Emulation Reset Architectural Protocol Driver as defined in TIANO</Abstract>\r
+    <Description>\r
+      This Reset module simulates system reset by process exit on NT.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>Reset</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Reset.c</Filename>\r
+    <Filename>Reset.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiResetArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>InitializeUnixReset</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.c b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.c
new file mode 100644 (file)
index 0000000..19fd911
--- /dev/null
@@ -0,0 +1,358 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Timer.c\r
+\r
+Abstract:\r
+\r
+  NT Emulation Timer Architectural Protocol Driver as defined in DXE CIS\r
+\r
+  This Timer module uses an NT Thread to simulate the timer-tick driven\r
+  timer service.  In the future, the Thread creation should possibly be \r
+  abstracted by the CPU architectural protocol\r
+\r
+--*/\r
+\r
+#include "Timer.h"\r
+\r
+//\r
+// Pointer to the CPU Architectural Protocol instance\r
+//\r
+EFI_CPU_ARCH_PROTOCOL   *mCpu;\r
+\r
+//\r
+// The Timer Architectural Protocol that this driver produces\r
+//\r
+EFI_TIMER_ARCH_PROTOCOL mTimer = {\r
+  UnixTimerDriverRegisterHandler,\r
+  UnixTimerDriverSetTimerPeriod,\r
+  UnixTimerDriverGetTimerPeriod,\r
+  UnixTimerDriverGenerateSoftInterrupt\r
+};\r
+\r
+//\r
+// The notification function to call on every timer interrupt\r
+//\r
+EFI_TIMER_NOTIFY        mTimerNotifyFunction = NULL;\r
+\r
+//\r
+// The current period of the timer interrupt\r
+//\r
+UINT64                  mTimerPeriod;\r
+\r
+//\r
+// The timer value from the last timer interrupt\r
+//\r
+UINT32                  mNtLastTick;\r
+\r
+VOID\r
+TimerCallback (UINT64 DeltaMs)
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  wTimerID  - TODO: add argument description\r
+  msg       - TODO: add argument description\r
+  dwUser    - TODO: add argument description\r
+  dw1       - TODO: add argument description\r
+  dw2       - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_TPL           OriginalTPL;\r
+  EFI_TIMER_NOTIFY  CallbackFunction;
+
+\r
+  OriginalTPL = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);\r
+\r
+  CallbackFunction = mTimerNotifyFunction;\r
+\r
+  //\r
+  // Only invoke the callback function if a Non-NULL handler has been\r
+  // registered. Assume all other handlers are legal.\r
+  //\r
+  if (CallbackFunction != NULL) {\r
+    CallbackFunction ((UINT64) (DeltaMs * 10000));\r
+  }\r
+\r
+  gBS->RestoreTPL (OriginalTPL);\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverRegisterHandler (\r
+  IN EFI_TIMER_ARCH_PROTOCOL           *This,\r
+  IN EFI_TIMER_NOTIFY                  NotifyFunction\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function registers the handler NotifyFunction so it is called every time \r
+  the timer interrupt fires.  It also passes the amount of time since the last \r
+  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the \r
+  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is \r
+  returned.  If the CPU does not support registering a timer interrupt handler, \r
+  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler \r
+  when a handler is already registered, then EFI_ALREADY_STARTED is returned.  \r
+  If an attempt is made to unregister a handler when a handler is not registered, \r
+  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to \r
+  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR \r
+  is returned.\r
+\r
+Arguments:\r
+\r
+  This           - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  NotifyFunction - The function to call when a timer interrupt fires.  This \r
+                   function executes at TPL_HIGH_LEVEL.  The DXE Core will \r
+                   register a handler for the timer interrupt, so it can know \r
+                   how much time has passed.  This information is used to \r
+                   signal timer based events.  NULL will unregister the handler.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - The timer handler was registered.\r
+\r
+  EFI_UNSUPPORTED       - The platform does not support timer interrupts.\r
+\r
+  EFI_ALREADY_STARTED   - NotifyFunction is not NULL, and a handler is already \r
+                          registered.\r
+\r
+  EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not \r
+                          previously registered.\r
+\r
+  EFI_DEVICE_ERROR      - The timer handler could not be registered.\r
+\r
+--*/\r
+{\r
+  //\r
+  // Check for invalid parameters\r
+  //\r
+  if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  if (NotifyFunction == NULL) {
+    /* Disable timer.  */
+    gUnix->SetTimer (0, TimerCallback);
+  } else if (mTimerNotifyFunction == NULL) {
+    /* Enable Timer.  */
+    gUnix->SetTimer (mTimerPeriod * 10, TimerCallback);
+  }
+  mTimerNotifyFunction = NotifyFunction;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverSetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                   TimerPeriod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adjusts the period of timer interrupts to the value specified \r
+  by TimerPeriod.  If the timer period is updated, then the selected timer \r
+  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If \r
+  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.  \r
+  If an error occurs while attempting to update the timer period, then the \r
+  timer hardware will be put back in its state prior to this call, and \r
+  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt \r
+  is disabled.  This is not the same as disabling the CPU's interrupts.  \r
+  Instead, it must either turn off the timer hardware, or it must adjust the \r
+  interrupt controller so that a CPU interrupt is not generated when the timer \r
+  interrupt fires. \r
+\r
+Arguments:\r
+\r
+  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - The rate to program the timer interrupt in 100 nS units.  If \r
+                the timer hardware is not programmable, then EFI_UNSUPPORTED is \r
+                returned.  If the timer is programmable, then the timer period \r
+                will be rounded up to the nearest timer period that is supported \r
+                by the timer hardware.  If TimerPeriod is set to 0, then the \r
+                timer interrupts will be disabled.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS      - The timer period was changed.\r
+\r
+  EFI_UNSUPPORTED  - The platform cannot change the period of the timer interrupt.\r
+\r
+  EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.\r
+\r
+--*/\r
+{\r
+\r
+  //\r
+  // If TimerPeriod is 0, then the timer thread should be canceled\r
+  // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
+  //\r
+  if (TimerPeriod == 0
+      || ((TimerPeriod > TIMER_MINIMUM_VALUE)
+         && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {\r
+    mTimerPeriod = TimerPeriod;\r
+
+    gUnix->SetTimer (TimerPeriod * 10, TimerCallback);
+  }
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverGetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL            *This,\r
+  OUT UINT64                            *TimerPeriod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function retrieves the period of timer interrupts in 100 ns units, \r
+  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod \r
+  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is \r
+  returned, then the timer is currently disabled.\r
+\r
+Arguments:\r
+\r
+  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - A pointer to the timer period to retrieve in 100 ns units.  If \r
+                0 is returned, then the timer is currently disabled.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS           - The timer period was returned in TimerPeriod.\r
+\r
+  EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r
+\r
+--*/\r
+{\r
+  if (TimerPeriod == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *TimerPeriod = mTimerPeriod;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverGenerateSoftInterrupt (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function generates a soft timer interrupt. If the platform does not support soft \r
+  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned. \r
+  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler() \r
+  service, then a soft timer interrupt will be generated. If the timer interrupt is \r
+  enabled when this service is called, then the registered handler will be invoked. The \r
+  registered handler should not be able to distinguish a hardware-generated timer \r
+  interrupt from a software-generated timer interrupt.\r
+\r
+Arguments:\r
+\r
+  This  -  The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+Returns: \r
+\r
+  EFI_SUCCESS       - The soft timer interrupt was generated.\r
+\r
+  EFI_UNSUPPORTEDT  - The platform does not support the generation of soft timer interrupts.\r
+\r
+--*/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize the Timer Architectural Protocol driver\r
+\r
+Arguments:\r
+\r
+  ImageHandle - ImageHandle of the loaded driver\r
+\r
+  SystemTable - Pointer to the System Table\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Timer Architectural Protocol created\r
+\r
+  EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.\r
+  \r
+  EFI_DEVICE_ERROR      - A device error occured attempting to initialize the driver.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  //\r
+  // Make sure the Timer Architectural Protocol is not already installed in the system\r
+  //\r
+  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);\r
+\r
+  //\r
+  // Get the CPU Architectural Protocol instance\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (void *)&mCpu);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Install the Timer Architectural Protocol onto a new handle\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  &gEfiTimerArchProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mTimer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.dxs b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.dxs
new file mode 100644 (file)
index 0000000..6e66383
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Timer.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/ \r
+\r
+\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  EFI_CPU_ARCH_PROTOCOL_GUID\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.h b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.h
new file mode 100644 (file)
index 0000000..98d1999
--- /dev/null
@@ -0,0 +1,162 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Timer.h\r
+\r
+Abstract:\r
+\r
+  NT Emulation Architectural Protocol Driver as defined in Tiano.\r
+  This Timer module uses an NT Thread to simulate the timer-tick driven\r
+  timer service.\r
+\r
+--*/\r
+\r
+#ifndef _TIMER_H_\r
+#define _TIMER_H_\r
+\r
+\r
+\r
+\r
+//\r
+// Legal timer value range in 100 ns units\r
+//\r
+#define TIMER_MINIMUM_VALUE 0\r
+#define TIMER_MAXIMUM_VALUE (0x100000000 - 1)\r
+\r
+//\r
+// Default timer value in 100 ns units (10 ms)\r
+//\r
+#define DEFAULT_TIMER_TICK_DURATION 100000\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageHandle - TODO: add argument description\r
+  SystemTable - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverRegisterHandler (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN EFI_TIMER_NOTIFY         NotifyFunction\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This            - TODO: add argument description\r
+  NotifyFunction  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverSetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                   TimerPeriod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  TimerPeriod - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverGetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL   *This,\r
+  OUT UINT64                   *TimerPeriod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This        - TODO: add argument description\r
+  TimerPeriod - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixTimerDriverGenerateSoftInterrupt (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  This  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.msa b/EdkUnixPkg/Dxe/UnixThunk/Chipset/Timer/Timer.msa
new file mode 100644 (file)
index 0000000..f240f32
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>Timer</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f36d49b4-8985-11db-809b-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Unix Emulation Timer Architectural Protocol Driver as defined in DXE CIS</Abstract>\r
+    <Description>\r
+      This Timer module uses an NT Thread to simulate the timer-tick driven\r
+      timer service.  In the future, the Thread creation should possibly be \r
+      abstracted by the CPU architectural protocol\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>Timer</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Timer.h</Filename>\r
+    <Filename>Timer.c</Filename>\r
+    <Filename>Timer.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiTimerArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>UnixTimerDriverInitialize</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.c b/EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.c
new file mode 100644 (file)
index 0000000..9149639
--- /dev/null
@@ -0,0 +1,730 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Cpu.c\r
+\r
+Abstract:\r
+\r
+  Unix Emulation Architectural Protocol Driver as defined in Tiano.\r
+  This CPU module abstracts the interrupt subsystem of a platform and\r
+  the CPU-specific setjump/long pair.  Other services are not implemented\r
+  in this driver.\r
+\r
+--*/\r
+\r
+#include "CpuDriver.h"\r
+\r
+#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpu (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+UnixIoProtocolNotifyFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  );\r
+\r
+typedef union {\r
+  EFI_CPU_DATA_RECORD *DataRecord;\r
+  UINT8               *Raw;\r
+} EFI_CPU_DATA_RECORD_BUFFER;\r
+\r
+EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader = {\r
+  EFI_PROCESSOR_SUBCLASS_VERSION,       // Version\r
+  sizeof (EFI_SUBCLASS_TYPE1_HEADER),   // Header Size\r
+  0,                                    // Instance, Initialize later\r
+  EFI_SUBCLASS_INSTANCE_NON_APPLICABLE, // SubInstance\r
+  0                                     // RecordType, Initialize later\r
+};\r
+\r
+//\r
+// Service routines for the driver\r
+//\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixFlushCpuDataCache (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS   Start,\r
+  IN UINT64                 Length,\r
+  IN EFI_CPU_FLUSH_TYPE     FlushType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would provide support for flushing the CPU data cache.\r
+  In the case of NT emulation environment, this flushing is not necessary and\r
+  is thus not implemented.\r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+  Start adddress in memory to flush\r
+  Length of memory to flush\r
+  Flush type\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    FlushType - add argument and description to function comment\r
+// TODO:    EFI_UNSUPPORTED - add return value to function comment\r
+{\r
+  if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) {\r
+    //\r
+    // Only WB flush is supported. We actually need do nothing on NT emulator\r
+    // environment. Classify this to follow EFI spec\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Other flush types are not supported by NT emulator\r
+  //\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixEnableInterrupt (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine provides support for emulation of the interrupt enable of the\r
+  the system.  For our purposes, CPU enable is just a BOOLEAN that the Timer \r
+  Architectural Protocol observes in order to defer behaviour while in its\r
+  emulated interrupt, or timer tick.\r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  Private                 = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  Private->InterruptState = TRUE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixDisableInterrupt (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine provides support for emulation of the interrupt disable of the\r
+  the system.  For our purposes, CPU enable is just a BOOLEAN that the Timer \r
+  Architectural Protocol observes in order to defer behaviour while in its\r
+  emulated interrupt, or timer tick.\r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  Private                 = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  Private->InterruptState = FALSE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixGetInterruptState (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  OUT BOOLEAN               *State\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine provides support for emulation of the interrupt disable of the\r
+  the system.  For our purposes, CPU enable is just a BOOLEAN that the Timer \r
+  Architectural Protocol observes in order to defer behaviour while in its\r
+  emulated interrupt, or timer tick.\r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    State - add argument and description to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  if (State == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  *State  = Private->InterruptState;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixInit (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_CPU_INIT_TYPE      InitType\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would support generation of a CPU INIT.  At \r
+  present, this code does not provide emulation.  \r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+  INIT Type\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_UNSUPPORTED - not yet implemented\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    InitType - add argument and description to function comment\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixRegisterInterruptHandler (\r
+  IN EFI_CPU_ARCH_PROTOCOL      *This,\r
+  IN EFI_EXCEPTION_TYPE         InterruptType,\r
+  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would support registration of an interrupt handler.  At \r
+  present, this code does not provide emulation.  \r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+  Pointer to interrupt handlers\r
+  Interrupt type\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_UNSUPPORTED - not yet implemented\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    InterruptType - add argument and description to function comment\r
+// TODO:    InterruptHandler - add argument and description to function comment\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  //\r
+  // Do parameter checking for EFI spec conformance\r
+  //\r
+  if (InterruptType < 0 || InterruptType > 0xff) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Do nothing for Nt32 emulation\r
+  //\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixGetTimerValue (\r
+  IN  EFI_CPU_ARCH_PROTOCOL *This,\r
+  IN  UINT32                TimerIndex,\r
+  OUT UINT64                *TimerValue,\r
+  OUT UINT64                *TimerPeriod OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would support querying of an on-CPU timer.  At present, \r
+  this code does not provide timer emulation.  \r
+\r
+Arguments:\r
+\r
+  This        - Pointer to CPU Architectural Protocol interface\r
+  TimerIndex  - Index of given CPU timer\r
+  TimerValue  - Output of the timer\r
+  TimerPeriod - Output of the timer period\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED       - not yet implemented\r
+  EFI_INVALID_PARAMETER - TimeValue is NULL\r
+\r
+--*/\r
+{\r
+  if (TimerValue == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // No timer supported\r
+  //\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSetMemoryAttributes (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
+  IN UINT64                 Length,\r
+  IN UINT64                 Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine would support querying of an on-CPU timer.  At present, \r
+  this code does not provide timer emulation.  \r
+\r
+Arguments:\r
+\r
+  Pointer to CPU Architectural Protocol interface\r
+  Start address of memory region\r
+  The size in bytes of the memory region\r
+  The bit mask of attributes to set for the memory region\r
+\r
+Returns:\r
+\r
+  Status\r
+    EFI_UNSUPPORTED - not yet implemented\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    BaseAddress - add argument and description to function comment\r
+// TODO:    Length - add argument and description to function comment\r
+// TODO:    Attributes - add argument and description to function comment\r
+// TODO:    EFI_INVALID_PARAMETER - add return value to function comment\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  //\r
+  // Check for invalid parameter for Spec conformance\r
+  //\r
+  if (Length == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 emulation\r
+  //\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpu (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize the state information for the CPU Architectural Protocol\r
+\r
+Arguments:\r
+\r
+  ImageHandle of the loaded driver\r
+  Pointer to the System Table\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  EFI_SUCCESS           - protocol instance can be published \r
+  EFI_OUT_OF_RESOURCES  - cannot allocate protocol data structure\r
+  EFI_DEVICE_ERROR      - cannot create the thread\r
+\r
+--*/\r
+// TODO:    SystemTable - add argument and description to function comment\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_EVENT                 Event;\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+  VOID                      *Registration;\r
+\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (CPU_ARCH_PROTOCOL_PRIVATE),\r
+                  (VOID **)&Private\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Private->Signature                    = CPU_ARCH_PROT_PRIVATE_SIGNATURE;\r
+  Private->Cpu.FlushDataCache           = UnixFlushCpuDataCache;\r
+  Private->Cpu.EnableInterrupt          = UnixEnableInterrupt;\r
+  Private->Cpu.DisableInterrupt         = UnixDisableInterrupt;\r
+  Private->Cpu.GetInterruptState        = UnixGetInterruptState;\r
+  Private->Cpu.Init                     = UnixInit;\r
+  Private->Cpu.RegisterInterruptHandler = UnixRegisterInterruptHandler;\r
+  Private->Cpu.GetTimerValue            = UnixGetTimerValue;\r
+  Private->Cpu.SetMemoryAttributes      = UnixSetMemoryAttributes;\r
+\r
+  Private->Cpu.NumberOfTimers           = 0;\r
+  Private->Cpu.DmaBufferAlignment       = 4;\r
+\r
+  Private->InterruptState               = TRUE;\r
+\r
+  Private->CpuIo.Mem.Read   = CpuMemoryServiceRead;\r
+  Private->CpuIo.Mem.Write  = CpuMemoryServiceWrite;\r
+  Private->CpuIo.Io.Read    = CpuIoServiceRead;\r
+  Private->CpuIo.Io.Write   = CpuIoServiceWrite;\r
+\r
+\r
+  Private->Handle                       = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Private->Handle,\r
+                  &gEfiCpuArchProtocolGuid,   &Private->Cpu,\r
+                  &gEfiCpuIoProtocolGuid,     &Private->CpuIo,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Install notify function to store processor data to HII database and data hub.\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  EFI_TPL_CALLBACK,\r
+                  UnixIoProtocolNotifyFunction,\r
+                  ImageHandle,\r
+                  &Event\r
+                  );\r
+  ASSERT (!EFI_ERROR (Status));\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  Event,\r
+                  &Registration\r
+                  );\r
+  ASSERT (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Should be at EFI_D_INFO, but lets us now things are running\r
+  //\r
+  DEBUG ((EFI_D_ERROR, "CPU Architectural Protocol Loaded\n"));\r
+\r
+\r
+  \r
+  return Status;\r
+}\r
+\r
+UINTN\r
+Atoi (\r
+  UINT16  *String\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Convert a unicode string to a UINTN\r
+\r
+Arguments:\r
+  String - Unicode string.\r
+\r
+Returns: \r
+  UINTN of the number represented by String.  \r
+\r
+--*/\r
+{\r
+  UINTN   Number;\r
+  UINT16   *Str;\r
+\r
+  //\r
+  // skip preceeding white space\r
+  //\r
+  Str = String;\r
+  while ((*Str) && (*Str == ' ' || *Str == '"')) {\r
+    Str++;\r
+  }\r
+  //\r
+  // Convert ot a Number\r
+  //\r
+  Number = 0;\r
+  while (*Str != '\0') {\r
+    if ((*Str >= '0') && (*Str <= '9')) {\r
+      Number = (Number * 10) +*Str - '0';\r
+    } else {\r
+      break;\r
+    }\r
+\r
+    Str++;\r
+  }\r
+\r
+  return Number;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+UnixIoProtocolNotifyFunction (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function will log processor version and frequency data to data hub.\r
+\r
+Arguments:\r
+  Event        - Event whose notification function is being invoked.\r
+  Context      - Pointer to the notification function's context.\r
+\r
+Returns:\r
+  None.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_CPU_DATA_RECORD_BUFFER  RecordBuffer;\r
+  EFI_DATA_RECORD_HEADER      *Record;\r
+  EFI_SUBCLASS_TYPE1_HEADER   *DataHeader;\r
+  UINT32                      HeaderSize;\r
+  UINT32                      TotalSize;\r
+  UINTN                       HandleCount;\r
+  UINTN                       HandleIndex;\r
+  UINT64                      MonotonicCount;\r
+  BOOLEAN                     RecordFound;\r
+  EFI_HANDLE                  *HandleBuffer;\r
+  EFI_UNIX_IO_PROTOCOL       *UnixIo;\r
+  EFI_DATA_HUB_PROTOCOL       *DataHub;\r
+  EFI_HII_PROTOCOL            *Hii;\r
+  EFI_HII_HANDLE              StringHandle;\r
+  EFI_HII_PACKAGES            *PackageList;\r
+  STRING_REF                  Token;\r
+\r
+  DataHub         = NULL;\r
+  Token           = 0;\r
+  MonotonicCount  = 0;\r
+  RecordFound     = FALSE;\r
+\r
+  //\r
+  // Retrieve the list of all handles from the handle database\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  &gEfiUnixIoProtocolGuid,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+  //\r
+  // Locate HII protocol\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID **)&Hii);\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+  //\r
+  // Locate DataHub protocol.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **)&DataHub);\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+  //\r
+  // Initialize data record header\r
+  //\r
+  mCpuDataRecordHeader.Instance = 1;\r
+  HeaderSize                    = sizeof (EFI_SUBCLASS_TYPE1_HEADER);\r
+\r
+  RecordBuffer.Raw              = AllocatePool (HeaderSize + EFI_CPU_DATA_MAXIMUM_LENGTH);\r
+  if (RecordBuffer.Raw == NULL) {\r
+    return ;\r
+  }\r
+\r
+  CopyMem (RecordBuffer.Raw, &mCpuDataRecordHeader, HeaderSize);\r
+\r
+  //\r
+  // Search the Handle array to find the CPU model and speed information\r
+  //\r
+  for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {\r
+    Status = gBS->OpenProtocol (\r
+                    HandleBuffer[HandleIndex],\r
+                    &gEfiUnixIoProtocolGuid,\r
+                    (VOID **)&UnixIo,\r
+                    Context,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    if ((UnixIo->UnixThunk->Signature == EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) &&\r
+        CompareGuid (UnixIo->TypeGuid, &gEfiUnixCPUModelGuid)\r
+          ) {\r
+      //\r
+      // Check if this record has been stored in data hub\r
+      //\r
+      do {\r
+        Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);\r
+        if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {\r
+          DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);\r
+          if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) &&\r
+              (DataHeader->RecordType == ProcessorVersionRecordType)\r
+              ) {\r
+            RecordFound = TRUE;\r
+          }\r
+        }\r
+      } while (MonotonicCount != 0);\r
+\r
+      if (RecordFound) {\r
+        RecordFound = FALSE;\r
+        continue;\r
+      }\r
+      //\r
+      // Initialize strings to HII database\r
+      //\r
+      PackageList = PreparePackages (1, &gEfiProcessorProducerGuid, STRING_ARRAY_NAME);\r
+\r
+      Status      = Hii->NewPack (Hii, PackageList, &StringHandle);\r
+      ASSERT (!EFI_ERROR (Status));\r
+\r
+      gBS->FreePool (PackageList);\r
+\r
+      //\r
+      // Store processor version data record to data hub\r
+      //\r
+      Status = Hii->NewString (Hii, NULL, StringHandle, &Token, UnixIo->EnvString);\r
+      ASSERT (!EFI_ERROR (Status));\r
+\r
+      RecordBuffer.DataRecord->DataRecordHeader.RecordType      = ProcessorVersionRecordType;\r
+      RecordBuffer.DataRecord->VariableRecord.ProcessorVersion  = Token;\r
+      TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_VERSION_DATA);\r
+\r
+      Status = DataHub->LogData (\r
+                          DataHub,\r
+                          &gEfiProcessorSubClassGuid,\r
+                          &gEfiProcessorProducerGuid,\r
+                          EFI_DATA_RECORD_CLASS_DATA,\r
+                          RecordBuffer.Raw,\r
+                          TotalSize\r
+                          );\r
+    }\r
+\r
+    if ((UnixIo->UnixThunk->Signature == EFI_UNIX_THUNK_PROTOCOL_SIGNATURE) &&\r
+        CompareGuid (UnixIo->TypeGuid, &gEfiUnixCPUSpeedGuid)\r
+          ) {\r
+      //\r
+      // Check if this record has been stored in data hub\r
+      //\r
+      do {\r
+        Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);\r
+        if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {\r
+          DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);\r
+          if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) &&\r
+              (DataHeader->RecordType == ProcessorCoreFrequencyRecordType)\r
+              ) {\r
+            RecordFound = TRUE;\r
+          }\r
+        }\r
+      } while (MonotonicCount != 0);\r
+\r
+      if (RecordFound) {\r
+        RecordFound = FALSE;\r
+        continue;\r
+      }\r
+      //\r
+      // Store CPU frequency data record to data hub\r
+      //\r
+      RecordBuffer.DataRecord->DataRecordHeader.RecordType                    = ProcessorCoreFrequencyRecordType;\r
+      RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Value    = (UINT16) Atoi (UnixIo->EnvString);\r
+      RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Exponent = 6;\r
+      TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_CORE_FREQUENCY_DATA);\r
+\r
+      Status = DataHub->LogData (\r
+                          DataHub,\r
+                          &gEfiProcessorSubClassGuid,\r
+                          &gEfiProcessorProducerGuid,\r
+                          EFI_DATA_RECORD_CLASS_DATA,\r
+                          RecordBuffer.Raw,\r
+                          TotalSize\r
+                          );\r
+\r
+      gBS->FreePool (RecordBuffer.Raw);\r
+    }\r
+\r
+    gBS->CloseProtocol (\r
+          HandleBuffer[HandleIndex],\r
+          &gEfiUnixIoProtocolGuid,\r
+          Context,\r
+          NULL\r
+          );\r
+  }\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.dxs b/EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.dxs
new file mode 100644 (file)
index 0000000..4f87af4
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Cpu.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/ \r
+\r
+#include <AutoGen.h> \r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  EFI_DATA_HUB_PROTOCOL_GUID  AND\r
+  EFI_HII_PROTOCOL_GUID\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.msa b/EdkUnixPkg/Dxe/UnixThunk/Cpu/Cpu.msa
new file mode 100644 (file)
index 0000000..b6be83f
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>Cpu</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f3794b60-8985-11db-8e53-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Cpu module.</Abstract>\r
+    <Description>This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>Cpu</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HiiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Strings.uni</Filename>\r
+    <Filename>CpuDriver.h</Filename>\r
+    <Filename>Cpu.c</Filename>\r
+    <Filename>CpuIo.c</Filename>\r
+    <Filename>Cpu.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiCpuIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="SOMETIMES_CONSUMED">\r
+      <ProtocolCName>gEfiHiiProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="SOMETIMES_CONSUMED">\r
+      <ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <ProtocolNotify Usage="SOMETIMES_CONSUMED">\r
+      <ProtocolNotifyCName>gEfiUnixIoProtocolGuid</ProtocolNotifyCName>\r
+    </ProtocolNotify>\r
+  </Protocols>\r
+  <DataHubs>\r
+    <DataHubRecord Usage="SOMETIMES_PRODUCED">\r
+      <DataHubCName>ProcessorVersion</DataHubCName>\r
+    </DataHubRecord>\r
+    <DataHubRecord Usage="SOMETIMES_PRODUCED">\r
+      <DataHubCName>ProcessorCoreFrequency</DataHubCName>\r
+    </DataHubRecord>\r
+  </DataHubs>\r
+  <Guids>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiProcessorProducerGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiProcessorSubClassGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiUnixCPUModelGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiUnixCPUSpeedGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>InitializeCpu</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Cpu/CpuDriver.h b/EdkUnixPkg/Dxe/UnixThunk/Cpu/CpuDriver.h
new file mode 100644 (file)
index 0000000..3a838a0
--- /dev/null
@@ -0,0 +1,96 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuDriver.h\r
+\r
+Abstract:\r
+\r
+  NT Emulation Architectural Protocol Driver as defined in Tiano.\r
+\r
+--*/\r
+\r
+#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_\r
+#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_\r
+\r
+\r
+\r
+extern UINT8  STRING_ARRAY_NAME[];\r
+\r
+//\r
+// Internal Data Structures\r
+//\r
+#define CPU_ARCH_PROT_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('c', 'a', 'p', 'd')\r
+\r
+typedef struct {\r
+  UINTN                 Signature;\r
+  EFI_HANDLE            Handle;\r
+\r
+  EFI_CPU_ARCH_PROTOCOL Cpu;\r
+  EFI_CPU_IO_PROTOCOL   CpuIo;\r
+\r
+  //\r
+  // Local Data for CPU interface goes here\r
+  //\r
+  BOOLEAN               InterruptState;\r
+\r
+} CPU_ARCH_PROTOCOL_PRIVATE;\r
+\r
+#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      CPU_ARCH_PROTOCOL_PRIVATE, \\r
+      Cpu, \\r
+      CPU_ARCH_PROT_PRIVATE_SIGNATURE \\r
+      )\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  EFI_CPU_IO_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  );\r
+\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Cpu/CpuIo.c b/EdkUnixPkg/Dxe/UnixThunk/Cpu/CpuIo.c
new file mode 100644 (file)
index 0000000..4aaa431
--- /dev/null
@@ -0,0 +1,335 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  CpuIo.c\r
+\r
+Abstract:\r
+\r
+  This is the code that publishes the CPU I/O Protocol.\r
+  The intent herein is to have a single I/O service that can load\r
+  as early as possible, extend into runtime, and be layered upon by \r
+  the implementations of architectural protocols and the PCI Root\r
+  Bridge I/O Protocol.\r
+\r
+--*/\r
+\r
+#include <CpuDriver.h>\r
+\r
+#define IA32_MAX_IO_ADDRESS   0xFFFF\r
+#define IA32_MAX_MEM_ADDRESS  0xFFFFFFFF\r
+\r
+EFI_CPU_IO_PROTOCOL mCpuIoProtocol;\r
+\r
+EFI_STATUS\r
+CpuIoCheckAddressRange (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer,\r
+  IN  UINT64                            Limit\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  EFI_CPU_IO_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform the Memory Access Read service for the CPU I/O Protocol\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the Memory access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from memory\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  EFI_SUCCESS             - The data was read from or written to the EFI \r
+                            System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, \r
+                            and Count is not valid for this EFI System.\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!Buffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform the Memory Access Read service for the CPU I/O Protocol\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the Memory access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from memory\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
+                            Count is not valid for this EFI System.\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!Buffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This is the service that implements the I/O read\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the I/O access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from I/O space\r
+\r
+Returns:\r
+\r
+  Status\r
+  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
+                            Count is not valid for this EFI System.\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    UserAddress - add argument and description to function comment\r
+// TODO:    UserBuffer - add argument and description to function comment\r
+{\r
+  UINTN       Address;\r
+  EFI_STATUS  Status;\r
+\r
+  if (!UserBuffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Address = (UINTN) UserAddress;\r
+\r
+  if (Width >= EfiCpuIoWidthMaximum) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN EFI_CPU_IO_PROTOCOL                *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  \r
+  This is the service that implements the I/O Write\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the I/O access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from I/O space\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  Status\r
+  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
+                            Count is not valid for this EFI System.\r
+\r
+--*/\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    UserAddress - add argument and description to function comment\r
+// TODO:    UserBuffer - add argument and description to function comment\r
+{\r
+  UINTN       Address;\r
+  EFI_STATUS  Status;\r
+\r
+  if (!UserBuffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Address = (UINTN) UserAddress;\r
+\r
+  if (Width >= EfiCpuIoWidthMaximum) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+CpuIoCheckAddressRange (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer,\r
+  IN  UINT64                            Limit\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Width   - TODO: add argument description\r
+  Address - TODO: add argument description\r
+  Count   - TODO: add argument description\r
+  Buffer  - TODO: add argument description\r
+  Limit   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+  UINTN AlignMask;\r
+\r
+  if (Address > Limit) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // For FiFo type, the target address won't increase during the access, so treat count as 1\r
+  //\r
+  if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {\r
+    Count = 1;\r
+  }\r
+\r
+  Width = Width & 0x03;\r
+  if (Address - 1 + (1 << Width) * Count > Limit) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  AlignMask = (1 << Width) - 1;\r
+  if ((UINTN) Buffer & AlignMask) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/Cpu/Strings.uni b/EdkUnixPkg/Dxe/UnixThunk/Cpu/Strings.uni
new file mode 100644 (file)
index 0000000..fd70fb9
Binary files /dev/null and b/EdkUnixPkg/Dxe/UnixThunk/Cpu/Strings.uni differ
diff --git a/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.c b/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.c
new file mode 100644 (file)
index 0000000..e7f4a24
--- /dev/null
@@ -0,0 +1,87 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixThunk.c\r
+\r
+Abstract:\r
+\r
+  Produce UnixThunk protocol and it's associated device path and controller \r
+  state protocols. UnixThunk is to the emulation environment as \r
+  PCI_ROOT_BRIGE is to real hardware. The UnixBusDriver is the child of this\r
+  driver.\r
+\r
+  Since we are a root hardware abstraction we do not install a Driver Binding\r
+  protocol on this handle. This driver can only support one one UnixThunk protocol\r
+  in the system, since the device path is hard coded.\r
+\r
+--*/\r
+\r
+#include "UnixThunk.h"\r
+\r
+//\r
+// WinNtThunk Device Path Protocol Instance\r
+//\r
+static UNIX_THUNK_DEVICE_PATH mUnixThunkDevicePath = {\r
+  {\r
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
+    (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
+    EFI_UNIX_THUNK_PROTOCOL_GUID,\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    END_DEVICE_PATH_LENGTH,\r
+    0\r
+  }\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeUnixThunk (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Install UnixThunk Protocol and it's associated Device Path protocol\r
+\r
+Arguments:\r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns:\r
+  EFI_SUCEESS - UnixThunk protocol is added or error status from \r
+                gBS->InstallMultiProtocolInterfaces().\r
+\r
+--*/\r
+// TODO:    ImageHandle - add argument and description to function comment\r
+// TODO:    SystemTable - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  ControllerHandle;\r
+\r
+  ControllerHandle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &ControllerHandle,\r
+                  &gEfiUnixThunkProtocolGuid,\r
+                  gUnix,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  &mUnixThunkDevicePath,\r
+                  NULL\r
+                  );\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.dxs b/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.dxs
new file mode 100644 (file)
index 0000000..f0dca99
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixThunk.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.h b/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.h
new file mode 100644 (file)
index 0000000..ce9a2f4
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixThunk.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+// TODO: add protective #ifndef\r
+\r
+\r
+//\r
+// WinNtThunk Device Path Protocol Instance Type\r
+//\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH        Vendor;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} UNIX_THUNK_DEVICE_PATH;\r
+\r
diff --git a/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.msa b/EdkUnixPkg/Dxe/UnixThunk/UnixThunk/UnixThunk.msa
new file mode 100644 (file)
index 0000000..e1f262a
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixThunk</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f38610fc-8985-11db-82d4-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>A DXE driver to produce EFI_UNIX_THUNK_PROTOCOL</Abstract>\r
+    <Description>EFI_UNIX_THUNK_PROTOCOL is a table of pointers to various Unix APIs used by various drivers to accomplish certain task in a Unix emulator.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixThunk</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixThunk.h</Filename>\r
+    <Filename>UnixThunk.c</Filename>\r
+    <Filename>UnixThunk.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>InitializeUnixThunk</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/EdkUnixPkg.spd b/EdkUnixPkg/EdkUnixPkg.spd
new file mode 100644 (file)
index 0000000..f43a44b
--- /dev/null
@@ -0,0 +1,360 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<PackageSurfaceArea  xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <SpdHeader>\r
+    <PackageName>EdkUnixPkg</PackageName>\r
+    <GuidValue>f2805c44-8985-11db-9e98-0040d02b1835</GuidValue>\r
+    <Version>0.3</Version>\r
+    <Abstract>This is the Unix Emulation Environment Platform</Abstract>\r
+    <Description>Reference platform implementation using an emulator.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <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>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </SpdHeader>\r
+  <PackageDefinitions>\r
+    <ReadOnly>true</ReadOnly>\r
+    <RePackage>false</RePackage>\r
+  </PackageDefinitions>\r
+  <LibraryClassDeclarations>\r
+    <LibraryClass Name="EdkGenericBdsLib">\r
+      <IncludeHeader>Include/Library/EdkGenericBdsLib.h</IncludeHeader>\r
+      <HelpText/>\r
+    </LibraryClass>\r
+    <LibraryClass Name="UnixLib">\r
+      <IncludeHeader>Include/Library/UnixLib.h</IncludeHeader>\r
+      <HelpText/>\r
+    </LibraryClass>\r
+  </LibraryClassDeclarations>\r
+  <IndustryStdIncludes>\r
+    <IndustryStdHeader Name="UnixInclude">\r
+      <IncludeHeader>Include/Common/UnixInclude.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="EdkGenericBdsLib">\r
+      <IncludeHeader>Include/library/EdkGenericBdsLib.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="UnixLib">\r
+      <IncludeHeader>Include/library/UnixLib.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="NtAutoscan">\r
+      <IncludeHeader>Include/Ppi/NtAutoscan.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="NtFwh">\r
+      <IncludeHeader>Include/Ppi/NtFwh.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="NtPeiLoadFile">\r
+      <IncludeHeader>Include/Ppi/NtPeiLoadFile.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="NtThunk">\r
+      <IncludeHeader>Include/Ppi/NtThunk.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="UnixIo">\r
+      <IncludeHeader>Include/Protocol/UnixIo.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="UnixThunk">\r
+      <IncludeHeader>Include/Protocol/UnixThunk.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="UnixUgaIo">\r
+      <IncludeHeader>Include/Protocol/UnixUgaIo.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="FlashLayout">\r
+      <IncludeHeader>Include/FlashLayout.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="UnixDxe">\r
+      <IncludeHeader>Include/UnixDxe.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+    <IndustryStdHeader Name="UnixPeim">\r
+      <IncludeHeader>Include/UnixPeim.h</IncludeHeader>\r
+      <HelpText/>\r
+    </IndustryStdHeader>\r
+  </IndustryStdIncludes>\r
+  <MsaFiles>\r
+    <Filename>Dxe/UnixPlatform/MiscSubclass/MiscSubclassDriver.msa</Filename>\r
+    <Filename>Dxe/PlatformBds/PlatformBds.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Bus/BlockIo/UnixBlockIo.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Bus/Console/UnixConsole.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Bus/Uga/UnixUga.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Bus/UnixBusDriver/UnixBusDriver.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Chipset/Metronome/Metronome.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Chipset/RealTimeClock/RealTimeClock.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Chipset/Reset/Reset.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Chipset/Timer/Timer.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/Cpu/Cpu.msa</Filename>\r
+    <Filename>Dxe/UnixThunk/UnixThunk/UnixThunk.msa</Filename>\r
+    <Filename>Library/DxeUnixLib/DxeUnixLib.msa</Filename>\r
+    <Filename>Library/UnixTimerLibNull/UnixTimerLib.msa</Filename>\r
+    <Filename>Library/EdkGenericBdsLib/EdkGenericBdsLib.msa</Filename>\r
+    <Filename>Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa</Filename>\r
+    <Filename>Library/UnixPeCoffLoaderLib/UnixPeCoffLoaderLib.msa</Filename>\r
+    <Filename>Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.msa</Filename>\r
+    <Filename>Logo/Logo.msa</Filename>\r
+    <Filename>Pei/AutoScan/UnixAutoScan.msa</Filename>\r
+    <Filename>Pei/BootMode/BootMode.msa</Filename>\r
+    <Filename>Pei/FirmwareVolume/UnixFwh.msa</Filename>\r
+    <Filename>Pei/FlashMap/FlashMap.msa</Filename>\r
+    <Filename>Pei/UnixStuff/UnixStuff.msa</Filename>\r
+    <Filename>RuntimeDxe/FvbServices/UnixFwh.msa</Filename>\r
+    <Filename>Sec/SecMain.msa</Filename>\r
+  </MsaFiles>\r
+  <PackageHeaders>\r
+    <IncludePkgHeader ModuleType="SEC">Include/UnixPeim.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="PEIM">Include/UnixPeim.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="DXE_DRIVER">Include/UnixDxe.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="DXE_RUNTIME_DRIVER">Include/UnixDxe.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="DXE_SMM_DRIVER">Include/UnixDxe.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="DXE_SAL_DRIVER">Include/UnixDxe.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="UEFI_DRIVER">Include/UnixDxe.h</IncludePkgHeader>\r
+    <IncludePkgHeader ModuleType="USER_DEFINED">Include/UnixPeim.h</IncludePkgHeader>\r
+  </PackageHeaders>\r
+  <GuidDeclarations>\r
+    <Entry Name="EdkUnixPkgTokenSpace">\r
+      <C_Name>gEfiEdkUnixPkgTokenSpaceGuid</C_Name>\r
+      <GuidValue>f2b6838c-8985-11db-9d1c-0040d02b1835</GuidValue>\r
+      <HelpText>All PCD define in EdkUnixPkg is in this token space scope</HelpText>\r
+    </Entry>  \r
+    <Entry Name="UnixVirtualDisks">\r
+      <C_Name>gEfiUnixVirtualDisksGuid</C_Name>\r
+      <GuidValue>f2ba331a-8985-11db-a406-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixPhysicalDisks">\r
+      <C_Name>gEfiUnixPhysicalDisksGuid</C_Name>\r
+      <GuidValue>f2bdcc96-8985-11db-8719-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixFileSystem">\r
+      <C_Name>gEfiUnixFileSystemGuid</C_Name>\r
+      <GuidValue>f2c16b9e-8985-11db-92c8-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixUga">\r
+      <C_Name>gEfiUnixUgaGuid</C_Name>\r
+      <GuidValue>f2c8b80e-8985-11db-93f1-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixConsole">\r
+      <C_Name>gEfiUnixConsoleGuid</C_Name>\r
+      <GuidValue>f2cc5d06-8985-11db-bb19-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixMemory">\r
+      <C_Name>gEfiUnixMemoryGuid</C_Name>\r
+      <GuidValue>f2d006cc-8985-11db-a472-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixCPUModel">\r
+      <C_Name>gEfiUnixCPUModelGuid</C_Name>\r
+      <GuidValue>f2d3b330-8985-11db-8aa3-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixCPUSpeed">\r
+      <C_Name>gEfiUnixCPUSpeedGuid</C_Name>\r
+      <GuidValue>f2d74e5a-8985-11db-9705-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="PcdHob">\r
+      <C_Name>gPcdHobGuid</C_Name>\r
+      <GuidValue>f2de8f12-8985-11db-aabc-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+  </GuidDeclarations>\r
+  <ProtocolDeclarations>\r
+    <Entry Name="UnixIo">\r
+      <C_Name>gEfiUnixIoProtocolGuid</C_Name>\r
+      <GuidValue>f2e23f54-8985-11db-ac79-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixUgaIo">\r
+      <C_Name>gEfiUnixUgaIoProtocolGuid</C_Name>\r
+      <GuidValue>f2e5e2c6-8985-11db-a191-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixThunk">\r
+      <C_Name>gEfiUnixThunkProtocolGuid</C_Name>\r
+      <GuidValue>f2e98868-8985-11db-9a59-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+  </ProtocolDeclarations>\r
+  <PpiDeclarations>\r
+    <Entry Name="UnixAutoScan">\r
+      <C_Name>gPeiUnixAutoScanPpiGuid</C_Name>\r
+      <GuidValue>f2ed3d14-8985-11db-b057-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixFwh">\r
+      <C_Name>gUnixFwhPpiGuid</C_Name>\r
+      <GuidValue>f2f0dc30-8985-11db-a15b-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixPeiLoadFile">\r
+      <C_Name>gUnixPeiLoadFilePpiGuid</C_Name>\r
+      <GuidValue>f2f48768-8985-11db-b8da-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+    <Entry Name="UnixThunk">\r
+      <C_Name>gPeiUnixThunkPpiGuid</C_Name>\r
+      <GuidValue>f2f830f2-8985-11db-806b-0040d02b1835</GuidValue>\r
+      <HelpText/>\r
+    </Entry>\r
+  </PpiDeclarations>\r
+  <PcdDeclarations>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixPhysicalDisk</C_Name>\r
+      <Token>0x00001000</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"E:RW;245760;512"</DefaultValue>\r
+      <HelpText>This PCD defines physical disk which will be simualted as a \r
+        harddisk in simulator. The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixVirtualDisk</C_Name>\r
+      <Token>0x00001001</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"FW;40960;512"</DefaultValue>\r
+      <HelpText>This PCD defines the devices which use a file to emulate a hard disk or \r
+        removable media device.The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixUga</C_Name>\r
+      <Token>0x00001003</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"UGA Window"</DefaultValue>\r
+      <HelpText>This PCD declares the resolutions for the UGA windows.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixFileSystem</C_Name>\r
+      <Token>0x00001004</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L".!..\\..\\..\\..\\..\\EdkShellBinPkg\\bin\\ia32\\Apps"</DefaultValue>\r
+      <HelpText>This PCD defines the windows directory who will be mounted as \r
+        harddisk in simulator.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixMemorySize</C_Name>\r
+      <Token>0x00001005</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"64!64"</DefaultValue>\r
+      <HelpText>This PCD defines the memory size of simulated machine. Simulator will allocate\r
+        the size of PcdUnixMemorySize in windows platform.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixBootMode</C_Name>\r
+      <Token>0x00001006</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>UINT32</DatumType>\r
+      <ValidUsage>FIXED_AT_BUILD PATCHABLE_IN_MODULE</ValidUsage>\r
+      <DefaultValue>1</DefaultValue>\r
+      <HelpText>This PCD defines the boot mode for simualtor. \r
+        The boot mode can be set as following value:\r
+          0x0:  Boot with full configuration.\r
+          0x1:  Boot with minimal configuration.\r
+          0x2:  Boot assume no configuration changes.\r
+          0x3:  Boot with full configuration plus diagnostics.\r
+          0x4:  Boot with default settings.\r
+          0x5:  Boot on S4 resume.\r
+          0x6:  Boot on S5 resume.\r
+          0x10: Boot on S2 resume. \r
+          0x11: Boot on S3 resume.\r
+          0x12: Boot on flash update.\r
+          0x20: Boot in reovery mode.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixCpuModel</C_Name>\r
+      <Token>0x00001007</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"Intel(R) Processor Model"</DefaultValue>\r
+      <HelpText>This PCD defines simulated CPU model string.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixCpuSpeed</C_Name>\r
+      <Token>0x00001008</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"3000"</DefaultValue>\r
+      <HelpText>This PCD defines simulated CPU speed string.\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixFirmwareVolume</C_Name>\r
+      <Token>0x00001009</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>FIXED_AT_BUILD PATCHABLE_IN_MODULE</ValidUsage>\r
+      <DefaultValue>L"..\\Fv\\Fv_Recovery.fd"</DefaultValue>\r
+      <HelpText>This PCD defines the FD file windows path string. Simulator will load the FD file and execute.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixConsole</C_Name>\r
+      <Token>0x0000100a</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>DYNAMIC</ValidUsage>\r
+      <DefaultValue>L"Bus Driver Console Window"</DefaultValue>\r
+      <HelpText>This PCD declares the title string of the text console window. \r
+        such as "My EFI Console".\r
+        The item type of this PCD can only be "DYNAMIC".</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixStatusCodeLibUseForPei</C_Name>\r
+      <Token>0x0000100b</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>BOOLEAN</DatumType>\r
+      <ValidUsage>FEATURE_FLAG</ValidUsage>\r
+      <DefaultValue>FALSE</DefaultValue>\r
+      <HelpText>Select which type of driver the library links against.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry>\r
+      <C_Name>PcdUnixMemorySizeForSecMain</C_Name>\r
+      <Token>0x0000100c</Token>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <DatumType>VOID*</DatumType>\r
+      <ValidUsage>FIXED_AT_BUILD PATCHABLE_IN_MODULE</ValidUsage>\r
+      <DefaultValue>L"64!64"</DefaultValue>\r
+      <HelpText>This PCD defines the memory size of simulated machine. Simulator will allocate\r
+        the size of PcdUnixMemorySizeForSecMain in windows platform.</HelpText>\r
+    </PcdEntry>\r
+  </PcdDeclarations>\r
+</PackageSurfaceArea>
diff --git a/EdkUnixPkg/Include/Common/UnixInclude.h b/EdkUnixPkg/Include/Common/UnixInclude.h
new file mode 100644 (file)
index 0000000..9229646
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+  UnixInclude.h\r
+\r
+Abstract:\r
+  Public include file for the Unix Library\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_INCLUDE_H__\r
+#define __UNIX_INCLUDE_H__\r
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/vfs.h>
+#include <sys/poll.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <time.h>
+#include <utime.h>
+#include <unistd.h>
+#endif\r
diff --git a/EdkUnixPkg/Include/FlashLayout.h b/EdkUnixPkg/Include/FlashLayout.h
new file mode 100644 (file)
index 0000000..1a13f16
--- /dev/null
@@ -0,0 +1,64 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FlashLayout.h\r
+   \r
+Abstract:\r
+\r
+  Platform specific flash layout\r
+\r
+  BugBug: We need a better way\r
+\r
+--*/\r
+\r
+#ifndef __EFI_FLASH_LAYOUT__\r
+#define __EFI_FLASH_LAYOUT__\r
+\r
+//\r
+// Firmware Volume Information for Nt32\r
+// adding one working block before FFS FV,\r
+// and another one for spare block behind FFS FV\r
+//\r
+//\r
+// Note: When block number is changed in .dsc file,\r
+//       this value should be changed accordingly!!!\r
+//\r
+#define FIRMWARE_BLOCK_NUMBER                         0x28\r
+\r
+#define EFI_WINNT_FIRMWARE_OFFSET                     0x0\r
+#define EFI_WINNT_FIRMWARE_LENGTH                     (0x10000 * FIRMWARE_BLOCK_NUMBER)\r
+\r
+#define EFI_WINNT_RUNTIME_UPDATABLE_OFFSET            (EFI_WINNT_FIRMWARE_OFFSET + EFI_WINNT_FIRMWARE_LENGTH)\r
+\r
+#define EFI_WINNT_RUNTIME_UPDATABLE_LENGTH            0x10000\r
+\r
+#define EFI_WINNT_FTW_SPARE_BLOCK_OFFSET              (EFI_WINNT_RUNTIME_UPDATABLE_OFFSET + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH)\r
+\r
+#define EFI_WINNT_FTW_SPARE_BLOCK_LENGTH              0x10000\r
+\r
+#define EFI_WINNT_RUNTIME_UPDATABLE_FV_HEADER_LENGTH  0x48\r
+\r
+#define EFI_VARIABLE_STORE_OFFSET                     EFI_WINNT_RUNTIME_UPDATABLE_OFFSET\r
+\r
+#define EFI_VARIABLE_STORE_LENGTH                     0x00C000\r
+\r
+#define EFI_EVENT_LOG_OFFSET                          (EFI_VARIABLE_STORE_OFFSET + EFI_VARIABLE_STORE_LENGTH)\r
+\r
+#define EFI_EVENT_LOG_LENGTH                          0x002000\r
+\r
+#define EFI_FTW_WORKING_OFFSET                        (EFI_EVENT_LOG_OFFSET + EFI_EVENT_LOG_LENGTH)\r
+\r
+#define EFI_FTW_WORKING_LENGTH                        0x002000\r
+\r
+#endif\r
+\r
diff --git a/EdkUnixPkg/Include/Library/EdkGenericBdsLib.h b/EdkUnixPkg/Include/Library/EdkGenericBdsLib.h
new file mode 100644 (file)
index 0000000..9abda55
--- /dev/null
@@ -0,0 +1,382 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsLib.h\r
+\r
+Abstract:\r
+\r
+  BDS library definition, include the file and data structure\r
+\r
+--*/\r
+\r
+#ifndef _BDS_LIB_H_\r
+#define _BDS_LIB_H_\r
+\r
+extern EFI_HANDLE mBdsImageHandle;\r
+\r
+//\r
+// Constants which are variable names used to access variables\r
+//\r
+#define VarLegacyDevOrder L"LegacyDevOrder"\r
+\r
+//\r
+// Data structures and defines\r
+//\r
+#define FRONT_PAGE_QUESTION_ID  0x0000\r
+#define FRONT_PAGE_DATA_WIDTH   0x01\r
+\r
+//\r
+// ConnectType\r
+//\r
+#define CONSOLE_OUT 0x00000001\r
+#define STD_ERROR   0x00000002\r
+#define CONSOLE_IN  0x00000004\r
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
+\r
+//\r
+// Load Option Attributes defined in EFI Specification\r
+//\r
+#define LOAD_OPTION_ACTIVE              0x00000001\r
+#define LOAD_OPTION_FORCE_RECONNECT     0x00000002\r
+#define IS_LOAD_OPTION_TYPE(_c, _Mask)  (BOOLEAN) (((_c) & (_Mask)) != 0)\r
+\r
+//\r
+// Define Maxmim characters that will be accepted\r
+//\r
+#define MAX_CHAR            480\r
+#define MAX_CHAR_SIZE       (MAX_CHAR * 2)\r
+\r
+#define MIN_ALIGNMENT_SIZE  4\r
+#define ALIGN_SIZE(a)       ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
+\r
+//\r
+// Define maximum characters for boot option variable "BootXXXX"\r
+//\r
+#define BOOT_OPTION_MAX_CHAR 10\r
+\r
+//\r
+// This data structure is the part of BDS_CONNECT_ENTRY that we can hard code.\r
+//\r
+#define BDS_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('B', 'd', 'C', 'O')\r
+\r
+typedef struct {\r
+\r
+  UINTN                     Signature;\r
+  LIST_ENTRY                Link;\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  CHAR16                    *OptionName;\r
+  UINTN                     OptionNumber;\r
+  UINT16                    BootCurrent;\r
+  UINT32                    Attribute;\r
+  CHAR16                    *Description;\r
+  VOID                      *LoadOptions;\r
+  UINT32                    LoadOptionsSize;\r
+\r
+} BDS_COMMON_OPTION;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINTN                     ConnectType;\r
+} BDS_CONSOLE_CONNECT_ENTRY;\r
+\r
+//\r
+// Lib Functions\r
+//\r
+\r
+//\r
+// Bds boot relate lib functions\r
+//\r
+EFI_STATUS\r
+BdsLibUpdateBootOrderList (\r
+  IN  LIST_ENTRY                 *BdsOptionList,\r
+  IN  CHAR16                     *VariableName\r
+  );\r
+\r
+VOID\r
+BdsLibBootNext (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibBootViaBootOption (\r
+  IN  BDS_COMMON_OPTION             * Option,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      * DevicePath,\r
+  OUT UINTN                         *ExitDataSize,\r
+  OUT CHAR16                        **ExitData OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibEnumerateAllBootOption (\r
+  IN OUT LIST_ENTRY    *BdsBootOptionList\r
+  );\r
+\r
+VOID\r
+BdsLibBuildOptionFromHandle (\r
+  IN  EFI_HANDLE      Handle,\r
+  IN  LIST_ENTRY      *BdsBootOptionList\r
+  );\r
+\r
+VOID\r
+BdsLibBuildOptionFromShell (\r
+  IN  EFI_HANDLE                 Handle,\r
+  IN  LIST_ENTRY                 *BdsBootOptionList\r
+  );\r
+\r
+//\r
+// Bds misc lib functions\r
+//\r
+UINT16\r
+BdsLibGetTimeout (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibGetBootMode (\r
+  OUT EFI_BOOT_MODE       *BootMode\r
+  );\r
+\r
+VOID\r
+BdsLibLoadDrivers (\r
+  IN  LIST_ENTRY          *BdsDriverLists\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibBuildOptionFromVar (\r
+  IN  LIST_ENTRY          *BdsCommonOptionList,\r
+  IN  CHAR16              *VariableName\r
+  );\r
+\r
+VOID                      *\r
+BdsLibGetVariableAndSize (\r
+  IN  CHAR16              *Name,\r
+  IN  EFI_GUID            *VendorGuid,\r
+  OUT UINTN               *VariableSize\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibOutputStrings (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *ConOut,\r
+  ...\r
+  );\r
+\r
+BDS_COMMON_OPTION         *\r
+BdsLibVariableToOption (\r
+  IN OUT LIST_ENTRY               *BdsCommonOptionList,\r
+  IN CHAR16                       *VariableName\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibRegisterNewOption (\r
+  IN  LIST_ENTRY                     *BdsOptionList,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
+  IN  CHAR16                         *String,\r
+  IN  CHAR16                         *VariableName\r
+  );\r
+\r
+//\r
+// Bds connect or disconnect driver lib funcion\r
+//\r
+VOID\r
+BdsLibConnectAllDriversToAllControllers (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+BdsLibConnectAll (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibConnectDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibConnectAllEfi (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibDisconnectAllEfi (\r
+  VOID\r
+  );\r
+\r
+//\r
+// Bds console relate lib functions\r
+//\r
+VOID\r
+BdsLibConnectAllConsoles (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibConnectAllDefaultConsoles (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibUpdateConsoleVariable (\r
+  IN  CHAR16                    *ConVarName,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath\r
+  );\r
+\r
+EFI_STATUS\r
+BdsLibConnectConsoleVariable (\r
+  IN  CHAR16                 *ConVarName\r
+  );\r
+\r
+//\r
+// Bds device path relate lib functions\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL  *\r
+BdsLibUnpackDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  );\r
+\r
+BOOLEAN\r
+BdsLibMatchDevicePaths (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Single\r
+  );\r
+\r
+CHAR16                    *\r
+DevicePathToStr (\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  );\r
+\r
+VOID                      *\r
+EfiLibGetVariable (\r
+  IN CHAR16               *Name,\r
+  IN EFI_GUID             *VendorGuid\r
+  );\r
+\r
+//\r
+// Internal definitions\r
+//\r
+typedef struct {\r
+  CHAR16  *str;\r
+  UINTN   len;\r
+  UINTN   maxlen;\r
+} POOL_PRINT;\r
+\r
+typedef struct {\r
+  UINT8 Type;\r
+  UINT8 SubType;\r
+  VOID (*Function) (POOL_PRINT *, VOID *);\r
+} DEVICE_PATH_STRING_TABLE;\r
+\r
+//\r
+// Internal functions\r
+//\r
+EFI_STATUS\r
+BdsBootByDiskSignatureAndPartition (\r
+  IN  BDS_COMMON_OPTION          * Option,\r
+  IN  HARDDRIVE_DEVICE_PATH      * HardDriveDevicePath,\r
+  IN  UINT32                     LoadOptionsSize,\r
+  IN  VOID                       *LoadOptions,\r
+  OUT UINTN                      *ExitDataSize,\r
+  OUT CHAR16                     **ExitData OPTIONAL\r
+  );\r
+\r
+//\r
+// Notes: EFI 64 shadow all option rom\r
+//\r
+#ifdef EFI64\r
+#define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();\r
+VOID\r
+ShadowAllOptionRom();\r
+#else\r
+#define EFI64_SHADOW_ALL_LEGACY_ROM()\r
+#endif\r
+\r
+//\r
+// BBS support macros and functions\r
+//\r
+#ifdef EFI32\r
+#define REFRESH_LEGACY_BOOT_OPTIONS \\r
+        BdsDeleteAllInvalidLegacyBootOptions ();\\r
+        BdsAddNonExistingLegacyBootOptions (); \\r
+        BdsUpdateLegacyDevOrder ()\r
+#else\r
+#define REFRESH_LEGACY_BOOT_OPTIONS\r
+#endif\r
+\r
+EFI_STATUS\r
+BdsDeleteAllInvalidLegacyBootOptions (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsAddNonExistingLegacyBootOptions (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsUpdateLegacyDevOrder (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+BdsRefreshBbsTableForBoot (\r
+  IN BDS_COMMON_OPTION        *Entry\r
+  );\r
+\r
+EFI_STATUS\r
+BdsDeleteBootOption (\r
+  IN UINTN                       OptionNumber,\r
+  IN OUT UINT16                  *BootOrder,\r
+  IN OUT UINTN                   *BootOrderSize\r
+  );\r
+\r
+//\r
+//The interface functions relate with Setup Browser Reset Reminder feature\r
+//\r
+VOID\r
+EnableResetReminderFeature (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+DisableResetReminderFeature (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EnableResetRequired (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+DisableResetRequired (\r
+  VOID\r
+  );\r
+\r
+BOOLEAN\r
+IsResetReminderFeatureEnable (\r
+  VOID\r
+  );\r
+\r
+BOOLEAN\r
+IsResetRequired (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+SetupResetReminder (\r
+  VOID\r
+  );\r
+  \r
+#endif // _BDS_LIB_H_\r
diff --git a/EdkUnixPkg/Include/Library/UnixLib.h b/EdkUnixPkg/Include/Library/UnixLib.h
new file mode 100644 (file)
index 0000000..3ea371a
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixLib.h\r
+\r
+Abstract:\r
+\r
+  Public include file for the Unix Library\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_LIB_H__\r
+#define __UNIX_LIB_H__\r
+\r
+extern EFI_UNIX_THUNK_PROTOCOL  *gUnix;\r
+\r
+#endif
diff --git a/EdkUnixPkg/Include/Ppi/UnixAutoScan.h b/EdkUnixPkg/Include/Ppi/UnixAutoScan.h
new file mode 100644 (file)
index 0000000..17a4c02
--- /dev/null
@@ -0,0 +1,66 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixAutoscan.h\r
+\r
+Abstract:\r
+\r
+Unix Autoscan PPI\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_PEI_AUTOSCAN_H__\r
+#define __UNIX_PEI_AUTOSCAN_H__\r
+\r
+#include <UnixDxe.h>\r
+\r
+#define PEI_UNIX_AUTOSCAN_PPI_GUID \\r
+  { \\r
+    0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_UNIX_AUTOSCAN) (\r
+  IN  UINTN                 Index,\r
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
+  OUT UINT64                *MemorySize\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  This service is called from Index == 0 until it returns EFI_UNSUPPORTED.\r
+  It allows discontiguous memory regions to be supported by the emulator.\r
+  It uses gSystemMemory[] and gSystemMemoryCount that were created by\r
+  parsing the Windows environment variable EFI_MEMORY_SIZE.\r
+  The size comes from the varaible and the address comes from the call to\r
+  WinNtOpenFile. \r
+\r
+Arguments:\r
+  Index      - Which memory region to use\r
+  MemoryBase - Return Base address of memory region\r
+  MemorySize - Return size in bytes of the memory region\r
+\r
+Returns:\r
+  EFI_SUCCESS - If memory region was mapped\r
+  EFI_UNSUPPORTED - If Index is not supported\r
+\r
+--*/\r
+typedef struct {\r
+  PEI_UNIX_AUTOSCAN UnixAutoScan;\r
+} PEI_UNIX_AUTOSCAN_PPI;\r
+\r
+extern EFI_GUID gPeiUnixAutoScanPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/Ppi/UnixFwh.h b/EdkUnixPkg/Include/Ppi/UnixFwh.h
new file mode 100644 (file)
index 0000000..869f4c9
--- /dev/null
@@ -0,0 +1,62 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixFwh.h\r
+\r
+Abstract:\r
+\r
+  Unix FWH PPI as defined in Tiano\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_PEI_FWH_H__\r
+#define __UNIX_PEI_FWH_H__\r
+\r
+#include <UnixDxe.h>\r
+\r
+#define UNIX_FWH_PPI_GUID \\r
+  { \\r
+    0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *UNIX_FWH_INFORMATION) (\r
+  IN     UINTN                  Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   *FdBase,\r
+  IN OUT UINT64                 *FdSize\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Return the FD Size and base address. Since the FD is loaded from a \r
+  file into Windows memory only the SEC will know it's address.\r
+\r
+Arguments:\r
+  Index  - Which FD, starts at zero.\r
+  FdSize - Size of the FD in bytes\r
+  FdBase - Start address of the FD. Assume it points to an FV Header\r
+\r
+Returns:\r
+  EFI_SUCCESS     - Return the Base address and size of the FV\r
+  EFI_UNSUPPORTED - Index does nto map to an FD in the system\r
+\r
+--*/\r
+typedef struct {\r
+  UNIX_FWH_INFORMATION  UnixFwh;\r
+} UNIX_FWH_PPI;\r
+\r
+extern EFI_GUID gUnixFwhPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/Ppi/UnixPeiLoadFile.h b/EdkUnixPkg/Include/Ppi/UnixPeiLoadFile.h
new file mode 100644 (file)
index 0000000..b91c630
--- /dev/null
@@ -0,0 +1,65 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ UnixPeiLoadFile.h\r
+\r
+Abstract:\r
+\r
+  Unix Load File PPI.\r
+\r
+  When the PEI core is done it calls the DXE IPL via PPI\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_PEI_LOAD_FILE_H__\r
+#define __UNIX_PEI_LOAD_FILE_H__\r
+\r
+#include <UnixDxe.h>\r
+\r
+#define UNIX_PEI_LOAD_FILE_GUID \\r
+  { \\r
+    0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *UNIX_PEI_LOAD_FILE) (\r
+  VOID                  *Pe32Data,\r
+  EFI_PHYSICAL_ADDRESS  *ImageAddress,\r
+  UINT64                *ImageSize,\r
+  EFI_PHYSICAL_ADDRESS  *EntryPoint\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Loads and relocates a PE/COFF image into memory.\r
+\r
+Arguments:\r
+  Pe32Data         - The base address of the PE/COFF file that is to be loaded and relocated\r
+  ImageAddress     - The base address of the relocated PE/COFF image\r
+  ImageSize        - The size of the relocated PE/COFF image\r
+  EntryPoint       - The entry point of the relocated PE/COFF image\r
+\r
+Returns:\r
+  EFI_SUCCESS   - The file was loaded and relocated\r
+  EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
+\r
+--*/\r
+typedef struct {\r
+  UNIX_PEI_LOAD_FILE  PeiLoadFileService;\r
+} UNIX_PEI_LOAD_FILE_PPI;\r
+\r
+extern EFI_GUID gUnixPeiLoadFilePpiGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/Ppi/UnixThunk.h b/EdkUnixPkg/Include/Ppi/UnixThunk.h
new file mode 100644 (file)
index 0000000..866bd61
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixThunk.h\r
+\r
+Abstract:\r
+\r
+  Unix Thunk interface PPI\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_PEI_UNIX_THUNK_H__\r
+#define __UNIX_PEI_UNIX_THUNK_H__\r
+\r
+#include <UnixDxe.h>\r
+\r
+#define PEI_UNIX_THUNK_PPI_GUID \\r
+  { \\r
+    0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+typedef\r
+VOID *\r
+(EFIAPI *PEI_UNIX_THUNK_INTERFACE) (\r
+  VOID\r
+  );\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Export of EFI_UNIX_THUNK_PROTOCOL from the Unix SEC.\r
+\r
+Arguments:\r
+  InterfaceBase - Address of the EFI_UNIX_THUNK_PROTOCOL\r
+\r
+Returns:\r
+  EFI_SUCCESS - Data returned\r
+\r
+--*/\r
+typedef struct {\r
+  PEI_UNIX_THUNK_INTERFACE  UnixThunk;\r
+} PEI_UNIX_THUNK_PPI;\r
+\r
+extern EFI_GUID gPeiUnixThunkPpiGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/Protocol/UnixIo.h b/EdkUnixPkg/Include/Protocol/UnixIo.h
new file mode 100644 (file)
index 0000000..6b83c99
--- /dev/null
@@ -0,0 +1,132 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixIo.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_IO_H_\r
+#define _UNIX_IO_H_\r
+\r
+#define EFI_UNIX_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+typedef struct {\r
+  EFI_UNIX_THUNK_PROTOCOL  *UnixThunk;\r
+  EFI_GUID                  *TypeGuid;\r
+  UINT16                    *EnvString;\r
+  UINT16                    InstanceNumber;\r
+} EFI_UNIX_IO_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiUnixIoProtocolGuid;\r
+\r
+//\r
+// The following GUIDs are used in EFI_UNIX_IO_PROTOCOL_GUID\r
+// Device paths. They map 1:1 with NT envirnment variables. The variables\r
+// define what virtual hardware the emulator/UnixBusDriver will produce.\r
+//\r
+//\r
+// EFI_UNIX_VIRTUAL_DISKS\r
+//\r
+#define EFI_UNIX_VIRTUAL_DISKS_GUID \\r
+  { \\r
+    0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixVirtualDisksGuid;\r
+\r
+//\r
+// EFI_UNIX_PHYSICAL_DISKS\r
+//\r
+#define EFI_UNIX_PHYSICAL_DISKS_GUID \\r
+  { \\r
+    0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixPhysicalDisksGuid;\r
+\r
+//\r
+// EFI_UNIX_FILE_SYSTEM\r
+//\r
+#define EFI_UNIX_FILE_SYSTEM_GUID \\r
+  { \\r
+    0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixFileSystemGuid;\r
+\r
+//\r
+// EFI_UNIX_UGA\r
+//\r
+#define EFI_UNIX_UGA_GUID \\r
+  { \\r
+    0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixUgaGuid;\r
+\r
+//\r
+// EFI_UNIX_GOP\r
+//\r
+#define EFI_UNIX_GOP_GUID \\r
+  { \\r
+    0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixGopGuid;\r
+\r
+//\r
+// EFI_UNIX_CONSOLE\r
+//\r
+#define EFI_UNIX_CONSOLE_GUID \\r
+  { \\r
+    0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixConsoleGuid;\r
+\r
+//\r
+// EFI_UNIX_MEMORY\r
+//\r
+#define EFI_UNIX_MEMORY_GUID \\r
+  { \\r
+    0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixMemoryGuid;\r
+\r
+//\r
+// EFI_UNIX_CPU_MODEL\r
+//\r
+#define EFI_UNIX_CPU_MODEL_GUID \\r
+  { \\r
+    0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixCPUModelGuid;\r
+\r
+//\r
+// EFI_UNIX_CPU_SPEED\r
+//\r
+#define EFI_UNIX_CPU_SPEED_GUID \\r
+  { \\r
+    0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+extern EFI_GUID gEfiUnixCPUSpeedGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/Protocol/UnixThunk.h b/EdkUnixPkg/Include/Protocol/UnixThunk.h
new file mode 100644 (file)
index 0000000..aabb9b1
--- /dev/null
@@ -0,0 +1,187 @@
+/*++\r
+\r
+Copyright (c) 2004, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixThunk.h\r
+\r
+Abstract:\r
+\r
+  This protocol allows an EFI driver in the Unix emulation environment\r
+  to make Posix calls.\r
+\r
+  NEVER make an Unix call directly, always make the call via this protocol.\r
+\r
+  There are no This pointers on the protocol member functions as they map\r
+  exactly into Unix system calls.\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_THUNK_H_\r
+#define _UNIX_THUNK_H_\r
+\r
+
+#define EFI_UNIX_THUNK_PROTOCOL_GUID \\r
+  { \\r
+    0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+typedef\r
+VOID\r
+(*UnixSleep) (\r
+  unsigned long Milliseconds\r
+  );\r
+\r
+typedef\r
+VOID\r
+(*UnixExit) (\r
+  int status  // exit code for all threads\r
+  );\r
+\r
+typedef
+VOID
+(*UnixSetTimer) (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
+typedef
+VOID
+(*UnixGetLocalTime) (EFI_TIME *Time);
+typedef
+struct tm *
+(*UnixGmTime)(const time_t *timep);
+typedef
+long
+(*UnixGetTimeZone)(void);
+typedef
+int
+(*UnixGetDayLight)(void);
+typedef
+int
+(*UnixPoll)(struct pollfd *pfd, int nfds, int timeout);
+typedef
+int
+(*UnixRead) (int fd, void *buf, int count);
+typedef
+int
+(*UnixWrite) (int fd, const void *buf, int count);
+typedef
+char *
+(*UnixGetenv) (const char *var);
+typedef
+int
+(*UnixOpen) (const char *name, int flags, int mode);
+typedef
+long int
+(*UnixSeek) (int fd, long int off, int whence);
+typedef
+int
+(*UnixFtruncate) (int fd, long int len);
+typedef
+int
+(*UnixClose) (int fd);
+
+typedef
+int
+(*UnixMkdir)(const char *pathname, mode_t mode);
+typedef
+int
+(*UnixRmDir)(const char *pathname);
+typedef
+int
+(*UnixUnLink)(const char *pathname);
+typedef
+int
+(*UnixGetErrno)(VOID);
+typedef
+DIR *
+(*UnixOpenDir)(const char *pathname);
+typedef
+void
+(*UnixRewindDir)(DIR *dir);
+typedef
+struct dirent *
+(*UnixReadDir)(DIR *dir);
+typedef
+int
+(*UnixCloseDir)(DIR *dir);
+typedef
+int
+(*UnixStat)(const char *path, struct stat *buf);
+typedef
+int
+(*UnixStatFs)(const char *path, struct statfs *buf);
+typedef
+int
+(*UnixRename)(const char *oldpath, const char *newpath);
+typedef
+time_t
+(*UnixMkTime)(struct tm *tm);
+typedef
+int
+(*UnixFSync)(int fd);
+typedef
+int
+(*UnixChmod)(const char *path, mode_t mode);
+typedef
+int
+(*UnixUTime)(const char *filename, const struct utimbuf *buf);
+
+struct _EFI_UNIX_UGA_IO_PROTOCOL;
+typedef
+EFI_STATUS
+(*UnixUgaCreate)(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo,
+                CONST CHAR16 *Title);
+
+//\r
+//\r
+//\r
+\r
+#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('L', 'N', 'X', 'T')\r
+\r
+typedef struct _EFI_UNIX_THUNK_PROTOCOL {\r
+  UINT64                              Signature;\r
+
+  UnixSleep                          Sleep;\r
+  UnixExit                           Exit;\r
+  UnixSetTimer                       SetTimer;
+  UnixGetLocalTime                   GetLocalTime;
+  UnixGmTime                          GmTime;
+  UnixGetTimeZone                     GetTimeZone;
+  UnixGetDayLight                     GetDayLight;
+  UnixPoll                           Poll;
+  UnixRead                           Read;
+  UnixWrite                          Write;
+  UnixGetenv                         Getenv;
+  UnixOpen                           Open;
+  UnixSeek                           Lseek;
+  UnixFtruncate                      FTruncate;
+  UnixClose                          Close;
+  UnixMkdir                           MkDir;
+  UnixRmDir                           RmDir;
+  UnixUnLink                          UnLink;
+  UnixGetErrno                        GetErrno;
+  UnixOpenDir                         OpenDir;
+  UnixRewindDir                       RewindDir;
+  UnixReadDir                         ReadDir;
+  UnixCloseDir                        CloseDir;
+  UnixStat                            Stat;
+  UnixStatFs                          StatFs;
+  UnixRename                          Rename;
+  UnixMkTime                          MkTime;
+  UnixFSync                           FSync;
+  UnixChmod                           Chmod;
+  UnixUTime                           UTime;
+
+  UnixUgaCreate                              UgaCreate;
+
+} EFI_UNIX_THUNK_PROTOCOL;
+\r
+extern EFI_GUID gEfiUnixThunkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/Protocol/UnixUgaIo.h b/EdkUnixPkg/Include/Protocol/UnixUgaIo.h
new file mode 100644 (file)
index 0000000..4ec0bb9
--- /dev/null
@@ -0,0 +1,72 @@
+/*++\r
+\r
+Copyright (c) 2006, Tristan Gingold\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the\r
+BSD License which accompanies this distribution.  The full text of the\r
+license may be found at http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  UnixUgaIo.h\r
+\r
+Abstract:\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_UGA_IO_H_\r
+#define _UNIX_UGA_IO_H_\r
+\r
+#define EFI_UNIX_UGA_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xf2e5e2c6, 0x8985, 0x11db, {0xa1, 0x91, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+  }\r
+\r
+struct _EFI_UNIX_UGA_IO_PROTOCOL;
+typedef struct _EFI_UNIX_UGA_IO_PROTOCOL EFI_UNIX_UGA_IO_PROTOCOL;\r
+
+typedef
+EFI_STATUS
+(*UGAClose)(EFI_UNIX_UGA_IO_PROTOCOL *Uga);
+
+typedef
+EFI_STATUS
+(*UGASize)(EFI_UNIX_UGA_IO_PROTOCOL *Uga, UINT32 Width, UINT32 Height);
+
+typedef
+EFI_STATUS
+(*UGACheckKey)(EFI_UNIX_UGA_IO_PROTOCOL *Uga);
+
+typedef
+EFI_STATUS
+(*UGAGetKey)(EFI_UNIX_UGA_IO_PROTOCOL *Uga, EFI_INPUT_KEY *key);
+
+typedef
+EFI_STATUS\r
+(*UGABlt)(EFI_UNIX_UGA_IO_PROTOCOL *Uga,
+         IN  EFI_UGA_PIXEL                           *BltBuffer OPTIONAL,\r
+         IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
+         IN  UINTN                                   SourceX,\r
+         IN  UINTN                                   SourceY,\r
+         IN  UINTN                                   DestinationX,\r
+         IN  UINTN                                   DestinationY,\r
+         IN  UINTN                                   Width,\r
+         IN  UINTN                                   Height,\r
+         IN  UINTN                                   Delta OPTIONAL);\r
+
+struct _EFI_UNIX_UGA_IO_PROTOCOL {\r
+  VOID                                *Private;
+  UGAClose                            UgaClose;
+  UGASize                             UgaSize;
+  UGACheckKey                         UgaCheckKey;
+  UGAGetKey                           UgaGetKey;
+  UGABlt                              UgaBlt;
+};
+
+\r
+extern EFI_GUID gEfiUnixUgaIoProtocolGuid;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/UnixDxe.h b/EdkUnixPkg/Include/UnixDxe.h
new file mode 100644 (file)
index 0000000..29a0c16
--- /dev/null
@@ -0,0 +1,36 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  UnixDxe.h\r
+\r
+Abstract:\r
+  Public include file for the Unix Library\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_DXE_H__\r
+#define __UNIX_DXE_H__\r
+\r
+#include <Ppi/UnixPeiLoadFile.h>\r
+#include <Ppi/UnixAutoScan.h>\r
+#include <Ppi/UnixThunk.h>\r
+#include <Ppi/UnixFwh.h>\r
+\r
+//\r
+//  UnixIo.h depends on UnixThunk.h\r
+//\r
+\r
+#include <Common/UnixInclude.h>
+#include <Protocol/UnixThunk.h>\r
+#include <Protocol/UnixIo.h>\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Include/UnixPeim.h b/EdkUnixPkg/Include/UnixPeim.h
new file mode 100644 (file)
index 0000000..4ddda91
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  UnixPeim.h\r
+\r
+Abstract:\r
+  Public include file for the Unix Library\r
+\r
+--*/\r
+\r
+#ifndef __UNIX_PEIM_H__\r
+#define __UNIX_PEIM_H__\r
+\r
+#include <Ppi/UnixPeiLoadFile.h>\r
+#include <Ppi/UnixAutoScan.h>\r
+#include <Ppi/UnixThunk.h>\r
+#include <Ppi/UnixFwh.h>\r
+\r
+#include <Protocol/UnixThunk.h>\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Library/DxeUnixLib/DxeUnixLib.msa b/EdkUnixPkg/Library/DxeUnixLib/DxeUnixLib.msa
new file mode 100644 (file)
index 0000000..d77a86e
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>DxeUnixLib</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f39efc84-8985-11db-ad67-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>A library to produce the global variable 'gUnix'</Abstract>\r
+    <Description>This library contains a single global variable 'gUnix' along with a constructor to initialize that global.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DxeUnixLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <Constructor>UnixLibConstructor</Constructor>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Library/DxeUnixLib/UnixLib.c b/EdkUnixPkg/Library/DxeUnixLib/UnixLib.c
new file mode 100644 (file)
index 0000000..99d1550
--- /dev/null
@@ -0,0 +1,48 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixLib.c\r
+\r
+Abstract:\r
+\r
+  Unix Library \r
+\r
+--*/\r
+\r
+\r
+\r
+EFI_UNIX_THUNK_PROTOCOL *gUnix;\r
+\r
+EFI_STATUS\r
+UnixLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_HOB_GUID_TYPE        *GuidHob;\r
+\r
+  GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);\r
+  ASSERT (GuidHob != NULL);\r
+  gUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
+  ASSERT (gUnix != NULL);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsBoot.c b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsBoot.c
new file mode 100644 (file)
index 0000000..755c042
--- /dev/null
@@ -0,0 +1,1097 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsBoot.c\r
+\r
+Abstract:\r
+\r
+  BDS Lib functions which relate with create or process the boot\r
+  option.\r
+\r
+--*/\r
+#include "Performance.h"\r
+\r
+BOOLEAN mEnumBootDevice = FALSE;\r
+\r
+EFI_STATUS\r
+BdsLibDoLegacyBoot (\r
+  IN  BDS_COMMON_OPTION           *Option\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Boot the legacy system with the boot option\r
+\r
+Arguments:\r
+\r
+  Option           - The legacy boot option which have BBS device path\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED  - There is no legacybios protocol, do not support\r
+                     legacy boot.\r
+                         \r
+  EFI_STATUS       - Return the status of LegacyBios->LegacyBoot ().\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL,
+                               (void **)&LegacyBios);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If no LegacyBios protocol we do not support legacy boot\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Notes: if we seperate the int 19, then we don't need to refresh BBS\r
+  //\r
+  BdsRefreshBbsTableForBoot (Option);\r
+\r
+  //\r
+  // Write boot to OS performance data to a file\r
+  //\r
+  PERF_CODE (\r
+    WriteBootToOsPerformanceData ();\r
+  );\r
+\r
+\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Legacy Boot: %S\n", Option->Description));\r
+  return LegacyBios->LegacyBoot (\r
+                      LegacyBios,\r
+                      (BBS_BBS_DEVICE_PATH *) Option->DevicePath,\r
+                      Option->LoadOptionsSize,\r
+                      Option->LoadOptions\r
+                      );\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibBootViaBootOption (\r
+  IN  BDS_COMMON_OPTION             * Option,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      * DevicePath,\r
+  OUT UINTN                         *ExitDataSize,\r
+  OUT CHAR16                        **ExitData OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the boot option follow the EFI 1.1 specification and \r
+  special treat the legacy boot option with BBS_DEVICE_PATH.\r
+\r
+Arguments:\r
+\r
+  Option       - The boot option need to be processed\r
+  \r
+  DevicePath   - The device path which describe where to load \r
+                 the boot image or the legcy BBS device path \r
+                 to boot the legacy OS\r
+\r
+  ExitDataSize - Returned directly from gBS->StartImage ()\r
+\r
+  ExitData     - Returned directly from gBS->StartImage ()\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Status from gBS->StartImage (),\r
+                  or BdsBootByDiskSignatureAndPartition ()\r
+\r
+  EFI_NOT_FOUND - If the Device Path is not found in the system\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_HANDLE                Handle;\r
+  EFI_HANDLE                ImageHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
+  EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
+  EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save;\r
+  EFI_BLOCK_IO_PROTOCOL     *BlkIo;\r
+  VOID                      *Buffer;\r
+\r
+  *ExitDataSize = 0;\r
+  *ExitData     = NULL;\r
+\r
+  //\r
+  // Notes: put EFI64 ROM Shadow Solution\r
+  //\r
+  EFI64_SHADOW_ALL_LEGACY_ROM ();\r
+\r
+  //\r
+  // Notes: this code can be remove after the s3 script table\r
+  // hook on the event EFI_EVENT_SIGNAL_READY_TO_BOOT or\r
+  // EFI_EVENT_SIGNAL_LEGACY_BOOT\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL,
+                               (VOID **)&AcpiS3Save);\r
+  if (!EFI_ERROR (Status)) {\r
+    AcpiS3Save->S3Save (AcpiS3Save, NULL);\r
+  }\r
+  //\r
+  // If it's Device Path that starts with a hard drive path,\r
+  // this routine will do the booting.\r
+  //\r
+  Status = BdsBootByDiskSignatureAndPartition (\r
+            Option,\r
+            (HARDDRIVE_DEVICE_PATH *) DevicePath,\r
+            Option->LoadOptionsSize,\r
+            Option->LoadOptions,\r
+            ExitDataSize,\r
+            ExitData\r
+            );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // If we found a disk signature and partition device path return success\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  EfiSignalEventReadyToBoot ();\r
+\r
+  //\r
+  // Set Boot Current\r
+  //\r
+  gRT->SetVariable (\r
+        L"BootCurrent",\r
+        &gEfiGlobalVariableGuid,\r
+        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+        sizeof (UINT16),\r
+        &Option->BootCurrent\r
+        );\r
+\r
+  if ((DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
+      (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
+    ) {\r
+    //\r
+    // Check to see if we should legacy BOOT. If yes then do the legacy boot\r
+    //\r
+    return BdsLibDoLegacyBoot (Option);\r
+  }\r
+\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Booting EFI 1.1 way %S\n", Option->Description));\r
+\r
+  Status = gBS->LoadImage (\r
+                  TRUE,\r
+                  mBdsImageHandle,\r
+                  DevicePath,\r
+                  NULL,\r
+                  0,\r
+                  &ImageHandle\r
+                  );\r
+\r
+  //\r
+  // If we didn't find an image, we may need to load the default\r
+  // boot behavior for the device.\r
+  //\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Find a Simple File System protocol on the device path. If the remaining\r
+    // device path is set to end then no Files are being specified, so try\r
+    // the removable media file name.\r
+    //\r
+    TempDevicePath = DevicePath;\r
+    Status = gBS->LocateDevicePath (\r
+                    &gEfiSimpleFileSystemProtocolGuid,\r
+                    &TempDevicePath,\r
+                    &Handle\r
+                    );\r
+    if (!EFI_ERROR (Status) && IsDevicePathEnd (TempDevicePath)) {\r
+      FilePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
+      if (FilePath) {\r
+        //\r
+        // Issue a dummy read to the device to check for media change.\r
+        // When the removable media is changed, any Block IO read/write will\r
+        // cause the BlockIo protocol be reinstalled and EFI_MEDIA_CHANGED is\r
+        // returned. After the Block IO protocol is reinstalled, subsequent\r
+        // Block IO read/write will success.\r
+        //\r
+        Status = gBS->HandleProtocol (\r
+                        Handle,\r
+                        &gEfiBlockIoProtocolGuid,\r
+                        (VOID **) &BlkIo\r
+                        );\r
+        if (!EFI_ERROR (Status)) {\r
+          Buffer = AllocatePool (BlkIo->Media->BlockSize);\r
+          if (Buffer != NULL) {\r
+            BlkIo->ReadBlocks (\r
+                     BlkIo,\r
+                     BlkIo->Media->MediaId,\r
+                     0,\r
+                     BlkIo->Media->BlockSize,\r
+                     Buffer\r
+                     );\r
+            gBS->FreePool (Buffer);\r
+          }\r
+        }\r
+\r
+        Status = gBS->LoadImage (\r
+                        TRUE,\r
+                        mBdsImageHandle,\r
+                        FilePath,\r
+                        NULL,\r
+                        0,\r
+                        &ImageHandle\r
+                        );\r
+        if (EFI_ERROR (Status)) {\r
+          //\r
+          // The DevicePath failed, and it's not a valid\r
+          // removable media device.\r
+          //\r
+          goto Done;\r
+        }\r
+      }\r
+    } else {\r
+      Status = EFI_NOT_FOUND;\r
+    }\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // It there is any error from the Boot attempt exit now.\r
+    //\r
+    goto Done;\r
+  }\r
+  //\r
+  // Provide the image with it's load options\r
+  //\r
+  Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
+                               (VOID **) &ImageInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (Option->LoadOptionsSize != 0) {\r
+    ImageInfo->LoadOptionsSize  = Option->LoadOptionsSize;\r
+    ImageInfo->LoadOptions      = Option->LoadOptions;\r
+  }\r
+  //\r
+  // Before calling the image, enable the Watchdog Timer for\r
+  // the 5 Minute period\r
+  //\r
+  gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
+\r
+  Status = gBS->StartImage (ImageHandle, ExitDataSize, ExitData);\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Image Return Status = %r\n", Status));\r
+\r
+  //\r
+  // Clear the Watchdog Timer after the image returns\r
+  //\r
+  gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
+\r
+Done:\r
+  //\r
+  // Clear Boot Current\r
+  //\r
+  gRT->SetVariable (\r
+        L"BootCurrent",\r
+        &gEfiGlobalVariableGuid,\r
+        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+        0,\r
+        &Option->BootCurrent\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsBootByDiskSignatureAndPartition (\r
+  IN  BDS_COMMON_OPTION          * Option,\r
+  IN  HARDDRIVE_DEVICE_PATH      * HardDriveDevicePath,\r
+  IN  UINT32                     LoadOptionsSize,\r
+  IN  VOID                       *LoadOptions,\r
+  OUT UINTN                      *ExitDataSize,\r
+  OUT CHAR16                     **ExitData OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check to see if a hard ware device path was passed in. If it was then search\r
+  all the block IO devices for the passed in hard drive device path. \r
+  \r
+Arguments:\r
+\r
+  Option - The current processing boot option.\r
+\r
+  HardDriveDevicePath - EFI Device Path to boot, if it starts with a hard\r
+                        drive device path.\r
+\r
+  LoadOptionsSize - Passed into gBS->StartImage ()\r
+                    via the loaded image protocol.\r
+\r
+  LoadOptions     - Passed into gBS->StartImage ()\r
+                    via the loaded image protocol.\r
+\r
+  ExitDataSize - returned directly from gBS->StartImage ()\r
+\r
+  ExitData     - returned directly from gBS->StartImage ()\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Status from gBS->StartImage (),\r
+                  or BootByDiskSignatureAndPartition ()\r
+                  \r
+  EFI_NOT_FOUND - If the Device Path is not found in the system\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     BlockIoHandleCount;\r
+  EFI_HANDLE                *BlockIoBuffer;\r
+  EFI_DEVICE_PATH_PROTOCOL  *BlockIoDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *BlockIoHdDevicePath;\r
+  HARDDRIVE_DEVICE_PATH     *TmpHdPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     Index;\r
+  BOOLEAN                   DevicePathMatch;\r
+  HARDDRIVE_DEVICE_PATH     *TempPath;\r
+\r
+  *ExitDataSize = 0;\r
+  *ExitData     = NULL;\r
+\r
+  if ( !((DevicePathType (&HardDriveDevicePath->Header) == MEDIA_DEVICE_PATH) &&\r
+          (DevicePathSubType (&HardDriveDevicePath->Header) == MEDIA_HARDDRIVE_DP))\r
+        ) {\r
+    //\r
+    // If the HardDriveDevicePath does not start with a Hard Drive Device Path\r
+    // exit.\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // The boot device have already been connected\r
+  //\r
+  Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);\r
+  if (EFI_ERROR (Status) || BlockIoHandleCount == 0) {\r
+    //\r
+    // If there was an error or there are no device handles that support\r
+    // the BLOCK_IO Protocol, then return.\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Loop through all the device handles that support the BLOCK_IO Protocol\r
+  //\r
+  for (Index = 0; Index < BlockIoHandleCount; Index++) {\r
+\r
+    Status = gBS->HandleProtocol (BlockIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &BlockIoDevicePath);\r
+    if (EFI_ERROR (Status) || BlockIoDevicePath == NULL) {\r
+      continue;\r
+    }\r
+    //\r
+    // Make PreviousDevicePath == the device path node before the end node\r
+    //\r
+    DevicePath          = BlockIoDevicePath;\r
+    BlockIoHdDevicePath = NULL;\r
+\r
+    //\r
+    // find HardDriver device path node\r
+    //\r
+    while (!IsDevicePathEnd (DevicePath)) {\r
+      if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
+          (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
+          ) {\r
+        BlockIoHdDevicePath = DevicePath;\r
+        break;\r
+      }\r
+\r
+      DevicePath = NextDevicePathNode (DevicePath);\r
+    }\r
+\r
+    if (BlockIoHdDevicePath == NULL) {\r
+      continue;\r
+    }\r
+    //\r
+    // See if the harddrive device path in blockio matches the orig Hard Drive Node\r
+    //\r
+    DevicePathMatch = FALSE;\r
+\r
+    TmpHdPath       = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePath;\r
+    TempPath        = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
+\r
+    //\r
+    // Only several fields will be checked. NOT whole NODE\r
+    //\r
+    if ( TmpHdPath->PartitionNumber == TempPath->PartitionNumber &&\r
+        TmpHdPath->MBRType == TempPath->MBRType &&\r
+        TmpHdPath->SignatureType == TempPath->SignatureType &&\r
+        CompareGuid ((EFI_GUID *) TmpHdPath->Signature, (EFI_GUID *) TempPath->Signature)) {\r
+      //\r
+      // Get the matched device path\r
+      //\r
+      DevicePathMatch = TRUE;\r
+    }\r
+    //\r
+    // Only do the boot, when devicepath match\r
+    //\r
+    if (DevicePathMatch) {\r
+      //\r
+      // Combine the Block IO and Hard Drive Device path together and try\r
+      // to boot from it.\r
+      //\r
+      DevicePath    = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
+      NewDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath);\r
+\r
+      //\r
+      // Recursive boot with new device path\r
+      //\r
+      Status = BdsLibBootViaBootOption (Option, NewDevicePath, ExitDataSize, ExitData);\r
+      if (!EFI_ERROR (Status)) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  gBS->FreePool (BlockIoBuffer);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibDeleteOptionFromHandle (\r
+  IN  EFI_HANDLE                 Handle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Delete the boot option associated with the handle passed in\r
+\r
+Arguments:\r
+\r
+  Handle - The handle which present the device path to create boot option\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Delete the boot option success\r
+\r
+  EFI_NOT_FOUND         - If the Device Path is not found in the system\r
+\r
+  EFI_OUT_OF_RESOURCES  - Lack of memory resource\r
+\r
+  Other                 - Error return value from SetVariable()\r
+\r
+--*/\r
+{\r
+  UINT16                    *BootOrder;\r
+  UINT8                     *BootOptionVar;\r
+  UINTN                     BootOrderSize;\r
+  UINTN                     BootOptionSize;\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  UINT16                    BootOption[BOOT_OPTION_MAX_CHAR];\r
+  UINTN                     DevicePathSize;\r
+  UINTN                     OptionDevicePathSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
+  UINT8                     *TempPtr;\r
+  CHAR16                    *Description;\r
+\r
+  Status        = EFI_SUCCESS;\r
+  BootOrder     = NULL;\r
+  BootOrderSize = 0;\r
+\r
+  BootOrder = BdsLibGetVariableAndSize (\r
+                L"BootOrder",\r
+                &gEfiGlobalVariableGuid,\r
+                &BootOrderSize\r
+                );\r
+  if (NULL == BootOrder) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  DevicePath = DevicePathFromHandle (Handle);\r
+  if (DevicePath == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  DevicePathSize = GetDevicePathSize (DevicePath);\r
+\r
+  Index = 0;\r
+  while (Index < BootOrderSize / sizeof (UINT16)) {\r
+    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
+    BootOptionVar = BdsLibGetVariableAndSize (\r
+                      BootOption,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &BootOptionSize\r
+                      );\r
+    if (NULL == BootOptionVar) {\r
+      gBS->FreePool (BootOrder);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    TempPtr = BootOptionVar;\r
+    TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
+    Description = (CHAR16 *) TempPtr;\r
+    TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+    OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+    OptionDevicePathSize = GetDevicePathSize (OptionDevicePath);\r
+\r
+    //\r
+    // Check whether the device path match\r
+    //\r
+    if ((OptionDevicePathSize == DevicePathSize) &&\r
+        (CompareMem (DevicePath, OptionDevicePath, DevicePathSize) == 0)) {\r
+      BdsDeleteBootOption (BootOrder[Index], BootOrder, &BootOrderSize);\r
+      gBS->FreePool (BootOptionVar);\r
+      break;\r
+    }\r
+\r
+    gBS->FreePool (BootOptionVar);\r
+    Index++;\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  BootOrderSize,\r
+                  BootOrder\r
+                  );\r
+\r
+  gBS->FreePool (BootOrder);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsDeleteAllInvalidEfiBootOption (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Delete all invalid EFI boot options. The probable invalid boot option could\r
+  be Removable media or Network boot device.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Delete all invalid boot option success\r
+\r
+  EFI_NOT_FOUND         - Variable "BootOrder" is not found\r
+\r
+  EFI_OUT_OF_RESOURCES  - Lack of memory resource\r
+\r
+  Other                 - Error return value from SetVariable()\r
+\r
+--*/\r
+{\r
+  UINT16                    *BootOrder;\r
+  UINT8                     *BootOptionVar;\r
+  UINTN                     BootOrderSize;\r
+  UINTN                     BootOptionSize;\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  UINTN                     Index2;\r
+  UINT16                    BootOption[BOOT_OPTION_MAX_CHAR];\r
+  UINTN                     OptionDevicePathSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *LastDeviceNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
+  UINT8                     *TempPtr;\r
+  CHAR16                    *Description;\r
+  EFI_HANDLE                Handle;\r
+  BOOLEAN                   NeedDelete;\r
+\r
+  Status        = EFI_SUCCESS;\r
+  BootOrder     = NULL;\r
+  BootOrderSize = 0;\r
+\r
+  BootOrder = BdsLibGetVariableAndSize (\r
+                L"BootOrder",\r
+                &gEfiGlobalVariableGuid,\r
+                &BootOrderSize\r
+                );\r
+  if (NULL == BootOrder) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  Index = 0;\r
+  while (Index < BootOrderSize / sizeof (UINT16)) {\r
+    UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
+    BootOptionVar = BdsLibGetVariableAndSize (\r
+                      BootOption,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &BootOptionSize\r
+                      );\r
+    if (NULL == BootOptionVar) {\r
+      gBS->FreePool (BootOrder);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    TempPtr = BootOptionVar;\r
+    TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
+    Description = (CHAR16 *) TempPtr;\r
+    TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+    OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+    OptionDevicePathSize = GetDevicePathSize (OptionDevicePath);\r
+\r
+    //\r
+    // Skip legacy boot option (BBS boot device)\r
+    //\r
+    if ((DevicePathType (OptionDevicePath) == BBS_DEVICE_PATH) &&\r
+        (DevicePathSubType (OptionDevicePath) == BBS_BBS_DP)) {\r
+      gBS->FreePool (BootOptionVar);\r
+      Index++;\r
+      continue;\r
+    }\r
+\r
+    TempDevicePath = OptionDevicePath;\r
+    LastDeviceNode = OptionDevicePath;\r
+    while (!EfiIsDevicePathEnd (TempDevicePath)) {\r
+      LastDeviceNode = TempDevicePath;\r
+      TempDevicePath = EfiNextDevicePathNode (TempDevicePath);\r
+    }\r
+    //\r
+    // Skip the boot option that point to a file, since the device path in \r
+    // removable media boot option doesn't contains a file name.\r
+    //\r
+    if (((DevicePathType (LastDeviceNode) == MEDIA_DEVICE_PATH) &&\r
+         (DevicePathSubType (LastDeviceNode) == MEDIA_FILEPATH_DP)) ||\r
+        //\r
+        // Skip boot option for internal Shell, it's always valid\r
+        //\r
+        (EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode) != NULL)) {\r
+      gBS->FreePool (BootOptionVar);\r
+      Index++;\r
+      continue;\r
+    }\r
+\r
+    NeedDelete = TRUE;\r
+    //\r
+    // Check if it's a valid boot option for removable media\r
+    //\r
+    TempDevicePath = OptionDevicePath;\r
+    Status = gBS->LocateDevicePath (\r
+                    &gEfiSimpleFileSystemProtocolGuid,\r
+                    &TempDevicePath,\r
+                    &Handle\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      NeedDelete = FALSE;\r
+    }\r
+    //\r
+    // Check if it's a valid boot option for network boot device\r
+    //\r
+    TempDevicePath = OptionDevicePath;\r
+    Status = gBS->LocateDevicePath (\r
+                    &gEfiLoadFileProtocolGuid,\r
+                    &TempDevicePath,\r
+                    &Handle\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      NeedDelete = FALSE;\r
+    }\r
+\r
+    if (NeedDelete) {\r
+      //\r
+      // Delete this invalid boot option "Boot####"\r
+      //\r
+      Status = gRT->SetVariable (\r
+                      BootOption,\r
+                      &gEfiGlobalVariableGuid,\r
+                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                      0,\r
+                      NULL\r
+                      );\r
+      //\r
+      // Mark this boot option in boot order as deleted\r
+      //\r
+      BootOrder[Index] = 0xffff;\r
+    }\r
+\r
+    gBS->FreePool (BootOptionVar);\r
+    Index++;\r
+  }\r
+\r
+  //\r
+  // Adjust boot order array\r
+  //\r
+  Index2 = 0;\r
+  for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
+    if (BootOrder[Index] != 0xffff) {\r
+      BootOrder[Index2] = BootOrder[Index];\r
+      Index2 ++;\r
+    }\r
+  }\r
+  Status = gRT->SetVariable (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  Index2 * sizeof (UINT16),\r
+                  BootOrder\r
+                  );\r
+\r
+  gBS->FreePool (BootOrder);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibEnumerateAllBootOption (\r
+  IN OUT LIST_ENTRY      *BdsBootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function will enumerate all possible boot device in the system,\r
+  it will only excute once of every boot.\r
+\r
+Arguments:\r
+\r
+  BdsBootOptionList - The header of the link list which indexed all\r
+                      current boot options\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Finished all the boot device enumerate and create\r
+                the boot option base on that boot device\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  UINT16                        BootOptionNumber;\r
+  UINTN                         NumberFileSystemHandles;\r
+  EFI_HANDLE                    *FileSystemHandles;\r
+  EFI_BLOCK_IO_PROTOCOL         *BlkIo;\r
+  UINTN                         Index;\r
+  UINTN                         NumberLoadFileHandles;\r
+  EFI_HANDLE                    *LoadFileHandles;\r
+  VOID                          *ProtocolInstance;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL  *Fv;\r
+  UINTN                         FvHandleCount;\r
+  EFI_HANDLE                    *FvHandleBuffer;\r
+  EFI_FV_FILETYPE               Type;\r
+  UINTN                         Size;\r
+  EFI_FV_FILE_ATTRIBUTES        Attributes;\r
+  UINT32                        AuthenticationStatus;\r
+  EFI_DEVICE_PATH_PROTOCOL      *FilePath;\r
+  EFI_HANDLE                    ImageHandle;\r
+  EFI_LOADED_IMAGE_PROTOCOL     *ImageInfo;\r
+  BOOLEAN                       NeedDelete;\r
+\r
+  BootOptionNumber = 0;\r
+\r
+  //\r
+  // If the boot device enumerate happened, just get the boot\r
+  // device from the boot order variable\r
+  //\r
+  if (mEnumBootDevice) {\r
+    BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Notes: this dirty code is to get the legacy boot option from the\r
+  // BBS table and create to variable as the EFI boot option, it should\r
+  // be removed after the CSM can provide legacy boot option directly\r
+  //\r
+  REFRESH_LEGACY_BOOT_OPTIONS;\r
+\r
+  //\r
+  // Delete invalid boot option\r
+  //\r
+  BdsDeleteAllInvalidEfiBootOption ();\r
+  //\r
+  // Parse removable media\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiSimpleFileSystemProtocolGuid,\r
+        NULL,\r
+        &NumberFileSystemHandles,\r
+        &FileSystemHandles\r
+        );\r
+  for (Index = 0; Index < NumberFileSystemHandles; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    FileSystemHandles[Index],\r
+                    &gEfiBlockIoProtocolGuid,\r
+                    (VOID **) &BlkIo\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      if (!BlkIo->Media->RemovableMedia) {\r
+        //\r
+        // If the file system handle supports a BlkIo protocol,\r
+        // skip the removable media devices\r
+        //\r
+        continue;\r
+      }\r
+    }\r
+\r
+    //\r
+    // Do the removable Media thing. \EFI\BOOT\boot{machinename}.EFI\r
+    //  machinename is ia32, ia64, x64, ...\r
+    //\r
+    FilePath = FileDevicePath (FileSystemHandles[Index], EFI_REMOVABLE_MEDIA_FILE_NAME);\r
+    NeedDelete = TRUE;\r
+    Status = gBS->LoadImage (\r
+                    TRUE,\r
+                    mBdsImageHandle,\r
+                    FilePath,\r
+                    NULL,\r
+                    0,\r
+                    &ImageHandle\r
+                    );\r
+    if (!EFI_ERROR(Status)) {\r
+      //\r
+      // Verify the image is a EFI application (and not a driver)\r
+      //\r
+      Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo);\r
+      ASSERT (!EFI_ERROR(Status));\r
+\r
+      if (ImageInfo->ImageCodeType == EfiLoaderCode) {\r
+        NeedDelete = FALSE;\r
+      }\r
+    }\r
+\r
+    if (NeedDelete) {\r
+      //\r
+      // No such file or the file is not a EFI application, delete this boot option\r
+      //\r
+      BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]);\r
+    } else {\r
+      BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList);\r
+      BootOptionNumber++;\r
+    }\r
+  }\r
+\r
+  if (NumberFileSystemHandles) {\r
+    gBS->FreePool (FileSystemHandles);\r
+  }\r
+  //\r
+  // Parse Network Boot Device\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiSimpleNetworkProtocolGuid,\r
+        NULL,\r
+        &NumberLoadFileHandles,\r
+        &LoadFileHandles\r
+        );\r
+  for (Index = 0; Index < NumberLoadFileHandles; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    LoadFileHandles[Index],\r
+                    &gEfiLoadFileProtocolGuid,\r
+                    (VOID **) &ProtocolInstance\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    BdsLibBuildOptionFromHandle (LoadFileHandles[Index], BdsBootOptionList);\r
+    BootOptionNumber++;\r
+  }\r
+\r
+  if (NumberLoadFileHandles) {\r
+    gBS->FreePool (LoadFileHandles);\r
+  }\r
+  //\r
+  // Check if we have on flash shell\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiFirmwareVolumeProtocolGuid,\r
+        NULL,\r
+        &FvHandleCount,\r
+        &FvHandleBuffer\r
+        );\r
+  for (Index = 0; Index < FvHandleCount; Index++) {\r
+    gBS->HandleProtocol (\r
+          FvHandleBuffer[Index],\r
+          &gEfiFirmwareVolumeProtocolGuid,\r
+          (VOID **) &Fv\r
+          );\r
+\r
+    Status = Fv->ReadFile (\r
+                  Fv,\r
+                  &gEfiShellFileGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  &Type,\r
+                  &Attributes,\r
+                  &AuthenticationStatus\r
+                  );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Skip if no shell file in the FV\r
+      //\r
+      continue;\r
+    }\r
+    //\r
+    // Build the shell boot option\r
+    //\r
+    BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);\r
+    BootOptionNumber++;\r
+  }\r
+\r
+  if (FvHandleCount) {\r
+    gBS->FreePool (FvHandleBuffer);\r
+  }\r
+  //\r
+  // Make sure every boot only have one time\r
+  // boot device enumerate\r
+  //\r
+  BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
+  mEnumBootDevice = TRUE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+BdsLibBuildOptionFromHandle (\r
+  IN  EFI_HANDLE             Handle,\r
+  IN  LIST_ENTRY             *BdsBootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Build the boot option with the handle parsed in\r
+  \r
+Arguments:\r
+\r
+  Handle - The handle which present the device path to create boot option\r
+  \r
+  BdsBootOptionList - The header of the link list which indexed all current\r
+                      boot options\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  CHAR16                    *TempString;\r
+\r
+  DevicePath  = DevicePathFromHandle (Handle);\r
+  TempString  = DevicePathToStr (DevicePath);\r
+\r
+  //\r
+  // Create and register new boot option\r
+  //\r
+  BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, TempString, L"BootOrder");\r
+}\r
+\r
+VOID\r
+BdsLibBuildOptionFromShell (\r
+  IN EFI_HANDLE              Handle,\r
+  IN OUT LIST_ENTRY          *BdsBootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Build the on flash shell boot option with the handle parsed in\r
+  \r
+Arguments:\r
+\r
+  Handle - The handle which present the device path to create on flash shell\r
+           boot option\r
+  \r
+  BdsBootOptionList - The header of the link list which indexed all current\r
+                      boot options\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ShellNode;\r
+\r
+  DevicePath = DevicePathFromHandle (Handle);\r
+\r
+  //\r
+  // Build the shell device path\r
+  //\r
+  EfiInitializeFwVolDevicepathNode (&ShellNode, &gEfiShellFileGuid);\r
+  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &ShellNode);\r
+\r
+  //\r
+  // Create and register the shell boot option\r
+  //\r
+  BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, L"Internal EFI Shell", L"BootOrder");\r
+\r
+}\r
+\r
+VOID\r
+BdsLibBootNext (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Boot from the EFI1.1 spec defined "BootNext" variable\r
+  \r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINT16            *BootNext;\r
+  UINTN             BootNextSize;\r
+  CHAR16            Buffer[20];\r
+  BDS_COMMON_OPTION *BootOption;\r
+  LIST_ENTRY        TempList;\r
+  UINTN             ExitDataSize;\r
+  CHAR16            *ExitData;\r
+\r
+  //\r
+  // Init the boot option name buffer and temp link list\r
+  //\r
+  InitializeListHead (&TempList);\r
+  ZeroMem (Buffer, sizeof (Buffer));\r
+\r
+  BootNext = BdsLibGetVariableAndSize (\r
+              L"BootNext",\r
+              &gEfiGlobalVariableGuid,\r
+              &BootNextSize\r
+              );\r
+\r
+  //\r
+  // Clear the boot next variable first\r
+  //\r
+  if (BootNext != NULL) {\r
+    gRT->SetVariable (\r
+          L"BootNext",\r
+          &gEfiGlobalVariableGuid,\r
+          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+          0,\r
+          BootNext\r
+          );\r
+\r
+    //\r
+    // Start to build the boot option and try to boot\r
+    //\r
+    UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *BootNext);\r
+    BootOption = BdsLibVariableToOption (&TempList, Buffer);\r
+    BdsLibConnectDevicePath (BootOption->DevicePath);\r
+    BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
+  }\r
+\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsBoot.c.orig b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsBoot.c.orig
new file mode 100644 (file)
index 0000000..574c528
--- /dev/null
@@ -0,0 +1,798 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsBoot.c\r
+\r
+Abstract:\r
+\r
+  BDS Lib functions which relate with create or process the boot\r
+  option.\r
+\r
+--*/\r
+#include "Performance.h"\r
+\r
+BOOLEAN mEnumBootDevice = FALSE;\r
+\r
+EFI_STATUS\r
+BdsLibDoLegacyBoot (\r
+  IN  BDS_COMMON_OPTION           *Option\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Boot the legacy system with the boot option\r
+\r
+Arguments:\r
+\r
+  Option           - The legacy boot option which have BBS device path\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED  - There is no legacybios protocol, do not support\r
+                     legacy boot.\r
+                         \r
+  EFI_STATUS       - Return the status of LegacyBios->LegacyBoot ().\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL,
+                               (void **)&LegacyBios);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If no LegacyBios protocol we do not support legacy boot\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Notes: if we seperate the int 19, then we don't need to refresh BBS\r
+  //\r
+  BdsRefreshBbsTableForBoot (Option);\r
+\r
+  //\r
+  // Write boot to OS performance data to a file\r
+  //\r
+  PERF_CODE (\r
+    WriteBootToOsPerformanceData ();\r
+  );\r
+\r
+\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Legacy Boot: %S\n", Option->Description));\r
+  return LegacyBios->LegacyBoot (\r
+                      LegacyBios,\r
+                      (BBS_BBS_DEVICE_PATH *) Option->DevicePath,\r
+                      Option->LoadOptionsSize,\r
+                      Option->LoadOptions\r
+                      );\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibBootViaBootOption (\r
+  IN  BDS_COMMON_OPTION             * Option,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      * DevicePath,\r
+  OUT UINTN                         *ExitDataSize,\r
+  OUT CHAR16                        **ExitData OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the boot option follow the EFI 1.1 specification and \r
+  special treat the legacy boot option with BBS_DEVICE_PATH.\r
+\r
+Arguments:\r
+\r
+  Option       - The boot option need to be processed\r
+  \r
+  DevicePath   - The device path which describe where to load \r
+                 the boot image or the legcy BBS device path \r
+                 to boot the legacy OS\r
+\r
+  ExitDataSize - Returned directly from gBS->StartImage ()\r
+\r
+  ExitData     - Returned directly from gBS->StartImage ()\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Status from gBS->StartImage (),\r
+                  or BdsBootByDiskSignatureAndPartition ()\r
+\r
+  EFI_NOT_FOUND - If the Device Path is not found in the system\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_HANDLE                Handle;\r
+  EFI_HANDLE                ImageHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
+  EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
+  EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save;\r
+\r
+  *ExitDataSize = 0;\r
+  *ExitData     = NULL;\r
+\r
+  //\r
+  // Notes: put EFI64 ROM Shadow Solution\r
+  //\r
+  EFI64_SHADOW_ALL_LEGACY_ROM ();\r
+\r
+  //\r
+  // Notes: this code can be remove after the s3 script table\r
+  // hook on the event EFI_EVENT_SIGNAL_READY_TO_BOOT or\r
+  // EFI_EVENT_SIGNAL_LEGACY_BOOT\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL,
+                               (VOID **)&AcpiS3Save);\r
+  if (!EFI_ERROR (Status)) {\r
+    AcpiS3Save->S3Save (AcpiS3Save, NULL);\r
+  }\r
+  //\r
+  // If it's Device Path that starts with a hard drive path,\r
+  // this routine will do the booting.\r
+  //\r
+  Status = BdsBootByDiskSignatureAndPartition (\r
+            Option,\r
+            (HARDDRIVE_DEVICE_PATH *) DevicePath,\r
+            Option->LoadOptionsSize,\r
+            Option->LoadOptions,\r
+            ExitDataSize,\r
+            ExitData\r
+            );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // If we found a disk signature and partition device path return success\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  EfiSignalEventReadyToBoot ();\r
+\r
+  //\r
+  // Set Boot Current\r
+  //\r
+  gRT->SetVariable (\r
+        L"BootCurrent",\r
+        &gEfiGlobalVariableGuid,\r
+        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+        sizeof (UINT16),\r
+        &Option->BootCurrent\r
+        );\r
+\r
+  if ((DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
+      (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
+    ) {\r
+    //\r
+    // Check to see if we should legacy BOOT. If yes then do the legacy boot\r
+    //\r
+    return BdsLibDoLegacyBoot (Option);\r
+  }\r
+\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Booting EFI 1.1 way %S\n", Option->Description));\r
+\r
+  Status = gBS->LoadImage (\r
+                  TRUE,\r
+                  mBdsImageHandle,\r
+                  DevicePath,\r
+                  NULL,\r
+                  0,\r
+                  &ImageHandle\r
+                  );\r
+\r
+  //\r
+  // If we didn't find an image, we may need to load the default\r
+  // boot behavior for the device.\r
+  //\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Find a Simple File System protocol on the device path. If the remaining\r
+    // device path is set to end then no Files are being specified, so try\r
+    // the removable media file name.\r
+    //\r
+    TempDevicePath = DevicePath;\r
+    Status = gBS->LocateDevicePath (\r
+                    &gEfiSimpleFileSystemProtocolGuid,\r
+                    &TempDevicePath,\r
+                    &Handle\r
+                    );\r
+    if (!EFI_ERROR (Status) && IsDevicePathEnd (TempDevicePath)) {\r
+      FilePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
+      if (FilePath) {\r
+        Status = gBS->LoadImage (\r
+                        TRUE,\r
+                        mBdsImageHandle,\r
+                        FilePath,\r
+                        NULL,\r
+                        0,\r
+                        &ImageHandle\r
+                        );\r
+        if (EFI_ERROR (Status)) {\r
+          //\r
+          // The DevicePath failed, and it's not a valid\r
+          // removable media device.\r
+          //\r
+          goto Done;\r
+        }\r
+      }\r
+    } else {\r
+      Status = EFI_NOT_FOUND;\r
+    }\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // It there is any error from the Boot attempt exit now.\r
+    //\r
+    goto Done;\r
+  }\r
+  //\r
+  // Provide the image with it's load options\r
+  //\r
+  Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
+                               (VOID **) &ImageInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (Option->LoadOptionsSize != 0) {\r
+    ImageInfo->LoadOptionsSize  = Option->LoadOptionsSize;\r
+    ImageInfo->LoadOptions      = Option->LoadOptions;\r
+  }\r
+  //\r
+  // Before calling the image, enable the Watchdog Timer for\r
+  // the 5 Minute period\r
+  //\r
+  gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
+\r
+  Status = gBS->StartImage (ImageHandle, ExitDataSize, ExitData);\r
+  DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Image Return Status = %r\n", Status));\r
+\r
+  //\r
+  // Clear the Watchdog Timer after the image returns\r
+  //\r
+  gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
+\r
+Done:\r
+  //\r
+  // Clear Boot Current\r
+  //\r
+  gRT->SetVariable (\r
+        L"BootCurrent",\r
+        &gEfiGlobalVariableGuid,\r
+        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+        0,\r
+        &Option->BootCurrent\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsBootByDiskSignatureAndPartition (\r
+  IN  BDS_COMMON_OPTION          * Option,\r
+  IN  HARDDRIVE_DEVICE_PATH      * HardDriveDevicePath,\r
+  IN  UINT32                     LoadOptionsSize,\r
+  IN  VOID                       *LoadOptions,\r
+  OUT UINTN                      *ExitDataSize,\r
+  OUT CHAR16                     **ExitData OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check to see if a hard ware device path was passed in. If it was then search\r
+  all the block IO devices for the passed in hard drive device path. \r
+  \r
+Arguments:\r
+\r
+  Option - The current processing boot option.\r
+\r
+  HardDriveDevicePath - EFI Device Path to boot, if it starts with a hard\r
+                        drive device path.\r
+\r
+  LoadOptionsSize - Passed into gBS->StartImage ()\r
+                    via the loaded image protocol.\r
+\r
+  LoadOptions     - Passed into gBS->StartImage ()\r
+                    via the loaded image protocol.\r
+\r
+  ExitDataSize - returned directly from gBS->StartImage ()\r
+\r
+  ExitData     - returned directly from gBS->StartImage ()\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - Status from gBS->StartImage (),\r
+                  or BootByDiskSignatureAndPartition ()\r
+                  \r
+  EFI_NOT_FOUND - If the Device Path is not found in the system\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     BlockIoHandleCount;\r
+  EFI_HANDLE                *BlockIoBuffer;\r
+  EFI_DEVICE_PATH_PROTOCOL  *BlockIoDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *BlockIoHdDevicePath;\r
+  HARDDRIVE_DEVICE_PATH     *TmpHdPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     Index;\r
+  BOOLEAN                   DevicePathMatch;\r
+  HARDDRIVE_DEVICE_PATH     *TempPath;\r
+\r
+  *ExitDataSize = 0;\r
+  *ExitData     = NULL;\r
+\r
+  if ( !((DevicePathType (&HardDriveDevicePath->Header) == MEDIA_DEVICE_PATH) &&\r
+          (DevicePathSubType (&HardDriveDevicePath->Header) == MEDIA_HARDDRIVE_DP))\r
+        ) {\r
+    //\r
+    // If the HardDriveDevicePath does not start with a Hard Drive Device Path\r
+    // exit.\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // The boot device have already been connected\r
+  //\r
+  Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);\r
+  if (EFI_ERROR (Status) || BlockIoHandleCount == 0) {\r
+    //\r
+    // If there was an error or there are no device handles that support\r
+    // the BLOCK_IO Protocol, then return.\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Loop through all the device handles that support the BLOCK_IO Protocol\r
+  //\r
+  for (Index = 0; Index < BlockIoHandleCount; Index++) {\r
+\r
+    Status = gBS->HandleProtocol (BlockIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &BlockIoDevicePath);\r
+    if (EFI_ERROR (Status) || BlockIoDevicePath == NULL) {\r
+      continue;\r
+    }\r
+    //\r
+    // Make PreviousDevicePath == the device path node before the end node\r
+    //\r
+    DevicePath          = BlockIoDevicePath;\r
+    BlockIoHdDevicePath = NULL;\r
+\r
+    //\r
+    // find HardDriver device path node\r
+    //\r
+    while (!IsDevicePathEnd (DevicePath)) {\r
+      if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
+          (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
+          ) {\r
+        BlockIoHdDevicePath = DevicePath;\r
+        break;\r
+      }\r
+\r
+      DevicePath = NextDevicePathNode (DevicePath);\r
+    }\r
+\r
+    if (BlockIoHdDevicePath == NULL) {\r
+      continue;\r
+    }\r
+    //\r
+    // See if the harddrive device path in blockio matches the orig Hard Drive Node\r
+    //\r
+    DevicePathMatch = FALSE;\r
+\r
+    TmpHdPath       = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePath;\r
+    TempPath        = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
+\r
+    //\r
+    // Only several fields will be checked. NOT whole NODE\r
+    //\r
+    if ( TmpHdPath->PartitionNumber == TempPath->PartitionNumber &&\r
+        TmpHdPath->MBRType == TempPath->MBRType &&\r
+        TmpHdPath->SignatureType == TempPath->SignatureType &&\r
+        CompareGuid ((EFI_GUID *) TmpHdPath->Signature, (EFI_GUID *) TempPath->Signature)) {\r
+      //\r
+      // Get the matched device path\r
+      //\r
+      DevicePathMatch = TRUE;\r
+    }\r
+    //\r
+    // Only do the boot, when devicepath match\r
+    //\r
+    if (DevicePathMatch) {\r
+      //\r
+      // Combine the Block IO and Hard Drive Device path together and try\r
+      // to boot from it.\r
+      //\r
+      DevicePath    = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
+      NewDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath);\r
+\r
+      //\r
+      // Recursive boot with new device path\r
+      //\r
+      Status = BdsLibBootViaBootOption (Option, NewDevicePath, ExitDataSize, ExitData);\r
+      if (!EFI_ERROR (Status)) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  gBS->FreePool (BlockIoBuffer);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibEnumerateAllBootOption (\r
+  IN OUT LIST_ENTRY      *BdsBootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function will enumerate all possible boot device in the system,\r
+  it will only excute once of every boot.\r
+\r
+Arguments:\r
+\r
+  BdsBootOptionList - The header of the link list which indexed all\r
+                      current boot options\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Finished all the boot device enumerate and create\r
+                the boot option base on that boot device\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  UINT16                        BootOptionNumber;\r
+  UINTN                         NumberFileSystemHandles;\r
+  EFI_HANDLE                    *FileSystemHandles;\r
+  UINTN                         NumberBlkIoHandles;\r
+  EFI_HANDLE                    *BlkIoHandles;\r
+  EFI_BLOCK_IO_PROTOCOL         *BlkIo;\r
+  UINTN                         Index;\r
+  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
+  UINTN                         NumberLoadFileHandles;\r
+  EFI_HANDLE                    *LoadFileHandles;\r
+  VOID                          *ProtocolInstance;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL  *Fv;\r
+  UINTN                         FvHandleCount;\r
+  EFI_HANDLE                    *FvHandleBuffer;\r
+  EFI_FV_FILETYPE               Type;\r
+  UINTN                         Size;\r
+  EFI_FV_FILE_ATTRIBUTES        Attributes;\r
+  UINT32                        AuthenticationStatus;\r
+\r
+  BootOptionNumber = 0;\r
+\r
+  //\r
+  // If the boot device enumerate happened, just get the boot\r
+  // device from the boot order variable\r
+  //\r
+  if (mEnumBootDevice) {\r
+    BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Notes: this dirty code is to get the legacy boot option from the\r
+  // BBS table and create to variable as the EFI boot option, it should\r
+  // be removed after the CSM can provide legacy boot option directly\r
+  //\r
+  REFRESH_LEGACY_BOOT_OPTIONS;\r
+\r
+  //\r
+  // Check all the block IO to create boot option\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiBlockIoProtocolGuid,\r
+        NULL,\r
+        &NumberBlkIoHandles,\r
+        &BlkIoHandles\r
+        );\r
+  for (Index = 0; Index < NumberBlkIoHandles; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    BlkIoHandles[Index],\r
+                    &gEfiBlockIoProtocolGuid,\r
+                    (VOID **) &BlkIo\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    if (!BlkIo->Media->RemovableMedia) {\r
+      //\r
+      // Skip fixed Media device on first loop interration\r
+      //\r
+      continue;\r
+    }\r
+\r
+    DevicePath = DevicePathFromHandle (BlkIoHandles[Index]);\r
+    if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
+        (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
+        ) {\r
+      //\r
+      // Build the boot option\r
+      //\r
+      BdsLibBuildOptionFromHandle (BlkIoHandles[Index], BdsBootOptionList);\r
+      BootOptionNumber++;\r
+    }\r
+  }\r
+\r
+  if (NumberBlkIoHandles) {\r
+    gBS->FreePool (BlkIoHandles);\r
+  }\r
+  //\r
+  // Parse Fixed Disk Devices.\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiSimpleFileSystemProtocolGuid,\r
+        NULL,\r
+        &NumberFileSystemHandles,\r
+        &FileSystemHandles\r
+        );\r
+  for (Index = 0; Index < NumberFileSystemHandles; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    FileSystemHandles[Index],\r
+                    &gEfiBlockIoProtocolGuid,\r
+                    (VOID **) &BlkIo\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      if (BlkIo->Media->RemovableMedia) {\r
+        //\r
+        // If the file system handle supports a BlkIo protocol,\r
+        // skip the removable media devices\r
+        //\r
+        continue;\r
+      }\r
+    }\r
+\r
+    DevicePath = DevicePathFromHandle (FileSystemHandles[Index]);\r
+    if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && \r
+        (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)\r
+        ) {\r
+      //\r
+      // If the FileSystem protocol does not contain a BlkIo protocol,\r
+      // then build it\r
+      //\r
+      BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList);\r
+      BootOptionNumber++;\r
+    }\r
+  }\r
+\r
+  if (NumberFileSystemHandles) {\r
+    gBS->FreePool (FileSystemHandles);\r
+  }\r
+  //\r
+  // Parse Network Boot Device\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiSimpleNetworkProtocolGuid,\r
+        NULL,\r
+        &NumberLoadFileHandles,\r
+        &LoadFileHandles\r
+        );\r
+  for (Index = 0; Index < NumberLoadFileHandles; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    LoadFileHandles[Index],\r
+                    &gEfiLoadFileProtocolGuid,\r
+                    (VOID **) &ProtocolInstance\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    BdsLibBuildOptionFromHandle (LoadFileHandles[Index], BdsBootOptionList);\r
+    BootOptionNumber++;\r
+  }\r
+\r
+  if (NumberLoadFileHandles) {\r
+    gBS->FreePool (LoadFileHandles);\r
+  }\r
+  //\r
+  // Check if we have on flash shell\r
+  //\r
+  gBS->LocateHandleBuffer (\r
+        ByProtocol,\r
+        &gEfiFirmwareVolumeProtocolGuid,\r
+        NULL,\r
+        &FvHandleCount,\r
+        &FvHandleBuffer\r
+        );\r
+  for (Index = 0; Index < FvHandleCount; Index++) {\r
+    gBS->HandleProtocol (\r
+          FvHandleBuffer[Index],\r
+          &gEfiFirmwareVolumeProtocolGuid,\r
+          (VOID **) &Fv\r
+          );\r
+\r
+    Status = Fv->ReadFile (\r
+                  Fv,\r
+                  &gEfiShellFileGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  &Type,\r
+                  &Attributes,\r
+                  &AuthenticationStatus\r
+                  );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Skip if no shell file in the FV\r
+      //\r
+      continue;\r
+    }\r
+    //\r
+    // Build the shell boot option\r
+    //\r
+    BdsLibBuildOptionFromShell (FvHandleBuffer[Index], BdsBootOptionList);\r
+    BootOptionNumber++;\r
+  }\r
+\r
+  if (FvHandleCount) {\r
+    gBS->FreePool (FvHandleBuffer);\r
+  }\r
+  //\r
+  // Make sure every boot only have one time\r
+  // boot device enumerate\r
+  //\r
+  BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
+  mEnumBootDevice = TRUE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+BdsLibBuildOptionFromHandle (\r
+  IN  EFI_HANDLE             Handle,\r
+  IN  LIST_ENTRY             *BdsBootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Build the boot option with the handle parsed in\r
+  \r
+Arguments:\r
+\r
+  Handle - The handle which present the device path to create boot option\r
+  \r
+  BdsBootOptionList - The header of the link list which indexed all current\r
+                      boot options\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  CHAR16                    *TempString;\r
+\r
+  DevicePath  = DevicePathFromHandle (Handle);\r
+  TempString  = DevicePathToStr (DevicePath);\r
+\r
+  //\r
+  // Create and register new boot option\r
+  //\r
+  BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, TempString, L"BootOrder");\r
+}\r
+\r
+VOID\r
+BdsLibBuildOptionFromShell (\r
+  IN EFI_HANDLE              Handle,\r
+  IN OUT LIST_ENTRY          *BdsBootOptionList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Build the on flash shell boot option with the handle parsed in\r
+  \r
+Arguments:\r
+\r
+  Handle - The handle which present the device path to create on flash shell\r
+           boot option\r
+  \r
+  BdsBootOptionList - The header of the link list which indexed all current\r
+                      boot options\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ShellNode;\r
+\r
+  DevicePath = DevicePathFromHandle (Handle);\r
+\r
+  //\r
+  // Build the shell device path\r
+  //\r
+  EfiInitializeFwVolDevicepathNode (&ShellNode, &gEfiShellFileGuid);\r
+  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &ShellNode);\r
+\r
+  //\r
+  // Create and register the shell boot option\r
+  //\r
+  BdsLibRegisterNewOption (BdsBootOptionList, DevicePath, L"Internal EFI Shell", L"BootOrder");\r
+\r
+}\r
+\r
+VOID\r
+BdsLibBootNext (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Boot from the EFI1.1 spec defined "BootNext" variable\r
+  \r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  UINT16            *BootNext;\r
+  UINTN             BootNextSize;\r
+  CHAR16            Buffer[20];\r
+  BDS_COMMON_OPTION *BootOption;\r
+  LIST_ENTRY        TempList;\r
+  UINTN             ExitDataSize;\r
+  CHAR16            *ExitData;\r
+\r
+  //\r
+  // Init the boot option name buffer and temp link list\r
+  //\r
+  InitializeListHead (&TempList);\r
+  ZeroMem (Buffer, sizeof (Buffer));\r
+\r
+  BootNext = BdsLibGetVariableAndSize (\r
+              L"BootNext",\r
+              &gEfiGlobalVariableGuid,\r
+              &BootNextSize\r
+              );\r
+\r
+  //\r
+  // Clear the boot next variable first\r
+  //\r
+  if (BootNext != NULL) {\r
+    gRT->SetVariable (\r
+          L"BootNext",\r
+          &gEfiGlobalVariableGuid,\r
+          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+          0,\r
+          BootNext\r
+          );\r
+\r
+    //\r
+    // Start to build the boot option and try to boot\r
+    //\r
+    UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *BootNext);\r
+    BootOption = BdsLibVariableToOption (&TempList, Buffer);\r
+    BdsLibConnectDevicePath (BootOption->DevicePath);\r
+    BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
+  }\r
+\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsConnect.c b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsConnect.c
new file mode 100644 (file)
index 0000000..9c649f1
--- /dev/null
@@ -0,0 +1,357 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsConnect.c\r
+\r
+Abstract:\r
+\r
+  BDS Lib functions which relate with connect the device\r
+\r
+--*/\r
+\r
+VOID\r
+BdsLibConnectAll (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This function will connect all the system driver to controller\r
+  first, and then special connect the default console, this make\r
+  sure all the system controller avialbe and the platform default\r
+  console connected.\r
+  \r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Connect the platform console first\r
+  //\r
+  BdsLibConnectAllDefaultConsoles ();\r
+\r
+  //\r
+  // Generic way to connect all the drivers\r
+  //\r
+  BdsLibConnectAllDriversToAllControllers ();\r
+\r
+  //\r
+  // Here we have the assumption that we have already had\r
+  // platform default console\r
+  //\r
+  BdsLibConnectAllDefaultConsoles ();\r
+}\r
+\r
+VOID\r
+BdsLibGenericConnectAll (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This function will connect all the system drivers to all controllers\r
+  first, and then connect all the console devices the system current \r
+  have. After this we should get all the device work and console avariable\r
+  if the system have console device.\r
+  \r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  //\r
+  // Most generic way to connect all the drivers\r
+  //\r
+  BdsLibConnectAllDriversToAllControllers ();\r
+  BdsLibConnectAllConsoles ();\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibConnectDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function will create all handles associate with every device\r
+  path node. If the handle associate with one device path node can not\r
+  be created success, then still give one chance to do the dispatch,\r
+  which load the missing drivers if possible.\r
+  \r
+Arguments:\r
+\r
+  DevicePathToConnect  - The device path which will be connected, it can\r
+                         be a multi-instance device path\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - All handles associate with every device path \r
+                         node have been created\r
+  \r
+  EFI_OUT_OF_RESOURCES - There is no resource to create new handles\r
+  \r
+  EFI_NOT_FOUND        - Create the handle associate with one device \r
+                         path node failed\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
+  EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
+  EFI_HANDLE                Handle;\r
+  EFI_HANDLE                PreviousHandle;\r
+  UINTN                     Size;\r
+\r
+  if (DevicePathToConnect == NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  DevicePath        = DuplicateDevicePath (DevicePathToConnect);\r
+  CopyOfDevicePath  = DevicePath;\r
+  if (DevicePath == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  do {\r
+    //\r
+    // The outer loop handles multi instance device paths.\r
+    // Only console variables contain multiple instance device paths.\r
+    //\r
+    // After this call DevicePath points to the next Instance\r
+    //\r
+    Instance  = GetNextDevicePathInstance (&DevicePath, &Size);\r
+    Next      = Instance;\r
+    while (!IsDevicePathEndType (Next)) {\r
+      Next = NextDevicePathNode (Next);\r
+    }\r
+\r
+    SetDevicePathEndNode (Next);\r
+\r
+    //\r
+    // Start the real work of connect with RemainingDevicePath\r
+    //\r
+    PreviousHandle = NULL;\r
+    do {\r
+      //\r
+      // Find the handle that best matches the Device Path. If it is only a\r
+      // partial match the remaining part of the device path is returned in\r
+      // RemainingDevicePath.\r
+      //\r
+      RemainingDevicePath = Instance;\r
+      Status              = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);\r
+\r
+      if (!EFI_ERROR (Status)) {\r
+        if (Handle == PreviousHandle) {\r
+          //\r
+          // If no forward progress is made try invoking the Dispatcher.\r
+          // A new FV may have been added to the system an new drivers\r
+          // may now be found.\r
+          // Status == EFI_SUCCESS means a driver was dispatched\r
+          // Status == EFI_NOT_FOUND means no new drivers were dispatched\r
+          //\r
+          Status = gDS->Dispatch ();\r
+        }\r
+\r
+        if (!EFI_ERROR (Status)) {\r
+          PreviousHandle = Handle;\r
+          //\r
+          // Connect all drivers that apply to Handle and RemainingDevicePath,\r
+          // the Recursive flag is FALSE so only one level will be expanded.\r
+          //\r
+          // Do not check the connect status here, if the connect controller fail,\r
+          // then still give the chance to do dispatch, because partial\r
+          // RemainingDevicepath may be in the new FV\r
+          //\r
+          // 1. If the connect fail, RemainingDevicepath and handle will not\r
+          //    change, so next time will do the dispatch, then dispatch's status\r
+          //    will take effect\r
+          // 2. If the connect success, the RemainingDevicepath and handle will\r
+          //    change, then avoid the dispatch, we have chance to continue the\r
+          //    next connection\r
+          //\r
+          gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);\r
+        }\r
+      }\r
+      //\r
+      // Loop until RemainingDevicePath is an empty device path\r
+      //\r
+    } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));\r
+\r
+  } while (DevicePath != NULL);\r
+\r
+  if (CopyOfDevicePath != NULL) {\r
+    gBS->FreePool (CopyOfDevicePath);\r
+  }\r
+  //\r
+  // All handle with DevicePath exists in the handle database\r
+  //\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibConnectAllEfi (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function will connect all current system handles recursively. The\r
+  connection will finish until every handle's child handle created if it have.\r
+  \r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - All handles and it's child handle have been connected\r
+  \r
+  EFI_STATUS           - Return the status of gBS->LocateHandleBuffer(). \r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       HandleCount;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       Index;\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
+  }\r
+\r
+  gBS->FreePool (HandleBuffer);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibDisconnectAllEfi (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function will disconnect all current system handles. The disconnection\r
+  will finish until every handle have been disconnected.\r
+  \r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - All handles have been disconnected\r
+  \r
+  EFI_STATUS           - Return the status of gBS->LocateHandleBuffer(). \r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       HandleCount;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       Index;\r
+\r
+  //\r
+  // Disconnect all\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
+  }\r
+\r
+  gBS->FreePool (HandleBuffer);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+BdsLibConnectAllDriversToAllControllers (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Connects all drivers to all controllers. \r
+  This function make sure all the current system driver will manage\r
+  the correspoinding controllers if have. And at the same time, make\r
+  sure all the system controllers have driver to manage it if have. \r
+  \r
+Arguments:\r
+  \r
+  None\r
+  \r
+Returns:\r
+  \r
+  None\r
+  \r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  do {\r
+    //\r
+    // Connect All EFI 1.10 drivers following EFI 1.10 algorithm\r
+    //\r
+    BdsLibConnectAllEfi ();\r
+\r
+    //\r
+    // Check to see if it's possible to dispatch an more DXE drivers.\r
+    // The BdsLibConnectAllEfi () may have made new DXE drivers show up.\r
+    // If anything is Dispatched Status == EFI_SUCCESS and we will try\r
+    // the connect again.\r
+    //\r
+    Status = gDS->Dispatch ();\r
+\r
+  } while (!EFI_ERROR (Status));\r
+\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsConsole.c b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsConsole.c
new file mode 100644 (file)
index 0000000..721d743
--- /dev/null
@@ -0,0 +1,370 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsConsole.c\r
+\r
+Abstract:\r
+\r
+  BDS Lib functions which contain all the code to connect console device\r
+\r
+--*/\r
+\r
+EFI_STATUS\r
+BdsLibUpdateConsoleVariable (\r
+  IN  CHAR16                    *ConVarName,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function update console variable based on ConVarName, it can \r
+  add or remove one specific console device path from the variable\r
+\r
+Arguments:\r
+\r
+  ConVarName   - Console related variable name, ConIn, ConOut, ErrOut.\r
+\r
+  CustomizedConDevicePath - The console device path which will be added to\r
+                            the console variable ConVarName, this parameter\r
+                            can not be multi-instance.\r
+\r
+  ExclusiveDevicePath     - The console device path which will be removed\r
+                            from the console variable ConVarName, this\r
+                            parameter can not be multi-instance.\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED         - Add or remove the same device path.\r
+  \r
+  EFI_SUCCESS             - Success add or remove the device path from \r
+                            the console variable.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *VarConsole;\r
+  UINTN                     DevicePathSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+\r
+  VarConsole      = NULL;\r
+  DevicePathSize  = 0;\r
+  NewDevicePath   = NULL;\r
+  Status          = EFI_UNSUPPORTED;\r
+\r
+  //\r
+  // Notes: check the device path point, here should check\r
+  // with compare memory\r
+  //\r
+  if (CustomizedConDevicePath == ExclusiveDevicePath) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Delete the ExclusiveDevicePath from current default console\r
+  //\r
+  VarConsole = BdsLibGetVariableAndSize (\r
+                ConVarName,\r
+                &gEfiGlobalVariableGuid,\r
+                &DevicePathSize\r
+                );\r
+\r
+  if (ExclusiveDevicePath != NULL && VarConsole != NULL) {\r
+    if (BdsLibMatchDevicePaths (VarConsole, ExclusiveDevicePath)) {\r
+\r
+      Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);\r
+\r
+      while (VarConsole != NULL) {\r
+        if (CompareMem (\r
+              Instance,\r
+              ExclusiveDevicePath,\r
+              DevicePathSize - sizeof (EFI_DEVICE_PATH_PROTOCOL)\r
+              ) == 0) {\r
+          //\r
+          // Remove the match part\r
+          //\r
+          NewDevicePath = AppendDevicePathInstance (NewDevicePath, VarConsole);\r
+          break;\r
+        } else {\r
+          //\r
+          // Continue the next instance\r
+          //\r
+          NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);\r
+        }\r
+\r
+        Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);\r
+      }\r
+      //\r
+      // Reset the console variable with new device path\r
+      //\r
+      gRT->SetVariable (\r
+            ConVarName,\r
+            &gEfiGlobalVariableGuid,\r
+            EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+            GetDevicePathSize (NewDevicePath),\r
+            NewDevicePath\r
+            );\r
+    }\r
+  }\r
+  //\r
+  // Try to append customized device path\r
+  //\r
+  VarConsole = BdsLibGetVariableAndSize (\r
+                ConVarName,\r
+                &gEfiGlobalVariableGuid,\r
+                &DevicePathSize\r
+                );\r
+\r
+  if (CustomizedConDevicePath != NULL) {\r
+    if (!BdsLibMatchDevicePaths (VarConsole, CustomizedConDevicePath)) {\r
+      //\r
+      // In the first check, the default console variable will be null,\r
+      // just append current customized device path\r
+      //\r
+      VarConsole = AppendDevicePathInstance (VarConsole, CustomizedConDevicePath);\r
+\r
+      //\r
+      // Update the variable of the default console\r
+      //\r
+      gRT->SetVariable (\r
+            ConVarName,\r
+            &gEfiGlobalVariableGuid,\r
+            EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+            GetDevicePathSize (VarConsole),\r
+            VarConsole\r
+            );\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibConnectConsoleVariable (\r
+  IN  CHAR16                 *ConVarName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Connect the console device base on the variable ConVarName, if\r
+  device path of the ConVarName is multi-instance device path, if\r
+  anyone of the instances is connected success, then this function\r
+  will return success.\r
+\r
+Arguments:\r
+\r
+  ConVarName   - Console related variable name, ConIn, ConOut, ErrOut.\r
+\r
+Returns:\r
+\r
+  EFI_NOT_FOUND           - There is not any console devices connected success\r
+  \r
+  EFI_SUCCESS             - Success connect any one instance of the console\r
+                            device path base on the variable ConVarName.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *StartDevicePath;\r
+  UINTN                     VariableSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Next;\r
+  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;\r
+  UINTN                     Size;\r
+  BOOLEAN                   DeviceExist;\r
+\r
+  Status      = EFI_SUCCESS;\r
+  DeviceExist = FALSE;\r
+\r
+  //\r
+  // Check if the console variable exist\r
+  //\r
+  StartDevicePath = BdsLibGetVariableAndSize (\r
+                      ConVarName,\r
+                      &gEfiGlobalVariableGuid,\r
+                      &VariableSize\r
+                      );\r
+  if (StartDevicePath == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  CopyOfDevicePath = DuplicateDevicePath (StartDevicePath);\r
+  do {\r
+    //\r
+    // Check every instance of the console variable\r
+    //\r
+    Instance  = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);\r
+    Next      = Instance;\r
+    while (!IsDevicePathEndType (Next)) {\r
+      Next = NextDevicePathNode (Next);\r
+    }\r
+\r
+    SetDevicePathEndNode (Next);\r
+\r
+    //\r
+    // Connect the instance device path\r
+    //\r
+    Status = BdsLibConnectDevicePath (Instance);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Delete the instance from the console varialbe\r
+      //\r
+      BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);\r
+    } else {\r
+      DeviceExist = TRUE;\r
+    }\r
+\r
+  } while (CopyOfDevicePath != NULL);\r
+\r
+  gBS->FreePool (StartDevicePath);\r
+\r
+  if (DeviceExist == FALSE) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+BdsLibConnectAllConsoles (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function will search every simpletxt devive in current system,\r
+  and make every simpletxt device as pertantial console device.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ConDevicePath;\r
+  UINTN                     HandleCount;\r
+  EFI_HANDLE                *HandleBuffer;\r
+\r
+  Index         = 0;\r
+  HandleCount   = 0;\r
+  HandleBuffer  = NULL;\r
+  ConDevicePath = NULL;\r
+\r
+  //\r
+  // Update all the console varables\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiSimpleTextInProtocolGuid,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    HandleBuffer[Index],\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID **) &ConDevicePath\r
+                    );\r
+    BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);\r
+  }\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiSimpleTextOutProtocolGuid,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
+    Status = gBS->HandleProtocol (\r
+                    HandleBuffer[Index],\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID **) &ConDevicePath\r
+                    );\r
+    BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);\r
+    BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);\r
+  }\r
+  //\r
+  // Connect all console variables\r
+  //\r
+  BdsLibConnectAllDefaultConsoles ();\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibConnectAllDefaultConsoles (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function will connect console device base on the console \r
+  device variable ConIn, ConOut and ErrOut.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS      - At least one of the ConIn and ConOut device have\r
+                     been connected success.\r
+                     \r
+  EFI_STATUS       - Return the status of BdsLibConnectConsoleVariable ().\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *VarErrout;\r
+  UINTN                     DevicePathSize;\r
+\r
+  //\r
+  // Connect all default console variables\r
+  //\r
+  Status = BdsLibConnectConsoleVariable (L"ConIn");\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = BdsLibConnectConsoleVariable (L"ConOut");\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Special treat the err out device, becaues the null\r
+  // err out var is legal.\r
+  //\r
+  VarErrout = BdsLibGetVariableAndSize (\r
+                L"ErrOut",\r
+                &gEfiGlobalVariableGuid,\r
+                &DevicePathSize\r
+                );\r
+  if (VarErrout != NULL) {\r
+    BdsLibConnectConsoleVariable (L"ErrOut");\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c
new file mode 100644 (file)
index 0000000..659bdc6
--- /dev/null
@@ -0,0 +1,978 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsMisc.c\r
+\r
+Abstract:\r
+\r
+  Misc BDS library function\r
+\r
+--*/\r
+\r
+#define MAX_STRING_LEN        200\r
+static BOOLEAN   mFeaturerSwitch = TRUE;\r
+static BOOLEAN   mResetRequired  = FALSE;\r
+extern UINT16 gPlatformBootTimeOutDefault;\r
+\r
+UINT16\r
+BdsLibGetTimeout (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Return the default value for system Timeout variable.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+  \r
+  Timeout value.\r
+\r
+--*/\r
+{\r
+  UINT16      Timeout;\r
+  UINTN       Size;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Return Timeout variable or 0xffff if no valid\r
+  // Timeout variable exists.\r
+  //\r
+  Size    = sizeof (UINT16);\r
+  Status  = gRT->GetVariable (L"Timeout", &gEfiGlobalVariableGuid, NULL, &Size, &Timeout);\r
+  if (!EFI_ERROR (Status)) {\r
+    return Timeout;\r
+  }\r
+  //\r
+  // To make the current EFI Automatic-Test activity possible, just add\r
+  // following code to make AutoBoot enabled when this variable is not\r
+  // present.\r
+  // This code should be removed later.\r
+  //\r
+  Timeout = gPlatformBootTimeOutDefault;\r
+\r
+  //\r
+  // Notes: Platform should set default variable if non exists on all error cases!!!\r
+  //\r
+  Status = gRT->SetVariable (\r
+                  L"Timeout",\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  sizeof (UINT16),\r
+                  &Timeout\r
+                  );\r
+  return Timeout;\r
+}\r
+\r
+VOID\r
+BdsLibLoadDrivers (\r
+  IN LIST_ENTRY               *BdsDriverLists\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  The function will go through the driver optoin link list, load and start\r
+  every driver the driver optoin device path point to.\r
+\r
+Arguments:\r
+\r
+  BdsDriverLists   - The header of the current driver option link list\r
+\r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  LIST_ENTRY                *Link;\r
+  BDS_COMMON_OPTION         *Option;\r
+  EFI_HANDLE                ImageHandle;\r
+  EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
+  UINTN                     ExitDataSize;\r
+  CHAR16                    *ExitData;\r
+  BOOLEAN                   ReconnectAll;\r
+\r
+  ReconnectAll = FALSE;\r
+\r
+  //\r
+  // Process the driver option\r
+  //\r
+  for (Link = BdsDriverLists->ForwardLink; Link != BdsDriverLists; Link = Link->ForwardLink) {\r
+    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+    //\r
+    // If a load option is not marked as LOAD_OPTION_ACTIVE,\r
+    // the boot manager will not automatically load the option.\r
+    //\r
+    if (!IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_ACTIVE)) {\r
+      continue;\r
+    }\r
+    //\r
+    // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT,\r
+    // then all of the EFI drivers in the system will be disconnected and\r
+    // reconnected after the last driver load option is processed.\r
+    //\r
+    if (IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_FORCE_RECONNECT)) {\r
+      ReconnectAll = TRUE;\r
+    }\r
+    //\r
+    // Make sure the driver path is connected.\r
+    //\r
+    BdsLibConnectDevicePath (Option->DevicePath);\r
+\r
+    //\r
+    // Load and start the image that Driver#### describes\r
+    //\r
+    Status = gBS->LoadImage (\r
+                    FALSE,\r
+                    mBdsImageHandle,\r
+                    Option->DevicePath,\r
+                    NULL,\r
+                    0,\r
+                    &ImageHandle\r
+                    );\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
+                          (VOID **)&ImageInfo);\r
+\r
+      //\r
+      // Verify whether this image is a driver, if not,\r
+      // exit it and continue to parse next load option\r
+      //\r
+      if (ImageInfo->ImageCodeType != EfiBootServicesCode && ImageInfo->ImageCodeType != EfiRuntimeServicesCode) {\r
+        gBS->Exit (ImageHandle, EFI_INVALID_PARAMETER, 0, NULL);\r
+        continue;\r
+      }\r
+\r
+      if (Option->LoadOptionsSize != 0) {\r
+        ImageInfo->LoadOptionsSize  = Option->LoadOptionsSize;\r
+        ImageInfo->LoadOptions      = Option->LoadOptions;\r
+      }\r
+      //\r
+      // Before calling the image, enable the Watchdog Timer for\r
+      // the 5 Minute period\r
+      //\r
+      gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
+\r
+      Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
+      DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Driver Return Status = %r\n", Status));\r
+\r
+      //\r
+      // Clear the Watchdog Timer after the image returns\r
+      //\r
+      gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
+    }\r
+  }\r
+  //\r
+  // Process the LOAD_OPTION_FORCE_RECONNECT driver option\r
+  //\r
+  if (ReconnectAll) {\r
+    BdsLibDisconnectAllEfi ();\r
+    BdsLibConnectAll ();\r
+  }\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibRegisterNewOption (\r
+  IN  LIST_ENTRY                     *BdsOptionList,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
+  IN  CHAR16                         *String,\r
+  IN  CHAR16                         *VariableName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This function will register the new boot#### or driver#### option base on\r
+  the VariableName. The new registered boot#### or driver#### will be linked\r
+  to BdsOptionList and also update to the VariableName. After the boot#### or\r
+  driver#### updated, the BootOrder or DriverOrder will also be updated.\r
+\r
+Arguments:\r
+\r
+  BdsOptionList    - The header of the boot#### or driver#### link list\r
+  \r
+  DevicePath       - The device path which the boot####\r
+                     or driver#### option present\r
+                     \r
+  String           - The description of the boot#### or driver####\r
+  \r
+  VariableName     - Indicate if the boot#### or driver#### option\r
+\r
+Returns:\r
+  \r
+  EFI_SUCCESS      - The boot#### or driver#### have been success registered\r
+  \r
+  EFI_STATUS       - Return the status of gRT->SetVariable ().\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  UINT16                    MaxOptionNumber;\r
+  UINT16                    RegisterOptionNumber;\r
+  UINT16                    *TempOptionPtr;\r
+  UINTN                     TempOptionSize;\r
+  UINT16                    *OptionOrderPtr;\r
+  VOID                      *OptionPtr;\r
+  UINTN                     OptionSize;\r
+  UINT8                     *TempPtr;\r
+  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
+  CHAR16                    *Description;\r
+  CHAR16                    OptionName[10];\r
+  BOOLEAN                   UpdateBootDevicePath;\r
+\r
+  OptionPtr             = NULL;\r
+  OptionSize            = 0;\r
+  TempPtr               = NULL;\r
+  OptionDevicePath      = NULL;\r
+  Description           = NULL;\r
+  MaxOptionNumber       = 0;\r
+  OptionOrderPtr        = NULL;\r
+  UpdateBootDevicePath  = FALSE;\r
+  ZeroMem (OptionName, sizeof (OptionName));\r
+\r
+  TempOptionSize = 0;\r
+  TempOptionPtr = BdsLibGetVariableAndSize (\r
+                    VariableName,\r
+                    &gEfiGlobalVariableGuid,\r
+                    &TempOptionSize\r
+                    );\r
+  //\r
+  // Compare with current option variable\r
+  //\r
+  for (Index = 0; Index < TempOptionSize / sizeof (UINT16); Index++) {\r
+    //\r
+    // Got the max option#### number\r
+    //\r
+    if (MaxOptionNumber < TempOptionPtr[Index]) {\r
+      MaxOptionNumber = TempOptionPtr[Index];\r
+    }\r
+\r
+    if (*VariableName == 'B') {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", TempOptionPtr[Index]);\r
+    } else {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", TempOptionPtr[Index]);\r
+    }\r
+\r
+    OptionPtr = BdsLibGetVariableAndSize (\r
+                  OptionName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  &OptionSize\r
+                  );\r
+    TempPtr = OptionPtr;\r
+    TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
+    Description = (CHAR16 *) TempPtr;\r
+    TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+    OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+\r
+    //\r
+    // Notes: the description may will change base on the GetStringToken\r
+    //\r
+    if (CompareMem (Description, String, StrSize (Description)) == 0) {\r
+      if (CompareMem (OptionDevicePath, DevicePath, GetDevicePathSize (OptionDevicePath)) == 0) {\r
+        //\r
+        // Got the option, so just return\r
+        //\r
+        gBS->FreePool (OptionPtr);\r
+        gBS->FreePool (TempOptionPtr);\r
+        return EFI_SUCCESS;\r
+      } else {\r
+        //\r
+        // Boot device path changed, need update.\r
+        //\r
+        UpdateBootDevicePath = TRUE;\r
+        break;\r
+      }\r
+    }\r
+\r
+    gBS->FreePool (OptionPtr);\r
+  }\r
+\r
+  OptionSize          = sizeof (UINT32) + sizeof (UINT16) + StrSize (String) + GetDevicePathSize (DevicePath);\r
+  OptionPtr           = AllocateZeroPool (OptionSize);\r
+  TempPtr             = OptionPtr;\r
+  *(UINT32 *) TempPtr = LOAD_OPTION_ACTIVE;\r
+  TempPtr += sizeof (UINT32);\r
+  *(UINT16 *) TempPtr = (UINT16) GetDevicePathSize (DevicePath);\r
+  TempPtr += sizeof (UINT16);\r
+  CopyMem (TempPtr, String, StrSize (String));\r
+  TempPtr += StrSize (String);\r
+  CopyMem (TempPtr, DevicePath, GetDevicePathSize (DevicePath));\r
+\r
+  if (UpdateBootDevicePath) {\r
+    //\r
+    // The number in option#### to be updated\r
+    //\r
+    RegisterOptionNumber = TempOptionPtr[Index];\r
+  } else {\r
+    //\r
+    // The new option#### number\r
+    //\r
+    RegisterOptionNumber = MaxOptionNumber + 1;\r
+  }\r
+\r
+  if (*VariableName == 'B') {\r
+    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", RegisterOptionNumber);\r
+  } else {\r
+    UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", RegisterOptionNumber);\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  OptionName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  OptionSize,\r
+                  OptionPtr\r
+                  );\r
+  if (EFI_ERROR (Status) || UpdateBootDevicePath) {\r
+    gBS->FreePool (OptionPtr);\r
+    gBS->FreePool (TempOptionPtr);\r
+    return Status;\r
+  }\r
+\r
+  gBS->FreePool (OptionPtr);\r
+\r
+  //\r
+  // Update the option order variable\r
+  //\r
+  OptionOrderPtr = AllocateZeroPool ((Index + 1) * sizeof (UINT16));\r
+  CopyMem (OptionOrderPtr, TempOptionPtr, Index * sizeof (UINT16));\r
+  OptionOrderPtr[Index] = RegisterOptionNumber;\r
+  Status = gRT->SetVariable (\r
+                  VariableName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  (Index + 1) * sizeof (UINT16),\r
+                  OptionOrderPtr\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (TempOptionPtr);\r
+    gBS->FreePool (OptionOrderPtr);\r
+    return Status;\r
+  }\r
+\r
+  gBS->FreePool (TempOptionPtr);\r
+  gBS->FreePool (OptionOrderPtr);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BDS_COMMON_OPTION *\r
+BdsLibVariableToOption (\r
+  IN OUT LIST_ENTRY               *BdsCommonOptionList,\r
+  IN  CHAR16                      *VariableName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build the boot#### or driver#### option from the VariableName, the \r
+  build boot#### or driver#### will also be linked to BdsCommonOptionList\r
+  \r
+Arguments:\r
+\r
+  BdsCommonOptionList - The header of the boot#### or driver#### option link list\r
+\r
+  VariableName - EFI Variable name indicate if it is boot#### or driver####\r
+\r
+Returns:\r
+\r
+  BDS_COMMON_OPTION    - Get the option just been created\r
+\r
+  NULL                 - Failed to get the new option\r
+\r
+--*/\r
+{\r
+  UINT32                    Attribute;\r
+  UINT16                    FilePathSize;\r
+  UINT8                     *Variable;\r
+  UINT8                     *TempPtr;\r
+  UINTN                     VariableSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  BDS_COMMON_OPTION         *Option;\r
+  VOID                      *LoadOptions;\r
+  UINT32                    LoadOptionsSize;\r
+  CHAR16                    *Description;\r
+\r
+  //\r
+  // Read the variable. We will never free this data.\r
+  //\r
+  Variable = BdsLibGetVariableAndSize (\r
+              VariableName,\r
+              &gEfiGlobalVariableGuid,\r
+              &VariableSize\r
+              );\r
+  if (Variable == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Notes: careful defined the variable of Boot#### or\r
+  // Driver####, consider use some macro to abstract the code\r
+  //\r
+  //\r
+  // Get the option attribute\r
+  //\r
+  TempPtr   = Variable;\r
+  Attribute = *(UINT32 *) Variable;\r
+  TempPtr += sizeof (UINT32);\r
+\r
+  //\r
+  // Get the option's device path size\r
+  //\r
+  FilePathSize = *(UINT16 *) TempPtr;\r
+  TempPtr += sizeof (UINT16);\r
+\r
+  //\r
+  // Get the option's description string\r
+  //\r
+  Description = (CHAR16 *) TempPtr;\r
+\r
+  //\r
+  // Get the option's description string size\r
+  //\r
+  TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+\r
+  //\r
+  // Get the option's device path\r
+  //\r
+  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+  TempPtr += FilePathSize;\r
+\r
+  LoadOptions     = TempPtr;\r
+  LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));\r
+\r
+  //\r
+  // The Console variables may have multiple device paths, so make\r
+  // an Entry for each one.\r
+  //\r
+  Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));\r
+  if (Option == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  Option->Signature   = BDS_LOAD_OPTION_SIGNATURE;\r
+  Option->DevicePath  = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
+  CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
+  Option->Attribute   = Attribute;\r
+  Option->Description = AllocateZeroPool (StrSize (Description));\r
+  CopyMem (Option->Description, Description, StrSize (Description));\r
+  Option->LoadOptions = AllocateZeroPool (LoadOptionsSize);\r
+  CopyMem (Option->LoadOptions, LoadOptions, LoadOptionsSize);\r
+  Option->LoadOptionsSize = LoadOptionsSize;\r
+\r
+  //\r
+  // Insert active entry to BdsDeviceList\r
+  //\r
+  if ((Option->Attribute & LOAD_OPTION_ACTIVE) == LOAD_OPTION_ACTIVE) {\r
+    InsertTailList (BdsCommonOptionList, &Option->Link);\r
+    gBS->FreePool (Variable);\r
+    return Option;\r
+  }\r
+\r
+  gBS->FreePool (Variable);\r
+  gBS->FreePool (Option);\r
+  return NULL;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibBuildOptionFromVar (\r
+  IN  LIST_ENTRY                  *BdsCommonOptionList,\r
+  IN  CHAR16                      *VariableName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process BootOrder, or DriverOrder variables, by calling\r
+  BdsLibVariableToOption () for each UINT16 in the variables.\r
+\r
+Arguments:\r
+\r
+  BdsCommonOptionList - The header of the option list base on variable\r
+                        VariableName\r
+\r
+  VariableName - EFI Variable name indicate the BootOrder or DriverOrder\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Success create the boot option or driver option list\r
+\r
+  EFI_OUT_OF_RESOURCES - Failed to get the boot option or driver option list\r
+\r
+--*/\r
+{\r
+  UINT16            *OptionOrder;\r
+  UINTN             OptionOrderSize;\r
+  UINTN             Index;\r
+  BDS_COMMON_OPTION *Option;\r
+  CHAR16            OptionName[20];\r
+\r
+  //\r
+  // Zero Buffer in order to get all BOOT#### variables\r
+  //\r
+  ZeroMem (OptionName, sizeof (OptionName));\r
+\r
+  //\r
+  // Read the BootOrder, or DriverOrder variable.\r
+  //\r
+  OptionOrder = BdsLibGetVariableAndSize (\r
+                  VariableName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  &OptionOrderSize\r
+                  );\r
+  if (OptionOrder == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionOrderSize / sizeof (UINT16); Index++) {\r
+    if (*VariableName == 'B') {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", OptionOrder[Index]);\r
+    } else {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", OptionOrder[Index]);\r
+    }\r
+    Option              = BdsLibVariableToOption (BdsCommonOptionList, OptionName);\r
+    Option->BootCurrent = OptionOrder[Index];\r
+\r
+  }\r
+\r
+  gBS->FreePool (OptionOrder);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibGetBootMode (\r
+  OUT EFI_BOOT_MODE       *BootMode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get boot mode by looking up configuration table and parsing HOB list\r
+\r
+Arguments:\r
+\r
+  BootMode - Boot mode from PEI handoff HOB.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Successfully get boot mode\r
+  \r
+  EFI_NOT_FOUND - Can not find the current system boot mode\r
+\r
+--*/\r
+{\r
+  EFI_HOB_HANDOFF_INFO_TABLE        *HobList;\r
+\r
+  HobList = GetHobList ();\r
+  ASSERT (HobList->Header.HobType == EFI_HOB_TYPE_HANDOFF);\r
+  *BootMode = HobList->BootMode;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID *\r
+BdsLibGetVariableAndSize (\r
+  IN  CHAR16              *Name,\r
+  IN  EFI_GUID            *VendorGuid,\r
+  OUT UINTN               *VariableSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
+  buffer, and the size of the buffer. If failure return NULL.\r
+\r
+Arguments:\r
+\r
+  Name       - String part of EFI variable name\r
+\r
+  VendorGuid - GUID part of EFI variable name\r
+\r
+  VariableSize - Returns the size of the EFI variable that was read\r
+\r
+Returns:\r
+\r
+  Dynamically allocated memory that contains a copy of the EFI variable.\r
+  Caller is responsible freeing the buffer.\r
+\r
+  NULL - Variable was not read\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       BufferSize;\r
+  VOID        *Buffer;\r
+\r
+  Buffer = NULL;\r
+\r
+  //\r
+  // Pass in a zero size buffer to find the required buffer size.\r
+  //\r
+  BufferSize  = 0;\r
+  Status      = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    //\r
+    // Allocate the buffer to return\r
+    //\r
+    Buffer = AllocateZeroPool (BufferSize);\r
+    if (Buffer == NULL) {\r
+      return NULL;\r
+    }\r
+    //\r
+    // Read variable into the allocated buffer.\r
+    //\r
+    Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
+    if (EFI_ERROR (Status)) {\r
+      BufferSize = 0;\r
+    }\r
+  }\r
+\r
+  *VariableSize = BufferSize;\r
+  return Buffer;\r
+}\r
+\r
+BOOLEAN\r
+BdsLibMatchDevicePaths (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Single\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function compares a device path data structure to that of all the nodes of a\r
+  second device path instance.\r
+\r
+Arguments:\r
+\r
+  Multi        - A pointer to a multi-instance device path data structure.\r
+\r
+  Single       - A pointer to a single-instance device path data structure.\r
+\r
+Returns:\r
+\r
+  TRUE   - If the Single is contained within Multi\r
+  \r
+  FALSE  - The Single is not match within Multi\r
+  \r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
+  UINTN                     Size;\r
+\r
+  if (!Multi || !Single) {\r
+    return FALSE;\r
+  }\r
+\r
+  DevicePath      = Multi;\r
+  DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
+\r
+  //\r
+  // Search for the match of 'Single' in 'Multi'\r
+  //\r
+  while (DevicePathInst != NULL) {\r
+    //\r
+    // If the single device path is found in multiple device paths,\r
+    // return success\r
+    //\r
+    if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
+      gBS->FreePool (DevicePathInst);\r
+      return TRUE;\r
+    }\r
+\r
+    gBS->FreePool (DevicePathInst);\r
+    DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibOutputStrings (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *ConOut,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function prints a series of strings.\r
+\r
+Arguments:\r
+\r
+  ConOut               - Pointer to EFI_SIMPLE_TEXT_OUT_PROTOCOL\r
+\r
+  ...                  - A variable argument list containing series of strings,\r
+                         the last string must be NULL.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - Success print out the string using ConOut.\r
+  \r
+  EFI_STATUS           - Return the status of the ConOut->OutputString ().\r
+\r
+--*/\r
+{\r
+  VA_LIST     args;\r
+  EFI_STATUS  Status;\r
+  CHAR16      *String;\r
+\r
+  Status = EFI_SUCCESS;\r
+  VA_START (args, ConOut);\r
+\r
+  while (!EFI_ERROR (Status)) {\r
+    //\r
+    // If String is NULL, then it's the end of the list\r
+    //\r
+    String = VA_ARG (args, CHAR16 *);\r
+    if (!String) {\r
+      break;\r
+    }\r
+\r
+    Status = ConOut->OutputString (ConOut, String);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+//\r
+//  Following are BDS Lib functions which  contain all the code about setup browser reset reminder feature.\r
+//  Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser  if \r
+//  user change any option setting which needs a reset to be effective, and  the reset will be applied according to  the user selection.\r
+//\r
+\r
+VOID\r
+EnableResetReminderFeature (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Enable the setup browser reset reminder feature.\r
+  This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mFeaturerSwitch = TRUE;\r
+} \r
+\r
+VOID\r
+DisableResetReminderFeature (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Disable the setup browser reset reminder feature.\r
+  This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
+  \r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mFeaturerSwitch = FALSE;\r
+} \r
+\r
+VOID\r
+EnableResetRequired (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+   Record the info that  a reset is required.\r
+   A  module boolean variable is used to record whether a reset is required. \r
+  \r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mResetRequired = TRUE;\r
+} \r
+\r
+VOID\r
+DisableResetRequired (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+   Record the info that  no reset is required.\r
+   A  module boolean variable is used to record whether a reset is required. \r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mResetRequired = FALSE;\r
+} \r
+\r
+BOOLEAN\r
+IsResetReminderFeatureEnable (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Check whether platform policy enable the reset reminder feature. The default is enabled.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  return mFeaturerSwitch;\r
+}\r
+\r
+BOOLEAN\r
+IsResetRequired (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Check if  user changed any option setting which needs a system reset to be effective.\r
+  \r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  return mResetRequired;\r
+}\r
+\r
+VOID\r
+SetupResetReminder (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Check whether a reset is needed, and finish the reset reminder feature.\r
+  If a reset is needed, Popup a menu to notice user, and finish the feature \r
+  according to the user selection.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_FORM_BROWSER_PROTOCOL     *Browser;\r
+  EFI_INPUT_KEY                 Key;  \r
+  CHAR16                        *StringBuffer1;\r
+  CHAR16                        *StringBuffer2;    \r
+\r
+\r
+  //\r
+  //check any reset required change is applied? if yes, reset system\r
+  //\r
+  if (IsResetReminderFeatureEnable ()) {\r
+    if (IsResetRequired ()) {\r
+    \r
+      Status = gBS->LocateProtocol (\r
+                      &gEfiFormBrowserProtocolGuid,\r
+                      NULL,\r
+                      (VOID **)&Browser\r
+                      );      \r
+                      \r
+      StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
+      ASSERT (StringBuffer1 != NULL);\r
+      StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
+      ASSERT (StringBuffer2 != NULL);      \r
+      StrCpy (StringBuffer1, L"Configuration changed. Reset to apply it Now ? ");\r
+      StrCpy (StringBuffer2, L"Enter (YES)  /   Esc (NO)");      \r
+      //\r
+      // Popup a menu to notice user\r
+      // \r
+      do {\r
+        Browser->CreatePopUp (2, TRUE, 0, NULL, &Key, StringBuffer1, StringBuffer2);\r
+      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN)); \r
+      \r
+      gBS->FreePool (StringBuffer1);      \r
+      gBS->FreePool (StringBuffer2);            \r
+      //\r
+      // If the user hits the YES Response key, reset\r
+      //\r
+      if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {\r
+        gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+      }\r
+      gST->ConOut->ClearScreen (gST->ConOut);\r
+    } \r
+  } \r
+} \r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c.orig b/EdkUnixPkg/Library/EdkGenericBdsLib/BdsMisc.c.orig
new file mode 100644 (file)
index 0000000..8f5544a
--- /dev/null
@@ -0,0 +1,983 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BdsMisc.c\r
+\r
+Abstract:\r
+\r
+  Misc BDS library function\r
+\r
+--*/\r
+\r
+#define MAX_STRING_LEN        200\r
+static BOOLEAN   mFeaturerSwitch = TRUE;\r
+static BOOLEAN   mResetRequired  = FALSE;\r
+extern UINT16 gPlatformBootTimeOutDefault;\r
+\r
+UINT16\r
+BdsLibGetTimeout (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Return the default value for system Timeout variable.\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+  \r
+  Timeout value.\r
+\r
+--*/\r
+{\r
+  UINT16      Timeout;\r
+  UINTN       Size;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Return Timeout variable or 0xffff if no valid\r
+  // Timeout variable exists.\r
+  //\r
+  Size    = sizeof (UINT16);\r
+  Status  = gRT->GetVariable (L"Timeout", &gEfiGlobalVariableGuid, NULL, &Size, &Timeout);\r
+  if (!EFI_ERROR (Status)) {\r
+    return Timeout;\r
+  }\r
+  //\r
+  // To make the current EFI Automatic-Test activity possible, just add\r
+  // following code to make AutoBoot enabled when this variable is not\r
+  // present.\r
+  // This code should be removed later.\r
+  //\r
+  Timeout = gPlatformBootTimeOutDefault;\r
+\r
+  //\r
+  // Notes: Platform should set default variable if non exists on all error cases!!!\r
+  //\r
+  Status = gRT->SetVariable (\r
+                  L"Timeout",\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  sizeof (UINT16),\r
+                  &Timeout\r
+                  );\r
+  return Timeout;\r
+}\r
+\r
+VOID\r
+BdsLibLoadDrivers (\r
+  IN LIST_ENTRY               *BdsDriverLists\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  The function will go through the driver optoin link list, load and start\r
+  every driver the driver optoin device path point to.\r
+\r
+Arguments:\r
+\r
+  BdsDriverLists   - The header of the current driver option link list\r
+\r
+Returns:\r
+  \r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  LIST_ENTRY                *Link;\r
+  BDS_COMMON_OPTION         *Option;\r
+  EFI_HANDLE                ImageHandle;\r
+  EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
+  UINTN                     ExitDataSize;\r
+  CHAR16                    *ExitData;\r
+  BOOLEAN                   ReconnectAll;\r
+\r
+  ReconnectAll = FALSE;\r
+\r
+  //\r
+  // Process the driver option\r
+  //\r
+  for (Link = BdsDriverLists->ForwardLink; Link != BdsDriverLists; Link = Link->ForwardLink) {\r
+    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+    //\r
+    // If a load option is not marked as LOAD_OPTION_ACTIVE,\r
+    // the boot manager will not automatically load the option.\r
+    //\r
+    if (!IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_ACTIVE)) {\r
+      continue;\r
+    }\r
+    //\r
+    // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT,\r
+    // then all of the EFI drivers in the system will be disconnected and\r
+    // reconnected after the last driver load option is processed.\r
+    //\r
+    if (IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_FORCE_RECONNECT)) {\r
+      ReconnectAll = TRUE;\r
+    }\r
+    //\r
+    // Make sure the driver path is connected.\r
+    //\r
+    BdsLibConnectDevicePath (Option->DevicePath);\r
+\r
+    //\r
+    // Load and start the image that Driver#### describes\r
+    //\r
+    Status = gBS->LoadImage (\r
+                    FALSE,\r
+                    mBdsImageHandle,\r
+                    Option->DevicePath,\r
+                    NULL,\r
+                    0,\r
+                    &ImageHandle\r
+                    );\r
+\r
+    if (!EFI_ERROR (Status)) {\r
+      gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
+                          (VOID **)&ImageInfo);\r
+\r
+      //\r
+      // Verify whether this image is a driver, if not,\r
+      // exit it and continue to parse next load option\r
+      //\r
+      if (ImageInfo->ImageCodeType != EfiBootServicesCode && ImageInfo->ImageCodeType != EfiRuntimeServicesCode) {\r
+        gBS->Exit (ImageHandle, EFI_INVALID_PARAMETER, 0, NULL);\r
+        continue;\r
+      }\r
+\r
+      if (Option->LoadOptionsSize != 0) {\r
+        ImageInfo->LoadOptionsSize  = Option->LoadOptionsSize;\r
+        ImageInfo->LoadOptions      = Option->LoadOptions;\r
+      }\r
+      //\r
+      // Before calling the image, enable the Watchdog Timer for\r
+      // the 5 Minute period\r
+      //\r
+      gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
+\r
+      Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
+      DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Driver Return Status = %r\n", Status));\r
+\r
+      //\r
+      // Clear the Watchdog Timer after the image returns\r
+      //\r
+      gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
+    }\r
+  }\r
+  //\r
+  // Process the LOAD_OPTION_FORCE_RECONNECT driver option\r
+  //\r
+  if (ReconnectAll) {\r
+    BdsLibDisconnectAllEfi ();\r
+    BdsLibConnectAll ();\r
+  }\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibRegisterNewOption (\r
+  IN  LIST_ENTRY                     *BdsOptionList,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
+  IN  CHAR16                         *String,\r
+  IN  CHAR16                         *VariableName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This function will register the new boot#### or driver#### option base on\r
+  the VariableName. The new registered boot#### or driver#### will be linked\r
+  to BdsOptionList and also update to the VariableName. After the boot#### or\r
+  driver#### updated, the BootOrder or DriverOrder will also be updated.\r
+\r
+Arguments:\r
+\r
+  BdsOptionList    - The header of the boot#### or driver#### link list\r
+  \r
+  DevicePath       - The device path which the boot####\r
+                     or driver#### option present\r
+                     \r
+  String           - The description of the boot#### or driver####\r
+  \r
+  VariableName     - Indicate if the boot#### or driver#### option\r
+\r
+Returns:\r
+  \r
+  EFI_SUCCESS      - The boot#### or driver#### have been success registered\r
+  \r
+  EFI_STATUS       - Return the status of gRT->SetVariable ().\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  UINT16                    MaxOptionNumber;\r
+  UINT16                    RegisterOptionNumber;\r
+  UINT16                    *TempOptionPtr;\r
+  UINTN                     TempOptionSize;\r
+  UINT16                    *OptionOrderPtr;\r
+  VOID                      *OptionPtr;\r
+  UINTN                     OptionSize;\r
+  UINT8                     *TempPtr;\r
+  EFI_DEVICE_PATH_PROTOCOL  *OptionDevicePath;\r
+  CHAR16                    *Description;\r
+  CHAR16                    OptionName[10];\r
+  BOOLEAN                   UpdateBootDevicePath;\r
+\r
+  OptionPtr             = NULL;\r
+  OptionSize            = 0;\r
+  TempPtr               = NULL;\r
+  OptionDevicePath      = NULL;\r
+  Description           = NULL;\r
+  MaxOptionNumber       = 0;\r
+  OptionOrderPtr        = NULL;\r
+  UpdateBootDevicePath  = FALSE;\r
+  ZeroMem (OptionName, sizeof (OptionName));\r
+\r
+  TempOptionSize = 0;\r
+  TempOptionPtr = BdsLibGetVariableAndSize (\r
+                    VariableName,\r
+                    &gEfiGlobalVariableGuid,\r
+                    &TempOptionSize\r
+                    );\r
+  //\r
+  // Compare with current option variable\r
+  //\r
+  for (Index = 0; Index < TempOptionSize / sizeof (UINT16); Index++) {\r
+    //\r
+    // Got the max option#### number\r
+    //\r
+    if (MaxOptionNumber < TempOptionPtr[Index]) {\r
+      MaxOptionNumber = TempOptionPtr[Index];\r
+    }\r
+\r
+    if (*VariableName == 'B') {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", TempOptionPtr[Index]);\r
+    } else {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", TempOptionPtr[Index]);\r
+    }\r
+\r
+    OptionPtr = BdsLibGetVariableAndSize (\r
+                  OptionName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  &OptionSize\r
+                  );\r
+    TempPtr = OptionPtr;\r
+    TempPtr += sizeof (UINT32) + sizeof (UINT16);\r
+    Description = (CHAR16 *) TempPtr;\r
+    TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+    OptionDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+\r
+    //\r
+    // Notes: the description may will change base on the GetStringToken\r
+    //\r
+    if (CompareMem (Description, String, StrSize (Description)) == 0) {\r
+      if (CompareMem (OptionDevicePath, DevicePath, GetDevicePathSize (OptionDevicePath)) == 0) {\r
+        //\r
+        // Got the option, so just return\r
+        //\r
+        gBS->FreePool (OptionPtr);\r
+        gBS->FreePool (TempOptionPtr);\r
+        return EFI_SUCCESS;\r
+      } else {\r
+        //\r
+        // Boot device path changed, need update.\r
+        //\r
+        UpdateBootDevicePath = TRUE;\r
+        break;\r
+      }\r
+    }\r
+\r
+    gBS->FreePool (OptionPtr);\r
+  }\r
+\r
+  OptionSize          = sizeof (UINT32) + sizeof (UINT16) + StrSize (String) + GetDevicePathSize (DevicePath);\r
+  OptionPtr           = AllocateZeroPool (OptionSize);\r
+  TempPtr             = OptionPtr;\r
+  *(UINT32 *) TempPtr = LOAD_OPTION_ACTIVE;\r
+  TempPtr += sizeof (UINT32);\r
+  *(UINT16 *) TempPtr = (UINT16) GetDevicePathSize (DevicePath);\r
+  TempPtr += sizeof (UINT16);\r
+  CopyMem (TempPtr, String, StrSize (String));\r
+  TempPtr += StrSize (String);\r
+  CopyMem (TempPtr, DevicePath, GetDevicePathSize (DevicePath));\r
+\r
+  if (UpdateBootDevicePath) {\r
+    //\r
+    // The number in option#### to be updated\r
+    //\r
+    RegisterOptionNumber = TempOptionPtr[Index];\r
+  } else {\r
+    //\r
+    // The new option#### number\r
+    //\r
+    RegisterOptionNumber = MaxOptionNumber + 1;\r
+  }\r
+\r
+  if (*VariableName == 'B') {\r
+    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", RegisterOptionNumber);\r
+  } else {\r
+    UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", RegisterOptionNumber);\r
+  }\r
+\r
+  Status = gRT->SetVariable (\r
+                  OptionName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  OptionSize,\r
+                  OptionPtr\r
+                  );\r
+  if (EFI_ERROR (Status) || UpdateBootDevicePath) {\r
+    gBS->FreePool (OptionPtr);\r
+    gBS->FreePool (TempOptionPtr);\r
+    return Status;\r
+  }\r
+\r
+  gBS->FreePool (OptionPtr);\r
+\r
+  //\r
+  // Update the option order variable\r
+  //\r
+  OptionOrderPtr = AllocateZeroPool ((Index + 1) * sizeof (UINT16));\r
+  CopyMem (OptionOrderPtr, TempOptionPtr, Index * sizeof (UINT16));\r
+  OptionOrderPtr[Index] = RegisterOptionNumber;\r
+  Status = gRT->SetVariable (\r
+                  VariableName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  (Index + 1) * sizeof (UINT16),\r
+                  OptionOrderPtr\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (TempOptionPtr);\r
+    gBS->FreePool (OptionOrderPtr);\r
+    return Status;\r
+  }\r
+\r
+  gBS->FreePool (TempOptionPtr);\r
+  gBS->FreePool (OptionOrderPtr);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BDS_COMMON_OPTION *\r
+BdsLibVariableToOption (\r
+  IN OUT LIST_ENTRY               *BdsCommonOptionList,\r
+  IN  CHAR16                      *VariableName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Build the boot#### or driver#### option from the VariableName, the \r
+  build boot#### or driver#### will also be linked to BdsCommonOptionList\r
+  \r
+Arguments:\r
+\r
+  BdsCommonOptionList - The header of the boot#### or driver#### option link list\r
+\r
+  VariableName - EFI Variable name indicate if it is boot#### or driver####\r
+\r
+Returns:\r
+\r
+  BDS_COMMON_OPTION    - Get the option just been created\r
+\r
+  NULL                 - Failed to get the new option\r
+\r
+--*/\r
+{\r
+  UINT32                    Attribute;\r
+  UINT16                    FilePathSize;\r
+  UINT8                     *Variable;\r
+  UINT8                     *TempPtr;\r
+  UINTN                     VariableSize;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  BDS_COMMON_OPTION         *Option;\r
+  VOID                      *LoadOptions;\r
+  UINT32                    LoadOptionsSize;\r
+  CHAR16                    *Description;\r
+\r
+  //\r
+  // Read the variable. We will never free this data.\r
+  //\r
+  Variable = BdsLibGetVariableAndSize (\r
+              VariableName,\r
+              &gEfiGlobalVariableGuid,\r
+              &VariableSize\r
+              );\r
+  if (Variable == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Notes: careful defined the variable of Boot#### or\r
+  // Driver####, consider use some macro to abstract the code\r
+  //\r
+  //\r
+  // Get the option attribute\r
+  //\r
+  TempPtr   = Variable;\r
+  Attribute = *(UINT32 *) Variable;\r
+  TempPtr += sizeof (UINT32);\r
+\r
+  //\r
+  // Get the option's device path size\r
+  //\r
+  FilePathSize = *(UINT16 *) TempPtr;\r
+  TempPtr += sizeof (UINT16);\r
+\r
+  //\r
+  // Get the option's description string\r
+  //\r
+  Description = (CHAR16 *) TempPtr;\r
+\r
+  //\r
+  // Get the option's description string size\r
+  //\r
+  TempPtr += StrSize ((CHAR16 *) TempPtr);\r
+\r
+  //\r
+  // Get the option's device path\r
+  //\r
+  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;\r
+  TempPtr += FilePathSize;\r
+\r
+  LoadOptions     = TempPtr;\r
+  LoadOptionsSize = (UINT32) (VariableSize - (UINTN) (TempPtr - Variable));\r
+\r
+  //\r
+  // The Console variables may have multiple device paths, so make\r
+  // an Entry for each one.\r
+  //\r
+  Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));\r
+  if (Option == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  Option->Signature   = BDS_LOAD_OPTION_SIGNATURE;\r
+  Option->DevicePath  = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
+  CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
+  Option->Attribute   = Attribute;\r
+  Option->Description = AllocateZeroPool (StrSize (Description));\r
+  CopyMem (Option->Description, Description, StrSize (Description));\r
+  Option->LoadOptions = AllocateZeroPool (LoadOptionsSize);\r
+  CopyMem (Option->LoadOptions, LoadOptions, LoadOptionsSize);\r
+  Option->LoadOptionsSize = LoadOptionsSize;\r
+\r
+  //\r
+  // Insert active entry to BdsDeviceList\r
+  //\r
+  if ((Option->Attribute & LOAD_OPTION_ACTIVE) == LOAD_OPTION_ACTIVE) {\r
+    InsertTailList (BdsCommonOptionList, &Option->Link);\r
+    gBS->FreePool (Variable);\r
+    return Option;\r
+  }\r
+\r
+  gBS->FreePool (Variable);\r
+  gBS->FreePool (Option);\r
+  return NULL;\r
+\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibBuildOptionFromVar (\r
+  IN  LIST_ENTRY                  *BdsCommonOptionList,\r
+  IN  CHAR16                      *VariableName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process BootOrder, or DriverOrder variables, by calling\r
+  BdsLibVariableToOption () for each UINT16 in the variables.\r
+\r
+Arguments:\r
+\r
+  BdsCommonOptionList - The header of the option list base on variable\r
+                        VariableName\r
+\r
+  VariableName - EFI Variable name indicate the BootOrder or DriverOrder\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Success create the boot option or driver option list\r
+\r
+  EFI_OUT_OF_RESOURCES - Failed to get the boot option or driver option list\r
+\r
+--*/\r
+{\r
+  UINT16            *OptionOrder;\r
+  UINTN             OptionOrderSize;\r
+  UINTN             Index;\r
+  BDS_COMMON_OPTION *Option;\r
+  CHAR16            OptionName[20];\r
+\r
+  //\r
+  // Zero Buffer in order to get all BOOT#### variables\r
+  //\r
+  ZeroMem (OptionName, sizeof (OptionName));\r
+\r
+  //\r
+  // Read the BootOrder, or DriverOrder variable.\r
+  //\r
+  OptionOrder = BdsLibGetVariableAndSize (\r
+                  VariableName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  &OptionOrderSize\r
+                  );\r
+  if (OptionOrder == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  for (Index = 0; Index < OptionOrderSize / sizeof (UINT16); Index++) {\r
+    if (*VariableName == 'B') {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", OptionOrder[Index]);\r
+    } else {\r
+      UnicodeSPrint (OptionName, sizeof (OptionName), L"Driver%04x", OptionOrder[Index]);\r
+    }\r
+    Option              = BdsLibVariableToOption (BdsCommonOptionList, OptionName);\r
+    Option->BootCurrent = OptionOrder[Index];\r
+\r
+  }\r
+\r
+  gBS->FreePool (OptionOrder);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibGetBootMode (\r
+  OUT EFI_BOOT_MODE       *BootMode\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get boot mode by looking up configuration table and parsing HOB list\r
+\r
+Arguments:\r
+\r
+  BootMode - Boot mode from PEI handoff HOB.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Successfully get boot mode\r
+  \r
+  EFI_NOT_FOUND - Can not find the current system boot mode\r
+\r
+--*/\r
+{\r
+  EFI_HOB_HANDOFF_INFO_TABLE        *HobList;\r
+\r
+  HobList = GetHobList ();\r
+  ASSERT (HobList->Header.HobType == EFI_HOB_TYPE_HANDOFF);\r
+  *BootMode = HobList->BootMode;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID *\r
+BdsLibGetVariableAndSize (\r
+  IN  CHAR16              *Name,\r
+  IN  EFI_GUID            *VendorGuid,\r
+  OUT UINTN               *VariableSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r
+  buffer, and the size of the buffer. If failure return NULL.\r
+\r
+Arguments:\r
+\r
+  Name       - String part of EFI variable name\r
+\r
+  VendorGuid - GUID part of EFI variable name\r
+\r
+  VariableSize - Returns the size of the EFI variable that was read\r
+\r
+Returns:\r
+\r
+  Dynamically allocated memory that contains a copy of the EFI variable.\r
+  Caller is responsible freeing the buffer.\r
+\r
+  NULL - Variable was not read\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       BufferSize;\r
+  VOID        *Buffer;\r
+\r
+  Buffer = NULL;\r
+\r
+  //\r
+  // Pass in a zero size buffer to find the required buffer size.\r
+  //\r
+  BufferSize  = 0;\r
+  Status      = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    //\r
+    // Allocate the buffer to return\r
+    //\r
+    Buffer = AllocateZeroPool (BufferSize);\r
+    if (Buffer == NULL) {\r
+      return NULL;\r
+    }\r
+    //\r
+    // Read variable into the allocated buffer.\r
+    //\r
+    Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
+    if (EFI_ERROR (Status)) {\r
+      BufferSize = 0;\r
+    }\r
+  }\r
+\r
+  *VariableSize = BufferSize;\r
+  return Buffer;\r
+}\r
+\r
+BOOLEAN\r
+BdsLibMatchDevicePaths (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *Single\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function compares a device path data structure to that of all the nodes of a\r
+  second device path instance.\r
+\r
+Arguments:\r
+\r
+  Multi        - A pointer to a multi-instance device path data structure.\r
+\r
+  Single       - A pointer to a single-instance device path data structure.\r
+\r
+Returns:\r
+\r
+  TRUE   - If the Single is contained within Multi\r
+  \r
+  FALSE  - The Single is not match within Multi\r
+  \r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
+  UINTN                     Size;\r
+\r
+  if (!Multi || !Single) {\r
+    return FALSE;\r
+  }\r
+\r
+  DevicePath      = Multi;\r
+  DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
+  Size -= sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+\r
+  //\r
+  // Search for the match of 'Single' in 'Multi'\r
+  //\r
+  while (DevicePathInst != NULL) {\r
+    //\r
+    // If the single device path is found in multiple device paths,\r
+    // return success\r
+    //\r
+    if (Size == 0) {\r
+      return FALSE;\r
+    }\r
+\r
+    if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
+      return TRUE;\r
+    }\r
+\r
+    gBS->FreePool (DevicePathInst);\r
+    DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
+    Size -= sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+BdsLibOutputStrings (\r
+  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL   *ConOut,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function prints a series of strings.\r
+\r
+Arguments:\r
+\r
+  ConOut               - Pointer to EFI_SIMPLE_TEXT_OUT_PROTOCOL\r
+\r
+  ...                  - A variable argument list containing series of strings,\r
+                         the last string must be NULL.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS          - Success print out the string using ConOut.\r
+  \r
+  EFI_STATUS           - Return the status of the ConOut->OutputString ().\r
+\r
+--*/\r
+{\r
+  VA_LIST     args;\r
+  EFI_STATUS  Status;\r
+  CHAR16      *String;\r
+\r
+  Status = EFI_SUCCESS;\r
+  VA_START (args, ConOut);\r
+\r
+  while (!EFI_ERROR (Status)) {\r
+    //\r
+    // If String is NULL, then it's the end of the list\r
+    //\r
+    String = VA_ARG (args, CHAR16 *);\r
+    if (!String) {\r
+      break;\r
+    }\r
+\r
+    Status = ConOut->OutputString (ConOut, String);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+//\r
+//  Following are BDS Lib functions which  contain all the code about setup browser reset reminder feature.\r
+//  Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser  if \r
+//  user change any option setting which needs a reset to be effective, and  the reset will be applied according to  the user selection.\r
+//\r
+\r
+VOID\r
+EnableResetReminderFeature (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Enable the setup browser reset reminder feature.\r
+  This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mFeaturerSwitch = TRUE;\r
+} \r
+\r
+VOID\r
+DisableResetReminderFeature (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Disable the setup browser reset reminder feature.\r
+  This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
+  \r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mFeaturerSwitch = FALSE;\r
+} \r
+\r
+VOID\r
+EnableResetRequired (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+   Record the info that  a reset is required.\r
+   A  module boolean variable is used to record whether a reset is required. \r
+  \r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mResetRequired = TRUE;\r
+} \r
+\r
+VOID\r
+DisableResetRequired (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+   Record the info that  no reset is required.\r
+   A  module boolean variable is used to record whether a reset is required. \r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  mResetRequired = FALSE;\r
+} \r
+\r
+BOOLEAN\r
+IsResetReminderFeatureEnable (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Check whether platform policy enable the reset reminder feature. The default is enabled.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  return mFeaturerSwitch;\r
+}\r
+\r
+BOOLEAN\r
+IsResetRequired (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Check if  user changed any option setting which needs a system reset to be effective.\r
+  \r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  return mResetRequired;\r
+}\r
+\r
+VOID\r
+SetupResetReminder (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
\r
+  Check whether a reset is needed, and finish the reset reminder feature.\r
+  If a reset is needed, Popup a menu to notice user, and finish the feature \r
+  according to the user selection.\r
+\r
+Arguments:\r
+\r
+  VOID\r
+\r
+Returns:\r
+\r
+  VOID\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_FORM_BROWSER_PROTOCOL     *Browser;\r
+  EFI_INPUT_KEY                 Key;  \r
+  CHAR16                        *StringBuffer1;\r
+  CHAR16                        *StringBuffer2;    \r
+\r
+\r
+  //\r
+  //check any reset required change is applied? if yes, reset system\r
+  //\r
+  if (IsResetReminderFeatureEnable ()) {\r
+    if (IsResetRequired ()) {\r
+    \r
+      Status = gBS->LocateProtocol (\r
+                      &gEfiFormBrowserProtocolGuid,\r
+                      NULL,\r
+                      (VOID **)&Browser\r
+                      );      \r
+                      \r
+      StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
+      ASSERT (StringBuffer1 != NULL);\r
+      StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
+      ASSERT (StringBuffer2 != NULL);      \r
+      StrCpy (StringBuffer1, L"Configuration changed. Reset to apply it Now ? ");\r
+      StrCpy (StringBuffer2, L"Enter (YES)  /   Esc (NO)");      \r
+      //\r
+      // Popup a menu to notice user\r
+      // \r
+      do {\r
+        Browser->CreatePopUp (2, TRUE, 0, NULL, &Key, StringBuffer1, StringBuffer2);\r
+      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN)); \r
+      \r
+      gBS->FreePool (StringBuffer1);      \r
+      gBS->FreePool (StringBuffer2);            \r
+      //\r
+      // If the user hits the YES Response key, reset\r
+      //\r
+      if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN)) {\r
+        gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+      }\r
+      gST->ConOut->ClearScreen (gST->ConOut);\r
+    } \r
+  } \r
+} \r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/DevicePath.c b/EdkUnixPkg/Library/EdkGenericBdsLib/DevicePath.c
new file mode 100644 (file)
index 0000000..1bb7d70
--- /dev/null
@@ -0,0 +1,1040 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DevicePath.c\r
+\r
+Abstract:\r
+\r
+  BDS internal function define the default device path string, it can be\r
+  replaced by platform device path.\r
+\r
+--*/\r
+\r
+\r
+#ifdef TIANO_EXTENSION_FLAG\r
+EFI_GUID  UnknownDeviceGuid           = UNKNOWN_DEVICE_GUID;\r
+#endif \r
+\r
+EFI_GUID  mEfiUnixThunkProtocolGuid  = EFI_UNIX_THUNK_PROTOCOL_GUID;\r
+EFI_GUID  mEfiUnixUgaGuid            = EFI_UNIX_UGA_GUID;\r
+EFI_GUID  mEfiMsgPcAnsiGuid           = DEVICE_PATH_MESSAGING_PC_ANSI;\r
+EFI_GUID  mEfiMsgVt100Guid            = DEVICE_PATH_MESSAGING_VT_100;\r
+EFI_GUID  mEfiMsgVt100PlusGuid        = DEVICE_PATH_MESSAGING_VT_100_PLUS;\r
+EFI_GUID  mEfiMsgVt100Utf8Guid        = DEVICE_PATH_MESSAGING_VT_UTF8;\r
+\r
+VOID *\r
+ReallocatePool (\r
+  IN VOID                 *OldPool,\r
+  IN UINTN                OldSize,\r
+  IN UINTN                NewSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Adjusts the size of a previously allocated buffer.\r
+\r
+Arguments:\r
+\r
+  OldPool               - A pointer to the buffer whose size is being adjusted.\r
+\r
+  OldSize               - The size of the current buffer.\r
+\r
+  NewSize               - The size of the new buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The requested number of bytes were allocated.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.\r
+\r
+  EFI_INVALID_PARAMETER - The buffer was invalid.\r
+\r
+--*/\r
+{\r
+  VOID  *NewPool;\r
+\r
+  NewPool = NULL;\r
+  if (NewSize) {\r
+    NewPool = AllocateZeroPool (NewSize);\r
+  }\r
+\r
+  if (OldPool) {\r
+    if (NewPool) {\r
+      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
+    }\r
+\r
+    gBS->FreePool (OldPool);\r
+  }\r
+\r
+  return NewPool;\r
+}\r
+\r
+CHAR16 *\r
+CatPrint (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN CHAR16           *fmt,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+    Concatenates a formatted unicode string to allocated pool.  \r
+    The caller must free the resulting buffer.\r
+\r
+Arguments:\r
+\r
+    Str         - Tracks the allocated pool, size in use, and \r
+                  amount of pool allocated.\r
+\r
+    fmt         - The format string\r
+\r
+Returns:\r
+\r
+    Allocated buffer with the formatted string printed in it.  \r
+    The caller must free the allocated buffer.   The buffer\r
+    allocation is not packed.\r
+\r
+--*/\r
+{\r
+  UINT16  *AppendStr;\r
+  VA_LIST args;\r
+  UINTN   strsize;\r
+\r
+  AppendStr = AllocateZeroPool (0x1000);\r
+  if (AppendStr == NULL) {\r
+    return Str->str;\r
+  }\r
+\r
+  VA_START (args, fmt);\r
+  UnicodeVSPrint (AppendStr, 0x1000, fmt, args);\r
+  VA_END (args);\r
+  if (NULL == Str->str) {\r
+    strsize   = StrSize (AppendStr);\r
+    Str->str  = AllocateZeroPool (strsize);\r
+    ASSERT (Str->str != NULL);\r
+  } else {\r
+    strsize = StrSize (AppendStr) + StrSize (Str->str) - sizeof (UINT16);\r
+    Str->str = ReallocatePool (\r
+                Str->str,\r
+                StrSize (Str->str),\r
+                strsize\r
+                );\r
+    ASSERT (Str->str != NULL);\r
+  }\r
+\r
+  Str->maxlen = MAX_CHAR * sizeof (UINT16);\r
+  if (strsize < Str->maxlen) {\r
+    StrCat (Str->str, AppendStr);\r
+    Str->len = strsize - sizeof (UINT16);\r
+  }\r
+\r
+  gBS->FreePool (AppendStr);\r
+  return Str->str;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+BdsLibUnpackDevicePath (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function unpacks a device path data structure so that all the nodes\r
+  of a device path are naturally aligned.\r
+\r
+Arguments:\r
+\r
+  DevPath        - A pointer to a device path data structure\r
+\r
+Returns:\r
+\r
+  If the memory for the device path is successfully allocated, then a \r
+  pointer to the new device path is returned.  Otherwise, NULL is returned.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *Src;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Dest;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewPath;\r
+  UINTN                     Size;\r
+\r
+  //\r
+  // Walk device path and round sizes to valid boundries\r
+  //\r
+  Src   = DevPath;\r
+  Size  = 0;\r
+  for (;;) {\r
+    Size += DevicePathNodeLength (Src);\r
+    Size += ALIGN_SIZE (Size);\r
+\r
+    if (IsDevicePathEnd (Src)) {\r
+      break;\r
+    }\r
+\r
+    Src = NextDevicePathNode (Src);\r
+  }\r
+  //\r
+  // Allocate space for the unpacked path\r
+  //\r
+  NewPath = AllocateZeroPool (Size);\r
+  if (NewPath) {\r
+\r
+    ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
+\r
+    //\r
+    // Copy each node\r
+    //\r
+    Src   = DevPath;\r
+    Dest  = NewPath;\r
+    for (;;) {\r
+      Size = DevicePathNodeLength (Src);\r
+      CopyMem (Dest, Src, Size);\r
+      Size += ALIGN_SIZE (Size);\r
+      SetDevicePathNodeLength (Dest, Size);\r
+      Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
+      Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
+\r
+      if (IsDevicePathEnd (Src)) {\r
+        break;\r
+      }\r
+\r
+      Src = NextDevicePathNode (Src);\r
+    }\r
+  }\r
+\r
+  return NewPath;\r
+}\r
+\r
+VOID\r
+DevPathPci (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  PCI_DEVICE_PATH *Pci;\r
+\r
+  Pci = DevPath;\r
+  CatPrint (Str, L"Pci(%x|%x)", Pci->Device, Pci->Function);\r
+}\r
+\r
+VOID\r
+DevPathPccard (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  PCCARD_DEVICE_PATH  *Pccard;\r
+\r
+  Pccard = DevPath;\r
+  CatPrint (Str, L"Pcmcia(Function%x)", Pccard->FunctionNumber);\r
+}\r
+\r
+VOID\r
+DevPathMemMap (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEMMAP_DEVICE_PATH  *MemMap;\r
+\r
+  MemMap = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"MemMap(%d:%.lx-%.lx)",\r
+    MemMap->MemoryType,\r
+    MemMap->StartingAddress,\r
+    MemMap->EndingAddress\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathController (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CONTROLLER_DEVICE_PATH  *Controller;\r
+\r
+  Controller = DevPath;\r
+  CatPrint (Str, L"Ctrl(%d)", Controller->ControllerNumber);\r
+}\r
+\r
+VOID\r
+DevPathVendor (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Convert Vendor device path to device name\r
+\r
+Arguments:\r
+\r
+  Str     - The buffer store device name\r
+  DevPath - Pointer to vendor device path\r
+\r
+Returns:\r
+\r
+  When it return, the device name have been stored in *Str.\r
+\r
+--*/\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+  CHAR16              *Type;\r
+  INT32               *Temp;\r
+\r
+  Vendor  = DevPath;\r
+  Temp    = (INT32 *) (&Vendor->Guid);\r
+\r
+  switch (DevicePathType (&Vendor->Header)) {\r
+  case HARDWARE_DEVICE_PATH:\r
+    //\r
+    // If the device is an Unix device, we will give it a readable device name.\r
+    //\r
+    if (CompareGuid (&Vendor->Guid, &mEfiUnixThunkProtocolGuid)) {\r
+      CatPrint (Str, L"%s", L"UnixBus");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiUnixUgaGuid)) {\r
+      CatPrint (Str, L"%s", L"UGA");\r
+      return ;\r
+    } else {\r
+      Type = L"Hw";\r
+      break;\r
+    }\r
+\r
+  case MESSAGING_DEVICE_PATH:\r
+    //\r
+    // If the device is an Unix device, we will give it a readable device name.\r
+    //\r
+    if (CompareGuid (&Vendor->Guid, &mEfiMsgPcAnsiGuid)) {\r
+      CatPrint (Str, L"%s", L"PC-ANSI");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiMsgVt100Guid)) {\r
+      CatPrint (Str, L"%s", L"VT100");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiMsgVt100PlusGuid)) {\r
+      CatPrint (Str, L"%s", L"VT100+");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiMsgVt100Utf8Guid)) {\r
+      CatPrint (Str, L"%s", L"VT100-UTF8");\r
+      return ;\r
+    } else {\r
+      Type = L"Msg";\r
+      break;\r
+    }\r
+\r
+  case MEDIA_DEVICE_PATH:\r
+    Type = L"Media";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+\r
+  CatPrint (Str, L"Ven%s(%g)", Type, &Vendor->Guid);\r
+}\r
+\r
+VOID\r
+DevPathAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+\r
+  Acpi = DevPath;\r
+  if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+    CatPrint (Str, L"Acpi(PNP%04x,%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
+  } else {\r
+    CatPrint (Str, L"Acpi(%08x,%x)", Acpi->HID, Acpi->UID);\r
+  }\r
+}\r
+\r
+VOID\r
+DevPathAtapi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ATAPI_DEVICE_PATH *Atapi;\r
+\r
+  Atapi = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Ata(%s,%s)",\r
+    Atapi->PrimarySecondary ? L"Secondary" : L"Primary",\r
+    Atapi->SlaveMaster ? L"Slave" : L"Master"\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathScsi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  SCSI_DEVICE_PATH  *Scsi;\r
+\r
+  Scsi = DevPath;\r
+  CatPrint (Str, L"Scsi(Pun%x,Lun%x)", Scsi->Pun, Scsi->Lun);\r
+}\r
+\r
+VOID\r
+DevPathFibre (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
+\r
+  Fibre = DevPath;\r
+  CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);\r
+}\r
+\r
+VOID\r
+DevPath1394 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  F1394_DEVICE_PATH *F1394;\r
+\r
+  F1394 = DevPath;\r
+  CatPrint (Str, L"1394(%g)", &F1394->Guid);\r
+}\r
+\r
+VOID\r
+DevPathUsb (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_DEVICE_PATH *Usb;\r
+\r
+  Usb = DevPath;\r
+  CatPrint (Str, L"Usb(%x, %x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
+}\r
+\r
+VOID\r
+DevPathUsbClass (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+  UsbClass = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Usb Class(%x, %x, %x, %x, %x)",\r
+    UsbClass->VendorId,\r
+    UsbClass->ProductId,\r
+    UsbClass->DeviceClass,\r
+    UsbClass->DeviceSubClass,\r
+    UsbClass->DeviceProtocol\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathI2O (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  I2O_DEVICE_PATH *I2O;\r
+\r
+  I2O = DevPath;\r
+  CatPrint (Str, L"I2O(%x)", I2O->Tid);\r
+}\r
+\r
+VOID\r
+DevPathMacAddr (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MAC_ADDR_DEVICE_PATH  *MAC;\r
+  UINTN                 HwAddressSize;\r
+  UINTN                 Index;\r
+\r
+  MAC           = DevPath;\r
+\r
+  HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
+  if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {\r
+    HwAddressSize = 6;\r
+  }\r
+\r
+  CatPrint (Str, L"Mac(");\r
+\r
+  for (Index = 0; Index < HwAddressSize; Index++) {\r
+    CatPrint (Str, L"%02x", MAC->MacAddress.Addr[Index]);\r
+  }\r
+\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+VOID\r
+DevPathIPv4 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  IPv4_DEVICE_PATH  *IP;\r
+\r
+  IP = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"IPv4(%d.%d.%d.%d:%d)",\r
+    IP->RemoteIpAddress.Addr[0],\r
+    IP->RemoteIpAddress.Addr[1],\r
+    IP->RemoteIpAddress.Addr[2],\r
+    IP->RemoteIpAddress.Addr[3],\r
+    IP->RemotePort\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathIPv6 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  IPv6_DEVICE_PATH  *IP;\r
+\r
+  IP = DevPath;\r
+  CatPrint (Str, L"IP-v6(not-done)");\r
+}\r
+\r
+VOID\r
+DevPathInfiniBand (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
+\r
+  InfiniBand = DevPath;\r
+  CatPrint (Str, L"InfiniBand(not-done)");\r
+}\r
+\r
+VOID\r
+DevPathUart (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  UART_DEVICE_PATH  *Uart;\r
+  CHAR8             Parity;\r
+\r
+  Uart = DevPath;\r
+  switch (Uart->Parity) {\r
+  case 0:\r
+    Parity = 'D';\r
+    break;\r
+\r
+  case 1:\r
+    Parity = 'N';\r
+    break;\r
+\r
+  case 2:\r
+    Parity = 'E';\r
+    break;\r
+\r
+  case 3:\r
+    Parity = 'O';\r
+    break;\r
+\r
+  case 4:\r
+    Parity = 'M';\r
+    break;\r
+\r
+  case 5:\r
+    Parity = 'S';\r
+    break;\r
+\r
+  default:\r
+    Parity = 'x';\r
+    break;\r
+  }\r
+\r
+  if (Uart->BaudRate == 0) {\r
+    CatPrint (Str, L"Uart(DEFAULT %c", Parity);\r
+  } else {\r
+    CatPrint (Str, L"Uart(%d %c", Uart->BaudRate, Parity);\r
+  }\r
+\r
+  if (Uart->DataBits == 0) {\r
+    CatPrint (Str, L"D");\r
+  } else {\r
+    CatPrint (Str, L"%d", Uart->DataBits);\r
+  }\r
+\r
+  switch (Uart->StopBits) {\r
+  case 0:\r
+    CatPrint (Str, L"D)");\r
+    break;\r
+\r
+  case 1:\r
+    CatPrint (Str, L"1)");\r
+    break;\r
+\r
+  case 2:\r
+    CatPrint (Str, L"1.5)");\r
+    break;\r
+\r
+  case 3:\r
+    CatPrint (Str, L"2)");\r
+    break;\r
+\r
+  default:\r
+    CatPrint (Str, L"x)");\r
+    break;\r
+  }\r
+}\r
+\r
+VOID\r
+DevPathHardDrive (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+  Hd = DevPath;\r
+  switch (Hd->SignatureType) {\r
+  case SIGNATURE_TYPE_MBR:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,Sig%08x)",\r
+      Hd->PartitionNumber,\r
+      *((UINT32 *) (&(Hd->Signature[0])))\r
+      );\r
+    break;\r
+\r
+  case SIGNATURE_TYPE_GUID:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,Sig%g)",\r
+      Hd->PartitionNumber,\r
+      (EFI_GUID *) &(Hd->Signature[0])\r
+      );\r
+    break;\r
+\r
+  default:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,MBRType=%02x,SigType=%02x)",\r
+      Hd->PartitionNumber,\r
+      Hd->MBRType,\r
+      Hd->SignatureType\r
+      );\r
+    break;\r
+  }\r
+}\r
+\r
+VOID\r
+DevPathCDROM (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CDROM_DEVICE_PATH *Cd;\r
+\r
+  Cd = DevPath;\r
+  CatPrint (Str, L"CDROM(Entry%x)", Cd->BootEntry);\r
+}\r
+\r
+VOID\r
+DevPathFilePath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  FILEPATH_DEVICE_PATH  *Fp;\r
+\r
+  Fp = DevPath;\r
+  CatPrint (Str, L"%s", Fp->PathName);\r
+}\r
+\r
+VOID\r
+DevPathMediaProtocol (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_PROTOCOL_DEVICE_PATH  *MediaProt;\r
+\r
+  MediaProt = DevPath;\r
+  CatPrint (Str, L"%g", &MediaProt->Protocol);\r
+}\r
+\r
+VOID\r
+DevPathFvFilePath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
+\r
+  FvFilePath = DevPath;\r
+  CatPrint (Str, L"%g", &FvFilePath->NameGuid);\r
+}\r
+\r
+VOID\r
+DevPathBssBss (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  BBS_BBS_DEVICE_PATH *Bbs;\r
+  CHAR16              *Type;\r
+\r
+  Bbs = DevPath;\r
+  switch (Bbs->DeviceType) {\r
+  case BBS_TYPE_FLOPPY:\r
+    Type = L"Floppy";\r
+    break;\r
+\r
+  case BBS_TYPE_HARDDRIVE:\r
+    Type = L"Harddrive";\r
+    break;\r
+\r
+  case BBS_TYPE_CDROM:\r
+    Type = L"CDROM";\r
+    break;\r
+\r
+  case BBS_TYPE_PCMCIA:\r
+    Type = L"PCMCIA";\r
+    break;\r
+\r
+  case BBS_TYPE_USB:\r
+    Type = L"Usb";\r
+    break;\r
+\r
+  case BBS_TYPE_EMBEDDED_NETWORK:\r
+    Type = L"Net";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+  //\r
+  // Since current Print function hasn't implemented %a (for ansi string)\r
+  // we will only print Unicode strings.\r
+  //\r
+  CatPrint (Str, L"Legacy-%s", Type);\r
+}\r
+\r
+VOID\r
+DevPathEndInstance (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CatPrint (Str, L",");\r
+}\r
+\r
+VOID\r
+DevPathNodeUnknown (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CatPrint (Str, L"?");\r
+}\r
+\r
+DEVICE_PATH_STRING_TABLE  DevPathTable[] = {\r
+  {
+    HARDWARE_DEVICE_PATH,\r
+    HW_PCI_DP,\r
+    DevPathPci\r
+  },
+  {
+    HARDWARE_DEVICE_PATH,\r
+    HW_PCCARD_DP,\r
+    DevPathPccard\r
+  },
+  {
+    HARDWARE_DEVICE_PATH,\r
+    HW_MEMMAP_DP,\r
+    DevPathMemMap\r
+  },
+  {
+    HARDWARE_DEVICE_PATH,\r
+    HW_VENDOR_DP,\r
+    DevPathVendor\r
+  },
+  {
+    HARDWARE_DEVICE_PATH,\r
+    HW_CONTROLLER_DP,\r
+    DevPathController\r
+  },
+  {
+    ACPI_DEVICE_PATH,\r
+    ACPI_DP,\r
+    DevPathAcpi\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_ATAPI_DP,\r
+    DevPathAtapi\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_SCSI_DP,\r
+    DevPathScsi\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_FIBRECHANNEL_DP,\r
+    DevPathFibre\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_1394_DP,\r
+    DevPath1394\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_USB_DP,\r
+    DevPathUsb\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_USB_CLASS_DP,\r
+    DevPathUsbClass\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_I2O_DP,\r
+    DevPathI2O\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_MAC_ADDR_DP,\r
+    DevPathMacAddr\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_IPv4_DP,\r
+    DevPathIPv4\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_IPv6_DP,\r
+    DevPathIPv6\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_INFINIBAND_DP,\r
+    DevPathInfiniBand\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_UART_DP,\r
+    DevPathUart\r
+  },
+  {
+    MESSAGING_DEVICE_PATH,\r
+    MSG_VENDOR_DP,\r
+    DevPathVendor\r
+  },
+  {
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_HARDDRIVE_DP,\r
+    DevPathHardDrive\r
+  },
+  {
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_CDROM_DP,\r
+    DevPathCDROM\r
+  },
+  {
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_VENDOR_DP,\r
+    DevPathVendor\r
+  },
+  {
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_FILEPATH_DP,\r
+    DevPathFilePath\r
+  },
+  {
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_PROTOCOL_DP,\r
+    DevPathMediaProtocol\r
+  },
+\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+  {
+    MEDIA_DEVICE_PATH,\r
+    MEDIA_FV_FILEPATH_DP,\r
+    DevPathFvFilePath\r
+  },
+#endif\r
+\r
+  {
+    BBS_DEVICE_PATH,\r
+    BBS_BBS_DP,\r
+    DevPathBssBss\r
+  },
+  {
+    END_DEVICE_PATH_TYPE,\r
+    END_INSTANCE_DEVICE_PATH_SUBTYPE,\r
+    DevPathEndInstance\r
+  },
+  {
+    0,\r
+    0,\r
+    NULL\r
+  }
+};\r
+\r
+CHAR16 *\r
+DevicePathToStr (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  )\r
+/*++\r
+\r
+  Turns the Device Path into a printable string.  Allcoates\r
+  the string from pool.  The caller must SafeFreePool the returned\r
+  string.\r
+\r
+--*/\r
+{\r
+  POOL_PRINT                Str;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;\r
+  VOID (*DumpNode) (POOL_PRINT *, VOID *);\r
+\r
+  UINTN Index;\r
+  UINTN NewSize;\r
+\r
+  ZeroMem (&Str, sizeof (Str));\r
+\r
+  if (DevPath == NULL) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Unpacked the device path\r
+  //\r
+  DevPath = BdsLibUnpackDevicePath (DevPath);\r
+  ASSERT (DevPath);\r
+\r
+  //\r
+  // Process each device path node\r
+  //\r
+  DevPathNode = DevPath;\r
+  while (!IsDevicePathEnd (DevPathNode)) {\r
+    //\r
+    // Find the handler to dump this device path node\r
+    //\r
+    DumpNode = NULL;\r
+    for (Index = 0; DevPathTable[Index].Function; Index += 1) {\r
+\r
+      if (DevicePathType (DevPathNode) == DevPathTable[Index].Type &&\r
+          DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType\r
+          ) {\r
+        DumpNode = DevPathTable[Index].Function;\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If not found, use a generic function\r
+    //\r
+    if (!DumpNode) {\r
+      DumpNode = DevPathNodeUnknown;\r
+    }\r
+    //\r
+    //  Put a path seperator in if needed\r
+    //\r
+    if (Str.len && DumpNode != DevPathEndInstance) {\r
+      CatPrint (&Str, L"/");\r
+    }\r
+    //\r
+    // Print this node of the device path\r
+    //\r
+    DumpNode (&Str, DevPathNode);\r
+\r
+    //\r
+    // Next device path node\r
+    //\r
+    DevPathNode = NextDevicePathNode (DevPathNode);\r
+  }\r
+  //\r
+  // Shrink pool used for string allocation\r
+  //\r
+  gBS->FreePool (DevPath);\r
+\r
+Done:\r
+  NewSize = (Str.len + 1) * sizeof (CHAR16);\r
+  Str.str = ReallocatePool (Str.str, NewSize, NewSize);\r
+  ASSERT (Str.str != NULL);\r
+  Str.str[Str.len] = 0;\r
+  return Str.str;\r
+}\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+LibDuplicateDevicePathInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Function creates a device path data structure that identically matches the \r
+  device path passed in.\r
+\r
+Arguments:\r
+\r
+  DevPath      - A pointer to a device path data structure.\r
+\r
+Returns:\r
+\r
+  The new copy of DevPath is created to identically match the input.  \r
+  Otherwise, NULL is returned.\r
+\r
+--*/\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Temp;\r
+  UINTN                     Size;\r
+\r
+  //\r
+  // get the size of an instance from the input\r
+  //\r
+  Temp            = DevPath;\r
+  DevicePathInst  = GetNextDevicePathInstance (&Temp, &Size);\r
+\r
+  //\r
+  // Make a copy\r
+  //\r
+  NewDevPath = NULL;\r
+  if (Size) {\r
+    NewDevPath = AllocateZeroPool (Size);\r
+    ASSERT (NewDevPath != NULL);\r
+  }\r
+\r
+  if (NewDevPath) {\r
+    CopyMem (NewDevPath, DevicePathInst, Size);\r
+  }\r
+\r
+  return NewDevPath;\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/EdkGenericBdsLib.msa b/EdkUnixPkg/Library/EdkGenericBdsLib/EdkGenericBdsLib.msa
new file mode 100644 (file)
index 0000000..2944bb2
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>EdkGenericBdsLib</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>f3aaea62-8985-11db-baff-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>EDK Generic BDS Common APIs Library Instance.</Abstract>\r
+    <Description>The library instance provides common library routines help in \r
+    performance measurement, device path debug print, boot device selections,\r
+    boot device connection, console supports in BDS phase and boot from boot\r
+    device.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>EdkGenericBdsLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>EdkGenericBdsLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DxeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiRuntimeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DevicePathLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PerformanceLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>BdsBoot.c</Filename>\r
+    <Filename>BdsConsole.c</Filename>\r
+    <Filename>BdsConnect.c</Filename>\r
+    <Filename>DevicePath.c</Filename>\r
+    <Filename>Performance.h</Filename>\r
+    <Filename>Performance.c</Filename>\r
+    <Filename>BdsMisc.c</Filename>\r
+    <Filename SupArchList="IPF">Ipf/ShadowRom.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiFirmwareVolumeProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiAcpiS3SaveProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiSimpleNetworkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiShellFileGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/Ipf/ShadowRom.c b/EdkUnixPkg/Library/EdkGenericBdsLib/Ipf/ShadowRom.c
new file mode 100644 (file)
index 0000000..44a643d
--- /dev/null
@@ -0,0 +1,53 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+  ShadowRom.c\r
+\r
+Abstract:\r
+\r
+  Shadow all option rom\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "EfiDriverLib.h"\r
+\r
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)\r
+\r
+UINT8 mShadowRomFlag = 0;\r
+\r
+VOID\r
+ShadowAllOptionRom()\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;\r
+  //\r
+  // Rom shadow only do once.\r
+  //\r
+  if (mShadowRomFlag == 0) {\r
+    Status = gBS->LocateProtocol (\r
+                    &gEfiLegacyBiosProtocolGuid,\r
+                    NULL,\r
+                    &LegacyBios\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      LegacyBios->PrepareToBootEfi (LegacyBios, NULL, NULL);\r
+    }\r
+\r
+    mShadowRomFlag = 1;\r
+  }\r
+\r
+  return ;\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/Performance.c b/EdkUnixPkg/Library/EdkGenericBdsLib/Performance.c
new file mode 100644 (file)
index 0000000..4bf5e8a
--- /dev/null
@@ -0,0 +1,399 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Performance.c\r
+\r
+Abstract:\r
+\r
+  This file include the file which can help to get the system\r
+  performance, all the function will only include if the performance\r
+  switch is set.\r
+\r
+--*/\r
+\r
+#include "Performance.h"\r
+\r
+VOID\r
+ClearDebugRegisters (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // BugBug: We should not need to do this. We need to root cause this bug!!!!\r
+  //\r
+  AsmWriteDr0 (0);\r
+  AsmWriteDr1 (0);\r
+}\r
+\r
+STATIC\r
+VOID\r
+GetShortPdbFileName (\r
+  CHAR8  *PdbFileName,\r
+  CHAR8  *GaugeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  UINTN Index1;\r
+  UINTN StartIndex;\r
+  UINTN EndIndex;\r
+\r
+  if (PdbFileName == NULL) {\r
+    AsciiStrCpy (GaugeString, " ");\r
+  } else {\r
+    StartIndex = 0;\r
+    for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
+      ;\r
+\r
+    for (Index = 0; PdbFileName[Index] != 0; Index++) {\r
+      if (PdbFileName[Index] == '\\') {\r
+        StartIndex = Index + 1;\r
+      }\r
+\r
+      if (PdbFileName[Index] == '.') {\r
+        EndIndex = Index;\r
+      }\r
+    }\r
+\r
+    Index1 = 0;\r
+    for (Index = StartIndex; Index < EndIndex; Index++) {\r
+      GaugeString[Index1] = PdbFileName[Index];\r
+      Index1++;\r
+      if (Index1 == PERF_TOKEN_LENGTH - 1) {\r
+        break;\r
+      }\r
+    }\r
+\r
+    GaugeString[Index1] = 0;\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+\r
+\r
+STATIC\r
+CHAR8 *\r
+GetPdbPath (\r
+  VOID *ImageBase\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Located PDB path name in PE image\r
+\r
+Arguments:\r
+\r
+  ImageBase - base of PE to search\r
+\r
+Returns:\r
+\r
+  Pointer into image at offset of PDB file name if PDB file name is found,\r
+  Otherwise a pointer to an empty string.\r
+\r
+--*/\r
+{\r
+  PE_COFF_LOADER_IMAGE_CONTEXT          ImageContext;\r
+\r
+  ZeroMem (&ImageContext, sizeof (ImageContext));\r
+  ImageContext.Handle    = ImageBase;\r
+  ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r
+\r
+  PeCoffLoaderGetImageInfo (&ImageContext);\r
+\r
+  return ImageContext.PdbPointer;\r
+}\r
+\r
+\r
+STATIC\r
+VOID\r
+GetNameFromHandle (\r
+  IN  EFI_HANDLE     Handle,\r
+  OUT CHAR8          *GaugeString\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL   *Image;\r
+  CHAR8                       *PdbFileName;\r
+  EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;\r
+\r
+  AsciiStrCpy (GaugeString, " ");\r
+\r
+  //\r
+  // Get handle name from image protocol\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID **)&Image\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Status = gBS->OpenProtocol (\r
+                    Handle,\r
+                    &gEfiDriverBindingProtocolGuid,\r
+                    (VOID **) &DriverBinding,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return ;\r
+    }\r
+    //\r
+    // Get handle name from image protocol\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                    DriverBinding->ImageHandle,\r
+                    &gEfiLoadedImageProtocolGuid,\r
+                    (VOID **)&Image\r
+                    );\r
+  }\r
+\r
+  PdbFileName = GetPdbPath (Image->ImageBase);\r
+\r
+  if (PdbFileName != NULL) {\r
+    GetShortPdbFileName (PdbFileName, GaugeString);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+\r
+\r
+VOID\r
+WriteBootToOsPerformanceData (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Allocates a block of memory and writes performance data of booting to OS into it.\r
+\r
+Arguments:\r
+  \r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_CPU_ARCH_PROTOCOL     *Cpu;\r
+  EFI_PHYSICAL_ADDRESS      mAcpiLowMemoryBase;\r
+  UINT32                    mAcpiLowMemoryLength;\r
+  UINT32                    LimitCount;\r
+  PERF_HEADER               mPerfHeader;\r
+  PERF_DATA                 mPerfData;\r
+  EFI_HANDLE                *Handles;\r
+  UINTN                     NoHandles;\r
+  CHAR8                     GaugeString[PERF_TOKEN_LENGTH];\r
+  UINT8                     *Ptr;\r
+  UINT32                    mIndex;\r
+  UINT64                    Ticker;\r
+  UINT64                    Freq;\r
+  UINT32                    Duration;\r
+  UINT64                    CurrentTicker;\r
+  UINT64                    TimerPeriod;\r
+  UINTN                     LogEntryKey;\r
+  CONST VOID                *Handle;\r
+  CONST CHAR8               *Token;\r
+  CONST CHAR8               *Module;\r
+  UINT64                    StartTicker;\r
+  UINT64                    EndTicker;\r
+\r
+  //\r
+  // Retrive time stamp count as early as possilbe\r
+  //\r
+  Ticker = AsmReadTsc ();\r
+\r
+  //\r
+  // Allocate a block of memory that contain performance data to OS\r
+  //\r
+  mAcpiLowMemoryBase = 0xFFFFFFFF;\r
+  Status = gBS->AllocatePages (\r
+                  AllocateMaxAddress,\r
+                  EfiReservedMemoryType,\r
+                  4,\r
+                  &mAcpiLowMemoryBase\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+\r
+  mAcpiLowMemoryLength  = EFI_PAGES_TO_SIZE(4);\r
+\r
+  Ptr                   = (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));\r
+  LimitCount            = (mAcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);\r
+\r
+  //\r
+  // Initialize performance data structure\r
+  //\r
+  ZeroMem (&mPerfHeader, sizeof (PERF_HEADER));\r
+\r
+  //\r
+  // Get CPU frequency\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiCpuArchProtocolGuid,\r
+                  NULL,\r
+                  (VOID **)&Cpu\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePages (mAcpiLowMemoryBase, 4);\r
+    return ;\r
+  }\r
+  //\r
+  // Get Cpu Frequency\r
+  //\r
+  Status = Cpu->GetTimerValue (Cpu, 0, &(CurrentTicker), &TimerPeriod);\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePages (mAcpiLowMemoryBase, 4);\r
+    return ;\r
+  }\r
+\r
+  Freq                = DivU64x32 (1000000000000UL, (UINTN) TimerPeriod);\r
+\r
+  mPerfHeader.CpuFreq = Freq;\r
+\r
+  //\r
+  // Record BDS raw performance data\r
+  //\r
+  mPerfHeader.BDSRaw = Ticker;\r
+\r
+  //\r
+  // Put Detailed performance data into memory\r
+  //\r
+  Handles = NULL;\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &NoHandles,\r
+                  &Handles\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->FreePages (mAcpiLowMemoryBase, 4);\r
+    return ;\r
+  }\r
+  //\r
+  // Get DXE drivers performance\r
+  //\r
+  for (mIndex = 0; mIndex < NoHandles; mIndex++) {\r
+    Ticker = 0;\r
+    LogEntryKey = 0;\r
+    while ((LogEntryKey = GetPerformanceMeasurement (\r
+                            LogEntryKey,\r
+                            &Handle,\r
+                            &Token,\r
+                            &Module,\r
+                            &StartTicker,\r
+                            &EndTicker)) != 0) {\r
+      if ((Handle == Handles[mIndex]) && (StartTicker < EndTicker)) {\r
+        Ticker += (EndTicker - StartTicker);\r
+      }\r
+    }\r
+\r
+    Duration = (UINT32) DivU64x32 (\r
+                          Ticker,\r
+                          (UINT32) Freq\r
+                          );\r
+\r
+    if (Duration > 0) {\r
+      ZeroMem (&mPerfData, sizeof (PERF_DATA));\r
+\r
+      GetNameFromHandle (Handles[mIndex], GaugeString);\r
+\r
+      AsciiStrCpy (mPerfData.Token, GaugeString);\r
+      mPerfData.Duration = Duration;\r
+\r
+      CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));\r
+      Ptr += sizeof (PERF_DATA);\r
+\r
+      mPerfHeader.Count++;\r
+      if (mPerfHeader.Count == LimitCount) {\r
+        goto Done;\r
+      }\r
+    }\r
+  }\r
+\r
+  gBS->FreePool (Handles);\r
+\r
+  //\r
+  // Get inserted performance data\r
+  //\r
+  LogEntryKey = 0;\r
+  while ((LogEntryKey = GetPerformanceMeasurement (\r
+                          LogEntryKey,\r
+                          &Handle,\r
+                          &Token,\r
+                          &Module,\r
+                          &StartTicker,\r
+                          &EndTicker)) != 0) {\r
+    if ((Handle == NULL) && (StartTicker <= EndTicker)) {\r
+\r
+      ZeroMem (&mPerfData, sizeof (PERF_DATA));\r
+\r
+      AsciiStrnCpy (mPerfData.Token, Token, DXE_PERFORMANCE_STRING_SIZE);\r
+      mPerfData.Duration = (UINT32) DivU64x32 (\r
+                                      EndTicker - StartTicker,\r
+                                      (UINT32) Freq\r
+                                      );\r
+\r
+      CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));\r
+      Ptr += sizeof (PERF_DATA);\r
+\r
+      mPerfHeader.Count++;\r
+      if (mPerfHeader.Count == LimitCount) {\r
+        goto Done;\r
+      }\r
+    }\r
+  }\r
+\r
+Done:\r
+\r
+  ClearDebugRegisters ();\r
+\r
+  mPerfHeader.Signiture = 0x66726550;\r
+\r
+  //\r
+  // Put performance data to memory\r
+  //\r
+  CopyMem (\r
+    (UINT32 *) (UINT32) mAcpiLowMemoryBase,\r
+    &mPerfHeader,\r
+    sizeof (PERF_HEADER)\r
+    );\r
+\r
+  gRT->SetVariable (\r
+        L"PerfDataMemAddr",\r
+        &gEfiGlobalVariableGuid,\r
+        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+        sizeof (UINT32),\r
+        (VOID *) &mAcpiLowMemoryBase\r
+        );\r
+\r
+  return ;\r
+}\r
diff --git a/EdkUnixPkg/Library/EdkGenericBdsLib/Performance.h b/EdkUnixPkg/Library/EdkGenericBdsLib/Performance.h
new file mode 100644 (file)
index 0000000..e7f80ab
--- /dev/null
@@ -0,0 +1,55 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  Performance.h\r
+\r
+Abstract:\r
+\r
+  This file included the performance relete function header and \r
+  definition.\r
+\r
+--*/\r
+\r
+#ifndef _PERF_H_\r
+#define _PERF_H_\r
+\r
+#define PERF_TOKEN_LENGTH       28\r
+#define PERF_PEI_ENTRY_MAX_NUM  50\r
+\r
+typedef struct {\r
+  CHAR8   Token[PERF_TOKEN_LENGTH];\r
+  UINT32  Duration;\r
+} PERF_DATA;\r
+\r
+typedef struct {\r
+  UINT64        BootToOs;\r
+  UINT64        S3Resume;\r
+  UINT32        S3EntryNum;\r
+  PERF_DATA     S3Entry[PERF_PEI_ENTRY_MAX_NUM];\r
+  UINT64        CpuFreq;\r
+  UINT64        BDSRaw;\r
+  UINT32        Count;\r
+  UINT32        Signiture;\r
+} PERF_HEADER;\r
+\r
+VOID\r
+WriteBootToOsPerformanceData (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+ClearDebugRegisters (\r
+  VOID\r
+  );\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa b/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/EdkUnixPeiPeCoffGetEntryPointLib.msa
new file mode 100644 (file)
index 0000000..1c44900
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>EdkUnixPeiPeCoffGetEntryPointLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f3b702e8-8985-11db-9558-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.</Abstract>\r
+    <Description>PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>EdkUnixPeiPeCoffGetEntryPointLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>PeCoffGetEntryPointLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>PeCoffGetEntryPoint.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gUnixPeiLoadFilePpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/EdkUnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
new file mode 100644 (file)
index 0000000..c0d0a01
--- /dev/null
@@ -0,0 +1,75 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  PeCoffGetEntryPoint.c\r
+\r
+Abstract:\r
+\r
+  Tiano PE/COFF loader\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetEntryPoint (\r
+  IN     VOID  *Pe32Data,\r
+  IN OUT VOID  **EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Loads a PE/COFF image into memory\r
+\r
+Arguments:\r
+\r
+  Pe32Data   - Pointer to a PE/COFF Image\r
+\r
+  EntryPoint - Pointer to the entry point of the PE/COFF image\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS            if the EntryPoint was returned\r
+  EFI_INVALID_PARAMETER  if the EntryPoint could not be found from Pe32Data\r
+\r
+--*/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
+  UNIX_PEI_LOAD_FILE_PPI *PeiUnixService;\r
+  EFI_PHYSICAL_ADDRESS    ImageAddress;\r
+  UINT64                  ImageSize;\r
+  EFI_PHYSICAL_ADDRESS    ImageEntryPoint;\r
+\r
+  Status = PeiServicesLocatePpi (\r
+             &gUnixPeiLoadFilePpiGuid,\r
+             0,\r
+             &PpiDescriptor,\r
+             (void **)&PeiUnixService\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = PeiUnixService->PeiLoadFileService (\r
+                           Pe32Data,\r
+                           &ImageAddress,\r
+                           &ImageSize,\r
+                           &ImageEntryPoint\r
+                           );\r
+  *EntryPoint = (VOID*)(UINTN)ImageEntryPoint;\r
+  return Status;\r
+}
diff --git a/EdkUnixPkg/Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.c b/EdkUnixPkg/Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.c
new file mode 100644 (file)
index 0000000..34f5e0d
--- /dev/null
@@ -0,0 +1,246 @@
+/** @file\r
+  OEM hook status code library functions with no library constructor/destructor\r
+\r
+  Copyright (c) 2006, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  Module Name:  UnixOemHookStatusCodeLib.c\r
+\r
+**/\r
+\r
+//\r
+// Cache of UnixThunk protocol \r
+//\r
+STATIC\r
+EFI_UNIX_THUNK_PROTOCOL   *mUnix;\r
+\r
+//\r
+// Cache of standard output handle . \r
+//\r
+STATIC\r
+int                      mStdOut;\r
+\r
+/**\r
+\r
+  Initialize OEM status code device .\r
+\r
+  @return    Always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeInitialize (\r
+  VOID\r
+  )\r
+{\r
+  PEI_UNIX_THUNK_PPI  *UnixThunkPpi;\r
+  EFI_STATUS        Status;\r
+\r
+  if (FeaturePcdGet (PcdUnixStatusCodeLibUseForPei)) {\r
+    //\r
+    // Locate NtThunkPpi for retrieving standard output handle\r
+    //\r
+    Status = PeiServicesLocatePpi (\r
+               &gPeiUnixThunkPpiGuid,\r
+               0,\r
+               NULL,\r
+               (VOID **) &UnixThunkPpi\r
+               );\r
+\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    mUnix  = (EFI_UNIX_THUNK_PROTOCOL *) UnixThunkPpi->UnixThunk ();\r
+  } else {\r
+    EFI_HOB_GUID_TYPE        *GuidHob;\r
+\r
+    //\r
+    // Retrieve UnixThunkProtocol from GUID'ed HOB\r
+    //\r
+    GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);\r
+    ASSERT (GuidHob != NULL);\r
+    mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
+    ASSERT (mUnix != NULL);\r
+  }\r
+\r
+  //\r
+  // Cache standard output handle.\r
+  //\r
+  mStdOut = 1;
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Report status code to OEM device.\r
\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This included information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  For progress codes, the operation is the current activity. \r
+                        For error codes, it is the exception.  For debug codes, it is not defined at this time. \r
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\r
+  @param  CallerId      This optional parameter may be used to identify the caller. \r
+                        This parameter allows the status code driver to apply different rules to different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeReport (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId, OPTIONAL\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\r
+{\r
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  CHAR8           *Format;\r
+  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT32          ErrorLevel;\r
+  UINT32          LineNumber;\r
+  UINTN           CharCount;\r
+  VA_LIST         Marker;\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+\r
+  Buffer[0] = '\0';\r
+\r
+  if (Data != NULL &&\r
+      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+    //\r
+    // Print ASSERT() information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer,\r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                  "\n\rASSERT!: %a (%d): %a\n\r",\r
+                  Filename,\r
+                  LineNumber,\r
+                  Description\r
+                  );\r
+\r
+    //\r
+    // Callout to standard output.\r
+    //\r
+    mUnix->Write (\r
+              mStdOut,\r
+              Buffer,\r
+              CharCount\r
+             );
+\r
+    return EFI_SUCCESS;\r
+\r
+  } else if (Data != NULL &&\r
+             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+    //\r
+    // Print DEBUG() information into output buffer.\r
+    //\r
+    CharCount = AsciiVSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  Format, \r
+                  Marker\r
+                  );\r
+  } else if (Data != NULL && \r
+             CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r
+             (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+    //\r
+    // Print specific data into output buffer.\r
+    //\r
+    DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
+    Marker    = (VA_LIST) (DebugInfo + 1);\r
+    Format    = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
+\r
+    CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+    //\r
+    // Print ERROR information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "ERROR: C%x:V%x I%x", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+\r
+    //\r
+    // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r
+    //\r
+    \r
+    if (CallerId != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                   "\n\r"\r
+                   );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "PROGRESS CODE: V%x I%x\n\r", \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  } else {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+  //\r
+  // Callout to standard output.\r
+  //\r
+  mUnix->Write (\r
+            mStdOut,\r
+            Buffer,\r
+            CharCount\r
+            );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/EdkUnixPkg/Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.msa b/EdkUnixPkg/Library/UnixOemHookStatusCodeLib/UnixOemHookStatusCodeLib.msa
new file mode 100644 (file)
index 0000000..8593902
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixOemHookStatusCodeLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f3c32014-8985-11db-bae7-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Memory Status Code Library for UEFI drivers</Abstract>\r
+    <Description>Lib to provide memory journal status code reporting Routines</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>\r
+      All rights reserved.\r
+      This software and associated documentation (if any) is furnished\r
+      under a license and may only be used or copied in accordance\r
+      with the terms of the license. Except as permitted by such\r
+      license, no part of this software or documentation may be\r
+      reproduced, stored in a retrieval system, or transmitted in any\r
+      form or by any means without the express written consent of\r
+      Intel Corporation.\r
+    </License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixOemHookStatusCodeLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>OemHookStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UnixLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixOemHookStatusCodeLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gPeiUnixThunkPpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+  <PcdCoded xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdUnixStatusCodeLibUseForPei</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>Select which type of driver the library links against.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Library/UnixPeCoffLoaderLib/UnixPeCoffLoader.c b/EdkUnixPkg/Library/UnixPeCoffLoaderLib/UnixPeCoffLoader.c
new file mode 100644 (file)
index 0000000..ead7752
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  TianoPeCoffLoader.c\r
+\r
+Abstract:\r
+\r
+  Wrap the Base PE/COFF loader with the PE COFF Protocol\r
+\r
+\r
+--*/\r
+\r
+\r
+\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL  *mPeiEfiPeiPeCoffLoader;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderConstructor (\r
+  IN EFI_FFS_FILE_HEADER      *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = (*PeiServices)->LocatePpi (\r
+                            PeiServices,\r
+                            &gEfiPeiPeCoffLoaderGuid,\r
+                            0,\r
+                            NULL,\r
+                            (VOID **)&mPeiEfiPeiPeCoffLoader\r
+                            );\r
+  return Status;\r
+}\r
+\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL *\r
+EFIAPI\r
+GetPeCoffLoaderProtocol (\r
+  )\r
+{\r
+  return mPeiEfiPeiPeCoffLoader;\r
+}\r
diff --git a/EdkUnixPkg/Library/UnixPeCoffLoaderLib/UnixPeCoffLoaderLib.msa b/EdkUnixPkg/Library/UnixPeCoffLoaderLib/UnixPeCoffLoaderLib.msa
new file mode 100644 (file)
index 0000000..60f5e24
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixPeCoffLoaderLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f3cf597e-8985-11db-95f6-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for the Nt32PeCoffLoaderLib library.</Abstract>\r
+    <Description>EdkPeCoffLoaderLib library class for NT32 instance implemented by PeiPeCoffLoader PPI.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixPeCoffLoaderLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>EdkPeCoffLoaderLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixPeCoffLoader.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Guids>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiPeiPeCoffLoaderGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <Constructor>PeCoffLoaderConstructor</Constructor>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Library/UnixTimerLibNull/UnixTimerLib.c b/EdkUnixPkg/Library/UnixTimerLibNull/UnixTimerLib.c
new file mode 100644 (file)
index 0000000..2c6495e
--- /dev/null
@@ -0,0 +1,113 @@
+/** @file\r
+  Timer Library functions for Unix platform.\r
+\r
+  @bug Still no complete implementation for time library function for Unix platform.\r
+\r
+  Copyright (c) 2006, Intel Corporation<BR>\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  Module Name:  UnixTimerLib.c\r
+\r
+**/\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return MicroSeconds;\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  Retrieves the current value of a 64-bit free running performance counter. The\r
+  counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return 0;\r
+}\r
diff --git a/EdkUnixPkg/Library/UnixTimerLibNull/UnixTimerLib.msa b/EdkUnixPkg/Library/UnixTimerLibNull/UnixTimerLib.msa
new file mode 100644 (file)
index 0000000..f7a6cd4
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixTimerLib</ModuleName>\r
+    <ModuleType>BASE</ModuleType>\r
+    <GuidValue>f3db5724-8985-11db-acbc-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Nt32Timer Library</Abstract>\r
+    <Description>Timer Library provide API of TimerLib library class for Nt32 platform,\r
+      Now this library do not impletement functionality completely.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixTimerLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>TimerLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename SupArchList="IA32">UnixTimerLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Logo/Logo.bmp b/EdkUnixPkg/Logo/Logo.bmp
new file mode 100644 (file)
index 0000000..3e85229
Binary files /dev/null and b/EdkUnixPkg/Logo/Logo.bmp differ
diff --git a/EdkUnixPkg/Logo/Logo.msa b/EdkUnixPkg/Logo/Logo.msa
new file mode 100644 (file)
index 0000000..d64bb07
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea  xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>Logo</ModuleName>\r
+    <ModuleType>BASE</ModuleType>\r
+    <GuidValue>7BB28B99-61BB-11D5-9A5D-0090273FC14D</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for creating a Logo file.</Abstract>\r
+    <Description>This module provides the logo bitmap picture shown on setup screen.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>true</BinaryModule>\r
+    <OutputFileBasename>Logo</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <SourceFiles>\r
+    <Filename>Logo.bmp</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+  </PackageDependencies>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.c
new file mode 100644 (file)
index 0000000..35c61af
--- /dev/null
@@ -0,0 +1,132 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  UnixAutoscan.c\r
+\r
+Abstract:\r
+  This PEIM to abstract memory auto-scan in an Unix environment.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeUnixAutoScan (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a call-back into the SEC simulator to get a memory value\r
+\r
+Arguments:\r
+  FfsHeader   - General purpose data available to every PEIM\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
+  PEI_UNIX_AUTOSCAN_PPI      *PeiUnixService;\r
+  UINT64                      MemorySize;\r
+  EFI_PHYSICAL_ADDRESS        MemoryBase;\r
+  PEI_BASE_MEMORY_TEST_PPI    *MemoryTestPpi;\r
+  EFI_PHYSICAL_ADDRESS        ErrorAddress;\r
+  UINTN                       Index;\r
+  EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
+\r
+\r
+  DEBUG ((EFI_D_ERROR, "Unix Autoscan PEIM Loaded\n"));\r
+\r
+  //\r
+  // Get the PEI NT Autoscan PPI\r
+  //\r
+  Status = (**PeiServices).LocatePpi (\r
+                            PeiServices,\r
+                            &gPeiUnixAutoScanPpiGuid, // GUID\r
+                            0,                      // INSTANCE\r
+                            &PpiDescriptor,         // EFI_PEI_PPI_DESCRIPTOR\r
+                            (VOID **)&PeiUnixService           // PPI\r
+                            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get the Memory Test PPI\r
+  //\r
+  Status = (**PeiServices).LocatePpi (\r
+                            PeiServices,\r
+                            &gPeiBaseMemoryTestPpiGuid,\r
+                            0,\r
+                            NULL,\r
+                            (VOID **)&MemoryTestPpi\r
+                            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Index = 0;\r
+  do {\r
+    Status = PeiUnixService->UnixAutoScan (Index, &MemoryBase, &MemorySize);\r
+    if (!EFI_ERROR (Status)) {\r
+      Attributes =\r
+        (\r
+          EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
+          EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
+          EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
+          EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
+          EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
+          EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
+        );\r
+\r
+      if (Index == 0) {\r
+        //\r
+        // For the first area register it as PEI tested memory\r
+        //\r
+        Status = MemoryTestPpi->BaseMemoryTest (\r
+                                  PeiServices,\r
+                                  MemoryTestPpi,\r
+                                  MemoryBase,\r
+                                  MemorySize,\r
+                                  Quick,\r
+                                  &ErrorAddress\r
+                                  );\r
+        ASSERT_EFI_ERROR (Status);\r
+\r
+        //\r
+        // Register the "tested" memory with the PEI Core\r
+        //\r
+        Status = (**PeiServices).InstallPeiMemory (PeiServices, MemoryBase, MemorySize);\r
+        ASSERT_EFI_ERROR (Status);\r
+\r
+        Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;\r
+      }\r
+      \r
+      BuildResourceDescriptorHob (\r
+        EFI_RESOURCE_SYSTEM_MEMORY,\r
+        Attributes,\r
+        MemoryBase,\r
+        MemorySize\r
+        );\r
+    }\r
+    Index++;\r
+  } while (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
+  //\r
+  BuildCpuHob (36, 16);\r
+  \r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.dxs
new file mode 100644 (file)
index 0000000..8ad9088
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixAutoscan.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression file for UnixAutoscan.\r
+\r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+  PEI_UNIX_AUTOSCAN_PPI_GUID AND EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI AND PEI_BASE_MEMORY_TEST_GUID\r
+DEPENDENCY_END\r
+\r
+\r
diff --git a/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa b/EdkUnixPkg/Pei/AutoScan/UnixAutoScan.msa
new file mode 100644 (file)
index 0000000..60830b6
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <MsaHeader>
+    <ModuleName>UnixAutoScan</ModuleName>
+    <ModuleType>PEIM</ModuleType>
+    <GuidValue>f3f36cb0-8985-11db-b195-0040d02b1835</GuidValue>
+    <Version>1.0</Version>
+    <Abstract>Component description file for UnixAutoScan module</Abstract>
+    <Description>This module abstracts memory auto-scan in a Unix environment.</Description>
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>
+  </MsaHeader>
+  <ModuleDefinitions>
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+    <BinaryModule>false</BinaryModule>
+    <OutputFileBasename>UnixAutoScan</OutputFileBasename>
+  </ModuleDefinitions>
+  <LibraryClassDefinitions>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>DebugLib</Keyword>
+    </LibraryClass>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>PeimEntryPoint</Keyword>
+    </LibraryClass>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>BaseLib</Keyword>
+    </LibraryClass>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>BaseMemoryLib</Keyword>
+    </LibraryClass>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>HobLib</Keyword>
+    </LibraryClass>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>PeiServicesLib</Keyword>
+    </LibraryClass>
+    <LibraryClass Usage="ALWAYS_CONSUMED">
+      <Keyword>PeiServicesTablePointerLib</Keyword>
+    </LibraryClass>
+  </LibraryClassDefinitions>
+  <SourceFiles>
+    <Filename>UnixAutoScan.c</Filename>
+    <Filename>UnixAutoScan.dxs</Filename>
+  </SourceFiles>
+  <PackageDependencies>
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+  </PackageDependencies>
+  <PPIs>
+    <Ppi Usage="ALWAYS_CONSUMED">
+      <PpiCName>gPeiUnixAutoScanPpiGuid</PpiCName>
+    </Ppi>
+    <Ppi Usage="ALWAYS_CONSUMED">
+      <PpiCName>gPeiBaseMemoryTestPpiGuid</PpiCName>
+    </Ppi>
+    <Ppi Usage="ALWAYS_PRODUCED">
+      <PpiCName>gEfiPeiMemoryDiscoveredPpiGuid</PpiCName>
+    </Ppi>
+  </PPIs>
+  <Externs>
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+    <Extern>
+      <ModuleEntryPoint>PeimInitializeUnixAutoScan</ModuleEntryPoint>
+    </Extern>
+  </Externs>
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/BootMode/BootMode.c b/EdkUnixPkg/Pei/BootMode/BootMode.c
new file mode 100644 (file)
index 0000000..b368dc1
--- /dev/null
@@ -0,0 +1,85 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMode.c\r
+   \r
+Abstract:\r
+\r
+  Tiano PEIM to provide the platform support functionality within Windows\r
+\r
+--*/\r
+\r
+\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_PPI_DESCRIPTOR  mPpiListBootMode = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiMasterBootModePpiGuid,\r
+  NULL\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR  mPpiListRecoveryBootMode = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiBootInRecoveryModePpiGuid,\r
+  NULL\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeBootMode (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Peform the boot mode determination logic\r
+\r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS if the boot mode could be set\r
+\r
+--*/\r
+// TODO:    FfsHeader - add argument and description to function comment\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       BootMode;\r
+\r
+  DEBUG ((EFI_D_ERROR, "Unix Boot Mode PEIM Loaded\n"));\r
+\r
+  //\r
+  // Let's assume things are OK if not told otherwise\r
+  // Should we read an environment variable in order to easily change this?\r
+  //\r
+  BootMode  = BOOT_WITH_FULL_CONFIGURATION;\r
+\r
+  Status    = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
+    Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Pei/BootMode/BootMode.dxs b/EdkUnixPkg/Pei/BootMode/BootMode.dxs
new file mode 100644 (file)
index 0000000..fd91a09
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  BootMode.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression file for BootMode.\r
+\r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END\r
+\r
+\r
diff --git a/EdkUnixPkg/Pei/BootMode/BootMode.msa b/EdkUnixPkg/Pei/BootMode/BootMode.msa
new file mode 100644 (file)
index 0000000..5b2c8d8
--- /dev/null
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>BootMode</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f3ff9aee-8985-11db-b133-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for BootMode module</Abstract>\r
+    <Description>This module provides platform specific function to detect boot mode.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>BootMode</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeimEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesTablePointerLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>BootMode.c</Filename>\r
+    <Filename>BootMode.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="SOMETIMES_PRODUCED">\r
+      <PpiCName>gEfiPeiBootInRecoveryModePpiGuid</PpiCName>\r
+    </Ppi>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gEfiPeiMasterBootModePpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>InitializeBootMode</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.c
new file mode 100644 (file)
index 0000000..8bec9f3
--- /dev/null
@@ -0,0 +1,123 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  UnixFwh.c\r
+    \r
+Abstract:\r
+  PEIM to abstract construction of firmware volume in an Unix environment.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+#include <FlashLayout.h>\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeUnixFwh (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
+\r
+Arguments:\r
+  FfsHeader   - Ffs Header availible to every PEIM\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
+  UNIX_FWH_PPI               *FwhPpi;\r
+  EFI_PHYSICAL_ADDRESS        FdBase;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  UINT64                      FdSize;\r
+  UINTN                       Index;\r
+\r
+  DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));\r
+\r
+  //\r
+  // Get the Fwh Information PPI\r
+  //\r
+  Status = (**PeiServices).LocatePpi (\r
+                            PeiServices,\r
+                            &gUnixFwhPpiGuid, // GUID\r
+                            0,              // INSTANCE\r
+                            &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
+                            (VOID **)&FwhPpi         // PPI\r
+                            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Index = 0;\r
+  do {\r
+    //\r
+    // Get information about all the FD's in the system\r
+    //\r
+    Status = FwhPpi->UnixFwh (Index, &FdBase, &FdSize);\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Assume the FD starts with an FV header\r
+      //\r
+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
+\r
+      //\r
+      // Make an FV Hob for the first FV in the FD\r
+      //\r
+      BuildFvHob (FdBase, FvHeader->FvLength);\r
+\r
+      if (Index == 0) {\r
+        //\r
+        // Assume the first FD was produced by the NT32.DSC\r
+        //  All these strange offests are needed to keep in\r
+        //  sync with the FlashMap and NT32.dsc file\r
+        //\r
+        BuildResourceDescriptorHob (\r
+          EFI_RESOURCE_FIRMWARE_DEVICE,\r
+          (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
+          FdBase,\r
+          (FvHeader->FvLength + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH)\r
+          );\r
+\r
+        //\r
+        // Hard code the address of the spare block and variable services.\r
+        //  Assume it's a hard coded offset from FV0 in FD0.\r
+        //\r
+        FdBase  = FdBase + EFI_WINNT_RUNTIME_UPDATABLE_OFFSET;\r
+        FdSize  = EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH;\r
+\r
+        BuildFvHob (FdBase, FdSize);\r
+      } else {\r
+        //\r
+        // For other FD's just map them in.\r
+        //\r
+        BuildResourceDescriptorHob (\r
+          EFI_RESOURCE_FIRMWARE_DEVICE,\r
+          (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
+          FdBase,\r
+          FdSize\r
+          );\r
+      }\r
+    }\r
+\r
+    Index++;\r
+  } while (!EFI_ERROR (Status));\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.dxs
new file mode 100644 (file)
index 0000000..3302a5d
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixFwh.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression file for UnixFwh PEIM.\r
+\r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+  UNIX_FWH_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID\r
+DEPENDENCY_END\r
+\r
+\r
diff --git a/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa b/EdkUnixPkg/Pei/FirmwareVolume/UnixFwh.msa
new file mode 100644 (file)
index 0000000..f46801a
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixFwh</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f40b7864-8985-11db-af21-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for WinNtFwh module</Abstract>\r
+    <Description>This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices\r
+    on the NT32 emulator.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixFwh</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeimEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesTablePointerLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixFwh.c</Filename>\r
+    <Filename>UnixFwh.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gUnixFwhPpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>PeimInitializeUnixFwh</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Pei/FlashMap/FlashMap.c b/EdkUnixPkg/Pei/FlashMap/FlashMap.c
new file mode 100644 (file)
index 0000000..9c57f2e
--- /dev/null
@@ -0,0 +1,302 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FlashMap.c\r
+   \r
+Abstract:\r
+\r
+  PEIM to build GUIDed HOBs for platform specific flash map\r
+\r
+--*/\r
+\r
+\r
+#include <FlashLayout.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetAreaInfo (\r
+  IN  EFI_PEI_SERVICES            **PeiServices,\r
+  IN PEI_FLASH_MAP_PPI            *This,\r
+  IN  EFI_FLASH_AREA_TYPE         AreaType,\r
+  IN  EFI_GUID                    *AreaTypeGuid,\r
+  OUT UINT32                      *NumEntries,\r
+  OUT EFI_FLASH_SUBAREA_ENTRY     **Entries\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MemoryDiscoveredPpiNotifyCallback (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
+  IN VOID                       *Ppi\r
+  );\r
+\r
+//\r
+// Module globals\r
+//\r
+static PEI_FLASH_MAP_PPI      mFlashMapPpi = { GetAreaInfo };\r
+\r
+static EFI_PEI_PPI_DESCRIPTOR mPpiListFlashMap = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gPeiFlashMapPpiGuid,\r
+  &mFlashMapPpi\r
+};\r
+\r
+static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {\r
+  //\r
+  // Variable area\r
+  //\r
+  {\r
+    EFI_VARIABLE_STORE_OFFSET,\r
+    EFI_VARIABLE_STORE_LENGTH,\r
+    EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
+    EFI_FLASH_AREA_EFI_VARIABLES,\r
+    0, 0, 0,\r
+    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
+  },\r
+  //\r
+  // FTW spare (backup) block\r
+  //\r
+  {\r
+    EFI_WINNT_FTW_SPARE_BLOCK_OFFSET,\r
+    EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
+    EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
+    EFI_FLASH_AREA_FTW_BACKUP,\r
+    0, 0, 0,\r
+    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
+  },\r
+  //\r
+  // FTW private working (state) area\r
+  //\r
+  {\r
+    EFI_FTW_WORKING_OFFSET,\r
+    EFI_FTW_WORKING_LENGTH,\r
+    EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
+    EFI_FLASH_AREA_FTW_STATE,\r
+    0, 0, 0,\r
+    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
+  },\r
+  //\r
+  // Recovery FV\r
+  //\r
+  {\r
+    EFI_WINNT_FIRMWARE_OFFSET,\r
+    EFI_WINNT_FIRMWARE_LENGTH,\r
+    EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
+    EFI_FLASH_AREA_RECOVERY_BIOS,\r
+    0, 0, 0,\r
+    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
+  },\r
+  //\r
+  // System Non-Volatile Storage FV\r
+  //\r
+  {\r
+    EFI_WINNT_RUNTIME_UPDATABLE_OFFSET,\r
+    EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
+    EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
+    EFI_FLASH_AREA_GUID_DEFINED,\r
+    0, 0, 0,\r
+    EFI_SYSTEM_NV_DATA_HOB_GUID\r
+  },\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeFlashMap (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Build GUIDed HOBs for platform specific flash map\r
+  \r
+Arguments:\r
+  FfsHeader   - A pointer to the EFI_FFS_FILE_HEADER structure.\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+  EFI_STATUS\r
+\r
+--*/\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  UNIX_FWH_PPI           *UnixFwhPpi;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
+  EFI_PHYSICAL_ADDRESS    FdBase;\r
+  UINT64                  FdSize;\r
+  UINTN                   NumOfHobData;\r
+  UINTN                   Index;\r
+  EFI_FLASH_AREA_HOB_DATA FlashHobData;\r
+\r
+  DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n"));\r
+\r
+  //\r
+  // Install FlashMap PPI\r
+  //\r
+  Status = PeiServicesInstallPpi (&mPpiListFlashMap);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  //\r
+  // Get the Fwh Information PPI\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+            &gUnixFwhPpiGuid, // GUID\r
+            0,              // INSTANCE\r
+            &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
+            (VOID **)&UnixFwhPpi       // PPI\r
+            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Assume that FD0 contains the Flash map.\r
+  //\r
+  Status = UnixFwhPpi->UnixFwh (0, &FdBase, &FdSize);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get number of types\r
+  //\r
+  NumOfHobData = sizeof (mFlashAreaData) / sizeof (EFI_FLASH_AREA_DATA);\r
+\r
+  //\r
+  // Build flash area entries as GUIDed HOBs.\r
+  //\r
+  for (Index = 0; Index < NumOfHobData; Index++) {\r
+    (*PeiServices)->SetMem (&FlashHobData, sizeof (EFI_FLASH_AREA_HOB_DATA), 0);\r
+\r
+    FlashHobData.AreaType               = mFlashAreaData[Index].AreaType;\r
+    FlashHobData.NumberOfEntries        = 1;\r
+    FlashHobData.SubAreaData.Attributes = mFlashAreaData[Index].Attributes;\r
+    FlashHobData.SubAreaData.Base       = FdBase + (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Base;\r
+    FlashHobData.SubAreaData.Length     = (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Length;\r
+\r
+    //\r
+    // We also update a PCD entry so that any driver that depend on\r
+    // PCD entry will get the information.\r
+    //\r
+    if (FlashHobData.AreaType == EFI_FLASH_AREA_EFI_VARIABLES) {\r
+      PcdSet32 (PcdFlashNvStorageVariableBase, (UINT32) FlashHobData.SubAreaData.Base);\r
+      PcdSet32 (PcdFlashNvStorageVariableSize, (UINT32) FlashHobData.SubAreaData.Length);\r
+    }\r
+\r
+    if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_STATE) {\r
+      PcdSet32 (PcdFlashNvStorageFtwWorkingBase, (UINT32) FlashHobData.SubAreaData.Base);\r
+      PcdSet32 (PcdFlashNvStorageFtwWorkingSize, (UINT32) FlashHobData.SubAreaData.Length);\r
+    }\r
+\r
+    if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_BACKUP) {\r
+      PcdSet32 (PcdFlashNvStorageFtwSpareBase, (UINT32) FlashHobData.SubAreaData.Base);\r
+      PcdSet32 (PcdFlashNvStorageFtwSpareSize, (UINT32) FlashHobData.SubAreaData.Length);\r
+    }\r
+\r
+    switch (FlashHobData.AreaType) {\r
+    case EFI_FLASH_AREA_RECOVERY_BIOS:\r
+    case EFI_FLASH_AREA_MAIN_BIOS:\r
+      (*PeiServices)->CopyMem (\r
+                        &FlashHobData.AreaTypeGuid,\r
+                        &gEfiFirmwareFileSystemGuid,\r
+                        sizeof (EFI_GUID)\r
+                        );\r
+      (*PeiServices)->CopyMem (\r
+                        &FlashHobData.SubAreaData.FileSystem,\r
+                        &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                        sizeof (EFI_GUID)\r
+                        );\r
+      break;\r
+\r
+    case EFI_FLASH_AREA_GUID_DEFINED:\r
+      (*PeiServices)->CopyMem (\r
+                        &FlashHobData.AreaTypeGuid,\r
+                        &mFlashAreaData[Index].AreaTypeGuid,\r
+                        sizeof (EFI_GUID)\r
+                        );\r
+      (*PeiServices)->CopyMem (\r
+                        &FlashHobData.SubAreaData.FileSystem,\r
+                        &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                        sizeof (EFI_GUID)\r
+                        );\r
+      break;\r
+\r
+    default:\r
+      break;\r
+    }\r
+\r
+    BuildGuidDataHob (\r
+      &gEfiFlashMapHobGuid,\r
+      &FlashHobData,\r
+      sizeof (EFI_FLASH_AREA_HOB_DATA)\r
+      );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetAreaInfo (\r
+  IN  EFI_PEI_SERVICES            **PeiServices,\r
+  IN PEI_FLASH_MAP_PPI            *This,\r
+  IN  EFI_FLASH_AREA_TYPE         AreaType,\r
+  IN  EFI_GUID                    *AreaTypeGuid,\r
+  OUT UINT32                      *NumEntries,\r
+  OUT EFI_FLASH_SUBAREA_ENTRY     **Entries\r
+  )\r
+/*++\r
+\r
+  Routine Description:    \r
+    Implementation of Flash Map PPI\r
+    \r
+--*/\r
+// TODO: function comment is missing 'Arguments:'\r
+// TODO: function comment is missing 'Returns:'\r
+// TODO:    PeiServices - add argument and description to function comment\r
+// TODO:    This - add argument and description to function comment\r
+// TODO:    AreaType - add argument and description to function comment\r
+// TODO:    AreaTypeGuid - add argument and description to function comment\r
+// TODO:    NumEntries - add argument and description to function comment\r
+// TODO:    Entries - add argument and description to function comment\r
+// TODO:    EFI_SUCCESS - add return value to function comment\r
+// TODO:    EFI_NOT_FOUND - add return value to function comment\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_PEI_HOB_POINTERS          Hob;\r
+  EFI_HOB_FLASH_MAP_ENTRY_TYPE  *FlashMapEntry;\r
+\r
+  Status = PeiServicesGetHobList ((VOID **)&Hob.Raw);\r
+  while (!END_OF_HOB_LIST (Hob)) {\r
+    if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION && CompareGuid (&Hob.Guid->Name, &gEfiFlashMapHobGuid)) {\r
+      FlashMapEntry = (EFI_HOB_FLASH_MAP_ENTRY_TYPE *) Hob.Raw;\r
+      if (AreaType == FlashMapEntry->AreaType) {\r
+        if (AreaType == EFI_FLASH_AREA_GUID_DEFINED) {\r
+          if (!CompareGuid (AreaTypeGuid, &FlashMapEntry->AreaTypeGuid)) {\r
+            goto NextHob;\r
+          }\r
+        }\r
+\r
+        *NumEntries = FlashMapEntry->NumEntries;\r
+        *Entries    = FlashMapEntry->Entries;\r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+  NextHob:\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
diff --git a/EdkUnixPkg/Pei/FlashMap/FlashMap.dxs b/EdkUnixPkg/Pei/FlashMap/FlashMap.dxs
new file mode 100644 (file)
index 0000000..f75e7aa
--- /dev/null
@@ -0,0 +1,28 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    FlashMap.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression file for FindFv.\r
+\r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+ PCD_PPI_GUID\r
+DEPENDENCY_END\r
+\r
diff --git a/EdkUnixPkg/Pei/FlashMap/FlashMap.msa b/EdkUnixPkg/Pei/FlashMap/FlashMap.msa
new file mode 100644 (file)
index 0000000..7576795
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>PeiFlashMap</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f417814a-8985-11db-8983-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for FlashMap PEI module</Abstract>\r
+    <Description>This module installs FlashMap PPI which is used to get flash layout information.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>PeiFlashMap</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeimEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesTablePointerLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>FlashMap.c</Filename>\r
+    <Filename>FlashMap.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiFirmwareVolumeBlockProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gPeiFlashMapPpiGuid</PpiCName>\r
+    </Ppi>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gUnixFwhPpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiFlashMapHobGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiFirmwareFileSystemGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gEfiSystemNvDataHobGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>PeimInitializeFlashMap</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdFlashNvStorageVariableBase</C_Name>\r
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>The driver sets the NV Storage FV base address defined by this PCD.  \r
+        This base address point to an EFI_FIRMWARE_VOLUMN_HEADER struct. Variable PEIM\r
+        will get the base address from this PCD. In NT emulator, this PCD is a DYNAMIC\r
+        type, as FD is mapped to process space by WinNT OS. On real platform, it is \r
+        normally a FIXED_AT_BUILD type as system memory map is fixed to BIOS.\r
+      </HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdFlashNvStorageVariableSize</C_Name>\r
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>\r
+        To get the NvStorage Variable size from this PCD.\r
+      </HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">\r
+      <C_Name>PcdFlashNvStorageFtwSpareBase</C_Name>\r
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>To get base address of the FTW spare block section in NV firmware volume.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">\r
+      <C_Name>PcdFlashNvStorageFtwSpareSize</C_Name>\r
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>To get size of the FTW spare block section in NV firmware volume.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">\r
+      <C_Name>PcdFlashNvStorageFtwWorkingBase</C_Name>\r
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>To get base address of the FTW working block section in NV firmware volume.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC" Usage="ALWAYS_CONSUMED">\r
+      <C_Name>PcdFlashNvStorageFtwWorkingSize</C_Name>\r
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>To get size of the FTW working block section in NV firmware volume.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>\r
diff --git a/EdkUnixPkg/Pei/UnixStuff/UnixStuff.c b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.c
new file mode 100644 (file)
index 0000000..40be01b
--- /dev/null
@@ -0,0 +1,73 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+    UnixStuff.c\r
+    \r
+Abstract:\r
+\r
+    Tiano PEIM to abstract construction of firmware volume in a Unix environment.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeUnixStuff (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform a call-back into the SEC simulator to get Unix Stuff\r
+\r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+// TODO:    FfsHeader - add argument and description to function comment\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
+  PEI_UNIX_THUNK_PPI     *PeiUnixService;\r
+  VOID                    *Ptr;\r
+\r
+  DEBUG ((EFI_D_ERROR, "Unix Stuff PEIM Loaded\n"));\r
+\r
+  Status = (**PeiServices).LocatePpi (\r
+                            PeiServices,\r
+                            &gPeiUnixThunkPpiGuid,  // GUID\r
+                            0,                    // INSTANCE\r
+                            &PpiDescriptor,       // EFI_PEI_PPI_DESCRIPTOR\r
+                            (VOID **)&PeiUnixService         // PPI\r
+                            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Ptr = PeiUnixService->UnixThunk ();\r
+\r
+  BuildGuidDataHob (\r
+    &gEfiUnixThunkProtocolGuid,         // Guid\r
+    &Ptr,                                // Buffer\r
+    sizeof (VOID *)                      // Sizeof Buffer\r
+    );\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.dxs
new file mode 100644 (file)
index 0000000..b2e8d04
--- /dev/null
@@ -0,0 +1,29 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixStuff.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression file for UnixStuff PEIM.\r
+\r
+--*/  \r
+\r
+#include <AutoGen.h>\r
+#include <PeimDepex.h>\r
+\r
+DEPENDENCY_START\r
+  PEI_UNIX_THUNK_PPI_GUID AND EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID\r
+DEPENDENCY_END\r
+\r
+\r
diff --git a/EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa b/EdkUnixPkg/Pei/UnixStuff/UnixStuff.msa
new file mode 100644 (file)
index 0000000..d7760bc
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>UnixStuff</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>f4239aa2-8985-11db-af82-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Stuff driver</Abstract>\r
+    <Description>\r
+      Tiano PEIM to abstract construction of firmware volume in a Windows NT environment.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>UnixStuff</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeimEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesTablePointerLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixStuff.c</Filename>\r
+    <Filename>UnixStuff.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiUnixThunkProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gPeiUnixThunkPpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>PeimInitializeUnixStuff</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/RuntimeDxe/FvbServices/FWBlockService.c b/EdkUnixPkg/RuntimeDxe/FvbServices/FWBlockService.c
new file mode 100644 (file)
index 0000000..84c40f4
--- /dev/null
@@ -0,0 +1,1494 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FWBlockService.c\r
+    \r
+Abstract:\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "FwBlockService.h"\r
+\r
+ESAL_FWB_GLOBAL         *mFvbModuleGlobal;\r
+\r
+EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {\r
+  FVB_DEVICE_SIGNATURE,\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_MEMMAP_DP,\r
+        {\r
+          sizeof (MEMMAP_DEVICE_PATH),\r
+          0\r
+        }\r
+      },\r
+      EfiMemoryMappedIO,\r
+      0,\r
+      0,\r
+    },\r
+    {\r
+      END_DEVICE_PATH_TYPE,\r
+      END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+      {\r
+        sizeof (EFI_DEVICE_PATH_PROTOCOL),\r
+        0\r
+      }\r
+    }\r
+  },\r
+  0,\r
+  {\r
+    FvbProtocolGetAttributes,\r
+    FvbProtocolSetAttributes,\r
+    FvbProtocolGetPhysicalAddress,\r
+    FvbProtocolGetBlockSize,\r
+    FvbProtocolRead,\r
+    FvbProtocolWrite,\r
+    FvbProtocolEraseBlocks,\r
+    NULL\r
+  },\r
+  {\r
+    FvbExtendProtocolEraseCustomBlockRange\r
+  }\r
+};\r
+\r
+\r
+\r
+VOID\r
+EFIAPI\r
+FvbVirtualddressChangeEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup internal data so that EFI and SAL can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert the mFvbModuleGlobal\r
+  date items to there virtual address.\r
+\r
+  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]  - Physical copy of instance data\r
+  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]   - Virtual pointer to common \r
+                                                instance data.\r
+\r
+Arguments:\r
+\r
+  (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  UINTN               Index;\r
+\r
+  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);\r
+\r
+  //\r
+  // Convert the base address of all the instances\r
+  //\r
+  Index       = 0;\r
+  FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];\r
+  while (Index < mFvbModuleGlobal->NumFv) {\r
+    EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);\r
+    FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
+      (\r
+        (UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +\r
+          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      );\r
+    Index++;\r
+  }\r
+\r
+  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);\r
+  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);\r
+}\r
+\r
+EFI_STATUS\r
+GetFvbInstance (\r
+  IN  UINTN                               Instance,\r
+  IN  ESAL_FWB_GLOBAL                     *Global,\r
+  OUT EFI_FW_VOL_INSTANCE                 **FwhInstance,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  FwhInstance           - The EFI_FW_VOL_INSTANCE fimrware instance structure\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhRecord;\r
+\r
+  if (Instance >= Global->NumFv) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  FwhRecord = Global->FvInstance[Virtual];\r
+  while (Instance > 0) {\r
+    FwhRecord = (EFI_FW_VOL_INSTANCE *)\r
+      (\r
+        (UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +\r
+          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      );\r
+    Instance--;\r
+  }\r
+\r
+  *FwhInstance = FwhRecord;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *Address,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                          that on successful return, contains the base address\r
+                          of the firmware volume. \r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+  *Address = FwhInstance->FvBase[Virtual];\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          returned\r
+  Attributes            - Output buffer which contains attributes\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+  *Attributes = FwhInstance->VolumeHeader.Attributes;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbGetLbaAddress (\r
+  IN  UINTN                               Instance,\r
+  IN  EFI_LBA                             Lba,\r
+  OUT UINTN                               *LbaAddress,\r
+  OUT UINTN                               *LbaLength,\r
+  OUT UINTN                               *NumOfBlocks,\r
+  IN  ESAL_FWB_GLOBAL                     *Global,\r
+  IN  BOOLEAN                             Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the starting address of an LBA in an FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance which the Lba belongs to\r
+  Lba                   - The logical block address\r
+  LbaAddress            - On output, contains the physical starting address \r
+                          of the Lba\r
+  LbaLength             - On output, contains the length of the block\r
+  NumOfBlocks           - A pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+--*/\r
+{\r
+  UINT32                  NumBlocks;\r
+  UINT32                  BlockLength;\r
+  UINTN                   Offset;\r
+  EFI_LBA                 StartLba;\r
+  EFI_LBA                 NextLba;\r
+  EFI_FW_VOL_INSTANCE     *FwhInstance;\r
+  EFI_FV_BLOCK_MAP_ENTRY  *BlockMap;\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  StartLba  = 0;\r
+  Offset    = 0;\r
+  BlockMap  = &(FwhInstance->VolumeHeader.FvBlockMap[0]);\r
+\r
+  //\r
+  // Parse the blockmap of the FV to find which map entry the Lba belongs to\r
+  //\r
+  while (TRUE) {\r
+    NumBlocks   = BlockMap->NumBlocks;\r
+    BlockLength = BlockMap->BlockLength;\r
+\r
+    if (NumBlocks == 0 || BlockLength == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    NextLba = StartLba + NumBlocks;\r
+\r
+    //\r
+    // The map entry found\r
+    //\r
+    if (Lba >= StartLba && Lba < NextLba) {\r
+      Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength);\r
+      if (LbaAddress != NULL) {\r
+        *LbaAddress = FwhInstance->FvBase[Virtual] + Offset;\r
+      }\r
+\r
+      if (LbaLength != NULL) {\r
+        *LbaLength = BlockLength;\r
+      }\r
+\r
+      if (NumOfBlocks != NULL) {\r
+        *NumOfBlocks = (UINTN) (NextLba - Lba);\r
+      }\r
+\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    StartLba  = NextLba;\r
+    Offset    = Offset + NumBlocks * BlockLength;\r
+    BlockMap++;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+FvbReadBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads specified number of bytes into a buffer from the specified block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be read from\r
+  Lba                   - The logical block address to be read from\r
+  BlockOffset           - Offset into the block at which to begin reading\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes read\r
+  Buffer                - Pointer to a caller allocated buffer that will be\r
+                          used to hold the data read\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes returned\r
+                          in Buffer\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be read\r
+  EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
+\r
+--*/\r
+{\r
+  EFI_FVB_ATTRIBUTES  Attributes;\r
+  UINTN               LbaAddress;\r
+  UINTN               LbaLength;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Check for invalid conditions\r
+  //\r
+  if ((NumBytes == NULL) || (Buffer == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (*NumBytes == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Check if the FV is read enabled\r
+  //\r
+  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
+\r
+  if ((Attributes & EFI_FVB_READ_STATUS) == 0) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+  //\r
+  // Perform boundary checks and adjust NumBytes\r
+  //\r
+  if (BlockOffset > LbaLength) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (LbaLength < (*NumBytes + BlockOffset)) {\r
+    *NumBytes = (UINT32) (LbaLength - BlockOffset);\r
+    Status    = EFI_BAD_BUFFER_SIZE;\r
+  }\r
+\r
+  CopyMem (Buffer, (UINT8 *) (LbaAddress + BlockOffset), (UINTN) (*NumBytes));\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+FvbWriteBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be written to\r
+  Lba                   - The starting logical block index to write to\r
+  BlockOffset           - Offset into the block at which to begin writing\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes actually written\r
+  Buffer                - Pointer to a caller allocated buffer that contains\r
+                          the source for the write\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was written successfully\r
+  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes\r
+                          actually written\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written\r
+  EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
+\r
+--*/\r
+{\r
+  EFI_FVB_ATTRIBUTES  Attributes;\r
+  UINTN               LbaAddress;\r
+  UINTN               LbaLength;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Check for invalid conditions\r
+  //\r
+  if ((NumBytes == NULL) || (Buffer == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (*NumBytes == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Check if the FV is write enabled\r
+  //\r
+  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
+\r
+  if ((Attributes & EFI_FVB_WRITE_STATUS) == 0) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+  //\r
+  // Perform boundary checks and adjust NumBytes\r
+  //\r
+  if (BlockOffset > LbaLength) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (LbaLength < (*NumBytes + BlockOffset)) {\r
+    *NumBytes = (UINT32) (LbaLength - BlockOffset);\r
+    Status    = EFI_BAD_BUFFER_SIZE;\r
+  }\r
+  //\r
+  // Write data\r
+  //\r
+  CopyMem ((UINT8 *) (LbaAddress + BlockOffset), Buffer, (UINTN) (*NumBytes));\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+FvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a firmware volume block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  Lba                   - The logical block index to be erased\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The erase request was successfully completed\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written. Firmware device may have been\r
+                          partially erased\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+--*/\r
+{\r
+\r
+  EFI_FVB_ATTRIBUTES  Attributes;\r
+  UINTN               LbaAddress;\r
+  UINTN               LbaLength;\r
+  EFI_STATUS          Status;\r
+  UINT8               Data;\r
+\r
+  //\r
+  // Check if the FV is write enabled\r
+  //\r
+  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
+\r
+  if ((Attributes & EFI_FVB_WRITE_STATUS) == 0) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+  //\r
+  // Get the starting address of the block for erase.\r
+  //\r
+  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if ((Attributes & EFI_FVB_ERASE_POLARITY) != 0) {\r
+    Data = 0xFF;\r
+  } else {\r
+    Data = 0x0;\r
+  }\r
+\r
+  SetMem ((UINT8 *) LbaAddress, LbaLength, Data);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbEraseCustomBlockRange (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a specified range of a firmware volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  StartLba              - The starting logical block index to be erased\r
+  OffsetStartLba        - Offset into the starting block at which to \r
+                          begin erasing\r
+  LastLba               - The last logical block index to be erased\r
+  OffsetStartLba        - Offset into the last block at which to end erasing\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was erased successfully\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written. Firmware device may have been\r
+                          partially erased\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+--*/\r
+{\r
+  EFI_LBA Index;\r
+  UINTN   LbaSize;\r
+  UINTN   ScratchLbaSizeData;\r
+\r
+  //\r
+  // First LBA\r
+  //\r
+  FvbGetLbaAddress (Instance, StartLba, NULL, &LbaSize, NULL, Global, Virtual);\r
+\r
+  //\r
+  // Use the scratch space as the intermediate buffer to transfer data\r
+  // Back up the first LBA in scratch space.\r
+  //\r
+  FvbReadBlock (Instance, StartLba, 0, &LbaSize, Global->FvbScratchSpace[Virtual], Global, Virtual);\r
+\r
+  //\r
+  // erase now\r
+  //\r
+  FvbEraseBlock (Instance, StartLba, Global, Virtual);\r
+  ScratchLbaSizeData = OffsetStartLba;\r
+\r
+  //\r
+  // write the data back to the first block\r
+  //\r
+  if (ScratchLbaSizeData > 0) {\r
+    FvbWriteBlock (Instance, StartLba, 0, &ScratchLbaSizeData, Global->FvbScratchSpace[Virtual], Global, Virtual);\r
+  }\r
+  //\r
+  // Middle LBAs\r
+  //\r
+  if (LastLba > (StartLba + 1)) {\r
+    for (Index = (StartLba + 1); Index <= (LastLba - 1); Index++) {\r
+      FvbEraseBlock (Instance, Index, Global, Virtual);\r
+    }\r
+  }\r
+  //\r
+  // Last LBAs, the same as first LBAs\r
+  //\r
+  if (LastLba > StartLba) {\r
+    FvbGetLbaAddress (Instance, LastLba, NULL, &LbaSize, NULL, Global, Virtual);\r
+    FvbReadBlock (Instance, LastLba, 0, &LbaSize, Global->FvbScratchSpace[Virtual], Global, Virtual);\r
+    FvbEraseBlock (Instance, LastLba, Global, Virtual);\r
+  }\r
+\r
+  ScratchLbaSizeData = LbaSize - (OffsetStartLba + 1);\r
+\r
+  return FvbWriteBlock (\r
+          Instance,\r
+          LastLba,\r
+          (OffsetLastLba + 1),\r
+          &ScratchLbaSizeData,\r
+          Global->FvbScratchSpace[Virtual],\r
+          Global,\r
+          Virtual\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+FvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN OUT EFI_FVB_ATTRIBUTES               *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modifies the current settings of the firmware volume according to the \r
+  input parameter, and returns the new setting of the volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          modified\r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r
+                          containing the desired firmware volume settings.\r
+                          On successful return, it contains the new settings\r
+                          of the firmware volume\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_ACCESS_DENIED     - The volume setting is locked and cannot be modified\r
+  EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are\r
+                          in conflict with the capabilities as declared in the\r
+                          firmware volume header\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  EFI_FVB_ATTRIBUTES  OldAttributes;\r
+  EFI_FVB_ATTRIBUTES  *AttribPtr;\r
+  UINT32              Capabilities;\r
+  UINT32              OldStatus;\r
+  UINT32              NewStatus;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  AttribPtr     = (EFI_FVB_ATTRIBUTES *) &(FwhInstance->VolumeHeader.Attributes);\r
+  OldAttributes = *AttribPtr;\r
+  Capabilities  = OldAttributes & EFI_FVB_CAPABILITIES;\r
+  OldStatus     = OldAttributes & EFI_FVB_STATUS;\r
+  NewStatus     = *Attributes & EFI_FVB_STATUS;\r
+\r
+  //\r
+  // If firmware volume is locked, no status bit can be updated\r
+  //\r
+  if (OldAttributes & EFI_FVB_LOCK_STATUS) {\r
+    if (OldStatus ^ NewStatus) {\r
+      return EFI_ACCESS_DENIED;\r
+    }\r
+  }\r
+  //\r
+  // Test read disable\r
+  //\r
+  if ((Capabilities & EFI_FVB_READ_DISABLED_CAP) == 0) {\r
+    if ((NewStatus & EFI_FVB_READ_STATUS) == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test read enable\r
+  //\r
+  if ((Capabilities & EFI_FVB_READ_ENABLED_CAP) == 0) {\r
+    if (NewStatus & EFI_FVB_READ_STATUS) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test write disable\r
+  //\r
+  if ((Capabilities & EFI_FVB_WRITE_DISABLED_CAP) == 0) {\r
+    if ((NewStatus & EFI_FVB_WRITE_STATUS) == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test write enable\r
+  //\r
+  if ((Capabilities & EFI_FVB_WRITE_ENABLED_CAP) == 0) {\r
+    if (NewStatus & EFI_FVB_WRITE_STATUS) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test lock\r
+  //\r
+  if ((Capabilities & EFI_FVB_LOCK_CAP) == 0) {\r
+    if (NewStatus & EFI_FVB_LOCK_STATUS) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+\r
+  *AttribPtr  = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB_STATUS));\r
+  *AttribPtr  = (*AttribPtr) | NewStatus;\r
+  *Attributes = *AttribPtr;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// FVB protocol APIs\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetPhysicalAddress (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  OUT EFI_PHYSICAL_ADDRESS                        *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the physical address of the device.\r
+\r
+Arguments:\r
+\r
+  This                  - Calling context\r
+  Address               - Output buffer containing the address.\r
+\r
+Returns:\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetBlockSize (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN  EFI_LBA                                     Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve the size of a logical block\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Lba                   - Indicates which block to return the size for.\r
+  BlockSize             - A pointer to a caller allocated UINTN in which\r
+                          the size of the block is returned\r
+  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbGetLbaAddress (\r
+          FvbDevice->Instance,\r
+          Lba,\r
+          NULL,\r
+          BlockSize,\r
+          NumOfBlocks,\r
+          mFvbModuleGlobal,\r
+          EfiGoneVirtual ()\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetAttributes (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  OUT EFI_FVB_ATTRIBUTES                          *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+    Retrieves Volume attributes.  No polarity translations are done.\r
+\r
+Arguments:\r
+    This                - Calling context\r
+    Attributes          - output buffer which contains attributes\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolSetAttributes (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN OUT EFI_FVB_ATTRIBUTES                       *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Sets Volume attributes. No polarity translations are done.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Attributes            - output buffer which contains attributes\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolEraseBlocks (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
+  ...  \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The EraseBlock() function erases one or more blocks as denoted by the \r
+  variable argument list. The entire parameter list of blocks must be verified\r
+  prior to erasing any blocks.  If a block is requested that does not exist \r
+  within the associated firmware volume (it has a larger index than the last \r
+  block of the firmware volume), the EraseBlock() function must return\r
+  EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  ...                   - Starting LBA followed by Number of Lba to erase. \r
+                          a -1 to terminate the list.\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The erase request was successfully completed\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written. Firmware device may have been\r
+                          partially erased\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+  EFI_FW_VOL_INSTANCE     *FwhInstance;\r
+  UINTN                   NumOfBlocks;\r
+  VA_LIST                 args;\r
+  EFI_LBA                 StartingLba;\r
+  UINTN                   NumOfLba;\r
+  EFI_STATUS              Status;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  Status    = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  NumOfBlocks = FwhInstance->NumOfBlocks;\r
+\r
+  VA_START (args, This);\r
+\r
+  do {\r
+    StartingLba = VA_ARG (args, EFI_LBA);\r
+    if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
+      break;\r
+    }\r
+\r
+    NumOfLba = VA_ARG (args, UINT32);\r
+\r
+    //\r
+    // Check input parameters\r
+    //\r
+    if (NumOfLba == 0) {\r
+      VA_END (args);\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if ((StartingLba + NumOfLba) > NumOfBlocks) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  } while (1);\r
+\r
+  VA_END (args);\r
+\r
+  VA_START (args, This);\r
+  do {\r
+    StartingLba = VA_ARG (args, EFI_LBA);\r
+    if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
+      break;\r
+    }\r
+\r
+    NumOfLba = VA_ARG (args, UINT32);\r
+\r
+    while (NumOfLba > 0) {\r
+      Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ());\r
+      if (EFI_ERROR (Status)) {\r
+        VA_END (args);\r
+        return Status;\r
+      }\r
+\r
+      StartingLba++;\r
+      NumOfLba--;\r
+    }\r
+\r
+  } while (1);\r
+\r
+  VA_END (args);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolWrite (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Writes data beginning at Lba:Offset from FV. The write terminates either\r
+  when *NumBytes of data have been written, or when a block boundary is\r
+  reached.  *NumBytes is updated to reflect the actual number of bytes\r
+  written. The write opertion does not include erase. This routine will\r
+  attempt to write only the specified bytes. If the writes do not stick,\r
+  it will return an error.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Lba                   - Block in which to begin write\r
+  Offset                - Offset in the block at which to begin write\r
+  NumBytes              - On input, indicates the requested write size. On\r
+                          output, indicates the actual number of bytes written\r
+  Buffer                - Buffer containing source data for the write.\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was written successfully\r
+  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes\r
+                          actually written\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written\r
+  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
+\r
+--*/\r
+{\r
+\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolRead (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads data beginning at Lba:Offset from FV. The Read terminates either\r
+  when *NumBytes of data have been read, or when a block boundary is\r
+  reached.  *NumBytes is updated to reflect the actual number of bytes\r
+  written. The write opertion does not include erase. This routine will\r
+  attempt to write only the specified bytes. If the writes do not stick,\r
+  it will return an error.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Lba                   - Block in which to begin Read\r
+  Offset                - Offset in the block at which to begin Read\r
+  NumBytes              - On input, indicates the requested write size. On\r
+                          output, indicates the actual number of bytes Read\r
+  Buffer                - Buffer containing source data for the Read.\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes returned\r
+                          in Buffer\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be read\r
+  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
+\r
+--*/\r
+{\r
+\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+//\r
+// FVB Extension Protocols\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+FvbExtendProtocolEraseCustomBlockRange (\r
+  IN EFI_FVB_EXTENSION_PROTOCOL           *This,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a specified range of a firmware volume\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  StartLba              - The starting logical block index to be erased\r
+  OffsetStartLba        - Offset into the starting block at which to \r
+                          begin erasing\r
+  LastLba               - The last logical block index to be erased\r
+  OffsetStartLba        - Offset into the last block at which to end erasing\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was erased successfully\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written. Firmware device may have been\r
+                          partially erased\r
+\r
+--*/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_EXTEND_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbEraseCustomBlockRange (\r
+          FvbDevice->Instance,\r
+          StartLba,\r
+          OffsetStartLba,\r
+          LastLba,\r
+          OffsetLastLba,\r
+          mFvbModuleGlobal,\r
+          EfiGoneVirtual ()\r
+          );\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+ValidateFvHeader (\r
+  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check the integrity of firmware volume header\r
+\r
+Arguments:\r
+  FwVolHeader           - A pointer to a firmware volume header\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume is consistent\r
+  EFI_NOT_FOUND         - The firmware volume has corrupted. So it is not an FV\r
+\r
+--*/\r
+{\r
+  UINT16  *Ptr;\r
+  UINT16  HeaderLength;\r
+  UINT16  Checksum;\r
+\r
+  //\r
+  // Verify the header revision, header signature, length\r
+  // Length of FvBlock cannot be 2**64-1\r
+  // HeaderLength cannot be an odd number\r
+  //\r
+  if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||\r
+      (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||\r
+      (FwVolHeader->FvLength == ((UINTN) -1)) ||\r
+      ((FwVolHeader->HeaderLength & 0x01) != 0)\r
+      ) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Verify the header checksum\r
+  //\r
+  HeaderLength  = (UINT16) (FwVolHeader->HeaderLength / 2);\r
+  Ptr           = (UINT16 *) FwVolHeader;\r
+  Checksum      = 0;\r
+  while (HeaderLength > 0) {\r
+    Checksum = Checksum + (*Ptr);\r
+    HeaderLength--;\r
+    Ptr++;\r
+  }\r
+\r
+  if (Checksum != 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbInitialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function does common initialization for FVB services\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                          Status;\r
+  EFI_FW_VOL_INSTANCE                 *FwhInstance;\r
+  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
+  EFI_DXE_SERVICES                    *DxeServices;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR     Descriptor;\r
+  UINT32                              BufferSize;\r
+  EFI_FV_BLOCK_MAP_ENTRY              *PtrBlockMapEntry;\r
+  EFI_HANDLE                          FwbHandle;\r
+  EFI_FW_VOL_BLOCK_DEVICE             *FvbDevice;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *OldFwbInterface;\r
+  EFI_DEVICE_PATH_PROTOCOL            *TempFwbDevicePath;\r
+  FV_DEVICE_PATH                      TempFvbDevicePathData;\r
+  UINT32                              MaxLbaSize;\r
+  EFI_PHYSICAL_ADDRESS                BaseAddress;\r
+  UINT64                              Length;\r
+  UINTN                               NumOfBlocks;\r
+  EFI_PEI_HOB_POINTERS                FvHob;\r
+\r
+   //\r
+  // Get the DXE services table\r
+  //\r
+  DxeServices = gDS;\r
+\r
+  //\r
+  // Allocate runtime services data for global variable, which contains\r
+  // the private data of all firmware volume block instances\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  sizeof (ESAL_FWB_GLOBAL),\r
+                  &mFvbModuleGlobal\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Calculate the total size for all firmware volume block instances\r
+  //\r
+  BufferSize            = 0;\r
+\r
+  FvHob.Raw = GetHobList ();\r
+  while ((FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw)) != NULL) {\r
+    BaseAddress = FvHob.FirmwareVolume->BaseAddress;\r
+    Length      = FvHob.FirmwareVolume->Length;\r
+    //\r
+    // Check if it is a "real" flash\r
+    //\r
+    Status = DxeServices->GetMemorySpaceDescriptor (\r
+                            BaseAddress,\r
+                            &Descriptor\r
+                            );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {\r
+      FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+      continue;\r
+    }\r
+\r
+    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
+    Status      = ValidateFvHeader (FwVolHeader);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Get FvbInfo\r
+      //\r
+      Status = GetFvbInfo (Length, &FwVolHeader);\r
+      if (EFI_ERROR (Status)) {\r
+        FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+        continue;\r
+      }\r
+    }\r
+\r
+    BufferSize += (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
+    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+  }\r
+\r
+  //\r
+  // Only need to allocate once. There is only one copy of physical memory for\r
+  // the private data of each FV instance. But in virtual mode or in physical\r
+  // mode, the address of the the physical memory may be different.\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  BufferSize,\r
+                  &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Make a virtual copy of the FvInstance pointer.\r
+  //\r
+  FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];\r
+  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance;\r
+\r
+  mFvbModuleGlobal->NumFv                   = 0;\r
+  MaxLbaSize = 0;\r
+\r
+  FvHob.Raw = GetHobList ();\r
+  while (NULL != (FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw))) {\r
+    BaseAddress = FvHob.FirmwareVolume->BaseAddress;\r
+    Length      = FvHob.FirmwareVolume->Length;\r
+    //\r
+    // Check if it is a "real" flash\r
+    //\r
+    Status = DxeServices->GetMemorySpaceDescriptor (\r
+                            BaseAddress,\r
+                            &Descriptor\r
+                            );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {\r
+      FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+      continue;\r
+    }\r
+\r
+    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
+    Status      = ValidateFvHeader (FwVolHeader);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Get FvbInfo to provide in FwhInstance.\r
+      //\r
+      Status = GetFvbInfo (Length, &FwVolHeader);\r
+      if (EFI_ERROR (Status)) {\r
+        FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+        continue;\r
+      }\r
+      //\r
+      //  Write healthy FV header back.\r
+      //\r
+      CopyMem (\r
+        (VOID *) (UINTN) BaseAddress,\r
+        (VOID *) FwVolHeader,\r
+        FwVolHeader->HeaderLength\r
+        );\r
+    }\r
+\r
+    FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;\r
+    FwhInstance->FvBase[FVB_VIRTUAL]  = (UINTN) BaseAddress;\r
+\r
+    CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);\r
+    FwVolHeader = &(FwhInstance->VolumeHeader);\r
+    EfiInitializeLock (&(FwhInstance->FvbDevLock), EFI_TPL_HIGH_LEVEL);\r
+\r
+    NumOfBlocks = 0;\r
+\r
+    for (PtrBlockMapEntry = FwVolHeader->FvBlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {\r
+      //\r
+      // Get the maximum size of a block. The size will be used to allocate\r
+      // buffer for Scratch space, the intermediate buffer for FVB extension\r
+      // protocol\r
+      //\r
+      if (MaxLbaSize < PtrBlockMapEntry->BlockLength) {\r
+        MaxLbaSize = PtrBlockMapEntry->BlockLength;\r
+      }\r
+\r
+      NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks;\r
+    }\r
+    //\r
+    // The total number of blocks in the FV.\r
+    //\r
+    FwhInstance->NumOfBlocks = NumOfBlocks;\r
+\r
+    //\r
+    // Add a FVB Protocol Instance\r
+    //\r
+    Status = gBS->AllocatePool (\r
+                    EfiRuntimeServicesData,\r
+                    sizeof (EFI_FW_VOL_BLOCK_DEVICE),\r
+                    &FvbDevice\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE));\r
+\r
+    FvbDevice->Instance = mFvbModuleGlobal->NumFv;\r
+    mFvbModuleGlobal->NumFv++;\r
+\r
+    //\r
+    // Set up the devicepath\r
+    //\r
+    FvbDevice->DevicePath.MemMapDevPath.StartingAddress = BaseAddress;\r
+    FvbDevice->DevicePath.MemMapDevPath.EndingAddress   = BaseAddress + (FwVolHeader->FvLength - 1);\r
+\r
+    //\r
+    // Find a handle with a matching device path that has supports FW Block protocol\r
+    //\r
+    TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &TempFvbDevicePathData;\r
+    CopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH));\r
+    Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // LocateDevicePath fails so install a new interface and device path\r
+      //\r
+      FwbHandle = NULL;\r
+      Status = gBS->InstallMultipleProtocolInterfaces (\r
+                      &FwbHandle,\r
+                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                      &FvbDevice->FwVolBlockInstance,\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      &FvbDevice->DevicePath,\r
+                      NULL\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+    } else if (EfiIsDevicePathEnd (TempFwbDevicePath)) {\r
+      //\r
+      // Device allready exists, so reinstall the FVB protocol\r
+      //\r
+      Status = gBS->HandleProtocol (\r
+                      FwbHandle,\r
+                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                      &OldFwbInterface\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+\r
+      Status = gBS->ReinstallProtocolInterface (\r
+                      FwbHandle,\r
+                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                      OldFwbInterface,\r
+                      &FvbDevice->FwVolBlockInstance\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+\r
+    } else {\r
+      //\r
+      // There was a FVB protocol on an End Device Path node\r
+      //\r
+      ASSERT (FALSE);\r
+    }\r
+    //\r
+    // Install FVB Extension Protocol on the same handle\r
+    //\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &FwbHandle,\r
+                    &gEfiFvbExtensionProtocolGuid,\r
+                    &FvbDevice->FvbExtension,\r
+                    &gEfiAlternateFvBlockGuid,\r
+                    NULL,\r
+                    NULL\r
+                    );\r
+\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
+      (\r
+        (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +\r
+          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      );\r
+\r
+    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+  }\r
+\r
+  //\r
+  // Allocate for scratch space, an intermediate buffer for FVB extention\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  MaxLbaSize,\r
+                  &mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL]\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL] = mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL];\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EdkUnixPkg/RuntimeDxe/FvbServices/FvbInfo.c b/EdkUnixPkg/RuntimeDxe/FvbServices/FvbInfo.c
new file mode 100644 (file)
index 0000000..d079423
--- /dev/null
@@ -0,0 +1,125 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FvbInfo.c\r
+\r
+Abstract:\r
+\r
+  Defines data structure that is the volume header found.These data is intent\r
+  to decouple FVB driver with FV header.\r
+\r
+--*/\r
+\r
+#include "FlashLayout.h"\r
+\r
+#define FIRMWARE_BLOCK_SIZE 0x10000\r
+\r
+typedef struct {\r
+  UINT64                      FvLength;\r
+  EFI_FIRMWARE_VOLUME_HEADER  FvbInfo;\r
+  //\r
+  // EFI_FV_BLOCK_MAP_ENTRY    ExtraBlockMap[n];//n=0\r
+  //\r
+  EFI_FV_BLOCK_MAP_ENTRY      End[1];\r
+} EFI_FVB_MEDIA_INFO;\r
+\r
+#define FVB_MEDIA_BLOCK_SIZE    FIRMWARE_BLOCK_SIZE\r
+#define RECOVERY_BOIS_BLOCK_NUM FIRMWARE_BLOCK_NUMBER\r
+#define SYSTEM_NV_BLOCK_NUM     2\r
+\r
+EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {\r
+  //\r
+  // Recovery BOIS FVB\r
+  //\r
+  {\r
+    EFI_WINNT_FIRMWARE_LENGTH,\r
+    {\r
+      {\r
+        0,\r
+      },  // ZeroVector[16]\r
+      EFI_FIRMWARE_FILE_SYSTEM_GUID,\r
+      FVB_MEDIA_BLOCK_SIZE * RECOVERY_BOIS_BLOCK_NUM,\r
+      EFI_FVH_SIGNATURE,\r
+      EFI_FVB_READ_ENABLED_CAP |\r
+        EFI_FVB_READ_STATUS |\r
+        EFI_FVB_WRITE_ENABLED_CAP |\r
+        EFI_FVB_WRITE_STATUS |\r
+        EFI_FVB_ERASE_POLARITY,\r
+      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
+      0,  // CheckSum\r
+      {\r
+        0,\r
+      },  // Reserved[3]\r
+      1,  // Revision\r
+      {\r
+        RECOVERY_BOIS_BLOCK_NUM,\r
+        FVB_MEDIA_BLOCK_SIZE,\r
+      }\r
+    },\r
+    {\r
+      0,\r
+      0\r
+    }\r
+  },\r
+  //\r
+  // Systen NvStorage FVB\r
+  //\r
+  {\r
+    EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
+    {\r
+      {\r
+        0,\r
+      },  // ZeroVector[16]\r
+      EFI_SYSTEM_NV_DATA_HOB_GUID,\r
+      FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,\r
+      EFI_FVH_SIGNATURE,\r
+      EFI_FVB_READ_ENABLED_CAP |\r
+        EFI_FVB_READ_STATUS |\r
+        EFI_FVB_WRITE_ENABLED_CAP |\r
+        EFI_FVB_WRITE_STATUS |\r
+        EFI_FVB_ERASE_POLARITY,\r
+      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
+      0,  // CheckSum\r
+      {\r
+        0,\r
+      },  // Reserved[3]\r
+      1,  // Revision\r
+      {\r
+        SYSTEM_NV_BLOCK_NUM,\r
+        FVB_MEDIA_BLOCK_SIZE,\r
+      }\r
+    },\r
+    {\r
+      0,\r
+      0\r
+    }\r
+  }\r
+};\r
+\r
+EFI_STATUS\r
+GetFvbInfo (\r
+  IN  UINT64                        FvLength,\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER    **FvbInfo\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
+    if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
+      *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
diff --git a/EdkUnixPkg/RuntimeDxe/FvbServices/FwBlockService.h b/EdkUnixPkg/RuntimeDxe/FvbServices/FwBlockService.h
new file mode 100644 (file)
index 0000000..6f949d3
--- /dev/null
@@ -0,0 +1,238 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  FwBlockService.h\r
+  \r
+Abstract:\r
+\r
+  Firmware volume block driver for Intel Firmware Hub (FWH) device\r
+\r
+--*/\r
+\r
+#ifndef _FW_BLOCK_SERVICE_H\r
+#define _FW_BLOCK_SERVICE_H\r
+\r
+//\r
+// BugBug: Add documentation here for data structure!!!!\r
+//\r
+#define FVB_PHYSICAL  0\r
+#define FVB_VIRTUAL   1\r
+\r
+typedef struct {\r
+  EFI_LOCK                    FvbDevLock;\r
+  UINTN                       FvBase[2];\r
+  UINTN                       NumOfBlocks;\r
+  EFI_FIRMWARE_VOLUME_HEADER  VolumeHeader;\r
+} EFI_FW_VOL_INSTANCE;\r
+\r
+typedef struct {\r
+  UINT32              NumFv;\r
+  EFI_FW_VOL_INSTANCE *FvInstance[2];\r
+  UINT8               *FvbScratchSpace[2];\r
+} ESAL_FWB_GLOBAL;\r
+\r
+//\r
+// Fvb Protocol instance data\r
+//\r
+#define FVB_DEVICE_FROM_THIS(a)         CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)\r
+#define FVB_EXTEND_DEVICE_FROM_THIS(a)  CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)\r
+#define FVB_DEVICE_SIGNATURE            EFI_SIGNATURE_32 ('F', 'V', 'B', 'N')\r
+\r
+typedef struct {\r
+  MEMMAP_DEVICE_PATH        MemMapDevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevPath;\r
+} FV_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  UINTN                               Signature;\r
+  FV_DEVICE_PATH                      DevicePath;\r
+  UINTN                               Instance;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  FwVolBlockInstance;\r
+  EFI_FVB_EXTENSION_PROTOCOL          FvbExtension;\r
+} EFI_FW_VOL_BLOCK_DEVICE;\r
+\r
+EFI_STATUS\r
+GetFvbInfo (\r
+  IN  UINT64                            FvLength,\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER        **FvbInfo\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbReadBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbWriteBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN OUT EFI_FVB_ATTRIBUTES               *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES                  *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *Address,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbInitialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+;\r
+\r
+\r
+VOID\r
+EFIAPI\r
+FvbClassAddressChangeEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbGetLbaAddress (\r
+  IN  UINTN                               Instance,\r
+  IN  EFI_LBA                             Lba,\r
+  OUT UINTN                               *LbaAddress,\r
+  OUT UINTN                               *LbaLength,\r
+  OUT UINTN                               *NumOfBlocks,\r
+  IN  ESAL_FWB_GLOBAL                     *Global,\r
+  IN  BOOLEAN                             Virtual\r
+  )\r
+;\r
+\r
+//\r
+// Protocol APIs\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetAttributes (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  OUT EFI_FVB_ATTRIBUTES                          *Attributes\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolSetAttributes (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN OUT EFI_FVB_ATTRIBUTES                       *Attributes\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetPhysicalAddress (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  OUT EFI_PHYSICAL_ADDRESS                        *Address\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetBlockSize (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN  EFI_LBA                                     Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolRead (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolWrite (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolEraseBlocks (\r
+  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
+  ...\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbExtendProtocolEraseCustomBlockRange (\r
+  IN EFI_FVB_EXTENSION_PROTOCOL           *This,\r
+  IN EFI_LBA                              StartLba,\r
+  IN UINTN                                OffsetStartLba,\r
+  IN EFI_LBA                              LastLba,\r
+  IN UINTN                                OffsetLastLba\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EdkUnixPkg/RuntimeDxe/FvbServices/UnixFwh.dxs b/EdkUnixPkg/RuntimeDxe/FvbServices/UnixFwh.dxs
new file mode 100644 (file)
index 0000000..e0b8ed4
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    UnixFwh.dxs\r
+\r
+Abstract:\r
+\r
+  Dependency expression source file.\r
+  \r
+--*/  \r
+#include <AutoGen.h>\r
+#include <DxeDepex.h>\r
+\r
+\r
+DEPENDENCY_START\r
+  TRUE\r
+DEPENDENCY_END
\ No newline at end of file
diff --git a/EdkUnixPkg/RuntimeDxe/FvbServices/UnixFwh.msa b/EdkUnixPkg/RuntimeDxe/FvbServices/UnixFwh.msa
new file mode 100644 (file)
index 0000000..3792a00
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>FwBlockService</ModuleName>\r
+    <ModuleType>DXE_RUNTIME_DRIVER</ModuleType>\r
+    <GuidValue>f42fd042-8985-11db-a7db-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Unix Fimware Volume Block DXE driver module.</Abstract>\r
+    <Description>This DXE runtime driver implements and produces the Fimware Volue Block Protocol on \r
+    Unix emulator.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>FwBlockService</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DxeServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiRuntimeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>UnixFwh.dxs</Filename>\r
+    <Filename SupArchList="IA32">FWBlockService.c</Filename>\r
+    <Filename SupArchList="IA32">FwBlockService.h</Filename>\r
+    <Filename SupArchList="IA32">FvbInfo.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="SOMETIMES_PRODUCED">\r
+      <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiFirmwareVolumeBlockProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gEfiFvbExtensionProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Events>\r
+    <CreateEvents>\r
+      <EventTypes EventGuidCName="gEfiEventVirtualAddressChangeGuid" Usage="ALWAYS_CONSUMED">\r
+        <EventType>EVENT_GROUP_GUID</EventType>\r
+      </EventTypes>\r
+    </CreateEvents>\r
+  </Events>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_PRODUCED">\r
+      <GuidCName>gEfiAlternateFvBlockGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>FvbInitialize</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Sec/FwVol.c b/EdkUnixPkg/Sec/FwVol.c
new file mode 100644 (file)
index 0000000..25ebe07
--- /dev/null
@@ -0,0 +1,314 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  FwVol.c\r
+\r
+Abstract:\r
+  A simple FV stack so the SEC can extract the SEC Core from an\r
+  FV.\r
+\r
+--*/\r
+\r
+#include "SecMain.h"\r
+\r
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
+  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))\r
+\r
+EFI_FFS_FILE_STATE\r
+GetFileState (\r
+  IN UINT8                ErasePolarity,\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Returns the highest bit set of the State field\r
+\r
+Arguments:\r
+  ErasePolarity   - Erase Polarity  as defined by EFI_FVB_ERASE_POLARITY\r
+                    in the Attributes field.\r
+  FfsHeader       - Pointer to FFS File Header.\r
+\r
+Returns:\r
+  Returns the highest bit in the State field\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_STATE  FileState;\r
+  EFI_FFS_FILE_STATE  HighestBit;\r
+\r
+  FileState = FfsHeader->State;\r
+\r
+  if (ErasePolarity != 0) {\r
+    FileState = (EFI_FFS_FILE_STATE)~FileState;\r
+  }\r
+\r
+  HighestBit = 0x80;\r
+  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
+    HighestBit >>= 1;\r
+  }\r
+\r
+  return HighestBit;\r
+}\r
+\r
+UINT8\r
+CalculateHeaderChecksum (\r
+  IN EFI_FFS_FILE_HEADER  *FileHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Calculates the checksum of the header of a file.\r
+\r
+Arguments:\r
+  FileHeader       - Pointer to FFS File Header.\r
+\r
+Returns:\r
+  Checksum of the header.\r
+  \r
+--*/\r
+{\r
+  UINT8 *ptr;\r
+  UINTN Index;\r
+  UINT8 Sum;\r
+\r
+  Sum = 0;\r
+  ptr = (UINT8 *) FileHeader;\r
+\r
+  for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {\r
+    Sum = (UINT8) (Sum + ptr[Index]);\r
+    Sum = (UINT8) (Sum + ptr[Index + 1]);\r
+    Sum = (UINT8) (Sum + ptr[Index + 2]);\r
+    Sum = (UINT8) (Sum + ptr[Index + 3]);\r
+  }\r
+\r
+  for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {\r
+    Sum = (UINT8) (Sum + ptr[Index]);\r
+  }\r
+  //\r
+  // State field (since this indicates the different state of file).\r
+  //\r
+  Sum = (UINT8) (Sum - FileHeader->State);\r
+  //\r
+  // Checksum field of the file is not part of the header checksum.\r
+  //\r
+  Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);\r
+\r
+  return Sum;\r
+}\r
+\r
+EFI_STATUS\r
+SecFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE             SearchType,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
+  IN OUT EFI_FFS_FILE_HEADER     **FileHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+    Given the input file pointer, search for the next matching file in the\r
+    FFS volume as defined by SearchType. The search starts from FileHeader inside\r
+    the Firmware Volume defined by FwVolHeader.\r
+\r
+Arguments:\r
+    SearchType - Filter to find only files of this type.\r
+                 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
+    FwVolHeader - Pointer to the FV header of the volume to search.\r
+                  This parameter must point to a valid FFS volume.\r
+    FileHeader  - Pointer to the current file from which to begin searching.\r
+                  This pointer will be updated upon return to reflect the file\r
+                  found.\r
+\r
+Returns:\r
+    EFI_NOT_FOUND - No files matching the search criteria were found\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  EFI_FFS_FILE_HEADER *FfsFileHeader;\r
+  UINT32              FileLength;\r
+  UINT32              FileOccupiedSize;\r
+  UINT32              FileOffset;\r
+  UINT64              FvLength;\r
+  UINT8               ErasePolarity;\r
+  UINT8               FileState;\r
+\r
+  FvLength = FwVolHeader->FvLength;\r
+  if (FwVolHeader->Attributes & EFI_FVB_ERASE_POLARITY) {\r
+    ErasePolarity = 1;\r
+  } else {\r
+    ErasePolarity = 0;\r
+  }\r
+  //\r
+  // If FileHeader is not specified (NULL) start with the first file in the\r
+  // firmware volume.  Otherwise, start from the FileHeader.\r
+  //\r
+  if (*FileHeader == NULL) {\r
+    FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);\r
+  } else {\r
+    //\r
+    // Length is 24 bits wide so mask upper 8 bits\r
+    // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.\r
+    //\r
+    FileLength        = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;\r
+    FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);\r
+    FfsFileHeader     = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);\r
+  }\r
+\r
+  FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);\r
+\r
+  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {\r
+    //\r
+    // Get FileState which is the highest bit of the State\r
+    //\r
+    FileState = GetFileState (ErasePolarity, FfsFileHeader);\r
+\r
+    switch (FileState) {\r
+\r
+    case EFI_FILE_HEADER_INVALID:\r
+      FileOffset += sizeof (EFI_FFS_FILE_HEADER);\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));\r
+      break;\r
+\r
+    case EFI_FILE_DATA_VALID:\r
+    case EFI_FILE_MARKED_FOR_UPDATE:\r
+      if (CalculateHeaderChecksum (FfsFileHeader) == 0) {\r
+        FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;\r
+        FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);\r
+\r
+        if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {\r
+\r
+          *FileHeader = FfsFileHeader;\r
+\r
+          return EFI_SUCCESS;\r
+        }\r
+\r
+        FileOffset += FileOccupiedSize;\r
+        FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);\r
+      } else {\r
+        return EFI_NOT_FOUND;\r
+      }\r
+      break;\r
+\r
+    case EFI_FILE_DELETED:\r
+      FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;\r
+      FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);\r
+      FileOffset += FileOccupiedSize;\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);\r
+      break;\r
+\r
+    default:\r
+      return EFI_NOT_FOUND;\r
+\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+SecFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE      SectionType,\r
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,\r
+  IN OUT VOID              **SectionData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+    Given the input file pointer, search for the next matching section in the\r
+    FFS volume.\r
+\r
+Arguments:\r
+    SearchType    - Filter to find only sections of this type.\r
+    FfsFileHeader - Pointer to the current file to search.\r
+    SectionData   - Pointer to the Section matching SectionType in FfsFileHeader.\r
+                     NULL if section not found\r
+\r
+Returns:\r
+    EFI_NOT_FOUND - No files matching the search criteria were found\r
+    EFI_SUCCESS\r
+\r
+--*/\r
+{\r
+  UINT32                    FileSize;\r
+  EFI_COMMON_SECTION_HEADER *Section;\r
+  UINT32                    SectionLength;\r
+  UINT32                    ParsedLength;\r
+\r
+  //\r
+  // Size is 24 bits wide so mask upper 8 bits.\r
+  //    Does not include FfsFileHeader header size\r
+  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.\r
+  //\r
+  Section   = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);\r
+  FileSize  = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;\r
+  FileSize -= sizeof (EFI_FFS_FILE_HEADER);\r
+\r
+  *SectionData  = NULL;\r
+  ParsedLength  = 0;\r
+  while (ParsedLength < FileSize) {\r
+    if (Section->Type == SectionType) {\r
+      *SectionData = (VOID *) (Section + 1);\r
+      return EFI_SUCCESS;\r
+    }\r
+    //\r
+    // Size is 24 bits wide so mask upper 8 bits.\r
+    // SectionLength is adjusted it is 4 byte aligned.\r
+    // Go to the next section\r
+    //\r
+    SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;\r
+    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
+\r
+    ParsedLength += SectionLength;\r
+    Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+SecFfsFindPeiCore (\r
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
+  OUT VOID                        **Pe32Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Given the pointer to the Firmware Volume Header find the SEC\r
+  core and return it's PE32 image.\r
+\r
+Arguments:\r
+  FwVolHeader - Pointer to memory mapped FV\r
+  Pe32Data - Pointer to SEC PE32 iamge.\r
\r
+Returns:  \r
+  EFI_SUCCESS - Pe32Data is valid\r
+  other       - Failure\r
+\r
+--*/\r
+{\r
+  EFI_STATUS          Status;\r
+  EFI_FFS_FILE_HEADER *FileHeader;\r
+  EFI_FV_FILETYPE     SearchType;\r
+\r
+  SearchType  = EFI_FV_FILETYPE_PEI_CORE;\r
+  FileHeader  = NULL;\r
+  do {\r
+    Status = SecFfsFindNextFile (SearchType, FwVolHeader, &FileHeader);\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = SecFfsFindSectionData (EFI_SECTION_PE32, FileHeader, Pe32Data);\r
+      return Status;\r
+    }\r
+  } while (!EFI_ERROR (Status));\r
+\r
+  return Status;\r
+}\r
diff --git a/EdkUnixPkg/Sec/SecMain.c b/EdkUnixPkg/Sec/SecMain.c
new file mode 100644 (file)
index 0000000..b2234c4
--- /dev/null
@@ -0,0 +1,995 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  SecMain.c\r
+\r
+Abstract:\r
+  WinNt emulator of SEC phase. It's really a Win32 application, but this is\r
+  Ok since all the other modules for NT32 are NOT Win32 applications.\r
+\r
+  This program processes Windows environment variables and figures out\r
+  what the memory layout will be, how may FD's will be loaded and also\r
+  what the boot mode is.\r
+\r
+  The SEC registers a set of services with the SEC core. gPrivateDispatchTable\r
+  is a list of PPI's produced by the SEC that are availble for usage in PEI.\r
+\r
+  This code produces 128 K of temporary memory for the PEI stack by opening a\r
+  Windows file and mapping it directly to memory addresses.\r
+\r
+  The system.cmd script is used to set windows environment variables that drive\r
+  the configuration opitons of the SEC.\r
+\r
+--*/\r
+\r
+#include "SecMain.h"\r
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+\r
+//\r
+// Globals\r
+//\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL_INSTANCE  mPeiEfiPeiPeCoffLoaderInstance = {\r
+  {\r
+    SecNt32PeCoffGetImageInfo,\r
+    SecNt32PeCoffLoadImage,\r
+    SecNt32PeCoffRelocateImage,\r
+    SecNt32PeCoffUnloadimage\r
+  },\r
+  NULL\r
+};\r
+\r
+\r
+\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL           *gPeiEfiPeiPeCoffLoader = &mPeiEfiPeiPeCoffLoaderInstance.PeCoff;\r
+\r
+UNIX_PEI_LOAD_FILE_PPI                      mSecNtLoadFilePpi     = { SecWinNtPeiLoadFile };\r
+\r
+PEI_UNIX_AUTOSCAN_PPI                       mSecNtAutoScanPpi     = { SecWinNtPeiAutoScan };\r
+\r
+PEI_UNIX_THUNK_PPI                          mSecWinNtThunkPpi     = { SecWinNtWinNtThunkAddress };\r
+\r
+EFI_PEI_PROGRESS_CODE_PPI                 mSecStatusCodePpi     = { SecPeiReportStatusCode };\r
+\r
+UNIX_FWH_PPI                                mSecFwhInformationPpi = { SecWinNtFdAddress };\r
+\r
+\r
+EFI_PEI_PPI_DESCRIPTOR  gPrivateDispatchTable[] = {\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gEfiPeiPeCoffLoaderGuid,\r
+    NULL\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gUnixPeiLoadFilePpiGuid,\r
+    &mSecNtLoadFilePpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gPeiUnixAutoScanPpiGuid,\r
+    &mSecNtAutoScanPpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gPeiUnixThunkPpiGuid,\r
+    &mSecWinNtThunkPpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gEfiPeiStatusCodePpiGuid,\r
+    &mSecStatusCodePpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    &gUnixFwhPpiGuid,\r
+    &mSecFwhInformationPpi\r
+  }\r
+};\r
+\r
+\r
+//\r
+// Default information about where the FD is located.\r
+//  This array gets filled in with information from EFI_FIRMWARE_VOLUMES\r
+//  EFI_FIRMWARE_VOLUMES is a Windows environment variable set by system.cmd.\r
+//  The number of array elements is allocated base on parsing\r
+//  EFI_FIRMWARE_VOLUMES and the memory is never freed.\r
+//\r
+UINTN                                     gFdInfoCount = 0;\r
+UNIX_FD_INFO                                *gFdInfo;\r
+\r
+//\r
+// Array that supports seperate memory rantes.\r
+//  The memory ranges are set in system.cmd via the EFI_MEMORY_SIZE variable.\r
+//  The number of array elements is allocated base on parsing\r
+//  EFI_MEMORY_SIZE and the memory is never freed.\r
+//\r
+UINTN                                     gSystemMemoryCount = 0;\r
+UNIX_SYSTEM_MEMORY                       *gSystemMemory;\r
+\r
+\r
+STATIC
+EFI_PHYSICAL_ADDRESS *
+MapMemory (
+  INTN fd,
+  UINT64 length,
+  INTN   prot,
+  INTN   flags);
+\r
+STATIC
+EFI_STATUS
+MapFile (
+  IN  CHAR8                     *FileName,\r
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                    *Length\r
+  );
+\r
+\r
+INTN\r
+EFIAPI\r
+main (\r
+  IN  INTN  Argc,\r
+  IN  CHAR8 **Argv,\r
+  IN  CHAR8 **Envp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Main entry point to SEC for WinNt. This is a Windows program\r
+\r
+Arguments:\r
+  Argc - Number of command line arguments\r
+  Argv - Array of command line argument strings\r
+  Envp - Array of environmemt variable strings\r
+\r
+Returns:\r
+  0 - Normal exit\r
+  1 - Abnormal exit\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  InitialStackMemory;\r
+  UINT64                InitialStackMemorySize;\r
+  UINTN                 Index;\r
+  UINTN                 Index1;\r
+  UINTN                 Index2;\r
+  UINTN                 PeiIndex;\r
+  CHAR8                 *FileName;\r
+  BOOLEAN               Done;\r
+  VOID                  *PeiCoreFile;\r
+  CHAR16                *MemorySizeStr;\r
+  CHAR16                *FirmwareVolumesStr;\r
+\r
+  MemorySizeStr      = (CHAR16 *)PcdGetPtr (PcdUnixMemorySizeForSecMain);\r
+  FirmwareVolumesStr = (CHAR16 *)PcdGetPtr (PcdUnixFirmwareVolume);\r
+\r
+  printf ("\nEDK SEC Main NT Emulation Environment from www.TianoCore.org\n");\r
+\r
+  //\r
+  // Allocate space for gSystemMemory Array\r
+  //\r
+  gSystemMemoryCount  = CountSeperatorsInString (MemorySizeStr, '!') + 1;\r
+  gSystemMemory       = calloc (gSystemMemoryCount, sizeof (UNIX_SYSTEM_MEMORY));\r
+  if (gSystemMemory == NULL) {\r
+    printf ("ERROR : Can not allocate memory for system.  Exiting.\n");
+    exit (1);\r
+  }\r
+  //\r
+  // Allocate space for gSystemMemory Array\r
+  //\r
+  gFdInfoCount  = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1;\r
+  gFdInfo       = calloc (gFdInfoCount, sizeof (UNIX_FD_INFO));\r
+  if (gFdInfo == NULL) {\r
+    printf ("ERROR : Can not allocate memory for fd info.  Exiting.\n");
+    exit (1);\r
+  }\r
+  //\r
+  // Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION)\r
+  //\r
+  printf ("  BootMode 0x%02x\n", FixedPcdGet32 (PcdUnixBootMode));\r
+\r
+  //\r
+  // Open up a 128K file to emulate temp memory for PEI.\r
+  //  on a real platform this would be SRAM, or using the cache as RAM.\r
+  //  Set InitialStackMemory to zero so WinNtOpenFile will allocate a new mapping\r
+  //\r
+  InitialStackMemorySize  = 0x20000;\r
+  InitialStackMemory = (UINTN)MapMemory(0, 
+                                       (UINT32) InitialStackMemorySize,\r
+                                       PROT_READ | PROT_WRITE,
+                                       MAP_ANONYMOUS | MAP_PRIVATE);
+  if (InitialStackMemory == 0) {\r
+    printf ("ERROR : Can not open SecStack Exiting\n");\r
+    exit (1);\r
+  }\r
+\r
+  printf ("  SEC passing in %u KB of temp RAM at 0x%08lx to PEI\n",
+         (UINTN)(InitialStackMemorySize / 1024),
+         (unsigned long)InitialStackMemory);\r
+\r
+  //\r
+  // Open All the firmware volumes and remember the info in the gFdInfo global\r
+  //\r
+  FileName = (CHAR8 *)malloc (StrLen (FirmwareVolumesStr) + 1);
+  if (FileName == NULL) {\r
+    printf ("ERROR : Can not allocate memory for firmware volume string\n");\r
+    exit (1);\r
+  }\r
+\r
+  Index2 = 0;
+  for (Done = FALSE, Index = 0, PeiIndex = 0, PeiCoreFile = NULL;
+       FirmwareVolumesStr[Index2] != 0;
+       Index++) {\r
+    for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++)\r
+      FileName[Index1++] = FirmwareVolumesStr[Index2];
+    if (FirmwareVolumesStr[Index2] == '!')
+      Index2++;
+    FileName[Index1]  = '\0';\r
+\r
+    //\r
+    // Open the FD and remmeber where it got mapped into our processes address space\r
+    //\r
+    Status = MapFile (\r
+                     FileName,\r
+                     &gFdInfo[Index].Address,\r
+                     &gFdInfo[Index].Size\r
+                     );\r
+    if (EFI_ERROR (Status)) {\r
+      printf ("ERROR : Can not open Firmware Device File %s (%x).  Exiting.\n", FileName, Status);\r
+      exit (1);\r
+    }\r
+\r
+    printf ("  FD loaded from %s at 0x%08lx",
+           FileName, (unsigned long)gFdInfo[Index].Address);\r
+
+    if (PeiCoreFile == NULL) {\r
+      //\r
+      // Assume the beginning of the FD is an FV and look for the PEI Core.\r
+      // Load the first one we find.\r
+      //\r
+      Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile);\r
+      if (!EFI_ERROR (Status)) {\r
+        PeiIndex = Index;\r
+        printf (" contains SEC Core");\r
+      }\r
+    }\r
+\r
+    printf ("\n");\r
+  }\r
+  //\r
+  // Calculate memory regions and store the information in the gSystemMemory\r
+  //  global for later use. The autosizing code will use this data to\r
+  //  map this memory into the SEC process memory space.\r
+  //\r
+  Index1 = 0;
+  Index = 0;
+  while (1) {
+    UINTN val = 0;
+    //\r
+    // Save the size of the memory.
+    //\r
+    while (MemorySizeStr[Index1] >= '0' && MemorySizeStr[Index1] <= '9') {
+      val = val * 10 + MemorySizeStr[Index1] - '0';
+      Index1++;
+    }
+    gSystemMemory[Index++].Size = val * 0x100000;
+    if (MemorySizeStr[Index1] == 0)
+      break;
+    Index1++;
+  }
+\r
+  printf ("\n");\r
+\r
+  //\r
+  // Hand off to PEI Core\r
+  //\r
+  SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, PeiCoreFile);\r
+\r
+  //\r
+  // If we get here, then the PEI Core returned. This is an error as PEI should\r
+  //  always hand off to DXE.\r
+  //\r
+  printf ("ERROR : PEI Core returned\n");\r
+  exit (1);\r
+}\r
+\r
+EFI_PHYSICAL_ADDRESS *
+MapMemory (
+  INTN fd,
+  UINT64 length,
+  INTN   prot,
+  INTN   flags)
+{
+  static UINTN base = 0x40000000;
+  const UINTN align = (1 << 24);
+  void *res;
+
+  res = mmap ((void *)base, length, prot, flags, fd, 0);
+  if (res == MAP_FAILED)
+    return NULL;
+
+  // Guard page.
+  base += length + 4096;
+  base = (base + align - 1) & ~(align - 1);
+
+  return res;
+}
+
+EFI_STATUS
+MapFile (
+  IN  CHAR8                     *FileName,\r
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                    *Length\r
+  )
+/*++
+
+Routine Description:
+  Opens and memory maps a file using WinNt services. If BaseAddress is non zero
+  the process will try and allocate the memory starting at BaseAddress.
+
+Arguments:
+  FileName            - The name of the file to open and map
+  MapSize             - The amount of the file to map in bytes
+  CreationDisposition - The flags to pass to CreateFile().  Use to create new files for
+                        memory emulation, and exiting files for firmware volume emulation
+  BaseAddress         - The base address of the mapped file in the user address space.
+                         If passed in as NULL the a new memory region is used.
+                         If passed in as non NULL the request memory region is used for
+                          the mapping of the file into the process space.
+  Length              - The size of the mapped region in bytes
+
+Returns:
+  EFI_SUCCESS      - The file was opened and mapped.
+  EFI_NOT_FOUND    - FileName was not found in the current directory
+  EFI_DEVICE_ERROR - An error occured attempting to map the opened file
+
+--*/
+{
+  int fd;
+  VOID    *res;
+  UINTN   FileSize;
+
+  fd = open (FileName, O_RDONLY);
+  if (fd < 0)
+    return EFI_NOT_FOUND;
+  FileSize = lseek (fd, 0, SEEK_END);
+
+#if 0
+  if (IsMain)
+    {
+      /* Read entry address.  */
+      lseek (fd, FileSize - 0x20, SEEK_SET);
+      if (read (fd, &EntryAddress, 4) != 4)
+       {
+         close (fd);
+         return EFI_DEVICE_ERROR;
+       }      
+    }
+#endif
+
+  res = MapMemory(fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
+  
+  close (fd);
+
+  if (res == MAP_FAILED)
+    return EFI_DEVICE_ERROR;
+
+  *Length = (UINT64) FileSize;
+  *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
+
+  return EFI_SUCCESS;
+}
+\r
+#define BYTES_PER_RECORD  512\r
+\r
+/**\r
+  Extracts ASSERT() information from a status code structure.\r
+\r
+  Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
+  arguments specified by Filename, Description, and LineNumber.  If CodeType is \r
+  an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r
+  Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r
+  Filename, Description, and LineNumber from the optional data area of the \r
+  status code buffer specified by Data.  The optional data area of Data contains \r
+  a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r
+  ASCII string for the Description, followed by a 32-bit LineNumber.  If the \r
+  ASSERT() information could be extracted from Data, then return TRUE.  \r
+  Otherwise, FALSE is returned.  \r
+\r
+  If Data is NULL, then ASSERT().\r
+  If Filename is NULL, then ASSERT().\r
+  If Description is NULL, then ASSERT().\r
+  If LineNumber is NULL, then ASSERT().\r
+\r
+  @param  CodeType     The type of status code being converted.\r
+  @param  Value        The status code value being converted.\r
+  @param  Data         Pointer to status code data buffer. \r
+  @param  Filename     Pointer to the source file name that generated the ASSERT().\r
+  @param  Description  Pointer to the description of the ASSERT().\r
+  @param  LineNumber   Pointer to source line number that generated the ASSERT().\r
+\r
+  @retval  TRUE   The status code specified by CodeType, Value, and Data was \r
+                  converted ASSERT() arguments specified by Filename, Description, \r
+                  and LineNumber.\r
+  @retval  FALSE  The status code specified by CodeType, Value, and Data could \r
+                  not be converted to ASSERT() arguments.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+ReportStatusCodeExtractAssertInfo (\r
+  IN EFI_STATUS_CODE_TYPE        CodeType,\r
+  IN EFI_STATUS_CODE_VALUE       Value,  \r
+  IN CONST EFI_STATUS_CODE_DATA  *Data, \r
+  OUT CHAR8                      **Filename,\r
+  OUT CHAR8                      **Description,\r
+  OUT UINT32                     *LineNumber\r
+  )\r
+{\r
+  EFI_DEBUG_ASSERT_DATA  *AssertData;\r
+\r
+  ASSERT (Data        != NULL);\r
+  ASSERT (Filename    != NULL);\r
+  ASSERT (Description != NULL);\r
+  ASSERT (LineNumber  != NULL);\r
+\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK)      == EFI_ERROR_CODE) && \r
+      ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK)  == EFI_ERROR_UNRECOVERED) &&\r
+      ((Value    & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r
+    AssertData   = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
+    *Filename    = (CHAR8 *)(AssertData + 1);\r
+    *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
+    *LineNumber  = AssertData->LineNumber;\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecPeiReportStatusCode (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE       CodeType,\r
+  IN EFI_STATUS_CODE_VALUE      Value,\r
+  IN UINT32                     Instance,\r
+  IN EFI_GUID                   * CallerId,\r
+  IN EFI_STATUS_CODE_DATA       * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine produces the ReportStatusCode PEI service. It's passed\r
+  up to the PEI Core via a PPI. T\r
+\r
+  This code currently uses the NT clib printf. This does not work the same way\r
+  as the EFI Print (), as %t, %g, %s as Unicode are not supported.\r
+\r
+Arguments:\r
+  (see EFI_PEI_REPORT_STATUS_CODE)\r
+\r
+Returns:\r
+  EFI_SUCCESS - Always return success\r
+\r
+--*/\r
+// TODO:    PeiServices - add argument and description to function comment\r
+// TODO:    CodeType - add argument and description to function comment\r
+// TODO:    Value - add argument and description to function comment\r
+// TODO:    Instance - add argument and description to function comment\r
+// TODO:    CallerId - add argument and description to function comment\r
+// TODO:    Data - add argument and description to function comment\r
+{\r
+  CHAR8           *Format;\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+  VA_LIST         Marker;\r
+  CHAR8           PrintBuffer[BYTES_PER_RECORD * 2];\r
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  UINT32          LineNumber;\r
+\r
+  if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+    //\r
+    // This supports DEBUG () marcos\r
+    // Data format\r
+    //  EFI_STATUS_CODE_DATA\r
+    //  EFI_DEBUG_INFO\r
+    //\r
+    // The first 12 * UINT64 bytes of the string are really an\r
+    // arguement stack to support varargs on the Format string.\r
+    //\r
+    if (Data != NULL) {\r
+      DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
+      Marker    = (VA_LIST) (DebugInfo + 1);\r
+      Format    = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
+\r
+      AsciiVSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker);\r
+      printf (PrintBuffer);\r
+    } else {\r
+      printf ("DEBUG <null>\n");\r
+    }\r
+  }\r
+\r
+  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&\r
+      ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED)\r
+      ) {\r
+    if (Data != NULL && ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+      //\r
+      // Support ASSERT () macro\r
+      //\r
+      printf ("ASSERT %s(%d): %s\n", Filename, LineNumber, Description);\r
+    } else {\r
+      printf ("ASSERT <null>\n");\r
+    }\r
+    CpuBreakpoint ();\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+VOID\r
+SecLoadFromCore (\r
+  IN  UINTN   LargestRegion,\r
+  IN  UINTN   LargestRegionSize,\r
+  IN  UINTN   BootFirmwareVolumeBase,\r
+  IN  VOID    *PeiCorePe32File\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This is the service to load the PEI Core from the Firmware Volume\r
+\r
+Arguments:\r
+  LargestRegion           - Memory to use for PEI.\r
+  LargestRegionSize       - Size of Memory to use for PEI\r
+  BootFirmwareVolumeBase  - Start of the Boot FV\r
+  PeiCorePe32File         - PEI Core PE32\r
+\r
+Returns:\r
+  Success means control is transfered and thus we should never return\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PHYSICAL_ADDRESS        TopOfMemory;\r
+  VOID                        *TopOfStack;\r
+  UINT64                      PeiCoreSize;\r
+  EFI_PHYSICAL_ADDRESS        PeiCoreEntryPoint;\r
+  EFI_PHYSICAL_ADDRESS        PeiImageAddress;\r
+  EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartup;\r
+\r
+  //\r
+  // Compute Top Of Memory for Stack and PEI Core Allocations\r
+  //\r
+  TopOfMemory = LargestRegion + LargestRegionSize;\r
+\r
+  //\r
+  // Allocate 128KB for the Stack\r
+  //\r
+  TopOfStack  = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_PEI_STARTUP_DESCRIPTOR) - CPU_STACK_ALIGNMENT);\r
+  TopOfStack  = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
+  TopOfMemory = TopOfMemory - STACK_SIZE;\r
+\r
+  //\r
+  // Patch value in dispatch table values\r
+  //\r
+  gPrivateDispatchTable[0].Ppi = gPeiEfiPeiPeCoffLoader;\r
+\r
+  //\r
+  // Bind this information into the SEC hand-off state\r
+  //\r
+  PeiStartup = (EFI_PEI_STARTUP_DESCRIPTOR *) (UINTN) TopOfStack;\r
+  PeiStartup->DispatchTable      = (EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable;\r
+  PeiStartup->SizeOfCacheAsRam   = STACK_SIZE;\r
+  PeiStartup->BootFirmwareVolume = BootFirmwareVolumeBase;\r
+\r
+  //\r
+  // Load the PEI Core from a Firmware Volume\r
+  //\r
+  Status = SecWinNtPeiLoadFile (\r
+            PeiCorePe32File,\r
+            &PeiImageAddress,\r
+            &PeiCoreSize,\r
+            &PeiCoreEntryPoint\r
+            );\r
+  if (EFI_ERROR (Status)) {\r
+    return ;\r
+  }\r
+  printf ("Jump to 0x%08lx\n", (unsigned long)PeiCoreEntryPoint);
+  //\r
+  // Transfer control to the PEI Core\r
+  //\r
+  SwitchStack (\r
+    (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,\r
+    PeiStartup,\r
+    NULL,\r
+    TopOfStack\r
+    );\r
+  //\r
+  // If we get here, then the PEI Core returned.  This is an error\r
+  //\r
+  return ;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtPeiAutoScan (\r
+  IN  UINTN                 Index,\r
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
+  OUT UINT64                *MemorySize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This service is called from Index == 0 until it returns EFI_UNSUPPORTED.\r
+  It allows discontiguous memory regions to be supported by the emulator.\r
+  It uses gSystemMemory[] and gSystemMemoryCount that were created by\r
+  parsing the Windows environment variable EFI_MEMORY_SIZE.\r
+  The size comes from the varaible and the address comes from the call to\r
+  WinNtOpenFile.\r
+\r
+Arguments:\r
+  Index      - Which memory region to use\r
+  MemoryBase - Return Base address of memory region\r
+  MemorySize - Return size in bytes of the memory region\r
+\r
+Returns:\r
+  EFI_SUCCESS - If memory region was mapped\r
+  EFI_UNSUPPORTED - If Index is not supported\r
+\r
+--*/\r
+{\r
+  void *res;
+\r
+  if (Index >= gSystemMemoryCount) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  *MemoryBase = 0;\r
+  res = MapMemory(0, gSystemMemory[Index].Size,
+                 PROT_READ | PROT_WRITE | PROT_EXEC,
+                 MAP_PRIVATE | MAP_ANONYMOUS);
+  if (res == MAP_FAILED)
+    return EFI_DEVICE_ERROR;
+  *MemorySize = gSystemMemory[Index].Size;
+  *MemoryBase = (UINTN)res;
+  gSystemMemory[Index].Memory = *MemoryBase;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID *\r
+EFIAPI\r
+SecWinNtWinNtThunkAddress (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Since the SEC is the only Windows program in stack it must export\r
+  an interface to do Win API calls. That's what the WinNtThunk address\r
+  is for. gWinNt is initailized in WinNtThunk.c.\r
+\r
+Arguments:\r
+  InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);\r
+  InterfaceBase - Address of the gWinNt global\r
+\r
+Returns:\r
+  EFI_SUCCESS - Data returned\r
+\r
+--*/\r
+{\r
+  return gUnix;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtPeiLoadFile (\r
+  IN  VOID                    *Pe32Data,\r
+  IN  EFI_PHYSICAL_ADDRESS    *ImageAddress,\r
+  IN  UINT64                  *ImageSize,\r
+  IN  EFI_PHYSICAL_ADDRESS    *EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Loads and relocates a PE/COFF image into memory.\r
+\r
+Arguments:\r
+  Pe32Data         - The base address of the PE/COFF file that is to be loaded and relocated\r
+  ImageAddress     - The base address of the relocated PE/COFF image\r
+  ImageSize        - The size of the relocated PE/COFF image\r
+  EntryPoint       - The entry point of the relocated PE/COFF image\r
+\r
+Returns:\r
+  EFI_SUCCESS   - The file was loaded and relocated\r
+  EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT          ImageContext;\r
+\r
+  ZeroMem (&ImageContext, sizeof (ImageContext));\r
+  ImageContext.Handle     = Pe32Data;\r
+\r
+  ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) SecImageRead;\r
+\r
+  Status                  = gPeiEfiPeiPeCoffLoader->GetImageInfo (gPeiEfiPeiPeCoffLoader, &ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Allocate space in NT (not emulator) memory. Extra space is for alignment\r
+  //\r
+  ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) malloc ((UINTN) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)));\r
+  if (ImageContext.ImageAddress == 0) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Align buffer on section boundry\r
+  //\r
+  ImageContext.ImageAddress += ImageContext.SectionAlignment;\r
+  ImageContext.ImageAddress &= ~(ImageContext.SectionAlignment - 1);\r
+
+\r
+  Status = gPeiEfiPeiPeCoffLoader->LoadImage (gPeiEfiPeiPeCoffLoader, &ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gPeiEfiPeiPeCoffLoader->RelocateImage (gPeiEfiPeiPeCoffLoader, &ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // BugBug: Flush Instruction Cache Here when CPU Lib is ready\r
+  //\r
+\r
+  *ImageAddress = ImageContext.ImageAddress;\r
+  *ImageSize    = ImageContext.ImageSize;\r
+  *EntryPoint   = ImageContext.EntryPoint;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtFdAddress (\r
+  IN     UINTN                 Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
+  IN OUT UINT64                *FdSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Return the FD Size and base address. Since the FD is loaded from a\r
+  file into Windows memory only the SEC will know it's address.\r
+\r
+Arguments:\r
+  Index  - Which FD, starts at zero.\r
+  FdSize - Size of the FD in bytes\r
+  FdBase - Start address of the FD. Assume it points to an FV Header\r
+\r
+Returns:\r
+  EFI_SUCCESS     - Return the Base address and size of the FV\r
+  EFI_UNSUPPORTED - Index does nto map to an FD in the system\r
+\r
+--*/\r
+{\r
+  if (Index >= gFdInfoCount) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  *FdBase = gFdInfo[Index].Address;\r
+  *FdSize = gFdInfo[Index].Size;\r
+\r
+  if (*FdBase == 0 && *FdSize == 0) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINTN   *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
+\r
+Arguments:\r
+  FileHandle - The handle to the PE/COFF file\r
+  FileOffset - The offset, in bytes, into the file to read\r
+  ReadSize   - The number of bytes to read from the file starting at FileOffset\r
+  Buffer     - A pointer to the buffer to read the data into.\r
+\r
+Returns:\r
+  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
+\r
+--*/\r
+{\r
+  CHAR8 *Destination8;\r
+  CHAR8 *Source8;\r
+  UINTN Length;\r
+\r
+  Destination8  = Buffer;\r
+  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
+  Length        = *ReadSize;\r
+  while (Length--) {\r
+    *(Destination8++) = *(Source8++);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+UINTN\r
+CountSeperatorsInString (\r
+  IN  const CHAR16   *String,\r
+  IN  CHAR16         Seperator\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Count the number of seperators in String\r
+\r
+Arguments:\r
+  String    - String to process\r
+  Seperator - Item to count\r
+\r
+Returns:\r
+  Number of Seperator in String\r
+\r
+--*/\r
+{\r
+  UINTN Count;\r
+\r
+  for (Count = 0; *String != '\0'; String++) {\r
+    if (*String == Seperator) {\r
+      Count++;\r
+    }\r
+  }\r
+\r
+  return Count;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffGetImageInfo (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = PeCoffLoaderGetImageInfo (ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  switch (ImageContext->ImageType) {\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:\r
+    ImageContext->ImageCodeMemoryType = EfiLoaderCode;\r
+    ImageContext->ImageDataMemoryType = EfiLoaderData;\r
+    break;\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:\r
+    ImageContext->ImageCodeMemoryType = EfiBootServicesCode;\r
+    ImageContext->ImageDataMemoryType = EfiBootServicesData;\r
+    break;\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
+  case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:\r
+    ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode;\r
+    ImageContext->ImageDataMemoryType = EfiRuntimeServicesData;\r
+    break;\r
+\r
+  default:\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffLoadImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = PeCoffLoaderLoadImage (ImageContext);\r
+  return Status;\r
+}\r
+\r
+VOID
+SecUnixLoaderBreak (
+  VOID
+  )
+{
+}
+
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffRelocateImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+\r
+#if 0
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+  EFI_IMAGE_SECTION_HEADER *Sec;
+  INTN i;
+#endif
+
+  fprintf (stderr, 
+          "Loading %s 0x%08lx - entry point 0x%08lx\n",
+          ImageContext->PdbPointer,
+          (unsigned long)ImageContext->ImageAddress,
+          (unsigned long)ImageContext->EntryPoint);
+
+#if 0
+  Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)
+    ((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);\r
+  Sec = (EFI_IMAGE_SECTION_HEADER*)
+    ((UINTN)ImageContext->ImageAddress
+     + ImageContext->PeCoffHeaderOffset
+     + sizeof(UINT32)
+     + sizeof(EFI_IMAGE_FILE_HEADER)
+     + Hdr.Pe32->FileHeader.SizeOfOptionalHeader);
+  for (i = 0; i < Hdr.Pe32->FileHeader.NumberOfSections; i++)
+    fprintf (stderr, "  %s 0x%08lx\n",
+            Sec[i].Name, (unsigned long)Sec[i].VirtualAddress);
+#endif
+
+  SecUnixLoaderBreak ();
+
+  return PeCoffLoaderRelocateImage (ImageContext);\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffUnloadimage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL      *This,\r
+  IN PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+_ModuleEntryPoint (\r
+  VOID\r
+  )\r
+{\r
+}\r
+\r
diff --git a/EdkUnixPkg/Sec/SecMain.h b/EdkUnixPkg/Sec/SecMain.h
new file mode 100644 (file)
index 0000000..815dc79
--- /dev/null
@@ -0,0 +1,529 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name:\r
+  SecMain.h\r
+\r
+Abstract:\r
+  Include file for Windows API based SEC\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+\r
+\r
+#define STACK_SIZE                0x20000      \r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  Address;\r
+  UINT64                Size;\r
+} UNIX_FD_INFO;\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  Memory;\r
+  UINT64                Size;\r
+} UNIX_SYSTEM_MEMORY;\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtPeiLoadFile (\r
+  VOID                  *Pe32Data,  // TODO: add IN/OUT modifier to Pe32Data\r
+  EFI_PHYSICAL_ADDRESS  *ImageAddress,  // TODO: add IN/OUT modifier to ImageAddress\r
+  UINT64                *ImageSize,  // TODO: add IN/OUT modifier to ImageSize\r
+  EFI_PHYSICAL_ADDRESS  *EntryPoint  // TODO: add IN/OUT modifier to EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Pe32Data      - TODO: add argument description\r
+  ImageAddress  - TODO: add argument description\r
+  ImageSize     - TODO: add argument description\r
+  EntryPoint    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtPeiAutoScan (\r
+  IN  UINTN                 Index,\r
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
+  OUT UINT64                *MemorySize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Index       - TODO: add argument description\r
+  MemoryBase  - TODO: add argument description\r
+  MemorySize  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID *\r
+EFIAPI\r
+SecWinNtWinNtThunkAddress (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  InterfaceSize - TODO: add argument description\r
+  InterfaceBase - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtWinNtFwhAddress (\r
+  IN OUT UINT64                *FwhSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FwhSize - TODO: add argument description\r
+  FwhBase - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecPeiReportStatusCode (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 * CallerId,\r
+  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  PeiServices - TODO: add argument description\r
+  CodeType    - TODO: add argument description\r
+  Value       - TODO: add argument description\r
+  Instance    - TODO: add argument description\r
+  CallerId    - TODO: add argument description\r
+  Data        - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+INTN\r
+EFIAPI\r
+main (\r
+  IN  INTN  Argc,\r
+  IN  CHAR8 **Argv,\r
+  IN  CHAR8 **Envp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Argc  - TODO: add argument description\r
+  Argv  - TODO: add argument description\r
+  Envp  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+SecLoadFromCore (\r
+  IN  UINTN   LargestRegion,\r
+  IN  UINTN   LargestRegionSize,\r
+  IN  UINTN   BootFirmwareVolumeBase,\r
+  IN  VOID    *PeiCoreFile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  LargestRegion           - TODO: add argument description\r
+  LargestRegionSize       - TODO: add argument description\r
+  BootFirmwareVolumeBase  - TODO: add argument description\r
+  PeiCoreFile             - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SecLoadFile (\r
+  IN  VOID                    *Pe32Data,\r
+  IN  EFI_PHYSICAL_ADDRESS    *ImageAddress,\r
+  IN  UINT64                  *ImageSize,\r
+  IN  EFI_PHYSICAL_ADDRESS    *EntryPoint\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Pe32Data      - TODO: add argument description\r
+  ImageAddress  - TODO: add argument description\r
+  ImageSize     - TODO: add argument description\r
+  EntryPoint    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SecFfsFindPeiCore (\r
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
+  OUT VOID                        **Pe32Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FwVolHeader - TODO: add argument description\r
+  Pe32Data    - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SecFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE             SearchType,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
+  IN OUT EFI_FFS_FILE_HEADER     **FileHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SearchType  - TODO: add argument description\r
+  FwVolHeader - TODO: add argument description\r
+  FileHeader  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+SecFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE      SectionType,\r
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,\r
+  IN OUT VOID              **SectionData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  SectionType   - TODO: add argument description\r
+  FfsFileHeader - TODO: add argument description\r
+  SectionData   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtPeCoffLoaderLoadAsDll (\r
+  IN CHAR8    *PdbFileName,\r
+  IN VOID     **ImageEntryPoint,\r
+  OUT VOID    **ModHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  PdbFileName     - TODO: add argument description\r
+  ImageEntryPoint - TODO: add argument description\r
+  ModHandle       - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtPeCoffLoaderFreeLibrary (\r
+  OUT VOID    *ModHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ModHandle - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecWinNtFdAddress (\r
+  IN     UINTN                 Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
+  IN OUT UINT64                *FdSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Index   - TODO: add argument description\r
+  FdBase  - TODO: add argument description\r
+  FdSize  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetImageReadFunction (\r
+  IN PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
+  IN EFI_PHYSICAL_ADDRESS                  *TopOfMemory\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  ImageContext  - TODO: add argument description\r
+  TopOfMemory   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINTN   *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  FileHandle  - TODO: add argument description\r
+  FileOffset  - TODO: add argument description\r
+  ReadSize    - TODO: add argument description\r
+  Buffer      - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+CHAR16                            *\r
+AsciiToUnicode (\r
+  IN  CHAR8   *Ascii,\r
+  IN  UINTN   *StrLen OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Ascii   - TODO: add argument description\r
+  StrLen  - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+UINTN\r
+CountSeperatorsInString (\r
+  IN  const CHAR16   *String,\r
+  IN  CHAR16   Seperator\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  String    - TODO: add argument description\r
+  Seperator - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffGetImageInfo (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffLoadImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffRelocateImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecNt32PeCoffUnloadimage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL      *This,\r
+  IN PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  );\r
+\r
+\r
+typedef struct {\r
+  EFI_PEI_PE_COFF_LOADER_PROTOCOL PeCoff;\r
+  VOID                            *ModHandle;\r
+} EFI_PEI_PE_COFF_LOADER_PROTOCOL_INSTANCE;\r
+\r
+extern EFI_UNIX_THUNK_PROTOCOL  *gUnix;\r
diff --git a/EdkUnixPkg/Sec/SecMain.msa b/EdkUnixPkg/Sec/SecMain.msa
new file mode 100644 (file)
index 0000000..335cc5f
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
+  <MsaHeader>\r
+    <ModuleName>SecMain</ModuleName>\r
+    <ModuleType>USER_DEFINED</ModuleType>\r
+    <GuidValue>f43be88c-8985-11db-8f78-0040d02b1835</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Entry Point of Unix Emulator</Abstract>\r
+    <Description>Main executable file of Unix Emulator that loads PEI core after initialization finished.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>SecMain</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeCoffLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename ToolCode="DUMMY">SecMain_build.xml</Filename>\r
+    <Filename>SecMain.c</Filename>\r
+    <Filename>FwVol.c</Filename>\r
+    <Filename>UnixThunk.c</Filename>\r
+    <Filename>UgaX11.c</Filename>\r
+    <Filename>SecMain.h</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+    <Package PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gPeiUnixThunkPpiGuid</PpiCName>\r
+    </Ppi>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gPeiUnixAutoScanPpiGuid</PpiCName>\r
+    </Ppi>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gUnixFwhPpiGuid</PpiCName>\r
+    </Ppi>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gEfiPeiStatusCodePpiGuid</PpiCName>\r
+    </Ppi>\r
+    <Ppi Usage="ALWAYS_PRODUCED">\r
+      <PpiCName>gUnixPeiLoadFilePpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_PRODUCED">\r
+      <GuidCName>gEfiPeiPeCoffLoaderGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixMemorySizeForSecMain</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines the memory size of simulated machine. Simulator will allocate\r
+        the size of PcdUnixMemorySizeForSecMain in windows platform.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixFirmwareVolume</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines the FD file windows path string. Simulator will load the FD file and execute.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdUnixBootMode</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>This PCD defines the boot mode for simualtor. \r
+        The boot mode can be set as following value:\r
+          0x0: Boot with full configuration.\r
+          0x1: Boot with minimal configuration.\r
+          0x2: Boot assume no configuration changes.\r
+          0x3: Boot with full configuration plus diagnostics.\r
+          0x4: Boot with default settings.\r
+          0x5: Boot on S4 resume.\r
+          0x6: Boot on S5 resume.\r
+          0x10: Boot on S2 resume. \r
+          0x11: Boot on S3 resume.\r
+          0x12: Boot on flash update.\r
+          0x20: Boot in reovery mode.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
diff --git a/EdkUnixPkg/Sec/SecMain_build.xml b/EdkUnixPkg/Sec/SecMain_build.xml
new file mode 100644 (file)
index 0000000..c1a5caf
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0" ?>\r
+<!--\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+-->\r
+<project name="SecMain" default="main" basedir="." >\r
+  <!-- Apply external ANT task -->\r
+  <taskdef resource="frameworktasks.tasks" /> \r
+  <taskdef resource="cpptasks.tasks" /> \r
+  <typedef resource="cpptasks.types" /> \r
+  <taskdef resource="net/sf/antcontrib/antlib.xml" />\r
+  <property environment="env" />\r
+  <!-- All Properties --> \r
+  <property name="BASE_NAME" value="SecMain" /> \r
+  \r
+  <!-- Default target --> \r
+  <target name="main" depends="libraries, sourcefiles, sections, output" /> \r
+  <!-- Compile all dependency Library instances. --> \r
+\r
+  <target name="libraries">\r
+    <GenBuild type="build">\r
+      <property name="ARCH" value="${ARCH}"/>\r
+      <property name="MODULE_GUID" value="27d67720-ea68-48ae-93da-a3a074c90e30"/>\r
+      <property name="MODULE_VERSION" value=""/>\r
+      <property name="PLATFORM" value="${PLATFORM}"/>\r
+      <property name="PACKAGE_GUID" value="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+      <property name="PACKAGE_VERSION" value=""/>\r
+    </GenBuild>\r
+    <GenBuild type="build">\r
+      <property name="ARCH" value="${ARCH}"/>\r
+      <property name="MODULE_GUID" value="fd44e603-002a-4b29-9f5f-529e815b6165"/>\r
+      <property name="MODULE_VERSION" value=""/>\r
+      <property name="PLATFORM" value="${PLATFORM}"/>\r
+      <property name="PACKAGE_GUID" value="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+      <property name="PACKAGE_VERSION" value=""/>\r
+    </GenBuild>\r
+    <GenBuild type="build">\r
+      <property name="ARCH" value="${ARCH}"/>\r
+      <property name="MODULE_GUID" value="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3"/>\r
+      <property name="MODULE_VERSION" value=""/>\r
+      <property name="PLATFORM" value="${PLATFORM}"/>\r
+      <property name="PACKAGE_GUID" value="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+      <property name="PACKAGE_VERSION" value=""/>\r
+    </GenBuild>\r
+    <GenBuild type="build">\r
+      <property name="ARCH" value="${ARCH}"/>\r
+      <property name="MODULE_GUID" value="556f5d10-7309-4af4-b80a-8196bd60946f"/>\r
+      <property name="MODULE_VERSION" value=""/>\r
+      <property name="PLATFORM" value="${PLATFORM}"/>\r
+      <property name="PACKAGE_GUID" value="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+      <property name="PACKAGE_VERSION" value=""/>\r
+    </GenBuild>\r
+    <GenBuild type="build">\r
+      <property name="ARCH" value="${ARCH}"/>\r
+      <property name="MODULE_GUID" value="9ba1d976-0624-41a3-8650-28165e8d9ae8"/>\r
+      <property name="MODULE_VERSION" value=""/>\r
+      <property name="PLATFORM" value="${PLATFORM}"/>\r
+      <property name="PACKAGE_GUID" value="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+      <property name="PACKAGE_VERSION" value=""/>\r
+    </GenBuild>\r
+  </target>\r
+  <target name="sourcefiles">\r
+      <Build_Init>\r
+        <EXTRA.INC>\r
+          <includepath path="${INCLUDE_PATHS}"/>\r
+        </EXTRA.INC>\r
+      </Build_Init>\r
+      <Build_AUTOGEN FILEEXT="c" FILENAME="AutoGen" FILEPATH=".">\r
+         <EXTRA.INC>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
+         </EXTRA.INC>\r
+       </Build_AUTOGEN>\r
+      <Build_CCode FILEEXT="c" FILENAME="FwVol" FILEPATH=".">\r
+         <EXTRA.INC>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
+         </EXTRA.INC>\r
+      </Build_CCode>\r
+      <Build_CCode FILEEXT="c" FILENAME="UnixThunk" FILEPATH=".">\r
+         <EXTRA.INC>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
+         </EXTRA.INC>\r
+      </Build_CCode>\r
+      <Build_CCode FILEEXT="c" FILENAME="UgaX11" FILEPATH=".">\r
+         <EXTRA.INC>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
+         </EXTRA.INC>\r
+      </Build_CCode>\r
+      <Build_CCode FILEEXT="c" FILENAME="SecMain" FILEPATH=".">\r
+         <EXTRA.INC>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
+         </EXTRA.INC>\r
+      </Build_CCode>\r
+    </target>\r
+\r
+    <target name="sections" />\r
+\r
+    <target name="output" >\r
+      <if>\r
+        <available type="file" file="${DEST_DIR_OUTPUT}/AutoGen.h.obj"/>\r
+        <then>\r
+          <var name="SLINK_FLAGS" value="${SLINK_FLAGS} ${DEST_DIR_OUTPUT}/AutoGen.h.obj"/>\r
+        </then>\r
+      </if>\r
+      <OnDependency>\r
+        <sourcefiles>\r
+          <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}" />\r
+          <file list="${LIBS}"/>\r
+        </sourcefiles>\r
+        <targetfiles>\r
+          <file name="${BIN_DIR}/SecMain.exe"/>\r
+        </targetfiles>\r
+        \r
+        <sequential>\r
+          <cc userdefine="on">\r
+            <command type="SLINK" cmd="${SLINK}" family="${SLINK_FAMILY}"\r
+                outputFile="${DEST_DIR_OUTPUT}/SecMainLocal.lib" dpath="${SLINK_DPATH}">\r
+                \r
+              <argument value="${SLINK_FLAGS}"/>\r
+\r
+              <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}"/>\r
+            </command>\r
+          </cc>\r
+\r
+          <var name="LIBS" value="${LIBS} ${DEST_DIR_OUTPUT}/SecMainLocal.lib" />\r
+         \r
+          <shellscript shell="sh" tmpsuffix=".cmd" >\r
+            set -v
+            gcc -Wl,--start-group ${LIBS} -Wl,--end-group -o ${BIN_DIR}/SecMain.exe -L/usr/X11R6/lib -lXext -lX11
+          </shellscript>\r
+        </sequential>\r
+      </OnDependency>\r
+  </target>\r
+  \r
+  <target name="clean" ></target>\r
+\r
+  <target name="cleanAll"></target>\r
+</project>\r
diff --git a/EdkUnixPkg/Sec/UgaX11.c b/EdkUnixPkg/Sec/UgaX11.c
new file mode 100644 (file)
index 0000000..565689a
--- /dev/null
@@ -0,0 +1,580 @@
+#include "Uefi/UefiSpec.h"
+#include "Protocol/UnixThunk.h"
+#include "Protocol/SimpleTextIn.h"
+#include "Protocol/UgaDraw.h"
+#include "Protocol/UnixUgaIo.h"
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/extensions/XShm.h>
+#include <X11/keysym.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* XQueryPointer  */
+
+struct uga_drv_shift_mask
+{
+  unsigned char shift;
+  unsigned char size;
+  unsigned char csize;
+};
+
+#define NBR_KEYS 32
+typedef struct
+{
+  EFI_UNIX_UGA_IO_PROTOCOL UgaIo;
+
+  Display *display;
+  int screen;                  /* values for window_size in main */
+  Window win;
+  GC gc;
+  Visual *visual;
+
+  int depth;
+  unsigned int width;
+  unsigned int height;
+  unsigned int line_bytes;
+  unsigned int pixel_shift;
+  unsigned char *image_data;
+
+  struct uga_drv_shift_mask r, g, b;
+
+  int use_shm;
+  XShmSegmentInfo xshm_info;
+  XImage *image;
+
+  unsigned int key_rd;
+  unsigned int key_wr;
+  unsigned int key_count;
+  EFI_INPUT_KEY keys[NBR_KEYS];
+} UGA_IO_PRIVATE;
+
+static void
+HandleEvents(UGA_IO_PRIVATE *drv);
+
+static void
+fill_shift_mask (struct uga_drv_shift_mask *sm, unsigned long mask)
+{
+  sm->shift = 0;
+  sm->size = 0;
+  while ((mask & 1) == 0)
+    {
+      mask >>= 1;
+      sm->shift++;
+    }
+  while (mask & 1)
+    {
+      sm->size++;
+      mask >>= 1;
+    }
+  sm->csize = 8 - sm->size;
+}
+
+static int
+TryCreateShmImage(UGA_IO_PRIVATE *drv)
+{
+  drv->image = XShmCreateImage (drv->display, drv->visual,
+                               drv->depth, ZPixmap, NULL, &drv->xshm_info,
+                               drv->width, drv->height);
+  if (drv->image == NULL)
+    return 0;
+
+  switch (drv->image->bitmap_unit) {
+  case 32:
+    drv->pixel_shift = 2;
+    break;
+  case 16:
+    drv->pixel_shift = 1;
+    break;
+  case 8:
+    drv->pixel_shift = 0;
+    break;
+  }
+
+  drv->xshm_info.shmid = shmget
+       (IPC_PRIVATE, drv->image->bytes_per_line * drv->image->height,
+        IPC_CREAT | 0777);
+  if (drv->xshm_info.shmid < 0)
+    {
+      XDestroyImage(drv->image);
+      return 0;
+    }
+      
+  drv->image_data = shmat (drv->xshm_info.shmid, NULL, 0);
+  if(!drv->image_data)
+    {
+      shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
+      XDestroyImage(drv->image);
+      return 0;
+    }
+  /* Can this fail ?  */
+  shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
+
+  drv->xshm_info.shmaddr = drv->image_data;
+  drv->image->data = drv->image_data;
+         
+  if (!XShmAttach (drv->display, &drv->xshm_info))
+    {
+      shmdt (drv->image_data);
+      XDestroyImage(drv->image);
+      return 0;
+    }
+  return 1;
+}
+
+static
+EFI_STATUS
+UgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
+{
+  UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
+
+  if (drv == NULL)
+    return EFI_SUCCESS;
+  if (drv->image != NULL)
+    {
+      XDestroyImage(drv->image);
+
+      if (drv->use_shm)
+       shmdt (drv->image_data);
+
+      drv->image_data = NULL;
+      drv->image = NULL;
+    }
+  XDestroyWindow(drv->display, drv->win);
+  XCloseDisplay(drv->display);
+  free(drv);
+  return EFI_SUCCESS;
+}
+
+static
+EFI_STATUS
+UgaSize(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height)
+{
+  UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
+  XSizeHints size_hints;
+
+  /* Destroy current buffer if created.  */
+  if (drv->image != NULL)
+    {
+      XDestroyImage(drv->image);
+
+      if (drv->use_shm)
+       shmdt (drv->image_data);
+
+      drv->image_data = NULL;
+      drv->image = NULL;
+    }
+
+  drv->width = Width;
+  drv->height = Height;
+  XResizeWindow (drv->display, drv->win, Width, Height);
+
+  /* Allocate image.  */
+  if (XShmQueryExtension(drv->display) && TryCreateShmImage(drv))
+    {
+      drv->use_shm = 1;
+    }  
+  else 
+    {
+      drv->use_shm = 0;
+      if (drv->depth > 16)
+       drv->pixel_shift = 2;
+      else if (drv->depth > 8)
+       drv->pixel_shift = 1;
+      else
+       drv->pixel_shift = 0;
+      
+      drv->image_data = malloc((drv->width * drv->height) << drv->pixel_shift);
+      drv->image = XCreateImage (drv->display, drv->visual, drv->depth,
+                                ZPixmap, 0, drv->image_data,
+                                drv->width, drv->height,
+                                8 << drv->pixel_shift, 0);
+    }
+  drv->line_bytes = drv->image->bytes_per_line;
+  fill_shift_mask (&drv->r, drv->image->red_mask);
+  fill_shift_mask (&drv->g, drv->image->green_mask);
+  fill_shift_mask (&drv->b, drv->image->blue_mask);
+
+  /* Set WM hints.  */
+  size_hints.flags = PSize | PMinSize | PMaxSize;
+  size_hints.min_width = size_hints.max_width = size_hints.base_width = Width;
+  size_hints.min_height = size_hints.max_height = size_hints.base_height = Height;
+  XSetWMNormalHints (drv->display, drv->win, &size_hints);
+
+  XMapWindow (drv->display, drv->win);
+  HandleEvents(drv);
+  return EFI_SUCCESS;
+}
+
+static void
+handleKeyEvent(UGA_IO_PRIVATE *drv, XEvent *ev)
+{
+  KeySym keysym;
+  char str[4];
+  EFI_INPUT_KEY Key;
+  int res;
+
+  if (drv->key_count == NBR_KEYS)
+    return;
+
+  res = XLookupString(&ev->xkey, str, sizeof(str), &keysym, NULL);
+  Key.ScanCode = 0;\r
+  Key.UnicodeChar = 0;
+  switch (keysym) {\r
+  case XK_Home:       Key.ScanCode = SCAN_HOME;       break;\r
+  case XK_End:        Key.ScanCode = SCAN_END;        break;\r
+  case XK_Left:       Key.ScanCode = SCAN_LEFT;       break;\r
+  case XK_Right:      Key.ScanCode = SCAN_RIGHT;      break;\r
+  case XK_Up:         Key.ScanCode = SCAN_UP;         break;\r
+  case XK_Down:       Key.ScanCode = SCAN_DOWN;       break;\r
+  case XK_Delete:     Key.ScanCode = SCAN_DELETE;     break;\r
+  case XK_Insert:     Key.ScanCode = SCAN_INSERT;     break;\r
+  case XK_Page_Up:    Key.ScanCode = SCAN_PAGE_UP;    break;\r
+  case XK_Page_Down:  Key.ScanCode = SCAN_PAGE_DOWN;  break;\r
+  case XK_Escape:     Key.ScanCode = SCAN_ESC;        break;\r
+\r
+  case XK_F1:   Key.ScanCode = SCAN_F1;   break;\r
+  case XK_F2:   Key.ScanCode = SCAN_F2;   break;\r
+  case XK_F3:   Key.ScanCode = SCAN_F3;   break;\r
+  case XK_F4:   Key.ScanCode = SCAN_F4;   break;\r
+  case XK_F5:   Key.ScanCode = SCAN_F5;   break;\r
+  case XK_F6:   Key.ScanCode = SCAN_F6;   break;\r
+  case XK_F7:   Key.ScanCode = SCAN_F7;   break;\r
+  case XK_F8:   Key.ScanCode = SCAN_F8;   break;\r
+  case XK_F9:   Key.ScanCode = SCAN_F9;   break;\r
+
+  default:
+    if (res == 1) {
+      Key.UnicodeChar = str[0];
+    } else {
+      return;
+    }
+  }\r
+\r
+  drv->keys[drv->key_wr] = Key;
+  drv->key_wr = (drv->key_wr + 1) % NBR_KEYS;
+  drv->key_count++;
+}
+
+static void
+Redraw(UGA_IO_PRIVATE *drv, UINTN X, UINTN Y, UINTN Width, UINTN Height)
+{
+  if (drv->use_shm)
+    XShmPutImage (drv->display, drv->win, drv->gc, drv->image,
+                 X, Y, X, Y, Width, Height, False);
+  else
+    XPutImage (drv->display, drv->win, drv->gc, drv->image,
+                 X, Y, X, Y, Width, Height);
+}
+
+static void
+HandleEvent(UGA_IO_PRIVATE *drv, XEvent *ev)
+{
+  switch (ev->type)
+    {
+    case Expose:
+      Redraw(drv, ev->xexpose.x, ev->xexpose.y,
+            ev->xexpose.width, ev->xexpose.height);
+      break;
+    case GraphicsExpose:
+      Redraw(drv, ev->xgraphicsexpose.x, ev->xgraphicsexpose.y,
+            ev->xgraphicsexpose.width, ev->xgraphicsexpose.height);
+      break;
+    case KeyPress:
+      handleKeyEvent(drv, ev);
+      break;
+    case MappingNotify:
+      XRefreshKeyboardMapping(&ev->xmapping);
+      break;
+#if 0
+    case DestroyNotify:
+      XCloseDisplay (drv->display);
+      exit (1);
+      break;
+#endif
+    case NoExpose:
+    default:
+      break;
+    }
+}
+
+static void
+HandleEvents(UGA_IO_PRIVATE *drv)
+{
+  while (XPending(drv->display) != 0)
+    {
+      XEvent ev;
+         
+      XNextEvent (drv->display, &ev);
+      HandleEvent(drv, &ev);
+    }
+}
+
+static
+unsigned long
+UgaPixelToColor (UGA_IO_PRIVATE *drv, EFI_UGA_PIXEL pixel)
+{
+  return ((pixel.Red >> drv->r.csize) << drv->r.shift)
+    | ((pixel.Green >> drv->g.csize) << drv->g.shift)
+    | ((pixel.Blue >> drv->b.csize) << drv->b.shift);
+}
+
+static
+EFI_UGA_PIXEL
+UgaColorToPixel (UGA_IO_PRIVATE *drv, unsigned long val)
+{
+  EFI_UGA_PIXEL res;
+
+  /* FIXME: should round instead of truncate.  */
+  res.Red = (val >> drv->r.shift) << drv->r.csize;
+  res.Green = (val >> drv->g.shift) << drv->g.csize;
+  res.Blue = (val >> drv->b.shift) << drv->b.csize;
+
+  return res;
+}
+
+static
+EFI_STATUS
+UgaCheckKey(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
+{
+  UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
+  HandleEvents(drv);
+  if (drv->key_count != 0)
+    return EFI_SUCCESS;
+  else {
+    /* EFI is certainly polling.  Be CPU-friendly.  */
+    usleep (50000);
+    return EFI_NOT_READY;
+  }
+}
+
+static
+EFI_STATUS
+UgaGetKey(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
+{
+  UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
+  EFI_STATUS status;
+
+  status = UgaCheckKey(UgaIo);
+  if (status != EFI_SUCCESS)
+    return status;
+
+  *key = drv->keys[drv->key_rd];
+  drv->key_rd = (drv->key_rd + 1) % NBR_KEYS;
+  drv->key_count--;
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS\r
+UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
+       IN  EFI_UGA_PIXEL                           *BltBuffer OPTIONAL,\r
+       IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
+       IN  UINTN                                   SourceX,\r
+       IN  UINTN                                   SourceY,\r
+       IN  UINTN                                   DestinationX,\r
+       IN  UINTN                                   DestinationY,\r
+       IN  UINTN                                   Width,\r
+       IN  UINTN                                   Height,\r
+       IN  UINTN                                   Delta OPTIONAL\r
+  )\r
+{
+  UGA_IO_PRIVATE *Private = (UGA_IO_PRIVATE *)UgaIo;
+  UINTN             DstY;\r
+  UINTN             SrcY;\r
+  UINTN             DstX;
+  UINTN             SrcX;
+  UINTN             Index;
+  EFI_UGA_PIXEL     *Blt;\r
+  UINT8             *Dst;
+  UINT8             *Src;
+  UINTN             Nbr;
+  unsigned long     Color;
+
+  //
+  //  Check bounds
+  //
+  if (BltOperation == EfiUgaVideoToBltBuffer
+      || BltOperation == EfiUgaVideoToVideo) {\r
+    //\r
+    // Source is Video.
+    //\r
+    if (SourceY + Height > Private->height) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if (SourceX + Width > Private->width) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }
+
+  if (BltOperation == EfiUgaBltBufferToVideo
+      || BltOperation == EfiUgaVideoToVideo
+      || BltOperation == EfiUgaVideoFill) {\r
+    //\r
+    // Destination is Video\r
+    //\r
+    if (DestinationY + Height > Private->height) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if (DestinationX + Width > Private->width) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }
+
+  switch (BltOperation) {\r
+  case EfiUgaVideoToBltBuffer:
+    Blt = BltBuffer;
+    Delta -= Width * sizeof (EFI_UGA_PIXEL);
+    for (SrcY = SourceY; SrcY < (Height + SourceY); SrcY++) {\r
+      for (SrcX = SourceX; SrcX < (Width + SourceX); SrcX++) {
+       *Blt++ = UgaColorToPixel(Private,
+                                XGetPixel(Private->image, SrcX, SrcY));
+      }
+      Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Delta);
+    }\r
+    break;
+  case EfiUgaBltBufferToVideo:\r
+    Blt = BltBuffer;
+    Delta -= Width * sizeof (EFI_UGA_PIXEL);
+    for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {\r
+      for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
+       XPutPixel(Private->image, DstX, DstY, UgaPixelToColor(Private, *Blt));
+       Blt++;
+      }
+      Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Delta);
+    }
+    break;
+  case EfiUgaVideoToVideo:\r
+    Dst = Private->image_data + (DestinationX << Private->pixel_shift)
+      + DestinationY * Private->line_bytes;
+    Src = Private->image_data + (SourceX << Private->pixel_shift)
+      + SourceY * Private->line_bytes;
+    Nbr = Width << Private->pixel_shift;
+    if (DestinationY < SourceY) {\r
+      for (Index = 0; Index < Height; Index++) {
+       memcpy (Dst, Src, Nbr);
+       Dst += Private->line_bytes;
+       Src += Private->line_bytes;
+      }
+    }
+    else {
+      Dst += (Height - 1) * Private->line_bytes;
+      Src += (Height - 1) * Private->line_bytes;
+      for (Index = 0; Index < Height; Index++) {
+       //
+       // Source and Destination Y may be equal, therefore Dst and Src may
+       // overlap.
+       //
+       memmove (Dst, Src, Nbr);
+       Dst -= Private->line_bytes;
+       Src -= Private->line_bytes;
+      }
+    }
+    break;
+  case EfiUgaVideoFill:
+    Color = UgaPixelToColor(Private, *BltBuffer);
+    for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {\r
+      for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {
+       XPutPixel(Private->image, DstX, DstY, Color);
+      }
+    }\r
+    break;
+  default:
+      return EFI_INVALID_PARAMETER;\r
+  }
+
+  //
+  //  Refresh screen.
+  //
+  switch (BltOperation) {\r
+  case EfiUgaVideoToVideo:\r
+    XCopyArea(Private->display, Private->win, Private->win, Private->gc,
+             SourceX, SourceY, Width, Height, DestinationX, DestinationY);
+    while (1) {
+      XEvent ev;
+         
+      XNextEvent (Private->display, &ev);
+      HandleEvent(Private, &ev);
+      if (ev.type == NoExpose || ev.type == GraphicsExpose)
+       break;
+    }
+    break;
+  case EfiUgaVideoFill:
+    Color = UgaPixelToColor(Private, *BltBuffer);
+    XSetForeground(Private->display, Private->gc, Color);
+    XFillRectangle(Private->display, Private->win, Private->gc,
+                  DestinationX, DestinationY, Width, Height);
+    break;
+  case EfiUgaBltBufferToVideo:\r
+    Redraw(Private, DestinationX, DestinationY, Width, Height);
+    break;
+  default:
+    break;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title)
+{
+  UGA_IO_PRIVATE *drv;
+  unsigned int border_width = 0;
+  char *display_name = NULL;
+  int title_len;
+
+  drv = (UGA_IO_PRIVATE *)
+    malloc (sizeof (UGA_IO_PRIVATE));
+  if (drv == NULL)
+    return EFI_OUT_OF_RESOURCES;
+
+  drv->UgaIo.UgaClose = UgaClose;
+  drv->UgaIo.UgaSize = UgaSize;
+  drv->UgaIo.UgaCheckKey = UgaCheckKey;
+  drv->UgaIo.UgaGetKey = UgaGetKey;
+  drv->UgaIo.UgaBlt = UgaBlt;
+
+  drv->key_count = 0;
+  drv->key_rd = 0;
+  drv->key_wr = 0;
+  drv->display = XOpenDisplay (display_name);
+  if (drv->display == NULL)
+    {
+      fprintf (stderr, "uga: cannot connect to X server %s\n",
+              XDisplayName (display_name));
+      free (drv);
+      return EFI_DEVICE_ERROR;
+    }
+  drv->screen = DefaultScreen (drv->display);
+  drv->visual = DefaultVisual (drv->display, drv->screen);
+  drv->win = XCreateSimpleWindow
+       (drv->display, RootWindow (drv->display, drv->screen),
+        0, 0, 4, 4, border_width,
+        BlackPixel (drv->display, drv->screen),
+        WhitePixel (drv->display, drv->screen));
+
+  drv->depth = DefaultDepth (drv->display, drv->screen);
+
+  /* Compute title len and convert to Ascii.  */
+  for (title_len = 0; Title[title_len] != 0; title_len++)
+    ;
+  {
+    char title[title_len + 1];
+    int i;
+    for (i = 0; i < title_len; i++)
+      title[i] = Title[i];
+    title[i] = 0;
+    
+    XStoreName (drv->display, drv->win, title);
+  }
+
+  XSelectInput (drv->display, drv->win,
+               ExposureMask | KeyPressMask);
+  drv->gc = DefaultGC (drv->display, drv->screen);
+
+  *Uga = (EFI_UNIX_UGA_IO_PROTOCOL *)drv;
+  return EFI_SUCCESS;
+}
diff --git a/EdkUnixPkg/Sec/UnixThunk.c b/EdkUnixPkg/Sec/UnixThunk.c
new file mode 100644 (file)
index 0000000..a94cb38
--- /dev/null
@@ -0,0 +1,189 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2006, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  UnixThunk.c\r
+\r
+Abstract:\r
+\r
+  Since the SEC is the only program in our emulation we \r
+  must use a Tiano mechanism to export APIs to other modules.\r
+  This is the role of the EFI_UNIX_THUNK_PROTOCOL.\r
+\r
+  The mUnixThunkTable exists so that a change to EFI_UNIX_THUNK_PROTOCOL\r
+  will cause an error in initializing the array if all the member functions\r
+  are not added. It looks like adding a element to end and not initializing\r
+  it may cause the table to be initaliized with the members at the end being\r
+  set to zero. This is bad as jumping to zero will crash.\r
+  \r
+\r
+  gUnix is a a public exported global that contains the initialized\r
+  data.\r
+\r
+--*/\r
+\r
+#include "SecMain.h"\r
+#include "Library/UnixLib.h"
+#include <sys/time.h>
+#include <time.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+
+static int settimer_initialized;
+static struct timeval settimer_timeval;
+static void (*settimer_callback)(UINT64 delta);
+
+static void
+settimer_handler (int sig)
+{
+  struct timeval timeval;
+  UINT64 delta;
+
+  gettimeofday (&timeval, NULL);
+  delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
+    - ((UINT64)settimer_timeval.tv_sec * 1000) 
+    - (settimer_timeval.tv_usec / 1000);
+  settimer_timeval = timeval;
+  if (settimer_callback)
+    (*settimer_callback)(delta);
+}
+
+static
+VOID
+SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
+{
+  struct itimerval timerval;
+
+  if (!settimer_initialized) {
+    struct sigaction act;
+
+    settimer_initialized = 1;
+    act.sa_handler = settimer_handler;
+    act.sa_flags = 0;
+    sigemptyset (&act.sa_mask);
+    if (sigaction (SIGALRM, &act, NULL) != 0) {
+      printf ("SetTimer: sigaction error %s\n", strerror (errno));
+    }
+    if (gettimeofday (&settimer_timeval, NULL) != 0) {
+      printf ("SetTimer: gettimeofday error %s\n", strerror (errno));
+    }
+  }
+  timerval.it_value.tv_sec = PeriodMs / 1000;
+  timerval.it_value.tv_usec = (PeriodMs % 1000) * 1000;
+  timerval.it_value.tv_sec = PeriodMs / 1000;
+  timerval.it_interval = timerval.it_value;
+  
+  if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
+    printf ("SetTimer: setitimer error %s\n", strerror (errno));
+  }
+  settimer_callback = CallBack;
+}
+
+void
+GetLocalTime (EFI_TIME *Time)
+{
+  struct tm *tm;
+  time_t t;
+
+  t = time (NULL);
+  tm = localtime (&t);
+
+  Time->Year = 1900 + tm->tm_year;
+  Time->Month = tm->tm_mon;
+  Time->Day = tm->tm_mday;
+  Time->Hour = tm->tm_hour;
+  Time->Minute = tm->tm_min;
+  Time->Second = tm->tm_sec;
+  Time->Nanosecond = 0;
+  Time->TimeZone = timezone;
+  Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
+    | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
+}
+
+void
+msSleep (unsigned long Milliseconds)
+{
+  usleep (Milliseconds * 1000);
+}
+
+static void
+TzSet (void)
+{
+  static int done = 0;
+  if (!done) {
+    tzset ();
+    done = 1;
+  }
+}
+
+long
+GetTimeZone(void)
+{
+  TzSet ();
+  return timezone;
+}
+
+int
+GetDayLight(void)
+{
+  TzSet ();
+  return daylight;
+}
+
+int
+GetErrno(void)
+{
+  return errno;
+}
+
+extern EFI_STATUS
+UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, CONST CHAR16 *Title);
+
+EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {\r
+  EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,\r
+  msSleep, /* Sleep */
+  exit, /* Exit */
+  SetTimer,
+  GetLocalTime,
+  gmtime,
+  GetTimeZone,
+  GetDayLight,
+  (UnixPoll)poll,
+  (UnixRead)read,
+  (UnixWrite)write,
+  getenv,
+  (UnixOpen)open,
+  lseek,
+  ftruncate,
+  close,
+  mkdir,
+  rmdir,
+  unlink,
+  GetErrno,
+  opendir,
+  rewinddir,
+  readdir,
+  closedir,
+  stat,
+  statfs,
+  rename,
+  mktime,
+  fsync,
+  chmod,
+  utime,
+
+  UgaCreate,
+};\r
+\r
+\r
+EFI_UNIX_THUNK_PROTOCOL *gUnix = &mUnixThunkTable;\r
diff --git a/EdkUnixPkg/Unix.fpd b/EdkUnixPkg/Unix.fpd
new file mode 100644 (file)
index 0000000..ece893e
--- /dev/null
@@ -0,0 +1,7806 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PlatformSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <PlatformHeader>
+    <PlatformName>Unix</PlatformName>
+    <GuidValue>7b3c1fb4-8986-11db-b5b2-0040d02b1835</GuidValue>
+    <Version>0.3</Version>
+    <Abstract>EFI/Framework Emulation Platform</Abstract>
+    <Description>The Emulation Platform can be used to debug individual modules, prior to creating
+      a real platform. This also provides an example for how an FPD is created.</Description>
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>
+  </PlatformHeader>
+  <PlatformDefinitions>
+    <SupportedArchitectures>IA32</SupportedArchitectures>
+    <BuildTargets>DEBUG RELEASE</BuildTargets>
+    <IntermediateDirectories>UNIFIED</IntermediateDirectories>
+    <OutputDirectory>Build/Unix</OutputDirectory>
+    <SkuInfo>
+      <UiSkuName SkuID="0">DEFAULT</UiSkuName>
+    </SkuInfo>
+  </PlatformDefinitions>
+  <Flash>
+    <FlashDefinitionFile>FlashMap.fdf</FlashDefinitionFile>
+    <!--FlashDefinitionFile-->
+    <FvImages>
+      <!--Global Varables-->
+      <NameValue Name="FV_RECOVERY_BASE_ADDRESS" Value="0xFFD80000"/>
+      <NameValue Name="FV_MAIN_BASE_ADDRESS" Value="0xFFF00000"/>
+      <!--Define Valid Image Names-->
+      <FvImage Type="ImageName">
+        <FvImageNames>FV_RECOVERY</FvImageNames>
+        <FvImageNames>NV_STORAGE</FvImageNames>
+      </FvImage>
+      <!--Define Attributes for on or more Images Names-->
+      <FvImage Type="Attributes">
+        <FvImageNames>FV_RECOVERY</FvImageNames>
+        <FvImageNames>NV_STORAGE</FvImageNames>
+        <FvImageNames>FV_FILE</FvImageNames>
+        <FvImageOptions>
+          <NameValue Name="EFI_ERASE_POLARITY" Value="1"/>
+          <NameValue Name="EFI_READ_DISABLED_CAP" Value="TRUE"/>
+          <NameValue Name="EFI_READ_ENABLED_CAP" Value="TRUE"/>
+          <NameValue Name="EFI_READ_STATUS" Value="TRUE"/>
+          <NameValue Name="EFI_WRITE_DISABLED_CAP" Value="TRUE"/>
+          <NameValue Name="EFI_WRITE_ENABLED_CAP" Value="TRUE"/>
+          <NameValue Name="EFI_WRITE_STATUS" Value="TRUE"/>
+          <NameValue Name="EFI_LOCK_CAP" Value="TRUE"/>
+          <NameValue Name="EFI_LOCK_STATUS" Value="TRUE"/>
+          <NameValue Name="EFI_MEMORY_MAPPED" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_CAP" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_2" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_4" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_8" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_16" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_32" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_64" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_128" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_256" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_512" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_1K" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_2K" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_4K" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_8K" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_16K" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_32K" Value="TRUE"/>
+          <NameValue Name="EFI_ALIGNMENT_64K" Value="TRUE"/>
+          <NameValue Name="EFI_STICKY_WRITE" Value="FALSE"/>
+        </FvImageOptions>
+      </FvImage>
+      <!--Define Components for one or more Image Names-->
+      <FvImage Type="Components">
+        <FvImageNames>NV_STORAGE</FvImageNames>
+        <FvImageOptions>
+          <NameValue Name="EFI_NV_VARIABLE" Value="0xC000"/>
+          <NameValue Name="EFI_NV_EVENT_LOG" Value="0x2000"/>
+          <NameValue Name="EFI_NV_FTW_WORKING" Value="0x2000"/>
+          <NameValue Name="EFI_NV_FTW_SPARE" Value="0x10000"/>
+        </FvImageOptions>
+      </FvImage>
+      <!--Define Options for Individual Image Names-->
+      <FvImage Type="Options">
+        <FvImageNames>FV_RECOVERY</FvImageNames>
+        <FvImageOptions>
+          <NameValue Name="EFI_BASE_ADDRESS" Value="${FV_RECOVERY_BASE_ADDRESS}"/>
+          <NameValue Name="EFI_FILE_NAME" Value="FV_RECOVERY.fv"/>
+          <NameValue Name="EFI_NUM_BLOCKS" Value="0x28"/>
+          <NameValue Name="EFI_BLOCK_SIZE" Value="0x10000"/>
+        </FvImageOptions>
+      </FvImage>
+      <FvImage Type="Options">
+        <FvImageNames>FV_FILE</FvImageNames>
+        <FvImageOptions>
+          <NameValue Name="EFI_BASE_ADDRESS" Value="0x00000000"/>
+          <NameValue Name="EFI_FILE_NAME" Value="${FV_FILENAME}.fv"/>
+          <NameValue Name="EFI_SYM_FILE_NAME" Value="${FV_FILENAME}.sym"/>
+          <NameValue Name="EFI_NUM_BLOCKS" Value="0x2"/>
+          <NameValue Name="EFI_BLOCK_SIZE" Value="0x10000"/>
+        </FvImageOptions>
+      </FvImage>
+      <FvImage Type="Options">
+        <FvImageNames>NV_STORAGE</FvImageNames>
+        <FvImageOptions>
+          <NameValue Name="EFI_BASE_ADDRESS" Value="0xFFFC0000"/>
+          <NameValue Name="EFI_FILE_NAME" Value="${FV_FILENAME}.fv"/>
+          <NameValue Name="EFI_NUM_BLOCKS" Value="0x2"/>
+          <NameValue Name="EFI_BLOCK_SIZE" Value="0x10000"/>
+          <NameValue Name="EFI_FV_GUID" Value="fff12b8d-7696-4c8b-a985-2747075b4f50"/>
+        </FvImageOptions>
+      </FvImage>
+      <FvImage Type="Options">
+        <FvImageNames>CAPSULE_A</FvImageNames>
+        <FvImageOptions>
+          <NameValue Name="EFI_BASE_ADDRESS" Value="${FV_RECOVERY_BASE_ADDRESS}"/>
+          <NameValue Name="EFI_FILE_NAME" Value="Capsule_A.fv"/>
+          <NameValue Name="EFI_NUM_BLOCKS" Value="0x28"/>
+          <NameValue Name="EFI_BLOCK_SIZE" Value="0x10000"/>
+        </FvImageOptions>
+      </FvImage>
+    </FvImages>
+  </Flash>
+  <FrameworkModules>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f43be88c-8985-11db-8f78-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9ba1d976-0624-41a3-8650-28165e8d9ae8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdUnixMemorySizeForSecMain</C_Name>
+          <Token>0x0000100c</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>10</MaxDatumSize>
+          <Value>L"64!64"</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdUnixFirmwareVolume</C_Name>
+          <Token>0x00001009</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>52</MaxDatumSize>
+          <Value>L"../FV/FV_RECOVERY.fd"</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdUnixBootMode</C_Name>
+          <Token>0x00001006</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>NULL</FvBinding>
+        <FfsFormatKey>CUSTOM_BUILD</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="52C05B14-0B98-496c-BC3B-04B50211D680">
+      <Libraries>
+        <Instance ModuleGuid="f3b702e8-8985-11db-9558-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="b3b0654a-969d-4096-86cb-27e262a02083" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b2585b69-fb63-4220-844a-8fbea8bf01af" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <!--Pkg: EdkUnixPkg Mod: UnixTimerLib Path: EdkUnixPkg\Library\UnixTimerLibNull\UnixTimerLib.msa-->
+        <Instance ModuleGuid="f3db5724-8985-11db-acbc-0040d02b1835" ModuleVersion="1.0" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+          <Token>0x00000009</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PEI_CORE</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b694e0dc-cd4e-4b30-885b-9c164ed3e74a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaxPeiPcdCallBackNumberPerPcdEntry</C_Name>
+          <Token>0x0001000f</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x08</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdVpdBaseAddress</C_Name>
+          <Token>0x00010010</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPeiPcdDatabaseTraverseEnabled</C_Name>
+          <Token>0x00010020</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPeiPcdDatabaseCallbackOnSetEnabled</C_Name>
+          <Token>0x00010032</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPeiPcdDatabaseExEnabled</C_Name>
+          <Token>0x00010033</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPeiPcdDatabaseGetSizeEnabled</C_Name>
+          <Token>0x00010031</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPeiPcdDatabaseSetEnabled</C_Name>
+          <Token>0x00010030</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="1EC0F53A-FDE0-4576-8F25-7A1A410F58EB">
+      <Libraries>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="9dbf6f25-0da2-4a1d-8e12-e78de6ab4d0e" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="9ba1d976-0624-41a3-8650-28165e8d9ae8" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="926c9cd0-4bb8-479b-9ac4-8a2a23f85307" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="e6e9c1f8-2c8a-4f4b-a27c-c382e4bb8e67" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="b5a05743-9b71-489b-a0ed-a0eb3950d23b" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="E4541241-8897-411a-91F8-7D7E45837146" ModuleVersion="1.0" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" PackageVersion="0.3"/>
+        <Instance ModuleGuid="f3c32014-8985-11db-bae7-0040d02b1835" ModuleVersion="1.0" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseSerial</C_Name>
+          <Token>0x00010022</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseMemory</C_Name>
+          <Token>0x00010023</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseOEM</C_Name>
+          <Token>0x00010024</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="PATCHABLE_IN_MODULE">
+          <C_Name>PcdStatusCodeMemorySize</C_Name>
+          <Token>0x00010025</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT16</DatumType>
+          <MaxDatumSize>2</MaxDatumSize>
+          <Value>1</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdFSBClock</C_Name>
+          <Token>0x0000000c</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>200000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdIoBlockBaseAddressForIpf</C_Name>
+          <Token>0x0000000c</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT64</DatumType>
+          <MaxDatumSize>8</MaxDatumSize>
+          <Value>0x0ffffc000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdUnixStatusCodeLibUseForPei</C_Name>
+          <Token>0x0000100b</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+        <Options>
+          <Option BuildTargets="DEBUG" ToolChainFamily="MSFT" SupArchList="IA32" ToolCode="DLINK">Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib</Option>
+          <Option BuildTargets="RELEASE" ToolChainFamily="MSFT" SupArchList="IA32" ToolCode="DLINK">Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib</Option>
+        </Options>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f3ff9aee-8985-11db-b133-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f417814a-8985-11db-8983-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9dbf6f25-0da2-4a1d-8e12-e78de6ab4d0e" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageVariableBase</C_Name>
+          <Token>0x30000001</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageVariableSize</C_Name>
+          <Token>0x30000002</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwSpareBase</C_Name>
+          <Token>0x30000013</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwSpareSize</C_Name>
+          <Token>0x30000014</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwWorkingBase</C_Name>
+          <Token>0x30000010</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwWorkingSize</C_Name>
+          <Token>0x30000011</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="736EB068-8C01-47c5-964B-1C57BD5D4D64">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="34C8C28F-B61C-45a2-8F2E-89E46BECC63B">
+      <Libraries>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9dbf6f25-0da2-4a1d-8e12-e78de6ab4d0e" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageVariableBase</C_Name>
+          <Token>0x30000001</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f3f36cb0-8985-11db-b195-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f40b7864-8985-11db-af21-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f4239aa2-8985-11db-af82-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="86D70125-BAA3-4296-A62F-602BEBBB9081">
+      <Libraries>
+        <Instance ModuleGuid="f3cf597e-8985-11db-95f6-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="fa177ff7-1fc7-458d-a358-d9d62ae61cec" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a9759d2-53bc-4eb2-abcd-c93099419063" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9643128f-ac24-4b3e-b6be-d8849a306153" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="123dd843-57c9-4158-8418-ce68b3944ce7" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="d774c4d9-c121-4da3-a5e2-0f317e3c630c" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="e5566134-c75e-4ace-bad1-e23a3b335e30" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b694e0dc-cd4e-4b30-885b-9c164ed3e74a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <!--Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/-->
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDxeIplSwitchToLongMode</C_Name>
+          <Token>0x0001003b</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDxeIplSupportEfiDecompress</C_Name>
+          <Token>0x00010034</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDxeIplSupportTianoDecompress</C_Name>
+          <Token>0x00010035</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDxeIplSupportCustomDecompress</C_Name>
+          <Token>0x00010036</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDxeIplBuildShareCodeHobs</C_Name>
+          <Token>0x0001003c</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>PE32_PEIM</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="D6A2CB7F-6A18-4e2f-B43B-9920A733700A">
+      <Libraries>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="123dd843-57c9-4158-8418-ce68b3944ce7" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="5c12c06f-5cf8-48a6-9860-6c5b2c036bbf" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="cef487a1-751d-4fe0-a39b-e6892b4610c8" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="942e0182-3e1d-47f9-92dc-4939d1a0ba00" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="ed3de5c8-c389-44f2-a35e-2ebdc9802a49" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="882ee1a3-35b2-412c-b8a2-7a8d34a7c390" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="d258d6af-2fc0-4019-9c1f-1101c3dd19b5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+          <Token>0x00000009</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>DXE_CORE</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="80CF7257-87AB-47f9-A3FE-D50B76D89541">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdVpdBaseAddress</C_Name>
+          <Token>0x00010010</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDxePcdDatabaseTraverseEnabled</C_Name>
+          <Token>0x00010021</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="51C9F40C-5243-4473-B265-B3C8FFAFF9FA">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f3794b60-8985-11db-8e53-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f348f6fe-8985-11db-b4c3-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f39efc84-8985-11db-ad67-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f36d49b4-8985-11db-809b-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f39efc84-8985-11db-ad67-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f3552032-8985-11db-8429-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f39efc84-8985-11db-ad67-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f3613084-8985-11db-8c26-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f39efc84-8985-11db-ad67-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f392b762-8985-11db-be87-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="baa1baa3-0a8d-402c-8042-985115fae953" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f3aaea62-8985-11db-baff-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="08c1a0e4-1208-47f8-a2c5-f42eabee653a" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="ea55bada-d488-427b-9d2d-227e0aaa3707" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+          <Token>0x00000009</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="F099D67F-71AE-4c36-B2A3-DCEB0EB2B7D8">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="B601F8C4-43B7-4784-95B1-F4226CB40CEE">
+      <Libraries>
+        <Instance ModuleGuid="123dd843-57c9-4158-8418-ce68b3944ce7" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>RT_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="AD608272-D07F-4964-801E-7BD3B7888652">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>RT_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F">
+      <Libraries>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b5a05743-9b71-489b-a0ed-a0eb3950d23b" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="926c9cd0-4bb8-479b-9ac4-8a2a23f85307" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="E4541241-8897-411a-91F8-7D7E45837146" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="f3c32014-8985-11db-bae7-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="1c747f6b-0a58-49ae-8ea3-0327a4fa10e3" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <Instance ModuleGuid="a804239b-4155-446f-acc8-f0825d74908c" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseHardSerial</C_Name>
+          <Token>0x00010027</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseEfiSerial</C_Name>
+          <Token>0x00010026</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseRuntimeMemory</C_Name>
+          <Token>0x00010028</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseDataHub</C_Name>
+          <Token>0x00010029</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeUseOEM</C_Name>
+          <Token>0x00010024</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeReplayInSerial</C_Name>
+          <Token>0x0001002a</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeReplayInDataHub</C_Name>
+          <Token>0x0001002c</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeReplayInRuntimeMemory</C_Name>
+          <Token>0x0001002b</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdStatusCodeReplayInOEM</C_Name>
+          <Token>0x0001002d</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="PATCHABLE_IN_MODULE">
+          <C_Name>PcdStatusCodeRuntimeMemorySize</C_Name>
+          <Token>0x0001002e</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT16</DatumType>
+          <MaxDatumSize>2</MaxDatumSize>
+          <Value>128</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdFSBClock</C_Name>
+          <Token>0x0000000c</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>200000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdIoBlockBaseAddressForIpf</C_Name>
+          <Token>0x0000000c</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT64</DatumType>
+          <MaxDatumSize>8</MaxDatumSize>
+          <Value>0x0ffffc000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdUnixStatusCodeLibUseForPei</C_Name>
+          <Token>0x0000100b</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+        <Options>
+          <Option BuildTargets="DEBUG" ToolChainFamily="MSFT" SupArchList="IA32" ToolCode="DLINK">Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib</Option>
+          <Option BuildTargets="RELEASE" ToolChainFamily="MSFT" SupArchList="IA32" ToolCode="DLINK">Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib</Option>
+        </Options>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f42fd042-8985-11db-a7db-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="baa1baa3-0a8d-402c-8042-985115fae953" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9ba1d976-0624-41a3-8650-28165e8d9ae8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>RT_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="4C862FC6-0E54-4e36-8C8F-FF6F3167951F">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <!--Pkg: MdePkg Mod: DxePcdLib Path: MdePkg\Library\DxePcdLib\DxePcdLib.msa-->
+        <Instance ModuleGuid="af97eb89-4cc6-45f8-a514-ca025b346480" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwSpareBase</C_Name>
+          <Token>0x30000013</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwSpareSize</C_Name>
+          <Token>0x30000014</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwWorkingBase</C_Name>
+          <Token>0x30000010</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageFtwWorkingSize</C_Name>
+          <Token>0x30000011</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="CBD2E4D5-7068-4FF5-B462-9822B4AD8D60">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="baa1baa3-0a8d-402c-8042-985115fae953" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bd4d540e-04b0-4b10-8fd5-4a7bb533cf67" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <!--Pkg: MdePkg Mod: DxePcdLib Path: MdePkg\Library\DxePcdLib\DxePcdLib.msa-->
+        <Instance ModuleGuid="af97eb89-4cc6-45f8-a514-ca025b346480" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageVariableBase</C_Name>
+          <Token>0x30000001</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdFlashNvStorageVariableSize</C_Name>
+          <Token>0x30000002</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>RT_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="42857F0A-13F2-4B21-8A23-53D3F714B840">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="baa1baa3-0a8d-402c-8042-985115fae953" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="9ba1d976-0624-41a3-8650-28165e8d9ae8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdSupportUpdateCapsuleRest</C_Name>
+          <Token>0x0001001d</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaxSizePopulateCapsule</C_Name>
+          <Token>0x0001001e</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaxSizeNonPopulateCapsule</C_Name>
+          <Token>0x0001001f</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x0</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>RT_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="F80697E9-7FD6-4665-8646-88E33EF71DFC">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="73E9457A-CEA1-4917-9A9C-9F1F0F0FD322">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPciBusHotplugDeviceSupport</C_Name>
+          <Token>0x0001003d</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>NULL</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="911D584C-35F7-4955-BEF9-B452769DDC3A">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>NULL</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="51ccf399-4fdf-4e55-a45b-e123f84d456a">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="408edcec-cf6d-477c-a5a8-b4844e3de281">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="CCCB0C28-4B24-11d5-9A5A-0090273FC14D">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="9E863906-A40F-4875-977F-5B93FF237FC6">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="53BCC14F-C24F-434C-B294-8ED2D4CC1860">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="CA515306-00CE-4032-874E-11B755FF6866">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="9B680FCE-AD6B-4F3A-B60B-F59899003443">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDevicePathSupportDevicePathToText</C_Name>
+          <Token>0x00010037</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDevicePathSupportDevicePathFromText</C_Name>
+          <Token>0x00010038</Token>
+          <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>TRUE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="6B38F7B4-AD98-40e9-9093-ACA2B5A253C4">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="13AC6DD0-73D0-11D4-B06B-00AA00BD6DE7">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="96B5C032-DF4C-4b6e-8232-438DCF448D0E">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="baa1baa3-0a8d-402c-8042-985115fae953" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="FCD337AB-B1D3-4EF8-957C-8048606FF670">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="ea55bada-d488-427b-9d2d-227e0aaa3707" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="1FA1F39E-FEFF-4aae-BD7B-38A070A3B609">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="7BB28B99-61BB-11D5-9A5D-0090273FC14D">
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>Logo</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="93B80004-9FB3-11d4-9A3A-0090273FC14D">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPciIsaEnable</C_Name>
+          <Token>0x00010039</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdPciVgaEnable</C_Name>
+          <Token>0x0001003a</Token>
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">\r
+          <C_Name>PcdPciBusHotplugDeviceSupport</C_Name>\r
+          <Token>0x0001003d</Token>\r
+          <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
+          <DatumType>BOOLEAN</DatumType>\r
+          <MaxDatumSize>1</MaxDatumSize>\r
+          <Value>TRUE</Value>\r
+        </PcdData>\r
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="EBf342FE-B1D3-4EF8-957C-8048606FF670">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="08c1a0e4-1208-47f8-a2c5-f42eabee653a" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="FE3542FE-C1D3-4EF8-657C-8048606FF670">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="08c1a0e4-1208-47f8-a2c5-f42eabee653a" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="ea55bada-d488-427b-9d2d-227e0aaa3707" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="CD3BAFB6-50FB-4fe8-8E4E-AB74D2C1A600">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="E49061CE-99A7-41d3-AB3A-36E5CFBAD63E">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="555F76EA-785F-40d7-9174-153C43636C68">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="69FD8E47-A161-4550-B01A-5594CEB2B2B2">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+          <Token>0x00000009</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="2FB92EFA-2EE0-4bae-9EB6-7464125E1EF7">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="BDFE430E-8F2A-4db0-9991-6F856594777E">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_MAIN</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="0167CCC4-D0F7-4f21-A3EF-9E64B7CDCE8B">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="46c9adef-aee6-410c-99e4-240e3af18d8b" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="0A66E322-3740-4cce-AD62-BD172CECCA35">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="46c9adef-aee6-410c-99e4-240e3af18d8b" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="B40612B9-A063-11d4-9A3A-0090273FC14D">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="240612B7-A063-11d4-9A3A-0090273FC14D">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="A3527D16-E6CC-42f5-BADB-BF3DE177742B">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="B40612B2-A063-11d4-9A3A-0090273FC14D">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="2D2E62CF-9ECF-43b7-8219-94E7FC713DFE">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="A5C6D68B-E78A-4426-9278-A8F0D9EB4D8F">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="2D2E62AA-9ECF-43b7-8219-94E7FC713DFE">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="87eb5df9-722a-4241-ad7f-370d0b3a56d7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="A3f436EA-A127-4EF8-957C-8048606FF670">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="50bcb105-6634-441d-b403-659110a03ad2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="a46c3330-be36-4977-9d24-a7cf92eef0fe">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="A2f436EA-A127-4EF8-957C-8048606FF670">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f38610fc-8985-11db-82d4-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f12b59c9-76d0-4661-ad7c-f04d1bef0558" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f39efc84-8985-11db-ad67-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f320d656-8985-11db-90e0-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="af97eb89-4cc6-45f8-a514-ca025b346480" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixConsole</C_Name>
+          <Token>0x0000100a</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>50</MaxDatumSize>
+          <Value>L"Bus Driver Console Window"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixUga</C_Name>
+          <Token>0x00001003</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>50</MaxDatumSize>
+          <Value>L"UGA Window"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixFileSystem</C_Name>
+          <Token>0x00001004</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>106</MaxDatumSize>
+          <Value>L".!../../../../EdkShellBinPkg/bin/ia32/Apps"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixVirtualDisk</C_Name>
+          <Token>0x00001001</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>24</MaxDatumSize>
+          <Value>L"disk1.img:FW"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixPhysicalDisk</C_Name>
+          <Token>0x00001000</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>30</MaxDatumSize>
+          <Value>L"E:RW;245760;512"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixCpuModel</C_Name>
+          <Token>0x00001007</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>48</MaxDatumSize>
+          <Value>L"Intel(R) Processor Model"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixCpuSpeed</C_Name>
+          <Token>0x00001008</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>8</MaxDatumSize>
+          <Value>L"3000"</Value>
+        </PcdData>
+        <PcdData ItemType="DYNAMIC">
+          <C_Name>PcdUnixMemorySize</C_Name>
+          <Token>0x00001005</Token>
+          <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>VOID*</DatumType>
+          <MaxDatumSize>10</MaxDatumSize>
+          <Value>L"64!64"</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f3085888-8985-11db-9c93-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b57a1df6-ffdb-4247-a3df-3a562176751a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f314a8cc-8985-11db-9f69-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b57a1df6-ffdb-4247-a3df-3a562176751a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" ModuleGuid="f2fbd108-8985-11db-b06a-0040d02b1835">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="1e2c4c2e-67e6-4e57-b3ae-cf5a5af72c2c" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdReportStatusCodePropertyMask</C_Name>
+          <Token>0x00000007</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x06</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="d4266a1b-1d38-4116-93ae-60dc3e2012a6" ModuleGuid="c57ad6b7-0515-40a8-9d21-551652854e37">
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>APPLICATION</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="0fd7197b-9bde-44fe-a7e4-d2177a9922e5" ModuleGuid="961578FE-B6B7-44c3-AF35-6BC705CD2B1F">
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <ModuleSA SupArchList="IA32" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" ModuleGuid="6987936E-ED34-44db-AE97-1FA5E4ED2116">
+      <Libraries>
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="b57a1df6-ffdb-4247-a3df-3a562176751a" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x1f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>APPLICATION</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <!--Mod: UnixUga Type: UEFI_DRIVER Path: EdkUnixPkg/Dxe/UnixThunk/Bus/Uga/UnixUga.msa-->
+    <ModuleSA ModuleGuid="f33cad86-8985-11db-8040-0040d02b1835" ModuleVersion="1.0" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" PackageVersion="0.3" SupArchList="IA32">
+      <Libraries>
+        <!--Pkg: MdePkg Mod: UefiDriverEntryPoint Path: MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.msa-->
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: BaseLib Path: MdePkg/Library/BaseLib/BaseLib.msa-->
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiLib Path: MdePkg/Library/UefiLib/UefiLib.msa-->
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiDriverModelLib Path: MdePkg/Library/UefiDriverModelLib/UefiDriverModelLib.msa-->
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: DxeMemoryAllocationLib Path: MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa-->
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: DxeMemoryLib Path: MdePkg/Library/DxeMemoryLib/DxeMemoryLib.msa-->
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiBootServicesTableLib Path: MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.msa-->
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiDebugLibStdErr Path: MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.msa-->
+        <Instance ModuleGuid="b57a1df6-ffdb-4247-a3df-3a562176751a" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: BasePrintLib Path: MdePkg/Library/BasePrintLib/BasePrintLib.msa-->
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x0f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+    <!--Mod: UnixSimpleFileSystem Type: UEFI_DRIVER Path: EdkUnixPkg/Dxe/UnixThunk/Bus/SimpleFileSystem/UnixSimpleFileSystem.msa-->
+    <ModuleSA ModuleGuid="f330834e-8985-11db-a295-0040d02b1835" ModuleVersion="1.0" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" PackageVersion="0.3" SupArchList="IA32">
+      <Libraries>
+        <!--Pkg: MdePkg Mod: UefiDriverEntryPoint Path: MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.msa-->
+        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: BaseLib Path: MdePkg/Library/BaseLib/BaseLib.msa-->
+        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: DxeMemoryAllocationLib Path: MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.msa-->
+        <Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiLib Path: MdePkg/Library/UefiLib/UefiLib.msa-->
+        <Instance ModuleGuid="3a004ba5-efe0-4a61-9f1a-267a46ae5ba9" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiBootServicesTableLib Path: MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.msa-->
+        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiDriverModelLib Path: MdePkg/Library/UefiDriverModelLib/UefiDriverModelLib.msa-->
+        <Instance ModuleGuid="52af22ae-9901-4484-8cdc-622dd5838b09" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: UefiDebugLibStdErr Path: MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.msa-->
+        <Instance ModuleGuid="b57a1df6-ffdb-4247-a3df-3a562176751a" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: DxeMemoryLib Path: MdePkg/Library/DxeMemoryLib/DxeMemoryLib.msa-->
+        <Instance ModuleGuid="f1bbe03d-2f28-4dee-bec7-d98d7a30c36a" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+        <!--Pkg: MdePkg Mod: BasePrintLib Path: MdePkg/Library/BasePrintLib/BasePrintLib.msa-->
+        <Instance ModuleGuid="a86fbfca-0183-4eeb-aa8a-762e3b7da1f3" ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec" PackageVersion="0.3"/>
+      </Libraries>
+      <PcdBuildDefinition>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
+          <Token>0x00000001</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumAsciiStringLength</C_Name>
+          <Token>0x00000002</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdMaximumLinkedListLength</C_Name>
+          <Token>0x00000003</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>1000000</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdSpinLockTimeout</C_Name>
+          <Token>0x00000004</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>10000000</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdComponentNameDisable</C_Name>
+          <Token>0x0000000d</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FEATURE_FLAG">
+          <C_Name>PcdDriverDiagnosticsDisable</C_Name>
+          <Token>0x0000000e</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>BOOLEAN</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>FALSE</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPropertyMask</C_Name>
+          <Token>0x00000005</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0x0f</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugClearMemoryValue</C_Name>
+          <Token>0x00000008</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT8</DatumType>
+          <MaxDatumSize>1</MaxDatumSize>
+          <Value>0xAF</Value>
+        </PcdData>
+        <PcdData ItemType="FIXED_AT_BUILD">
+          <C_Name>PcdDebugPrintErrorLevel</C_Name>
+          <Token>0x00000006</Token>
+          <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
+          <DatumType>UINT32</DatumType>
+          <MaxDatumSize>4</MaxDatumSize>
+          <Value>0x80000000</Value>
+        </PcdData>
+      </PcdBuildDefinition>
+      <ModuleSaBuildOptions>
+        <FvBinding>FV_RECOVERY</FvBinding>
+        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
+      </ModuleSaBuildOptions>
+    </ModuleSA>
+  </FrameworkModules>
+  <DynamicPcdBuildDefinitions>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdFlashNvStorageVariableBase</C_Name>
+      <Token>0x30000001</Token>
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>UINT32</DatumType>
+      <MaxDatumSize>4</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>0x0</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdFlashNvStorageVariableSize</C_Name>
+      <Token>0x30000002</Token>
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>UINT32</DatumType>
+      <MaxDatumSize>4</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>0x0</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdFlashNvStorageFtwSpareBase</C_Name>
+      <Token>0x30000013</Token>
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>UINT32</DatumType>
+      <MaxDatumSize>4</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>0x0</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdFlashNvStorageFtwSpareSize</C_Name>
+      <Token>0x30000014</Token>
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>UINT32</DatumType>
+      <MaxDatumSize>4</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>0x0</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdFlashNvStorageFtwWorkingBase</C_Name>
+      <Token>0x30000010</Token>
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>UINT32</DatumType>
+      <MaxDatumSize>4</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>0x0</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdFlashNvStorageFtwWorkingSize</C_Name>
+      <Token>0x30000011</Token>
+      <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>UINT32</DatumType>
+      <MaxDatumSize>4</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>0x0</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixConsole</C_Name>
+      <Token>0x0000100a</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>50</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"Bus Driver Console Window"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixUga</C_Name>
+      <Token>0x00001003</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>50</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"UGA Window"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixFileSystem</C_Name>
+      <Token>0x00001004</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>106</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L".!../../../../EdkShellBinPkg/bin/ia32/Apps"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixVirtualDisk</C_Name>
+      <Token>0x00001001</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>24</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"disk1.img:FW"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixPhysicalDisk</C_Name>
+      <Token>0x00001000</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>30</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"E:RW;245760;512"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixCpuModel</C_Name>
+      <Token>0x00001007</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>48</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"Intel(R) Processor Model"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixCpuSpeed</C_Name>
+      <Token>0x00001008</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>8</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"3000"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+    <PcdBuildData ItemType="DYNAMIC">
+      <C_Name>PcdUnixMemorySize</C_Name>
+      <Token>0x00001005</Token>
+      <TokenSpaceGuidCName>gEfiEdkUnixPkgTokenSpaceGuid</TokenSpaceGuidCName>
+      <DatumType>VOID*</DatumType>
+      <MaxDatumSize>10</MaxDatumSize>
+      <SkuInfo>
+        <SkuId>0</SkuId>
+        <Value>L"64!64"</Value>
+      </SkuInfo>
+    </PcdBuildData>
+  </DynamicPcdBuildDefinitions>
+  <BuildOptions>
+    <Options>
+      <Option BuildTargets="DEBUG" ToolChainFamily="MSFT" SupArchList="IA32" ToolCode="DLINK">/EXPORT:InitializeDriver=_ModuleEntryPoint /ALIGN:4096</Option>
+      <Option BuildTargets="RELEASE" ToolChainFamily="MSFT" SupArchList="IA32" ToolCode="DLINK">/ALIGN:4096</Option>
+    </Options>
+    <UserExtensions UserID="IMAGES" Identifier="1">
+      <FvName>FV_RECOVERY</FvName>
+      <InfFileName/>
+      <IncludeModules>
+        <Module ModuleGuid="52C05B14-0B98-496c-BC3B-04B50211D680" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="9B3ADA4F-AE56-4c24-8DEA-F03B7558AE50" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="1EC0F53A-FDE0-4576-8F25-7A1A410F58EB" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="f3ff9aee-8985-11db-b133-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f417814a-8985-11db-8983-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="736EB068-8C01-47c5-964B-1C57BD5D4D64" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="34C8C28F-B61C-45a2-8F2E-89E46BECC63B" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="f3f36cb0-8985-11db-b195-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f40b7864-8985-11db-af21-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f4239aa2-8985-11db-af82-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="86D70125-BAA3-4296-A62F-602BEBBB9081" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="D6A2CB7F-6A18-4e2f-B43B-9920A733700A" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="80CF7257-87AB-47f9-A3FE-D50B76D89541" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="51C9F40C-5243-4473-B265-B3C8FFAFF9FA" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="f3794b60-8985-11db-8e53-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f348f6fe-8985-11db-b4c3-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f36d49b4-8985-11db-809b-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f3552032-8985-11db-8429-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f3613084-8985-11db-8c26-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f392b762-8985-11db-be87-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="F099D67F-71AE-4c36-B2A3-DCEB0EB2B7D8" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="B601F8C4-43B7-4784-95B1-F4226CB40CEE" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="AD608272-D07F-4964-801E-7BD3B7888652" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="f42fd042-8985-11db-a7db-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="4C862FC6-0E54-4e36-8C8F-FF6F3167951F" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="CBD2E4D5-7068-4FF5-B462-9822B4AD8D60" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="42857F0A-13F2-4B21-8A23-53D3F714B840" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="F80697E9-7FD6-4665-8646-88E33EF71DFC" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="51ccf399-4fdf-4e55-a45b-e123f84d456a" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="408edcec-cf6d-477c-a5a8-b4844e3de281" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="CCCB0C28-4B24-11d5-9A5A-0090273FC14D" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="9E863906-A40F-4875-977F-5B93FF237FC6" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="53BCC14F-C24F-434C-B294-8ED2D4CC1860" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="CA515306-00CE-4032-874E-11B755FF6866" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="9B680FCE-AD6B-4F3A-B60B-F59899003443" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="6B38F7B4-AD98-40e9-9093-ACA2B5A253C4" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="13AC6DD0-73D0-11D4-B06B-00AA00BD6DE7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="96B5C032-DF4C-4b6e-8232-438DCF448D0E" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="FCD337AB-B1D3-4EF8-957C-8048606FF670" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="1FA1F39E-FEFF-4aae-BD7B-38A070A3B609" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="7BB28B99-61BB-11D5-9A5D-0090273FC14D" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="93B80004-9FB3-11d4-9A3A-0090273FC14D" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="EBf342FE-B1D3-4EF8-957C-8048606FF670" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="FE3542FE-C1D3-4EF8-657C-8048606FF670" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="CD3BAFB6-50FB-4fe8-8E4E-AB74D2C1A600" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="E49061CE-99A7-41d3-AB3A-36E5CFBAD63E" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="555F76EA-785F-40d7-9174-153C43636C68" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="69FD8E47-A161-4550-B01A-5594CEB2B2B2" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="2FB92EFA-2EE0-4bae-9EB6-7464125E1EF7" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="0167CCC4-D0F7-4f21-A3EF-9E64B7CDCE8B" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="0A66E322-3740-4cce-AD62-BD172CECCA35" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="B40612B9-A063-11d4-9A3A-0090273FC14D" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="240612B7-A063-11d4-9A3A-0090273FC14D" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="A3527D16-E6CC-42f5-BADB-BF3DE177742B" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="B40612B2-A063-11d4-9A3A-0090273FC14D" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="2D2E62CF-9ECF-43b7-8219-94E7FC713DFE" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="A5C6D68B-E78A-4426-9278-A8F0D9EB4D8F" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="2D2E62AA-9ECF-43b7-8219-94E7FC713DFE" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="A3f436EA-A127-4EF8-957C-8048606FF670" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="a46c3330-be36-4977-9d24-a7cf92eef0fe" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="A2f436EA-A127-4EF8-957C-8048606FF670" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="f38610fc-8985-11db-82d4-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f320d656-8985-11db-90e0-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f3085888-8985-11db-9c93-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f314a8cc-8985-11db-9f69-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="f33cad86-8985-11db-8040-0040d02b1835" ModuleVersion="1.0" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" PackageVersion="0.3" Arch="IA32"/>
+        <Module ModuleGuid="f2fbd108-8985-11db-b06a-0040d02b1835" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" Arch="IA32"/>
+        <Module ModuleGuid="c57ad6b7-0515-40a8-9d21-551652854e37" PackageGuid="d4266a1b-1d38-4116-93ae-60dc3e2012a6" Arch="IA32"/>
+        <Module ModuleGuid="961578FE-B6B7-44c3-AF35-6BC705CD2B1F" PackageGuid="0fd7197b-9bde-44fe-a7e4-d2177a9922e5" Arch="IA32"/>
+        <Module ModuleGuid="6987936E-ED34-44db-AE97-1FA5E4ED2116" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d" Arch="IA32"/>
+        <Module ModuleGuid="f330834e-8985-11db-a295-0040d02b1835" ModuleVersion="1.0" PackageGuid="f2805c44-8985-11db-9e98-0040d02b1835" PackageVersion="0.3" Arch="IA32"/>
+      </IncludeModules>
+    </UserExtensions>
+    <Ffs FfsKey="APPLICATION">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_APPLICATION"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="FILE">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_FREEFORM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_RAW"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="Apriori">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_FREEFORM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_RAW"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="Logo">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_FREEFORM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_RAW"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="RAWFILE">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_RAW"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_RAW"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="Legacy16">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_FREEFORM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_RAW"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="BINARY">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_FREEFORM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_RAW"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="PE32_PEIM_TE_PEIM">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEIM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_PEI_DEPEX"/>
+        <Section SectionType="EFI_SECTION_TE"/>
+        <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+        <Section SectionType="EFI_SECTION_VERSION"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="Config_Config">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_RAW"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_RAW"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="BS_DRIVER_Ifr_Bin">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_PEI_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+          <Section SectionType="EFI_SECTION_RAW"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="PEI_CORE">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEI_CORE"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_PE32"/>
+        <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+        <Section SectionType="EFI_SECTION_VERSION"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="PE32_PEIM">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEIM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_PEI_DEPEX"/>
+        <Section SectionType="EFI_SECTION_PE32"/>
+        <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+        <Section SectionType="EFI_SECTION_VERSION"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="PE32_PEIM_Relocatable">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEIM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_PEI_DEPEX"/>
+        <Section SectionType="EFI_SECTION_PE32"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="PE32_PEIM_CompressPEIM">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_PEIM"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_PEI_DEPEX"/>
+        <Sections EncapsulationType="Compress">
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="COMBINED_PEIM_DRIVER">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_PEI_DEPEX"/>
+        <!--Section SectionType="EFI_SECTION_UNKNOW"/-->
+        <Section SectionType="EFI_SECTION_PE32"/>
+        <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+        <Section SectionType="EFI_SECTION_VERSION"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="DXE_CORE">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DXE_CORE"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Section SectionType="EFI_SECTION_PE32"/>
+        <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+        <Section SectionType="EFI_SECTION_VERSION"/>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="BS_DRIVER">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_DXE_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="RT_DRIVER">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_DXE_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="SAL_RT_DRIVER">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_DXE_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="BS_DRIVER_EFI">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_DXE_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="RT_DRIVER_EFI">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_DXE_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="APPLICATION_EFI">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_DRIVER"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections EncapsulationType="Compress">
+        <Sections EncapsulationType="Guid-Defined">
+          <Section SectionType="EFI_SECTION_DXE_DEPEX"/>
+          <Section SectionType="EFI_SECTION_PE32"/>
+          <Section SectionType="EFI_SECTION_USER_INTERFACE"/>
+          <Section SectionType="EFI_SECTION_VERSION"/>
+        </Sections>
+      </Sections>
+    </Ffs>
+    <Ffs FfsKey="Microcode">
+      <Attribute Name="FFS_FILETYPE" Value="EFI_FV_FILETYPE_RAW"/>
+      <Attribute Name="FFS_ATTRIB_CHECKSUM" Value="TRUE"/>
+      <Sections>
+        <Section SectionType="EFI_SECTION_RAW"/>
+      </Sections>
+    </Ffs>
+  </BuildOptions>
+  <UserExtensions UserID="TianoCore" Identifier="1">
+    <concat destfile="${FV_DIR}/FV_RECOVERY.fd" binary="true" force="no">
+      <fileset dir="${FV_DIR}" includes="*.fv"/>
+    </concat>
+    <!--Generate Run.cmd file. This file will call SecMain.exe to start shell.-->
+    <pathconvert property="SecMainPath" targetos="unix">
+      <path path="${TARGET_DIR}/IA32"/>
+    </pathconvert>
+    <echo file="${BUILD_DIR}/run.cmd">#
+      # 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.
+      # 
+      
+      cd ${SecMainPath}
+      ./SecMain.exe</echo>
+  </UserExtensions>
+</PlatformSurfaceArea>