]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DuetPkg: Remove DuetPkg
authorShenglei Zhang <shenglei.zhang@intel.com>
Fri, 30 Nov 2018 02:30:38 +0000 (10:30 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 6 Dec 2018 06:31:25 +0000 (14:31 +0800)
DuetPkg depends on Legacy BIOS to provide a UEFI environment.
It was invented in the era when UEFI environment is hard to find.
Since now UEFI is very popular in PC area, we could stop the
official support of this package and remove it from the master.
https://bugzilla.tianocore.org/show_bug.cgi?id=1322

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
172 files changed:
DuetPkg/AcpiResetDxe/Reset.c [deleted file]
DuetPkg/AcpiResetDxe/Reset.inf [deleted file]
DuetPkg/BiosVideoThunkDxe/BiosVideo.c [deleted file]
DuetPkg/BiosVideoThunkDxe/BiosVideo.h [deleted file]
DuetPkg/BiosVideoThunkDxe/BiosVideo.inf [deleted file]
DuetPkg/BiosVideoThunkDxe/ComponentName.c [deleted file]
DuetPkg/BiosVideoThunkDxe/LegacyBiosThunk.c [deleted file]
DuetPkg/BiosVideoThunkDxe/VesaBiosExtensions.h [deleted file]
DuetPkg/BootSector/BootSector.inf [deleted file]
DuetPkg/BootSector/FILE.LST [deleted file]
DuetPkg/BootSector/GNUmakefile [deleted file]
DuetPkg/BootSector/Gpt.S [deleted file]
DuetPkg/BootSector/Gpt.asm [deleted file]
DuetPkg/BootSector/Makefile [deleted file]
DuetPkg/BootSector/Mbr.S [deleted file]
DuetPkg/BootSector/Mbr.asm [deleted file]
DuetPkg/BootSector/bin/Gpt.com [deleted file]
DuetPkg/BootSector/bin/Mbr.com [deleted file]
DuetPkg/BootSector/bin/Readme.txt [deleted file]
DuetPkg/BootSector/bin/St16_64.com [deleted file]
DuetPkg/BootSector/bin/St32_64.com [deleted file]
DuetPkg/BootSector/bin/Start.com [deleted file]
DuetPkg/BootSector/bin/Start16.com [deleted file]
DuetPkg/BootSector/bin/Start32.com [deleted file]
DuetPkg/BootSector/bin/Start64.com [deleted file]
DuetPkg/BootSector/bin/bootsect.com [deleted file]
DuetPkg/BootSector/bin/bs16.com [deleted file]
DuetPkg/BootSector/bin/bs32.com [deleted file]
DuetPkg/BootSector/bin/efi32.com [deleted file]
DuetPkg/BootSector/bin/efi32.com2 [deleted file]
DuetPkg/BootSector/bin/efi64.com [deleted file]
DuetPkg/BootSector/bin/efi64.com2 [deleted file]
DuetPkg/BootSector/bootsect.S [deleted file]
DuetPkg/BootSector/bootsect.asm [deleted file]
DuetPkg/BootSector/bs16.S [deleted file]
DuetPkg/BootSector/bs16.asm [deleted file]
DuetPkg/BootSector/bs32.S [deleted file]
DuetPkg/BootSector/bs32.asm [deleted file]
DuetPkg/BootSector/efi32.S [deleted file]
DuetPkg/BootSector/efi32.asm [deleted file]
DuetPkg/BootSector/efi64.S [deleted file]
DuetPkg/BootSector/efi64.asm [deleted file]
DuetPkg/BootSector/st16_64.S [deleted file]
DuetPkg/BootSector/st16_64.asm [deleted file]
DuetPkg/BootSector/st32_64.S [deleted file]
DuetPkg/BootSector/st32_64.asm [deleted file]
DuetPkg/BootSector/start.S [deleted file]
DuetPkg/BootSector/start.asm [deleted file]
DuetPkg/BootSector/start16.S [deleted file]
DuetPkg/BootSector/start16.asm [deleted file]
DuetPkg/BootSector/start32.S [deleted file]
DuetPkg/BootSector/start32.asm [deleted file]
DuetPkg/BootSector/start64.S [deleted file]
DuetPkg/BootSector/start64.asm [deleted file]
DuetPkg/CreateBootDisk.bat [deleted file]
DuetPkg/CreateBootDisk.sh [deleted file]
DuetPkg/DuetPkg.dec [deleted file]
DuetPkg/DuetPkg.fdf [deleted file]
DuetPkg/DuetPkgIa32.dsc [deleted file]
DuetPkg/DuetPkgX64.dsc [deleted file]
DuetPkg/DxeIpl/Debug.c [deleted file]
DuetPkg/DxeIpl/Debug.h [deleted file]
DuetPkg/DxeIpl/DxeInit.c [deleted file]
DuetPkg/DxeIpl/DxeIpl.h [deleted file]
DuetPkg/DxeIpl/DxeIpl.inf [deleted file]
DuetPkg/DxeIpl/HobGeneration.c [deleted file]
DuetPkg/DxeIpl/HobGeneration.h [deleted file]
DuetPkg/DxeIpl/Ia32/EnterDxeCore.c [deleted file]
DuetPkg/DxeIpl/Ia32/Paging.c [deleted file]
DuetPkg/DxeIpl/Ia32/VirtualMemory.h [deleted file]
DuetPkg/DxeIpl/LegacyTable.c [deleted file]
DuetPkg/DxeIpl/LegacyTable.h [deleted file]
DuetPkg/DxeIpl/PpisNeededByDxeCore.c [deleted file]
DuetPkg/DxeIpl/PpisNeededByDxeCore.h [deleted file]
DuetPkg/DxeIpl/SerialStatusCode.c [deleted file]
DuetPkg/DxeIpl/SerialStatusCode.h [deleted file]
DuetPkg/DxeIpl/X64/EnterDxeCore.c [deleted file]
DuetPkg/DxeIpl/X64/Paging.c [deleted file]
DuetPkg/DxeIpl/X64/VirtualMemory.h [deleted file]
DuetPkg/EfiLdr/Debug.c [deleted file]
DuetPkg/EfiLdr/Debug.h [deleted file]
DuetPkg/EfiLdr/EfiLdr.h [deleted file]
DuetPkg/EfiLdr/EfiLdr.inf [deleted file]
DuetPkg/EfiLdr/EfiLdrHandoff.h [deleted file]
DuetPkg/EfiLdr/EfiLoader.c [deleted file]
DuetPkg/EfiLdr/LzmaDecompress.h [deleted file]
DuetPkg/EfiLdr/PeLoader.c [deleted file]
DuetPkg/EfiLdr/PeLoader.h [deleted file]
DuetPkg/EfiLdr/Support.c [deleted file]
DuetPkg/EfiLdr/Support.h [deleted file]
DuetPkg/EfiLdr/TianoDecompress.c [deleted file]
DuetPkg/EfiLdr/TianoDecompress.h [deleted file]
DuetPkg/EfiLdr/efildr.c [deleted file]
DuetPkg/FSVariable/FSVariable.c [deleted file]
DuetPkg/FSVariable/FSVariable.h [deleted file]
DuetPkg/FSVariable/FSVariable.inf [deleted file]
DuetPkg/FSVariable/FileStorage.c [deleted file]
DuetPkg/FSVariable/MemStorage.c [deleted file]
DuetPkg/FSVariable/VariableStorage.h [deleted file]
DuetPkg/FvbRuntimeService/DUETFwh.inf [deleted file]
DuetPkg/FvbRuntimeService/FWBlockService.c [deleted file]
DuetPkg/FvbRuntimeService/FileIo.c [deleted file]
DuetPkg/FvbRuntimeService/FileIo.h [deleted file]
DuetPkg/FvbRuntimeService/FvbInfo.c [deleted file]
DuetPkg/FvbRuntimeService/FwBlockService.h [deleted file]
DuetPkg/Include/EfiFlashMap.h [deleted file]
DuetPkg/Include/EfiLdrHandoff.h [deleted file]
DuetPkg/Include/FlashLayout.h [deleted file]
DuetPkg/Include/Guid/AcpiDescription.h [deleted file]
DuetPkg/Include/Guid/ConsoleOutConfig.h [deleted file]
DuetPkg/Include/Guid/DxeCoreFileName.h [deleted file]
DuetPkg/Include/Guid/FlashMapHob.h [deleted file]
DuetPkg/Include/Guid/LdrMemoryDescriptor.h [deleted file]
DuetPkg/Include/Guid/PciExpressBaseAddress.h [deleted file]
DuetPkg/Include/Guid/PciOptionRomTable.h [deleted file]
DuetPkg/LegacyMetronome/Metronome.c [deleted file]
DuetPkg/LegacyMetronome/Metronome.h [deleted file]
DuetPkg/LegacyMetronome/Metronome.inf [deleted file]
DuetPkg/Library/DuetBdsLib/BdsPlatform.c [deleted file]
DuetPkg/Library/DuetBdsLib/BdsPlatform.h [deleted file]
DuetPkg/Library/DuetBdsLib/PlatformBds.inf [deleted file]
DuetPkg/Library/DuetBdsLib/PlatformData.c [deleted file]
DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf [deleted file]
DuetPkg/Library/DuetTimerLib/X86TimerLib.c [deleted file]
DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeCoreReportStatusCodeLibFromHob.inf [deleted file]
DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeSupport.c [deleted file]
DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/ReportStatusCodeLib.c [deleted file]
DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/ReportStatusCodeLibInternal.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/ComponentName.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciBus.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciBus.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciCommand.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciCommand.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciDeviceSupport.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciDeviceSupport.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciDriverOverride.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciDriverOverride.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciEnumerator.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciEnumerator.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciIo.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciIo.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciOptionRomSupport.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciOptionRomSupport.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.h [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciRomTable.c [deleted file]
DuetPkg/PciBusNoEnumerationDxe/PciRomTable.h [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/DeviceIo.c [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/DeviceIo.h [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridge.c [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridge.h [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeDevicePath.c [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeIo.c [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf [deleted file]
DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c [deleted file]
DuetPkg/PostBuild.bat [deleted file]
DuetPkg/PostBuild.sh [deleted file]
DuetPkg/ReadMe.txt [deleted file]
DuetPkg/SataControllerDxe/ComponentName.c [deleted file]
DuetPkg/SataControllerDxe/SataController.c [deleted file]
DuetPkg/SataControllerDxe/SataController.h [deleted file]
DuetPkg/SataControllerDxe/SataControllerDxe.inf [deleted file]
DuetPkg/SmbiosGenDxe/SmbiosGen.c [deleted file]
DuetPkg/SmbiosGenDxe/SmbiosGen.h [deleted file]
DuetPkg/SmbiosGenDxe/SmbiosGen.inf [deleted file]
DuetPkg/SmbiosGenDxe/SmbiosGenStrings.uni [deleted file]
DuetPkg/build32.sh [deleted file]
DuetPkg/build64.sh [deleted file]

diff --git a/DuetPkg/AcpiResetDxe/Reset.c b/DuetPkg/AcpiResetDxe/Reset.c
deleted file mode 100644 (file)
index 425109a..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/*++ @file\r
-  Reset Architectural Protocol implementation.\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/Reset.h>\r
-\r
-#include <Guid/AcpiDescription.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/PciLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-///\r
-/// Handle for the Reset Architectural Protocol\r
-///\r
-EFI_HANDLE            mResetHandle = NULL;\r
-\r
-///\r
-/// Copy of ACPI Description HOB in runtime memory\r
-///\r
-EFI_ACPI_DESCRIPTION  mAcpiDescription;\r
-\r
-/**\r
-  Reset the system.\r
-\r
-  @param[in] ResetType       Warm or cold\r
-  @param[in] ResetStatus     Possible cause of reset\r
-  @param[in] DataSize        Size of ResetData in bytes\r
-  @param[in] ResetData       Optional Unicode string\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-EfiAcpiResetSystem (\r
-  IN EFI_RESET_TYPE   ResetType,\r
-  IN EFI_STATUS       ResetStatus,\r
-  IN UINTN            DataSize,\r
-  IN VOID             *ResetData OPTIONAL\r
-  )\r
-{\r
-  UINT8   Dev;\r
-  UINT8   Func;\r
-  UINT8   Register;\r
-  \r
-  switch (ResetType) {\r
-  case EfiResetShutdown:\r
-    //\r
-    // 1. Write SLP_TYPa\r
-    //\r
-    if ((mAcpiDescription.PM1a_CNT_BLK.Address != 0) && (mAcpiDescription.SLP_TYPa != 0)) {\r
-      switch (mAcpiDescription.PM1a_CNT_BLK.AddressSpaceId) {\r
-      case EFI_ACPI_3_0_SYSTEM_IO:\r
-        IoAndThenOr16 ((UINTN)mAcpiDescription.PM1a_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPa << 10)));\r
-        break;\r
-      case EFI_ACPI_3_0_SYSTEM_MEMORY:\r
-        MmioAndThenOr16 ((UINTN)mAcpiDescription.PM1a_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPa << 10)));\r
-        break;\r
-      }\r
-    }\r
-\r
-    //\r
-    // 2. Write SLP_TYPb\r
-    //\r
-    if ((mAcpiDescription.PM1b_CNT_BLK.Address != 0) && (mAcpiDescription.SLP_TYPb != 0)) {\r
-      switch (mAcpiDescription.PM1b_CNT_BLK.AddressSpaceId) {\r
-      case EFI_ACPI_3_0_SYSTEM_IO:\r
-        IoAndThenOr16 ((UINTN)mAcpiDescription.PM1b_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPb << 10)));\r
-        break;\r
-      case EFI_ACPI_3_0_SYSTEM_MEMORY:\r
-        MmioAndThenOr16 ((UINTN)mAcpiDescription.PM1b_CNT_BLK.Address, 0xc3ff, (UINT16)(0x2000 | (mAcpiDescription.SLP_TYPb << 10)));\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // If Shutdown fails, then let fall through to reset \r
-    //\r
-  case EfiResetWarm:\r
-  case EfiResetCold:\r
-    if ((mAcpiDescription.RESET_REG.Address != 0) &&\r
-        ((mAcpiDescription.RESET_REG.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_IO) ||\r
-         (mAcpiDescription.RESET_REG.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_MEMORY) ||\r
-         (mAcpiDescription.RESET_REG.AddressSpaceId == EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE))) {\r
-      //\r
-      // Use ACPI System Reset\r
-      //\r
-      switch (mAcpiDescription.RESET_REG.AddressSpaceId) {\r
-      case EFI_ACPI_3_0_SYSTEM_IO:\r
-        //\r
-        // Send reset request through I/O port register\r
-        //\r
-        IoWrite8 ((UINTN)mAcpiDescription.RESET_REG.Address, mAcpiDescription.RESET_VALUE);\r
-        //\r
-        // Halt \r
-        //\r
-        CpuDeadLoop ();\r
-      case EFI_ACPI_3_0_SYSTEM_MEMORY:\r
-        //\r
-        // Send reset request through MMIO register\r
-        //\r
-        MmioWrite8 ((UINTN)mAcpiDescription.RESET_REG.Address, mAcpiDescription.RESET_VALUE);\r
-        //\r
-        // Halt \r
-        //\r
-        CpuDeadLoop ();\r
-      case EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE:\r
-        //\r
-        // Send reset request through PCI register\r
-        //\r
-        Register = (UINT8)mAcpiDescription.RESET_REG.Address;\r
-        Func     = (UINT8) (RShiftU64 (mAcpiDescription.RESET_REG.Address, 16) & 0x7);\r
-        Dev      = (UINT8) (RShiftU64 (mAcpiDescription.RESET_REG.Address, 32) & 0x1F);\r
-        PciWrite8 (PCI_LIB_ADDRESS (0, Dev, Func, Register), mAcpiDescription.RESET_VALUE);\r
-        //\r
-        // Halt \r
-        //\r
-        CpuDeadLoop ();\r
-      }\r
-    }\r
-\r
-    //\r
-    // If system comes here, means ACPI reset is not supported, so do Legacy System Reset, assume 8042 available\r
-    //\r
-    IoWrite8 (0x64, 0xfe);\r
-    CpuDeadLoop ();\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  //\r
-  // Given we should have reset getting here would be bad\r
-  //\r
-  ASSERT (FALSE);\r
-  CpuDeadLoop();\r
-}\r
-\r
-/**\r
-  Initialize the state information for the Reset Architectural Protocol.\r
-\r
-  @param[in] ImageHandle  Image handle of the loaded driver\r
-  @param[in] SystemTable  Pointer to the System Table\r
-\r
-  @retval EFI_SUCCESS           Thread can be successfully created\r
-  @retval EFI_UNSUPPORTED       Cannot find the info to reset system\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeReset (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  EFI_HOB_GUID_TYPE  *HobAcpiDescription;\r
-\r
-  //\r
-  // Make sure the Reset Architectural Protocol is not already installed in the system\r
-  //\r
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);\r
-\r
-  //\r
-  // Get ACPI Description HOB\r
-  //\r
-  HobAcpiDescription = GetFirstGuidHob (&gEfiAcpiDescriptionGuid);\r
-  if (HobAcpiDescription == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Copy it to Runtime Memory\r
-  //\r
-  ASSERT (sizeof (EFI_ACPI_DESCRIPTION) == GET_GUID_HOB_DATA_SIZE (HobAcpiDescription));\r
-  CopyMem (&mAcpiDescription, GET_GUID_HOB_DATA (HobAcpiDescription), sizeof (EFI_ACPI_DESCRIPTION));\r
-\r
-  DEBUG ((DEBUG_INFO, "ACPI Reset Base  - %lx\n", mAcpiDescription.RESET_REG.Address));\r
-  DEBUG ((DEBUG_INFO, "ACPI Reset Value - %02x\n", (UINTN)mAcpiDescription.RESET_VALUE));\r
-  DEBUG ((DEBUG_INFO, "IAPC support     - %x\n", (UINTN)(mAcpiDescription.IAPC_BOOT_ARCH)));\r
-  \r
-  //\r
-  // Hook the runtime service table\r
-  //\r
-  SystemTable->RuntimeServices->ResetSystem = EfiAcpiResetSystem;\r
-\r
-  //\r
-  // Install the Reset Architectural Protocol onto a new handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mResetHandle,\r
-                  &gEfiResetArchProtocolGuid, NULL,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/DuetPkg/AcpiResetDxe/Reset.inf b/DuetPkg/AcpiResetDxe/Reset.inf
deleted file mode 100644 (file)
index 591bdcf..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-## @file\r
-#  Component description file for AcpiResetDxe module.\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# 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
-##\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = AcpiReset\r
-  FILE_GUID                      = 928EF6D4-72BC-4686-B57B-1EEB6ABD4F93\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeReset\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  IoLib\r
-  PciLib\r
-  HobLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-\r
-[Sources]\r
-  Reset.c\r
-\r
-[Protocols]\r
-  gEfiResetArchProtocolGuid\r
-\r
-[Guids]\r
-  gEfiAcpiDescriptionGuid\r
-\r
-[Depex]\r
-  TRUE\r
diff --git a/DuetPkg/BiosVideoThunkDxe/BiosVideo.c b/DuetPkg/BiosVideoThunkDxe/BiosVideo.c
deleted file mode 100644 (file)
index dc367e9..0000000
+++ /dev/null
@@ -1,2822 +0,0 @@
-/** @file\r
-\r
-  BiosVideo driver produce EFI_GRAPHIC_OUTPUT_PROTOCOL via LegacyBios Video rom.\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#include "BiosVideo.h"\r
-\r
-//\r
-// EFI Driver Binding Protocol Instance\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding = {\r
-  BiosVideoDriverBindingSupported,\r
-  BiosVideoDriverBindingStart,\r
-  BiosVideoDriverBindingStop,\r
-  0x3,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-//\r
-// Global lookup tables for VGA graphics modes\r
-//\r
-UINT8 mVgaLeftMaskTable[]   = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };\r
-\r
-UINT8 mVgaRightMaskTable[]  = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };\r
-\r
-UINT8 mVgaBitMaskTable[]    = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };\r
-\r
-EFI_LEGACY_8259_PROTOCOL   *mLegacy8259 = NULL;\r
-THUNK_CONTEXT              mThunkContext;\r
-\r
-EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mVgaColorToGraphicsOutputColor[] = {\r
-  //\r
-  // {B, G, R, reserved}\r
-  //  \r
-  {0x00, 0x00, 0x00, 0x00}, // BLACK\r
-  {0x98, 0x00, 0x00, 0x00}, // LIGHTBLUE\r
-  {0x00, 0x98, 0x00, 0x00}, // LIGHGREEN\r
-  {0x98, 0x98, 0x00, 0x00}, // LIGHCYAN\r
-  {0x00, 0x00, 0x98, 0x00}, // LIGHRED\r
-  {0x98, 0x00, 0x98, 0x00}, // MAGENTA\r
-  {0x00, 0x98, 0x98, 0x00}, // BROWN\r
-  {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY\r
-  {0x10, 0x10, 0x10, 0x00},\r
-  {0xff, 0x10, 0x10, 0x00}, // BLUE\r
-  {0x10, 0xff, 0x10, 0x00}, // LIME\r
-  {0xff, 0xff, 0x10, 0x00}, // CYAN\r
-  {0x10, 0x10, 0xff, 0x00}, // RED\r
-  {0xf0, 0x10, 0xff, 0x00}, // FUCHSIA\r
-  {0x10, 0xff, 0xff, 0x00}, // YELLOW\r
-  {0xff, 0xff, 0xff, 0x00}  // WHITE  \r
-};\r
-\r
-//\r
-// Standard timing defined by VESA EDID\r
-//\r
-VESA_BIOS_EXTENSIONS_EDID_TIMING mEstablishedEdidTiming[] = {\r
-  //\r
-  // Established Timing I\r
-  //\r
-  {800, 600, 60},\r
-  {800, 600, 56},\r
-  {640, 480, 75},\r
-  {640, 480, 72},\r
-  {640, 480, 67},\r
-  {640, 480, 60},\r
-  {720, 400, 88},\r
-  {720, 400, 70},\r
-  //\r
-  // Established Timing II\r
-  //\r
-  {1280, 1024, 75},\r
-  {1024,  768, 75},\r
-  {1024,  768, 70},\r
-  {1024,  768, 60},\r
-  {1024,  768, 87},\r
-  {832,   624, 75},\r
-  {800,   600, 75},\r
-  {800,   600, 72},\r
-  //\r
-  // Established Timing III\r
-  //\r
-  {1152, 870, 75}\r
-};\r
-\r
-/**\r
-  Install child handle for a detect BiosVideo device and install related protocol\r
-  into this handle, such as EFI_GRAPHIC_OUTPUT_PROTOCOL.\r
-\r
-  @param This                Instance pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param ParentHandle        Parent's controller handle\r
-  @param ParentPciIo         Parent's EFI_PCI_IO_PROTOCOL instance pointer\r
-  @param ParentLegacy8259    Parent's EFI_LEGACY_8259_PROTOCOL instance pointer \r
-  @param ParentDevicePath    Parent's BIOS Video controller device path\r
-  @param RemainingDevicePath Remaining device path node instance for children.\r
-\r
-  @return whether success to create children handle for a VGA device and install \r
-          related protocol into new children handle.\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleInstall (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     ParentHandle,\r
-  IN  EFI_PCI_IO_PROTOCOL            *ParentPciIo,\r
-  IN  EFI_LEGACY_8259_PROTOCOL       *ParentLegacy8259,\r
-  IN  THUNK_CONTEXT                  *ThunkContext,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *ParentDevicePath,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  Deregister an video child handle and free resources\r
-\r
-  @param This            Protocol instance pointer.\r
-  @param Controller      Video controller handle\r
-  @param Handle          Video child handle\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-\r
-EFI_STATUS\r
-BiosVideoChildHandleUninstall (\r
-  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  EFI_HANDLE                     Controller,\r
-  EFI_HANDLE                     Handle\r
-  )\r
-;\r
-\r
-/**\r
-  Collect the resource from destroyed bios video device.\r
-\r
-  @param BiosVideoPrivate   Video child device private data structure\r
-**/\r
-\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
-  BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-;\r
-\r
-/**\r
-  Driver Entry Point.\r
-\r
-  @param ImageHandle      Handle of driver image.\r
-  @param SystemTable      Pointer to system table.\r
-\r
-  @return EFI_STATUS\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-            ImageHandle,\r
-            SystemTable,\r
-            &gBiosVideoDriverBinding,\r
-            ImageHandle,\r
-            &gBiosVideoComponentName,\r
-            &gBiosVideoComponentName2\r
-            );\r
-            \r
-  return Status;\r
-}\r
-\r
-/**\r
-  Test to see if Bios Video could be supported on the Controller.\r
-\r
-  @param This                  Pointer to driver binding protocol\r
-  @param Controller            Controller handle to connect\r
-  @param RemainingDevicePath   A pointer to the remaining portion of a device path\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device.\r
-  @retval other               This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_LEGACY_8259_PROTOCOL  *LegacyBios;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-\r
-  //\r
-  // See if the Legacy 8259 Protocol is available\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **) &LegacyBios);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (!BiosVideoIsVga (PciIo)) {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-\r
-  gBS->CloseProtocol (\r
-         Controller,\r
-         &gEfiPciIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Install Graphics Output Protocol onto VGA device handles\r
-\r
-  @param This                   Pointer to driver binding protocol\r
-  @param Controller             Controller handle to connect\r
-  @param RemainingDevicePath    A pointer to the remaining portion of a device path\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
-  EFI_PCI_IO_PROTOCOL             *PciIo;\r
-\r
-  PciIo = NULL;\r
-  //\r
-  // Prepare for status code\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Establish legacy environment for thunk call for all children handle.\r
-  //\r
-  if (mLegacy8259 == NULL) {\r
-    Status = gBS->LocateProtocol (&gEfiLegacy8259ProtocolGuid, NULL, (VOID **) &mLegacy8259);\r
-    if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-    }\r
-    \r
-    InitializeBiosIntCaller(&mThunkContext);\r
-    InitializeInterruptRedirection(mLegacy8259);\r
-  }\r
-\r
-  //\r
-  // Create child handle and install GraphicsOutputProtocol on it\r
-  //\r
-  Status = BiosVideoChildHandleInstall (\r
-             This,\r
-             Controller,\r
-             PciIo,\r
-             mLegacy8259,\r
-             &mThunkContext,\r
-             ParentDevicePath,\r
-             RemainingDevicePath\r
-             );\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (PciIo != NULL) {\r
-      //\r
-      // Release PCI I/O Protocols on the controller handle.\r
-      //\r
-      gBS->CloseProtocol (\r
-             Controller,\r
-             &gEfiPciIoProtocolGuid,\r
-             This->DriverBindingHandle,\r
-             Controller\r
-             );\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on Controller \r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  Controller        Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed Controller.\r
-  @retval other             This driver was not removed from this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Controller,\r
-  IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  BOOLEAN                      AllChildrenStopped;\r
-  UINTN                        Index;\r
-\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close PCI I/O protocol on the controller handle\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  AllChildrenStopped = TRUE;\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-    Status = BiosVideoChildHandleUninstall (This, Controller, ChildHandleBuffer[Index]);\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
-/**\r
-  Install child handle for a detect BiosVideo device and install related protocol\r
-  into this handle, such as EFI_GRAPHIC_OUTPUT_PROTOCOL.\r
-\r
-  @param This                Instance pointer of EFI_DRIVER_BINDING_PROTOCOL\r
-  @param ParentHandle        Parent's controller handle\r
-  @param ParentPciIo         Parent's EFI_PCI_IO_PROTOCOL instance pointer\r
-  @param ParentLegacy8259    Parent's EFI_LEGACY_8259_PROTOCOL instance pointer \r
-  @param ParentDevicePath    Parent's BIOS Video controller device path\r
-  @param RemainingDevicePath Remaining device path node instance for children.\r
-\r
-  @return whether success to create children handle for a VGA device and install \r
-          related protocol into new children handle.\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleInstall (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     ParentHandle,\r
-  IN  EFI_PCI_IO_PROTOCOL            *ParentPciIo,\r
-  IN  EFI_LEGACY_8259_PROTOCOL       *ParentLegacy8259,\r
-  IN  THUNK_CONTEXT                  *ParentThunkContext,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *ParentDevicePath,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS               Status;\r
-  BIOS_VIDEO_DEV           *BiosVideoPrivate;\r
-  ACPI_ADR_DEVICE_PATH     AcpiDeviceNode;\r
-\r
-  //\r
-  // Allocate the private device structure for video device\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (BIOS_VIDEO_DEV),\r
-                  (VOID**) &BiosVideoPrivate\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  ZeroMem (BiosVideoPrivate, sizeof (BIOS_VIDEO_DEV));\r
-\r
-  if (!BiosVideoIsVga (ParentPciIo)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-  \r
-  BiosVideoPrivate->VgaCompatible = TRUE;\r
-\r
-  //\r
-  // Initialize the child private structure\r
-  //\r
-  BiosVideoPrivate->Signature = BIOS_VIDEO_DEV_SIGNATURE;\r
-  BiosVideoPrivate->Handle    = NULL;\r
-\r
-  //\r
-  // Fill in Graphics Output specific mode structures\r
-  //\r
-  BiosVideoPrivate->HardwareNeedsStarting = TRUE;\r
-  BiosVideoPrivate->ModeData              = NULL;\r
-  BiosVideoPrivate->LineBuffer            = NULL;\r
-  BiosVideoPrivate->VgaFrameBuffer        = NULL;\r
-  BiosVideoPrivate->VbeFrameBuffer        = NULL;\r
-\r
-  //\r
-  // Fill in the VGA Mini Port Protocol fields\r
-  //\r
-  BiosVideoPrivate->VgaMiniPort.SetMode                   = BiosVideoVgaMiniPortSetMode;\r
-  BiosVideoPrivate->VgaMiniPort.VgaMemoryOffset           = 0xb8000;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcAddressRegisterOffset = 0x3d4;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcDataRegisterOffset    = 0x3d5;\r
-  BiosVideoPrivate->VgaMiniPort.VgaMemoryBar              = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcAddressRegisterBar    = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-  BiosVideoPrivate->VgaMiniPort.CrtcDataRegisterBar       = EFI_PCI_IO_PASS_THROUGH_BAR;\r
-\r
-  //\r
-  // Assume that Graphics Output Protocol will be produced until proven otherwise\r
-  //\r
-  BiosVideoPrivate->ProduceGraphicsOutput = TRUE;\r
-\r
-  //\r
-  // Child handle need to consume the Legacy Bios protocol\r
-  //\r
-  BiosVideoPrivate->Legacy8259   = ParentLegacy8259;\r
-  BiosVideoPrivate->ThunkContext = ParentThunkContext;\r
-  \r
-  //\r
-  // When check for VBE, PCI I/O protocol is needed, so use parent's protocol interface temporally\r
-  //\r
-  BiosVideoPrivate->PciIo = ParentPciIo;\r
-\r
-  //\r
-  // Check for VESA BIOS Extensions for modes that are compatible with Graphics Output\r
-  //\r
-  Status = BiosVideoCheckForVbe (BiosVideoPrivate);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // The VESA BIOS Extensions are not compatible with Graphics Output, so check for support\r
-    // for the standard 640x480 16 color VGA mode\r
-    //\r
-    if (BiosVideoPrivate->VgaCompatible) {\r
-      Status = BiosVideoCheckForVga (BiosVideoPrivate);\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Neither VBE nor the standard 640x480 16 color VGA mode are supported, so do\r
-      // not produce the Graphics Output protocol.  Instead, produce the VGA MiniPort Protocol.\r
-      //\r
-      BiosVideoPrivate->ProduceGraphicsOutput = FALSE;\r
-\r
-      //\r
-      // INT services are available, so on the 80x25 and 80x50 text mode are supported\r
-      //\r
-      BiosVideoPrivate->VgaMiniPort.MaxMode = 2;\r
-    }\r
-  }\r
-\r
-  if (BiosVideoPrivate->ProduceGraphicsOutput) {\r
-    if (RemainingDevicePath == NULL) {\r
-      ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));\r
-      AcpiDeviceNode.Header.Type    = ACPI_DEVICE_PATH;\r
-      AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;\r
-      AcpiDeviceNode.ADR            = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);\r
-      SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
-\r
-      BiosVideoPrivate->DevicePath = AppendDevicePathNode (\r
-                                       ParentDevicePath, \r
-                                       (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode\r
-                                       );\r
-    } else {\r
-      BiosVideoPrivate->DevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);\r
-    }\r
-\r
-    //\r
-    // Creat child handle and install Graphics Output Protocol,EDID Discovered/Active Protocol\r
-    //\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &BiosVideoPrivate->Handle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    BiosVideoPrivate->DevicePath,\r
-                    &gEfiGraphicsOutputProtocolGuid,\r
-                    &BiosVideoPrivate->GraphicsOutput,\r
-                    &gEfiEdidDiscoveredProtocolGuid,\r
-                    &BiosVideoPrivate->EdidDiscovered,\r
-                    &gEfiEdidActiveProtocolGuid,\r
-                    &BiosVideoPrivate->EdidActive,\r
-                    NULL\r
-                    );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Open the Parent Handle for the child\r
-      //\r
-      Status = gBS->OpenProtocol (\r
-                      ParentHandle,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **) &BiosVideoPrivate->PciIo,\r
-                      This->DriverBindingHandle,\r
-                      BiosVideoPrivate->Handle,\r
-                      EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-    }\r
-  } else {\r
-    //\r
-    // Install VGA Mini Port Protocol\r
-    //\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &BiosVideoPrivate->Handle,\r
-                    &gEfiVgaMiniPortProtocolGuid,\r
-                    &BiosVideoPrivate->VgaMiniPort,\r
-                    NULL\r
-                    );\r
-  }\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Free private data structure\r
-    //\r
-    BiosVideoDeviceReleaseResource (BiosVideoPrivate);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Deregister an video child handle and free resources\r
-\r
-  @param This            Protocol instance pointer.\r
-  @param Controller      Video controller handle\r
-  @param Handle          Video child handle\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-BiosVideoChildHandleUninstall (\r
-  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  EFI_HANDLE                     Controller,\r
-  EFI_HANDLE                     Handle\r
-  )\r
-{\r
-  EFI_STATUS                   Status;\r
-  IA32_REGISTER_SET        Regs;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
-  EFI_VGA_MINI_PORT_PROTOCOL   *VgaMiniPort;\r
-  BIOS_VIDEO_DEV               *BiosVideoPrivate;\r
-  EFI_PCI_IO_PROTOCOL          *PciIo;\r
-\r
-  BiosVideoPrivate = NULL;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **) &GraphicsOutput,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiVgaMiniPortProtocolGuid,\r
-                  (VOID **) &VgaMiniPort,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS (VgaMiniPort);\r
-  }\r
-\r
-  if (BiosVideoPrivate == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Close PCI I/O protocol that opened by child handle\r
-  //\r
-  Status = gBS->CloseProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  This->DriverBindingHandle,\r
-                  Handle\r
-                  );\r
-\r
-  //\r
-  // Uninstall protocols on child handle\r
-  //\r
-  if (BiosVideoPrivate->ProduceGraphicsOutput) {\r
-    Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                    BiosVideoPrivate->Handle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    BiosVideoPrivate->DevicePath,\r
-                    &gEfiGraphicsOutputProtocolGuid,\r
-                    &BiosVideoPrivate->GraphicsOutput,\r
-                    &gEfiEdidDiscoveredProtocolGuid,\r
-                    &BiosVideoPrivate->EdidDiscovered,\r
-                    &gEfiEdidActiveProtocolGuid,\r
-                    &BiosVideoPrivate->EdidActive,\r
-                    NULL\r
-                    );\r
-  } else {\r
-    Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                    BiosVideoPrivate->Handle,\r
-                    &gEfiVgaMiniPortProtocolGuid,\r
-                    &BiosVideoPrivate->VgaMiniPort,\r
-                    NULL\r
-                    );\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->OpenProtocol (\r
-           Controller,\r
-           &gEfiPciIoProtocolGuid,\r
-           (VOID **) &PciIo,\r
-           This->DriverBindingHandle,\r
-           Handle,\r
-           EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-           );\r
-    return Status;\r
-  }\r
-\r
-  gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-\r
-  //\r
-  // Set the 80x25 Text VGA Mode\r
-  //\r
-  Regs.H.AH = 0x00;\r
-  Regs.H.AL = 0x03;\r
-  LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-  \r
-  Regs.H.AH = 0x11;\r
-  Regs.H.AL = 0x14;\r
-  Regs.H.BL = 0;\r
-  LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-  \r
-  //\r
-  // Do not disable IO/memory decode since that would prevent legacy ROM from working\r
-  //\r
-\r
-  //\r
-  // Release all allocated resources\r
-  //\r
-  BiosVideoDeviceReleaseResource (BiosVideoPrivate);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Collect the resource from destroyed bios video device.\r
-\r
-  @param BiosVideoPrivate   Video child device private data structure\r
-\r
-**/\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
-  BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-{\r
-  if (BiosVideoPrivate == NULL) {\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Release all the resourses occupied by the BIOS_VIDEO_DEV\r
-  //\r
-  \r
-  //\r
-  // Free VGA Frame Buffer\r
-  //\r
-  if (BiosVideoPrivate->VgaFrameBuffer != NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->VgaFrameBuffer);\r
-  }\r
-  //\r
-  // Free VBE Frame Buffer\r
-  //\r
-  if (BiosVideoPrivate->VbeFrameBuffer != NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->VbeFrameBuffer);\r
-  }\r
-  //\r
-  // Free line buffer\r
-  //\r
-  if (BiosVideoPrivate->LineBuffer != NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->LineBuffer);\r
-  }\r
-  //\r
-  // Free mode data\r
-  //\r
-  if (BiosVideoPrivate->ModeData != NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->ModeData);\r
-  }\r
-  //\r
-  // Free memory allocated below 1MB\r
-  //\r
-  if (BiosVideoPrivate->PagesBelow1MB != 0) {\r
-    gBS->FreePages (BiosVideoPrivate->PagesBelow1MB, BiosVideoPrivate->NumberOfPagesBelow1MB);\r
-  }\r
-\r
-  if (BiosVideoPrivate->VbeSaveRestorePages != 0) {\r
-    gBS->FreePages (BiosVideoPrivate->VbeSaveRestoreBuffer, BiosVideoPrivate->VbeSaveRestorePages);\r
-  }\r
-  //\r
-  // Free graphics output protocol occupied resource\r
-  //\r
-  if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {\r
-    if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {\r
-        gBS->FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);\r
-    }\r
-    gBS->FreePool (BiosVideoPrivate->GraphicsOutput.Mode);\r
-  }\r
-  //\r
-  // Free EDID discovered protocol occupied resource\r
-  //\r
-  if (BiosVideoPrivate->EdidDiscovered.Edid != NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->EdidDiscovered.Edid);\r
-  }\r
-  //\r
-  // Free EDID active protocol occupied resource\r
-  //\r
-  if (BiosVideoPrivate->EdidActive.Edid != NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->EdidActive.Edid);\r
-  }\r
-\r
-  if (BiosVideoPrivate->DevicePath!= NULL) {\r
-    gBS->FreePool (BiosVideoPrivate->DevicePath);\r
-  }\r
-\r
-  gBS->FreePool (BiosVideoPrivate);\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-\r
-  Generate a search key for a specified timing data.\r
-\r
-\r
-  @param EdidTiming      - Pointer to EDID timing\r
-\r
-  @return The 32 bit unique key for search.\r
-\r
-**/\r
-STATIC\r
-UINT32\r
-CalculateEdidKey (\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
-  )\r
-{\r
-  UINT32 Key;\r
-\r
-  //\r
-  // Be sure no conflicts for all standard timing defined by VESA.\r
-  //\r
-  Key = (EdidTiming->HorizontalResolution * 2) + EdidTiming->VerticalResolution;\r
-  return Key;\r
-}\r
-\r
-/**\r
-\r
-  Parse the Established Timing and Standard Timing in EDID data block.\r
-\r
-\r
-  @param EdidBuffer      - Pointer to EDID data block\r
-  @param ValidEdidTiming - Valid EDID timing information\r
-\r
-  @return TRUE              - The EDID data is valid.\r
-          FALSE             - The EDID data is invalid.\r
-\r
-**/\r
-STATIC\r
-BOOLEAN\r
-ParseEdidData (\r
-  UINT8                                      *EdidBuffer,\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming\r
-  )\r
-{\r
-  UINT8  CheckSum;\r
-  UINT32 Index;\r
-  UINT32 ValidNumber;\r
-  UINT32 TimingBits;\r
-  UINT8  *BufferIndex;\r
-  UINT16 HorizontalResolution;\r
-  UINT16 VerticalResolution;\r
-  UINT8  AspectRatio;\r
-  UINT8  RefreshRate;\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING     TempTiming;\r
-  VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *EdidDataBlock;\r
-\r
-  EdidDataBlock = (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *) EdidBuffer;\r
-\r
-  //\r
-  // Check the checksum of EDID data\r
-  //\r
-  CheckSum = 0;\r
-  for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; Index ++) {\r
-    CheckSum = (UINT8)(CheckSum + EdidBuffer[Index]);\r
-  }\r
-  if (CheckSum != 0) {\r
-    return FALSE;\r
-  }\r
-\r
-  ValidNumber = 0;\r
-  gBS->SetMem (ValidEdidTiming, sizeof (VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING), 0);\r
-\r
-  if ((EdidDataBlock->EstablishedTimings[0] != 0) ||\r
-      (EdidDataBlock->EstablishedTimings[1] != 0) ||\r
-      (EdidDataBlock->EstablishedTimings[2] != 0)\r
-      ) {\r
-    //\r
-    // Established timing data\r
-    //\r
-    TimingBits = EdidDataBlock->EstablishedTimings[0] |\r
-                 (EdidDataBlock->EstablishedTimings[1] << 8) |\r
-                 ((EdidDataBlock->EstablishedTimings[2] & 0x80) << 9) ;\r
-    for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER; Index ++) {\r
-      if (TimingBits & 0x1) {\r
-        ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&mEstablishedEdidTiming[Index]);\r
-        ValidNumber ++;\r
-      }\r
-      TimingBits = TimingBits >> 1;\r
-    }\r
-  } else {\r
-    //\r
-    // If no Established timing data, read the standard timing data\r
-    //\r
-    BufferIndex = &EdidDataBlock->StandardTimingIdentification[0];\r
-    for (Index = 0; Index < 8; Index ++) {\r
-      if ((BufferIndex[0] != 0x1) && (BufferIndex[1] != 0x1)){\r
-        //\r
-        // A valid Standard Timing\r
-        //\r
-        HorizontalResolution = (UINT8) (BufferIndex[0] * 8 + 248);\r
-        AspectRatio = (UINT8) (BufferIndex[1] >> 6);\r
-        switch (AspectRatio) {\r
-          case 0:\r
-            VerticalResolution = (UINT8) (HorizontalResolution / 16 * 10);\r
-            break;\r
-          case 1:\r
-            VerticalResolution = (UINT8) (HorizontalResolution / 4 * 3);\r
-            break;\r
-          case 2:\r
-            VerticalResolution = (UINT8) (HorizontalResolution / 5 * 4);\r
-            break;\r
-          case 3:\r
-            VerticalResolution = (UINT8) (HorizontalResolution / 16 * 9);\r
-            break;\r
-          default:\r
-            VerticalResolution = (UINT8) (HorizontalResolution / 4 * 3);\r
-            break;\r
-        }\r
-        RefreshRate = (UINT8) ((BufferIndex[1] & 0x1f) + 60);\r
-        TempTiming.HorizontalResolution = HorizontalResolution;\r
-        TempTiming.VerticalResolution = VerticalResolution;\r
-        TempTiming.RefreshRate = RefreshRate;\r
-        ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);\r
-        ValidNumber ++;\r
-      }\r
-      BufferIndex += 2;\r
-    }\r
-  }\r
-\r
-  ValidEdidTiming->ValidNumber = ValidNumber;\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-\r
-  Search a specified Timing in all the valid EDID timings.\r
-\r
-\r
-  @param ValidEdidTiming - All valid EDID timing information.\r
-  @param EdidTiming      - The Timing to search for.\r
-\r
-  @return TRUE  - Found.\r
-          FALSE - Not found.\r
-\r
-**/\r
-STATIC\r
-BOOLEAN\r
-SearchEdidTiming (\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming,\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       *EdidTiming\r
-  )\r
-{\r
-  UINT32 Index;\r
-  UINT32 Key;\r
-\r
-  Key = CalculateEdidKey (EdidTiming);\r
-\r
-  for (Index = 0; Index < ValidEdidTiming->ValidNumber; Index ++) {\r
-    if (Key == ValidEdidTiming->Key[Index]) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-#define PCI_DEVICE_ENABLED  (EFI_PCI_COMMAND_IO_SPACE | EFI_PCI_COMMAND_MEMORY_SPACE)\r
-\r
-\r
-/**\r
-  Judge whether this device is VGA device.\r
-\r
-  @param PciIo      Parent PciIo protocol instance pointer\r
-\r
-  @retval TRUE  Is vga device\r
-  @retval FALSE Is no vga device\r
-**/\r
-BOOLEAN\r
-BiosVideoIsVga (\r
-  IN  EFI_PCI_IO_PROTOCOL       *PciIo\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  BOOLEAN       VgaCompatible;\r
-  PCI_TYPE00    Pci;\r
-\r
-  VgaCompatible = FALSE;\r
-\r
-  //\r
-  // Read the PCI Configuration Header\r
-  //\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint32,\r
-                        0,\r
-                        sizeof (Pci) / sizeof (UINT32),\r
-                        &Pci\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    return VgaCompatible;\r
-  }\r
-\r
-  //\r
-  // See if this is a VGA compatible controller or not\r
-  //\r
-  if ((Pci.Hdr.Command & PCI_DEVICE_ENABLED) == PCI_DEVICE_ENABLED) {\r
-    if (Pci.Hdr.ClassCode[2] == PCI_CLASS_OLD && Pci.Hdr.ClassCode[1] == PCI_CLASS_OLD_VGA) {\r
-      //\r
-      // Base Class 0x00 Sub-Class 0x01 - Backward compatible VGA device\r
-      //\r
-      VgaCompatible = TRUE;\r
-    }\r
-\r
-    if (Pci.Hdr.ClassCode[2] == PCI_CLASS_DISPLAY && Pci.Hdr.ClassCode[1] == PCI_CLASS_DISPLAY_VGA && Pci.Hdr.ClassCode[0] == 0x00) {\r
-      //\r
-      // Base Class 3 Sub-Class 0 Programming interface 0 - VGA compatible Display controller\r
-      //\r
-      VgaCompatible = TRUE;\r
-    }\r
-  }\r
-\r
-  return VgaCompatible;\r
-}\r
-\r
-\r
-/**\r
-  Check for VBE device\r
-\r
-  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS VBE device found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoCheckForVbe (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-{\r
-  EFI_STATUS                             Status;\r
-  IA32_REGISTER_SET                  Regs;\r
-  UINT16                                 *ModeNumberPtr;\r
-  BOOLEAN                                ModeFound;\r
-  BOOLEAN                                EdidFound;\r
-  BIOS_VIDEO_MODE_DATA                   *ModeBuffer;\r
-  BIOS_VIDEO_MODE_DATA                   *CurrentModeData;\r
-  UINTN                                  PreferMode;\r
-  UINTN                                  ModeNumber;\r
-  VESA_BIOS_EXTENSIONS_EDID_TIMING       Timing;\r
-  VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING ValidEdidTiming;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE      *GraphicsOutputMode;\r
-\r
-  //\r
-  // Allocate buffer under 1MB for VBE data structures\r
-  //\r
-  BiosVideoPrivate->NumberOfPagesBelow1MB = EFI_SIZE_TO_PAGES (\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK) +\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK) +\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK) +\r
-                                              sizeof (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK)\r
-                                              );\r
-\r
-  BiosVideoPrivate->PagesBelow1MB = 0x00100000 - 1;\r
-\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiBootServicesData,\r
-                  BiosVideoPrivate->NumberOfPagesBelow1MB,\r
-                  &BiosVideoPrivate->PagesBelow1MB\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ZeroMem (&ValidEdidTiming, sizeof (VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING));\r
-\r
-  //\r
-  // Fill in the Graphics Output Protocol\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.QueryMode = BiosVideoGraphicsOutputQueryMode;\r
-  BiosVideoPrivate->GraphicsOutput.SetMode = BiosVideoGraphicsOutputSetMode;\r
-  BiosVideoPrivate->GraphicsOutput.Blt     = BiosVideoGraphicsOutputVbeBlt;\r
-  BiosVideoPrivate->GraphicsOutput.Mode = NULL;\r
-\r
-  //\r
-  // Fill in the VBE related data structures\r
-  //\r
-  BiosVideoPrivate->VbeInformationBlock = (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *) (UINTN) (BiosVideoPrivate->PagesBelow1MB);\r
-  BiosVideoPrivate->VbeModeInformationBlock = (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *) (BiosVideoPrivate->VbeInformationBlock + 1);\r
-  BiosVideoPrivate->VbeEdidDataBlock = (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *) (BiosVideoPrivate->VbeModeInformationBlock + 1);\r
-  BiosVideoPrivate->VbeCrtcInformationBlock = (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *) (BiosVideoPrivate->VbeEdidDataBlock + 1);\r
-  BiosVideoPrivate->VbeSaveRestorePages   = 0;\r
-  BiosVideoPrivate->VbeSaveRestoreBuffer  = 0;\r
-\r
-  //\r
-  // Test to see if the Video Adapter is compliant with VBE 3.0\r
-  //\r
-  // INT 10 - VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION\r
-  //\r
-  //  AX = 4F00h\r
-  //  ES:DI -> buffer for SuperVGA information (see #00077)\r
-  // Return: AL = 4Fh if function supported\r
-  //  AH = status\r
-  //      00h successful\r
-  //    ES:DI buffer filled\r
-  //      01h failed\r
-  //      ---VBE v2.0---\r
-  //      02h function not supported by current hardware configuration\r
-  //      03h function invalid in current video mode\r
-  // Desc:  determine whether VESA BIOS extensions are present and the capabilities\r
-  //    supported by the display adapter\r
-  //\r
-  gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-  Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION;\r
-  gBS->SetMem (BiosVideoPrivate->VbeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK), 0);\r
-  BiosVideoPrivate->VbeInformationBlock->VESASignature  = VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE;\r
-  Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
-  Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
-\r
-  LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    \r
-  Status = EFI_DEVICE_ERROR;\r
-\r
-  //\r
-  // See if the VESA call succeeded\r
-  //\r
-  if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check for 'VESA' signature\r
-  //\r
-  if (BiosVideoPrivate->VbeInformationBlock->VESASignature != VESA_BIOS_EXTENSIONS_VESA_SIGNATURE) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check to see if this is VBE 2.0 or higher\r
-  //\r
-  if (BiosVideoPrivate->VbeInformationBlock->VESAVersion < VESA_BIOS_EXTENSIONS_VERSION_2_0) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Read EDID information\r
-  //\r
-  // INT 10 - VESA VBE/DC (Display Data Channel) - READ EDID\r
-  //\r
-  //    AX = 4F15h\r
-  //    BL = 01h\r
-  //    CX = 0000h\r
-  //    DX = 0000h\r
-  //    ES:DI -> 128-byte buffer for EDID record (see #00127)\r
-  // Return: AL = 4Fh if function supported\r
-  //    AH = status\r
-  //        00h successful\r
-  //    ES:DI buffer filled\r
-  //    01h failed (e.g. non-DDC monitor)\r
-  //\r
-  gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-  Regs.X.AX = VESA_BIOS_EXTENSIONS_EDID;\r
-  Regs.X.BX = 1;\r
-  Regs.X.CX = 0;\r
-  Regs.X.DX = 0;\r
-  Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
-  Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
-\r
-  LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-  \r
-  //\r
-  // See if the VESA call succeeded\r
-  //\r
-  EdidFound = FALSE;\r
-  if (Regs.X.AX == VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-    //\r
-    // Parse EDID data structure to retrieve modes supported by monitor\r
-    //\r
-    if (ParseEdidData ((UINT8 *) BiosVideoPrivate->VbeEdidDataBlock, &ValidEdidTiming) == TRUE) {\r
-      EdidFound = TRUE;\r
-\r
-      BiosVideoPrivate->EdidDiscovered.SizeOfEdid = VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE;\r
-      Status = gBS->AllocatePool (\r
-                      EfiBootServicesData,\r
-                      VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE,\r
-                      (VOID**) &BiosVideoPrivate->EdidDiscovered.Edid\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-      gBS->CopyMem (\r
-             BiosVideoPrivate->EdidDiscovered.Edid,\r
-             BiosVideoPrivate->VbeEdidDataBlock,\r
-             VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE\r
-             );\r
-\r
-      BiosVideoPrivate->EdidActive.SizeOfEdid = VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE;\r
-      Status = gBS->AllocatePool (\r
-                      EfiBootServicesData,\r
-                      VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE,\r
-                      (VOID**)&BiosVideoPrivate->EdidActive.Edid\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-      gBS->CopyMem (\r
-             BiosVideoPrivate->EdidActive.Edid,\r
-             BiosVideoPrivate->VbeEdidDataBlock,\r
-             VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE\r
-             );\r
-    } else {\r
-      BiosVideoPrivate->EdidDiscovered.SizeOfEdid = 0;\r
-      BiosVideoPrivate->EdidDiscovered.Edid = NULL;\r
-\r
-      BiosVideoPrivate->EdidActive.SizeOfEdid = 0;\r
-      BiosVideoPrivate->EdidActive.Edid = NULL;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Walk through the mode list to see if there is at least one mode the is compatible with the EDID mode\r
-  //\r
-  ModeNumberPtr = (UINT16 *)\r
-    (\r
-      (((UINTN) BiosVideoPrivate->VbeInformationBlock->VideoModePtr & 0xffff0000) >> 12) |\r
-        ((UINTN) BiosVideoPrivate->VbeInformationBlock->VideoModePtr & 0x0000ffff)\r
-    );\r
-\r
-  PreferMode = 0;\r
-  ModeNumber = 0;\r
-\r
-  for (; *ModeNumberPtr != VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST; ModeNumberPtr++) {\r
-    //\r
-    // Make sure this is a mode number defined by the VESA VBE specification.  If it isn'tm then skip this mode number.\r
-    //\r
-    if ((*ModeNumberPtr & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // Get the information about the mode\r
-    //\r
-    // INT 10 - VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION\r
-    //\r
-    //   AX = 4F01h\r
-    //   CX = SuperVGA video mode (see #04082 for bitfields)\r
-    //   ES:DI -> 256-byte buffer for mode information (see #00079)\r
-    // Return: AL = 4Fh if function supported\r
-    //   AH = status\r
-    //      00h successful\r
-    //    ES:DI buffer filled\r
-    //      01h failed\r
-    // Desc:  determine the attributes of the specified video mode\r
-    //\r
-    gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-    Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION;\r
-    Regs.X.CX = *ModeNumberPtr;\r
-    gBS->SetMem (BiosVideoPrivate->VbeModeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK), 0);\r
-    Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
-    Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
-\r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    \r
-    //\r
-    // See if the call succeeded.  If it didn't, then try the next mode.\r
-    //\r
-    if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports color.  If it doesn't then try the next mode.\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports graphics.  If it doesn't then try the next mode.\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports a linear frame buffer.  If it doesn't then try the next mode.\r
-    //\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER) == 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the mode supports 32 bit color.  If it doesn't then try the next mode.\r
-    // 32 bit mode can be implemented by 24 Bits Per Pixels. Also make sure the\r
-    // number of bits per pixel is a multiple of 8 or more than 32 bits per pixel\r
-    //\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel < 24) {\r
-      continue;\r
-    }\r
-\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel > 32) {\r
-      continue;\r
-    }\r
-\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel % 8) != 0) {\r
-      continue;\r
-    }\r
-    //\r
-    // See if the physical base pointer for the linear mode is valid.  If it isn't then try the next mode.\r
-    //\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->PhysBasePtr == 0) {\r
-      continue;\r
-    }\r
-\r
-    if (EdidFound && (ValidEdidTiming.ValidNumber > 0)) {\r
-      //\r
-      // EDID exist, check whether this mode match with any mode in EDID\r
-      //\r
-      Timing.HorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;\r
-      Timing.VerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;\r
-      if (SearchEdidTiming (&ValidEdidTiming, &Timing) == FALSE) {\r
-        continue;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Select a reasonable mode to be set for current display mode\r
-    //\r
-    ModeFound = FALSE;\r
-\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 1024 &&\r
-        BiosVideoPrivate->VbeModeInformationBlock->YResolution == 768\r
-        ) {\r
-      ModeFound = TRUE;\r
-    }\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 800 &&\r
-        BiosVideoPrivate->VbeModeInformationBlock->YResolution == 600\r
-        ) {\r
-      ModeFound = TRUE;\r
-      PreferMode = ModeNumber;\r
-    }\r
-    if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 640 &&\r
-        BiosVideoPrivate->VbeModeInformationBlock->YResolution == 480\r
-        ) {\r
-      ModeFound = TRUE;\r
-    }\r
-    if ((!EdidFound) && (!ModeFound)) {\r
-      //\r
-      // When no EDID exist, only select three possible resolutions, i.e. 1024x768, 800x600, 640x480\r
-      //\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Add mode to the list of available modes\r
-    //\r
-    ModeNumber ++;\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData,\r
-                    ModeNumber * sizeof (BIOS_VIDEO_MODE_DATA),\r
-                    (VOID **) &ModeBuffer\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    if (ModeNumber > 1) {\r
-      gBS->CopyMem (\r
-            ModeBuffer,\r
-            BiosVideoPrivate->ModeData,\r
-            (ModeNumber - 1) * sizeof (BIOS_VIDEO_MODE_DATA)\r
-            );\r
-    }\r
-\r
-    if (BiosVideoPrivate->ModeData != NULL) {\r
-      gBS->FreePool (BiosVideoPrivate->ModeData);\r
-    }\r
-\r
-    CurrentModeData = &ModeBuffer[ModeNumber - 1];\r
-    CurrentModeData->VbeModeNumber = *ModeNumberPtr;\r
-    if (BiosVideoPrivate->VbeInformationBlock->VESAVersion >= VESA_BIOS_EXTENSIONS_VERSION_3_0) {\r
-      CurrentModeData->BytesPerScanLine = BiosVideoPrivate->VbeModeInformationBlock->LinBytesPerScanLine;\r
-      CurrentModeData->Red.Position = BiosVideoPrivate->VbeModeInformationBlock->LinRedFieldPosition;\r
-      CurrentModeData->Red.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinRedMaskSize) - 1);\r
-      CurrentModeData->Blue.Position = BiosVideoPrivate->VbeModeInformationBlock->LinBlueFieldPosition;\r
-      CurrentModeData->Blue.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinBlueMaskSize) - 1);\r
-      CurrentModeData->Green.Position = BiosVideoPrivate->VbeModeInformationBlock->LinGreenFieldPosition;\r
-      CurrentModeData->Green.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinGreenMaskSize) - 1);\r
-      CurrentModeData->Reserved.Position = BiosVideoPrivate->VbeModeInformationBlock->LinRsvdFieldPosition;\r
-      CurrentModeData->Reserved.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->LinRsvdMaskSize) - 1);\r
-    } else {\r
-      CurrentModeData->BytesPerScanLine = BiosVideoPrivate->VbeModeInformationBlock->BytesPerScanLine;\r
-      CurrentModeData->Red.Position = BiosVideoPrivate->VbeModeInformationBlock->RedFieldPosition;\r
-      CurrentModeData->Red.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->RedMaskSize) - 1);\r
-      CurrentModeData->Blue.Position = BiosVideoPrivate->VbeModeInformationBlock->BlueFieldPosition;\r
-      CurrentModeData->Blue.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->BlueMaskSize) - 1);\r
-      CurrentModeData->Green.Position = BiosVideoPrivate->VbeModeInformationBlock->GreenFieldPosition;\r
-      CurrentModeData->Green.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->GreenMaskSize) - 1);\r
-      CurrentModeData->Reserved.Position = BiosVideoPrivate->VbeModeInformationBlock->RsvdFieldPosition;\r
-      CurrentModeData->Reserved.Mask = (UINT8) ((1 << BiosVideoPrivate->VbeModeInformationBlock->RsvdMaskSize) - 1);\r
-    }\r
-    CurrentModeData->PixelFormat = PixelBitMask;\r
-    if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel == 32) &&\r
-        (CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff)) {\r
-      if ((CurrentModeData->Red.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Blue.Position == 16)) {\r
-        CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;\r
-      } else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) {\r
-        CurrentModeData->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;\r
-      }\r
-    }\r
-    CurrentModeData->PixelBitMask.RedMask = ((UINT32) CurrentModeData->Red.Mask) << CurrentModeData->Red.Position;\r
-    CurrentModeData->PixelBitMask.GreenMask = ((UINT32) CurrentModeData->Green.Mask) << CurrentModeData->Green.Position;\r
-    CurrentModeData->PixelBitMask.BlueMask = ((UINT32) CurrentModeData->Blue.Mask) << CurrentModeData->Blue.Position;\r
-    CurrentModeData->PixelBitMask.ReservedMask = ((UINT32) CurrentModeData->Reserved.Mask) << CurrentModeData->Reserved.Position;\r
-\r
-    CurrentModeData->LinearFrameBuffer = (VOID *) (UINTN)BiosVideoPrivate->VbeModeInformationBlock->PhysBasePtr;\r
-    CurrentModeData->FrameBufferSize = BiosVideoPrivate->VbeInformationBlock->TotalMemory * 64 * 1024;\r
-    CurrentModeData->HorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;\r
-    CurrentModeData->VerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;\r
-\r
-    CurrentModeData->BitsPerPixel  = BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel;\r
-\r
-    BiosVideoPrivate->ModeData = ModeBuffer;\r
-  }\r
-  //\r
-  // Check to see if we found any modes that are compatible with GRAPHICS OUTPUT\r
-  //\r
-  if (ModeNumber == 0) {\r
-    Status = EFI_DEVICE_ERROR;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Allocate buffer for Graphics Output Protocol mode information\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                EfiBootServicesData,\r
-                sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),\r
-                (VOID **) &BiosVideoPrivate->GraphicsOutput.Mode\r
-                );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  GraphicsOutputMode = BiosVideoPrivate->GraphicsOutput.Mode;\r
-  Status = gBS->AllocatePool (\r
-                EfiBootServicesData,\r
-                sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
-                (VOID **) &GraphicsOutputMode->Info\r
-                );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  GraphicsOutputMode->MaxMode = (UINT32) ModeNumber;\r
-  //\r
-  // Current mode is unknow till now, set it to an invalid mode.\r
-  //\r
-  GraphicsOutputMode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
-\r
-  //\r
-  // Find the best mode to initialize\r
-  //\r
-  Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, (UINT32) PreferMode);\r
-  if (EFI_ERROR (Status)) {\r
-    for (PreferMode = 0; PreferMode < ModeNumber; PreferMode ++) {\r
-      Status = BiosVideoGraphicsOutputSetMode (\r
-                &BiosVideoPrivate->GraphicsOutput,\r
-                (UINT32) PreferMode\r
-                );\r
-      if (!EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-    }\r
-    if (PreferMode == ModeNumber) {\r
-      //\r
-      // None mode is set successfully.\r
-      //\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-Done:\r
-  //\r
-  // If there was an error, then free the mode structure\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    if (BiosVideoPrivate->ModeData != NULL) {\r
-      gBS->FreePool (BiosVideoPrivate->ModeData);\r
-    }\r
-    if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {\r
-      if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {\r
-        gBS->FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);\r
-      }\r
-      gBS->FreePool (BiosVideoPrivate->GraphicsOutput.Mode);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check for VGA device\r
-\r
-  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS  Standard VGA device found\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoCheckForVga (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  BIOS_VIDEO_MODE_DATA  *ModeBuffer;\r
-  \r
-  //\r
-  // Fill in the Graphics Output Protocol\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.QueryMode = BiosVideoGraphicsOutputQueryMode;\r
-  BiosVideoPrivate->GraphicsOutput.SetMode = BiosVideoGraphicsOutputSetMode;\r
-  BiosVideoPrivate->GraphicsOutput.Blt     = BiosVideoGraphicsOutputVgaBlt;\r
-\r
-  //\r
-  // Allocate buffer for Graphics Output Protocol mode information\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                EfiBootServicesData,\r
-                sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),\r
-                (VOID **) &BiosVideoPrivate->GraphicsOutput.Mode\r
-                );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  Status = gBS->AllocatePool (\r
-                EfiBootServicesData,\r
-                sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
-                (VOID **) &BiosVideoPrivate->GraphicsOutput.Mode->Info\r
-                );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Add mode to the list of available modes\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Mode->MaxMode = 1;\r
-\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (BIOS_VIDEO_MODE_DATA),\r
-                  (VOID **) &ModeBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  ModeBuffer->VbeModeNumber         = 0x0012;\r
-  ModeBuffer->BytesPerScanLine      = 640;\r
-  ModeBuffer->LinearFrameBuffer     = (VOID *) (UINTN) (0xa0000);\r
-  ModeBuffer->FrameBufferSize       = 0;\r
-  ModeBuffer->HorizontalResolution  = 640;\r
-  ModeBuffer->VerticalResolution    = 480;\r
-  ModeBuffer->BitsPerPixel          = 8;  \r
-  ModeBuffer->PixelFormat           = PixelBltOnly;\r
-\r
-  BiosVideoPrivate->ModeData = ModeBuffer;\r
-\r
-  //\r
-  // Test to see if the Video Adapter support the 640x480 16 color mode\r
-  //\r
-  BiosVideoPrivate->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
-  Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, 0);\r
-\r
-Done:\r
-  //\r
-  // If there was an error, then free the mode structure\r
-  //\r
-  if (EFI_ERROR (Status)) {\r
-    if (BiosVideoPrivate->ModeData != NULL) {\r
-      gBS->FreePool (BiosVideoPrivate->ModeData);\r
-    }\r
-    if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {\r
-      if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {\r
-        gBS->FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);\r
-      }\r
-      gBS->FreePool (BiosVideoPrivate->GraphicsOutput.Mode);\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-//\r
-// Graphics Output Protocol Member Functions for VESA BIOS Extensions\r
-//\r
-/**\r
-\r
-  Graphics Output protocol interface to get video mode\r
-\r
-\r
-  @param This            - Protocol instance pointer.\r
-  @param ModeNumber      - The mode number to return information on.\r
-  @param SizeOfInfo      - A pointer to the size, in bytes, of the Info buffer.\r
-  @param Info            - Caller allocated buffer that returns information about ModeNumber.\r
-\r
-  @return EFI_SUCCESS           - Mode information returned.\r
-          EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\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
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputQueryMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,\r
-  IN  UINT32                                ModeNumber,\r
-  OUT UINTN                                 *SizeOfInfo,\r
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
-  EFI_STATUS            Status;\r
-  BIOS_VIDEO_MODE_DATA  *ModeData;\r
-\r
-  BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-\r
-  if (BiosVideoPrivate->HardwareNeedsStarting) {\r
-    return EFI_NOT_STARTED;\r
-  }\r
-\r
-  if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
-                  (VOID**) Info\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
-\r
-  ModeData = &BiosVideoPrivate->ModeData[ModeNumber];\r
-  (*Info)->Version = 0;\r
-  (*Info)->HorizontalResolution = ModeData->HorizontalResolution;\r
-  (*Info)->VerticalResolution   = ModeData->VerticalResolution;\r
-  (*Info)->PixelFormat = ModeData->PixelFormat;\r
-  (*Info)->PixelInformation = ModeData->PixelBitMask;\r
-\r
-  (*Info)->PixelsPerScanLine =  (ModeData->BytesPerScanLine * 8) / ModeData->BitsPerPixel;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Graphics Output protocol interface to set video mode\r
-\r
-\r
-  @param This            - Protocol instance pointer.\r
-  @param ModeNumber      - The mode number to be set.\r
-\r
-  @return EFI_SUCCESS      - Graphics mode was changed.\r
-          EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
-          EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputSetMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
-  IN  UINT32                       ModeNumber\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  BIOS_VIDEO_DEV          *BiosVideoPrivate;\r
-  IA32_REGISTER_SET   Regs;\r
-  BIOS_VIDEO_MODE_DATA    *ModeData;\r
-\r
-  BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ModeNumber >= This->Mode->MaxMode) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  ModeData = &BiosVideoPrivate->ModeData[ModeNumber];\r
-\r
-  if (BiosVideoPrivate->LineBuffer) {\r
-    gBS->FreePool (BiosVideoPrivate->LineBuffer);\r
-  }\r
-\r
-  if (BiosVideoPrivate->VgaFrameBuffer) {\r
-    gBS->FreePool (BiosVideoPrivate->VgaFrameBuffer);\r
-  }\r
-\r
-  if (BiosVideoPrivate->VbeFrameBuffer) {\r
-    gBS->FreePool (BiosVideoPrivate->VbeFrameBuffer);\r
-  }\r
-\r
-  BiosVideoPrivate->LineBuffer = NULL;\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  ModeData->BytesPerScanLine,\r
-                  (VOID**) &BiosVideoPrivate->LineBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Clear all registers\r
-  //\r
-  gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-\r
-  if (ModeData->VbeModeNumber < 0x100) {\r
-    //\r
-    // Allocate a working buffer for BLT operations to the VGA frame buffer\r
-    //\r
-    BiosVideoPrivate->VgaFrameBuffer = NULL;\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData,\r
-                    4 * 480 * 80,\r
-                    (VOID**) &BiosVideoPrivate->VgaFrameBuffer\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Set VGA Mode\r
-    //\r
-    Regs.X.AX = ModeData->VbeModeNumber;\r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-\r
-  } else {\r
-    //\r
-    // Allocate a working buffer for BLT operations to the VBE frame buffer\r
-    //\r
-    BiosVideoPrivate->VbeFrameBuffer = NULL;\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData,\r
-                    ModeData->BytesPerScanLine * ModeData->VerticalResolution,\r
-                    (VOID**) &BiosVideoPrivate->VbeFrameBuffer\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    //\r
-    // Set VBE mode\r
-    //\r
-    Regs.X.AX = VESA_BIOS_EXTENSIONS_SET_MODE;\r
-    Regs.X.BX = (UINT16) (ModeData->VbeModeNumber | VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER);\r
-    gBS->SetMem (BiosVideoPrivate->VbeCrtcInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK), 0);\r
-    Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
-    Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
-    \r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    \r
-    //\r
-    // Check to see if the call succeeded\r
-    //\r
-    if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    //\r
-    // Initialize the state of the VbeFrameBuffer\r
-    //\r
-    Status = BiosVideoPrivate->PciIo->Mem.Read (\r
-                                            BiosVideoPrivate->PciIo,\r
-                                            EfiPciIoWidthUint32,\r
-                                            EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                            (UINT64) (UINTN) ModeData->LinearFrameBuffer,\r
-                                            (ModeData->BytesPerScanLine * ModeData->VerticalResolution) >> 2,\r
-                                            BiosVideoPrivate->VbeFrameBuffer\r
-                                            );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  This->Mode->Mode = ModeNumber;\r
-  This->Mode->Info->Version = 0;\r
-  This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;\r
-  This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;\r
-  This->Mode->Info->PixelFormat = ModeData->PixelFormat;\r
-  This->Mode->Info->PixelInformation = ModeData->PixelBitMask;\r
-  This->Mode->Info->PixelsPerScanLine =  (ModeData->BytesPerScanLine * 8) / ModeData->BitsPerPixel;\r
-  This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
-\r
-  //\r
-  // Frame BufferSize remain unchanged\r
-  //\r
-  This->Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)ModeData->LinearFrameBuffer;\r
-  This->Mode->FrameBufferSize = ModeData->FrameBufferSize;\r
-\r
-  BiosVideoPrivate->HardwareNeedsStarting = FALSE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Update physical frame buffer, copy 4 bytes block, then copy remaining bytes.\r
-\r
-\r
-  @param PciIo           - The pointer of EFI_PCI_IO_PROTOCOL\r
-  @param VbeBuffer       - The data to transfer to screen\r
-  @param MemAddress      - Physical frame buffer base address\r
-  @param DestinationX    - The X coordinate of the destination for BltOperation\r
-  @param DestinationY    - The Y coordinate of the destination for BltOperation\r
-  @param TotalBytes      - The total bytes of copy\r
-  @param VbePixelWidth   - Bytes per pixel\r
-  @param BytesPerScanLine - Bytes per scan line\r
-\r
-  @return None.\r
-\r
-**/\r
-VOID\r
-CopyVideoBuffer (\r
-  IN  EFI_PCI_IO_PROTOCOL   *PciIo,\r
-  IN  UINT8                 *VbeBuffer,\r
-  IN  VOID                  *MemAddress,\r
-  IN  UINTN                 DestinationX,\r
-  IN  UINTN                 DestinationY,\r
-  IN  UINTN                 TotalBytes,\r
-  IN  UINT32                VbePixelWidth,\r
-  IN  UINTN                 BytesPerScanLine\r
-  )\r
-{\r
-  UINTN                 FrameBufferAddr;\r
-  UINTN                 CopyBlockNum;\r
-  UINTN                 RemainingBytes;\r
-  UINTN                 UnalignedBytes;\r
-  EFI_STATUS            Status;\r
-\r
-  FrameBufferAddr = (UINTN) MemAddress + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth;\r
-\r
-  //\r
-  // If TotalBytes is less than 4 bytes, only start byte copy.\r
-  //\r
-  if (TotalBytes < 4) {\r
-    Status = PciIo->Mem.Write (\r
-                     PciIo,\r
-                     EfiPciIoWidthUint8,\r
-                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                     (UINT64) FrameBufferAddr,\r
-                     TotalBytes,\r
-                     VbeBuffer\r
-                     );\r
-    ASSERT_EFI_ERROR (Status);\r
-    return;\r
-  }\r
-\r
-  //\r
-  // If VbeBuffer is not 4-byte aligned, start byte copy.\r
-  //\r
-  UnalignedBytes  = (4 - ((UINTN) VbeBuffer & 0x3)) & 0x3;\r
-\r
-  if (UnalignedBytes != 0) {\r
-    Status = PciIo->Mem.Write (\r
-                     PciIo,\r
-                     EfiPciIoWidthUint8,\r
-                     EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                     (UINT64) FrameBufferAddr,\r
-                     UnalignedBytes,\r
-                     VbeBuffer\r
-                     );\r
-    ASSERT_EFI_ERROR (Status);\r
-    FrameBufferAddr += UnalignedBytes;\r
-    VbeBuffer       += UnalignedBytes;\r
-  }\r
-\r
-  //\r
-  // Calculate 4-byte block count and remaining bytes.\r
-  //\r
-  CopyBlockNum   = (TotalBytes - UnalignedBytes) >> 2;\r
-  RemainingBytes = (TotalBytes - UnalignedBytes) &  3;\r
-\r
-  //\r
-  // Copy 4-byte block and remaining bytes to physical frame buffer.\r
-  //\r
-  if (CopyBlockNum != 0) {\r
-    Status = PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint32,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) FrameBufferAddr,\r
-                    CopyBlockNum,\r
-                    VbeBuffer\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  if (RemainingBytes != 0) {\r
-    FrameBufferAddr += (CopyBlockNum << 2);\r
-    VbeBuffer       += (CopyBlockNum << 2);\r
-    Status = PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) FrameBufferAddr,\r
-                    RemainingBytes,\r
-                    VbeBuffer\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-//\r
-// BUGBUG : Add Blt for 16 bit color, 15 bit color, and 8 bit color modes\r
-//\r
-/**\r
-\r
-  Graphics Output protocol instance to block transfer for VBE device\r
-\r
-\r
-  @param This            - Pointer to Graphics Output protocol instance\r
-  @param BltBuffer       - The data to transfer to screen\r
-  @param BltOperation    - The operation to perform\r
-  @param SourceX         - The X coordinate of the source for BltOperation\r
-  @param SourceY         - The Y coordinate of the source for BltOperation\r
-  @param DestinationX    - The X coordinate of the destination for BltOperation\r
-  @param DestinationY    - The Y coordinate of the destination for BltOperation\r
-  @param Width           - The width of a rectangle in the blt rectangle in pixels\r
-  @param Height          - The height of a rectangle in the blt rectangle in pixels\r
-  @param Delta           - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                         If a subrectangle of the BltBuffer is used, then Delta represents\r
-                         the number of bytes in a row of the BltBuffer.\r
-\r
-  @return EFI_INVALID_PARAMETER - Invalid parameter passed in\r
-          EFI_SUCCESS - Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVbeBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_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\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV                 *BiosVideoPrivate;\r
-  BIOS_VIDEO_MODE_DATA           *Mode;\r
-  EFI_PCI_IO_PROTOCOL            *PciIo;\r
-  EFI_TPL                        OriginalTPL;\r
-  UINTN                          DstY;\r
-  UINTN                          SrcY;\r
-  UINTN                          DstX;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *Blt;\r
-  VOID                           *MemAddress;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *VbeFrameBuffer;\r
-  UINTN                          BytesPerScanLine;\r
-  UINTN                          Index;\r
-  UINT8                          *VbeBuffer;\r
-  UINT8                          *VbeBuffer1;\r
-  UINT8                          *BltUint8;\r
-  UINT32                         VbePixelWidth;\r
-  UINT32                         Pixel;\r
-  UINTN                          TotalBytes;\r
-\r
-  BiosVideoPrivate  = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-  Mode              = &BiosVideoPrivate->ModeData[This->Mode->Mode];\r
-  PciIo             = BiosVideoPrivate->PciIo;\r
-\r
-  VbeFrameBuffer    = BiosVideoPrivate->VbeFrameBuffer;\r
-  MemAddress        = Mode->LinearFrameBuffer;\r
-  BytesPerScanLine  = Mode->BytesPerScanLine;\r
-  VbePixelWidth     = Mode->BitsPerPixel / 8;\r
-  BltUint8          = (UINT8 *) BltBuffer;\r
-  TotalBytes        = Width * VbePixelWidth;\r
-\r
-  if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Width == 0 || Height == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // We need to fill the Virtual Screen buffer with the blt data.\r
-  // The virtual screen is upside down, as the first row is the bootom row of\r
-  // the image.\r
-  //\r
-  if (BltOperation == EfiBltVideoToBltBuffer) {\r
-    //\r
-    // Video to BltBuffer: Source is Video, destination is BltBuffer\r
-    //\r
-    if (SourceY + Height > Mode->VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (SourceX + Width > Mode->HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } else {\r
-    //\r
-    // BltBuffer to Video: Source is BltBuffer, destination is Video\r
-    //\r
-    if (DestinationY + Height > Mode->VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (DestinationX + Width > Mode->HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\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_GRAPHICS_OUTPUT_BLT_PIXEL);\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 (TPL_NOTIFY);\r
-\r
-  switch (BltOperation) {\r
-  case EfiBltVideoToBltBuffer:\r
-    for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {\r
-      Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (BltUint8 + DstY * Delta + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-      //\r
-      // Shuffle the packed bytes in the hardware buffer to match EFI_GRAPHICS_OUTPUT_BLT_PIXEL\r
-      //\r
-      VbeBuffer = ((UINT8 *) VbeFrameBuffer + (SrcY * BytesPerScanLine + SourceX * VbePixelWidth));\r
-      for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
-        Pixel         = *(UINT32 *) (VbeBuffer);\r
-        Blt->Red      = (UINT8) ((Pixel >> Mode->Red.Position) & Mode->Red.Mask);\r
-        Blt->Blue     = (UINT8) ((Pixel >> Mode->Blue.Position) & Mode->Blue.Mask);\r
-        Blt->Green    = (UINT8) ((Pixel >> Mode->Green.Position) & Mode->Green.Mask);\r
-        Blt->Reserved = 0;\r
-        Blt++;\r
-        VbeBuffer += VbePixelWidth;\r
-      }\r
-\r
-    }\r
-    break;\r
-\r
-  case EfiBltVideoToVideo:\r
-    for (Index = 0; Index < Height; Index++) {\r
-      if (DestinationY <= SourceY) {\r
-        SrcY  = SourceY + Index;\r
-        DstY  = DestinationY + Index;\r
-      } else {\r
-        SrcY  = SourceY + Height - Index - 1;\r
-        DstY  = DestinationY + Height - Index - 1;\r
-      }\r
-\r
-      VbeBuffer   = ((UINT8 *) VbeFrameBuffer + DstY * BytesPerScanLine + DestinationX * VbePixelWidth);\r
-      VbeBuffer1  = ((UINT8 *) VbeFrameBuffer + SrcY * BytesPerScanLine + SourceX * VbePixelWidth);\r
-\r
-      gBS->CopyMem (\r
-            VbeBuffer,\r
-            VbeBuffer1,\r
-            TotalBytes\r
-            );\r
-\r
-      //\r
-      // Update physical frame buffer.\r
-      //\r
-      CopyVideoBuffer (\r
-        PciIo,\r
-        VbeBuffer,\r
-        MemAddress,\r
-        DestinationX,\r
-        DstY,\r
-        TotalBytes,\r
-        VbePixelWidth,\r
-        BytesPerScanLine\r
-        );\r
-    }\r
-    break;\r
-\r
-  case EfiBltVideoFill:\r
-    VbeBuffer = (UINT8 *) ((UINTN) VbeFrameBuffer + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth);\r
-    Blt       = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltUint8;\r
-    //\r
-    // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match the hardware buffer\r
-    //\r
-    Pixel = ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) |\r
-      (\r
-        (Blt->Green & Mode->Green.Mask) <<\r
-        Mode->Green.Position\r
-      ) |\r
-          ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position);\r
-\r
-    for (Index = 0; Index < Width; Index++) {\r
-      gBS->CopyMem (\r
-            VbeBuffer,\r
-            &Pixel,\r
-            VbePixelWidth\r
-            );\r
-      VbeBuffer += VbePixelWidth;\r
-    }\r
-\r
-    VbeBuffer = (UINT8 *) ((UINTN) VbeFrameBuffer + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth);\r
-    for (DstY = DestinationY + 1; DstY < (Height + DestinationY); DstY++) {\r
-      gBS->CopyMem (\r
-            (VOID *) ((UINTN) VbeFrameBuffer + (DstY * BytesPerScanLine) + DestinationX * VbePixelWidth),\r
-            VbeBuffer,\r
-            TotalBytes\r
-            );\r
-    }\r
-    for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {\r
-      //\r
-      // Update physical frame buffer.\r
-      //\r
-      CopyVideoBuffer (\r
-        PciIo,\r
-        VbeBuffer,\r
-        MemAddress,\r
-        DestinationX,\r
-        DstY,\r
-        TotalBytes,\r
-        VbePixelWidth,\r
-        BytesPerScanLine\r
-        );\r
-    }\r
-    break;\r
-\r
-  case EfiBltBufferToVideo:\r
-    for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
-      Blt       = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (BltUint8 + (SrcY * Delta) + (SourceX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-      VbeBuffer = ((UINT8 *) VbeFrameBuffer + (DstY * BytesPerScanLine + DestinationX * VbePixelWidth));\r
-      for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
-        //\r
-        // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match the hardware buffer\r
-        //\r
-        Pixel = ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) |\r
-          ((Blt->Green & Mode->Green.Mask) << Mode->Green.Position) |\r
-            ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position);\r
-        gBS->CopyMem (\r
-              VbeBuffer,\r
-              &Pixel,\r
-              VbePixelWidth\r
-              );\r
-        Blt++;\r
-        VbeBuffer += VbePixelWidth;\r
-      }\r
-\r
-      VbeBuffer = ((UINT8 *) VbeFrameBuffer + (DstY * BytesPerScanLine + DestinationX * VbePixelWidth));\r
-\r
-      //\r
-      // Update physical frame buffer.\r
-      //\r
-      CopyVideoBuffer (\r
-        PciIo,\r
-        VbeBuffer,\r
-        MemAddress,\r
-        DestinationX,\r
-        DstY,\r
-        TotalBytes,\r
-        VbePixelWidth,\r
-        BytesPerScanLine\r
-        );\r
-    }\r
-    break;\r
-  default:\r
-    break;\r
-  }\r
-\r
-  gBS->RestoreTPL (OriginalTPL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-\r
-  Write graphics controller registers\r
-\r
-\r
-  @param PciIo           - Pointer to PciIo protocol instance of the controller\r
-  @param Address         - Register address\r
-  @param Data            - Data to be written to register\r
-\r
-  @return None\r
-\r
-**/\r
-STATIC\r
-VOID\r
-WriteGraphicsController (\r
-  IN  EFI_PCI_IO_PROTOCOL  *PciIo,\r
-  IN  UINTN                Address,\r
-  IN  UINTN                Data\r
-  )\r
-{\r
-  Address = Address | (Data << 8);\r
-  PciIo->Io.Write (\r
-              PciIo,\r
-              EfiPciIoWidthUint16,\r
-              EFI_PCI_IO_PASS_THROUGH_BAR,\r
-              VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER,\r
-              1,\r
-              &Address\r
-              );\r
-}\r
-\r
-/**\r
-\r
-  Read the four bit plane of VGA frame buffer\r
-\r
-\r
-  @param PciIo           - Pointer to PciIo protocol instance of the controller\r
-  @param HardwareBuffer  - Hardware VGA frame buffer address\r
-  @param MemoryBuffer    - Memory buffer address\r
-  @param WidthInBytes    - Number of bytes in a line to read\r
-  @param Height          - Height of the area to read\r
-\r
-  @return None\r
-\r
-**/\r
-VOID\r
-VgaReadBitPlanes (\r
-  EFI_PCI_IO_PROTOCOL  *PciIo,\r
-  UINT8                *HardwareBuffer,\r
-  UINT8                *MemoryBuffer,\r
-  UINTN                WidthInBytes,\r
-  UINTN                Height\r
-  )\r
-{\r
-  UINTN BitPlane;\r
-  UINTN Rows;\r
-  UINTN FrameBufferOffset;\r
-  UINT8 *Source;\r
-  UINT8 *Destination;\r
-\r
-  //\r
-  // Program the Mode Register Write mode 0, Read mode 0\r
-  //\r
-  WriteGraphicsController (\r
-    PciIo,\r
-    VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-    VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0\r
-    );\r
-\r
-  for (BitPlane = 0, FrameBufferOffset = 0;\r
-       BitPlane < VGA_NUMBER_OF_BIT_PLANES;\r
-       BitPlane++, FrameBufferOffset += VGA_BYTES_PER_BIT_PLANE\r
-      ) {\r
-    //\r
-    // Program the Read Map Select Register to select the correct bit plane\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER,\r
-      BitPlane\r
-      );\r
-\r
-    Source      = HardwareBuffer;\r
-    Destination = MemoryBuffer + FrameBufferOffset;\r
-\r
-    for (Rows = 0; Rows < Height; Rows++, Source += VGA_BYTES_PER_SCAN_LINE, Destination += VGA_BYTES_PER_SCAN_LINE) {\r
-      PciIo->Mem.Read (\r
-                  PciIo,\r
-                  EfiPciIoWidthUint8,\r
-                  (UINT8) EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                  (UINT64)(UINTN) Source,\r
-                  WidthInBytes,\r
-                  (VOID *) Destination\r
-                  );\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Internal routine to convert VGA color to Grahpics Output color\r
-\r
-\r
-  @param MemoryBuffer    - Buffer containing VGA color\r
-  @param X               - The X coordinate of pixel on screen\r
-  @param Y               - The Y coordinate of pixel on screen\r
-  @param BltBuffer       - Buffer to contain converted Grahpics Output color\r
-\r
-  @return None\r
-\r
-**/\r
-VOID\r
-VgaConvertToGraphicsOutputColor (\r
-  UINT8                          *MemoryBuffer,\r
-  UINTN                          X,\r
-  UINTN                          Y,\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer\r
-  )\r
-{\r
-  UINTN Mask;\r
-  UINTN Bit;\r
-  UINTN Color;\r
-\r
-  MemoryBuffer += ((Y << 6) + (Y << 4) + (X >> 3));\r
-  Mask = mVgaBitMaskTable[X & 0x07];\r
-  for (Bit = 0x01, Color = 0; Bit < 0x10; Bit <<= 1, MemoryBuffer += VGA_BYTES_PER_BIT_PLANE) {\r
-    if (*MemoryBuffer & Mask) {\r
-      Color |= Bit;\r
-    }\r
-  }\r
-\r
-  *BltBuffer = mVgaColorToGraphicsOutputColor[Color];\r
-}\r
-\r
-/**\r
-\r
-  Internal routine to convert Grahpics Output color to VGA color\r
-\r
-\r
-  @param BltBuffer       - buffer containing Grahpics Output color\r
-\r
-  @return Converted VGA color\r
-\r
-**/\r
-UINT8\r
-VgaConvertColor (\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL          *BltBuffer\r
-  )\r
-{\r
-  UINT8 Color;\r
-\r
-  Color = (UINT8) ((BltBuffer->Blue >> 7) | ((BltBuffer->Green >> 6) & 0x02) | ((BltBuffer->Red >> 5) & 0x04));\r
-  if ((BltBuffer->Red + BltBuffer->Green + BltBuffer->Blue) > 0x180) {\r
-    Color |= 0x08;\r
-  }\r
-\r
-  return Color;\r
-}\r
-\r
-/**\r
-  Grahpics Output protocol instance to block transfer for VGA device\r
-\r
-  @param This            Pointer to Grahpics Output protocol instance\r
-  @param BltBuffer       The data to transfer to screen\r
-  @param BltOperation    The operation to perform\r
-  @param SourceX         The X coordinate of the source for BltOperation\r
-  @param SourceY         The Y coordinate of the source for BltOperation\r
-  @param DestinationX    The X coordinate of the destination for BltOperation\r
-  @param DestinationY    The Y coordinate of the destination for BltOperation\r
-  @param Width           The width of a rectangle in the blt rectangle in pixels\r
-  @param Height          The height of a rectangle in the blt rectangle in pixels\r
-  @param Delta           Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                         If a subrectangle of the BltBuffer is used, then Delta represents\r
-                         the number of bytes in a row of the BltBuffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
-  @retval EFI_SUCCESS           Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVgaBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_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\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV      *BiosVideoPrivate;\r
-  EFI_TPL             OriginalTPL;\r
-  UINT8               *MemAddress;\r
-  UINTN               BytesPerScanLine;\r
-  //UINTN               BytesPerBitPlane;\r
-  UINTN               Bit;\r
-  UINTN               Index;\r
-  UINTN               Index1;\r
-  UINTN               StartAddress;\r
-  UINTN               Bytes;\r
-  UINTN               Offset;\r
-  UINT8               LeftMask;\r
-  UINT8               RightMask;\r
-  UINTN               Address;\r
-  UINTN               AddressFix;\r
-  UINT8               *Address1;\r
-  UINT8               *SourceAddress;\r
-  UINT8               *DestinationAddress;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  UINT8               Data;\r
-  UINT8               PixelColor;\r
-  UINT8               *VgaFrameBuffer;\r
-  UINTN               SourceOffset;\r
-  UINTN               SourceWidth;\r
-  UINTN               Rows;\r
-  UINTN               Columns;\r
-  UINTN               X;\r
-  UINTN               Y;\r
-  UINTN               CurrentMode;\r
-\r
-  BiosVideoPrivate  = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
-\r
-  CurrentMode = This->Mode->Mode;\r
-  PciIo             = BiosVideoPrivate->PciIo;\r
-  MemAddress        = BiosVideoPrivate->ModeData[CurrentMode].LinearFrameBuffer;\r
-  BytesPerScanLine  = BiosVideoPrivate->ModeData[CurrentMode].BytesPerScanLine >> 3;\r
-  //BytesPerBitPlane  = BytesPerScanLine * BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution;\r
-  VgaFrameBuffer    = BiosVideoPrivate->VgaFrameBuffer;\r
-\r
-  if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Width == 0 || Height == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // We need to fill the Virtual Screen buffer with the blt data.\r
-  // The virtual screen is upside down, as the first row is the bootom row of\r
-  // the image.\r
-  //\r
-  if (BltOperation == EfiBltVideoToBltBuffer) {\r
-    //\r
-    // Video to BltBuffer: Source is Video, destination is BltBuffer\r
-    //\r
-    if (SourceY + Height > BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (SourceX + Width > BiosVideoPrivate->ModeData[CurrentMode].HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } else {\r
-    //\r
-    // BltBuffer to Video: Source is BltBuffer, destination is Video\r
-    //\r
-    if (DestinationY + Height > BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (DestinationX + Width > BiosVideoPrivate->ModeData[CurrentMode].HorizontalResolution) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\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_GRAPHICS_OUTPUT_BLT_PIXEL);\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 (TPL_NOTIFY);\r
-\r
-  //\r
-  // Compute some values we need for VGA\r
-  //\r
-  switch (BltOperation) {\r
-  case EfiBltVideoToBltBuffer:\r
-\r
-    SourceOffset  = (SourceY << 6) + (SourceY << 4) + (SourceX >> 3);\r
-    SourceWidth   = ((SourceX + Width - 1) >> 3) - (SourceX >> 3) + 1;\r
-\r
-    //\r
-    // Read all the pixels in the 4 bit planes into a memory buffer that looks like the VGA buffer\r
-    //\r
-    VgaReadBitPlanes (\r
-      PciIo,\r
-      MemAddress + SourceOffset,\r
-      VgaFrameBuffer + SourceOffset,\r
-      SourceWidth,\r
-      Height\r
-      );\r
-\r
-    //\r
-    // Convert VGA Bit Planes to a Graphics Output 32-bit color value\r
-    //\r
-    BltBuffer += (DestinationY * (Delta >> 2) + DestinationX);\r
-    for (Rows = 0, Y = SourceY; Rows < Height; Rows++, Y++, BltBuffer += (Delta >> 2)) {\r
-      for (Columns = 0, X = SourceX; Columns < Width; Columns++, X++, BltBuffer++) {\r
-        VgaConvertToGraphicsOutputColor (VgaFrameBuffer, X, Y, BltBuffer);\r
-      }\r
-\r
-      BltBuffer -= Width;\r
-    }\r
-\r
-    break;\r
-\r
-  case EfiBltVideoToVideo:\r
-    //\r
-    // Check for an aligned Video to Video operation\r
-    //\r
-    if ((SourceX & 0x07) == 0x00 && (DestinationX & 0x07) == 0x00 && (Width & 0x07) == 0x00) {\r
-      //\r
-      // Program the Mode Register Write mode 1, Read mode 0\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-        VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1\r
-        );\r
-\r
-      SourceAddress       = (UINT8 *) (MemAddress + (SourceY << 6) + (SourceY << 4) + (SourceX >> 3));\r
-      DestinationAddress  = (UINT8 *) (MemAddress + (DestinationY << 6) + (DestinationY << 4) + (DestinationX >> 3));\r
-      Bytes               = Width >> 3;\r
-      for (Index = 0, Offset = 0; Index < Height; Index++, Offset += BytesPerScanLine) {\r
-        PciIo->CopyMem (\r
-                PciIo,\r
-                EfiPciIoWidthUint8,\r
-                EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                (UINT64) ((UINTN)DestinationAddress + Offset),\r
-                EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                (UINT64) ((UINTN)SourceAddress + Offset),\r
-                Bytes\r
-                );\r
-      }\r
-    } else {\r
-      SourceOffset  = (SourceY << 6) + (SourceY << 4) + (SourceX >> 3);\r
-      SourceWidth   = ((SourceX + Width - 1) >> 3) - (SourceX >> 3) + 1;\r
-\r
-      //\r
-      // Read all the pixels in the 4 bit planes into a memory buffer that looks like the VGA buffer\r
-      //\r
-      VgaReadBitPlanes (\r
-        PciIo,\r
-        MemAddress + SourceOffset,\r
-        VgaFrameBuffer + SourceOffset,\r
-        SourceWidth,\r
-        Height\r
-        );\r
-    }\r
-\r
-    break;\r
-\r
-  case EfiBltVideoFill:\r
-    StartAddress  = (UINTN) (MemAddress + (DestinationY << 6) + (DestinationY << 4) + (DestinationX >> 3));\r
-    Bytes         = ((DestinationX + Width - 1) >> 3) - (DestinationX >> 3);\r
-    LeftMask      = mVgaLeftMaskTable[DestinationX & 0x07];\r
-    RightMask     = mVgaRightMaskTable[(DestinationX + Width - 1) & 0x07];\r
-    if (Bytes == 0) {\r
-      LeftMask = (UINT8) (LeftMask & RightMask);\r
-      RightMask = 0;\r
-    }\r
-\r
-    if (LeftMask == 0xff) {\r
-      StartAddress--;\r
-      Bytes++;\r
-      LeftMask = 0;\r
-    }\r
-\r
-    if (RightMask == 0xff) {\r
-      Bytes++;\r
-      RightMask = 0;\r
-    }\r
-\r
-    PixelColor = VgaConvertColor (BltBuffer);\r
-\r
-    //\r
-    // Program the Mode Register Write mode 2, Read mode 0\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2\r
-      );\r
-\r
-    //\r
-    // Program the Data Rotate/Function Select Register to replace\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE\r
-      );\r
-\r
-    if (LeftMask != 0) {\r
-      //\r
-      // Program the BitMask register with the Left column mask\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-        LeftMask\r
-        );\r
-\r
-      for (Index = 0, Address = StartAddress; Index < Height; Index++, Address += BytesPerScanLine) {\r
-        //\r
-        // Read data from the bit planes into the latches\r
-        //\r
-        PciIo->Mem.Read (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) Address,\r
-                    1,\r
-                    &Data\r
-                    );\r
-        //\r
-        // Write the lower 4 bits of PixelColor to the bit planes in the pixels enabled by BitMask\r
-        //\r
-        PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) Address,\r
-                    1,\r
-                    &PixelColor\r
-                    );\r
-      }\r
-    }\r
-\r
-    if (Bytes > 1) {\r
-      //\r
-      // Program the BitMask register with the middle column mask of 0xff\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-        0xff\r
-        );\r
-\r
-      for (Index = 0, Address = StartAddress + 1; Index < Height; Index++, Address += BytesPerScanLine) {\r
-        PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthFillUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) Address,\r
-                    Bytes - 1,\r
-                    &PixelColor\r
-                    );\r
-      }\r
-    }\r
-\r
-    if (RightMask != 0) {\r
-      //\r
-      // Program the BitMask register with the Right column mask\r
-      //\r
-      WriteGraphicsController (\r
-        PciIo,\r
-        VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-        RightMask\r
-        );\r
-\r
-      for (Index = 0, Address = StartAddress + Bytes; Index < Height; Index++, Address += BytesPerScanLine) {\r
-        //\r
-        // Read data from the bit planes into the latches\r
-        //\r
-        PciIo->Mem.Read (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) Address,\r
-                    1,\r
-                    &Data\r
-                    );\r
-        //\r
-        // Write the lower 4 bits of PixelColor to the bit planes in the pixels enabled by BitMask\r
-        //\r
-        PciIo->Mem.Write (\r
-                    PciIo,\r
-                    EfiPciIoWidthUint8,\r
-                    EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                    (UINT64) Address,\r
-                    1,\r
-                    &PixelColor\r
-                    );\r
-      }\r
-    }\r
-    break;\r
-\r
-  case EfiBltBufferToVideo:\r
-    StartAddress  = (UINTN) (MemAddress + (DestinationY << 6) + (DestinationY << 4) + (DestinationX >> 3));\r
-    LeftMask      = mVgaBitMaskTable[DestinationX & 0x07];\r
-\r
-    //\r
-    // Program the Mode Register Write mode 2, Read mode 0\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_MODE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2\r
-      );\r
-\r
-    //\r
-    // Program the Data Rotate/Function Select Register to replace\r
-    //\r
-    WriteGraphicsController (\r
-      PciIo,\r
-      VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER,\r
-      VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE\r
-      );\r
-\r
-    for (Index = 0, Address = StartAddress; Index < Height; Index++, Address += BytesPerScanLine) {\r
-      for (Index1 = 0; Index1 < Width; Index1++) {\r
-        BiosVideoPrivate->LineBuffer[Index1] = VgaConvertColor (&BltBuffer[(SourceY + Index) * (Delta >> 2) + SourceX + Index1]);\r
-      }\r
-      AddressFix = Address;\r
-\r
-      for (Bit = 0; Bit < 8; Bit++) {\r
-        //\r
-        // Program the BitMask register with the Left column mask\r
-        //\r
-        WriteGraphicsController (\r
-          PciIo,\r
-          VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER,\r
-          LeftMask\r
-          );\r
-\r
-        for (Index1 = Bit, Address1 = (UINT8 *) AddressFix; Index1 < Width; Index1 += 8, Address1++) {\r
-          //\r
-          // Read data from the bit planes into the latches\r
-          //\r
-          PciIo->Mem.Read (\r
-                      PciIo,\r
-                      EfiPciIoWidthUint8,\r
-                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      (UINT64)(UINTN) Address1,\r
-                      1,\r
-                      &Data\r
-                      );\r
-\r
-          PciIo->Mem.Write (\r
-                      PciIo,\r
-                      EfiPciIoWidthUint8,\r
-                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      (UINT64)(UINTN) Address1,\r
-                      1,\r
-                      &BiosVideoPrivate->LineBuffer[Index1]\r
-                      );\r
-        }\r
-\r
-        LeftMask = (UINT8) (LeftMask >> 1);\r
-        if (LeftMask == 0) {\r
-          LeftMask = 0x80;\r
-          AddressFix++;\r
-        }\r
-      }\r
-    }\r
-\r
-    break;\r
-  default:\r
-    break;\r
-  }\r
-\r
-  gBS->RestoreTPL (OriginalTPL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// VGA Mini Port Protocol Functions\r
-//\r
-/**\r
-  VgaMiniPort protocol interface to set mode\r
-\r
-  @param This             Pointer to VgaMiniPort protocol instance\r
-  @param ModeNumber       The index of the mode\r
-\r
-  @retval EFI_UNSUPPORTED The requested mode is not supported\r
-  @retval EFI_SUCCESS     The requested mode is set successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoVgaMiniPortSetMode (\r
-  IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN  UINTN                       ModeNumber\r
-  )\r
-{\r
-  BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
-  IA32_REGISTER_SET Regs;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Make sure the ModeNumber is a valid value\r
-  //\r
-  if (ModeNumber >= This->MaxMode) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get the device structure for this device\r
-  //\r
-  BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS (This);\r
-  \r
-  gBS->SetMem (&Regs, sizeof (Regs), 0);\r
-\r
-  switch (ModeNumber) {\r
-  case 0:\r
-    //\r
-    // Set the 80x25 Text VGA Mode\r
-    //\r
-    Regs.H.AH = 0x00;\r
-    Regs.H.AL = 0x83;\r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    \r
-    Regs.H.AH = 0x11;\r
-    Regs.H.AL = 0x14;\r
-    Regs.H.BL = 0;\r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    \r
-    break;\r
-\r
-  case 1:\r
-    //\r
-    // Set the 80x50 Text VGA Mode\r
-    //\r
-    Regs.H.AH = 0x00;\r
-    Regs.H.AL = 0x83;\r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    \r
-    Regs.H.AH = 0x11;\r
-    Regs.H.AL = 0x12;\r
-    Regs.H.BL = 0;\r
-    LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-    break;\r
-\r
-  default:\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/BiosVideoThunkDxe/BiosVideo.h b/DuetPkg/BiosVideoThunkDxe/BiosVideo.h
deleted file mode 100644 (file)
index 37e303e..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#ifndef _BIOS_GRAPHICS_OUTPUT_H\r
-#define _BIOS_GRAPHICS_OUTPUT_H\r
-\r
-#include <Uefi.h>\r
-\r
-//\r
-// Driver Consumed Protocol Prototypes\r
-//\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/DriverBinding.h>\r
-#include <Protocol/ComponentName.h>\r
-#include <Protocol/ComponentName2.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/VgaMiniPort.h>\r
-#include <Protocol/Legacy8259.h>\r
-#include <Protocol/EdidActive.h>\r
-#include <Protocol/EdidDiscovered.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/UefiLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#include "VesaBiosExtensions.h"\r
-\r
-//\r
-// Packed format support: The number of bits reserved for each of the colors and the actual\r
-// position of RGB in the frame buffer is specified in the VBE Mode information\r
-//\r
-typedef struct {\r
-  UINT8 Position; // Position of the color\r
-  UINT8 Mask;     // The number of bits expressed as a mask\r
-} BIOS_VIDEO_COLOR_PLACEMENT;\r
-\r
-//\r
-// BIOS Graphics Output Graphical Mode Data\r
-//\r
-typedef struct {\r
-  UINT16                      VbeModeNumber;\r
-  UINT16                      BytesPerScanLine;\r
-  VOID                        *LinearFrameBuffer;\r
-  UINTN                       FrameBufferSize;\r
-  UINT32                      HorizontalResolution;\r
-  UINT32                      VerticalResolution;\r
-  UINT32                      RefreshRate;\r
-  UINT32                      BitsPerPixel;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Red;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Green;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Blue;\r
-  BIOS_VIDEO_COLOR_PLACEMENT  Reserved;\r
-  EFI_GRAPHICS_PIXEL_FORMAT   PixelFormat;\r
-  EFI_PIXEL_BITMASK           PixelBitMask;\r
-} BIOS_VIDEO_MODE_DATA;\r
-\r
-//\r
-// BIOS video child handle private data Structure\r
-//\r
-#define BIOS_VIDEO_DEV_SIGNATURE    SIGNATURE_32 ('B', 'V', 'M', 'p')\r
-\r
-typedef struct {\r
-  UINTN                                       Signature;\r
-  EFI_HANDLE                                  Handle;\r
-\r
-  //\r
-  // Consumed Protocols inherited from parent controller.\r
-  //\r
-  EFI_PCI_IO_PROTOCOL                         *PciIo;\r
-  EFI_LEGACY_8259_PROTOCOL                    *Legacy8259;\r
-  THUNK_CONTEXT                               *ThunkContext;\r
-  \r
-  //\r
-  // Produced Protocols\r
-  //\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL                GraphicsOutput;\r
-  EFI_EDID_DISCOVERED_PROTOCOL                EdidDiscovered;\r
-  EFI_EDID_ACTIVE_PROTOCOL                    EdidActive;\r
-  EFI_VGA_MINI_PORT_PROTOCOL                  VgaMiniPort;\r
-\r
-  //\r
-  // General fields\r
-  //\r
-  BOOLEAN                                     VgaCompatible;\r
-  BOOLEAN                                     ProduceGraphicsOutput;\r
-\r
-  //\r
-  // Graphics Output Protocol related fields\r
-  //\r
-  BOOLEAN                                     HardwareNeedsStarting;\r
-  BIOS_VIDEO_MODE_DATA                        *ModeData;\r
-  UINT8                                       *LineBuffer;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL               *VbeFrameBuffer;\r
-  UINT8                                       *VgaFrameBuffer;\r
-\r
-  //\r
-  // VESA Bios Extensions related fields\r
-  //\r
-  UINTN                                       NumberOfPagesBelow1MB;    // Number of 4KB pages in PagesBelow1MB\r
-  EFI_PHYSICAL_ADDRESS                        PagesBelow1MB;            // Buffer for all VBE Information Blocks\r
-  VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK      *VbeInformationBlock;     // 0x200 bytes.  Must be allocated below 1MB\r
-  VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock; // 0x100 bytes.  Must be allocated below 1MB\r
-  VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK        *VbeEdidDataBlock;        // 0x80  bytes.  Must be allocated below 1MB\r
-  VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *VbeCrtcInformationBlock; // 59 bytes.  Must be allocated below 1MB\r
-  UINTN                                       VbeSaveRestorePages;      // Number of 4KB pages in VbeSaveRestoreBuffer\r
-  EFI_PHYSICAL_ADDRESS                        VbeSaveRestoreBuffer;     // Must be allocated below 1MB\r
-  //\r
-  // Status code\r
-  //\r
-  EFI_DEVICE_PATH_PROTOCOL                    *DevicePath;\r
-} BIOS_VIDEO_DEV;\r
-\r
-#define BIOS_VIDEO_DEV_FROM_PCI_IO_THIS(a)      CR (a, BIOS_VIDEO_DEV, PciIo, BIOS_VIDEO_DEV_SIGNATURE)\r
-#define BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a)      CR (a, BIOS_VIDEO_DEV, GraphicsOutput, BIOS_VIDEO_DEV_SIGNATURE)\r
-#define BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS(a) CR (a, BIOS_VIDEO_DEV, VgaMiniPort, BIOS_VIDEO_DEV_SIGNATURE)\r
-\r
-#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER  0xffff\r
-\r
-#define EFI_SEGMENT(_Adr)     (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)\r
-#define EFI_OFFSET(_Adr)      (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL   gBiosVideoDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL   gBiosVideoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gBiosVideoComponentName2;\r
-\r
-//\r
-// Driver Binding Protocol functions\r
-//\r
-/**\r
-  Test to see if Bios Video could be supported on the Controller.\r
-\r
-  @param This                  Pointer to driver binding protocol\r
-  @param Controller            Controller handle to connect\r
-  @param RemainingDevicePath   A pointer to the remaining portion of a device path\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device.\r
-  @retval other               This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  Install Graphics Output Protocol onto VGA device handles\r
-\r
-  @param This                   Pointer to driver binding protocol\r
-  @param Controller             Controller handle to connect\r
-  @param RemainingDevicePath    A pointer to the remaining portion of a device path\r
-\r
-  @return EFI_STATUS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  Stop this driver on Controller \r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  Controller        Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       This driver is removed Controller.\r
-  @retval other             This driver was not removed from this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Controller,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-;\r
-\r
-//\r
-// Private worker functions\r
-//\r
-/**\r
-  Check for VBE device\r
-\r
-  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS VBE device found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoCheckForVbe (\r
-  IN OUT BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-;\r
-\r
-/**\r
-  Check for VGA device\r
-\r
-  @param BiosVideoPrivate - Pointer to BIOS_VIDEO_DEV structure\r
-\r
-  @retval EFI_SUCCESS  Standard VGA device found\r
-**/\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoCheckForVga (\r
-  BIOS_VIDEO_DEV  *BiosVideoPrivate\r
-  )\r
-;\r
-\r
-/**\r
-  Collect the resource from destroyed bios video device.\r
-\r
-  @param BiosVideoPrivate   Video child device private data structure\r
-\r
-**/\r
-VOID\r
-BiosVideoDeviceReleaseResource (\r
-  BIOS_VIDEO_DEV  *BiosVideoChildPrivate\r
-  )\r
-;\r
-\r
-//\r
-// BIOS Graphics Output Protocol functions\r
-//\r
-/**\r
-\r
-  Graphics Output protocol interface to get video mode\r
-\r
-\r
-  @param This            - Protocol instance pointer.\r
-  @param ModeNumber      - The mode number to return information on.\r
-  @param SizeOfInfo      - A pointer to the size, in bytes, of the Info buffer.\r
-  @param Info            - Caller allocated buffer that returns information about ModeNumber.\r
-\r
-  @return EFI_SUCCESS           - Mode information returned.\r
-          EFI_DEVICE_ERROR      - A hardware error occurred trying to retrieve the video mode.\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
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputQueryMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,\r
-  IN  UINT32                                ModeNumber,\r
-  OUT UINTN                                 *SizeOfInfo,\r
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info\r
-  )\r
-;\r
-\r
-/**\r
-\r
-  Graphics Output protocol interface to set video mode\r
-\r
-\r
-  @param This            - Protocol instance pointer.\r
-  @param ModeNumber      - The mode number to be set.\r
-\r
-  @return EFI_SUCCESS      - Graphics mode was changed.\r
-          EFI_DEVICE_ERROR - The device had an error and could not complete the request.\r
-          EFI_UNSUPPORTED  - ModeNumber is not supported by this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputSetMode (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
-  IN  UINT32                       ModeNumber\r
-  )\r
-;\r
-\r
-/**\r
-\r
-  Graphics Output protocol instance to block transfer for VBE device\r
-\r
-\r
-  @param This            - Pointer to Graphics Output protocol instance\r
-  @param BltBuffer       - The data to transfer to screen\r
-  @param BltOperation    - The operation to perform\r
-  @param SourceX         - The X coordinate of the source for BltOperation\r
-  @param SourceY         - The Y coordinate of the source for BltOperation\r
-  @param DestinationX    - The X coordinate of the destination for BltOperation\r
-  @param DestinationY    - The Y coordinate of the destination for BltOperation\r
-  @param Width           - The width of a rectangle in the blt rectangle in pixels\r
-  @param Height          - The height of a rectangle in the blt rectangle in pixels\r
-  @param Delta           - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                         If a subrectangle of the BltBuffer is used, then Delta represents\r
-                         the number of bytes in a row of the BltBuffer.\r
-\r
-  @return EFI_INVALID_PARAMETER - Invalid parameter passed in\r
-          EFI_SUCCESS - Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVbeBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_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\r
-  )\r
-;\r
-\r
-/**\r
-  Grahpics Output protocol instance to block transfer for VGA device\r
-\r
-  @param This            Pointer to Grahpics Output protocol instance\r
-  @param BltBuffer       The data to transfer to screen\r
-  @param BltOperation    The operation to perform\r
-  @param SourceX         The X coordinate of the source for BltOperation\r
-  @param SourceY         The Y coordinate of the source for BltOperation\r
-  @param DestinationX    The X coordinate of the destination for BltOperation\r
-  @param DestinationY    The Y coordinate of the destination for BltOperation\r
-  @param Width           The width of a rectangle in the blt rectangle in pixels\r
-  @param Height          The height of a rectangle in the blt rectangle in pixels\r
-  @param Delta           Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
-                         If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
-                         If a subrectangle of the BltBuffer is used, then Delta represents\r
-                         the number of bytes in a row of the BltBuffer.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
-  @retval EFI_SUCCESS           Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoGraphicsOutputVgaBlt (\r
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL       *This,\r
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL\r
-  IN  EFI_GRAPHICS_OUTPUT_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\r
-  )\r
-;\r
-\r
-//\r
-// BIOS VGA Mini Port Protocol functions\r
-//\r
-/**\r
-  VgaMiniPort protocol interface to set mode\r
-\r
-  @param This             Pointer to VgaMiniPort protocol instance\r
-  @param ModeNumber       The index of the mode\r
-\r
-  @retval EFI_UNSUPPORTED The requested mode is not supported\r
-  @retval EFI_SUCCESS     The requested mode is set successfully\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoVgaMiniPortSetMode (\r
-  IN  EFI_VGA_MINI_PORT_PROTOCOL  *This,\r
-  IN  UINTN                       ModeNumber\r
-  )\r
-;\r
-\r
-/**\r
-  Judge whether this device is VGA device.\r
-\r
-  @param PciIo      Parent PciIo protocol instance pointer\r
-\r
-  @retval TRUE  Is vga device\r
-  @retval FALSE Is no vga device\r
-**/\r
-BOOLEAN\r
-BiosVideoIsVga (\r
-  IN  EFI_PCI_IO_PROTOCOL       *PciIo\r
-  )\r
-;\r
-\r
-\r
-//\r
-// Standard VGA Definitions\r
-//\r
-#define VGA_HORIZONTAL_RESOLUTION                         640\r
-#define VGA_VERTICAL_RESOLUTION                           480\r
-#define VGA_NUMBER_OF_BIT_PLANES                          4\r
-#define VGA_PIXELS_PER_BYTE                               8\r
-#define VGA_BYTES_PER_SCAN_LINE                           (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS_PER_BYTE)\r
-#define VGA_BYTES_PER_BIT_PLANE                           (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PER_SCAN_LINE)\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER          0x3ce\r
-#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER             0x3cf\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER        0x00\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER    0x02\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER      0x03\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE          0x00\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND              0x08\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR               0x10\r
-#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR              0x18\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER  0x04\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER             0x05\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0               0x00\r
-#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1               0x08\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0              0x00\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1              0x01\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2              0x02\r
-#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3              0x03\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER    0x06\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER  0x07\r
-\r
-#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER         0x08\r
-\r
-/**\r
-  Initialize legacy environment for BIOS INI caller.\r
-  \r
-  @param ThunkContext   the instance pointer of THUNK_CONTEXT\r
-**/\r
-VOID\r
-InitializeBiosIntCaller (\r
-  THUNK_CONTEXT     *ThunkContext\r
-  );\r
-  \r
-/**\r
-   Initialize interrupt redirection code and entries, because\r
-   IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
-   Or the interrupt will lost when we do thunk.\r
-   NOTE: We do not reset 8259 vector base, because it will cause pending\r
-   interrupt lost.\r
-   \r
-   @param Legacy8259  Instance pointer for EFI_LEGACY_8259_PROTOCOL.\r
-   \r
-**/  \r
-VOID\r
-InitializeInterruptRedirection (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *Legacy8259\r
-  );\r
-  \r
-/**\r
-  Thunk to 16-bit real mode and execute a software interrupt with a vector \r
-  of BiosInt. Regs will contain the 16-bit register context on entry and \r
-  exit.\r
-  \r
-  @param  This    Protocol instance pointer.\r
-  @param  BiosInt Processor interrupt vector to invoke\r
-  @param  Reg     Register contexted passed into (and returned) from thunk to 16-bit mode\r
-  \r
-  @retval TRUE   Thunk completed, and there were no BIOS errors in the target code.\r
-                 See Regs for status.\r
-  @retval FALSE  There was a BIOS erro in the target code.  \r
-**/  \r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosInt86 (\r
-  IN  BIOS_VIDEO_DEV                 *BiosDev,\r
-  IN  UINT8                           BiosInt,\r
-  IN  IA32_REGISTER_SET           *Regs\r
-  );    \r
-  \r
-#endif\r
diff --git a/DuetPkg/BiosVideoThunkDxe/BiosVideo.inf b/DuetPkg/BiosVideoThunkDxe/BiosVideo.inf
deleted file mode 100644 (file)
index 82243c0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-## @file\r
-#  This module provides EFI_GRAPHIC_OUT_PROTOCOL based on functions of video \r
-#  on legacy BIOS.\r
-#  \r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#  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.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = BiosVideo\r
-  FILE_GUID                      = 29CF55F8-B675-4f5d-8F2F-B87A3ECFD063\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = BiosVideoDriverEntryPoint\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiLib\r
-  DebugLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  UefiDriverEntryPoint\r
-  DevicePathLib\r
-  \r
-[Sources]\r
-  BiosVideo.h\r
-  BiosVideo.c\r
-  ComponentName.c\r
-  VesaBiosExtensions.h\r
-  LegacyBiosThunk.c\r
-  \r
-[Protocols]\r
-  gEfiPciIoProtocolGuid\r
-  gEfiVgaMiniPortProtocolGuid\r
-  gEfiLegacy8259ProtocolGuid\r
-  gEfiEdidDiscoveredProtocolGuid\r
-  gEfiEdidActiveProtocolGuid\r
diff --git a/DuetPkg/BiosVideoThunkDxe/ComponentName.c b/DuetPkg/BiosVideoThunkDxe/ComponentName.c
deleted file mode 100644 (file)
index 364bc3b..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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 "BiosVideo.h"\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetControllerName (\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
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gBiosVideoComponentName = {\r
-  BiosVideoComponentNameGetDriverName,\r
-  BiosVideoComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosVideoComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosVideoComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-static EFI_UNICODE_STRING_TABLE mBiosVideoDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"BIOS[INT10] Video Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetDriverName (\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 LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mBiosVideoDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gBiosVideoComponentName)\r
-           );          \r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BiosVideoComponentNameGetControllerName (\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
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/DuetPkg/BiosVideoThunkDxe/LegacyBiosThunk.c b/DuetPkg/BiosVideoThunkDxe/LegacyBiosThunk.c
deleted file mode 100644 (file)
index 6dc453f..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/** @file\r
-  Provide legacy thunk interface for accessing Bios Video Rom.\r
-  \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#include "BiosVideo.h"\r
-\r
-#define EFI_CPU_EFLAGS_IF 0x200\r
-\r
-/**\r
-  Initialize legacy environment for BIOS INI caller.\r
-  \r
-  @param ThunkContext   the instance pointer of THUNK_CONTEXT\r
-**/\r
-VOID\r
-InitializeBiosIntCaller (\r
-  THUNK_CONTEXT     *ThunkContext\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  UINT32                RealModeBufferSize;\r
-  UINT32                ExtraStackSize;\r
-  EFI_PHYSICAL_ADDRESS  LegacyRegionBase;\r
-  UINT32                LegacyRegionSize;\r
-  //\r
-  // Get LegacyRegion\r
-  //\r
-  AsmGetThunk16Properties (&RealModeBufferSize, &ExtraStackSize);\r
-  LegacyRegionSize = (((RealModeBufferSize + ExtraStackSize) / EFI_PAGE_SIZE) + 1) * EFI_PAGE_SIZE;\r
-  LegacyRegionBase = 0x100000;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIMemoryNVS,\r
-                  EFI_SIZE_TO_PAGES(LegacyRegionSize),\r
-                  &LegacyRegionBase\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  ThunkContext->RealModeBuffer     = (VOID*)(UINTN)LegacyRegionBase;\r
-  ThunkContext->RealModeBufferSize = LegacyRegionSize;\r
-  ThunkContext->ThunkAttributes    = THUNK_ATTRIBUTE_BIG_REAL_MODE|THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15;\r
-  AsmPrepareThunk16(ThunkContext);\r
-}\r
-\r
-/**\r
-   Initialize interrupt redirection code and entries, because\r
-   IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.\r
-   Or the interrupt will lost when we do thunk.\r
-   NOTE: We do not reset 8259 vector base, because it will cause pending\r
-   interrupt lost.\r
-   \r
-   @param Legacy8259  Instance pointer for EFI_LEGACY_8259_PROTOCOL.\r
-   \r
-**/\r
-VOID\r
-InitializeInterruptRedirection (\r
-  IN  EFI_LEGACY_8259_PROTOCOL  *Legacy8259\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  LegacyRegionBase;\r
-  UINTN                 LegacyRegionLength;\r
-  UINT32                *IdtArray;\r
-  UINTN                 Index;\r
-  UINT8                 ProtectedModeBaseVector;\r
-  UINT32                InterruptRedirectionCode[] = {\r
-    0x90CF08CD, // INT8; IRET; NOP\r
-    0x90CF09CD, // INT9; IRET; NOP\r
-    0x90CF0ACD, // INTA; IRET; NOP\r
-    0x90CF0BCD, // INTB; IRET; NOP\r
-    0x90CF0CCD, // INTC; IRET; NOP\r
-    0x90CF0DCD, // INTD; IRET; NOP\r
-    0x90CF0ECD, // INTE; IRET; NOP\r
-    0x90CF0FCD  // INTF; IRET; NOP\r
-  };\r
-\r
-  //\r
-  // Get LegacyRegion\r
-  //\r
-  LegacyRegionLength = sizeof(InterruptRedirectionCode);\r
-  LegacyRegionBase = 0x100000;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIMemoryNVS,\r
-                  EFI_SIZE_TO_PAGES(LegacyRegionLength),\r
-                  &LegacyRegionBase\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Copy code to legacy region\r
-  //\r
-  CopyMem ((VOID *)(UINTN)LegacyRegionBase, InterruptRedirectionCode, sizeof (InterruptRedirectionCode));\r
-\r
-  //\r
-  // Get VectorBase, it should be 0x68\r
-  //\r
-  Status = Legacy8259->GetVector (Legacy8259, Efi8259Irq0, &ProtectedModeBaseVector);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Patch IVT 0x68 ~ 0x6f\r
-  //\r
-  IdtArray = (UINT32 *) 0;\r
-  for (Index = 0; Index < 8; Index++) {\r
-    IdtArray[ProtectedModeBaseVector + Index] = ((EFI_SEGMENT (LegacyRegionBase + Index * 4)) << 16) | (EFI_OFFSET (LegacyRegionBase + Index * 4));\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-/**\r
-  Thunk to 16-bit real mode and execute a software interrupt with a vector \r
-  of BiosInt. Regs will contain the 16-bit register context on entry and \r
-  exit.\r
-  \r
-  @param  This    Protocol instance pointer.\r
-  @param  BiosInt Processor interrupt vector to invoke\r
-  @param  Reg     Register contexted passed into (and returned) from thunk to 16-bit mode\r
-  \r
-  @retval TRUE   Thunk completed, and there were no BIOS errors in the target code.\r
-                 See Regs for status.\r
-  @retval FALSE  There was a BIOS erro in the target code.  \r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-LegacyBiosInt86 (\r
-  IN  BIOS_VIDEO_DEV                 *BiosDev,\r
-  IN  UINT8                           BiosInt,\r
-  IN  IA32_REGISTER_SET              *Regs\r
-  )\r
-{\r
-  UINTN                 Status;\r
-  IA32_REGISTER_SET     ThunkRegSet;\r
-  BOOLEAN               Ret;\r
-  UINT16                *Stack16;\r
-  BOOLEAN               Enabled;\r
-  \r
-  ZeroMem (&ThunkRegSet, sizeof (ThunkRegSet));\r
-  ThunkRegSet.E.EFLAGS.Bits.Reserved_0 = 1;\r
-  ThunkRegSet.E.EFLAGS.Bits.Reserved_1 = 0;\r
-  ThunkRegSet.E.EFLAGS.Bits.Reserved_2 = 0;\r
-  ThunkRegSet.E.EFLAGS.Bits.Reserved_3 = 0;\r
-  ThunkRegSet.E.EFLAGS.Bits.IOPL       = 3;\r
-  ThunkRegSet.E.EFLAGS.Bits.NT         = 0;\r
-  ThunkRegSet.E.EFLAGS.Bits.IF         = 1;\r
-  ThunkRegSet.E.EFLAGS.Bits.TF         = 0;\r
-  ThunkRegSet.E.EFLAGS.Bits.CF         = 0;\r
-  \r
-  ThunkRegSet.E.EDI  = Regs->E.EDI;\r
-  ThunkRegSet.E.ESI  = Regs->E.ESI;\r
-  ThunkRegSet.E.EBP  = Regs->E.EBP;\r
-  ThunkRegSet.E.EBX  = Regs->E.EBX;\r
-  ThunkRegSet.E.EDX  = Regs->E.EDX;\r
-  ThunkRegSet.E.ECX  = Regs->E.ECX;\r
-  ThunkRegSet.E.EAX  = Regs->E.EAX;\r
-  ThunkRegSet.E.DS   = Regs->E.DS;\r
-  ThunkRegSet.E.ES   = Regs->E.ES;\r
-\r
-  //\r
-  // The call to Legacy16 is a critical section to EFI\r
-  //\r
-  Enabled = SaveAndDisableInterrupts();\r
-\r
-  //\r
-  // Set Legacy16 state. 0x08, 0x70 is legacy 8259 vector bases.\r
-  //\r
-  Status = BiosDev->Legacy8259->SetMode (BiosDev->Legacy8259, Efi8259LegacyMode, NULL, NULL);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  Stack16 = (UINT16 *)((UINT8 *) BiosDev->ThunkContext->RealModeBuffer + BiosDev->ThunkContext->RealModeBufferSize - sizeof (UINT16));\r
-\r
-  ThunkRegSet.E.SS   = (UINT16) (((UINTN) Stack16 >> 16) << 12);\r
-  ThunkRegSet.E.ESP  = (UINT16) (UINTN) Stack16;\r
-\r
-  ThunkRegSet.E.Eip  = (UINT16)((UINT32 *)NULL)[BiosInt];\r
-  ThunkRegSet.E.CS   = (UINT16)(((UINT32 *)NULL)[BiosInt] >> 16);\r
-  BiosDev->ThunkContext->RealModeState = &ThunkRegSet;\r
-  AsmThunk16 (BiosDev->ThunkContext);\r
-  \r
-  //\r
-  // Restore protected mode interrupt state\r
-  //\r
-  Status = BiosDev->Legacy8259->SetMode (BiosDev->Legacy8259, Efi8259ProtectedMode, NULL, NULL);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // End critical section\r
-  //\r
-  SetInterruptState (Enabled);\r
-\r
-  Regs->E.EDI      = ThunkRegSet.E.EDI;      \r
-  Regs->E.ESI      = ThunkRegSet.E.ESI;  \r
-  Regs->E.EBP      = ThunkRegSet.E.EBP;  \r
-  Regs->E.EBX      = ThunkRegSet.E.EBX;  \r
-  Regs->E.EDX      = ThunkRegSet.E.EDX;  \r
-  Regs->E.ECX      = ThunkRegSet.E.ECX;  \r
-  Regs->E.EAX      = ThunkRegSet.E.EAX;\r
-  Regs->E.SS       = ThunkRegSet.E.SS;\r
-  Regs->E.CS       = ThunkRegSet.E.CS;  \r
-  Regs->E.DS       = ThunkRegSet.E.DS;  \r
-  Regs->E.ES       = ThunkRegSet.E.ES;\r
-\r
-  CopyMem (&(Regs->E.EFLAGS), &(ThunkRegSet.E.EFLAGS), sizeof (UINT32));\r
-\r
-  Ret = (BOOLEAN) (Regs->E.EFLAGS.Bits.CF == 1);\r
-\r
-  return Ret;\r
-}\r
-\r
-\r
diff --git a/DuetPkg/BiosVideoThunkDxe/VesaBiosExtensions.h b/DuetPkg/BiosVideoThunkDxe/VesaBiosExtensions.h
deleted file mode 100644 (file)
index f27cf11..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  VesaBiosExtensions.h\r
-\r
-Abstract:\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _VESA_BIOS_EXTENSIONS_H\r
-#define _VESA_BIOS_EXTENSIONS_H\r
-\r
-//\r
-// Turn on byte packing of data structures\r
-//\r
-#pragma pack(1)\r
-//\r
-// VESA BIOS Extensions status codes\r
-//\r
-#define VESA_BIOS_EXTENSIONS_STATUS_SUCCESS 0x004f\r
-\r
-//\r
-// VESA BIOS Extensions Services\r
-//\r
-#define VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION  0x4f00\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 00 : Return Controller Information\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f00\r
-      ES:DI = Pointer to buffer to place VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK structure\r
-    Outputs:\r
-      AX    = Return Status\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION  0x4f01\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 01 : Return Mode Information\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f01\r
-      CX    = Mode Number\r
-      ES:DI = Pointer to buffer to place VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK structure\r
-    Outputs:\r
-      AX    = Return Status\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_SET_MODE 0x4f02\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 02 : Set Mode\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f02\r
-      BX    = Desired mode to set\r
-        D0-D8   = Mode Number\r
-        D9-D10  = Reserved (must be 0)\r
-        D11     = 0 - Use current default refresh rate\r
-                = 1 - Use user specfieid CRTC values for refresh rate\r
-        D12-D13 = Reserved (must be 0)\r
-        D14     = 0 - Use windowed frame buffer model\r
-                = 1 - Use linear/flat frame buffer model\r
-        D15     = 0 - Clear display memory\r
-                = 1 - Don't clear display memory\r
-      ES:DI = Pointer to buffer to the VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK structure\r
-    Outputs:\r
-      AX    = Return Status\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_RETURN_CURRENT_MODE  0x4f03\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 03 : Return Current Mode\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f03\r
-    Outputs:\r
-      AX    = Return Status\r
-      BX    = Current mode\r
-        D0-D13  = Mode Number\r
-        D14     = 0 - Windowed frame buffer model\r
-                = 1 - Linear/flat frame buffer model\r
-        D15     = 0 - Memory cleared at last mode set\r
-                = 1 - Memory not cleared at last mode set\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_SAVE_RESTORE_STATE 0x4f04\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 04 : Save/Restore State\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f03\r
-      DL    = 0x00 - Return Save/Restore State buffer size\r
-            = 0x01 - Save State\r
-            = 0x02 - Restore State\r
-      CX    = Requested Status\r
-        D0  = Save/Restore controller hardware state\r
-        D1  = Save/Restore BIOS data state\r
-        D2  = Save/Restore DAC state\r
-        D3  = Save/Restore Regsiter state\r
-      ES:BX = Pointer to buffer if DL=1 or DL=2\r
-    Outputs:\r
-      AX    = Return Status\r
-      BX    = Number of 64 byte blocks to hold the state buffer if DL=0\r
-\r
---*/\r
-#define VESA_BIOS_EXTENSIONS_EDID  0x4f15\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Function 15 : implement VBE/DDC service\r
-\r
-  Arguments:\r
-    Inputs:\r
-      AX    = 0x4f15\r
-      BL    = 0x00 - Report VBE/DDC Capabilities\r
-      CX    = 0x00 - Controller unit number (00 = primary controller)\r
-      ES:DI = Null pointer, must be 0:0 in version 1.0\r
-    Outputs:\r
-      AX    = Return Status\r
-      BH    = Approx. time in seconds, rounded up, to transfer one EDID block(128 bytes)\r
-      BL    = DDC level supported\r
-        D0  = 0 DDC1 not supported\r
-            = 1 DDC1 supported\r
-        D1  = 0 DDC2 not supported\r
-            = 1 DDC2 supported\r
-        D2  = 0 Screen not blanked during data transfer\r
-            = 1 Screen blanked during data transfer\r
-\r
-    Inputs:\r
-      AX    = 0x4f15\r
-      BL    = 0x01 - Read EDID\r
-      CX    = 0x00 - Controller unit number (00 = primary controller)\r
-      DX    = 0x00 - EDID block number\r
-      ES:DI = Pointer to buffer in which the EDID block is returned\r
-    Outputs:\r
-      AX    = Return Status\r
---*/\r
-\r
-//\r
-// Timing data from EDID data block\r
-//\r
-#define VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE                    128\r
-#define VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER 17\r
-\r
-typedef struct {\r
-  UINT16  HorizontalResolution;\r
-  UINT16  VerticalResolution;\r
-  UINT16  RefreshRate;\r
-} VESA_BIOS_EXTENSIONS_EDID_TIMING;\r
-\r
-typedef struct {\r
-  UINT32  ValidNumber;\r
-  UINT32  Key[VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER];\r
-} VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING;\r
-\r
-typedef struct {\r
-  UINT8   Header[8];                        //EDID header "00 FF FF FF FF FF FF 00"\r
-  UINT16  ManufactureName;                  //EISA 3-character ID\r
-  UINT16  ProductCode;                      //Vendor assigned code\r
-  UINT32  SerialNumber;                     //32-bit serial number\r
-  UINT8   WeekOfManufacture;                //Week number\r
-  UINT8   YearOfManufacture;                //Year\r
-  UINT8   EdidVersion;                      //EDID Structure Version\r
-  UINT8   EdidRevision;                     //EDID Structure Revision\r
-  UINT8   VideoInputDefinition;\r
-  UINT8   MaxHorizontalImageSize;           //cm\r
-  UINT8   MaxVerticalImageSize;             //cm\r
-  UINT8   DisplayTransferCharacteristic;\r
-  UINT8   FeatureSupport;\r
-  UINT8   RedGreenLowBits;                  //Rx1 Rx0 Ry1 Ry0 Gx1 Gx0 Gy1Gy0\r
-  UINT8   BlueWhiteLowBits;                 //Bx1 Bx0 By1 By0 Wx1 Wx0 Wy1 Wy0\r
-  UINT8   RedX;                             //Red-x Bits 9 - 2\r
-  UINT8   RedY;                             //Red-y Bits 9 - 2\r
-  UINT8   GreenX;                           //Green-x Bits 9 - 2\r
-  UINT8   GreenY;                           //Green-y Bits 9 - 2\r
-  UINT8   BlueX;                            //Blue-x Bits 9 - 2\r
-  UINT8   BlueY;                            //Blue-y Bits 9 - 2\r
-  UINT8   WhiteX;                           //White-x Bits 9 - 2\r
-  UINT8   WhiteY;                           //White-x Bits 9 - 2\r
-  UINT8   EstablishedTimings[3];\r
-  UINT8   StandardTimingIdentification[16];\r
-  UINT8   DetailedTimingDescriptions[72];\r
-  UINT8   ExtensionFlag;                    //Number of (optional) 128-byte EDID extension blocks to follow\r
-  UINT8   Checksum;\r
-} VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK;\r
-\r
-//\r
-// Super VGA Information Block\r
-//\r
-typedef struct {\r
-  UINT32  VESASignature;      // 'VESA' 4 byte signature\r
-  UINT16  VESAVersion;        // VBE version number\r
-  UINT32  OEMStringPtr;       // Pointer to OEM string\r
-  UINT32  Capabilities;       // Capabilities of video card\r
-  UINT32  VideoModePtr;       // Pointer to an array of 16-bit supported modes values terminated by 0xFFFF\r
-  UINT16  TotalMemory;        // Number of 64kb memory blocks\r
-  UINT16  OemSoftwareRev;     // VBE implementation Software revision\r
-  UINT32  OemVendorNamePtr;   // VbeFarPtr to Vendor Name String\r
-  UINT32  OemProductNamePtr;  // VbeFarPtr to Product Name String\r
-  UINT32  OemProductRevPtr;   // VbeFarPtr to Product Revision String\r
-  UINT8   Reserved[222];      // Reserved for VBE implementation scratch area\r
-  UINT8   OemData[256];       // Data area for OEM strings.  Pad to 512 byte block size\r
-} VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK;\r
-\r
-//\r
-// Super VGA Information Block VESASignature values\r
-//\r
-#define VESA_BIOS_EXTENSIONS_VESA_SIGNATURE SIGNATURE_32 ('V', 'E', 'S', 'A')\r
-#define VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE SIGNATURE_32 ('V', 'B', 'E', '2')\r
-\r
-//\r
-// Super VGA Information Block VESAVersion values\r
-//\r
-#define VESA_BIOS_EXTENSIONS_VERSION_1_2  0x0102\r
-#define VESA_BIOS_EXTENSIONS_VERSION_2_0  0x0200\r
-#define VESA_BIOS_EXTENSIONS_VERSION_3_0  0x0300\r
-\r
-//\r
-// Super VGA Information Block Capabilities field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_8_BIT_DAC 0x01  // 0: DAC width is fixed at 6 bits/color\r
-// 1: DAC width switchable to 8 bits/color\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_VGA 0x02  // 0: Controller is VGA compatible\r
-// 1: Controller is not VGA compatible\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_NORMAL_RAMDAC 0x04  // 0: Normal RAMDAC operation\r
-// 1: Use blank bit in function 9 to program RAMDAC\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_STEREOSCOPIC  0x08  // 0: No hardware stereoscopic signal support\r
-// 1: Hardware stereoscopic signal support\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CAPABILITY_VESA_EVC  0x10  // 0: Stero signaling supported via external VESA stereo connector\r
-// 1: Stero signaling supported via VESA EVC connector\r
-//\r
-// Super VGA mode number bite field definitions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA 0x0100  // 0: Not a VESA defined VBE mode\r
-// 1: A VESA defined VBE mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_REFRESH_CONTROL_USER 0x0800  // 0: Use current BIOS default referesh rate\r
-// 1: Use the user specified CRTC values for refresh rate\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER  0x4000  // 0: Use a banked/windowed frame buffer\r
-// 1: Use a linear/flat frame buffer\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_PRESERVE_MEMORY  0x8000  // 0: Clear display memory\r
-// 1: Preseve display memory\r
-//\r
-// Super VGA Information Block mode list terminator value\r
-//\r
-#define VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST 0xffff\r
-\r
-//\r
-// Window Function\r
-//\r
-typedef\r
-VOID\r
-(*VESA_BIOS_EXTENSIONS_WINDOW_FUNCTION) (\r
-  VOID\r
-  );\r
-\r
-//\r
-// Super VGA Mode Information Block\r
-//\r
-typedef struct {\r
-  //\r
-  // Manadory fields for all VESA Bios Extensions revisions\r
-  //\r
-  UINT16                                ModeAttributes;   // Mode attributes\r
-  UINT8                                 WinAAttributes;   // Window A attributes\r
-  UINT8                                 WinBAttributes;   // Window B attributes\r
-  UINT16                                WinGranularity;   // Window granularity in k\r
-  UINT16                                WinSize;          // Window size in k\r
-  UINT16                                WinASegment;      // Window A segment\r
-  UINT16                                WinBSegment;      // Window B segment\r
-  UINT32                                WindowFunction;   // Pointer to window function\r
-  UINT16                                BytesPerScanLine; // Bytes per scanline\r
-  //\r
-  // Manadory fields for VESA Bios Extensions 1.2 and above\r
-  //\r
-  UINT16                                XResolution;          // Horizontal resolution\r
-  UINT16                                YResolution;          // Vertical resolution\r
-  UINT8                                 XCharSize;            // Character cell width\r
-  UINT8                                 YCharSize;            // Character cell height\r
-  UINT8                                 NumberOfPlanes;       // Number of memory planes\r
-  UINT8                                 BitsPerPixel;         // Bits per pixel\r
-  UINT8                                 NumberOfBanks;        // Number of CGA style banks\r
-  UINT8                                 MemoryModel;          // Memory model type\r
-  UINT8                                 BankSize;             // Size of CGA style banks\r
-  UINT8                                 NumberOfImagePages;   // Number of images pages\r
-  UINT8                                 Reserved1;            // Reserved\r
-  UINT8                                 RedMaskSize;          // Size of direct color red mask\r
-  UINT8                                 RedFieldPosition;     // Bit posn of lsb of red mask\r
-  UINT8                                 GreenMaskSize;        // Size of direct color green mask\r
-  UINT8                                 GreenFieldPosition;   // Bit posn of lsb of green mask\r
-  UINT8                                 BlueMaskSize;         // Size of direct color blue mask\r
-  UINT8                                 BlueFieldPosition;    // Bit posn of lsb of blue mask\r
-  UINT8                                 RsvdMaskSize;         // Size of direct color res mask\r
-  UINT8                                 RsvdFieldPosition;    // Bit posn of lsb of res mask\r
-  UINT8                                 DirectColorModeInfo;  // Direct color mode attributes\r
-  //\r
-  // Manadory fields for VESA Bios Extensions 2.0 and above\r
-  //\r
-  UINT32                                PhysBasePtr;  // Physical Address for flat memory frame buffer\r
-  UINT32                                Reserved2;    // Reserved\r
-  UINT16                                Reserved3;    // Reserved\r
-  //\r
-  // Manadory fields for VESA Bios Extensions 3.0 and above\r
-  //\r
-  UINT16                                LinBytesPerScanLine;    // Bytes/scan line for linear modes\r
-  UINT8                                 BnkNumberOfImagePages;  // Number of images for banked modes\r
-  UINT8                                 LinNumberOfImagePages;  // Number of images for linear modes\r
-  UINT8                                 LinRedMaskSize;         // Size of direct color red mask (linear mode)\r
-  UINT8                                 LinRedFieldPosition;    // Bit posiiton of lsb of red mask (linear modes)\r
-  UINT8                                 LinGreenMaskSize;       // Size of direct color green mask (linear mode)\r
-  UINT8                                 LinGreenFieldPosition;  // Bit posiiton of lsb of green mask (linear modes)\r
-  UINT8                                 LinBlueMaskSize;        // Size of direct color blue mask (linear mode)\r
-  UINT8                                 LinBlueFieldPosition;   // Bit posiiton of lsb of blue mask (linear modes)\r
-  UINT8                                 LinRsvdMaskSize;        // Size of direct color reserved mask (linear mode)\r
-  UINT8                                 LinRsvdFieldPosition;   // Bit posiiton of lsb of reserved mask (linear modes)\r
-  UINT32                                MaxPixelClock;          // Maximum pixel clock (in Hz) for graphics mode\r
-  UINT8                                 Pad[190];               // Pad to 256 byte block size\r
-} VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK;\r
-\r
-//\r
-// Super VGA Mode Information Block ModeAttributes field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_HARDWARE  0x0001  // 0: Mode not supported in handware\r
-// 1: Mode supported in handware\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_TTY 0x0004  // 0: TTY Output functions not supported by BIOS\r
-// 1: TTY Output functions supported by BIOS\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR 0x0008  // 0: Monochrome mode\r
-// 1: Color mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS  0x0010  // 0: Text mode\r
-// 1: Graphics mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_VGA 0x0020  // 0: VGA compatible mode\r
-// 1: Not a VGA compatible mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_WINDOWED  0x0040  // 0: VGA compatible windowed memory mode\r
-// 1: Not a VGA compatible windowed memory mode\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER 0x0080  // 0: No linear fram buffer mode available\r
-// 1: Linear frame buffer mode available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DOUBLE_SCAN 0x0100  // 0: No double scan mode available\r
-// 1: Double scan mode available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_INTERLACED  0x0200  // 0: No interlaced mode is available\r
-// 1: Interlaced mode is available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NO_TRIPPLE_BUFFER 0x0400  // 0: No hardware triple buffer mode support available\r
-// 1: Hardware triple buffer mode support available\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_STEREOSCOPIC  0x0800  // 0: No hardware steroscopic display support\r
-// 1: Hardware steroscopic display support\r
-//\r
-#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DUAL_DISPLAY  0x1000  // 0: No dual display start address support\r
-// 1: Dual display start address support\r
-//\r
-// Super VGA Mode Information Block WinAAttribite/WinBAttributes field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_RELOCATABLE 0x01  // 0: Single non-relocatable window only\r
-// 1: Relocatable window(s) are supported\r
-//\r
-#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_READABLE  0x02  // 0: Window is not readable\r
-// 1: Window is readable\r
-//\r
-#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_WRITABLE  0x04  // 0: Window is not writable\r
-// 1: Window is writable\r
-//\r
-// Super VGA Mode Information Block DirectColorMode field bit defintions\r
-//\r
-#define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_PROG_COLOR_RAMP  0x01  // 0: Color ram is fixed\r
-// 1: Color ramp is programmable\r
-//\r
-#define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_RSVD_USABLE  0x02  // 0: Bits in Rsvd field are reserved\r
-// 1: Bits in Rsdv field are usable\r
-//\r
-// Super VGA Memory Models\r
-//\r
-typedef enum {\r
-  memPL = 3,  // Planar memory model\r
-  memPK = 4,  // Packed pixel memory model\r
-  memRGB= 6,  // Direct color RGB memory model\r
-  memYUV= 7   // Direct color YUV memory model\r
-} VESA_BIOS_EXTENSIONS_MEMORY_MODELS;\r
-\r
-//\r
-// Super VGA CRTC Information Block\r
-//\r
-typedef struct {\r
-  UINT16  HorizontalTotal;      // Horizontal total in pixels\r
-  UINT16  HorizontalSyncStart;  // Horizontal sync start in pixels\r
-  UINT16  HorizontalSyncEnd;    // Horizontal sync end in pixels\r
-  UINT16  VericalTotal;         // Vertical total in pixels\r
-  UINT16  VericalSyncStart;     // Vertical sync start in pixels\r
-  UINT16  VericalSyncEnd;       // Vertical sync end in pixels\r
-  UINT8   Flags;                // Flags (Interlaced/DoubleScan/etc).\r
-  UINT32  PixelClock;           // Pixel clock in units of Hz\r
-  UINT16  RefreshRate;          // Refresh rate in units of 0.01 Hz\r
-  UINT8   Reserved[40];         // Pad\r
-} VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK;\r
-\r
-#define VESA_BIOS_EXTENSIONS_CRTC_FLAGS_DOUBLE_SCAN 0x01  // 0: Graphics mode is not souble scanned\r
-// 1: Graphics mode is double scanned\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CRTC_FLAGSINTERLACED 0x02  // 0: Graphics mode is not interlaced\r
-// 1: Graphics mode is interlaced\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CRTC_HORIZONTAL_SYNC_NEGATIVE  0x04  // 0: Horizontal sync polarity is positive(+)\r
-// 0: Horizontal sync polarity is negative(-)\r
-//\r
-#define VESA_BIOS_EXTENSIONS_CRTC_VERITICAL_SYNC_NEGATIVE 0x08  // 0: Verical sync polarity is positive(+)\r
-// 0: Verical sync polarity is negative(-)\r
-//\r
-// Turn off byte packing of data structures\r
-//\r
-#pragma pack()\r
-\r
-#endif\r
diff --git a/DuetPkg/BootSector/BootSector.inf b/DuetPkg/BootSector/BootSector.inf
deleted file mode 100644 (file)
index 49f69eb..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-## @file\r
-# \r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# 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
-##\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = BootSector\r
-  FILE_GUID                      = C89D72CE-E21A-4c71-BA79-770EF373D6DA\r
-  MODULE_TYPE                    = USER_DEFINED\r
-  VERSION_STRING                 = 1.0\r
-  CUSTOM_MAKEFILE                = MSFT|Makefile\r
-  CUSTOM_MAKEFILE                = GCC|GNUmakefile\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[Sources]\r
-  bootsect.asm | INTEL\r
-  bootsect.asm | MSFT\r
-  bootsect.S   | GCC \r
-\r
-  bs16.asm     | INTEL\r
-  bs16.asm     | MSFT\r
-  bs16.S       | GCC \r
-\r
-  bs32.asm     | INTEL\r
-  bs32.asm     | MSFT\r
-  bs32.S       | GCC\r
\r
-  Gpt.asm      | INTEL\r
-  Gpt.asm      | MSFT\r
-  Gpt.S        | GCC\r
-\r
-  Mbr.asm      | INTEL\r
-  Mbr.asm      | MSFT\r
-  Mbr.S        | GCC\r
-\r
-  start.asm    | INTEL\r
-  start.asm    | MSFT\r
-  start.S      | GCC\r
-\r
-  start16.asm  | INTEL\r
-  start16.asm  | MSFT\r
-  start16.S    | GCC\r
-\r
-  start32.asm  | INTEL\r
-  start32.asm  | MSFT\r
-  start32.S    | GCC\r
-\r
-  efi32.asm    | INTEL\r
-  efi32.asm    | MSFT\r
-  efi32.S      | GCC\r
-\r
-  start64.asm  | INTEL\r
-  start64.asm  | MSFT\r
-  start64.S    | GCC\r
-\r
-  st16_64.asm  | INTEL\r
-  st16_64.asm  | MSFT\r
-  st16_64.S    | GCC\r
-\r
-  st32_64.asm  | INTEL\r
-  st32_64.asm  | MSFT\r
-  st32_64.S    | GCC\r
-\r
-  efi64.asm    | INTEL\r
-  efi64.asm    | MSFT\r
-  efi64.S      | GCC\r
-\r
diff --git a/DuetPkg/BootSector/FILE.LST b/DuetPkg/BootSector/FILE.LST
deleted file mode 100644 (file)
index abbe1da..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-## @file\r
-#\r
-#  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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.\r
-#\r
-##\r
-\r
-IA32\r
-====\r
-FAT12                   FAT16             FAT32\r
-bootsect.asm            bs16.asm          bs32.asm\r
-start.asm               start16.asm       start32.asm\r
-         \                   |                 /\r
-          \                  |                /\r
-                         efi32.asm\r
-\r
-X64\r
-===\r
-FAT12                   FAT16             FAT32\r
-bootsect.asm            bs16.asm          bs32.asm\r
-start64.asm             st16_64.asm       st32_64.asm\r
-         \                   |                 /\r
-          \                  |                /\r
-                         efi64.asm\r
-\r
-MBR\r
-===\r
-Mbr.asm\r
-\r
-\r
-GPT\r
-===\r
-Gpt.asm
\ No newline at end of file
diff --git a/DuetPkg/BootSector/GNUmakefile b/DuetPkg/BootSector/GNUmakefile
deleted file mode 100644 (file)
index da38876..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-## @file\r
-#  Just use host GCC to compile boot sector image.\r
-#\r
-#  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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.\r
-#\r
-#\r
-##\r
-\r
-ASM=gcc\r
-DLINK=ld\r
-\r
-ASSEMBLY_CODE_FILE_LIST = $(MODULE_DIR)/bootsect.S \\r
-                          $(MODULE_DIR)/bs16.S \\r
-                          $(MODULE_DIR)/bs32.S \\r
-                          $(MODULE_DIR)/efi32.S \\r
-                          $(MODULE_DIR)/efi64.S \\r
-                          $(MODULE_DIR)/Gpt.S \\r
-                          $(MODULE_DIR)/Mbr.S \\r
-                          $(MODULE_DIR)/start.S \\r
-                          $(MODULE_DIR)/start16.S \\r
-                          $(MODULE_DIR)/start32.S \\r
-                          $(MODULE_DIR)/start64.S \\r
-                          $(MODULE_DIR)/st16_64.S \\r
-                          $(MODULE_DIR)/st32_64.S\r
-\r
-TARGET_FILES = $(OUTPUT_DIR)/bootsect.com \\r
-               $(OUTPUT_DIR)/bs16.com \\r
-               $(OUTPUT_DIR)/bs32.com \\r
-               $(OUTPUT_DIR)/Gpt.com \\r
-               $(OUTPUT_DIR)/Mbr.com \\r
-               $(OUTPUT_DIR)/start.com \\r
-               $(OUTPUT_DIR)/start16.com \\r
-               $(OUTPUT_DIR)/start32.com \\r
-               $(OUTPUT_DIR)/efi32.com2 \\r
-               $(OUTPUT_DIR)/start64.com \\r
-               $(OUTPUT_DIR)/st16_64.com \\r
-               $(OUTPUT_DIR)/st32_64.com \\r
-               $(OUTPUT_DIR)/efi64.com2\r
-\r
-.PHONY : all\r
-all: $(TARGET_FILES)\r
-\r
-# bootsect.S\r
-$(OUTPUT_DIR)/bootsect.o: $(MODULE_DIR)/bootsect.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/bootsect.o $(MODULE_DIR)/bootsect.S\r
-$(OUTPUT_DIR)/bootsect.com: $(OUTPUT_DIR)/bootsect.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/bootsect.com $(OUTPUT_DIR)/bootsect.o -Ttext 0 -Map $(OUTPUT_DIR)/bootsect.map\r
-\r
-# bs16.S\r
-$(OUTPUT_DIR)/bs16.o: $(MODULE_DIR)/bs16.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/bs16.o $(MODULE_DIR)/bs16.S\r
-$(OUTPUT_DIR)/bs16.com: $(OUTPUT_DIR)/bs16.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/bs16.com $(OUTPUT_DIR)/bs16.o -Ttext 0 -Map $(OUTPUT_DIR)/bs16.map\r
-\r
-# bs32.S\r
-$(OUTPUT_DIR)/bs32.o: $(MODULE_DIR)/bs32.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/bs32.o $(MODULE_DIR)/bs32.S\r
-$(OUTPUT_DIR)/bs32.com: $(OUTPUT_DIR)/bs32.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/bs32.com $(OUTPUT_DIR)/bs32.o -Ttext 0 -Map $(OUTPUT_DIR)/bs32.map\r
-\r
-# Gpt.S\r
-$(OUTPUT_DIR)/Gpt.o: $(MODULE_DIR)/Gpt.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/Gpt.o $(MODULE_DIR)/Gpt.S\r
-$(OUTPUT_DIR)/Gpt.com: $(OUTPUT_DIR)/Gpt.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/Gpt.com $(OUTPUT_DIR)/Gpt.o -Ttext 0 -Map $(OUTPUT_DIR)/Gpt.map\r
-\r
-# Mbr.S\r
-$(OUTPUT_DIR)/Mbr.o: $(MODULE_DIR)/Mbr.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/Mbr.o $(MODULE_DIR)/Mbr.S\r
-$(OUTPUT_DIR)/Mbr.com: $(OUTPUT_DIR)/Mbr.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/Mbr.com $(OUTPUT_DIR)/Mbr.o -Ttext 0 -Map $(OUTPUT_DIR)/Mbr.map\r
-\r
-# start.S\r
-$(OUTPUT_DIR)/start.o: $(MODULE_DIR)/start.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/start.o $(MODULE_DIR)/start.S\r
-$(OUTPUT_DIR)/start.com: $(OUTPUT_DIR)/start.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start.com $(OUTPUT_DIR)/start.o -Ttext 0 -Map $(OUTPUT_DIR)/start.map\r
-\r
-# start16.S\r
-$(OUTPUT_DIR)/start16.o: $(MODULE_DIR)/start16.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/start16.o $(MODULE_DIR)/start16.S\r
-$(OUTPUT_DIR)/start16.com: $(OUTPUT_DIR)/start16.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start16.com $(OUTPUT_DIR)/start16.o -Ttext 0 -Map $(OUTPUT_DIR)/start16.map\r
-\r
-# start32.S\r
-$(OUTPUT_DIR)/start32.o: $(MODULE_DIR)/start32.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/start32.o $(MODULE_DIR)/start32.S\r
-$(OUTPUT_DIR)/start32.com: $(OUTPUT_DIR)/start32.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start32.com $(OUTPUT_DIR)/start32.o -Ttext 0 -Map $(OUTPUT_DIR)/start32.map\r
-\r
-# start64.S\r
-$(OUTPUT_DIR)/start64.o: $(MODULE_DIR)/start64.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/start64.o $(MODULE_DIR)/start64.S\r
-$(OUTPUT_DIR)/start64.com: $(OUTPUT_DIR)/start64.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/start64.com $(OUTPUT_DIR)/start64.o -Ttext 0 -Map $(OUTPUT_DIR)/start64.map\r
-\r
-# start16_64.S\r
-$(OUTPUT_DIR)/st16_64.o: $(MODULE_DIR)/st16_64.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/st16_64.o $(MODULE_DIR)/st16_64.S\r
-$(OUTPUT_DIR)/st16_64.com: $(OUTPUT_DIR)/st16_64.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/st16_64.com $(OUTPUT_DIR)/st16_64.o -Ttext 0 -Map $(OUTPUT_DIR)/st16_64.map\r
-\r
-# start32_64.S\r
-$(OUTPUT_DIR)/st32_64.o: $(MODULE_DIR)/st32_64.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/st32_64.o $(MODULE_DIR)/st32_64.S\r
-$(OUTPUT_DIR)/st32_64.com: $(OUTPUT_DIR)/st32_64.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/st32_64.com $(OUTPUT_DIR)/st32_64.o -Ttext 0 -Map $(OUTPUT_DIR)/st32_64.map\r
-\r
-# efi32.S\r
-$(OUTPUT_DIR)/efi32.o: $(MODULE_DIR)/efi32.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/efi32.o $(MODULE_DIR)/efi32.S\r
-$(OUTPUT_DIR)/efi32.com: $(OUTPUT_DIR)/efi32.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/efi32.com $(OUTPUT_DIR)/efi32.o -Ttext 0 -Map $(OUTPUT_DIR)/efi32.map\r
-$(OUTPUT_DIR)/efi32.com2: $(OUTPUT_DIR)/efi32.com\r
-       Split -f $(OUTPUT_DIR)/efi32.com -p $(OUTPUT_DIR) -o efi32.com1 -p $(OUTPUT_DIR) -t efi32.com2 -s 135168\r
-\r
-# efi64.S\r
-$(OUTPUT_DIR)/efi64.o: $(MODULE_DIR)/efi64.S\r
-       $(ASM) -c -o $(OUTPUT_DIR)/efi64.o $(MODULE_DIR)/efi64.S\r
-$(OUTPUT_DIR)/efi64.com: $(OUTPUT_DIR)/efi64.o\r
-       $(DLINK) --oformat binary -o $(OUTPUT_DIR)/efi64.com $(OUTPUT_DIR)/efi64.o -Ttext 0 -Map $(OUTPUT_DIR)/efi64.map\r
-$(OUTPUT_DIR)/efi64.com2: $(OUTPUT_DIR)/efi64.com\r
-       Split -f $(OUTPUT_DIR)/efi64.com -p $(OUTPUT_DIR) -o efi64.com1 -p $(OUTPUT_DIR) -t efi64.com2 -s 135168\r
-\r
-clean:\r
-ifneq ($(OUTPUT_DIR), )\r
-       rm -r $(OUTPUT_DIR)\r
-endif\r
-ifneq ($(DEBUG_DIR), )\r
-       rm -r $(DEBUG_DIR)\r
-endif\r
-\r
-\r
diff --git a/DuetPkg/BootSector/Gpt.S b/DuetPkg/BootSector/Gpt.S
deleted file mode 100644 (file)
index 821ca84..0000000
+++ /dev/null
@@ -1,297 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    gpt.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-    #.MODEL small\r
-#   .dosseg\r
-    .stack: \r
-    .486p: \r
-    .code16 \r
-\r
-.equ                      BLOCK_SIZE,  0x0200\r
-.equ                      BLOCK_MASK,  0x01ff\r
-.equ                      BLOCK_SHIFT, 9\r
-\r
-# ****************************************************************************\r
-# Code loaded by BIOS at 0x0000:0x7C00\r
-# ****************************************************************************\r
-\r
-        .org 0x00\r
-Start: \r
-\r
-# ****************************************************************************\r
-# Start Print\r
-# ****************************************************************************\r
-\r
-    movw $0xb800, %ax\r
-    movw %ax, %es\r
-    movw $0x7c0, %ax\r
-    movw %ax, %ds\r
-    leaw %cs:StartString, %si\r
-    movw $10, %cx\r
-    movw $160, %di\r
-    rep\r
-    movsw\r
-\r
-# ****************************************************************************\r
-# Print over\r
-# ****************************************************************************\r
-\r
-# ****************************************************************************\r
-# Initialize segment registers and copy code at 0x0000:0x7c00 to 0x0000:0x0600\r
-# ****************************************************************************\r
-        xorw  %ax, %ax                  # AX = 0x0000  \r
-        movw  $0x7c00, %bx              # BX = 0x7C00\r
-        movw  $0x600, %bp               # BP = 0x0600\r
-        movw  RelocatedStart, %si       # SI = Offset(RelocatedStart)\r
-        movw  $0x200, %cx               # CX = 0x0200\r
-        subw  %si, %cx                  # CS = 0x0200 - Offset(RelocatedStart)\r
-        leaw  (%bp,%si,), %di           # DI = 0x0600 + Offset(RelocatedStart)\r
-        leaw  (%bx,%si,), %si           # BX = 0x7C00 + Offset(RelocatedStart)\r
-        movw  %ax, %ss                  # SS = 0x0000\r
-        movw  %bx, %sp                  # SP = 0x7C00\r
-        movw  %ax, %es                  # ES = 0x0000\r
-        movw  %ax, %ds                  # DS = 0x0000\r
-        pushw %ax                       # PUSH 0x0000\r
-        pushw %di                       # PUSH 0x0600 + Offset(RelocatedStart)\r
-        cld                             # Clear the direction flag\r
-        rep\r
-        movsb                           # Copy 0x0200 bytes from 0x7C00 to 0x0600\r
-        retl                            # JMP 0x0000:0x0600 + Offset(RelocatedStart)\r
-\r
-# ****************************************************************************\r
-# Code relocated to 0x0000:0x0600\r
-# ****************************************************************************\r
-\r
-RelocatedStart: \r
-# ****************************************************************************\r
-# Get Driver Parameters to 0x0000:0x7BFC\r
-# ****************************************************************************\r
-        xorw  %ax, %ax      # ax = 0\r
-        movw  %ax, %ss      # ss = 0\r
-        addw  $0x1000, %ax\r
-        movw  %ax, %ds\r
-\r
-        movw  $0x7c00, %sp  # sp = 0x7c00\r
-        movw  %sp, %bp      # bp = 0x7c00\r
-\r
-        movb  $8, %ah                             # ah = 8 - Get Drive Parameters Function\r
-        movb  %dl, PhysicalDrive(%bp)             # BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-        int   $0x13                               # Get Drive Parameters\r
-        xorw  %ax, %ax                # ax = 0\r
-        movb  %dh, %al                # al = dh\r
-        incb  %al                     # MaxHead = al + 1\r
-        pushw %ax                     # 0000:7bfe = MaxHead\r
-        movb  %cl, %al                # al = cl\r
-        andb  $0x3f, %al              # MaxSector = al & 0x3f\r
-        pushw %ax                     # 0000:7bfc = MaxSector\r
-\r
-# ****************************************************************************\r
-# Read GPT Header from hard disk to 0x0000:0x0800\r
-# ****************************************************************************\r
-        xorw    %ax, %ax\r
-        movw    %ax, %es                          # Read to 0x0000:0x0800\r
-        movw    $0x800, %di                       # Read to 0x0000:0x0800\r
-        movl    $1, %eax                          # Read LBA #1\r
-        movl    $0, %edx                          # Read LBA #1\r
-        movw    $1, %bx                           # Read 1 Block\r
-        pushw   %es\r
-        call    ReadBlocks\r
-        popw    %es\r
-\r
-# ****************************************************************************\r
-# Read Target GPT Entry from hard disk to 0x0000:0x0A00\r
-# ****************************************************************************\r
-        cmpl  $0x20494645, %es:(%di)              # Check for "EFI "\r
-        jne   BadGpt\r
-        cmpl  $0x54524150, %es:4(%di)             # Check for "PART"\r
-        jne   BadGpt\r
-        cmpl  $0x00010000, %es:8(%di)             # Check Revision - 0x10000\r
-        jne   BadGpt\r
-\r
-        movl  %es:84(%di), %eax                   # EAX = SizeOfPartitionEntry\r
-        mulb  GptPartitionIndicator(%bp)          # EAX = SizeOfPartitionEntry * GptPartitionIndicator\r
-        movl  %eax, %edx                          # EDX = SizeOfPartitionEntry * GptPartitionIndicator\r
-        shrl  $BLOCK_SHIFT, %eax                  # EAX = (SizeOfPartitionEntry * GptPartitionIndicator) / BLOCK_SIZE\r
-        andl  $BLOCK_MASK, %edx                   # EDX = Targer PartitionEntryLBA Offset\r
-                                                  #     = (SizeOfPartitionEntry * GptPartitionIndicator) % BLOCK_SIZE\r
-        pushl %edx\r
-        movl  %es:72(%di), %ecx                   # ECX = PartitionEntryLBA (Low)\r
-        movl  %es:76(%di), %ebx                   # EBX = PartitionEntryLBA (High)\r
-        addl  %ecx, %eax                          # EAX = Target PartitionEntryLBA (Low)\r
-                                                  #     = (PartitionEntryLBA + \r
-                                                  #        (SizeOfPartitionEntry * GptPartitionIndicator) / BLOCK_SIZE)\r
-        adcl  %ebx, %edx                          # EDX = Target PartitionEntryLBA (High)\r
-\r
-        movw  $0xA00, %di                         # Read to 0x0000:0x0A00\r
-        movw  $1, %bx                             # Read 1 Block\r
-        pushw %es\r
-        call  ReadBlocks\r
-        popw  %es\r
-\r
-# ****************************************************************************\r
-# Read Target DBR from hard disk to 0x0000:0x7C00\r
-# ****************************************************************************\r
-        popl  %edx                                # EDX = (SizeOfPartitionEntry * GptPartitionIndicator) % BLOCK_SIZE\r
-        addw  %dx, %di                            # DI = Targer PartitionEntryLBA Offset\r
-        cmpl  $0xC12A7328, %es:(%di)              # Check for EFI System Partition "C12A7328-F81F-11d2-BA4B-00A0C93EC93B"\r
-        jne   BadGpt\r
-        cmpl  $0x11d2F81F, %es:4(%di)             # \r
-        jne   BadGpt\r
-        cmpl  $0xA0004BBA, %es:8(%di)             # \r
-        jne   BadGpt\r
-        cmpl  $0x3BC93EC9, %es:0xc(%di)           # \r
-        jne   BadGpt\r
-\r
-        movl  %es:32(%di), %eax                   # EAX = StartingLBA (Low)\r
-        movl  %es:36(%di), %edx                   # EDX = StartingLBA (High)\r
-        movw  $0x7C00, %di                        # Read to 0x0000:0x7C00\r
-        movw  $1, %bx                             # Read 1 Block\r
-        call  ReadBlocks\r
-\r
-# ****************************************************************************\r
-# Transfer control to BootSector - Jump to 0x0000:0x7C00\r
-# ****************************************************************************\r
-        xorw  %ax, %ax\r
-        pushw %ax                       # PUSH 0x0000\r
-        movw  $0x7c00, %di\r
-        pushw %di                       # PUSH 0x7C00\r
-        retl                            # JMP 0x0000:0x7C00\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# EDX:EAX = Start LBA\r
-# BX      = Number of Blocks to Read (must < 127)\r
-# ES:DI   = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# si = DiskAddressPacket\r
-\r
-ReadBlocks: \r
-        pushal\r
-        pushw %ds\r
-        xorw  %cx, %cx\r
-        movw  %cx, %ds\r
-        movw  $0x600, %bp                       # bp = 0x600\r
-        leaw  AddressPacket(%bp), %si\r
-        movb  %bl, %ds:2(%si)                   #    02 = Number Of Block transfered\r
-        movw  %di, %ds:4(%si)                   #    04 = Transfer Buffer Offset\r
-        movw  %es, %ds:6(%si)                   #    06 = Transfer Buffer Segment\r
-        movl  %eax, %ds:8(%si)                  #    08 = Starting LBA (Low)\r
-        movl  %edx, %ds:0xc(%si)                #    0C = Starting LBA (High)\r
-        movb  $0x42, %ah                        # ah = Function 42\r
-        movb  PhysicalDrive(%bp), %dl           # dl = Drive Number\r
-        int   $0x13\r
-        jc    BadGpt\r
-        popw  %ds\r
-        popal\r
-        ret\r
-\r
-# ****************************************************************************\r
-# Address Packet used by ReadBlocks\r
-# ****************************************************************************\r
-AddressPacket: \r
-        .byte 0x10                      # Size of address packet\r
-        .byte 0x0                       # Reserved.  Must be 0\r
-        .byte 0x1                       # Read blocks at a time (To be fixed each times)\r
-        .byte 0x0                       # Reserved.  Must be 0\r
-        .word 0x000                     # Destination Address offset (To be fixed each times)\r
-        .word 0x000                     # Destination Address segment (To be fixed each times)\r
-AddressPacketLba: \r
-        .long 0x0,0x0                   # Start LBA (To be fixed each times)\r
-AddressPacketEnd: \r
-\r
-# ****************************************************************************\r
-# ERROR Condition:\r
-# ****************************************************************************\r
-\r
-BadGpt: \r
-    movw $0xb800, %ax\r
-    movw %ax, %es\r
-    movw $0x60, %ax\r
-    movw %ax, %ds\r
-    leaw %cs:ErrorString, %si\r
-    movw $10, %cx\r
-    movw $320, %di\r
-    rep\r
-    movsw\r
-Halt: \r
-    jmp   Halt\r
-\r
-StartString: \r
-    .byte 'G', 0x0c, 'P', 0x0c, 'T', 0x0c, ' ', 0x0c, 'S', 0x0c, 't', 0x0c, 'a', 0x0c, 'r', 0x0c, 't', 0x0c, '!', 0x0c\r
-ErrorString: \r
-    .byte 'G', 0x0c, 'P', 0x0c, 'T', 0x0c, ' ', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!', 0x0c\r
-\r
-# ****************************************************************************\r
-# PhysicalDrive - Used to indicate which disk to be boot\r
-#                 Can be patched by tool\r
-# ****************************************************************************\r
-    # .org   0x01B6 # Just for passing build.\r
-PhysicalDrive:        .byte 0x80\r
-\r
-# ****************************************************************************\r
-# GptPartitionIndicator - Used to indicate which GPT partition to be boot\r
-#                         Can be patched by tool\r
-# ****************************************************************************\r
-   # .org   0x01B7  # Just for passing build.\r
-GptPartitionIndicator: .byte 0\r
-\r
-# ****************************************************************************\r
-# Unique MBR signature\r
-# ****************************************************************************\r
-   # .org   0x01B8  # Just for passing build.\r
-    .ascii "DUET"\r
-\r
-# ****************************************************************************\r
-# Unknown\r
-# ****************************************************************************\r
-    # .org   0x01BC  # Just for passing build.\r
-    .word 0\r
-\r
-# ****************************************************************************\r
-# PMBR Entry - Can be patched by tool\r
-# ****************************************************************************\r
-    # .org   0x01BE  # Just for passing build.\r
-    .byte 0       # Boot Indicator\r
-    .byte 0xff    # Start Header\r
-    .byte 0xff    # Start Sector\r
-    .byte 0xff    # Start Track\r
-    .byte 0xee    # OS Type\r
-    .byte 0xff    # End Header\r
-    .byte 0xff    # End Sector\r
-    .byte 0xff    # End Track\r
-    .long 1       # Starting LBA\r
-    .long 0xFFFFFFFF # End LBA\r
-\r
-    # .org   0x01CE  # Just for passing build.\r
-    .long  0,0,0,0\r
-    # .org   0x01DE  # Just for passing build.\r
-    .long  0,0,0,0\r
-    # .org   0x01EE  # Just for passing build.\r
-    .long 0,0,0,0\r
-\r
-# ****************************************************************************\r
-# Sector Signature\r
-# ****************************************************************************\r
-\r
-  # .org      0x01FE  # Just for passing build.\r
-SectorSignature: \r
-  .word     0xaa55      # Boot Sector Signature\r
-\r
-\r
-\r
diff --git a/DuetPkg/BootSector/Gpt.asm b/DuetPkg/BootSector/Gpt.asm
deleted file mode 100644 (file)
index e940753..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    gpt.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-    .model  small\r
-;   .dosseg\r
-    .stack\r
-    .486p\r
-    .code\r
-\r
-BLOCK_SIZE                EQU     0200h\r
-BLOCK_MASK                EQU     01ffh\r
-BLOCK_SHIFT               EQU     9\r
-\r
-; ****************************************************************************\r
-; Code loaded by BIOS at 0x0000:0x7C00\r
-; ****************************************************************************\r
-\r
-        org 0h\r
-Start:\r
-\r
-; ****************************************************************************\r
-; Start Print\r
-; ****************************************************************************\r
-\r
-    mov  ax,0b800h\r
-    mov  es,ax\r
-    mov  ax, 07c0h\r
-    mov  ds, ax\r
-    lea  si, cs:[StartString]\r
-    mov  cx, 10\r
-    mov  di, 160\r
-    rep  movsw \r
-\r
-; ****************************************************************************\r
-; Print over\r
-; ****************************************************************************\r
-\r
-; ****************************************************************************\r
-; Initialize segment registers and copy code at 0x0000:0x7c00 to 0x0000:0x0600\r
-; ****************************************************************************\r
-        xor   ax, ax                    ; AX = 0x0000  \r
-        mov   bx, 07c00h                ; BX = 0x7C00\r
-        mov   bp, 0600h                 ; BP = 0x0600\r
-        mov   si, OFFSET RelocatedStart ; SI = Offset(RelocatedStart)\r
-        mov   cx, 0200h                 ; CX = 0x0200\r
-        sub   cx, si                    ; CS = 0x0200 - Offset(RelocatedStart)\r
-        lea   di, [bp+si]               ; DI = 0x0600 + Offset(RelocatedStart)\r
-        lea   si, [bx+si]               ; BX = 0x7C00 + Offset(RelocatedStart)\r
-        mov   ss, ax                    ; SS = 0x0000\r
-        mov   sp, bx                    ; SP = 0x7C00\r
-        mov   es,ax                     ; ES = 0x0000\r
-        mov   ds,ax                     ; DS = 0x0000\r
-        push  ax                        ; PUSH 0x0000\r
-        push  di                        ; PUSH 0x0600 + Offset(RelocatedStart)\r
-        cld                             ; Clear the direction flag\r
-        rep   movsb                     ; Copy 0x0200 bytes from 0x7C00 to 0x0600\r
-        retf                            ; JMP 0x0000:0x0600 + Offset(RelocatedStart)\r
-\r
-; ****************************************************************************\r
-; Code relocated to 0x0000:0x0600\r
-; ****************************************************************************\r
-\r
-RelocatedStart:\r
-; ****************************************************************************\r
-; Get Driver Parameters to 0x0000:0x7BFC\r
-; ****************************************************************************\r
-        xor   ax,ax         ; ax = 0\r
-        mov   ss,ax         ; ss = 0\r
-        add   ax,1000h\r
-        mov   ds,ax\r
-\r
-        mov   sp,07c00h     ; sp = 0x7c00\r
-        mov   bp,sp         ; bp = 0x7c00\r
-\r
-        mov   ah,8                                ; ah = 8 - Get Drive Parameters Function\r
-        mov   byte ptr [bp+PhysicalDrive],dl      ; BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-        int   13h                                 ; Get Drive Parameters\r
-        xor   ax,ax                   ; ax = 0\r
-        mov   al,dh                   ; al = dh\r
-        inc   al                      ; MaxHead = al + 1\r
-        push  ax                      ; 0000:7bfe = MaxHead\r
-        mov   al,cl                   ; al = cl\r
-        and   al,03fh                 ; MaxSector = al & 0x3f\r
-        push  ax                      ; 0000:7bfc = MaxSector\r
-\r
-; ****************************************************************************\r
-; Read GPT Header from hard disk to 0x0000:0x0800\r
-; ****************************************************************************\r
-        xor     ax, ax\r
-        mov     es, ax                            ; Read to 0x0000:0x0800\r
-        mov     di, 0800h                         ; Read to 0x0000:0x0800\r
-        mov     eax, 1                            ; Read LBA #1\r
-        mov     edx, 0                            ; Read LBA #1\r
-        mov     bx, 1                             ; Read 1 Block\r
-        push    es\r
-        call    ReadBlocks\r
-        pop     es\r
-\r
-; ****************************************************************************\r
-; Read Target GPT Entry from hard disk to 0x0000:0x0A00\r
-; ****************************************************************************\r
-        cmp   dword ptr es:[di], 020494645h       ; Check for "EFI "\r
-        jne   BadGpt\r
-        cmp   dword ptr es:[di + 4], 054524150h   ; Check for "PART"\r
-        jne   BadGpt\r
-        cmp   dword ptr es:[di + 8], 000010000h   ; Check Revision - 0x10000\r
-        jne   BadGpt\r
-\r
-        mov   eax, dword ptr es:[di + 84]         ; EAX = SizeOfPartitionEntry\r
-        mul   byte ptr [bp+GptPartitionIndicator] ; EAX = SizeOfPartitionEntry * GptPartitionIndicator\r
-        mov   edx, eax                            ; EDX = SizeOfPartitionEntry * GptPartitionIndicator\r
-        shr   eax, BLOCK_SHIFT                    ; EAX = (SizeOfPartitionEntry * GptPartitionIndicator) / BLOCK_SIZE\r
-        and   edx, BLOCK_MASK                     ; EDX = Targer PartitionEntryLBA Offset\r
-                                                  ;     = (SizeOfPartitionEntry * GptPartitionIndicator) % BLOCK_SIZE\r
-        push  edx\r
-        mov   ecx, dword ptr es:[di + 72]         ; ECX = PartitionEntryLBA (Low)\r
-        mov   ebx, dword ptr es:[di + 76]         ; EBX = PartitionEntryLBA (High)\r
-        add   eax, ecx                            ; EAX = Target PartitionEntryLBA (Low)\r
-                                                  ;     = (PartitionEntryLBA + \r
-                                                  ;        (SizeOfPartitionEntry * GptPartitionIndicator) / BLOCK_SIZE)\r
-        adc   edx, ebx                            ; EDX = Target PartitionEntryLBA (High)\r
-\r
-        mov   di, 0A00h                           ; Read to 0x0000:0x0A00\r
-        mov   bx, 1                               ; Read 1 Block\r
-        push  es\r
-        call  ReadBlocks\r
-        pop   es\r
-\r
-; ****************************************************************************\r
-; Read Target DBR from hard disk to 0x0000:0x7C00\r
-; ****************************************************************************\r
-        pop   edx                                 ; EDX = (SizeOfPartitionEntry * GptPartitionIndicator) % BLOCK_SIZE\r
-        add   di, dx                              ; DI = Targer PartitionEntryLBA Offset\r
-        cmp   dword ptr es:[di], 0C12A7328h       ; Check for EFI System Partition "C12A7328-F81F-11d2-BA4B-00A0C93EC93B"\r
-        jne   BadGpt\r
-        cmp   dword ptr es:[di + 4], 011d2F81Fh   ; \r
-        jne   BadGpt\r
-        cmp   dword ptr es:[di + 8], 0A0004BBAh   ; \r
-        jne   BadGpt\r
-        cmp   dword ptr es:[di + 0ch], 03BC93EC9h ; \r
-        jne   BadGpt\r
-\r
-        mov   eax, dword ptr es:[di + 32]         ; EAX = StartingLBA (Low)\r
-        mov   edx, dword ptr es:[di + 36]         ; EDX = StartingLBA (High)\r
-        mov   di, 07C00h                          ; Read to 0x0000:0x7C00\r
-        mov   bx, 1                               ; Read 1 Block\r
-        call  ReadBlocks\r
-\r
-; ****************************************************************************\r
-; Transfer control to BootSector - Jump to 0x0000:0x7C00\r
-; ****************************************************************************\r
-        xor   ax, ax\r
-        push  ax                        ; PUSH 0x0000\r
-        mov   di, 07c00h\r
-        push  di                        ; PUSH 0x7C00\r
-        retf                            ; JMP 0x0000:0x7C00\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; EDX:EAX = Start LBA\r
-; BX      = Number of Blocks to Read (must < 127)\r
-; ES:DI   = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; si = DiskAddressPacket\r
-\r
-ReadBlocks:\r
-        pushad\r
-        push  ds\r
-        xor   cx, cx\r
-        mov   ds, cx\r
-        mov   bp, 0600h                         ; bp = 0x600\r
-        lea   si, [bp + OFFSET AddressPacket]   ; DS:SI = Disk Address Packet\r
-        mov   BYTE PTR ds:[si+2],bl             ;    02 = Number Of Block transfered\r
-        mov   WORD PTR ds:[si+4],di             ;    04 = Transfer Buffer Offset\r
-        mov   WORD PTR ds:[si+6],es             ;    06 = Transfer Buffer Segment\r
-        mov   DWORD PTR ds:[si+8],eax           ;    08 = Starting LBA (Low)\r
-        mov   DWORD PTR ds:[si+0ch],edx         ;    0C = Starting LBA (High)\r
-        mov   ah, 42h                           ; ah = Function 42\r
-        mov   dl,byte ptr [bp+PhysicalDrive]    ; dl = Drive Number\r
-        int   13h\r
-        jc    BadGpt\r
-        pop   ds\r
-        popad\r
-        ret\r
-\r
-; ****************************************************************************\r
-; Address Packet used by ReadBlocks\r
-; ****************************************************************************\r
-AddressPacket:\r
-        db    10h                       ; Size of address packet\r
-        db    00h                       ; Reserved.  Must be 0\r
-        db    01h                       ; Read blocks at a time (To be fixed each times)\r
-        db    00h                       ; Reserved.  Must be 0\r
-        dw    0000h                     ; Destination Address offset (To be fixed each times)\r
-        dw    0000h                     ; Destination Address segment (To be fixed each times)\r
-AddressPacketLba:\r
-        dd    0h, 0h                    ; Start LBA (To be fixed each times)\r
-AddressPacketEnd:\r
-\r
-; ****************************************************************************\r
-; ERROR Condition:\r
-; ****************************************************************************\r
-\r
-BadGpt:\r
-    mov  ax,0b800h\r
-    mov  es,ax\r
-    mov  ax, 060h\r
-    mov  ds, ax\r
-    lea  si, cs:[ErrorString]\r
-    mov  cx, 10\r
-    mov  di, 320\r
-    rep  movsw \r
-Halt:\r
-    jmp   Halt\r
-\r
-StartString:\r
-    db 'G', 0ch, 'P', 0ch, 'T', 0ch, ' ', 0ch, 'S', 0ch, 't', 0ch, 'a', 0ch, 'r', 0ch, 't', 0ch, '!', 0ch\r
-ErrorString:\r
-    db 'G', 0ch, 'P', 0ch, 'T', 0ch, ' ', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-; ****************************************************************************\r
-; PhysicalDrive - Used to indicate which disk to be boot\r
-;                 Can be patched by tool\r
-; ****************************************************************************\r
-    org   01B6h\r
-PhysicalDrive         db  80h\r
-\r
-; ****************************************************************************\r
-; GptPartitionIndicator - Used to indicate which GPT partition to be boot\r
-;                         Can be patched by tool\r
-; ****************************************************************************\r
-    org   01B7h\r
-GptPartitionIndicator db 0\r
-\r
-; ****************************************************************************\r
-; Unique MBR signature\r
-; ****************************************************************************\r
-    org   01B8h\r
-    db 'DUET'\r
-\r
-; ****************************************************************************\r
-; Unknown\r
-; ****************************************************************************\r
-    org   01BCh\r
-    dw 0\r
-\r
-; ****************************************************************************\r
-; PMBR Entry - Can be patched by tool\r
-; ****************************************************************************\r
-    org   01BEh\r
-    db 0          ; Boot Indicator\r
-    db 0ffh       ; Start Header\r
-    db 0ffh       ; Start Sector\r
-    db 0ffh       ; Start Track\r
-    db 0eeh       ; OS Type\r
-    db 0ffh       ; End Header\r
-    db 0ffh       ; End Sector\r
-    db 0ffh       ; End Track\r
-    dd 1          ; Starting LBA\r
-    dd 0FFFFFFFFh ; End LBA\r
-\r
-    org   01CEh\r
-    dd 0, 0, 0, 0\r
-    org   01DEh\r
-    dd 0, 0, 0, 0\r
-    org   01EEh\r
-    dd 0, 0, 0, 0\r
-\r
-; ****************************************************************************\r
-; Sector Signature\r
-; ****************************************************************************\r
-\r
-  org 01FEh\r
-SectorSignature:\r
-  dw        0aa55h      ; Boot Sector Signature\r
-\r
-  end \r
-  \r
diff --git a/DuetPkg/BootSector/Makefile b/DuetPkg/BootSector/Makefile
deleted file mode 100644 (file)
index cfee9a0..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-## @file\r
-#\r
-#  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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.\r
-#\r
-#\r
-##\r
-\r
-BASETOOLS_DIR = $(EDK_TOOLS_PATH)\Bin\Win32\r
-\r
-#\r
-# Build Macro\r
-#\r
-ASSEMBLY_CODE_FILE_LIST = $(MODULE_DIR)\bootsect.asm \\r
-                          $(MODULE_DIR)\bs16.asm \\r
-                          $(MODULE_DIR)\bs32.asm \\r
-                          $(MODULE_DIR)\efi32.asm \\r
-                          $(MODULE_DIR)\Gpt.asm \\r
-                          $(MODULE_DIR)\Mbr.asm \\r
-                          $(MODULE_DIR)\start.asm \\r
-                          $(MODULE_DIR)\start16.asm \\r
-                          $(MODULE_DIR)\start32.asm \r
-\r
-TARGET_FILES = $(OUTPUT_DIR)\bootsect.com \\r
-               $(OUTPUT_DIR)\bs16.com \\r
-               $(OUTPUT_DIR)\bs32.com \\r
-               $(OUTPUT_DIR)\Gpt.com \\r
-               $(OUTPUT_DIR)\Mbr.com \\r
-               $(OUTPUT_DIR)\Start.com \\r
-               $(OUTPUT_DIR)\Start16.com \\r
-               $(OUTPUT_DIR)\Start32.com \\r
-               $(OUTPUT_DIR)\Start64.com \\r
-               $(OUTPUT_DIR)\St16_64.com \\r
-               $(OUTPUT_DIR)\St32_64.com \\r
-               $(OUTPUT_DIR)\efi32.com2 \\r
-               $(OUTPUT_DIR)\efi64.com2 \r
-\r
-INC = \r
-      \r
-\r
-#OBJECTS = \r
-\r
-LIBS = \r
-\r
-COMMON_DEPS = \r
-\r
-all: $(TARGET_FILES)\r
-          \r
-#=============                \r
-$(OUTPUT_DIR)\bootsect.obj:$(MODULE_DIR)\bootsect.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\bootsect.obj" /FR"$(OUTPUT_DIR)\bootsect.txt" "$(MODULE_DIR)\bootsect.asm"\r
-             \r
-$(OUTPUT_DIR)\bootsect.com:$(OUTPUT_DIR)\bootsect.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\bootsect.obj,$(OUTPUT_DIR)\bootsect.com,$(OUTPUT_DIR)\bootsect.map,,,\r
-\r
-#=============                \r
-\r
-$(OUTPUT_DIR)\bs16.obj:$(MODULE_DIR)\bs16.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\bs16.obj" "$(MODULE_DIR)\bs16.asm"\r
-             \r
-$(OUTPUT_DIR)\bs16.com:$(OUTPUT_DIR)\bs16.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\bs16.obj,$(OUTPUT_DIR)\bs16.com,$(OUTPUT_DIR)\bs16.map,,,\r
-\r
-#=============                \r
-\r
-$(OUTPUT_DIR)\bs32.obj:$(MODULE_DIR)\bs32.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\bs32.obj" "$(MODULE_DIR)\bs32.asm"\r
-             \r
-$(OUTPUT_DIR)\bs32.com:$(OUTPUT_DIR)\bs32.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\bs32.obj,$(OUTPUT_DIR)\bs32.com,$(OUTPUT_DIR)\bs32.map,,,\r
-\r
-#=============                \r
-\r
-$(OUTPUT_DIR)\Gpt.obj:$(MODULE_DIR)\Gpt.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\Gpt.obj" "$(MODULE_DIR)\Gpt.asm"\r
-             \r
-$(OUTPUT_DIR)\Gpt.com:$(OUTPUT_DIR)\Gpt.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\Gpt.obj,$(OUTPUT_DIR)\Gpt.com,$(OUTPUT_DIR)\Gpt.map,,,\r
-\r
-#=============                \r
-\r
-$(OUTPUT_DIR)\Mbr.obj:$(MODULE_DIR)\Mbr.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\Mbr.obj" "$(MODULE_DIR)\Mbr.asm"\r
-             \r
-$(OUTPUT_DIR)\Mbr.com:$(OUTPUT_DIR)\Mbr.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\Mbr.obj,$(OUTPUT_DIR)\Mbr.com,$(OUTPUT_DIR)\Mbr.map,,,\r
-\r
-#============\r
-\r
-$(OUTPUT_DIR)\Start.obj:$(MODULE_DIR)\Start.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\Start.obj" "$(MODULE_DIR)\Start.asm"\r
-             \r
-$(OUTPUT_DIR)\Start.com:$(OUTPUT_DIR)\Start.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\Start.obj,$(OUTPUT_DIR)\Start.com,$(OUTPUT_DIR)\Start.map,,,\r
-  \r
-#=============     \r
-\r
-$(OUTPUT_DIR)\Start16.obj:$(MODULE_DIR)\Start16.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\Start16.obj" "$(MODULE_DIR)\Start16.asm"\r
-             \r
-$(OUTPUT_DIR)\Start16.com:$(OUTPUT_DIR)\Start16.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\Start16.obj,$(OUTPUT_DIR)\Start16.com,$(OUTPUT_DIR)\Start16.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\Start32.obj:$(MODULE_DIR)\Start32.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\Start32.obj" "$(MODULE_DIR)\Start32.asm"\r
-             \r
-$(OUTPUT_DIR)\Start32.com:$(OUTPUT_DIR)\Start32.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\Start32.obj,$(OUTPUT_DIR)\Start32.com,$(OUTPUT_DIR)\Start32.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\Start64.obj:$(MODULE_DIR)\Start64.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\Start64.obj" "$(MODULE_DIR)\Start64.asm"\r
-             \r
-$(OUTPUT_DIR)\Start64.com:$(OUTPUT_DIR)\Start64.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\Start64.obj,$(OUTPUT_DIR)\Start64.com,$(OUTPUT_DIR)\Start64.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\St16_64.obj:$(MODULE_DIR)\St16_64.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\St16_64.obj" "$(MODULE_DIR)\St16_64.asm"\r
-             \r
-$(OUTPUT_DIR)\St16_64.com:$(OUTPUT_DIR)\St16_64.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\St16_64.obj,$(OUTPUT_DIR)\St16_64.com,$(OUTPUT_DIR)\St16_64.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\St32_64.obj:$(MODULE_DIR)\St32_64.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\St32_64.obj" "$(MODULE_DIR)\St32_64.asm"\r
-             \r
-$(OUTPUT_DIR)\St32_64.com:$(OUTPUT_DIR)\St32_64.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\St32_64.obj,$(OUTPUT_DIR)\St32_64.com,$(OUTPUT_DIR)\St32_64.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\efi32.obj:$(MODULE_DIR)\efi32.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\efi32.obj" "$(MODULE_DIR)\efi32.asm"\r
-             \r
-$(OUTPUT_DIR)\efi32.com:$(OUTPUT_DIR)\efi32.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\efi32.obj,$(OUTPUT_DIR)\efi32.com,$(OUTPUT_DIR)\efi32.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\efi32.com2:$(OUTPUT_DIR)\efi32.com\r
-       $(BASETOOLS_DIR)\Split.exe -f $(OUTPUT_DIR)\efi32.com -t $(OUTPUT_DIR)\efi32.com2 -s 135168\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\efi64.obj:$(MODULE_DIR)\efi64.asm\r
-       "$(ASM)" /c /omf /Fo"$(OUTPUT_DIR)\efi64.obj" "$(MODULE_DIR)\efi64.asm"\r
-             \r
-$(OUTPUT_DIR)\efi64.com:$(OUTPUT_DIR)\efi64.obj\r
-       "$(ASMLINK)" /tiny $(OUTPUT_DIR)\efi64.obj,$(OUTPUT_DIR)\efi64.com,$(OUTPUT_DIR)\efi64.map,,,\r
-\r
-#=============\r
-\r
-$(OUTPUT_DIR)\efi64.com2:$(OUTPUT_DIR)\efi64.com\r
-       $(BASETOOLS_DIR)\Split.exe -f $(OUTPUT_DIR)\efi64.com -t $(OUTPUT_DIR)\efi64.com2 -s 135168\r
-\r
-    \r
-clean:\r
-       if exist $(DEBUG_DIR) rmdir /s /q $(DEBUG_DIR)\r
-       if exist $(OUTPUT_DIR) rmdir /s /q $(OUTPUT_DIR)\r
-\r
-\r
diff --git a/DuetPkg/BootSector/Mbr.S b/DuetPkg/BootSector/Mbr.S
deleted file mode 100644 (file)
index 65c97ea..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    Mbr.asm\r
-#*\r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-    .code16 \r
-\r
-.equ                      BLOCK_SIZE, 0x0200\r
-.equ                      BLOCK_MASK, 0x01ff\r
-.equ                      BLOCK_SHIFT, 9\r
-\r
-# ****************************************************************************\r
-# Code loaded by BIOS at 0x0000:0x7C00\r
-# ****************************************************************************\r
-\r
-.org 0x0\r
-\r
-.global _start\r
-_start:\r
-\r
-# ****************************************************************************\r
-# Start Print\r
-# ****************************************************************************\r
-\r
-        movw $0xb800, %ax\r
-        movw %ax, %es\r
-        movw $0x7c0, %ax\r
-        movw %ax, %ds\r
-        leaw %cs:StartString, %si\r
-        movw $10, %cx\r
-        movw $160, %di\r
-        rep \r
-        movsw\r
-\r
-# ****************************************************************************\r
-# Print over\r
-# ****************************************************************************\r
-\r
-# ****************************************************************************\r
-# Initialize segment registers and copy code at 0x0000:0x7c00 to 0x0000:0x0600\r
-# ****************************************************************************\r
-        xorw  %ax, %ax                            # AX = 0x0000\r
-        movw  $0x7c00, %bx                        # BX = 0x7C00\r
-        movw  $0x600, %bp                         # BP = 0x0600\r
-        movw  $RelocatedStart, %si                # SI = Offset(RelocatedStart)\r
-        movw  $0x200, %cx                         # CX = 0x0200\r
-        subw  %si, %cx                            # CS = 0x0200 - Offset(RelocatedStart)\r
-        leaw  (%bp,%si,), %di                     # DI = 0x0600 + Offset(RelocatedStart)\r
-        leaw  (%bx,%si,), %si                     # BX = 0x7C00 + Offset(RelocatedStart)\r
-        movw  %ax, %ss                            # SS = 0x0000\r
-        movw  %bx, %sp                            # SP = 0x7C00\r
-        movw  %ax, %es                            # ES = 0x0000\r
-        movw  %ax, %ds                            # DS = 0x0000\r
-        pushw %ax                                 # PUSH 0x0000\r
-        pushw %di                                 # PUSH 0x0600 + Offset(RelocatedStart)\r
-        cld                                       # Clear the direction flag\r
-        rep\r
-        movsb                                     # Copy 0x0200 bytes from 0x7C00 to 0x0600\r
-        retl                                      # JMP 0x0000:0x0600 + Offset(RelocatedStart)\r
-\r
-# ****************************************************************************\r
-# Code relocated to 0x0000:0x0600\r
-# ****************************************************************************\r
-\r
-RelocatedStart: \r
-# ****************************************************************************\r
-# Get Driver Parameters to 0x0000:0x7BFC\r
-# ****************************************************************************\r
-\r
-        xorw  %ax, %ax                            # AX = 0\r
-        movw  %ax, %ss                            # SS = 0\r
-        addw  $0x1000, %ax\r
-        movw  %ax, %ds\r
-\r
-        movw  $0x7c00, %sp                        # SP = 0x7c00\r
-        movw  %sp, %bp                            # BP = 0x7c00\r
-\r
-        movb  $8, %ah                             # AH = 8 - Get Drive Parameters Function\r
-        movb  %dl, PhysicalDrive(%bp)             # BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-        int   $0x13                               # Get Drive Parameters\r
-        xorw  %ax, %ax                            # AX = 0\r
-        movb  %dh, %al                            # AL = DH\r
-        incb  %al                                 # MaxHead = AL + 1\r
-        pushw %ax                                 # 0000:7bfe = MaxHead\r
-        movb  %cl, %al                            # AL = CL\r
-        andb  $0x3f, %al                          # MaxSector = AL & 0x3f\r
-        pushw %ax                                 # 0000:7bfc = MaxSector\r
-\r
-# ****************************************************************************\r
-# Read Target DBR from hard disk to 0x0000:0x7C00\r
-# ****************************************************************************\r
-\r
-        xorw  %ax, %ax\r
-        movb  MbrPartitionIndicator(%bp), %al          # AX = MbrPartitionIndex\r
-        cmpb  $0xff, %al                               # 0xFF means do legacy MBR boot\r
-        jnz   EfiDbr\r
-LegacyMbr: \r
-        movl  $0x0000600, %eax                    # Assume LegacyMBR is backuped in Sector 6\r
-        jmp   StartReadTo7C00                     # EAX = Header/Sector/Tracker/Zero\r
-\r
-EfiDbr: \r
-        cmpb  $4, %al                             # MbrPartitionIndex should < 4\r
-        jae   BadDbr\r
-        shlw  $4, %ax                             # AX  = MBREntrySize * Index\r
-        addw  $0x1be, %ax                         # AX  = MBREntryOffset\r
-        movw  %ax, %di                            # DI  = MBREntryOffset\r
-\r
-        # Here we don't use the C/H/S information provided by Partition table\r
-        #  but calculate C/H/S from LBA ourselves\r
-        #       Ci: Cylinder number\r
-        #       Hi: Header number\r
-        #       Si: Sector number\r
-        movl  %es:8(%bp,%di,), %eax               # Start LBA\r
-        movl  %eax, %edx\r
-        shrl  $16, %edx                           # DX:AX = Start LBA\r
-                                                  #       = Ci * (H * S) + Hi * S + (Si - 1)\r
-\r
-        # Calculate C/H/S according to LBA\r
-        movw  $0x7bfa, %bp\r
-        divw  2(%bp)                              # AX = Hi + H*Ci\r
-                                                  # DX = Si - 1\r
-        incw  %dx                                 # DX = Si\r
-        pushw %dx                                 # 0000:7bfa = Si  <----\r
-        xorw  %dx, %dx                            # DX:AX = Hi + H*Ci\r
-        divw  4(%bp)                              # AX = Ci         <----\r
-                                                  # DX = Hi         <----\r
-\r
-StartReadTo7C00: \r
-\r
-        movb  (%bp), %cl                          # Si\r
-        movb  %al, %ch                            # Ci[0-7]\r
-        orb   %ah, %cl                            # Ci[8,9]\r
-        movw  $0x7c00, %bx                        # ES:BX = 0000:7C00h\r
-        movb  $0x2, %ah                           # Function 02h\r
-        movb  $1, %al                             # 1 Sector\r
-        movb  %dl, %dh                            # Hi\r
-        movw  $0x600, %bp\r
-        movb  PhysicalDrive(%bp), %dl             # Drive number\r
-        int   $0x13\r
-        jc    BadDbr\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# Transfer control to BootSector - Jump to 0x0000:0x7C00\r
-# ****************************************************************************\r
-        xorw  %ax, %ax\r
-        pushw %ax                                 # PUSH 0x0000 - Segment\r
-        movw  $0x7c00, %di\r
-        pushw %di                                 # PUSH 0x7C00 - Offset\r
-        retl                                      # JMP 0x0000:0x7C00\r
-\r
-# ****************************************************************************\r
-# ERROR Condition:\r
-# ****************************************************************************\r
-\r
-BadDbr: \r
-    pushw %ax\r
-    movw $0xb800, %ax\r
-    movw %ax, %es\r
-    movw $0x60, %ax\r
-    movw %ax, %ds\r
-    leaw %cs:ErrorString, %si\r
-    movw $320, %di\r
-    popw %ax\r
-    call A2C\r
-    movb %ah, 16(%si)\r
-    movb %al, 18(%si)\r
-    movw $10, %cx\r
-    rep\r
-    movsw\r
-Halt: \r
-    jmp   Halt\r
-\r
-StartString: \r
-.byte 'M', 0x0c, 'B', 0x0c, 'R', 0x0c, ' ', 0x0c, 'S', 0x0c, 't', 0x0c, 'a', 0x0c, 'r', 0x0c, 't', 0x0c, '!', 0x0c\r
-ErrorString: \r
-.byte 'M', 0x0c, 'B', 0x0c, 'R', 0x0c, ' ', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, ':', 0x0c, '?', 0x0c, '?', 0x0c\r
-\r
-# ****************************************************************************\r
-# A2C - convert Ascii code stored in AH to character stored in AX\r
-# ****************************************************************************\r
-A2C: \r
-    movb %ah, %al\r
-    shrb $4, %ah\r
-    andb $0xF, %al\r
-    addb '0', %ah\r
-    addb '0', %al\r
-\r
-    cmpb '9', %ah\r
-    jle  A2C_L1\r
-    addb $7, %ah\r
-A2C_L1: \r
-\r
-    cmpb '9', %al\r
-    jle A2C_L2\r
-    addb $7, %al\r
-A2C_L2: \r
-    ret\r
-\r
-\r
-# ****************************************************************************\r
-# PhysicalDrive - Used to indicate which disk to be boot\r
-#                 Can be patched by tool\r
-# ****************************************************************************\r
-.org   0x01B6\r
-PhysicalDrive:        .byte 0x80\r
-\r
-# ****************************************************************************\r
-# MbrPartitionIndicator - Used to indicate which MBR partition to be boot\r
-#                         Can be patched by tool\r
-#                         OxFF means boot to legacy MBR. (LBA OFFSET 6)\r
-# ****************************************************************************\r
-.org   0x01B7\r
-MbrPartitionIndicator: .byte 0\r
-\r
-# ****************************************************************************\r
-# Unique MBR signature\r
-# ****************************************************************************\r
-.org   0x01B8\r
-    .ascii "DUET"\r
-\r
-# ****************************************************************************\r
-# Unknown\r
-# ****************************************************************************\r
-.org   0x01BC\r
-    .word 0\r
-\r
-# ****************************************************************************\r
-# MBR Entry - To be patched\r
-# ****************************************************************************\r
-.org   0x01BE\r
-    .long 0,0,0,0\r
-.org   0x01CE\r
-    .long 0,0,0,0\r
-.org   0x01DE\r
-    .long 0,0,0,0\r
-.org   0x01EE\r
-    .long 0,0,0,0\r
-\r
-# ****************************************************************************\r
-# Sector Signature\r
-# ****************************************************************************\r
-\r
-.org 0x01FE\r
-SectorSignature: \r
-  .word     0xaa55      # Boot Sector Signature\r
-\r
-\r
-\r
diff --git a/DuetPkg/BootSector/Mbr.asm b/DuetPkg/BootSector/Mbr.asm
deleted file mode 100644 (file)
index b105c08..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    Mbr.asm\r
-;*\r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-    .model  small\r
-;   .dosseg\r
-    .stack\r
-    .486p\r
-    .code\r
-\r
-BLOCK_SIZE                EQU     0200h\r
-BLOCK_MASK                EQU     01ffh\r
-BLOCK_SHIFT               EQU     9\r
-\r
-; ****************************************************************************\r
-; Code loaded by BIOS at 0x0000:0x7C00\r
-; ****************************************************************************\r
-\r
-        org 0h\r
-Start:\r
-\r
-; ****************************************************************************\r
-; Start Print\r
-; ****************************************************************************\r
-\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  ax, 07c0h\r
-        mov  ds, ax\r
-        lea  si, cs:[StartString]\r
-        mov  cx, 10\r
-        mov  di, 160\r
-        rep  movsw\r
-\r
-; ****************************************************************************\r
-; Print over\r
-; ****************************************************************************\r
-\r
-; ****************************************************************************\r
-; Initialize segment registers and copy code at 0x0000:0x7c00 to 0x0000:0x0600\r
-; ****************************************************************************\r
-        xor   ax, ax                              ; AX = 0x0000\r
-        mov   bx, 07c00h                          ; BX = 0x7C00\r
-        mov   bp, 0600h                           ; BP = 0x0600\r
-        mov   si, OFFSET RelocatedStart           ; SI = Offset(RelocatedStart)\r
-        mov   cx, 0200h                           ; CX = 0x0200\r
-        sub   cx, si                              ; CS = 0x0200 - Offset(RelocatedStart)\r
-        lea   di, [bp+si]                         ; DI = 0x0600 + Offset(RelocatedStart)\r
-        lea   si, [bx+si]                         ; BX = 0x7C00 + Offset(RelocatedStart)\r
-        mov   ss, ax                              ; SS = 0x0000\r
-        mov   sp, bx                              ; SP = 0x7C00\r
-        mov   es,ax                               ; ES = 0x0000\r
-        mov   ds,ax                               ; DS = 0x0000\r
-        push  ax                                  ; PUSH 0x0000\r
-        push  di                                  ; PUSH 0x0600 + Offset(RelocatedStart)\r
-        cld                                       ; Clear the direction flag\r
-        rep   movsb                               ; Copy 0x0200 bytes from 0x7C00 to 0x0600\r
-        retf                                      ; JMP 0x0000:0x0600 + Offset(RelocatedStart)\r
-\r
-; ****************************************************************************\r
-; Code relocated to 0x0000:0x0600\r
-; ****************************************************************************\r
-\r
-RelocatedStart:\r
-; ****************************************************************************\r
-; Get Driver Parameters to 0x0000:0x7BFC\r
-; ****************************************************************************\r
-\r
-        xor   ax,ax                               ; AX = 0\r
-        mov   ss,ax                               ; SS = 0\r
-        add   ax,1000h\r
-        mov   ds,ax\r
-\r
-        mov   sp,07c00h                           ; SP = 0x7c00\r
-        mov   bp,sp                               ; BP = 0x7c00\r
-\r
-        mov   ah,8                                ; AH = 8 - Get Drive Parameters Function\r
-        mov   byte ptr [bp+PhysicalDrive],dl      ; BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-        int   13h                                 ; Get Drive Parameters\r
-        xor   ax,ax                               ; AX = 0\r
-        mov   al,dh                               ; AL = DH\r
-        inc   al                                  ; MaxHead = AL + 1\r
-        push  ax                                  ; 0000:7bfe = MaxHead\r
-        mov   al,cl                               ; AL = CL\r
-        and   al,03fh                             ; MaxSector = AL & 0x3f\r
-        push  ax                                  ; 0000:7bfc = MaxSector\r
-\r
-; ****************************************************************************\r
-; Read Target DBR from hard disk to 0x0000:0x7C00\r
-; ****************************************************************************\r
-\r
-        xor   ax, ax\r
-        mov   al, byte ptr [bp+MbrPartitionIndicator]  ; AX = MbrPartitionIndex\r
-        cmp   al, 0ffh                                 ; 0xFF means do legacy MBR boot\r
-        jnz   EfiDbr\r
-LegacyMbr:\r
-        mov   eax, 00000600h                      ; Assume LegacyMBR is backuped in Sector 6\r
-        jmp   StartReadTo7C00                     ; EAX = Header/Sector/Tracker/Zero\r
-\r
-EfiDbr:\r
-        cmp   al, 4                               ; MbrPartitionIndex should < 4\r
-        jae   BadDbr\r
-        shl   ax, 4                               ; AX  = MBREntrySize * Index\r
-        add   ax, 1beh                            ; AX  = MBREntryOffset\r
-        mov   di, ax                              ; DI  = MBREntryOffset\r
-\r
-        ; Here we don't use the C/H/S information provided by Partition table\r
-        ;  but calculate C/H/S from LBA ourselves\r
-        ;       Ci: Cylinder number\r
-        ;       Hi: Header number\r
-        ;       Si: Sector number\r
-        mov   eax, dword ptr es:[bp + di + 8]     ; Start LBA\r
-        mov   edx, eax\r
-        shr   edx, 16                             ; DX:AX = Start LBA\r
-                                                  ;       = Ci * (H * S) + Hi * S + (Si - 1)\r
-\r
-        ; Calculate C/H/S according to LBA\r
-        mov   bp, 7bfah\r
-        div   word ptr [bp+2]                     ; AX = Hi + H*Ci\r
-                                                  ; DX = Si - 1\r
-        inc   dx                                  ; DX = Si\r
-        push  dx                                  ; 0000:7bfa = Si  <----\r
-        xor   dx, dx                              ; DX:AX = Hi + H*Ci\r
-        div   word ptr [bp+4]                     ; AX = Ci         <----\r
-                                                  ; DX = Hi         <----\r
-\r
-StartReadTo7C00:\r
-\r
-        mov   cl, byte ptr [bp]                   ; Si\r
-        mov   ch, al                              ; Ci[0-7]\r
-        or    cl, ah                              ; Ci[8,9]\r
-        mov   bx, 7c00h                           ; ES:BX = 0000:7C00h\r
-        mov   ah, 2h                              ; Function 02h\r
-        mov   al, 1                               ; 1 Sector\r
-        mov   dh, dl                              ; Hi\r
-        mov   bp, 0600h\r
-        mov   dl, byte ptr [bp + PhysicalDrive]   ; Drive number\r
-        int   13h\r
-        jc    BadDbr\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; Transfer control to BootSector - Jump to 0x0000:0x7C00\r
-; ****************************************************************************\r
-        xor   ax, ax\r
-        push  ax                                  ; PUSH 0x0000 - Segment\r
-        mov   di, 07c00h\r
-        push  di                                  ; PUSH 0x7C00 - Offset\r
-        retf                                      ; JMP 0x0000:0x7C00\r
-\r
-; ****************************************************************************\r
-; ERROR Condition:\r
-; ****************************************************************************\r
-\r
-BadDbr:\r
-    push ax\r
-    mov  ax, 0b800h\r
-    mov  es, ax\r
-    mov  ax, 060h\r
-    mov  ds, ax\r
-    lea  si, cs:[ErrorString]\r
-    mov  di, 320\r
-    pop  ax\r
-    call A2C\r
-    mov  [si+16], ah\r
-    mov  [si+18], al\r
-    mov  cx, 10\r
-    rep  movsw\r
-Halt:\r
-    jmp   Halt\r
-\r
-StartString:\r
-    db 'M', 0ch, 'B', 0ch, 'R', 0ch, ' ', 0ch, 'S', 0ch, 't', 0ch, 'a', 0ch, 'r', 0ch, 't', 0ch, '!', 0ch\r
-ErrorString:\r
-    db 'M', 0ch, 'B', 0ch, 'R', 0ch, ' ', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, ':', 0ch, '?', 0ch, '?', 0ch\r
-\r
-; ****************************************************************************\r
-; A2C - convert Ascii code stored in AH to character stored in AX\r
-; ****************************************************************************\r
-A2C:\r
-    mov  al, ah\r
-    shr  ah, 4\r
-    and  al, 0Fh\r
-    add  ah, '0'\r
-    add  al, '0'\r
-\r
-    cmp  ah, '9'\r
-    jle  @f\r
-    add  ah, 7\r
-@@:\r
-\r
-    cmp al, '9'\r
-    jle @f\r
-    add al, 7\r
-@@:\r
-    ret\r
-\r
-\r
-; ****************************************************************************\r
-; PhysicalDrive - Used to indicate which disk to be boot\r
-;                 Can be patched by tool\r
-; ****************************************************************************\r
-    org   01B6h\r
-PhysicalDrive         db  80h\r
-\r
-; ****************************************************************************\r
-; MbrPartitionIndicator - Used to indicate which MBR partition to be boot\r
-;                         Can be patched by tool\r
-;                         OxFF means boot to legacy MBR. (LBA OFFSET 6)\r
-; ****************************************************************************\r
-    org   01B7h\r
-MbrPartitionIndicator db 0\r
-\r
-; ****************************************************************************\r
-; Unique MBR signature\r
-; ****************************************************************************\r
-    org   01B8h\r
-    db 'DUET'\r
-\r
-; ****************************************************************************\r
-; Unknown\r
-; ****************************************************************************\r
-    org   01BCh\r
-    dw 0\r
-\r
-; ****************************************************************************\r
-; MBR Entry - To be patched\r
-; ****************************************************************************\r
-    org   01BEh\r
-    dd 0, 0, 0, 0\r
-    org   01CEh\r
-    dd 0, 0, 0, 0\r
-    org   01DEh\r
-    dd 0, 0, 0, 0\r
-    org   01EEh\r
-    dd 0, 0, 0, 0\r
-\r
-; ****************************************************************************\r
-; Sector Signature\r
-; ****************************************************************************\r
-\r
-  org 01FEh\r
-SectorSignature:\r
-  dw        0aa55h      ; Boot Sector Signature\r
-\r
-  end\r
-\r
diff --git a/DuetPkg/BootSector/bin/Gpt.com b/DuetPkg/BootSector/bin/Gpt.com
deleted file mode 100644 (file)
index f055fd7..0000000
Binary files a/DuetPkg/BootSector/bin/Gpt.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/Mbr.com b/DuetPkg/BootSector/bin/Mbr.com
deleted file mode 100644 (file)
index ca292a0..0000000
Binary files a/DuetPkg/BootSector/bin/Mbr.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/Readme.txt b/DuetPkg/BootSector/bin/Readme.txt
deleted file mode 100644 (file)
index 55dd8cd..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-These binaries are used to make the bootable floppy or usb disk. \r
-The binaries of boot sector are built from DuetPkg\Bootsector\BootSector.inf at r8617 with following steps:\r
-1) enter edk2 workspace directory from command line windows.\r
-2) run "edksetup.bat"\r
-3) run "build -p DuetPkg/DuetPkg.dsc -a IA32 -m DuetPkg/BootSector/BootSector.inf"\r
-\r
-\r
-\r
diff --git a/DuetPkg/BootSector/bin/St16_64.com b/DuetPkg/BootSector/bin/St16_64.com
deleted file mode 100644 (file)
index dbb4a9a..0000000
Binary files a/DuetPkg/BootSector/bin/St16_64.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/St32_64.com b/DuetPkg/BootSector/bin/St32_64.com
deleted file mode 100644 (file)
index 68b6c76..0000000
Binary files a/DuetPkg/BootSector/bin/St32_64.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/Start.com b/DuetPkg/BootSector/bin/Start.com
deleted file mode 100644 (file)
index 0fd19a1..0000000
Binary files a/DuetPkg/BootSector/bin/Start.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/Start16.com b/DuetPkg/BootSector/bin/Start16.com
deleted file mode 100644 (file)
index b2d77c1..0000000
Binary files a/DuetPkg/BootSector/bin/Start16.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/Start32.com b/DuetPkg/BootSector/bin/Start32.com
deleted file mode 100644 (file)
index ac0e3cb..0000000
Binary files a/DuetPkg/BootSector/bin/Start32.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/Start64.com b/DuetPkg/BootSector/bin/Start64.com
deleted file mode 100644 (file)
index 326e3fe..0000000
Binary files a/DuetPkg/BootSector/bin/Start64.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/bootsect.com b/DuetPkg/BootSector/bin/bootsect.com
deleted file mode 100644 (file)
index 079978e..0000000
Binary files a/DuetPkg/BootSector/bin/bootsect.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/bs16.com b/DuetPkg/BootSector/bin/bs16.com
deleted file mode 100644 (file)
index be40ba8..0000000
Binary files a/DuetPkg/BootSector/bin/bs16.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/bs32.com b/DuetPkg/BootSector/bin/bs32.com
deleted file mode 100644 (file)
index 9cd368a..0000000
Binary files a/DuetPkg/BootSector/bin/bs32.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/efi32.com b/DuetPkg/BootSector/bin/efi32.com
deleted file mode 100644 (file)
index 4bcd83e..0000000
Binary files a/DuetPkg/BootSector/bin/efi32.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/efi32.com2 b/DuetPkg/BootSector/bin/efi32.com2
deleted file mode 100644 (file)
index 05522ec..0000000
Binary files a/DuetPkg/BootSector/bin/efi32.com2 and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/efi64.com b/DuetPkg/BootSector/bin/efi64.com
deleted file mode 100644 (file)
index e534132..0000000
Binary files a/DuetPkg/BootSector/bin/efi64.com and /dev/null differ
diff --git a/DuetPkg/BootSector/bin/efi64.com2 b/DuetPkg/BootSector/bin/efi64.com2
deleted file mode 100644 (file)
index 689f4ab..0000000
Binary files a/DuetPkg/BootSector/bin/efi64.com2 and /dev/null differ
diff --git a/DuetPkg/BootSector/bootsect.S b/DuetPkg/BootSector/bootsect.S
deleted file mode 100644 (file)
index 5993a1a..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*   bootsect.S\r
-#*  \r
-#*   bootsect.S is built as 16-bit binary file in 512 bytes and patched to disk/partition's \r
-#*   first section - boot sector. \r
-#*\r
-#*   The startup sequence for DUET disk boot sector is:\r
-#*\r
-#*   1, LegacyBios check 0xAA55 signature at boot sectore offset 0x1FE to judget \r
-#*      whether disk/partition is bootable.\r
-#*   2, LegacyBios will load boot sector to 0x7c00 in real mode, pass BPB data and\r
-#*      hand off control to 0x7c00 code.\r
-#*   3, boot sector code simply parse FAT format in boot disk and find EfiLdr binary file \r
-#*      and EfiVar.bin if exists. For first boot, EfiVar.bin does not exist.\r
-#*   4, boot sector load the first sector of EfiLdr binary which is start.com to\r
-#*      0x2000:0x0000 address.\r
-#*   5, boot sector handoff control to 0x2000:0x0000 for start.com binary.\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                      FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                      FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                      BLOCK_SIZE, 0x0200\r
-.equ                      BLOCK_MASK, 0x01ff\r
-.equ                      BLOCK_SHIFT, 9\r
-                                               # "EFILDR_____"\r
-.equ                      LOADER_FILENAME_PART1, 0x04c494645    # "EFIL"\r
-.equ                      LOADER_FILENAME_PART2, 0x020205244    # "DR__"\r
-.equ                      LOADER_FILENAME_PART3, 0x020202020    # "____"\r
-\r
-        .org 0x0\r
-.global _start\r
-_start:\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst                  - 3 bytes\r
-  nop\r
-\r
-OemId:              .ascii   "INTEL   "       # OemId               - 8 bytes\r
-# BPB data below will be fixed by tool\r
-SectorSize:         .word  0                  # Sector Size         - 16 bits\r
-SectorsPerCluster:  .byte  0                  # Sector Per Cluster  - 8 bits\r
-ReservedSectors:    .word  0                  # Reserved Sectors    - 16 bits\r
-NoFats:             .byte  0                  # Number of FATs      - 8 bits\r
-RootEntries:        .word  0                  # Root Entries        - 16 bits\r
-Sectors:            .word  0                  # Number of Sectors   - 16 bits\r
-Media:              .byte  0                  # Media               - 8 bits  - ignored\r
-SectorsPerFat:      .word  0                  # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:    .word  0                  # Sectors Per Track   - 16 bits - ignored\r
-Heads:              .word  0                  # Heads               - 16 bits - ignored\r
-HiddenSectors:      .long  0                  # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:       .long  0                  # Large Sectors       - 32 bits \r
-PhysicalDrive:      .byte  0                  # PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead:        .byte  0                  # Current Head        - 8 bits\r
-Signature:          .byte  0                  # Signature           - 8 bits  - ignored\r
-VolId:              .ascii "    "             # Volume Serial Number- 4 bytes\r
-FatLabel:           .ascii "           "      # Label               - 11 bytes\r
-SystemId:           .ascii "FAT12   "         # SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-        #ASSUME ds:@code\r
-        #ASSUME ss:@code\r
-\r
-# ****************************************************************************\r
-# Start Print\r
-# ****************************************************************************\r
-  movw $StartString, %si\r
-  call PrintString\r
-\r
-# ****************************************************************************\r
-# Print over\r
-# ****************************************************************************\r
-\r
-  movw  %cs, %ax      # ax = 0\r
-  movw  %ax, %ss      # ss = 0\r
-  addw  $0x1000, %ax\r
-  movw  %ax, %ds\r
-\r
-  movw  $0x7c00, %sp  # sp = 0x7c00\r
-  movw  %sp, %bp      # bp = 0x7c00\r
-\r
-  movb  $8, %ah                             # ah = 8 - Get Drive Parameters Function\r
-  movb  %dl, PhysicalDrive(%bp)             # BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-  int   $0x13                               # Get Drive Parameters\r
-  xorw  %ax, %ax                # ax = 0\r
-  movb  %dh, %al                # al = dh\r
-  incb  %al                     # MaxHead = al + 1\r
-  pushw %ax                     # 0000:7bfe = MaxHead\r
-  movb  %cl, %al                # al = cl\r
-  andb  $0x3f, %al              # MaxSector = al & 0x3f\r
-  pushw %ax                     # 0000:7bfc = MaxSector\r
-\r
-  cmpw  $0xaa55, SectorSignature(%bp)         # Verify Boot Sector Signature\r
-  jne   BadBootSector\r
-  movw  RootEntries(%bp), %cx             # cx = RootEntries\r
-  shlw  $FAT_DIRECTORY_ENTRY_SHIFT, %cx   # cx = cx * 32 = cx * sizeof(FAT_DIRECTORY_ENTRY) = Size of Root Directory in bytes\r
-  movw  %cx, %bx                          # bx = size of the Root Directory in bytes\r
-  andw  $BLOCK_MASK, %bx                  # See if it is an even number of sectors long\r
-  jne   BadBootSector                     # If is isn't, then the boot sector is bad.\r
-  movw  %cx, %bx                          # bx = size of the Root Directory in bytes\r
-  shrw  $BLOCK_SHIFT, %bx                 # bx = size of Root Directory in sectors\r
-  movb  NoFats(%bp), %al                  # al = NoFats\r
-  xorb  %ah, %ah                          # ah = 0  ==> ax = NoFats\r
-  mulw  SectorsPerFat(%bp)                # ax = NoFats * SectorsPerFat\r
-  addw  ReservedSectors(%bp), %ax         # ax = NoFats * SectorsPerFat + ReservedSectors = RootLBA\r
-  pushw %ds\r
-  popw  %es\r
-  xorw  %di, %di                          # Store directory in es:di = 1000:0000\r
-  call  ReadBlocks                        # Read entire Root Directory\r
-  addw  %bx, %ax                          # ax = NoFats * SectorsPerFat + ReservedSectors + RootDirSectors = FirstClusterLBA (FirstDataSector)\r
-  movw  %ax, (%bp)                        # Save FirstClusterLBA (FirstDataSector) for later use\r
-\r
-  # dx - variable storage (initial value is 0)\r
-  # bx - loader (initial value is 0)\r
-  xorw  %dx, %dx\r
-  xorw  %bx, %bx\r
-\r
-FindEFILDR: \r
-  cmpl   $LOADER_FILENAME_PART1, (%di)        # Compare to "EFIL"\r
-  jne   FindVARSTORE\r
-  cmpl   $LOADER_FILENAME_PART2, 4(%di) \r
-  jne   FindVARSTORE\r
-  cmpl   $LOADER_FILENAME_PART3, 7(%di) \r
-  jne   FindVARSTORE\r
-  movw  26(%di), %bx                      # bx = Start Cluster for EFILDR  <----------------------------------\r
-  testw %dx, %dx\r
-  je    FindNext                          # Efivar.bin is not loaded\r
-  jmp   FoundAll\r
-\r
-FindVARSTORE: \r
-  ## if the file is not loader file, see if it's "EFIVAR  BIN"\r
-  cmpl  $0x56494645, (%di)                # Compare to "EFIV"\r
-  jne   FindNext\r
-  cmpl  $0x20205241, 4(%di)               # Compare to "AR  "\r
-  jne   FindNext\r
-  cmpl  $0x4e494220, 7(%di)               # Compare to " BIN"\r
-  jne   FindNext\r
-  movw  %di, %dx                          # dx = Offset of Start Cluster for Efivar.bin <---------------------\r
-  addw  $26, %dx\r
-  testw %bx, %bx\r
-  je    FindNext                          # Efildr is not loaded\r
-  jmp   FoundAll\r
-\r
-FindNext: \r
-  # go to next find\r
-  addw  $FAT_DIRECTORY_ENTRY_SIZE, %di    # Increment di\r
-  subw  $FAT_DIRECTORY_ENTRY_SIZE, %cx    # Decrement cx\r
-  # TODO: jump to FindVarStore if ...\r
-  jne   FindEFILDR\r
-  jmp   NotFoundAll\r
-\r
-FoundAll: \r
-FoundEFILDR: \r
-  movw    %bx, %cx                            # cx = Start Cluster for EFILDR  <----------------------------------\r
-  movw    %cs, %ax                            # Destination = 2000:0000\r
-  addw    $0x2000, %ax\r
-  movw    %ax, %es\r
-  xorw    %di, %di\r
-ReadFirstClusterOfEFILDR: \r
-  movw    %cx, %ax                            # ax = StartCluster\r
-  subw    $2, %ax                             # ax = StartCluster - 2\r
-  xorb    %bh, %bh\r
-  movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-  pushw   %dx\r
-  mulw    %bx\r
-  popw    %dx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-  addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  xorb    %bh, %bh\r
-  movb    SectorsPerCluster(%bp), %bl         # bx = Number of Sectors in a cluster\r
-  pushw   %es\r
-  call    ReadBlocks\r
-  popw    %ax\r
-JumpIntoFirstSectorOfEFILDR: \r
-  movw    %ax, JumpSegment(%bp)\r
-JumpFarInstruction: \r
-  .byte   0xea\r
-JumpOffset: \r
-  .word   0x000\r
-JumpSegment: \r
-  .word   0x2000\r
-\r
-\r
-PrintString: \r
-  movw $0xb800, %ax\r
-  movw %ax, %es\r
-  movw $0x7c0, %ax\r
-  movw %ax, %ds\r
-  movw $7, %cx\r
-  movw $160, %di\r
-  rep\r
-  movsw\r
-  ret\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-  pusha\r
-  addl    LBAOffsetForBootSector(%bp), %eax            # Add LBAOffsetForBootSector to Start LBA\r
-  addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-  movl    %eax, %esi                          # esi = Start LBA\r
-  movw    %bx, %cx                            # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-  movw    $0x7bfc, %bp                        # bp = 0x7bfc\r
-  movl    %esi, %eax                          # eax = Start LBA\r
-  xorl    %edx, %edx                          # edx = 0\r
-  movzwl  (%bp), %ebx                         # bx = MaxSector\r
-  divl    %ebx                                # ax = StartLBA / MaxSector\r
-  incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-  subw    %dx, %bx                            # bx = MaxSector - Sector\r
-  incw    %bx                                 # bx = MaxSector - Sector + 1\r
-  cmpw    %bx, %cx                            # Compare (Blocks) to (MaxSector - Sector + 1)\r
-  jg      LimitTransfer\r
-  movw    %cx, %bx                            # bx = Blocks\r
-LimitTransfer: \r
-  pushw   %cx\r
-  movb    %dl, %cl                            # cl = (StartLBA % MaxSector) + 1 = Sector\r
-  xorw    %dx, %dx                            # dx = 0\r
-  divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                              # dx = ax % (MaxHead + 1) = Head\r
-\r
-  pushw   %bx                                 # Save number of blocks to transfer\r
-  movb    %dl, %dh                            # dh = Head\r
-  movw    $0x7c00, %bp                        # bp = 0x7c00\r
-  movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-  movb    %al, %ch                            # ch = Cylinder\r
-  movb    %bl, %al                            # al = Blocks\r
-  movb    $2, %ah                             # ah = Function 2\r
-  movw    %di, %bx                            # es:bx = Buffer address\r
-  int     $0x13\r
-  jc      DiskError\r
-  popw    %bx\r
-  popw    %cx\r
-  movzwl  %bx, %ebx\r
-  addl    %ebx, %esi                          # StartLBA = StartLBA + NumberOfBlocks\r
-  subw    %bx, %cx                            # Blocks = Blocks - NumberOfBlocks\r
-  movw    %es, %ax\r
-  shlw    $(BLOCK_SHIFT-4), %bx\r
-  addw    %bx, %ax\r
-  movw    %ax, %es                            # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-  cmpw    $0, %cx\r
-  jne     ReadCylinderLoop\r
-  popa\r
-  ret\r
-\r
-# ****************************************************************************\r
-# ERROR Condition:\r
-# ****************************************************************************\r
-NotFoundAll: \r
-  ## if we found EFILDR, continue\r
-  testw %bx, %bx\r
-  jne  FoundEFILDR\r
-BadBootSector: \r
-DiskError: \r
-  movw $ErrorString, %si\r
-  call PrintString\r
-Halt: \r
-  jmp   Halt\r
-\r
-StartString: \r
-  .byte 'B', 0x0c, 'S', 0x0c, 't', 0x0c, 'a', 0x0c, 'r', 0x0c, 't', 0x0c, '!', 0x0c\r
-ErrorString: \r
-  .byte 'B', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!', 0x0c\r
-\r
-# ****************************************************************************\r
-# LBA Offset for BootSector, need patched by tool for HD boot.\r
-# ****************************************************************************\r
-\r
-  .org 0x01fa   # Comment it for pass build. Should optimise code size. \r
-LBAOffsetForBootSector: \r
-  .long     0x0\r
-\r
-# ****************************************************************************\r
-# Sector Signature\r
-# ****************************************************************************\r
-\r
-  .org 0x01fe    # Comment it for pass build.\r
-SectorSignature: \r
-  .word     0xaa55      # Boot Sector Signature\r
-\r
-\r
-\r
diff --git a/DuetPkg/BootSector/bootsect.asm b/DuetPkg/BootSector/bootsect.asm
deleted file mode 100644 (file)
index 3366b7a..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*   bootsect.asm\r
-;*    \r
-;*   bootsect.asm is built as 16-bit binary file in 512 bytes and patched to disk/partition's \r
-;*   first section - boot sector. \r
-;*\r
-;*   The startup sequence for DUET disk boot sector is:\r
-;*\r
-;*   1, LegacyBios check 0xAA55 signature at boot sectore offset 0x1FE to judget \r
-;*      whether disk/partition is bootable.\r
-;*   2, LegacyBios will load boot sector to 0x7c00 in real mode, pass BPB data and\r
-;*      hand off control to 0x7c00 code.\r
-;*   3, boot sector code simply parse FAT format in boot disk and find EfiLdr binary file \r
-;*      and EfiVar.bin if exists. For first boot, EfiVar.bin does not exist.\r
-;*   4, boot sector load the first sector of EfiLdr binary which is start.com to\r
-;*      0x2000:0x0000 address.\r
-;*   5, boot sector handoff control to 0x2000:0x0000 for start.com binary.\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE  EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT EQU     5\r
-BLOCK_SIZE                EQU     0200h\r
-BLOCK_MASK                EQU     01ffh\r
-BLOCK_SHIFT               EQU     9\r
-                                               ; "EFILDR_____"\r
-LOADER_FILENAME_PART1     EQU     04c494645h   ; "EFIL"\r
-LOADER_FILENAME_PART2     EQU     020205244h   ; "DR__"\r
-LOADER_FILENAME_PART3     EQU     020202020h   ; "____"\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst                  - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-; BPB data below will be fixed by tool\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-PhysicalDrive     db  0             ; PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead       db  0             ; Current Head        - 8 bits\r
-Signature         db  0             ; Signature           - 8 bits  - ignored\r
-Id                db  "    "        ; Id                  - 4 bytes\r
-FatLabel          db  "           " ; Label               - 11 bytes\r
-SystemId          db  "FAT12   "    ; SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-\r
-; ****************************************************************************\r
-; Start Print\r
-; ****************************************************************************\r
-  lea  si, cs:[StartString]\r
-  call PrintString\r
-\r
-; ****************************************************************************\r
-; Print over\r
-; ****************************************************************************\r
-\r
-  mov   ax,cs         ; ax = 0\r
-  mov   ss,ax         ; ss = 0\r
-  add   ax,1000h\r
-  mov   ds,ax\r
-\r
-  mov   sp,07c00h     ; sp = 0x7c00\r
-  mov   bp,sp         ; bp = 0x7c00\r
-\r
-  mov   ah,8                                ; ah = 8 - Get Drive Parameters Function\r
-  mov   byte ptr [bp+PhysicalDrive],dl      ; BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-  int   13h                                 ; Get Drive Parameters\r
-  xor   ax,ax                               ; ax = 0\r
-  mov   al,dh                               ; al = dh (number of sides (0 based))\r
-  inc   al                                  ; MaxHead = al + 1\r
-  push  ax                                  ; 0000:7bfe = MaxHead\r
-  mov   al,cl                               ; al = cl (CL = sectors per track)\r
-  and   al,03fh                             ; MaxSector = al & 0x3f\r
-  push  ax                                  ; 0000:7bfc = MaxSector\r
-\r
-  cmp   word ptr [bp+SectorSignature],0aa55h  ; Verify Boot Sector Signature\r
-  jne   BadBootSector\r
-  mov   cx,word ptr [bp+RootEntries]      ; cx = RootEntries\r
-  shl   cx,FAT_DIRECTORY_ENTRY_SHIFT      ; cx = cx * 32 = cx * sizeof(FAT_DIRECTORY_ENTRY) = Size of Root Directory in bytes\r
-  mov   bx,cx                             ; bx = size of the Root Directory in bytes\r
-  and   bx,BLOCK_MASK                     ; See if it is an even number of sectors long\r
-  jne   BadBootSector                     ; If is isn't, then the boot sector is bad.\r
-  mov   bx,cx                             ; bx = size of the Root Directory in bytes\r
-  shr   bx,BLOCK_SHIFT                    ; bx = size of Root Directory in sectors\r
-  mov   al,byte ptr [bp+NoFats]           ; al = NoFats\r
-  xor   ah,ah                             ; ah = 0  ==> ax = NoFats\r
-  mul   word ptr [bp+SectorsPerFat]       ; ax = NoFats * SectorsPerFat\r
-  add   ax,word ptr [bp+ReservedSectors]  ; ax = NoFats * SectorsPerFat + ReservedSectors = RootLBA\r
-  push  ds\r
-  pop   es\r
-  xor   di,di                             ; Store directory in es:di = 1000:0000\r
-  call  ReadBlocks                        ; Read entire Root Directory\r
-  add   ax,bx                             ; ax = NoFats * SectorsPerFat + ReservedSectors + RootDirSectors = FirstClusterLBA (FirstDataSector)\r
-  mov   word ptr [bp],ax                  ; Save FirstClusterLBA (FirstDataSector) for later use\r
-\r
-  ; dx - variable storage (initial value is 0)\r
-  ; bx - loader (initial value is 0)\r
-  xor   dx, dx\r
-  xor   bx, bx\r
-\r
-FindEFILDR:\r
-  cmp   dword ptr [di],LOADER_FILENAME_PART1         ; Compare to "EFIL"\r
-  jne   FindVARSTORE\r
-  cmp   dword ptr [di+4],LOADER_FILENAME_PART2\r
-  jne   FindVARSTORE\r
-  cmp   dword ptr [di+7],LOADER_FILENAME_PART3\r
-  jne   FindVARSTORE\r
-  mov   bx, word ptr [di+26]              ; bx = Start Cluster for EFILDR  <----------------------------------\r
-  test  dx, dx\r
-  je    FindNext                          ; Efivar.bin is not loaded\r
-  jmp   FoundAll\r
-\r
-FindVARSTORE:\r
-  ; if the file is not loader file, see if it's "EFIVAR  BIN"\r
-  cmp   dword ptr [di], 056494645h        ; Compare to "EFIV"\r
-  jne   FindNext\r
-  cmp   dword ptr [di+4], 020205241h      ; Compare to "AR  "\r
-  jne   FindNext\r
-  cmp   dword ptr [di+7], 04e494220h      ; Compare to " BIN"\r
-  jne   FindNext\r
-  mov   dx, di                            ; dx = Offset of Start Cluster for Efivar.bin <---------------------\r
-  add   dx, 26\r
-  test  bx, bx\r
-  je    FindNext                          ; Efildr is not loaded\r
-  jmp   FoundAll\r
-  \r
-FindNext:\r
-  ; go to next find\r
-  add   di,FAT_DIRECTORY_ENTRY_SIZE       ; Increment di\r
-  sub   cx,FAT_DIRECTORY_ENTRY_SIZE       ; Decrement cx\r
-  ; TODO: jump to FindVarStore if ...\r
-  jne   FindEFILDR\r
-  jmp   NotFoundAll\r
-\r
-FoundAll:\r
-FoundEFILDR:                                  ; 0x7cfe\r
-  mov     cx,bx                               ; cx = Start Cluster for EFILDR  <----------------------------------\r
-  mov     ax,cs                               ; Destination = 2000:0000\r
-  add     ax,2000h\r
-  mov     es,ax\r
-  xor     di,di\r
-ReadFirstClusterOfEFILDR:\r
-  mov     ax,cx                               ; ax = StartCluster\r
-  sub     ax,2                                ; ax = StartCluster - 2\r
-  xor     bh,bh                               \r
-  mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-  push    dx\r
-  mul     bx\r
-  pop     dx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-  add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  xor     bh,bh\r
-  mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = Number of Sectors in a cluster\r
-  push    es\r
-  call    ReadBlocks\r
-  pop     ax\r
-JumpIntoFirstSectorOfEFILDR:\r
-  mov     word ptr [bp+JumpSegment],ax        ; 0x7d26\r
-JumpFarInstruction:                           ; 0x7d2a\r
-  db      0eah\r
-JumpOffset:\r
-  dw      0000h\r
-JumpSegment:\r
-  dw      2000h\r
-\r
-\r
-PrintString:\r
-  mov  ax,0b800h\r
-  mov  es,ax\r
-  mov  ax, 07c0h\r
-  mov  ds, ax\r
-  mov  cx, 7\r
-  mov  di, 160\r
-  rep  movsw\r
-  ret\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-  pusha\r
-  add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-  add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-  mov     esi,eax                             ; esi = Start LBA\r
-  mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-  mov     bp,07bfch                           ; bp = 0x7bfc\r
-  mov     eax,esi                             ; eax = Start LBA\r
-  xor     edx,edx                             ; edx = 0\r
-  movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-  div     ebx                                 ; ax = StartLBA / MaxSector\r
-  inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-  sub     bx,dx                               ; bx = MaxSector - Sector\r
-  inc     bx                                  ; bx = MaxSector - Sector + 1\r
-  cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-  jg      LimitTransfer\r
-  mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-  push    cx\r
-  mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-  xor     dx,dx                               ; dx = 0\r
-  div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                              ; dx = ax % (MaxHead + 1) = Head\r
-\r
-  push    bx                                  ; Save number of blocks to transfer\r
-  mov     dh,dl                               ; dh = Head\r
-  mov     bp,07c00h                           ; bp = 0x7c00\r
-  mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-  mov     ch,al                               ; ch = Cylinder\r
-  mov     al,bl                               ; al = Blocks\r
-  mov     ah,2                                ; ah = Function 2\r
-  mov     bx,di                               ; es:bx = Buffer address\r
-  int     013h\r
-  jc      DiskError\r
-  pop     bx\r
-  pop     cx\r
-  movzx   ebx,bx\r
-  add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-  sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-  mov     ax,es\r
-  shl     bx,(BLOCK_SHIFT-4)\r
-  add     ax,bx\r
-  mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-  cmp     cx,0\r
-  jne     ReadCylinderLoop\r
-  popa\r
-  ret\r
-\r
-; ****************************************************************************\r
-; ERROR Condition:\r
-; ****************************************************************************\r
-NotFoundAll:                            ; 0x7da6\r
-  ; if we found EFILDR, continue\r
-  test bx,bx\r
-  jne  FoundEFILDR\r
-BadBootSector:\r
-DiskError:\r
-  lea  si, cs:[ErrorString]\r
-  call PrintString\r
-Halt:\r
-  jmp   Halt\r
-\r
-StartString:\r
-  db 'B', 0ch, 'S', 0ch, 't', 0ch, 'a', 0ch, 'r', 0ch, 't', 0ch, '!', 0ch\r
-ErrorString:\r
-  db 'B', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-; ****************************************************************************\r
-; LBA Offset for BootSector, need patched by tool for HD boot.\r
-; ****************************************************************************\r
-\r
-  org 01fah\r
-LBAOffsetForBootSector:\r
-  dd        0h\r
-\r
-; ****************************************************************************\r
-; Sector Signature\r
-; ****************************************************************************\r
-\r
-  org 01feh\r
-SectorSignature:\r
-  dw        0aa55h      ; Boot Sector Signature\r
-\r
-  end \r
-  \r
diff --git a/DuetPkg/BootSector/bs16.S b/DuetPkg/BootSector/bs16.S
deleted file mode 100644 (file)
index 039e256..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    bs16.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-        #.MODEL small\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                      FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                      FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                      BLOCK_SIZE, 0x0200\r
-.equ                      BLOCK_MASK, 0x01ff\r
-.equ                      BLOCK_SHIFT, 9\r
-                                               # "EFILDR_____"\r
-.equ                      LOADER_FILENAME_PART1, 0x04c494645    # "EFIL"\r
-.equ                      LOADER_FILENAME_PART2, 0x036315244    # "DR16"\r
-.equ                      LOADER_FILENAME_PART3, 0x020202036    # "6___"\r
-\r
-        .org 0x0\r
-.global _start\r
-_start:\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst                  - 3 bytes\r
-  nop\r
-\r
-OemId:              .ascii   "INTEL   "       # OemId               - 8 bytes\r
-# BPB data below will be fixed by tool\r
-SectorSize:         .word  0                  # Sector Size         - 16 bits\r
-SectorsPerCluster:  .byte  0                  # Sector Per Cluster  - 8 bits\r
-ReservedSectors:    .word  0                  # Reserved Sectors    - 16 bits\r
-NoFats:             .byte  0                  # Number of FATs      - 8 bits\r
-RootEntries:        .word  0                  # Root Entries        - 16 bits\r
-Sectors:            .word  0                  # Number of Sectors   - 16 bits\r
-Media:              .byte  0                  # Media               - 8 bits  - ignored\r
-SectorsPerFat:      .word  0                  # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:    .word  0                  # Sectors Per Track   - 16 bits - ignored\r
-Heads:              .word  0                  # Heads               - 16 bits - ignored\r
-HiddenSectors:      .long  0                  # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:       .long  0                  # Large Sectors       - 32 bits \r
-PhysicalDrive:      .byte  0                  # PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead:        .byte  0                  # Current Head        - 8 bits\r
-Signature:          .byte  0                  # Signature           - 8 bits  - ignored\r
-VolId:              .ascii "    "             # Volume Serial Number- 4 bytes\r
-FatLabel:           .ascii "           "      # Label               - 11 bytes\r
-SystemId:           .ascii "FAT12   "         # SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-        #ASSUME ds:@code\r
-        #ASSUME ss:@code\r
-\r
-# ****************************************************************************\r
-# Start Print\r
-# ****************************************************************************\r
-  movw $StartString, %si\r
-  call PrintString\r
-\r
-# ****************************************************************************\r
-# Print over\r
-# ****************************************************************************\r
-\r
-  movw  %cs, %ax      # ax = 0\r
-  movw  %ax, %ss      # ss = 0\r
-  addw  $0x1000, %ax\r
-  movw  %ax, %ds\r
-\r
-  movw  $0x7c00, %sp  # sp = 0x7c00\r
-  movw  %sp, %bp      # bp = 0x7c00\r
-\r
-  movb  $8, %ah                             # ah = 8 - Get Drive Parameters Function\r
-  movb  %dl, PhysicalDrive(%bp)             # BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-  int   $0x13                               # Get Drive Parameters\r
-  xorw  %ax, %ax                # ax = 0\r
-  movb  %dh, %al                # al = dh\r
-  incb  %al                     # MaxHead = al + 1\r
-  pushw %ax                     # 0000:7bfe = MaxHead\r
-  movb  %cl, %al                # al = cl\r
-  andb  $0x3f, %al              # MaxSector = al & 0x3f\r
-  pushw %ax                     # 0000:7bfc = MaxSector\r
-\r
-  cmpw  $0xaa55, SectorSignature(%bp)         # Verify Boot Sector Signature\r
-  jne   BadBootSector\r
-  movw  RootEntries(%bp), %cx             # cx = RootEntries\r
-  shlw  $FAT_DIRECTORY_ENTRY_SHIFT, %cx   # cx = cx * 32 = cx * sizeof(FAT_DIRECTORY_ENTRY) = Size of Root Directory in bytes\r
-  movw  %cx, %bx                          # bx = size of the Root Directory in bytes\r
-  andw  $BLOCK_MASK, %bx                  # See if it is an even number of sectors long\r
-  jne   BadBootSector                     # If is isn't, then the boot sector is bad.\r
-  movw  %cx, %bx                          # bx = size of the Root Directory in bytes\r
-  shrw  $BLOCK_SHIFT, %bx                 # bx = size of Root Directory in sectors\r
-  movb  NoFats(%bp), %al                  # al = NoFats\r
-  xorb  %ah, %ah                          # ah = 0  ==> ax = NoFats\r
-  mulw  SectorsPerFat(%bp)                # ax = NoFats * SectorsPerFat\r
-  addw  ReservedSectors(%bp), %ax         # ax = NoFats * SectorsPerFat + ReservedSectors = RootLBA\r
-  pushw %ds\r
-  popw  %es\r
-  xorw  %di, %di                          # Store directory in es:di = 1000:0000\r
-  call  ReadBlocks                        # Read entire Root Directory\r
-  addw  %bx, %ax                          # ax = NoFats * SectorsPerFat + ReservedSectors + RootDirSectors = FirstClusterLBA (FirstDataSector)\r
-  movw  %ax, (%bp)                        # Save FirstClusterLBA (FirstDataSector) for later use\r
-\r
-  # dx - variable storage (initial value is 0)\r
-  # bx - loader (initial value is 0)\r
-  xorw  %dx, %dx\r
-  xorw  %bx, %bx\r
-\r
-FindEFILDR: \r
-  cmpl   $LOADER_FILENAME_PART1, (%di)        # Compare to "EFIL"\r
-  jne   FindVARSTORE\r
-  cmpl   $LOADER_FILENAME_PART2, 4(%di) \r
-  jne   FindVARSTORE\r
-  cmpl   $LOADER_FILENAME_PART3, 7(%di) \r
-  jne   FindVARSTORE\r
-  movw  26(%di), %bx                      # bx = Start Cluster for EFILDR  <----------------------------------\r
-  testw %dx, %dx\r
-  je    FindNext                          # Efivar.bin is not loaded\r
-  jmp   FoundAll\r
-\r
-FindVARSTORE: \r
-  ##if the file is not loader file, see if it's "EFIVAR  BIN"\r
-  cmpl  $0x56494645, (%di)                # Compare to "EFIV"\r
-  jne   FindNext\r
-  cmpl  $0x20205241, 4(%di)               # Compare to "AR  "\r
-  jne   FindNext\r
-  cmpl  $0x4e494220, 7(%di)               # Compare to " BIN"\r
-  jne   FindNext\r
-  movw  %di, %dx                          # dx = Offset of Start Cluster for Efivar.bin <---------------------\r
-  addw  $26, %dx\r
-  testw %bx, %bx\r
-  je    FindNext                          # Efildr is not loaded\r
-  jmp   FoundAll\r
-\r
-FindNext: \r
-  # go to next find\r
-  addw  $FAT_DIRECTORY_ENTRY_SIZE, %di    # Increment di\r
-  subw  $FAT_DIRECTORY_ENTRY_SIZE, %cx    # Decrement cx\r
-  # TODO: jump to FindVarStore if ...\r
-  jne   FindEFILDR\r
-  jmp   NotFoundAll\r
-\r
-FoundAll: \r
-FoundEFILDR: \r
-  movw    %bx, %cx                            # cx = Start Cluster for EFILDR  <----------------------------------\r
-  movw    %cs, %ax                            # Destination = 2000:0000\r
-  addw    $0x2000, %ax\r
-  movw    %ax, %es\r
-  xorw    %di, %di\r
-ReadFirstClusterOfEFILDR: \r
-  movw    %cx, %ax                            # ax = StartCluster\r
-  subw    $2, %ax                             # ax = StartCluster - 2\r
-  xorb    %bh, %bh\r
-  movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-  pushw   %dx\r
-  mulw    %bx\r
-  popw    %dx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-  addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  xorb    %bh, %bh\r
-  movb    SectorsPerCluster(%bp), %bl         # bx = Number of Sectors in a cluster\r
-  pushw   %es\r
-  call    ReadBlocks\r
-  popw    %ax\r
-JumpIntoFirstSectorOfEFILDR: \r
-  movw    %ax, JumpSegment(%bp)\r
-JumpFarInstruction: \r
-  .byte   0xea\r
-JumpOffset: \r
-  .word   0x000\r
-JumpSegment: \r
-  .word   0x2000\r
-\r
-\r
-PrintString: \r
-  movw $0xb800, %ax\r
-  movw %ax, %es\r
-  movw $0x7c0, %ax\r
-  movw %ax, %ds\r
-  movw $7, %cx\r
-  movw $160, %di\r
-  rep\r
-  movsw\r
-  ret\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-  pusha\r
-  addl    LBAOffsetForBootSector(%bp), %eax            # Add LBAOffsetForBootSector to Start LBA\r
-  addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-  movl    %eax, %esi                          # esi = Start LBA\r
-  movw    %bx, %cx                            # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-  movw    $0x7bfc, %bp                        # bp = 0x7bfc\r
-  movl    %esi, %eax                          # eax = Start LBA\r
-  xorl    %edx, %edx                          # edx = 0\r
-  movzwl  (%bp), %ebx                         # bx = MaxSector\r
-  divl    %ebx                                # ax = StartLBA / MaxSector\r
-  incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-  subw    %dx, %bx                            # bx = MaxSector - Sector\r
-  incw    %bx                                 # bx = MaxSector - Sector + 1\r
-  cmpw    %bx, %cx                            # Compare (Blocks) to (MaxSector - Sector + 1)\r
-  jg      LimitTransfer\r
-  movw    %cx, %bx                            # bx = Blocks\r
-LimitTransfer: \r
-  pushw   %cx\r
-  movb    %dl, %cl                            # cl = (StartLBA % MaxSector) + 1 = Sector\r
-  xorw    %dx, %dx                            # dx = 0\r
-  divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                              # dx = ax % (MaxHead + 1) = Head\r
-\r
-  pushw   %bx                                 # Save number of blocks to transfer\r
-  movb    %dl, %dh                            # dh = Head\r
-  movw    $0x7c00, %bp                        # bp = 0x7c00\r
-  movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-  movb    %al, %ch                            # ch = Cylinder\r
-  movb    %bl, %al                            # al = Blocks\r
-  movb    $2, %ah                             # ah = Function 2\r
-  movw    %di, %bx                            # es:bx = Buffer address\r
-  int     $0x13\r
-  jc      DiskError\r
-  popw    %bx\r
-  popw    %cx\r
-  movzwl  %bx, %ebx\r
-  addl    %ebx, %esi                          # StartLBA = StartLBA + NumberOfBlocks\r
-  subw    %bx, %cx                            # Blocks = Blocks - NumberOfBlocks\r
-  movw    %es, %ax\r
-  shlw    $(BLOCK_SHIFT-4),%bx\r
-  addw    %bx, %ax\r
-  movw    %ax, %es                            # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-  cmpw    $0, %cx\r
-  jne     ReadCylinderLoop\r
-  popa\r
-  ret\r
-\r
-# ****************************************************************************\r
-# ERROR Condition:\r
-# ****************************************************************************\r
-NotFoundAll: \r
-  ## if we found EFILDR, continue\r
-  testw %bx, %bx\r
-  jne  FoundEFILDR\r
-BadBootSector: \r
-DiskError: \r
-  movw $ErrorString, %si\r
-  call PrintString\r
-Halt: \r
-  jmp   Halt\r
-\r
-StartString: \r
-  .byte  'B', 0x0c, 'S', 0x0c, 't', 0x0c, 'a', 0x0c, 'r', 0x0c, 't', 0x0c, '!', 0x0c\r
-ErrorString: \r
-  .byte  'B', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!', 0x0c\r
-\r
-# ****************************************************************************\r
-# LBA Offset for BootSector, need patched by tool for HD boot.\r
-# ****************************************************************************\r
-\r
-  .org 0x01fa\r
-LBAOffsetForBootSector: \r
-  .long     0x0\r
-\r
-# ****************************************************************************\r
-# Sector Signature\r
-# ****************************************************************************\r
-\r
-  .org 0x01fe\r
-SectorSignature: \r
-  .word     0xaa55      # Boot Sector Signature\r
-\r
-\r
-\r
diff --git a/DuetPkg/BootSector/bs16.asm b/DuetPkg/BootSector/bs16.asm
deleted file mode 100644 (file)
index 87b76db..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    bs16.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE  EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT EQU     5\r
-BLOCK_SIZE                EQU     0200h\r
-BLOCK_MASK                EQU     01ffh\r
-BLOCK_SHIFT               EQU     9\r
-                                               ; "EFILDR_____"\r
-LOADER_FILENAME_PART1     EQU     04c494645h   ; "EFIL"\r
-LOADER_FILENAME_PART2     EQU     036315244h   ; "DR16"\r
-LOADER_FILENAME_PART3     EQU     020202036h   ; "6___"\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst                  - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-; BPB data below will be fixed by tool\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-PhysicalDrive     db  0             ; PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead       db  0             ; Current Head        - 8 bits\r
-Signature         db  0             ; Signature           - 8 bits  - ignored\r
-Id                db  "    "        ; Id                  - 4 bytes\r
-FatLabel          db  "           " ; Label               - 11 bytes\r
-SystemId          db  "FAT16   "    ; SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-\r
-; ****************************************************************************\r
-; Start Print\r
-; ****************************************************************************\r
-  lea  si, cs:[StartString]\r
-  call PrintString\r
-\r
-; ****************************************************************************\r
-; Print over\r
-; ****************************************************************************\r
-\r
-  mov   ax,cs         ; ax = 0\r
-  mov   ss,ax         ; ss = 0\r
-  add   ax,1000h\r
-  mov   ds,ax\r
-\r
-  mov   sp,07c00h     ; sp = 0x7c00\r
-  mov   bp,sp         ; bp = 0x7c00\r
-\r
-  mov   ah,8                                ; ah = 8 - Get Drive Parameters Function\r
-  mov   byte ptr [bp+PhysicalDrive],dl      ; BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-  int   13h                                 ; Get Drive Parameters\r
-  xor   ax,ax                   ; ax = 0\r
-  mov   al,dh                   ; al = dh\r
-  inc   al                      ; MaxHead = al + 1\r
-  push  ax                      ; 0000:7bfe = MaxHead\r
-  mov   al,cl                   ; al = cl\r
-  and   al,03fh                 ; MaxSector = al & 0x3f\r
-  push  ax                      ; 0000:7bfc = MaxSector\r
-\r
-  cmp   word ptr [bp+SectorSignature],0aa55h  ; Verify Boot Sector Signature\r
-  jne   BadBootSector\r
-  mov   cx,word ptr [bp+RootEntries]      ; cx = RootEntries\r
-  shl   cx,FAT_DIRECTORY_ENTRY_SHIFT      ; cx = cx * 32 = cx * sizeof(FAT_DIRECTORY_ENTRY) = Size of Root Directory in bytes\r
-  mov   bx,cx                             ; bx = size of the Root Directory in bytes\r
-  and   bx,BLOCK_MASK                     ; See if it is an even number of sectors long\r
-  jne   BadBootSector                     ; If is isn't, then the boot sector is bad.\r
-  mov   bx,cx                             ; bx = size of the Root Directory in bytes\r
-  shr   bx,BLOCK_SHIFT                    ; bx = size of Root Directory in sectors\r
-  mov   al,byte ptr [bp+NoFats]           ; al = NoFats\r
-  xor   ah,ah                             ; ah = 0  ==> ax = NoFats\r
-  mul   word ptr [bp+SectorsPerFat]       ; ax = NoFats * SectorsPerFat\r
-  add   ax,word ptr [bp+ReservedSectors]  ; ax = NoFats * SectorsPerFat + ReservedSectors = RootLBA\r
-  push  ds\r
-  pop   es\r
-  xor   di,di                             ; Store directory in es:di = 1000:0000\r
-  call  ReadBlocks                        ; Read entire Root Directory\r
-  add   ax,bx                             ; ax = NoFats * SectorsPerFat + ReservedSectors + RootDirSectors = FirstClusterLBA (FirstDataSector)\r
-  mov   word ptr [bp],ax                  ; Save FirstClusterLBA (FirstDataSector) for later use\r
-\r
-  ; dx - variable storage (initial value is 0)\r
-  ; bx - loader (initial value is 0)\r
-  xor   dx, dx\r
-  xor   bx, bx\r
-\r
-FindEFILDR:\r
-  cmp   dword ptr [di],LOADER_FILENAME_PART1         ; Compare to "EFIL"\r
-  jne   FindVARSTORE\r
-  cmp   dword ptr [di+4],LOADER_FILENAME_PART2\r
-  jne   FindVARSTORE\r
-  cmp   dword ptr [di+7],LOADER_FILENAME_PART3\r
-  jne   FindVARSTORE\r
-  mov   bx, word ptr [di+26]              ; bx = Start Cluster for EFILDR  <----------------------------------\r
-  test  dx, dx\r
-  je    FindNext                          ; Efivar.bin is not loaded\r
-  jmp   FoundAll\r
-\r
-FindVARSTORE:\r
-  ; if the file is not loader file, see if it's "EFIVAR  BIN"\r
-  cmp   dword ptr [di], 056494645h        ; Compare to "EFIV"\r
-  jne   FindNext\r
-  cmp   dword ptr [di+4], 020205241h      ; Compare to "AR  "\r
-  jne   FindNext\r
-  cmp   dword ptr [di+7], 04e494220h      ; Compare to " BIN"\r
-  jne   FindNext\r
-  mov   dx, di                            ; dx = Offset of Start Cluster for Efivar.bin <---------------------\r
-  add   dx, 26\r
-  test  bx, bx\r
-  je    FindNext                          ; Efildr is not loaded\r
-  jmp   FoundAll\r
-  \r
-FindNext:\r
-  ; go to next find\r
-  add   di,FAT_DIRECTORY_ENTRY_SIZE       ; Increment di\r
-  sub   cx,FAT_DIRECTORY_ENTRY_SIZE       ; Decrement cx\r
-  ; TODO: jump to FindVarStore if ...\r
-  jne   FindEFILDR\r
-  jmp   NotFoundAll\r
-\r
-FoundAll:\r
-FoundEFILDR:\r
-  mov     cx,bx                               ; cx = Start Cluster for EFILDR  <----------------------------------\r
-  mov     ax,cs                               ; Destination = 2000:0000\r
-  add     ax,2000h\r
-  mov     es,ax\r
-  xor     di,di\r
-ReadFirstClusterOfEFILDR:\r
-  mov     ax,cx                               ; ax = StartCluster\r
-  sub     ax,2                                ; ax = StartCluster - 2\r
-  xor     bh,bh                               \r
-  mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-  push    dx\r
-  mul     bx\r
-  pop     dx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-  add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  xor     bh,bh\r
-  mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = Number of Sectors in a cluster\r
-  push    es\r
-  call    ReadBlocks\r
-  pop     ax\r
-JumpIntoFirstSectorOfEFILDR:\r
-  mov     word ptr [bp+JumpSegment],ax\r
-JumpFarInstruction:\r
-  db      0eah\r
-JumpOffset:\r
-  dw      0000h\r
-JumpSegment:\r
-  dw      2000h\r
-\r
-\r
-PrintString:\r
-  mov  ax,0b800h\r
-  mov  es,ax\r
-  mov  ax, 07c0h\r
-  mov  ds, ax\r
-  mov  cx, 7\r
-  mov  di, 160\r
-  rep  movsw\r
-  ret\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-  pusha\r
-  add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-  add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-  mov     esi,eax                             ; esi = Start LBA\r
-  mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-  mov     bp,07bfch                           ; bp = 0x7bfc\r
-  mov     eax,esi                             ; eax = Start LBA\r
-  xor     edx,edx                             ; edx = 0\r
-  movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-  div     ebx                                 ; ax = StartLBA / MaxSector\r
-  inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-  sub     bx,dx                               ; bx = MaxSector - Sector\r
-  inc     bx                                  ; bx = MaxSector - Sector + 1\r
-  cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-  jg      LimitTransfer\r
-  mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-  push    cx\r
-  mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-  xor     dx,dx                               ; dx = 0\r
-  div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                              ; dx = ax % (MaxHead + 1) = Head\r
-\r
-  push    bx                                  ; Save number of blocks to transfer\r
-  mov     dh,dl                               ; dh = Head\r
-  mov     bp,07c00h                           ; bp = 0x7c00\r
-  mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-  mov     ch,al                               ; ch = Cylinder\r
-  mov     al,bl                               ; al = Blocks\r
-  mov     ah,2                                ; ah = Function 2\r
-  mov     bx,di                               ; es:bx = Buffer address\r
-  int     013h\r
-  jc      DiskError\r
-  pop     bx\r
-  pop     cx\r
-  movzx   ebx,bx\r
-  add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-  sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-  mov     ax,es\r
-  shl     bx,(BLOCK_SHIFT-4)\r
-  add     ax,bx\r
-  mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-  cmp     cx,0\r
-  jne     ReadCylinderLoop\r
-  popa\r
-  ret\r
-\r
-; ****************************************************************************\r
-; ERROR Condition:\r
-; ****************************************************************************\r
-NotFoundAll:\r
-  ; if we found EFILDR, continue\r
-  test bx,bx\r
-  jne  FoundEFILDR\r
-BadBootSector:\r
-DiskError:\r
-  lea  si, cs:[ErrorString]\r
-  call PrintString\r
-Halt:\r
-  jmp   Halt\r
-\r
-StartString:\r
-  db 'B', 0ch, 'S', 0ch, 't', 0ch, 'a', 0ch, 'r', 0ch, 't', 0ch, '!', 0ch\r
-ErrorString:\r
-  db 'B', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-; ****************************************************************************\r
-; LBA Offset for BootSector, need patched by tool for HD boot.\r
-; ****************************************************************************\r
-\r
-  org 01fah\r
-LBAOffsetForBootSector:\r
-  dd        0h\r
-\r
-; ****************************************************************************\r
-; Sector Signature\r
-; ****************************************************************************\r
-\r
-  org 01feh\r
-SectorSignature:\r
-  dw        0aa55h      ; Boot Sector Signature\r
-\r
-  end \r
-  \r
diff --git a/DuetPkg/BootSector/bs32.S b/DuetPkg/BootSector/bs32.S
deleted file mode 100644 (file)
index 2584517..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    bs32.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-        #.MODEL small\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                      FAT_DIRECTORY_ENTRY_SIZE, 0x0020\r
-.equ                      FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                      BLOCK_SIZE, 0x0200\r
-.equ                      BLOCK_MASK, 0x01ff\r
-.equ                      BLOCK_SHIFT, 9\r
-                                               # "EFILDR_____"\r
-.equ                      LOADER_FILENAME_PART1, 0x4c494645    # "EFIL"\r
-.equ                      LOADER_FILENAME_PART2, 0x30325244    # "DR20"\r
-.equ                      LOADER_FILENAME_PART3, 0x20202030    # "0___"\r
-\r
-        .org 0x0\r
-.global _start\r
-_start:\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst                  - 3 bytes\r
-  nop\r
-\r
-OemId:             .ascii  "INTEL   "   # OemId               - 8 bytes\r
-# BPB data below will be fixed by tool\r
-SectorSize:        .word  0             # Sector Size         - 16 bits\r
-SectorsPerCluster: .byte  0             # Sector Per Cluster  - 8 bits\r
-ReservedSectors:   .word  0             # Reserved Sectors    - 16 bits\r
-NoFats:            .byte  0             # Number of FATs      - 8 bits\r
-RootEntries:       .word  0             # Root Entries        - 16 bits\r
-Sectors:           .word  0             # Number of Sectors   - 16 bits\r
-Media:             .byte  0             # Media               - 8 bits  - ignored\r
-SectorsPerFat:     .word  0             # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:   .word  0             # Sectors Per Track   - 16 bits - ignored\r
-Heads:             .word  0             # Heads               - 16 bits - ignored\r
-HiddenSectors:     .long  0             # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:      .long  0             # Large Sectors       - 32 bits \r
-\r
-#******************************************************************************\r
-#\r
-#The structure for FAT32 starting at offset 36 of the boot sector. (At this point, \r
-#the BPB/boot sector for FAT12 and FAT16 differs from the BPB/boot sector for FAT32.)\r
-#\r
-#******************************************************************************\r
-\r
-SectorsPerFat32:   .long  0              # Sectors Per FAT for FAT32       - 4 bytes\r
-ExtFlags:          .word  0              # Mirror Flag                     - 2 bytes\r
-FSVersion:         .word  0              # File System Version             - 2 bytes\r
-RootCluster:       .long  0              # 1st Cluster Number of Root Dir  - 4 bytes\r
-FSInfo:            .word  0              # Sector Number of FSINFO         - 2 bytes\r
-BkBootSector:      .word  0              # Sector Number of Bk BootSector  - 2 bytes\r
-Reserved:          .fill  12, 1, 0       # Reserved Field                  - 12 bytes\r
-PhysicalDrive:     .byte  0              # Physical Drive Number           - 1 byte\r
-Reserved1:         .byte  0              # Reserved Field                  - 1 byte\r
-Signature:         .byte  0              # Extended Boot Signature         - 1 byte\r
-VolId:             .ascii  "    "        # Volume Serial Number            - 4 bytes\r
-FatLabel:          .ascii  "           " # Volume Label                    - 11 bytes\r
-FileSystemType:    .ascii  "FAT32   "    # File System Type                - 8 bytes\r
-BootSectorEntryPoint: \r
-        #ASSUME ds:@code\r
-        #ASSUME ss:@code\r
-\r
-# ****************************************************************************\r
-# Start Print\r
-# ****************************************************************************\r
-  movw $StartString, %si\r
-  call PrintString\r
-\r
-# ****************************************************************************\r
-# Print over\r
-# ****************************************************************************\r
-\r
-  movw  %cs, %ax      # ax = 0\r
-  movw  %ax, %ss      # ss = 0\r
-  addw  $0x1000, %ax\r
-  movw  %ax, %ds\r
-\r
-  movw  $0x7c00, %sp  # sp = 0x7c00\r
-  movw  %sp, %bp      # bp = 0x7c00\r
-\r
-  movb  $8, %ah                             # ah = 8 - Get Drive Parameters Function\r
-  movb  %dl, PhysicalDrive(%bp)             # BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-  int   $0x13                               # Get Drive Parameters\r
-  xorw  %ax, %ax                # ax = 0\r
-  movb  %dh, %al                # al = dh\r
-  incb  %al                     # MaxHead = al + 1\r
-  pushw %ax                     # 0000:7bfe = MaxHead\r
-  movb  %cl, %al                # al = cl\r
-  andb  $0x3f, %al              # MaxSector = al & 0x3f\r
-  pushw %ax                     # 0000:7bfc = MaxSector\r
-\r
-  cmpw  $0xaa55, SectorSignature(%bp)         # Verify Boot Sector Signature\r
-  jne   BadBootSector\r
-  movw  RootEntries(%bp), %cx             # cx = RootEntries\r
-  shlw  $FAT_DIRECTORY_ENTRY_SHIFT, %cx   # cx = cx * 32 = cx * sizeof(FAT_DIRECTORY_ENTRY) = Size of Root Directory in bytes\r
-  movw  %cx, %bx                          # bx = size of the Root Directory in bytes\r
-  andw  $BLOCK_MASK, %bx                  # See if it is an even number of sectors long\r
-  jne   BadBootSector                     # If is isn't, then the boot sector is bad.\r
-  movw  %cx, %bx                          # bx = size of the Root Directory in bytes\r
-  shrw  $BLOCK_SHIFT, %bx                 # bx = size of Root Directory in sectors\r
-  movb  NoFats(%bp), %al                  # al = NoFats\r
-  xorb  %ah, %ah                          # ah = 0  ==> ax = NoFats\r
-  mulw  SectorsPerFat32(%bp)              # ax = NoFats * SectorsPerFat\r
-  addw  ReservedSectors(%bp), %ax         # ax = NoFats * SectorsPerFat + ReservedSectors = RootLBA\r
-  addw  %bx, %ax                          # ax = NoFats * SectorsPerFat + ReservedSectors + RootDirSectors = FirstClusterLBA\r
-  movw  %ax, (%bp)                        # Save FirstClusterLBA for later use\r
-\r
-  movw  RootCluster(%bp), %ax             # ax = StartCluster of Root Directory\r
-  subw  $2, %ax                           # ax = StartCluster - 2\r
-  xorb  %bh, %bh\r
-  movb  SectorsPerCluster(%bp), %bl       # bx = SectorsPerCluster\r
-  mulw  %bx                               # ax = (StartCluster - 2) * SectorsPerCluster\r
-  addw  (%bp), %ax                        # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  pushw %ds\r
-  popw  %es\r
-  xorw  %di, %di                          # Store directory in es:di = 1000:0000\r
-  call  ReadBlocks                        # Read StartCluster of Root Directory\r
-\r
-  # dx - variable storage (initial value is 0)\r
-  # bx - loader (initial value is 0)\r
-  xorw  %dx, %dx\r
-  xorw  %bx, %bx\r
-\r
-FindEFILDR: \r
-  cmpl  $LOADER_FILENAME_PART1, (%di)\r
-  jne   FindVARSTORE\r
-  cmpl  $LOADER_FILENAME_PART2, 4(%di)\r
-  jne   FindVARSTORE\r
-  cmpl  $LOADER_FILENAME_PART3, 7(%di)\r
-  jne   FindVARSTORE\r
-  movw  26(%di), %bx                      # bx = Start Cluster for EFILDR  <----------------------------------\r
-  testw %dx, %dx\r
-  je    FindNext                          # Efivar.bin is not loaded\r
-  jmp   FoundAll\r
-\r
-FindVARSTORE: \r
-  ## if the file is not loader file, see if it's "EFIVAR  BIN"\r
-  cmpl  $0x56494645, (%di)                # Compare to "EFIV"\r
-  jne   FindNext\r
-  cmpl  $0x20205241, 4(%di)               # Compare to "AR  "\r
-  jne   FindNext\r
-  cmpl  $0x4e494220, 7(%di)               # Compare to " BIN"\r
-  jne   FindNext\r
-  movw  %di, %dx                          # dx = Offset of Start Cluster for Efivar.bin <---------------------\r
-  addw  $26, %dx\r
-  testw %bx, %bx\r
-  je    FindNext                          # Efildr is not loaded\r
-  jmp   FoundAll\r
-\r
-FindNext: \r
-  # go to next find\r
-  addw  $FAT_DIRECTORY_ENTRY_SIZE, %di    # Increment di\r
-  subw  $FAT_DIRECTORY_ENTRY_SIZE, %cx    # Decrement cx\r
-  # TODO: jump to FindVarStore if ...\r
-  jne   FindEFILDR\r
-  jmp   NotFoundAll\r
-\r
-FoundAll: \r
-FoundEFILDR: \r
-  movw    %bx, %cx                            # cx = Start Cluster for EFILDR  <----------------------------------\r
-  movw    %cs, %ax                            # Destination = 2000:0000\r
-  addw    $0x2000, %ax\r
-  movw    %ax, %es\r
-  xorw    %di, %di\r
-ReadFirstClusterOfEFILDR: \r
-  movw    %cx, %ax                            # ax = StartCluster\r
-  subw    $2, %ax                             # ax = StartCluster - 2\r
-  xorb    %bh, %bh\r
-  movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-  pushw   %dx\r
-  mulw    %bx\r
-  popw    %dx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-  addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  xorb    %bh, %bh\r
-  movb    SectorsPerCluster(%bp), %bl         # bx = Number of Sectors in a cluster\r
-  pushw   %es\r
-  call    ReadBlocks\r
-  popw    %ax\r
-JumpIntoFirstSectorOfEFILDR: \r
-  movw    %ax, JumpSegment(%bp)\r
-JumpFarInstruction: \r
-  .byte   0xea\r
-JumpOffset: \r
-  .word   0x000\r
-JumpSegment: \r
-  .word   0x2000\r
-\r
-\r
-PrintString: \r
-  movw $0xb800, %ax\r
-  movw %ax, %es\r
-  movw $0x7c0, %ax\r
-  movw %ax, %ds\r
-  movw $6, %cx\r
-  movw $160, %di\r
-  rep\r
-  movsw\r
-  ret\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-  pusha\r
-  addl    LBAOffsetForBootSector(%bp), %eax            # Add LBAOffsetForBootSector to Start LBA\r
-  addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-  movl    %eax, %esi                          # esi = Start LBA\r
-  movw    %bx, %cx                            # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-  movw    $0x7bfc, %bp                        # bp = 0x7bfc\r
-  movl    %esi, %eax                          # eax = Start LBA\r
-  xorl    %edx, %edx                          # edx = 0\r
-  movzwl  (%bp), %ebx                         # bx = MaxSector\r
-  divl    %ebx                                # ax = StartLBA / MaxSector\r
-  incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-  subw    %dx, %bx                            # bx = MaxSector - Sector\r
-  incw    %bx                                 # bx = MaxSector - Sector + 1\r
-  cmpw    %bx, %cx                            # Compare (Blocks) to (MaxSector - Sector + 1)\r
-  jg      LimitTransfer\r
-  movw    %cx, %bx                            # bx = Blocks\r
-LimitTransfer: \r
-  pushw   %cx\r
-  movb    %dl, %cl                            # cl = (StartLBA % MaxSector) + 1 = Sector\r
-  xorw    %dx, %dx                            # dx = 0\r
-  divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                              # dx = ax % (MaxHead + 1) = Head\r
-\r
-  pushw   %bx                                 # Save number of blocks to transfer\r
-  movb    %dl, %dh                            # dh = Head\r
-  movw    $0x7c00, %bp                        # bp = 0x7c00\r
-  movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-  movb    %al, %ch                            # ch = Cylinder\r
-  movb    %bl, %al                            # al = Blocks\r
-  movb    $2, %ah                             # ah = Function 2\r
-  movw    %di, %bx                            # es:bx = Buffer address\r
-  int     $0x13\r
-  jc      DiskError\r
-  popw    %bx\r
-  popw    %cx\r
-  movzwl  %bx, %ebx\r
-  addl    %ebx, %esi                          # StartLBA = StartLBA + NumberOfBlocks\r
-  subw    %bx, %cx                            # Blocks = Blocks - NumberOfBlocks\r
-  movw    %es, %ax\r
-  shlw    $(BLOCK_SHIFT-4), %bx\r
-  addw    %bx, %ax\r
-  movw    %ax, %es                            # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-  cmpw    $0, %cx\r
-  jne     ReadCylinderLoop\r
-  popa\r
-  ret\r
-\r
-# ****************************************************************************\r
-# ERROR Condition:\r
-# ****************************************************************************\r
-NotFoundAll: \r
-  ## if we found EFILDR, continue\r
-  testw %bx, %bx\r
-  jne  FoundEFILDR\r
-BadBootSector: \r
-DiskError: \r
-  movw $ErrorString, %si\r
-  call PrintString\r
-Halt: \r
-  jmp   Halt\r
-\r
-StartString: \r
-  .byte 'B', 0x0c, 'S', 0x0c, 't', 0x0c, 'a', 0x0c, 'r', 0x0c, 't', 0x0c\r
-ErrorString: \r
-  .byte 'B', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c\r
-\r
-# ****************************************************************************\r
-# LBA Offset for BootSector, need patched by tool for HD boot.\r
-# ****************************************************************************\r
-\r
-  .org 0x01fa\r
-LBAOffsetForBootSector: \r
-  .long     0x0\r
-\r
-# ****************************************************************************\r
-# Sector Signature\r
-# ****************************************************************************\r
-\r
-  .org 0x01fe\r
-SectorSignature: \r
-  .word     0xaa55      # Boot Sector Signature\r
-\r
-\r
-\r
diff --git a/DuetPkg/BootSector/bs32.asm b/DuetPkg/BootSector/bs32.asm
deleted file mode 100644 (file)
index 7105ae6..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    bs32.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE  EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT EQU     5\r
-BLOCK_SIZE                EQU     0200h\r
-BLOCK_MASK                EQU     01ffh\r
-BLOCK_SHIFT               EQU     9\r
-                                               ; "EFILDR_____"\r
-LOADER_FILENAME_PART1     EQU     04c494645h   ; "EFIL"\r
-LOADER_FILENAME_PART2     EQU     030325244h   ; "DR20"\r
-LOADER_FILENAME_PART3     EQU     020202030h   ; "0___"\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst                  - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-; BPB data below will be fixed by tool\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-\r
-;******************************************************************************\r
-;\r
-;The structure for FAT32 starting at offset 36 of the boot sector. (At this point, \r
-;the BPB/boot sector for FAT12 and FAT16 differs from the BPB/boot sector for FAT32.)\r
-;\r
-;******************************************************************************\r
-\r
-SectorsPerFat32   dd  0             ; Sectors Per FAT for FAT32       - 4 bytes\r
-ExtFlags          dw  0             ; Mirror Flag                     - 2 bytes\r
-FSVersion         dw  0             ; File System Version             - 2 bytes\r
-RootCluster       dd  0             ; 1st Cluster Number of Root Dir  - 4 bytes\r
-FSInfo            dw  0             ; Sector Number of FSINFO         - 2 bytes\r
-BkBootSector      dw  0             ; Sector Number of Bk BootSector  - 2 bytes\r
-Reserved          db  12 dup(0)     ; Reserved Field                  - 12 bytes\r
-PhysicalDrive     db  0             ; Physical Drive Number           - 1 byte\r
-Reserved1         db  0             ; Reserved Field                  - 1 byte\r
-Signature         db  0             ; Extended Boot Signature         - 1 byte\r
-VolId             db  "    "        ; Volume Serial Number            - 4 bytes\r
-FatLabel          db  "           " ; Volume Label                    - 11 bytes\r
-FileSystemType    db  "FAT32   "    ; File System Type                - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-\r
-; ****************************************************************************\r
-; Start Print\r
-; ****************************************************************************\r
-  mov  si, offset StartString\r
-  call PrintString\r
-\r
-; ****************************************************************************\r
-; Print over\r
-; ****************************************************************************\r
-\r
-  mov   ax,cs         ; ax = 0\r
-  mov   ss,ax         ; ss = 0\r
-  add   ax,1000h\r
-  mov   ds,ax\r
-\r
-  mov   sp,07c00h     ; sp = 0x7c00\r
-  mov   bp,sp         ; bp = 0x7c00\r
-\r
-  mov   ah,8                                ; ah = 8 - Get Drive Parameters Function\r
-  mov   byte ptr [bp+PhysicalDrive],dl      ; BBS defines that BIOS would pass the booting driver number to the loader through DL\r
-  int   13h                                 ; Get Drive Parameters\r
-  xor   ax,ax                   ; ax = 0\r
-  mov   al,dh                   ; al = dh\r
-  inc   al                      ; MaxHead = al + 1\r
-  push  ax                      ; 0000:7bfe = MaxHead\r
-  mov   al,cl                   ; al = cl\r
-  and   al,03fh                 ; MaxSector = al & 0x3f\r
-  push  ax                      ; 0000:7bfc = MaxSector\r
-\r
-  cmp   word ptr [bp+SectorSignature],0aa55h  ; Verify Boot Sector Signature\r
-  jne   BadBootSector\r
-  mov   cx,word ptr [bp+RootEntries]      ; cx = RootEntries\r
-  shl   cx,FAT_DIRECTORY_ENTRY_SHIFT      ; cx = cx * 32 = cx * sizeof(FAT_DIRECTORY_ENTRY) = Size of Root Directory in bytes\r
-  mov   bx,cx                             ; bx = size of the Root Directory in bytes\r
-  and   bx,BLOCK_MASK                     ; See if it is an even number of sectors long\r
-  jne   BadBootSector                     ; If is isn't, then the boot sector is bad.\r
-  mov   bx,cx                             ; bx = size of the Root Directory in bytes\r
-  shr   bx,BLOCK_SHIFT                    ; bx = size of Root Directory in sectors\r
-  mov   al,byte ptr [bp+NoFats]           ; al = NoFats\r
-  xor   ah,ah                             ; ah = 0  ==> ax = NoFats\r
-  mul   word ptr [bp+SectorsPerFat32]     ; ax = NoFats * SectorsPerFat\r
-  add   ax,word ptr [bp+ReservedSectors]  ; ax = NoFats * SectorsPerFat + ReservedSectors = RootLBA\r
-  add   ax,bx                             ; ax = NoFats * SectorsPerFat + ReservedSectors + RootDirSectors = FirstClusterLBA\r
-  mov   word ptr [bp],ax                  ; Save FirstClusterLBA for later use\r
-  \r
-  mov   ax,word ptr [bp+RootCluster]      ; ax = StartCluster of Root Directory\r
-  sub   ax,2                              ; ax = StartCluster - 2\r
-  xor   bh,bh                               \r
-  mov   bl,byte ptr [bp+SectorsPerCluster]; bx = SectorsPerCluster\r
-  mul   bx                                ; ax = (StartCluster - 2) * SectorsPerCluster\r
-  add   ax, word ptr [bp]                 ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  push  ds\r
-  pop   es\r
-  xor   di,di                             ; Store directory in es:di = 1000:0000\r
-  call  ReadBlocks                        ; Read StartCluster of Root Directory\r
-\r
-  ; dx - variable storage (initial value is 0)\r
-  ; bx - loader (initial value is 0)\r
-  xor   dx, dx\r
-  xor   bx, bx\r
-\r
-FindEFILDR:\r
-  cmp   dword ptr [di],LOADER_FILENAME_PART1         ; Compare to "EFIL"\r
-  jne   FindVARSTORE\r
-  cmp   dword ptr [di+4],LOADER_FILENAME_PART2\r
-  jne   FindVARSTORE\r
-  cmp   dword ptr [di+7],LOADER_FILENAME_PART3\r
-  jne   FindVARSTORE\r
-  mov   bx, word ptr [di+26]              ; bx = Start Cluster for EFILDR  <----------------------------------\r
-  test  dx, dx\r
-  je    FindNext                          ; Efivar.bin is not loaded\r
-  jmp   FoundAll\r
-\r
-FindVARSTORE:\r
-  ; if the file is not loader file, see if it's "EFIVAR  BIN"\r
-  cmp   dword ptr [di], 056494645h        ; Compare to "EFIV"\r
-  jne   FindNext\r
-  cmp   dword ptr [di+4], 020205241h      ; Compare to "AR  "\r
-  jne   FindNext\r
-  cmp   dword ptr [di+7], 04e494220h      ; Compare to " BIN"\r
-  jne   FindNext\r
-  mov   dx, di                            ; dx = Offset of Start Cluster for Efivar.bin <---------------------\r
-  add   dx, 26\r
-  test  bx, bx\r
-  je    FindNext                          ; Efildr is not loaded\r
-  jmp   FoundAll\r
-  \r
-FindNext:\r
-  ; go to next find\r
-  add   di,FAT_DIRECTORY_ENTRY_SIZE       ; Increment di\r
-  sub   cx,FAT_DIRECTORY_ENTRY_SIZE       ; Decrement cx\r
-  ; TODO: jump to FindVarStore if ...\r
-  jne   FindEFILDR\r
-  jmp   NotFoundAll\r
-\r
-FoundAll:\r
-FoundEFILDR:\r
-  mov     cx,bx                               ; cx = Start Cluster for EFILDR  <----------------------------------\r
-  mov     ax,cs                               ; Destination = 2000:0000\r
-  add     ax,2000h\r
-  mov     es,ax\r
-  xor     di,di\r
-ReadFirstClusterOfEFILDR:\r
-  mov     ax,cx                               ; ax = StartCluster\r
-  sub     ax,2                                ; ax = StartCluster - 2\r
-  xor     bh,bh                               \r
-  mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-  push    dx\r
-  mul     bx\r
-  pop     dx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-  add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-  xor     bh,bh\r
-  mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = Number of Sectors in a cluster\r
-  push    es\r
-  call    ReadBlocks\r
-  pop     ax\r
-JumpIntoFirstSectorOfEFILDR:\r
-  mov     word ptr [bp+JumpSegment],ax\r
-JumpFarInstruction:\r
-  db      0eah\r
-JumpOffset:\r
-  dw      0000h\r
-JumpSegment:\r
-  dw      2000h\r
-\r
-\r
-PrintString:\r
-  mov  ax,0b800h\r
-  mov  es,ax\r
-  mov  ax, 07c0h\r
-  mov  ds, ax\r
-  mov  cx, 6\r
-  mov  di, 160\r
-  rep  movsw\r
-  ret\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-  pusha\r
-  add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-  add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-  mov     esi,eax                             ; esi = Start LBA\r
-  mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-  mov     bp,07bfch                           ; bp = 0x7bfc\r
-  mov     eax,esi                             ; eax = Start LBA\r
-  xor     edx,edx                             ; edx = 0\r
-  movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-  div     ebx                                 ; ax = StartLBA / MaxSector\r
-  inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-  sub     bx,dx                               ; bx = MaxSector - Sector\r
-  inc     bx                                  ; bx = MaxSector - Sector + 1\r
-  cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-  jg      LimitTransfer\r
-  mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-  push    cx\r
-  mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-  xor     dx,dx                               ; dx = 0\r
-  div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                              ; dx = ax % (MaxHead + 1) = Head\r
-\r
-  push    bx                                  ; Save number of blocks to transfer\r
-  mov     dh,dl                               ; dh = Head\r
-  mov     bp,07c00h                           ; bp = 0x7c00\r
-  mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-  mov     ch,al                               ; ch = Cylinder\r
-  mov     al,bl                               ; al = Blocks\r
-  mov     ah,2                                ; ah = Function 2\r
-  mov     bx,di                               ; es:bx = Buffer address\r
-  int     013h\r
-  jc      DiskError\r
-  pop     bx\r
-  pop     cx\r
-  movzx   ebx,bx\r
-  add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-  sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-  mov     ax,es\r
-  shl     bx,(BLOCK_SHIFT-4)\r
-  add     ax,bx\r
-  mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-  cmp     cx,0\r
-  jne     ReadCylinderLoop\r
-  popa\r
-  ret\r
-\r
-; ****************************************************************************\r
-; ERROR Condition:\r
-; ****************************************************************************\r
-NotFoundAll:\r
-  ; if we found EFILDR, continue\r
-  test bx,bx\r
-  jne  FoundEFILDR\r
-BadBootSector:\r
-DiskError:\r
-  mov  si, offset ErrorString\r
-  call PrintString\r
-Halt:\r
-  jmp   Halt\r
-\r
-StartString:\r
-  db 'B', 0ch, 'S', 0ch, 't', 0ch, 'a', 0ch, 'r', 0ch, 't', 0ch\r
-ErrorString:\r
-  db 'B', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch\r
-\r
-; ****************************************************************************\r
-; LBA Offset for BootSector, need patched by tool for HD boot.\r
-; ****************************************************************************\r
-\r
-  org 01fah\r
-LBAOffsetForBootSector:\r
-  dd        0h\r
-\r
-; ****************************************************************************\r
-; Sector Signature\r
-; ****************************************************************************\r
-\r
-  org 01feh\r
-SectorSignature:\r
-  dw        0aa55h      ; Boot Sector Signature\r
-\r
-  end \r
-  \r
diff --git a/DuetPkg/BootSector/efi32.S b/DuetPkg/BootSector/efi32.S
deleted file mode 100644 (file)
index ebbc450..0000000
+++ /dev/null
@@ -1,1176 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    efi32.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-##############################################################################\r
-# Now in 32-bit protected mode.\r
-##############################################################################\r
-\r
-        .org 0x21000\r
-\r
-.global _start\r
-_start:\r
-\r
-.equ                 DEFAULT_HANDLER_SIZE, INT1 - INT0\r
-\r
-.macro jmpCommonIdtEntry  \r
-    # jmp     commonIdtEntry - this must be hand coded to keep the assembler from\r
-    #                          using a 8 bit reletive jump when the entries are\r
-    #                          within 255 bytes of the common entry.  This must\r
-    #                          be done to maintain the consistency of the size\r
-    #                          of entry points...\r
-    .byte   0xe9                        # jmp 16 bit relative\r
-    .long      commonIdtEntry - . - 4   # offset to jump to     \r
-.endm\r
-\r
-Start:  \r
-    movw    %bx, %ax\r
-    movw    %ax, %ds\r
-    movw    %ax, %es\r
-    movw    %ax, %fs\r
-    movw    %ax, %gs\r
-    movw    %ax, %ss\r
-    movl    $0x001ffff0, %esp\r
-\r
-    call    ClearScreen\r
-\r
-    # Populate IDT with meaningful offsets for exception handlers...\r
-    sidt    Idtr            \r
-\r
-    movl    Halt, %eax\r
-    movl    %eax, %ebx                  # use bx to copy 15..0 to descriptors\r
-    shrl    $16, %eax                   # use ax to copy 31..16 to descriptors \r
-    movl    $0x78, %ecx                 # 78h IDT entries to initialize with unique entry points (exceptions)\r
-    movl    (Idtr + 2), %esi\r
-    movl    (%esi), %edi\r
-\r
-LOOP_1:                                         # loop through all IDT entries exception handlers and initialize to default handler\r
-    movw    %bx, (%edi)                         # write bits 15..0 of offset\r
-    movw    $0x20, 2(%edi)                      # SYS_CODE_SEL from GDT\r
-    movw    $(0x0e00 | 0x8000), 4(%edi)         # type = 386 interrupt gate, present\r
-    movw    %ax, 6(%edi)                        # write bits 31..16 of offset\r
-    addl    $8, %edi                            # move up to next descriptor\r
-    addw    DEFAULT_HANDLER_SIZE, %bx           # move to next entry point\r
-    loopl   LOOP_1                                 # loop back through again until all descriptors are initialized\r
-\r
-    ## at this point edi contains the offset of the descriptor for INT 20\r
-    ## and bx contains the low 16 bits of the offset of the default handler\r
-    ## so initialize all the rest of the descriptors with these two values...\r
-#    mov     ecx, 101                            ; there are 100 descriptors left (INT 20 (14h) - INT 119 (77h)\r
-#@@:                                             ; loop through all IDT entries exception handlers and initialize to default handler\r
-#    mov     word ptr [edi], bx                  ; write bits 15..0 of offset\r
-#    mov     word ptr [edi+2], 20h               ; SYS_CODE_SEL from GDT\r
-#    mov     word ptr [edi+4], 0e00h OR 8000h    ; type = 386 interrupt gate, present\r
-#    mov     word ptr [edi+6], ax                ; write bits 31..16 of offset\r
-#    add     edi, 8                              ; move up to next descriptor\r
-#    loop    @b                                  ; loop back through again until all descriptors are initialized\r
-\r
-\r
-##  DUMP    location of IDT and several of the descriptors\r
-#    mov     ecx, 8\r
-#    mov     eax, [offset Idtr + 2]\r
-#    mov     eax, [eax]\r
-#    mov     edi, 0b8000h\r
-#    call    PrintDword\r
-#    mov     esi, eax\r
-#    mov     edi, 0b80a0h\r
-#    jmp     OuterLoop\r
-\r
-##    \r
-## just for fun, let's do a software interrupt to see if we correctly land in the exception handler...\r
-#    mov     eax, 011111111h\r
-#    mov     ebx, 022222222h\r
-#    mov     ecx, 033333333h\r
-#    mov     edx, 044444444h\r
-#    mov     ebp, 055555555h\r
-#    mov     esi, 066666666h\r
-#    mov     edi, 077777777h\r
-#    push    011111111h\r
-#    push    022222222h\r
-#    push    033333333h\r
-#    int     119\r
-\r
-\r
-    movl    $0x22000, %esi              # esi = 22000\r
-    movl    0x14(%esi), %eax            # eax = [22014]\r
-    addl    %eax, %esi                  # esi = 22000 + [22014] = Base of EFILDR.C\r
-    movl    0x3c(%esi), %ebp            # ebp = [22000 + [22014] + 3c] = NT Image Header for EFILDR.C\r
-    addl    %esi, %ebp\r
-    movl    0x34(%ebp), %edi            # edi = [[22000 + [22014] + 3c] + 30] = ImageBase\r
-    movl    0x28(%ebp), %eax            # eax = [[22000 + [22014] + 3c] + 24] = EntryPoint\r
-    addl    %edi, %eax                  # eax = ImageBase + EntryPoint\r
-    movl    %eax, EfiLdrOffset             # Modify far jump instruction for correct entry point\r
-\r
-    movw    6(%ebp), %bx                # bx = Number of sections\r
-    xorl    %eax, %eax\r
-    movw    0x14(%ebp), %ax             # ax = Optional Header Size\r
-    addl    %eax, %ebp\r
-    addl    $0x18, %ebp                 # ebp = Start of 1st Section\r
-\r
-SectionLoop: \r
-    pushl   %esi                        # Save Base of EFILDR.C\r
-    pushl   %edi                        # Save ImageBase\r
-    addl    0x14(%ebp), %esi            # esi = Base of EFILDR.C + PointerToRawData\r
-    addl    0x0c(%ebp), %edi            # edi = ImageBase + VirtualAddress\r
-    movl    0x10(%ebp), %ecx            # ecs = SizeOfRawData\r
-\r
-    cld\r
-    shrl    $2, %ecx\r
-    rep\r
-    movsl\r
-\r
-    popl    %edi                        # Restore ImageBase\r
-    popl    %esi                        # Restore Base of EFILDR.C\r
-\r
-    addw    $0x28, %bp                  # ebp = ebp + 028h = Pointer to next section record\r
-    decw    %bx\r
-    cmpw    $0, %bx\r
-    jne     SectionLoop\r
-\r
-    movzwl  (Idtr), %eax                # get size of IDT\r
-    incl    %eax\r
-    addl    (Idtr + 2), %eax            # add to base of IDT to get location of memory map... \r
-    pushl   %eax                        # push memory map location on stack for call to EFILDR...\r
-\r
-    pushl   %eax                        # push return address (useless, just for stack balance)\r
-    .byte   0xb8\r
-EfiLdrOffset: \r
-    .long   0x00401000                  # Offset of EFILDR\r
-# mov eax, 401000h\r
-    pushl   %eax\r
-    ret\r
-\r
-#    db      "**** DEFAULT IDT ENTRY ***",0\r
-    .p2align 1\r
-Halt: \r
-INT0: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x0\r
-    jmpCommonIdtEntry \r
-#    db      0e9h                        ; jmp 16 bit reletive \r
-#    dd      commonIdtEntry - $ - 4      ;  offset to jump to\r
-\r
-INT1: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x1\r
-    jmpCommonIdtEntry \r
-\r
-INT2: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x2\r
-    jmpCommonIdtEntry \r
-\r
-INT3: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x3\r
-    jmpCommonIdtEntry \r
-\r
-INT4: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x4\r
-    jmpCommonIdtEntry \r
-\r
-INT5: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x5\r
-    jmpCommonIdtEntry \r
-\r
-INT6: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x6\r
-    jmpCommonIdtEntry \r
-\r
-INT7: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x7\r
-    jmpCommonIdtEntry \r
-\r
-INT8: \r
-#   Double fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $0x8\r
-    jmpCommonIdtEntry \r
-\r
-INT9: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x9\r
-    jmpCommonIdtEntry \r
-\r
-INT10: \r
-#   Invalid TSS causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $10\r
-    jmpCommonIdtEntry \r
-\r
-INT11: \r
-#   Segment Not Present causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $11\r
-    jmpCommonIdtEntry \r
-\r
-INT12: \r
-#   Stack fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $12\r
-    jmpCommonIdtEntry \r
-\r
-INT13: \r
-#   GP fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $13\r
-    jmpCommonIdtEntry \r
-\r
-INT14: \r
-#   Page fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $14\r
-    jmpCommonIdtEntry \r
-\r
-INT15: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $15\r
-    jmpCommonIdtEntry \r
-\r
-INT16: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $16\r
-    jmpCommonIdtEntry \r
-\r
-INT17: \r
-#   Alignment check causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $17\r
-    jmpCommonIdtEntry \r
-\r
-INT18: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $18\r
-    jmpCommonIdtEntry \r
-\r
-INT19: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $19\r
-    jmpCommonIdtEntry \r
-\r
-INTUnknown: \r
-# The following segment repeats (0x78 - 20) times:\r
-# No. 1\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 2\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 3\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 4\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 5\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 6\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 7\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 8\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 9\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 10\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 11\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 12\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 13\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 14\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 15\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 16\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 17\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 18\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 19\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 20\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 21\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 22\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 23\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 24\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 25\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 26\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 27\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 28\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 29\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 30\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 31\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 32\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 33\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 34\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 35\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 36\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 37\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 38\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 39\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 40\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 41\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 42\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 43\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 44\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 45\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 46\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 47\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 48\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 49\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 50\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 51\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 52\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 53\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 54\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 55\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 56\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 57\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 58\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 59\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 60\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 61\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 62\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 63\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 64\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 65\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 66\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 67\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 68\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 69\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 70\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 71\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 72\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 73\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 74\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 75\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 76\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 77\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 78\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 79\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 80\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 81\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 82\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 83\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 84\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 85\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 86\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 87\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 88\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 89\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 90\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 91\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 92\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 93\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 94\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 95\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 96\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 97\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 98\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 99\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-# No. 100\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#   push    $0xxx   # push vector number\r
-    .byte   0x6a\r
-    .long   ( . - INTUnknown - 3 ) / 9 + 20  # vector number\r
-    jmpCommonIdtEntry \r
-\r
-\r
-commonIdtEntry: \r
-    pushal\r
-    movl    %esp, %ebp\r
-##\r
-##  At this point the stack looks like this:\r
-##\r
-##      eflags\r
-##      Calling CS\r
-##      Calling EIP\r
-##      Error code or 0\r
-##      Int num or 0ffh for unknown int num\r
-##      eax\r
-##      ecx\r
-##      edx\r
-##      ebx\r
-##      esp\r
-##      ebp\r
-##      esi\r
-##      edi <------- ESP, EBP\r
-##      \r
-\r
-    call    ClearScreen\r
-    movl    String1, %esi\r
-    call    PrintString\r
-    movl    32(%ebp), %eax      ## move Int number into EAX \r
-    cmpl    $19, %eax\r
-    ja      PrintDefaultString\r
-PrintExceptionString: \r
-    shll    $2, %eax            ## multiply by 4 to get offset from StringTable to actual string address\r
-    addl    StringTable, %eax\r
-    movl    (%eax), %esi\r
-    jmp     PrintTheString\r
-PrintDefaultString: \r
-    movl    IntUnknownString, %esi\r
-    # patch Int number\r
-    movl    %eax, %edx\r
-    call    A2C\r
-    movb    %al, 1(%esi)\r
-    movl    %edx, %eax\r
-    shrl    $4, %eax\r
-    call    A2C\r
-    movb    %al, (%esi)\r
-PrintTheString:        \r
-    call    PrintString\r
-    movl    String2, %esi\r
-    call    PrintString\r
-    movl    44(%ebp), %eax         # CS\r
-    call    PrintDword\r
-    movb    ':', %al\r
-    movb    %al, (%edi)\r
-    addl    $2, %edi\r
-    movl    40(%ebp), %eax         # EIP\r
-    call    PrintDword\r
-    movl    String3, %esi\r
-    call    PrintString\r
-\r
-    movl    $0xb8140, %edi\r
-\r
-    movl    StringEax, %esi           # eax\r
-    call    PrintString\r
-    movl    28(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEbx, %esi           # ebx\r
-    call    PrintString\r
-    movl    16(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEcx, %esi           # ecx\r
-    call    PrintString\r
-    movl    24(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEdx, %esi           # edx\r
-    call    PrintString\r
-    movl    20(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEcode, %esi         # error code\r
-    call    PrintString\r
-    movl    36(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    $0xb81e0, %edi\r
-\r
-    movl    StringEsp, %esi           # esp\r
-    call    PrintString\r
-    movl    12(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEbp, %esi           # ebp\r
-    call    PrintString\r
-    movl    8(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEsi, %esi           # esi\r
-    call    PrintString\r
-    movl    4(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEdi, %esi          # edi\r
-    call    PrintString\r
-    movl    (%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    StringEflags, %esi       # eflags\r
-    call    PrintString\r
-    movl    48(%ebp), %eax\r
-    call    PrintDword\r
-\r
-    movl    $0xb8320, %edi\r
-\r
-    movl    %ebp, %esi\r
-    addl    $52, %esi\r
-    movl    $8, %ecx\r
-\r
-\r
-OuterLoop: \r
-    pushl   %ecx\r
-    movl    $8, %ecx\r
-    movl    %edi, %edx\r
-\r
-InnerLoop: \r
-    movl    (%esi), %eax\r
-    call    PrintDword\r
-    addl    $4, %esi\r
-    movb    ' ', %al \r
-    movb    %al, (%edi)\r
-    addl    $2, %edi\r
-    loop    InnerLoop\r
-\r
-    popl    %ecx\r
-    addl    $0xa0, %edx\r
-    movl    %edx, %edi\r
-    loop    OuterLoop\r
-\r
-\r
-    movl    $0xb8960, %edi\r
-\r
-    movl    40(%ebp), %eax # EIP\r
-    subl    $32*4, %eax\r
-    movl    %eax, %esi      # esi = eip - 32 DWORD linear (total 64 DWORD)\r
-\r
-    movl    $8, %ecx\r
-\r
-OuterLoop1: \r
-    pushl   %ecx\r
-    movl    $8, %ecx\r
-    movl    %edi, %edx\r
-\r
-InnerLoop1: \r
-    movl    (%esi), %eax\r
-    call    PrintDword\r
-    addl    $4, %esi\r
-    movb    ' ', %al \r
-    movb    %al, (%edi)\r
-    addl    $2, %edi\r
-    loop    InnerLoop1\r
-\r
-    popl    %ecx\r
-    addl    $0xa0, %edx\r
-    movl    %edx, %edi\r
-    loop    OuterLoop1\r
-\r
-\r
-\r
-#    wbinvd ; this intruction does not support in early than 486 arch\r
-LN_C1:    \r
-    jmp     LN_C1\r
-#\r
-# return\r
-#\r
-    movl    %ebp, %esp\r
-    popal\r
-    addl    $8, %esp # error code and INT number\r
-\r
-    iretl\r
-\r
-\r
-PrintString: \r
-    pushl   %eax\r
-LN_C2: \r
-    movb    (%esi), %al\r
-    cmpb    $0, %al\r
-    je      LN_C3\r
-    movb    %al, (%edi)\r
-    incl    %esi\r
-    addl    $2, %edi\r
-    jmp     LN_C2\r
-LN_C3: \r
-    popl    %eax\r
-    ret\r
-\r
-## EAX contains dword to print\r
-## EDI contains memory location (screen location) to print it to\r
-PrintDword: \r
-    pushl   %ecx\r
-    pushl   %ebx\r
-    pushl   %eax\r
-\r
-    movl    $8, %ecx\r
-looptop: \r
-    roll    $4, %eax\r
-    movb    %al, %bl\r
-    andb    $0xf, %bl\r
-    addb    '0', %bl\r
-    cmpb    '9', %bl\r
-    jle     LN_C4\r
-    addb    $7, %bl\r
-LN_C4: \r
-    movb    %bl, (%edi)\r
-    addl    $2, %edi\r
-    loop    looptop\r
-    #wbinvd\r
-\r
-    popl    %eax\r
-    popl    %ebx\r
-    popl    %ecx\r
-    ret\r
-\r
-ClearScreen: \r
-    pushl   %eax\r
-    pushl   %ecx\r
-\r
-    movb    $0x00, %al\r
-    movb    $0xc, %ah\r
-    movl    $0xb8000, %edi\r
-    movl    $80*24, %ecx\r
-LN_C5: \r
-    movw    %ax, (%edi)\r
-    addl    $2, %edi\r
-    loop    LN_C5\r
-    movl    $0xb8000, %edi\r
-\r
-    popl    %ecx\r
-    popl    %eax\r
-\r
-    ret\r
-\r
-A2C: \r
-    andb    $0xf, %al\r
-    addb    '0', %al\r
-    cmpb    '9', %al\r
-    jle     LN_C6\r
-    addb    $7, %al\r
-LN_C6: \r
-    ret\r
-\r
-String1:            .asciz      "*** INT "\r
-\r
-Int0String:         .asciz      "00h Divide by 0 -"\r
-Int1String:         .asciz      "01h Debug exception -"\r
-Int2String:         .asciz      "02h NMI -"\r
-Int3String:         .asciz      "03h Breakpoint -"\r
-Int4String:         .asciz      "04h Overflow -"\r
-Int5String:         .asciz      "05h Bound -"\r
-Int6String:         .asciz      "06h Invalid opcode -"\r
-Int7String:         .asciz      "07h Device not available -"\r
-Int8String:         .asciz      "08h Double fault -"\r
-Int9String:         .asciz      "09h Coprocessor seg overrun (reserved) -"\r
-Int10String:        .asciz      "0Ah Invalid TSS -"\r
-Int11String:        .asciz      "0Bh Segment not present -"\r
-Int12String:        .asciz      "0Ch Stack fault -"\r
-Int13String:        .asciz      "0Dh General protection fault -"\r
-Int14String:        .asciz      "0Eh Page fault -"\r
-Int15String:        .asciz      "0Fh (Intel reserved) -"\r
-Int16String:        .asciz      "10h Floating point error -"\r
-Int17String:        .asciz      "11h Alignment check -"\r
-Int18String:        .asciz      "12h Machine check -"\r
-Int19String:        .asciz      "13h SIMD Floating-Point Exception -"\r
-IntUnknownString:   .asciz      "??h Unknown interrupt -"\r
-\r
-StringTable:   .long  Int0String, Int1String, Int2String, Int3String,    \\r
-                      Int4String, Int5String, Int6String, Int7String,    \\r
-                      Int8String, Int9String, Int10String, Int11String,  \\r
-                      Int12String, Int13String, Int14String, Int15String,\\r
-                      Int16String, Int17String, Int18String, Int19String\r
-\r
-String2:         .asciz  " HALT!! *** ("\r
-String3:         .asciz  ")"\r
-StringEax:       .asciz  "EAX="\r
-StringEbx:       .asciz  "EBX="\r
-StringEcx:       .asciz  "ECX="\r
-StringEdx:       .asciz  "EDX="\r
-StringEcode:     .asciz  "ECODE="\r
-StringEsp:       .asciz  "ESP="\r
-StringEbp:       .asciz  "EBP="\r
-StringEsi:       .asciz  "ESI="\r
-StringEdi:       .asciz  "EDI="\r
-StringEflags:    .asciz  "EFLAGS="\r
-\r
-Idtr:        .float  0\r
-\r
-    .org 0x21ffe\r
-BlockSignature: \r
-    .word   0xaa55\r
-\r
-\r
diff --git a/DuetPkg/BootSector/efi32.asm b/DuetPkg/BootSector/efi32.asm
deleted file mode 100644 (file)
index 7ccf86f..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    efi32.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; Now in 32-bit protected mode.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        .486\r
-        .model  flat        \r
-        .stack\r
-        .code\r
-        org 21000h\r
-        \r
-DEFAULT_HANDLER_SIZE EQU INT1 - INT0\r
-\r
-JmpCommonIdtEntry  macro\r
-    ; jmp     commonIdtEntry - this must be hand coded to keep the assembler from\r
-    ;                          using a 8 bit reletive jump when the entries are\r
-    ;                          within 255 bytes of the common entry.  This must\r
-    ;                          be done to maintain the consistency of the size\r
-    ;                          of entry points...\r
-    db      0e9h                        ; jmp 16 bit relative \r
-    dd      commonIdtEntry - $ - 4      ;  offset to jump to\r
-endm    \r
-\r
-        \r
-Start:  \r
-    mov     ax,bx                      ; flat data descriptor in BX\r
-    mov     ds,ax\r
-    mov     es,ax\r
-    mov     fs,ax\r
-    mov     gs,ax\r
-    mov     ss,ax\r
-    mov     esp,0001ffff0h\r
-\r
-    call    ClearScreen\r
-\r
-    ; Populate IDT with meaningful offsets for exception handlers...\r
-    sidt    fword ptr [Idtr]             ; get fword address of IDT\r
-\r
-    mov     eax, offset Halt\r
-    mov     ebx, eax                    ; use bx to copy 15..0 to descriptors\r
-    shr     eax, 16                     ; use ax to copy 31..16 to descriptors \r
-    mov     ecx, 78h                    ; 78h IDT entries to initialize with unique entry points (exceptions)\r
-    mov     esi, [offset Idtr + 2]\r
-    mov     edi, [esi]\r
-    \r
-@@:                                             ; loop through all IDT entries exception handlers and initialize to default handler\r
-    mov     word ptr [edi], bx                  ; write bits 15..0 of offset\r
-    mov     word ptr [edi+2], 20h               ; SYS_CODE_SEL from GDT\r
-    mov     word ptr [edi+4], 0e00h OR 8000h    ; type = 386 interrupt gate, present\r
-    mov     word ptr [edi+6], ax                ; write bits 31..16 of offset\r
-    add     edi, 8                              ; move up to next descriptor\r
-    add     bx, DEFAULT_HANDLER_SIZE            ; move to next entry point\r
-    loop    @b                                  ; loop back through again until all descriptors are initialized\r
-    \r
-    ;; at this point edi contains the offset of the descriptor for INT 20\r
-    ;; and bx contains the low 16 bits of the offset of the default handler\r
-    ;; so initialize all the rest of the descriptors with these two values...\r
-;    mov     ecx, 101                            ; there are 100 descriptors left (INT 20 (14h) - INT 119 (77h)\r
-;@@:                                             ; loop through all IDT entries exception handlers and initialize to default handler\r
-;    mov     word ptr [edi], bx                  ; write bits 15..0 of offset\r
-;    mov     word ptr [edi+2], 20h               ; SYS_CODE_SEL from GDT\r
-;    mov     word ptr [edi+4], 0e00h OR 8000h    ; type = 386 interrupt gate, present\r
-;    mov     word ptr [edi+6], ax                ; write bits 31..16 of offset\r
-;    add     edi, 8                              ; move up to next descriptor\r
-;    loop    @b                                  ; loop back through again until all descriptors are initialized\r
-    \r
-    \r
-;;  DUMP    location of IDT and several of the descriptors\r
-;    mov     ecx, 8\r
-;    mov     eax, [offset Idtr + 2]\r
-;    mov     eax, [eax]\r
-;    mov     edi, 0b8000h\r
-;    call    PrintDword\r
-;    mov     esi, eax\r
-;    mov     edi, 0b80a0h\r
-;    jmp     OuterLoop\r
-    \r
-;;    \r
-;; just for fun, let's do a software interrupt to see if we correctly land in the exception handler...\r
-;    mov     eax, 011111111h\r
-;    mov     ebx, 022222222h\r
-;    mov     ecx, 033333333h\r
-;    mov     edx, 044444444h\r
-;    mov     ebp, 055555555h\r
-;    mov     esi, 066666666h\r
-;    mov     edi, 077777777h\r
-;    push    011111111h\r
-;    push    022222222h\r
-;    push    033333333h\r
-;    int     119\r
-\r
-    \r
-    mov     esi,022000h                 ; esi = 22000\r
-    mov     eax,[esi+014h]              ; eax = [22014]\r
-    add     esi,eax                     ; esi = 22000 + [22014] = Base of EFILDR.C\r
-    mov     ebp,[esi+03ch]              ; ebp = [22000 + [22014] + 3c] = NT Image Header for EFILDR.C\r
-    add     ebp,esi\r
-    mov     edi,[ebp+034h]              ; edi = [[22000 + [22014] + 3c] + 30] = ImageBase\r
-    mov     eax,[ebp+028h]              ; eax = [[22000 + [22014] + 3c] + 24] = EntryPoint\r
-    add     eax,edi                     ; eax = ImageBase + EntryPoint\r
-    mov     dword ptr [EfiLdrOffset],eax   ; Modify far jump instruction for correct entry point\r
-\r
-    mov     bx,word ptr[ebp+6]          ; bx = Number of sections\r
-    xor     eax,eax\r
-    mov     ax,word ptr[ebp+014h]       ; ax = Optional Header Size\r
-    add     ebp,eax\r
-    add     ebp,018h                    ; ebp = Start of 1st Section\r
-\r
-SectionLoop:\r
-    push    esi                         ; Save Base of EFILDR.C\r
-    push    edi                         ; Save ImageBase\r
-    add     esi,[ebp+014h]              ; esi = Base of EFILDR.C + PointerToRawData\r
-    add     edi,[ebp+00ch]              ; edi = ImageBase + VirtualAddress\r
-    mov     ecx,[ebp+010h]              ; ecs = SizeOfRawData\r
-\r
-    cld\r
-    shr     ecx,2\r
-    rep     movsd\r
-\r
-    pop     edi                         ; Restore ImageBase\r
-    pop     esi                         ; Restore Base of EFILDR.C\r
-\r
-    add     bp,028h                     ; ebp = ebp + 028h = Pointer to next section record\r
-    dec     bx\r
-    cmp     bx,0\r
-    jne     SectionLoop\r
-\r
-    movzx   eax, word ptr [Idtr]         ; get size of IDT\r
-    inc     eax\r
-    add     eax, dword ptr [Idtr + 2]    ; add to base of IDT to get location of memory map...\r
-    push    eax                         ; push memory map location on stack for call to EFILDR...\r
-\r
-    push    eax                         ; push return address (useless, just for stack balance)\r
-    db      0b8h\r
-EfiLdrOffset:\r
-    dd      000401000h                  ; Offset of EFILDR\r
-; mov eax, 401000h\r
-    push    eax\r
-    ret\r
-\r
-;    db      "**** DEFAULT IDT ENTRY ***",0\r
-    align 02h\r
-Halt:\r
-INT0:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    0h\r
-    JmpCommonIdtEntry\r
-;    db      0e9h                        ; jmp 16 bit reletive \r
-;    dd      commonIdtEntry - $ - 4      ;  offset to jump to\r
-    \r
-INT1:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    1h\r
-    JmpCommonIdtEntry\r
-    \r
-INT2:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    2h\r
-    JmpCommonIdtEntry\r
-    \r
-INT3:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    3h\r
-    JmpCommonIdtEntry\r
-    \r
-INT4:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    4h\r
-    JmpCommonIdtEntry\r
-    \r
-INT5:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    5h\r
-    JmpCommonIdtEntry\r
-    \r
-INT6:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    6h\r
-    JmpCommonIdtEntry\r
-    \r
-INT7:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    7h\r
-    JmpCommonIdtEntry\r
-    \r
-INT8:\r
-;   Double fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    8h\r
-    JmpCommonIdtEntry\r
-    \r
-INT9:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    9h\r
-    JmpCommonIdtEntry\r
-    \r
-INT10:\r
-;   Invalid TSS causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    10\r
-    JmpCommonIdtEntry\r
-    \r
-INT11:\r
-;   Segment Not Present causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    11\r
-    JmpCommonIdtEntry\r
-    \r
-INT12:\r
-;   Stack fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    12\r
-    JmpCommonIdtEntry\r
-    \r
-INT13:\r
-;   GP fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    13\r
-    JmpCommonIdtEntry\r
-    \r
-INT14:\r
-;   Page fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    14\r
-    JmpCommonIdtEntry\r
-    \r
-INT15:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    15\r
-    JmpCommonIdtEntry\r
-    \r
-INT16:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    16\r
-    JmpCommonIdtEntry\r
-    \r
-INT17:\r
-;   Alignment check causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    17\r
-    JmpCommonIdtEntry\r
-    \r
-INT18:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    18\r
-    JmpCommonIdtEntry\r
-    \r
-INT19:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    19\r
-    JmpCommonIdtEntry\r
-\r
-INTUnknown:\r
-REPEAT  (78h - 20)\r
-    push    0h      ; push error code place holder on the stack\r
-;    push    xxh     ; push vector number\r
-    db      06ah\r
-    db      ( $ - INTUnknown - 3 ) / 9 + 20 ; vector number\r
-    JmpCommonIdtEntry\r
-ENDM\r
-\r
-commonIdtEntry:\r
-    pushad\r
-    mov     ebp, esp\r
-;;\r
-;;  At this point the stack looks like this:\r
-;;\r
-;;      eflags\r
-;;      Calling CS\r
-;;      Calling EIP\r
-;;      Error code or 0\r
-;;      Int num or 0ffh for unknown int num\r
-;;      eax\r
-;;      ecx\r
-;;      edx\r
-;;      ebx\r
-;;      esp\r
-;;      ebp\r
-;;      esi\r
-;;      edi <------- ESP, EBP\r
-;;      \r
-\r
-    call    ClearScreen\r
-    mov     esi, offset String1\r
-    call    PrintString\r
-    mov     eax, [ebp + 32]     ;; move Int number into EAX \r
-    cmp     eax, 19\r
-    ja      PrintDefaultString\r
-PrintExceptionString:\r
-    shl     eax, 2              ;; multiply by 4 to get offset from StringTable to actual string address\r
-    add     eax, offset StringTable\r
-    mov     esi, [eax]\r
-    jmp     PrintTheString\r
-PrintDefaultString:\r
-    mov     esi, offset IntUnknownString\r
-    ; patch Int number\r
-    mov     edx, eax\r
-    call    A2C\r
-    mov     [esi + 1], al\r
-    mov     eax, edx\r
-    shr     eax, 4\r
-    call    A2C\r
-    mov     [esi], al\r
-PrintTheString:        \r
-    call    PrintString\r
-    mov     esi, offset String2\r
-    call    PrintString\r
-    mov     eax, [ebp+44]          ; CS\r
-    call    PrintDword\r
-    mov     al, ':'\r
-    mov     byte ptr [edi], al\r
-    add     edi, 2\r
-    mov     eax, [ebp+40]          ; EIP\r
-    call    PrintDword\r
-    mov     esi, offset String3\r
-    call    PrintString\r
-    \r
-    mov     edi, 0b8140h\r
-    \r
-    mov     esi, offset StringEax     ; eax\r
-    call    PrintString\r
-    mov     eax, [ebp+28]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEbx     ; ebx\r
-    call    PrintString\r
-    mov     eax, [ebp+16]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEcx     ; ecx\r
-    call    PrintString\r
-    mov     eax, [ebp+24]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEdx     ; edx\r
-    call    PrintString\r
-    mov     eax, [ebp+20]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEcode   ; error code\r
-    call    PrintString\r
-    mov     eax, [ebp+36]\r
-    call    PrintDword\r
-    \r
-    mov     edi, 0b81e0h\r
-    \r
-    mov     esi, offset StringEsp     ; esp\r
-    call    PrintString\r
-    mov     eax, [ebp+12]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEbp     ; ebp\r
-    call    PrintString\r
-    mov     eax, [ebp+8]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEsi     ; esi\r
-    call    PrintString\r
-    mov     eax, [ebp+4]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEdi    ; edi\r
-    call    PrintString\r
-    mov     eax, [ebp]\r
-    call    PrintDword\r
-    \r
-    mov     esi, offset StringEflags ; eflags\r
-    call    PrintString\r
-    mov     eax, [ebp+48]\r
-    call    PrintDword\r
-    \r
-    mov     edi, 0b8320h\r
-\r
-    mov     esi, ebp\r
-    add     esi, 52\r
-    mov     ecx, 8\r
-\r
-    \r
-OuterLoop:\r
-    push    ecx\r
-    mov     ecx, 8\r
-    mov     edx, edi\r
-\r
-InnerLoop:\r
-    mov     eax, [esi]\r
-    call    PrintDword\r
-    add     esi, 4\r
-    mov     al, ' '\r
-    mov     [edi], al\r
-    add     edi, 2\r
-    loop    InnerLoop\r
-\r
-    pop     ecx\r
-    add     edx, 0a0h\r
-    mov     edi, edx\r
-    loop    OuterLoop\r
-\r
-\r
-    mov     edi, 0b8960h\r
-\r
-    mov     eax, [ebp+40]  ; EIP\r
-    sub     eax, 32 * 4\r
-    mov     esi, eax        ; esi = eip - 32 DWORD linear (total 64 DWORD)\r
-\r
-    mov     ecx, 8\r
-    \r
-OuterLoop1:\r
-    push    ecx\r
-    mov     ecx, 8\r
-    mov     edx, edi\r
-\r
-InnerLoop1:\r
-    mov     eax, [esi]\r
-    call    PrintDword\r
-    add     esi, 4\r
-    mov     al, ' '\r
-    mov     [edi], al\r
-    add     edi, 2\r
-    loop    InnerLoop1\r
-\r
-    pop     ecx\r
-    add     edx, 0a0h\r
-    mov     edi, edx\r
-    loop    OuterLoop1\r
-\r
-\r
-\r
-;    wbinvd ; Ken: this intruction does not support in early than 486 arch\r
-@@:    \r
-    jmp     @b\r
-;\r
-; return\r
-;\r
-    mov     esp, ebp\r
-    popad\r
-    add     esp, 8 ; error code and INT number\r
-    \r
-    iretd\r
-\r
-\r
-PrintString:\r
-    push    eax\r
-@@:\r
-    mov     al, byte ptr [esi]\r
-    cmp     al, 0\r
-    je      @f\r
-    mov     byte ptr [edi], al\r
-    inc     esi\r
-    add     edi, 2\r
-    jmp     @b\r
-@@:\r
-    pop     eax\r
-    ret\r
-        \r
-;; EAX contains dword to print\r
-;; EDI contains memory location (screen location) to print it to\r
-PrintDword:\r
-    push    ecx\r
-    push    ebx\r
-    push    eax\r
-    \r
-    mov     ecx, 8\r
-looptop:\r
-    rol     eax, 4\r
-    mov     bl, al\r
-    and     bl, 0fh\r
-    add     bl, '0'\r
-    cmp     bl, '9'\r
-    jle     @f\r
-    add     bl, 7\r
-@@:\r
-    mov     byte ptr [edi], bl\r
-    add     edi, 2\r
-    loop    looptop\r
-    ;wbinvd\r
-    \r
-    pop     eax\r
-    pop     ebx\r
-    pop     ecx\r
-    ret\r
-\r
-ClearScreen:\r
-    push    eax\r
-    push    ecx\r
-    \r
-    mov     al, ' '\r
-    mov     ah, 0ch\r
-    mov     edi, 0b8000h\r
-    mov     ecx, 80 * 24\r
-@@:\r
-    mov     word ptr [edi], ax\r
-    add     edi, 2\r
-    loop    @b\r
-    mov     edi, 0b8000h\r
-    \r
-    pop     ecx\r
-    pop     eax\r
-\r
-    ret                \r
-        \r
-A2C:\r
-    and     al, 0fh\r
-    add     al, '0'\r
-    cmp     al, '9'\r
-    jle     @f\r
-    add     al, 7\r
-@@:\r
-    ret\r
-        \r
-String1           db  "*** INT ",0\r
-\r
-Int0String        db  "00h Divide by 0 -",0\r
-Int1String        db  "01h Debug exception -",0\r
-Int2String        db  "02h NMI -",0\r
-Int3String        db  "03h Breakpoint -",0\r
-Int4String        db  "04h Overflow -",0\r
-Int5String        db  "05h Bound -",0\r
-Int6String        db  "06h Invalid opcode -",0\r
-Int7String        db  "07h Device not available -",0\r
-Int8String        db  "08h Double fault -",0\r
-Int9String        db  "09h Coprocessor seg overrun (reserved) -",0\r
-Int10String       db  "0Ah Invalid TSS -",0\r
-Int11String       db  "0Bh Segment not present -",0\r
-Int12String       db  "0Ch Stack fault -",0\r
-Int13String       db  "0Dh General protection fault -",0\r
-Int14String       db  "0Eh Page fault -",0\r
-Int15String       db  "0Fh (Intel reserved) -",0\r
-Int16String       db  "10h Floating point error -",0\r
-Int17String       db  "11h Alignment check -",0\r
-Int18String       db  "12h Machine check -",0\r
-Int19String       db  "13h SIMD Floating-Point Exception -",0\r
-IntUnknownString  db  "??h Unknown interrupt -",0\r
-\r
-StringTable       dd  offset Int0String, offset Int1String, offset Int2String, offset Int3String, \r
-                      offset Int4String, offset Int5String, offset Int6String, offset Int7String,\r
-                      offset Int8String, offset Int9String, offset Int10String, offset Int11String,\r
-                      offset Int12String, offset Int13String, offset Int14String, offset Int15String,\r
-                      offset Int16String, offset Int17String, offset Int18String, offset Int19String\r
-\r
-String2           db  " HALT!! *** (",0\r
-String3           db  ")",0\r
-StringEax         db  "EAX=",0\r
-StringEbx         db  " EBX=",0\r
-StringEcx         db  " ECX=",0\r
-StringEdx         db  " EDX=",0\r
-StringEcode       db  " ECODE=",0\r
-StringEsp         db  "ESP=",0\r
-StringEbp         db  " EBP=",0\r
-StringEsi         db  " ESI=",0\r
-StringEdi         db  " EDI=",0\r
-StringEflags      db  " EFLAGS=",0\r
-\r
-Idtr        df  0\r
-\r
-    org 21ffeh\r
-BlockSignature:\r
-    dw      0aa55h\r
-    \r
-    end\r
diff --git a/DuetPkg/BootSector/efi64.S b/DuetPkg/BootSector/efi64.S
deleted file mode 100644 (file)
index 34bd752..0000000
+++ /dev/null
@@ -1,1385 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    efi64.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-##############################################################################\r
-# Now in 64-bit long mode.\r
-##############################################################################\r
-\r
-        .486: \r
-        .stack: \r
-        .code: \r
-        .org 0x21000\r
-\r
-.global _start\r
-_start:\r
-\r
-.equ                 DEFAULT_HANDLER_SIZE, INT1 - INT0\r
-\r
-.macro jmpCommonIdtEntry  \r
-    # jmp     commonIdtEntry - this must be hand coded to keep the assembler from\r
-    #                          using a 8 bit reletive jump when the entries are\r
-    #                          within 255 bytes of the common entry.  This must\r
-    #                          be done to maintain the consistency of the size\r
-    #                          of entry points...\r
-    .byte   0xe9                     # jmp 16 bit relative\r
-    .long   commonIdtEntry - . - 4   # offset to jump to\r
-.endm\r
-\r
-\r
-Start:  \r
-\r
-    movl    $0x001fffe8,%esp # make final stack aligned\r
-\r
-    # set OSFXSR and OSXMMEXCPT because some code will use XMM register\r
-    .byte 0xf\r
-    .byte 0x20\r
-    .byte 0xe0\r
-#    mov rax, cr4\r
-    btsl $9,%eax\r
-    btsl $0xa,%eax\r
-    .byte 0xf\r
-    .byte 0x22\r
-    .byte 0xe0\r
-#    mov cr4, rax\r
-\r
-    call    ClearScreen\r
-\r
-    # Populate IDT with meaningful offsets for exception handlers...\r
-    movl    $Idtr, %eax\r
-    sidt    (%eax)                      # get fword address of IDT\r
-    \r
-\r
-    movl    $Halt, %eax\r
-    movl    %eax,%ebx                   # use bx to copy 15..0 to descriptors\r
-    shrl    $16,%eax                    # use ax to copy 31..16 to descriptors \r
-                                        # 63..32 of descriptors is 0\r
-    movl    $0x78,%ecx                  # 78h IDT entries to initialize with unique entry points (exceptions)\r
-    movl    $(Idtr + 2), %esi\r
-    movl    (%esi),%edi\r
-\r
-LOOP_1:                                         # loop through all IDT entries exception handlers and initialize to default handler\r
-    movw    %bx, (%edi)                         # write bits 15..0 of offset\r
-    movw    $0x38, 2(%edi)                      # SYS_CODE_SEL64 from GDT\r
-    movw    $(0x0e00 | 0x8000), 4(%edi)         # type = 386 interrupt gate, present\r
-    movw    %ax, 6(%edi)                        # write bits 31..16 of offset\r
-    movl    $0, 8(%edi)                         # write bits 31..16 of offset  \r
-    addl    $16, %edi                           # move up to next descriptor\r
-    addw    $DEFAULT_HANDLER_SIZE, %bx          # move to next entry point\r
-    loopl   LOOP_1                              # loop back through again until all descriptors are initialized\r
-\r
-    ## at this point edi contains the offset of the descriptor for INT 20\r
-    ## and bx contains the low 16 bits of the offset of the default handler\r
-    ## so initialize all the rest of the descriptors with these two values...\r
-#    mov     ecx, 101                            ; there are 100 descriptors left (INT 20 (14h) - INT 119 (77h)\r
-#@@:                                             ; loop through all IDT entries exception handlers and initialize to default handler\r
-#    mov     word ptr [edi], bx                  ; write bits 15..0 of offset\r
-#    mov     word ptr [edi+2], 38h               ; SYS_CODE64_SEL from GDT\r
-#    mov     word ptr [edi+4], 0e00h OR 8000h    ; type = 386 interrupt gate, present\r
-#    mov     word ptr [edi+6], ax                ; write bits 31..16 of offset\r
-#    mov     dword ptr [edi+8], 0                ; write bits 63..32 of offset\r
-#    add     edi, 16                             ; move up to next descriptor\r
-#    loop    @b                                  ; loop back through again until all descriptors are initialized\r
-\r
-\r
-##  DUMP    location of IDT and several of the descriptors\r
-#    mov     ecx, 8\r
-#    mov     eax, [offset Idtr + 2]\r
-#    mov     eax, [eax]\r
-#    mov     edi, 0b8000h\r
-#    call    PrintQword\r
-#    mov     esi, eax\r
-#    mov     edi, 0b80a0h\r
-#    jmp     OuterLoop\r
-\r
-##    \r
-## just for fun, let's do a software interrupt to see if we correctly land in the exception handler...\r
-#    mov     eax, 011111111h\r
-#    mov     ebx, 022222222h\r
-#    mov     ecx, 033333333h\r
-#    mov     edx, 044444444h\r
-#    mov     ebp, 055555555h\r
-#    mov     esi, 066666666h\r
-#    mov     edi, 077777777h\r
-#    push    011111111h\r
-#    push    022222222h\r
-#    push    033333333h\r
-#    int     119\r
-\r
-    movl    $0x22000,%esi               # esi = 22000\r
-    movl    0x14(%esi),%eax             # eax = [22014]\r
-    addl    %eax,%esi                   # esi = 22000 + [22014] = Base of EFILDR.C\r
-    movl    0x3c(%esi),%ebp             # ebp = [22000 + [22014] + 3c] = NT Image Header for EFILDR.C\r
-    addl    %esi,%ebp\r
-    movl    0x30(%ebp),%edi             # edi = [[22000 + [22014] + 3c] + 2c] = ImageBase (63..32 is zero, ignore)\r
-    movl    0x28(%ebp),%eax             # eax = [[22000 + [22014] + 3c] + 24] = EntryPoint\r
-    addl    %edi,%eax                   # eax = ImageBase + EntryPoint\r
-    movl    $EfiLdrOffset, %ebx\r
-    movl    %eax, (%ebx)                # Modify far jump instruction for correct entry point\r
-\r
-    movw    6(%ebp), %bx                # bx = Number of sections\r
-    xorl    %eax,%eax\r
-    movw    0x14(%ebp), %ax             # ax = Optional Header Size\r
-    addl    %eax,%ebp\r
-    addl    $0x18,%ebp                  # ebp = Start of 1st Section\r
-\r
-SectionLoop: \r
-    pushl   %esi                        # Save Base of EFILDR.C\r
-    pushl   %edi                        # Save ImageBase\r
-    addl    0x14(%ebp),%esi             # esi = Base of EFILDR.C + PointerToRawData\r
-    addl    0x0c(%ebp),%edi             # edi = ImageBase + VirtualAddress\r
-    movl    0x10(%ebp),%ecx             # ecs = SizeOfRawData\r
-\r
-    cld\r
-    shrl    $2,%ecx\r
-    rep\r
-    movsl\r
-\r
-    popl    %edi                        # Restore ImageBase\r
-    popl    %esi                        # Restore Base of EFILDR.C\r
-\r
-    addw    $0x28,%bp                   # ebp = ebp + 028h = Pointer to next section record\r
-    .byte 0x66\r
-    .byte 0xff\r
-    .byte 0xcb\r
-#    dec     bx\r
-    cmpw    $0,%bx\r
-    jne     SectionLoop\r
-\r
-    movl    $Idtr, %edx                  # get size of IDT\r
-    movzxw  (%edx), %eax\r
-    .byte 0xff\r
-    .byte 0xc0\r
-#    inc     eax\r
-    addl    2(%edx), %eax                # add to base of IDT to get location of memory map...\r
-    xorl    %ecx,%ecx\r
-    movl    %eax,%ecx                    # put argument to RCX\r
-\r
-    .byte 0x48\r
-    .byte 0xc7\r
-    .byte 0xc0\r
-EfiLdrOffset: \r
-    .long 0x00401000                    # Offset of EFILDR\r
-#   mov rax, 401000h\r
-    .byte 0x50\r
-#   push rax\r
-\r
-# ret\r
-    .byte 0xc3\r
-\r
-#    db      "**** DEFAULT IDT ENTRY ***",0\r
-    .p2align 1\r
-Halt: \r
-INT0: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x0\r
-    jmpCommonIdtEntry \r
-#    db      0e9h                        ; jmp 16 bit reletive \r
-#    dd      commonIdtEntry - $ - 4      ;  offset to jump to\r
-\r
-INT1: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x1\r
-    jmpCommonIdtEntry \r
-\r
-INT2: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x2\r
-    jmpCommonIdtEntry \r
-\r
-INT3: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x3\r
-    jmpCommonIdtEntry \r
-\r
-INT4: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x4\r
-    jmpCommonIdtEntry \r
-\r
-INT5: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x5\r
-    jmpCommonIdtEntry \r
-\r
-INT6: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x6\r
-    jmpCommonIdtEntry \r
-\r
-INT7: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x7\r
-    jmpCommonIdtEntry \r
-\r
-INT8: \r
-#   Double fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $0x8\r
-    jmpCommonIdtEntry \r
-\r
-INT9: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $0x9\r
-    jmpCommonIdtEntry \r
-\r
-INT10: \r
-#   Invalid TSS causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $10\r
-    jmpCommonIdtEntry \r
-\r
-INT11: \r
-#   Segment Not Present causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $11\r
-    jmpCommonIdtEntry \r
-\r
-INT12: \r
-#   Stack fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $12\r
-    jmpCommonIdtEntry \r
-\r
-INT13: \r
-#   GP fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $13\r
-    jmpCommonIdtEntry \r
-\r
-INT14: \r
-#   Page fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $14\r
-    jmpCommonIdtEntry \r
-\r
-INT15: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $15\r
-    jmpCommonIdtEntry \r
-\r
-INT16: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $16\r
-    jmpCommonIdtEntry \r
-\r
-INT17: \r
-#   Alignment check causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    pushl   $17\r
-    jmpCommonIdtEntry \r
-\r
-INT18: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $18\r
-    jmpCommonIdtEntry \r
-\r
-INT19: \r
-    pushl   $0x0    # push error code place holder on the stack\r
-    pushl   $19\r
-    jmpCommonIdtEntry \r
-\r
-INTUnknown: \r
-# The following segment repeats (0x78 - 20) times:\r
-# No. 1\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 2\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 3\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 4\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 5\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 6\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 7\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 8\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 9\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 10\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 11\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 12\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 13\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 14\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 15\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 16\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 17\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 18\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 19\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 20\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 21\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 22\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 23\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 24\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 25\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 26\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 27\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 28\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 29\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 30\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 31\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 32\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 33\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 34\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 35\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 36\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 37\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 38\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 39\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 40\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 41\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 42\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 43\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 44\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 45\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 46\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 47\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 48\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 49\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 50\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 51\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 52\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 53\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 54\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 55\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 56\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 57\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 58\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 59\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 60\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 61\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 62\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 63\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 64\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 65\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 66\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 67\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 68\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 69\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 70\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 71\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 72\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 73\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 74\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 75\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 76\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 77\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 78\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 79\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 80\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 81\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 82\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 83\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 84\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 85\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 86\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 87\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 88\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 89\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 90\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 91\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 92\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 93\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 94\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 95\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 96\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 97\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 98\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 99\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-# No. 100\r
-    pushl   $0x0    # push error code place holder on the stack\r
-#    push    xxh     ; push vector number\r
-    .byte 0x6a\r
-    .byte      ( . - INTUnknown - 3 ) / 9 + 20   # vector number\r
-    jmpCommonIdtEntry \r
-\r
-\r
-commonIdtEntry: \r
-    pushl   %eax\r
-    pushl   %ecx\r
-    pushl   %edx\r
-    pushl   %ebx\r
-    pushl   %esp\r
-    pushl   %ebp\r
-    pushl   %esi\r
-    pushl   %edi\r
-    .byte 0x41\r
-    .byte 0x50\r
-#    push    r8\r
-    .byte 0x41\r
-    .byte 0x51\r
-#    push    r9\r
-    .byte 0x41\r
-    .byte 0x52\r
-#    push    r10\r
-    .byte 0x41\r
-    .byte 0x53\r
-#    push    r11\r
-    .byte 0x41\r
-    .byte 0x54\r
-#    push    r12\r
-    .byte 0x41\r
-    .byte 0x55\r
-#    push    r13\r
-    .byte 0x41\r
-    .byte 0x56\r
-#    push    r14\r
-    .byte 0x41\r
-    .byte 0x57\r
-#    push    r15\r
-    .byte 0x48\r
-    movl    %esp,%ebp\r
-#    mov     rbp, rsp\r
-\r
-##\r
-##  At this point the stack looks like this:\r
-##\r
-##      Calling SS\r
-##      Calling RSP\r
-##      rflags\r
-##      Calling CS\r
-##      Calling RIP\r
-##      Error code or 0\r
-##      Int num or 0ffh for unknown int num\r
-##      rax\r
-##      rcx\r
-##      rdx\r
-##      rbx\r
-##      rsp\r
-##      rbp\r
-##      rsi\r
-##      rdi\r
-##      r8\r
-##      r9\r
-##      r10\r
-##      r11\r
-##      r12\r
-##      r13\r
-##      r14\r
-##      r15 <------- RSP, RBP\r
-##      \r
-\r
-    call    ClearScreen\r
-    movl    $String1, %esi \r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    16*8(%ebp),%eax       ## move Int number into RAX \r
-    .byte 0x48\r
-    cmpl    $18,%eax\r
-    ja      PrintDefaultString\r
-PrintExceptionString: \r
-    shll    $3,%eax             ## multiply by 8 to get offset from StringTable to actual string address\r
-    addl    $StringTable, %eax\r
-    movl    (%eax),%esi\r
-    jmp     PrintTheString\r
-PrintDefaultString: \r
-    movl    $IntUnknownString, %esi\r
-    # patch Int number\r
-    movl    %eax,%edx\r
-    call    A2C\r
-    movb    %al,1(%esi)\r
-    movl    %edx,%eax\r
-    shrl    $4,%eax\r
-    call    A2C\r
-    movb    %al,(%esi)\r
-PrintTheString:        \r
-    call    PrintString\r
-    movl    $String2, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    19*8(%ebp),%eax    # CS\r
-    call    PrintQword\r
-    movb    $':', %al\r
-    movb    %al, (%edi)\r
-    addl    $2,%edi\r
-    .byte 0x48\r
-    movl    18*8(%ebp),%eax    # RIP\r
-    call    PrintQword\r
-    movl    $String3, %esi\r
-    call    PrintString\r
-\r
-    movl    $0xb8140,%edi\r
-\r
-    movl    $StringRax, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    15*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringRcx, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    14*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringRdx, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    13*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb81e0,%edi\r
-\r
-    movl    $StringRbx, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    12*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringRsp, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    21*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringRbp, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    10*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb8280,%edi\r
-\r
-    movl    $StringRsi, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    9*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringRdi, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    8*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringEcode, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    17*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb8320,%edi\r
-\r
-    movl    $StringR8, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    7*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringR9, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    6*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringR10, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    5*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb83c0,%edi\r
-\r
-    movl    $StringR11, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    4*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringR12, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    3*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringR13, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    2*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb8460,%edi\r
-\r
-    movl    $StringR14, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    1*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringR15, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    0*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $StringSs, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    22*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb8500,%edi\r
-\r
-    movl    $StringRflags, %esi\r
-    call    PrintString\r
-    .byte 0x48\r
-    movl    20*8(%ebp),%eax\r
-    call    PrintQword\r
-\r
-    movl    $0xb8640,%edi\r
-\r
-    movl    %ebp,%esi\r
-    addl    $23*8,%esi\r
-    movl    $4,%ecx\r
-\r
-\r
-OuterLoop: \r
-    pushl   %ecx\r
-    movl    $4,%ecx\r
-    .byte 0x48\r
-    movl    %edi,%edx\r
-\r
-InnerLoop: \r
-    .byte 0x48\r
-    movl    (%esi),%eax\r
-    call    PrintQword\r
-    addl    $8,%esi\r
-    movb    $0x20, %al       # blank character\r
-    movb    %al,(%edi)\r
-    addl    $2,%edi\r
-    loop    InnerLoop\r
-\r
-    popl    %ecx\r
-    addl    $0xa0,%edx\r
-    movl    %edx,%edi\r
-    loop    OuterLoop\r
-\r
-\r
-    movl    $0xb8960,%edi\r
-\r
-    .byte 0x48\r
-    movl    18*8(%ebp),%eax  # RIP\r
-    subl    $8*8,%eax\r
-    .byte 0x48\r
-    movl    %eax,%esi       # esi = rip - 8 QWORD linear (total 16 QWORD)\r
-\r
-    movl    $4,%ecx\r
-\r
-OuterLoop1: \r
-    pushl   %ecx\r
-    movl    $4,%ecx\r
-    movl    %edi,%edx\r
-\r
-InnerLoop1: \r
-    .byte 0x48\r
-    movl    (%esi),%eax\r
-    call    PrintQword\r
-    addl    $8,%esi\r
-    movb    $0x20, %al     # blank character\r
-    movb    %al,(%edi)\r
-    addl    $2,%edi\r
-    loop    InnerLoop1\r
-\r
-    popl    %ecx\r
-    addl    $0xa0,%edx\r
-    movl    %edx,%edi\r
-    loop    OuterLoop1\r
-\r
-\r
-\r
-    #wbinvd\r
-LN_C1:    \r
-    jmp     LN_C1\r
-\r
-#\r
-# return\r
-#\r
-    movl    %ebp,%esp\r
-#    mov     rsp, rbp\r
-    .byte 0x41\r
-    .byte 0x5f\r
-#    pop    r15\r
-    .byte 0x41\r
-    .byte 0x5e\r
-#    pop    r14\r
-    .byte 0x41\r
-    .byte 0x5d\r
-#    pop    r13\r
-    .byte 0x41\r
-    .byte 0x5c\r
-#    pop    r12\r
-    .byte 0x41\r
-    .byte 0x5b\r
-#    pop    r11\r
-    .byte 0x41\r
-    .byte 0x5a\r
-#    pop    r10\r
-    .byte 0x41\r
-    .byte 0x59\r
-#    pop    r9\r
-    .byte 0x41\r
-    .byte 0x58\r
-#    pop    r8\r
-    popl   %edi\r
-    popl   %esi\r
-    popl   %ebp\r
-    popl   %eax # esp\r
-    popl   %ebx\r
-    popl   %edx\r
-    popl   %ecx\r
-    popl   %eax\r
-\r
-    .byte 0x48\r
-    .byte 0x83\r
-    .byte 0xc4\r
-    .byte 0x10\r
-#    add    esp, 16 ; error code and INT number\r
-\r
-    .byte 0x48\r
-    .byte 0xcf\r
-#    iretq\r
-\r
-PrintString: \r
-    pushl   %eax\r
-LN_C2: \r
-    movb    (%esi), %al\r
-    cmpb    $0,%al\r
-    je      LN_C3\r
-    movb    %al, (%edi)\r
-    .byte 0xff\r
-    .byte 0xc6\r
-#    inc     esi\r
-    addl    $2,%edi\r
-    jmp     LN_C2\r
-LN_C3: \r
-    popl    %eax\r
-    ret\r
-\r
-## RAX contains qword to print\r
-## RDI contains memory location (screen location) to print it to\r
-PrintQword: \r
-    pushl   %ecx\r
-    pushl   %ebx\r
-    pushl   %eax\r
-\r
-    .byte 0x48\r
-    .byte 0xc7\r
-    .byte 0xc1\r
-    .long 16\r
-#    mov     rcx, 16\r
-looptop: \r
-    .byte 0x48\r
-    roll    $4,%eax\r
-    movb    %al,%bl\r
-    andb    $0xf,%bl\r
-    addb    $'0', %bl\r
-    cmpb    $'9', %bl\r
-    jle     LN_C4\r
-    addb    $7,%bl\r
-LN_C4: \r
-    movb %bl, (%edi)\r
-    addl    $2,%edi\r
-    loop    looptop\r
-    #wbinvd\r
-\r
-    popl    %eax\r
-    popl    %ebx\r
-    popl    %ecx\r
-    ret\r
-\r
-ClearScreen: \r
-    pushl   %eax\r
-    pushl   %ecx\r
-\r
-    movb    $0x20, %al       # blank character\r
-    movb    $0xc,%ah\r
-    movl    $0xb8000,%edi\r
-    movl    $80*24,%ecx\r
-LN_C5: \r
-    movw    %ax, (%edi)\r
-    addl    $2,%edi\r
-    loop    LN_C5\r
-    movl    $0xb8000,%edi\r
-\r
-    popl    %ecx\r
-    popl    %eax\r
-\r
-    ret\r
-\r
-A2C: \r
-    andb    $0xf,%al\r
-    addb    $'0', %al\r
-    cmpb    $'9', %al\r
-    jle     LN_C6\r
-    addb    $7,%al\r
-LN_C6: \r
-    ret\r
-\r
-String1:            .asciz      "*** INT "\r
-\r
-Int0String:         .asciz      "00h Divide by 0 -"\r
-Int1String:         .asciz      "01h Debug exception -"\r
-Int2String:         .asciz      "02h NMI -"\r
-Int3String:         .asciz      "03h Breakpoint -"\r
-Int4String:         .asciz      "04h Overflow -"\r
-Int5String:         .asciz      "05h Bound -"\r
-Int6String:         .asciz      "06h Invalid opcode -"\r
-Int7String:         .asciz      "07h Device not available -"\r
-Int8String:         .asciz      "08h Double fault -"\r
-Int9String:         .asciz      "09h Coprocessor seg overrun (reserved) -"\r
-Int10String:        .asciz      "0Ah Invalid TSS -"\r
-Int11String:        .asciz      "0Bh Segment not present -"\r
-Int12String:        .asciz      "0Ch Stack fault -"\r
-Int13String:        .asciz      "0Dh General protection fault -"\r
-Int14String:        .asciz      "0Eh Page fault -"\r
-Int15String:        .asciz      "0Fh (Intel reserved) -"\r
-Int16String:        .asciz      "10h Floating point error -"\r
-Int17String:        .asciz      "11h Alignment check -"\r
-Int18String:        .asciz      "12h Machine check -"\r
-Int19String:        .asciz      "13h SIMD Floating-Point Exception -"\r
-IntUnknownString:   .asciz      "??h Unknown interrupt -"\r
-\r
-StringTable:   .long  Int0String, 0, Int1String, 0, Int2String, 0, Int3String, 0,  \\r
-                      Int4String, 0, Int5String, 0, Int6String, 0, Int7String, 0,  \\r
-                      Int8String, 0, Int9String, 0, Int10String, 0, Int11String, 0,  \\r
-                      Int12String, 0, Int13String, 0, Int14String, 0, Int15String, 0,  \\r
-                      Int16String, 0, Int17String, 0, Int18String, 0, Int19String, 0\r
-\r
-String2:           .asciz  " HALT!! *** ("\r
-String3:           .asciz  ")"\r
-StringRax:         .asciz  "RAX="\r
-StringRcx:         .asciz  " RCX="\r
-StringRdx:         .asciz  " RDX="\r
-StringRbx:         .asciz  "RBX="\r
-StringRsp:         .asciz  " RSP="\r
-StringRbp:         .asciz  " RBP="\r
-StringRsi:         .asciz  "RSI="\r
-StringRdi:         .asciz  " RDI="\r
-StringEcode:       .asciz  " ECODE="\r
-StringR8:          .asciz  "R8 ="\r
-StringR9:          .asciz  " R9 ="\r
-StringR10:         .asciz  " R10="\r
-StringR11:         .asciz  "R11="\r
-StringR12:         .asciz  " R12="\r
-StringR13:         .asciz  " R13="\r
-StringR14:         .asciz  "R14="\r
-StringR15:         .asciz  " R15="\r
-StringSs:          .asciz  " SS ="\r
-StringRflags:      .asciz  "RFLAGS="\r
-\r
-Idtr:        .float  0\r
-            .float  0\r
-\r
-    .org 0x21ffe\r
-BlockSignature: \r
-    .word 0xaa55\r
-\r
diff --git a/DuetPkg/BootSector/efi64.asm b/DuetPkg/BootSector/efi64.asm
deleted file mode 100644 (file)
index ee6f9fd..0000000
+++ /dev/null
@@ -1,787 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    efi64.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; Now in 64-bit long mode.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        .486\r
-        .model  flat        \r
-        .stack\r
-        .code\r
-        org 21000h\r
-        \r
-DEFAULT_HANDLER_SIZE EQU INT1 - INT0\r
-\r
-JmpCommonIdtEntry  macro\r
-    ; jmp     commonIdtEntry - this must be hand coded to keep the assembler from\r
-    ;                          using a 8 bit reletive jump when the entries are\r
-    ;                          within 255 bytes of the common entry.  This must\r
-    ;                          be done to maintain the consistency of the size\r
-    ;                          of entry points...\r
-    db      0e9h                        ; jmp 16 bit reletive \r
-    dd      commonIdtEntry - $ - 4      ;  offset to jump to\r
-endm    \r
-\r
-        \r
-Start:  \r
-\r
-    mov     esp,0001fffe8h ; make final stack aligned\r
-\r
-    ; set OSFXSR and OSXMMEXCPT because some code will use XMM register\r
-    db 0fh\r
-    db 20h\r
-    db 0e0h\r
-;    mov rax, cr4\r
-    bts eax, 9\r
-    bts eax, 0ah\r
-    db 0fh\r
-    db 22h\r
-    db 0e0h\r
-;    mov cr4, rax\r
-\r
-    call    ClearScreen\r
-\r
-    ; Populate IDT with meaningful offsets for exception handlers...\r
-    mov     eax, offset Idtr\r
-    sidt    fword ptr [eax]             ; get fword address of IDT\r
-\r
-    mov     eax, offset Halt\r
-    mov     ebx, eax                    ; use bx to copy 15..0 to descriptors\r
-    shr     eax, 16                     ; use ax to copy 31..16 to descriptors \r
-                                        ; 63..32 of descriptors is 0\r
-    mov     ecx, 78h                    ; 78h IDT entries to initialize with unique entry points (exceptions)\r
-    mov     esi, [offset Idtr + 2]\r
-    mov     edi, [esi]\r
-\r
-@@:                                             ; loop through all IDT entries exception handlers and initialize to default handler\r
-    mov     word ptr [edi], bx                  ; write bits 15..0 of offset\r
-    mov     word ptr [edi+2], 38h               ; SYS_CODE64_SEL from GDT\r
-    mov     word ptr [edi+4], 0e00h OR 8000h    ; type = 386 interrupt gate, present\r
-    mov     word ptr [edi+6], ax                ; write bits 31..16 of offset\r
-    mov     dword ptr [edi+8], 0                ; write bits 63..32 of offset\r
-    add     edi, 16                             ; move up to next descriptor\r
-    add     bx, DEFAULT_HANDLER_SIZE            ; move to next entry point\r
-    loop    @b                                  ; loop back through again until all descriptors are initialized\r
-    \r
-    ;; at this point edi contains the offset of the descriptor for INT 20\r
-    ;; and bx contains the low 16 bits of the offset of the default handler\r
-    ;; so initialize all the rest of the descriptors with these two values...\r
-;    mov     ecx, 101                            ; there are 100 descriptors left (INT 20 (14h) - INT 119 (77h)\r
-;@@:                                             ; loop through all IDT entries exception handlers and initialize to default handler\r
-;    mov     word ptr [edi], bx                  ; write bits 15..0 of offset\r
-;    mov     word ptr [edi+2], 38h               ; SYS_CODE64_SEL from GDT\r
-;    mov     word ptr [edi+4], 0e00h OR 8000h    ; type = 386 interrupt gate, present\r
-;    mov     word ptr [edi+6], ax                ; write bits 31..16 of offset\r
-;    mov     dword ptr [edi+8], 0                ; write bits 63..32 of offset\r
-;    add     edi, 16                             ; move up to next descriptor\r
-;    loop    @b                                  ; loop back through again until all descriptors are initialized\r
-    \r
-    \r
-;;  DUMP    location of IDT and several of the descriptors\r
-;    mov     ecx, 8\r
-;    mov     eax, [offset Idtr + 2]\r
-;    mov     eax, [eax]\r
-;    mov     edi, 0b8000h\r
-;    call    PrintQword\r
-;    mov     esi, eax\r
-;    mov     edi, 0b80a0h\r
-;    jmp     OuterLoop\r
-    \r
-;;    \r
-;; just for fun, let's do a software interrupt to see if we correctly land in the exception handler...\r
-;    mov     eax, 011111111h\r
-;    mov     ebx, 022222222h\r
-;    mov     ecx, 033333333h\r
-;    mov     edx, 044444444h\r
-;    mov     ebp, 055555555h\r
-;    mov     esi, 066666666h\r
-;    mov     edi, 077777777h\r
-;    push    011111111h\r
-;    push    022222222h\r
-;    push    033333333h\r
-;    int     119\r
-\r
-    mov     esi,022000h                 ; esi = 22000\r
-    mov     eax,[esi+014h]              ; eax = [22014]\r
-    add     esi,eax                     ; esi = 22000 + [22014] = Base of EFILDR.C\r
-    mov     ebp,[esi+03ch]              ; ebp = [22000 + [22014] + 3c] = NT Image Header for EFILDR.C\r
-    add     ebp,esi\r
-    mov     edi,[ebp+030h]              ; edi = [[22000 + [22014] + 3c] + 2c] = ImageBase (63..32 is zero, ignore)\r
-    mov     eax,[ebp+028h]              ; eax = [[22000 + [22014] + 3c] + 24] = EntryPoint\r
-    add     eax,edi                     ; eax = ImageBase + EntryPoint\r
-    mov     ebx, offset EfiLdrOffset\r
-    mov     dword ptr [ebx],eax         ; Modify far jump instruction for correct entry point\r
-\r
-    mov     bx,word ptr[ebp+6]          ; bx = Number of sections\r
-    xor     eax,eax\r
-    mov     ax,word ptr[ebp+014h]       ; ax = Optional Header Size\r
-    add     ebp,eax\r
-    add     ebp,018h                    ; ebp = Start of 1st Section\r
-\r
-SectionLoop:\r
-    push    esi                         ; Save Base of EFILDR.C\r
-    push    edi                         ; Save ImageBase\r
-    add     esi,[ebp+014h]              ; esi = Base of EFILDR.C + PointerToRawData\r
-    add     edi,[ebp+00ch]              ; edi = ImageBase + VirtualAddress\r
-    mov     ecx,[ebp+010h]              ; ecs = SizeOfRawData\r
-\r
-    cld\r
-    shr     ecx,2\r
-    rep     movsd\r
-\r
-    pop     edi                         ; Restore ImageBase\r
-    pop     esi                         ; Restore Base of EFILDR.C\r
-\r
-    add     bp,028h                     ; ebp = ebp + 028h = Pointer to next section record\r
-    db 66h\r
-    db 0ffh\r
-    db 0cbh\r
-;    dec     bx\r
-    cmp     bx,0\r
-    jne     SectionLoop\r
-\r
-    mov     edx, offset Idtr\r
-    movzx   eax, word ptr [edx]          ; get size of IDT\r
-    db 0ffh\r
-    db 0c0h\r
-;    inc     eax\r
-    add     eax, dword ptr [edx + 2]     ; add to base of IDT to get location of memory map...\r
-    xor     ecx, ecx\r
-    mov     ecx, eax                     ; put argument to RCX\r
-\r
-    db 48h\r
-    db 0c7h\r
-    db 0c0h\r
-EfiLdrOffset:\r
-    dd      000401000h                  ; Offset of EFILDR\r
-;   mov rax, 401000h\r
-    db 50h\r
-;   push rax\r
-\r
-; ret\r
-    db 0c3h\r
-\r
-;    db      "**** DEFAULT IDT ENTRY ***",0\r
-    align 02h\r
-Halt:\r
-INT0:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    0h\r
-    JmpCommonIdtEntry\r
-;    db      0e9h                        ; jmp 16 bit reletive \r
-;    dd      commonIdtEntry - $ - 4      ;  offset to jump to\r
-    \r
-INT1:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    1h\r
-    JmpCommonIdtEntry\r
-    \r
-INT2:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    2h\r
-    JmpCommonIdtEntry\r
-    \r
-INT3:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    3h\r
-    JmpCommonIdtEntry\r
-    \r
-INT4:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    4h\r
-    JmpCommonIdtEntry\r
-    \r
-INT5:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    5h\r
-    JmpCommonIdtEntry\r
-    \r
-INT6:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    6h\r
-    JmpCommonIdtEntry\r
-    \r
-INT7:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    7h\r
-    JmpCommonIdtEntry\r
-    \r
-INT8:\r
-;   Double fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    8h\r
-    JmpCommonIdtEntry\r
-    \r
-INT9:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    9h\r
-    JmpCommonIdtEntry\r
-    \r
-INT10:\r
-;   Invalid TSS causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    10\r
-    JmpCommonIdtEntry\r
-    \r
-INT11:\r
-;   Segment Not Present causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    11\r
-    JmpCommonIdtEntry\r
-    \r
-INT12:\r
-;   Stack fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    12\r
-    JmpCommonIdtEntry\r
-    \r
-INT13:\r
-;   GP fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    13\r
-    JmpCommonIdtEntry\r
-    \r
-INT14:\r
-;   Page fault causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    14\r
-    JmpCommonIdtEntry\r
-    \r
-INT15:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    15\r
-    JmpCommonIdtEntry\r
-    \r
-INT16:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    16\r
-    JmpCommonIdtEntry\r
-    \r
-INT17:\r
-;   Alignment check causes an error code to be pushed so no phony push necessary\r
-    nop\r
-    nop\r
-    push    17\r
-    JmpCommonIdtEntry\r
-    \r
-INT18:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    18\r
-    JmpCommonIdtEntry\r
-    \r
-INT19:\r
-    push    0h      ; push error code place holder on the stack\r
-    push    19\r
-    JmpCommonIdtEntry\r
-\r
-INTUnknown:\r
-REPEAT  (78h - 20)\r
-    push    0h      ; push error code place holder on the stack\r
-;    push    xxh     ; push vector number\r
-    db      06ah\r
-    db      ( $ - INTUnknown - 3 ) / 9 + 20 ; vector number\r
-    JmpCommonIdtEntry\r
-ENDM\r
-\r
-commonIdtEntry:\r
-    push    eax\r
-    push    ecx\r
-    push    edx\r
-    push    ebx\r
-    push    esp\r
-    push    ebp\r
-    push    esi\r
-    push    edi\r
-    db 41h\r
-    db 50h\r
-;    push    r8\r
-    db 41h\r
-    db 51h\r
-;    push    r9\r
-    db 41h\r
-    db 52h\r
-;    push    r10\r
-    db 41h\r
-    db 53h\r
-;    push    r11\r
-    db 41h\r
-    db 54h\r
-;    push    r12\r
-    db 41h\r
-    db 55h\r
-;    push    r13\r
-    db 41h\r
-    db 56h\r
-;    push    r14\r
-    db 41h\r
-    db 57h\r
-;    push    r15\r
-    db 48h\r
-    mov     ebp, esp\r
-;    mov     rbp, rsp\r
-\r
-;;\r
-;;  At this point the stack looks like this:\r
-;;\r
-;;      Calling SS\r
-;;      Calling RSP\r
-;;      rflags\r
-;;      Calling CS\r
-;;      Calling RIP\r
-;;      Error code or 0\r
-;;      Int num or 0ffh for unknown int num\r
-;;      rax\r
-;;      rcx\r
-;;      rdx\r
-;;      rbx\r
-;;      rsp\r
-;;      rbp\r
-;;      rsi\r
-;;      rdi\r
-;;      r8\r
-;;      r9\r
-;;      r10\r
-;;      r11\r
-;;      r12\r
-;;      r13\r
-;;      r14\r
-;;      r15 <------- RSP, RBP\r
-;;      \r
-\r
-    call    ClearScreen\r
-    mov     esi, offset String1\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp + 16*8]     ;; move Int number into RAX \r
-    db 48h\r
-    cmp     eax, 18\r
-    ja      PrintDefaultString\r
-PrintExceptionString:\r
-    shl     eax, 3              ;; multiply by 8 to get offset from StringTable to actual string address\r
-    add     eax, offset StringTable\r
-    mov     esi, [eax]\r
-    jmp     PrintTheString\r
-PrintDefaultString:\r
-    mov     esi, offset IntUnknownString\r
-    ; patch Int number\r
-    mov     edx, eax\r
-    call    A2C\r
-    mov     [esi + 1], al\r
-    mov     eax, edx\r
-    shr     eax, 4\r
-    call    A2C\r
-    mov     [esi], al\r
-PrintTheString:        \r
-    call    PrintString\r
-    mov     esi, offset String2\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+19*8]    ; CS\r
-    call    PrintQword\r
-    mov     al, ':'\r
-    mov     byte ptr [edi], al\r
-    add     edi, 2\r
-    db 48h\r
-    mov     eax, [ebp+18*8]    ; RIP\r
-    call    PrintQword\r
-    mov     esi, offset String3\r
-    call    PrintString\r
-    \r
-    mov     edi, 0b8140h\r
-    \r
-    mov     esi, offset StringRax     ; rax\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+15*8]\r
-    call    PrintQword\r
-   \r
-    mov     esi, offset StringRcx     ; rcx\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+14*8]\r
-    call    PrintQword\r
-    \r
-    mov     esi, offset StringRdx     ; rdx\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+13*8]\r
-    call    PrintQword\r
-    \r
-    mov     edi, 0b81e0h\r
-    \r
-    mov     esi, offset StringRbx     ; rbx\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+12*8]\r
-    call    PrintQword\r
-     \r
-    mov     esi, offset StringRsp     ; rsp\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+21*8]\r
-    call    PrintQword\r
-    \r
-    mov     esi, offset StringRbp     ; rbp\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+10*8]\r
-    call    PrintQword\r
-    \r
-    mov     edi, 0b8280h\r
-     \r
-    mov     esi, offset StringRsi     ; rsi\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+9*8]\r
-    call    PrintQword\r
-    \r
-    mov     esi, offset StringRdi     ; rdi\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+8*8]\r
-    call    PrintQword\r
-    \r
-    mov     esi, offset StringEcode   ; error code\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+17*8]\r
-    call    PrintQword\r
-    \r
-    mov     edi, 0b8320h\r
\r
-    mov     esi, offset StringR8      ; r8\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+7*8]\r
-    call    PrintQword\r
-\r
-    mov     esi, offset StringR9      ; r9\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+6*8]\r
-    call    PrintQword\r
-\r
-    mov     esi, offset StringR10     ; r10\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+5*8]\r
-    call    PrintQword\r
-\r
-    mov     edi, 0b83c0h\r
-\r
-    mov     esi, offset StringR11     ; r11\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+4*8]\r
-    call    PrintQword\r
-\r
-    mov     esi, offset StringR12     ; r12\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+3*8]\r
-    call    PrintQword\r
-\r
-    mov     esi, offset StringR13     ; r13\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+2*8]\r
-    call    PrintQword\r
\r
-    mov     edi, 0b8460h\r
-\r
-    mov     esi, offset StringR14     ; r14\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+1*8]\r
-    call    PrintQword\r
\r
-    mov     esi, offset StringR15     ; r15\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+0*8]\r
-    call    PrintQword\r
-\r
-    mov     esi, offset StringSs      ; ss\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+22*8]\r
-    call    PrintQword\r
-  \r
-    mov     edi, 0b8500h\r
-\r
-    mov     esi, offset StringRflags  ; rflags\r
-    call    PrintString\r
-    db 48h\r
-    mov     eax, [ebp+20*8]\r
-    call    PrintQword\r
-    \r
-    mov     edi, 0b8640h\r
-\r
-    mov     esi, ebp\r
-    add     esi, 23*8\r
-    mov     ecx, 4\r
-\r
-    \r
-OuterLoop:\r
-    push    ecx\r
-    mov     ecx, 4\r
-    db 48h\r
-    mov     edx, edi\r
-\r
-InnerLoop:\r
-    db 48h\r
-    mov     eax, [esi]\r
-    call    PrintQword\r
-    add     esi, 8\r
-    mov     al, ' '\r
-    mov     [edi], al\r
-    add     edi, 2\r
-    loop    InnerLoop\r
-\r
-    pop     ecx\r
-    add     edx, 0a0h\r
-    mov     edi, edx\r
-    loop    OuterLoop\r
-\r
-\r
-    mov     edi, 0b8960h\r
-\r
-    db 48h\r
-    mov     eax, [ebp+18*8]  ; RIP\r
-    sub     eax, 8 * 8\r
-    db 48h\r
-    mov     esi, eax        ; esi = rip - 8 QWORD linear (total 16 QWORD)\r
-\r
-    mov     ecx, 4\r
-    \r
-OuterLoop1:\r
-    push    ecx\r
-    mov     ecx, 4\r
-    mov     edx, edi\r
-\r
-InnerLoop1:\r
-    db 48h\r
-    mov     eax, [esi]\r
-    call    PrintQword\r
-    add     esi, 8\r
-    mov     al, ' '\r
-    mov     [edi], al\r
-    add     edi, 2\r
-    loop    InnerLoop1\r
-\r
-    pop     ecx\r
-    add     edx, 0a0h\r
-    mov     edi, edx\r
-    loop    OuterLoop1\r
-\r
-\r
-\r
-    ;wbinvd\r
-@@:    \r
-    jmp     @b\r
-\r
-;\r
-; return\r
-;\r
-    mov     esp, ebp\r
-;    mov     rsp, rbp\r
-    db 41h\r
-    db 5fh\r
-;    pop    r15\r
-    db 41h\r
-    db 5eh\r
-;    pop    r14\r
-    db 41h\r
-    db 5dh\r
-;    pop    r13\r
-    db 41h\r
-    db 5ch\r
-;    pop    r12\r
-    db 41h\r
-    db 5bh\r
-;    pop    r11\r
-    db 41h\r
-    db 5ah\r
-;    pop    r10\r
-    db 41h\r
-    db 59h\r
-;    pop    r9\r
-    db 41h\r
-    db 58h\r
-;    pop    r8\r
-    pop    edi\r
-    pop    esi\r
-    pop    ebp\r
-    pop    eax ; esp\r
-    pop    ebx\r
-    pop    edx\r
-    pop    ecx\r
-    pop    eax\r
\r
-    db 48h\r
-    db 83h\r
-    db 0c4h\r
-    db 10h   \r
-;    add    esp, 16 ; error code and INT number\r
-\r
-    db 48h\r
-    db 0cfh\r
-;    iretq\r
-\r
-PrintString:\r
-    push    eax\r
-@@:\r
-    mov     al, byte ptr [esi]\r
-    cmp     al, 0\r
-    je      @f\r
-    mov     byte ptr [edi], al\r
-    db 0ffh\r
-    db 0c6h\r
-;    inc     esi\r
-    add     edi, 2\r
-    jmp     @b\r
-@@:\r
-    pop     eax\r
-    ret\r
-        \r
-;; RAX contains qword to print\r
-;; RDI contains memory location (screen location) to print it to\r
-PrintQword:\r
-    push    ecx\r
-    push    ebx\r
-    push    eax\r
-    \r
-    db 48h\r
-    db 0c7h\r
-    db 0c1h\r
-    dd 16\r
-;    mov     rcx, 16\r
-looptop:\r
-    db 48h\r
-    rol     eax, 4\r
-    mov     bl, al\r
-    and     bl, 0fh\r
-    add     bl, '0'\r
-    cmp     bl, '9'\r
-    jle     @f\r
-    add     bl, 7\r
-@@:\r
-    mov     byte ptr [edi], bl\r
-    add     edi, 2\r
-    loop    looptop\r
-    ;wbinvd\r
-    \r
-    pop     eax\r
-    pop     ebx\r
-    pop     ecx\r
-    ret\r
-\r
-ClearScreen:\r
-    push    eax\r
-    push    ecx\r
-    \r
-    mov     al, ' '\r
-    mov     ah, 0ch\r
-    mov     edi, 0b8000h\r
-    mov     ecx, 80 * 24\r
-@@:\r
-    mov     word ptr [edi], ax\r
-    add     edi, 2\r
-    loop    @b\r
-    mov     edi, 0b8000h\r
-    \r
-    pop     ecx\r
-    pop     eax\r
-\r
-    ret                \r
-        \r
-A2C:\r
-    and     al, 0fh\r
-    add     al, '0'\r
-    cmp     al, '9'\r
-    jle     @f\r
-    add     al, 7\r
-@@:\r
-    ret\r
-        \r
-String1           db  "*** INT ",0\r
-\r
-Int0String        db  "00h Divide by 0 -",0\r
-Int1String        db  "01h Debug exception -",0\r
-Int2String        db  "02h NMI -",0\r
-Int3String        db  "03h Breakpoint -",0\r
-Int4String        db  "04h Overflow -",0\r
-Int5String        db  "05h Bound -",0\r
-Int6String        db  "06h Invalid opcode -",0\r
-Int7String        db  "07h Device not available -",0\r
-Int8String        db  "08h Double fault -",0\r
-Int9String        db  "09h Coprocessor seg overrun (reserved) -",0\r
-Int10String       db  "0Ah Invalid TSS -",0\r
-Int11String       db  "0Bh Segment not present -",0\r
-Int12String       db  "0Ch Stack fault -",0\r
-Int13String       db  "0Dh General protection fault -",0\r
-Int14String       db  "0Eh Page fault -",0\r
-Int15String       db  "0Fh (Intel reserved) -",0\r
-Int16String       db  "10h Floating point error -",0\r
-Int17String       db  "11h Alignment check -",0\r
-Int18String       db  "12h Machine check -",0\r
-Int19String       db  "13h SIMD Floating-Point Exception -",0\r
-IntUnknownString  db  "??h Unknown interrupt -",0\r
-\r
-StringTable       dq  offset Int0String, offset Int1String, offset Int2String, offset Int3String, \r
-                      offset Int4String, offset Int5String, offset Int6String, offset Int7String,\r
-                      offset Int8String, offset Int9String, offset Int10String, offset Int11String,\r
-                      offset Int12String, offset Int13String, offset Int14String, offset Int15String,\r
-                      offset Int16String, offset Int17String, offset Int18String, offset Int19String\r
-\r
-String2           db  " HALT!! *** (",0\r
-String3           db  ")",0\r
-StringRax         db  "RAX=",0\r
-StringRcx         db  " RCX=",0\r
-StringRdx         db  " RDX=",0\r
-StringRbx         db  "RBX=",0\r
-StringRsp         db  " RSP=",0\r
-StringRbp         db  " RBP=",0\r
-StringRsi         db  "RSI=",0\r
-StringRdi         db  " RDI=",0\r
-StringEcode       db  " ECODE=",0\r
-StringR8          db  "R8 =",0\r
-StringR9          db  " R9 =",0\r
-StringR10         db  " R10=",0\r
-StringR11         db  "R11=",0\r
-StringR12         db  " R12=",0\r
-StringR13         db  " R13=",0\r
-StringR14         db  "R14=",0\r
-StringR15         db  " R15=",0\r
-StringSs          db  " SS =",0\r
-StringRflags      db  "RFLAGS=",0\r
-\r
-Idtr        df  0\r
-            df  0\r
-\r
-    org 21ffeh\r
-BlockSignature:\r
-    dw      0aa55h\r
-    \r
-    end\r
diff --git a/DuetPkg/BootSector/st16_64.S b/DuetPkg/BootSector/st16_64.S
deleted file mode 100644 (file)
index 8eadd28..0000000
+++ /dev/null
@@ -1,1142 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    st16_64.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                        FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                        FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                        BLOCK_SIZE, 0x0200\r
-.equ                        BLOCK_MASK, 0x01ff\r
-.equ                        BLOCK_SHIFT, 9\r
-\r
-       .org 0x0\r
-\r
-.global _start\r
-_start:\r
-\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId:              .ascii   "INTEL   "       # OemId               - 8 bytes\r
-\r
-SectorSize:         .word  0                  # Sector Size         - 16 bits\r
-SectorsPerCluster:  .byte  0                  # Sector Per Cluster  - 8 bits\r
-ReservedSectors:    .word  0                  # Reserved Sectors    - 16 bits\r
-NoFats:             .byte  0                  # Number of FATs      - 8 bits\r
-RootEntries:        .word  0                  # Root Entries        - 16 bits\r
-Sectors:            .word  0                  # Number of Sectors   - 16 bits\r
-Media:              .byte  0                  # Media               - 8 bits  - ignored\r
-SectorsPerFat:      .word  0                  # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:    .word  0                  # Sectors Per Track   - 16 bits - ignored\r
-Heads:              .word  0                  # Heads               - 16 bits - ignored\r
-HiddenSectors:      .long  0                  # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:       .long  0                  # Large Sectors       - 32 bits \r
-PhysicalDrive:      .byte  0                  # PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead:        .byte  0                  # Current Head        - 8 bits\r
-Signature:          .byte  0                  # Signature           - 8 bits  - ignored\r
-VolId:              .ascii "    "             # Volume Serial Number- 4 bytes\r
-FatLabel:           .ascii "           "      # Label               - 11 bytes\r
-SystemId:           .ascii "FAT16   "         # SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-      # ASSUME  ds:@code\r
-      # ASSUME  ss:@code\r
-      # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      # cx = Start Cluster of EfiLdr\r
-      # dx = Start Cluster of Efivar.bin\r
-\r
-# Re use the BPB data stored in Boot Sector\r
-        movw    $0x7c00,%bp\r
-\r
-        pushw   %cx\r
-# Read Efivar.bin\r
-#       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        movw    $0x1900,%ax\r
-        movw    %ax,%es\r
-        testw   %dx,%dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        movb    $1,%al\r
-NoVarStore: \r
-        pushw   %es\r
-# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        movb    %al, %es:(4)\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize: \r
-        movw    %dx,%di\r
-        cmpl    $0x4000, %ds:2(%di)\r
-        movb    $2,%al\r
-        jne     NoVarStore\r
-\r
-LoadVarStore: \r
-        movb    $0,%al\r
-        movb    %al, %es:(4)\r
-        movw    (%di), %cx\r
-#       ES:DI = 1500:0\r
-        xorw    %di,%di\r
-        pushw   %es\r
-        movw    $0x1500,%ax\r
-        movw    %ax,%es\r
-        call    ReadFile\r
-SaveVolumeId: \r
-        popw    %es\r
-        movw    VolId(%bp), %ax\r
-        movw    %ax, %es:(0)                    # Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        movw    VolId+2(%bp), %ax\r
-        movw    %ax, %es:(2)\r
-\r
-# Read Efildr\r
-        popw    %cx\r
-#       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-#       ES:DI = 2000:0, first cluster will be read again\r
-        xorw    %di,%di                             # di = 0\r
-        movw    $0x2000,%ax\r
-        movw    %ax,%es\r
-        call    ReadFile\r
-        movw    %cs,%ax\r
-        movw    %ax, %cs:JumpSegment\r
-\r
-CheckEm64T: \r
-        movl $0x80000001,%eax\r
-#        cpuid\r
-        .word 0xA20F\r
-        btl  $29,%edx\r
-        jc   CheckEm64TPass\r
-        pushw %cs\r
-        popw %ds\r
-        leaw Em64String,%si\r
-        movw $18,%cx\r
-        jmp  PrintStringAndHalt\r
-CheckEm64TPass: \r
-JumpFarInstruction: \r
-        .byte 0xea\r
-JumpOffset: \r
-        .word 0x200\r
-JumpSegment: \r
-        .word 0x2000\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# ReadFile\r
-#\r
-# Arguments:\r
-#   CX    = Start Cluster of File\r
-#   ES:DI = Buffer to store file content read from disk\r
-#\r
-# Return:\r
-#   (ES << 4 + DI) = end of file content Buffer\r
-#\r
-# ****************************************************************************\r
-ReadFile: \r
-# si      = NumberOfClusters\r
-# cx      = ClusterNumber\r
-# dx      = CachedFatSectorNumber\r
-# ds:0000 = CacheFatSectorBuffer\r
-# es:di   = Buffer to load file\r
-# bx      = NextClusterNumber\r
-        pusha\r
-        movw    $1,%si                              # NumberOfClusters = 1\r
-        pushw   %cx                                 # Push Start Cluster onto stack\r
-        movw    $0xfff,%dx                          # CachedFatSectorNumber = 0xfff\r
-FatChainLoop: \r
-        movw    %cx,%ax                             # ax = ClusterNumber    \r
-        andw    $0xfff8,%ax                         # ax = ax & 0xfff8\r
-        cmpw    $0xfff8,%ax                         # See if this is the last cluster\r
-        je      FoundLastCluster                    # Jump if last cluster found\r
-        movw    %cx,%ax                             # ax = ClusterNumber\r
-        shlw    %ax                                 # FatOffset = ClusterNumber * 2\r
-        pushw   %si                                 # Save si\r
-        movw    %ax,%si                             # si = FatOffset\r
-        shrw    $BLOCK_SHIFT, %ax                   # ax = FatOffset >> BLOCK_SHIFT\r
-        addw    ReservedSectors(%bp), %ax           # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        andw    $BLOCK_MASK, %si                    # si = FatOffset & BLOCK_MASK\r
-        cmpw    %dx,%ax                             # Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        movw    $2,%bx\r
-        pushw   %es\r
-        pushw   %ds\r
-        popw    %es\r
-        call    ReadBlocks                          # Read 2 blocks starting at AX storing at ES:DI\r
-        popw    %es\r
-        movw    %ax,%dx                             # CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead: \r
-        movw    (%si), %bx                          # bx = NextClusterNumber\r
-        movw    %cx,%ax                             # ax = ClusterNumber\r
-        popw    %si                                 # Restore si\r
-        decw    %bx                                 # bx = NextClusterNumber - 1\r
-        cmpw    %cx,%bx                             # See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        incw    %bx                                 # bx = NextClusterNumber\r
-        incw    %si                                 # NumberOfClusters++\r
-        movw    %bx,%cx                             # ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters: \r
-        incw    %bx\r
-        popw    %ax                                 # ax = StartCluster\r
-        pushw   %bx                                 # StartCluster = NextClusterNumber\r
-        movw    %bx,%cx                             # ClusterNumber = NextClusterNumber\r
-        subw    $2,%ax                              # ax = StartCluster - 2\r
-        xorb    %bh,%bh\r
-        movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-        mulw    %bx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-        addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        pushw   %ax                                 # save start sector\r
-        movw    %si,%ax                             # ax = NumberOfClusters\r
-        mulw    %bx                                 # ax = NumberOfClusters * SectorsPerCluster\r
-        movw    %ax,%bx                             # bx = Number of Sectors\r
-        popw    %ax                                 # ax = Start Sector\r
-        call    ReadBlocks\r
-        movw    $1,%si                              # NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster: \r
-        popw    %cx\r
-        popa\r
-        ret\r
-\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-        pusha\r
-        addl    LBAOffsetForBootSector(%bp), %eax   # Add LBAOffsetForBootSector to Start LBA\r
-        addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-        movl    %eax,%esi                           # esi = Start LBA\r
-        movw    %bx,%cx                             # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-        movw    $0x7bfc,%bp                         # bp = 0x7bfc\r
-        movl    %esi,%eax                           # eax = Start LBA\r
-        xorl    %edx,%edx                           # edx = 0\r
-        movzwl  (%bp), %ebx                         # bx = MaxSector\r
-        divl    %ebx                                # ax = StartLBA / MaxSector\r
-        incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-\r
-        movw    (%bp), %bx                          # bx = MaxSector\r
-        subw    %dx,%bx                             # bx = MaxSector - Sector\r
-        incw    %bx                                 # bx = MaxSector - Sector + 1\r
-        cmpw    %bx,%cx                             # Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        movw    %cx,%bx                             # bx = Blocks\r
-LimitTransfer: \r
-        pushw   %ax                                 # save ax\r
-        movw    %es,%ax                             # ax = es\r
-        shrw    $(BLOCK_SHIFT-4), %ax               # ax = Number of blocks into mem system\r
-        andw    $0x7f,%ax                           # ax = Number of blocks into current seg\r
-        addw    %bx,%ax                             # ax = End Block number of transfer\r
-        cmpw    $0x80,%ax                           # See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               # Branch if not crossing 64K boundry\r
-        subw    $0x80,%ax                           # ax = Number of blocks past 64K boundry\r
-        subw    %ax,%bx                             # Decrease transfer size by block overage\r
-NotCrossing64KBoundry: \r
-        popw    %ax                                 # restore ax\r
-\r
-        pushw   %cx\r
-        movb    %dl,%cl                             # cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xorw    %dx,%dx                             # dx = 0\r
-        divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    # dx = ax % (MaxHead + 1) = Head\r
-\r
-        pushw   %bx                                 # Save number of blocks to transfer\r
-        movb    %dl,%dh                             # dh = Head\r
-        movw    $0x7c00,%bp                         # bp = 0x7c00\r
-        movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-        movb    %al,%ch                             # ch = Cylinder\r
-        movb    %bl,%al                             # al = Blocks\r
-        movb    $2,%ah                              # ah = Function 2\r
-        movw    %di,%bx                             # es:bx = Buffer address\r
-        int     $0x13\r
-        jc      DiskError\r
-        popw    %bx\r
-        popw    %cx\r
-        movzwl  %bx,%ebx\r
-        addl    %ebx,%esi                           # StartLBA = StartLBA + NumberOfBlocks\r
-        subw    %bx,%cx                             # Blocks = Blocks - NumberOfBlocks\r
-        movw    %es,%ax\r
-        shlw    $(BLOCK_SHIFT-4), %bx\r
-        addw    %bx,%ax\r
-        movw    %ax,%es                             # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmpw    $0,%cx\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError: \r
-        pushw %cs\r
-        popw %ds\r
-        leaw ErrorString,%si\r
-        movw $7,%cx\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt: \r
-        movw $0xb800,%ax\r
-        movw %ax,%es\r
-        movw $160,%di\r
-        rep\r
-        movsw\r
-Halt: \r
-        jmp   Halt\r
-\r
-ErrorString: \r
-        .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!',0x0c\r
-\r
-        .org     0x01fa\r
-LBAOffsetForBootSector: \r
-        .long 0x0\r
-\r
-        .org    0x01fe\r
-        .word 0xaa55\r
-\r
-#******************************************************************************\r
-#******************************************************************************\r
-#******************************************************************************\r
-\r
-.equ                 DELAY_PORT, 0x0ed # Port to use for 1uS delay\r
-.equ                 KBD_CONTROL_PORT, 0x060 # 8042 control port     \r
-.equ                 KBD_STATUS_PORT, 0x064 # 8042 status port      \r
-.equ                 WRITE_DATA_PORT_CMD, 0x0d1 # 8042 command to write the data port\r
-.equ                 ENABLE_A20_CMD, 0x0df # 8042 command to enable A20\r
-\r
-        .org     0x200\r
-        jmp start\r
-Em64String: \r
-.byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
-\r
-start:  \r
-        movw %cs,%ax\r
-        movw %ax,%ds\r
-        movw %ax,%es\r
-        movw %ax,%ss\r
-        movw $MyStack, %sp\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[160],'a'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        movl $0,%ebx\r
-        leal MemoryMap, %edi\r
-MemMapLoop: \r
-        movl $0xe820,%eax\r
-        movl $20,%ecx\r
-        movl $0x534d4150, %edx  # SMAP\r
-        int $0x15\r
-        jc  MemMapDone\r
-        addl $20,%edi\r
-        cmpl $0,%ebx\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone: \r
-        leal MemoryMap, %eax\r
-        subl %eax,%edi                      # Get the address of the memory map\r
-        movl %edi, MemoryMapSize            # Save the size of the memory map\r
-\r
-        xorl    %ebx,%ebx\r
-        movw    %cs,%bx                     # BX=segment\r
-        shll    $4,%ebx                     # BX="linear" address of segment base\r
-        leal    GDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of gdt\r
-        movl    %eax, (gdtr + 2)            # Put address of gdt into the gdtr\r
-        leal    IDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of idt\r
-        movl    %eax, (idtr + 2)            # Put address of idt into the idtr\r
-        leal    MemoryMapSize(%ebx), %edx   # Physical base address of the memory map\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[162],'b'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-#\r
-# Enable A20 Gate \r
-#\r
-\r
-        movw $0x2401,%ax                    # Enable A20 Gate\r
-        int $0x15\r
-        jnc A20GateEnabled                  # Jump if it suceeded\r
-\r
-#\r
-# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-#\r
-\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        movb    $WRITE_DATA_PORT_CMD, %al   # 8042 cmd to write output port\r
-        outb    %al, $KBD_STATUS_PORT       # Send command to the 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        movb    $ENABLE_A20_CMD, %al        # gate address bit 20 on\r
-        outb    %al, $KBD_CONTROL_PORT      # Send command to thre 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        movw    $25,%cx                     # Delay 25 uS for the command to complete on the 8042\r
-Delay25uS: \r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        loop    Delay25uS\r
-Timeout8042: \r
-\r
-\r
-A20GateEnabled: \r
-\r
-#\r
-# DISABLE INTERRUPTS - Entering Protected Mode\r
-#\r
-\r
-        cli\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[164],'c'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-    leal OffsetIn32BitProtectedMode, %eax\r
-    addl $0x20000+0x6,%eax\r
-    movl %eax, OffsetIn32BitProtectedMode \r
-\r
-    leal OffsetInLongMode, %eax\r
-    addl $0x20000+0x6,%eax\r
-    movl %eax, OffsetInLongMode \r
-\r
-    #\r
-    # load GDT\r
-    #\r
-    .byte 0x66\r
-    lgdt    gdtr\r
-\r
-    #\r
-    # Enable Protect Mode (set CR0.PE=1)\r
-    #\r
-    movl  %cr0, %eax      # Read CR0.\r
-    orl   $0x1,%eax       # Set PE=1\r
-    movl  %eax, %cr0      # Write CR0.\r
-    .byte 0x66\r
-    .byte 0xea                        # jmp far 16:32\r
-OffsetIn32BitProtectedMode: \r
-    .long 0x0000000                   # offset $+8   (In32BitProtectedMode)\r
-    .word 0x10                        # selector  (flat CS)\r
-In32BitProtectedMode: \r
-\r
-#\r
-# Entering Long Mode\r
-#\r
-    .byte 0x66\r
-    movw $8,%ax\r
-    movw %ax,%ds\r
-    movw %ax,%es\r
-    movw %ax,%ss\r
-\r
-    #\r
-    # Enable the 64-bit page-translation-table entries by\r
-    # setting CR4.PAE=1 (this is _required_ before activating\r
-    # long mode). Paging is not enabled until after long mode\r
-    # is enabled.\r
-    #\r
-    .byte 0xf\r
-    .byte 0x20\r
-    .byte 0xe0\r
-#    mov eax, cr4\r
-    btsl $5,%eax\r
-    .byte 0xf\r
-    .byte 0x22\r
-    .byte 0xe0\r
-#    mov cr4, eax\r
-\r
-    #\r
-    # This is the Trapolean Page Tables that are guarenteed\r
-    #  under 4GB.\r
-    #\r
-    # Address Map:\r
-    #    10000 ~    12000 - efildr (loaded)\r
-    #    20000 ~    21000 - start64.com\r
-    #    21000 ~    22000 - efi64.com\r
-    #    22000 ~    90000 - efildr\r
-    #    90000 ~    96000 - 4G pagetable (will be reload later)\r
-    #\r
-    .byte 0xb8\r
-    .long 0x90000\r
-#    mov eax, 90000h\r
-    movl %eax, %cr3\r
-\r
-    #\r
-    # Enable long mode (set EFER.LME=1).\r
-    #\r
-    .byte 0xb9\r
-    .long 0xc0000080\r
-#    mov   ecx, 0c0000080h ; EFER MSR number.\r
-    .byte 0xf\r
-    .byte 0x32\r
-#    rdmsr                 ; Read EFER.\r
-    .byte 0xf\r
-    .byte 0xba\r
-    .byte 0xe8\r
-    .byte 0x8\r
-#    bts   eax, 8          ; Set LME=1.\r
-    .byte 0xf\r
-    .byte 0x30\r
-#    wrmsr                 ; Write EFER.\r
-\r
-    #\r
-    # Enable paging to activate long mode (set CR0.PG=1)\r
-    #\r
-    movl  %cr0, %eax      # Read CR0.\r
-    .byte 0xf\r
-    .byte 0xba\r
-    .byte 0xe8\r
-    .byte 0x1f\r
-#    bts   eax, 31         ; Set PG=1.\r
-    movl  %eax, %cr0      # Write CR0.\r
-    jmp   GoToLongMode\r
-GoToLongMode: \r
-\r
-    .byte 0x67\r
-    .byte 0xea                  # Far Jump $+9:Selector to reload CS\r
-OffsetInLongMode: \r
-    .long 00000000              #   $+9 Offset is ensuing instruction boundary\r
-    .word 0x38                  #   Selector is our code selector, 38h\r
-\r
-InLongMode: \r
-    .byte 0x66\r
-    movw    $0x30,%ax\r
-    movw    %ax,%ds\r
-\r
-    .byte 0x66\r
-    movw    $0x18,%ax\r
-    movw    %ax,%es\r
-    movw    %ax,%ss\r
-    movw    %ax,%ds\r
-\r
-    .byte 0xbd\r
-    .long 0x400000\r
-#    mov ebp,000400000h                  ; Destination of EFILDR32\r
-    .byte 0xbb\r
-    .long 0x70000\r
-#    mov ebx,000070000h                  ; Length of copy\r
-\r
-    #\r
-    # load idt later\r
-    #\r
-    .byte 0x48\r
-    .byte 0x33\r
-    .byte 0xc0\r
-#    xor rax, rax\r
-    .byte 0x66\r
-     movw $idtr, %ax\r
-    .byte 0x48\r
-    .byte 0x5\r
-    .long 0x20000\r
-#    add rax, 20000h\r
-\r
-    .byte 0xf\r
-    .byte 0x1\r
-    .byte 0x18\r
-#    lidt    fword ptr [rax]\r
-\r
-    .byte 0x48\r
-    .byte 0xc7\r
-    .byte 0xc0\r
-    .long 0x21000\r
-#   mov rax, 21000h\r
-    .byte 0x50\r
-#   push rax\r
-\r
-# ret\r
-    .byte 0xc3\r
-\r
-Empty8042InputBuffer: \r
-        movw $0,%cx\r
-Empty8042Loop: \r
-        outw    %ax, $DELAY_PORT            # Delay 1us\r
-        inb     $KBD_STATUS_PORT, %al       # Read the 8042 Status Port\r
-        andb    $0x2,%al                    # Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               # Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-##############################################################################\r
-# data\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-        gdtr:    .long  GDT_END - GDT_BASE - 1  # GDT limit \r
-        .long 0                     # (GDT base gets set above)\r
-##############################################################################\r
-#   global descriptor table (GDT)\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-GDT_BASE: \r
-# null descriptor\r
-.equ                NULL_SEL, .-GDT_BASE    # Selector [0x0]\r
-        .word 0         # limit 15:0\r
-        .word 0         # base 15:0\r
-        .byte 0         # base 23:16\r
-        .byte 0         # type\r
-        .byte 0         # limit 19:16, flags\r
-        .byte 0         # base 31:24\r
-\r
-# linear data segment descriptor\r
-.equ            LINEAR_SEL, .-GDT_BASE  # Selector [0x8]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# linear code segment descriptor\r
-.equ            LINEAR_CODE_SEL, .-GDT_BASE # Selector [0x10]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system data segment descriptor\r
-.equ            SYS_DATA_SEL, .-GDT_BASE # Selector [0x18]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system code segment descriptor\r
-.equ            SYS_CODE_SEL, .-GDT_BASE # Selector [0x20]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE3_SEL, .-GDT_BASE  # Selector [0x28]\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-#\r
-# system data segment descriptor\r
-#\r
-.equ              SYS_DATA64_SEL, .-GDT_BASE # Selector [0x30]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # P | DPL [1..2] | 1   | 1   | C | R | A\r
-        .byte 0xCF      # G | D   | L    | AVL | Segment [19..16]\r
-        .byte 0\r
-\r
-#\r
-# system code segment descriptor\r
-#\r
-.equ              SYS_CODE64_SEL, .-GDT_BASE # Selector [0x38]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # P | DPL [1..2] | 1   | 1   | C | R | A\r
-        .byte 0xAF      # G | D   | L    | AVL | Segment [19..16]\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE4_SEL, .-GDT_BASE    # Selector [0x40]\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-GDT_END: \r
-\r
-        .p2align 1\r
-\r
-\r
-\r
-idtr:   .long  IDT_END - IDT_BASE - 1 # IDT limit\r
-        .quad 0                     # (IDT base gets set above)\r
-\r
-##############################################################################\r
-#   interrupt descriptor table (IDT)\r
-#\r
-#   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-#       mappings.  This implementation only uses the system timer and all other\r
-#       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-#       for convenience.\r
-##############################################################################\r
-\r
-#idt_tag db "IDT",0     \r
-        .p2align 1\r
-\r
-\r
-IDT_BASE: \r
-# divide by zero (INT 0)\r
-.equ                DIV_ZERO_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# debug exception (INT 1)\r
-.equ                DEBUG_EXCEPT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# NMI (INT 2)\r
-.equ                NMI_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# soft breakpoint (INT 3)\r
-.equ                BREAKPOINT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# overflow (INT 4)\r
-.equ                OVERFLOW_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# bounds check (INT 5)\r
-.equ                BOUNDS_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# invalid opcode (INT 6)\r
-.equ                INVALID_OPCODE_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# device not available (INT 7)\r
-.equ                DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# double fault (INT 8)\r
-.equ                DOUBLE_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Coprocessor segment overrun - reserved (INT 9)\r
-.equ                RSVD_INTR_SEL1, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# invalid TSS (INT 0ah)\r
-.equ                INVALID_TSS_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# segment not present (INT 0bh)\r
-.equ                SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# stack fault (INT 0ch)\r
-.equ                STACK_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# general protection (INT 0dh)\r
-.equ                GP_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# page fault (INT 0eh)\r
-.equ                PAGE_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Intel reserved - do not use (INT 0fh)\r
-.equ                RSVD_INTR_SEL2, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# floating point error (INT 10h)\r
-.equ                FLT_POINT_ERR_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# alignment check (INT 11h)\r
-.equ                ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# machine check (INT 12h)\r
-.equ                MACHINE_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# SIMD floating-point exception (INT 13h)\r
-.equ                SIMD_EXCEPTION_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        .fill 85 * 16, 1, 0   # db (85 * 16) dup(0)\r
-\r
-# IRQ 0 (System timer) - (INT 68h)\r
-.equ                IRQ0_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-.equ                IRQ1_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-.equ                IRQ2_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 3 (COM 2) - (INT 6bh)\r
-.equ                IRQ3_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 4 (COM 1) - (INT 6ch)\r
-.equ                IRQ4_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 5 (LPT 2) - (INT 6dh)\r
-.equ                IRQ5_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 6 (Floppy controller) - (INT 6eh)\r
-.equ                IRQ6_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 7 (LPT 1) - (INT 6fh)\r
-.equ                IRQ7_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 8 (RTC Alarm) - (INT 70h)\r
-.equ                IRQ8_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 9 - (INT 71h)\r
-.equ                IRQ9_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 10 - (INT 72h)\r
-.equ                 IRQ10_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 11 - (INT 73h)\r
-.equ                 IRQ11_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 12 (PS/2 mouse) - (INT 74h)\r
-.equ                 IRQ12_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 13 (Floating point error) - (INT 75h)\r
-.equ                 IRQ13_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 14 (Secondary IDE) - (INT 76h)\r
-.equ                 IRQ14_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 15 (Primary IDE) - (INT 77h)\r
-.equ                 IRQ15_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-IDT_END: \r
-\r
-        .p2align 1\r
-\r
-MemoryMapSize:  .long 0\r
-MemoryMap:  .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        .org 0x0fe0\r
-MyStack:    \r
-        # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        #    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        #    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        #    8259.c\r
-\r
-        int $8\r
-        iret\r
-\r
-        int $9\r
-        iret\r
-\r
-        int $10\r
-        iret\r
-\r
-        int $11\r
-        iret\r
-\r
-        int $12\r
-        iret\r
-\r
-        int $13\r
-        iret\r
-\r
-        int $14\r
-        iret\r
-\r
-        int $15\r
-        iret\r
-\r
-\r
-        .org 0x0ffe\r
-BlockSignature: \r
-        .word 0xaa55\r
-\r
diff --git a/DuetPkg/BootSector/st16_64.asm b/DuetPkg/BootSector/st16_64.asm
deleted file mode 100644 (file)
index 93a73d4..0000000
+++ /dev/null
@@ -1,1140 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    st16_64.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE    EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT   EQU     5\r
-BLOCK_SIZE                  EQU     0200h\r
-BLOCK_MASK                  EQU     01ffh\r
-BLOCK_SHIFT                 EQU     9\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-PhysicalDrive     db  0             ; PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead       db  0             ; Current Head        - 8 bits\r
-Signature         db  0             ; Signature           - 8 bits  - ignored\r
-VolId             db  "    "        ; Volume Serial Number- 4 bytes\r
-FatLabel          db  "           " ; Label               - 11 bytes\r
-SystemId          db  "FAT16   "    ; SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-      ; ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      ; cx = Start Cluster of EfiLdr\r
-      ; dx = Start Cluster of Efivar.bin\r
-\r
-; Re use the BPB data stored in Boot Sector\r
-        mov     bp,07c00h\r
-\r
-        push    cx\r
-; Read Efivar.bin\r
-;       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        mov     ax,01900h\r
-        mov     es,ax\r
-        test    dx,dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        mov     al,1\r
-NoVarStore:\r
-        push    es\r
-; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        mov     byte ptr es:[4],al\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize:\r
-        mov     di,dx\r
-        cmp     dword ptr ds:[di+2], 04000h\r
-        mov     al,2\r
-        jne     NoVarStore\r
-\r
-LoadVarStore:\r
-        mov     al,0\r
-        mov     byte ptr es:[4],al\r
-        mov     cx,word ptr[di]\r
-;       ES:DI = 1500:0\r
-        xor     di,di\r
-        push    es\r
-        mov     ax,01500h\r
-        mov     es,ax\r
-        call    ReadFile\r
-SaveVolumeId:\r
-        pop     es\r
-        mov     ax,word ptr [bp+VolId]\r
-        mov     word ptr es:[0],ax                  ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        mov     ax,word ptr [bp+VolId+2]\r
-        mov     word ptr es:[2],ax\r
-\r
-; Read Efildr\r
-        pop     cx\r
-;       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-;       ES:DI = 2000:0, first cluster will be read again\r
-        xor     di,di                               ; di = 0\r
-        mov     ax,02000h\r
-        mov     es,ax\r
-        call    ReadFile\r
-        mov     ax,cs\r
-        mov     word ptr cs:[JumpSegment],ax\r
-\r
-CheckEm64T:\r
-        mov  eax, 080000001h\r
-;        cpuid\r
-        dw   0A20Fh\r
-        bt   edx, 29\r
-        jc   CheckEm64TPass\r
-        push cs\r
-        pop  ds\r
-        lea  si, [Em64String]\r
-        mov  cx, 18\r
-        jmp  PrintStringAndHalt\r
-CheckEm64TPass:\r
-JumpFarInstruction:\r
-        db      0eah\r
-JumpOffset:\r
-        dw      0200h\r
-JumpSegment:\r
-        dw      2000h\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; ReadFile\r
-;\r
-; Arguments:\r
-;   CX    = Start Cluster of File\r
-;   ES:DI = Buffer to store file content read from disk\r
-;\r
-; Return:\r
-;   (ES << 4 + DI) = end of file content Buffer\r
-;\r
-; ****************************************************************************\r
-ReadFile:\r
-; si      = NumberOfClusters\r
-; cx      = ClusterNumber\r
-; dx      = CachedFatSectorNumber\r
-; ds:0000 = CacheFatSectorBuffer\r
-; es:di   = Buffer to load file\r
-; bx      = NextClusterNumber\r
-        pusha\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        push    cx                                  ; Push Start Cluster onto stack\r
-        mov     dx,0fffh                            ; CachedFatSectorNumber = 0xfff\r
-FatChainLoop:\r
-        mov     ax,cx                               ; ax = ClusterNumber    \r
-        and     ax,0fff8h                           ; ax = ax & 0xfff8\r
-        cmp     ax,0fff8h                           ; See if this is the last cluster\r
-        je      FoundLastCluster                    ; Jump if last cluster found\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        shl     ax,1                                ; FatOffset = ClusterNumber * 2\r
-        push    si                                  ; Save si\r
-        mov     si,ax                               ; si = FatOffset\r
-        shr     ax,BLOCK_SHIFT                      ; ax = FatOffset >> BLOCK_SHIFT\r
-        add     ax,word ptr [bp+ReservedSectors]    ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        and     si,BLOCK_MASK                       ; si = FatOffset & BLOCK_MASK\r
-        cmp     ax,dx                               ; Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        mov     bx,2                                \r
-        push    es\r
-        push    ds\r
-        pop     es\r
-        call    ReadBlocks                          ; Read 2 blocks starting at AX storing at ES:DI\r
-        pop     es\r
-        mov     dx,ax                               ; CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead:\r
-        mov     bx,word ptr [si]                    ; bx = NextClusterNumber\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        pop     si                                  ; Restore si\r
-        dec     bx                                  ; bx = NextClusterNumber - 1\r
-        cmp     bx,cx                               ; See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        inc     bx                                  ; bx = NextClusterNumber\r
-        inc     si                                  ; NumberOfClusters++\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters:\r
-        inc     bx\r
-        pop     ax                                  ; ax = StartCluster\r
-        push    bx                                  ; StartCluster = NextClusterNumber\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        sub     ax,2                                ; ax = StartCluster - 2\r
-        xor     bh,bh                               \r
-        mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-        mul     bx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-        add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        push    ax                                  ; save start sector\r
-        mov     ax,si                               ; ax = NumberOfClusters\r
-        mul     bx                                  ; ax = NumberOfClusters * SectorsPerCluster\r
-        mov     bx,ax                               ; bx = Number of Sectors\r
-        pop     ax                                  ; ax = Start Sector\r
-        call    ReadBlocks\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster:\r
-        pop     cx\r
-        popa\r
-        ret\r
-\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-        pusha\r
-        add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-        add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-        mov     esi,eax                             ; esi = Start LBA\r
-        mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-        mov     bp,07bfch                           ; bp = 0x7bfc\r
-        mov     eax,esi                             ; eax = Start LBA\r
-        xor     edx,edx                             ; edx = 0\r
-        movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-        div     ebx                                 ; ax = StartLBA / MaxSector\r
-        inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-\r
-        mov     bx,word ptr [bp]                    ; bx = MaxSector\r
-        sub     bx,dx                               ; bx = MaxSector - Sector\r
-        inc     bx                                  ; bx = MaxSector - Sector + 1\r
-        cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-        push    ax                                  ; save ax\r
-        mov     ax,es                               ; ax = es\r
-        shr     ax,(BLOCK_SHIFT-4)                  ; ax = Number of blocks into mem system\r
-        and     ax,07fh                             ; ax = Number of blocks into current seg\r
-        add     ax,bx                               ; ax = End Block number of transfer\r
-        cmp     ax,080h                             ; See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               ; Branch if not crossing 64K boundry\r
-        sub     ax,080h                             ; ax = Number of blocks past 64K boundry\r
-        sub     bx,ax                               ; Decrease transfer size by block overage\r
-NotCrossing64KBoundry:\r
-        pop     ax                                  ; restore ax\r
-\r
-        push    cx\r
-        mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xor     dx,dx                               ; dx = 0\r
-        div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    ; dx = ax % (MaxHead + 1) = Head\r
-\r
-        push    bx                                  ; Save number of blocks to transfer\r
-        mov     dh,dl                               ; dh = Head\r
-        mov     bp,07c00h                           ; bp = 0x7c00\r
-        mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-        mov     ch,al                               ; ch = Cylinder\r
-        mov     al,bl                               ; al = Blocks\r
-        mov     ah,2                                ; ah = Function 2\r
-        mov     bx,di                               ; es:bx = Buffer address\r
-        int     013h\r
-        jc      DiskError\r
-        pop     bx\r
-        pop     cx\r
-        movzx   ebx,bx\r
-        add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-        sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-        mov     ax,es\r
-        shl     bx,(BLOCK_SHIFT-4)\r
-        add     ax,bx\r
-        mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmp     cx,0\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError:\r
-        push cs\r
-        pop  ds\r
-        lea  si, [ErrorString]\r
-        mov  cx, 7\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt:\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  di,160\r
-        rep  movsw\r
-Halt:\r
-        jmp   Halt\r
-\r
-ErrorString:\r
-        db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-        org     01fah\r
-LBAOffsetForBootSector:\r
-        dd      0h\r
-\r
-        org     01feh\r
-        dw      0aa55h\r
-\r
-;******************************************************************************\r
-;******************************************************************************\r
-;******************************************************************************\r
-\r
-DELAY_PORT           equ     0edh    ; Port to use for 1uS delay\r
-KBD_CONTROL_PORT     equ     060h    ; 8042 control port     \r
-KBD_STATUS_PORT      equ     064h    ; 8042 status port      \r
-WRITE_DATA_PORT_CMD  equ     0d1h    ; 8042 command to write the data port\r
-ENABLE_A20_CMD       equ     0dfh    ; 8042 command to enable A20\r
-\r
-        org     200h\r
-        jmp start\r
-Em64String:\r
-        db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch\r
-\r
-start:  \r
-        mov ax,cs\r
-        mov ds,ax\r
-        mov es,ax\r
-        mov ss,ax\r
-        mov sp,MyStack\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[160],'a'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        mov ebx,0\r
-        lea edi,MemoryMap\r
-MemMapLoop:\r
-        mov eax,0e820h\r
-        mov ecx,20\r
-        mov edx,'SMAP'\r
-        int 15h\r
-        jc  MemMapDone\r
-        add edi,20\r
-        cmp ebx,0\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone:\r
-        lea eax,MemoryMap\r
-        sub edi,eax                         ; Get the address of the memory map\r
-        mov dword ptr [MemoryMapSize],edi   ; Save the size of the memory map\r
-\r
-        xor     ebx,ebx\r
-        mov     bx,cs                       ; BX=segment\r
-        shl     ebx,4                       ; BX="linear" address of segment base\r
-        lea     eax,[GDT_BASE + ebx]        ; EAX=PHYSICAL address of gdt\r
-        mov     dword ptr [gdtr + 2],eax    ; Put address of gdt into the gdtr\r
-        lea     eax,[IDT_BASE + ebx]        ; EAX=PHYSICAL address of idt\r
-        mov     dword ptr [idtr + 2],eax    ; Put address of idt into the idtr\r
-        lea     edx,[MemoryMapSize + ebx]   ; Physical base address of the memory map\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[162],'b'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-;\r
-; Enable A20 Gate \r
-;\r
-\r
-        mov ax,2401h                        ; Enable A20 Gate\r
-        int 15h\r
-        jnc A20GateEnabled                  ; Jump if it suceeded\r
-\r
-;\r
-; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-;\r
-\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        mov     al,WRITE_DATA_PORT_CMD      ; 8042 cmd to write output port\r
-        out     KBD_STATUS_PORT,al          ; Send command to the 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        mov     al,ENABLE_A20_CMD           ; gate address bit 20 on\r
-        out     KBD_CONTROL_PORT,al         ; Send command to thre 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        mov     cx,25                       ; Delay 25 uS for the command to complete on the 8042\r
-Delay25uS:\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        loop    Delay25uS                       \r
-Timeout8042:\r
-\r
-\r
-A20GateEnabled:\r
-\r
-;\r
-; DISABLE INTERRUPTS - Entering Protected Mode\r
-;\r
-\r
-        cli                             \r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[164],'c'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-    lea eax, OffsetIn32BitProtectedMode\r
-    add eax, 20000h + 6h\r
-    mov dword ptr[OffsetIn32BitProtectedMode], eax\r
-\r
-    lea eax, OffsetInLongMode\r
-    add eax, 20000h + 6h\r
-    mov dword ptr[OffsetInLongMode], eax\r
-\r
-    ;\r
-    ; load GDT\r
-    ;\r
-    db      66h     \r
-    lgdt    fword ptr [gdtr]\r
-\r
-    ;\r
-    ; Enable Protect Mode (set CR0.PE=1)\r
-    ;\r
-    mov   eax, cr0        ; Read CR0.\r
-    or    eax, 1h         ; Set PE=1\r
-    mov   cr0, eax        ; Write CR0.\r
-    db    066h\r
-    db    0eah                        ; jmp far 16:32\r
-OffsetIn32BitProtectedMode:\r
-    dd    00000000h                   ; offset $+8   (In32BitProtectedMode)\r
-    dw    10h                         ; selector  (flat CS)\r
-In32BitProtectedMode:\r
-\r
-;\r
-; Entering Long Mode\r
-;\r
-    db   66h\r
-    mov  ax, 8\r
-    mov  ds, ax\r
-    mov  es, ax\r
-    mov  ss, ax\r
-\r
-    ;\r
-    ; Enable the 64-bit page-translation-table entries by\r
-    ; setting CR4.PAE=1 (this is _required_ before activating\r
-    ; long mode). Paging is not enabled until after long mode\r
-    ; is enabled.\r
-    ;\r
-    db 0fh\r
-    db 20h\r
-    db 0e0h\r
-;    mov eax, cr4\r
-    bts eax, 5\r
-    db 0fh\r
-    db 22h\r
-    db 0e0h\r
-;    mov cr4, eax\r
-\r
-    ;\r
-    ; This is the Trapolean Page Tables that are guarenteed\r
-    ;  under 4GB.\r
-    ;\r
-    ; Address Map:\r
-    ;    10000 ~    12000 - efildr (loaded)\r
-    ;    20000 ~    21000 - start64.com\r
-    ;    21000 ~    22000 - efi64.com\r
-    ;    22000 ~    90000 - efildr\r
-    ;    90000 ~    96000 - 4G pagetable (will be reload later)\r
-    ;\r
-    db  0b8h\r
-    dd  90000h\r
-;    mov eax, 90000h\r
-    mov cr3, eax\r
-\r
-    ;\r
-    ; Enable long mode (set EFER.LME=1).\r
-    ;\r
-    db  0b9h\r
-    dd  0c0000080h\r
-;    mov   ecx, 0c0000080h ; EFER MSR number.\r
-    db 0fh\r
-    db 32h\r
-;    rdmsr                 ; Read EFER.\r
-    db    0fh\r
-    db    0bah\r
-    db    0e8h\r
-    db    08h\r
-;    bts   eax, 8          ; Set LME=1.\r
-    db 0fh\r
-    db 30h\r
-;    wrmsr                 ; Write EFER.\r
-\r
-    ;\r
-    ; Enable paging to activate long mode (set CR0.PG=1)\r
-    ;\r
-    mov   eax, cr0        ; Read CR0.\r
-    db    0fh\r
-    db    0bah\r
-    db    0e8h\r
-    db    01fh\r
-;    bts   eax, 31         ; Set PG=1.\r
-    mov   cr0, eax        ; Write CR0.\r
-    jmp   GoToLongMode\r
-GoToLongMode:\r
-\r
-    db      067h\r
-    db      0eah                ; Far Jump $+9:Selector to reload CS\r
-OffsetInLongMode:\r
-    dd      00000000            ;   $+9 Offset is ensuing instruction boundary\r
-    dw      038h                ;   Selector is our code selector, 38h\r
-\r
-InLongMode:\r
-    db   66h\r
-    mov     ax, 30h\r
-    mov     ds, ax\r
-\r
-    db   66h\r
-    mov     ax, 18h\r
-    mov     es, ax\r
-    mov     ss, ax\r
-    mov     ds, ax\r
-\r
-    db 0bdh\r
-    dd 400000h\r
-;    mov ebp,000400000h                  ; Destination of EFILDR32\r
-    db 0bbh\r
-    dd 70000h\r
-;    mov ebx,000070000h                  ; Length of copy\r
-\r
-    ;\r
-    ; load idt later\r
-    ;\r
-    db 48h\r
-    db 33h\r
-    db 0c0h\r
-;    xor rax, rax\r
-    db 66h\r
-    mov ax, offset idtr\r
-    db 48h\r
-    db 05h\r
-    dd 20000h\r
-;    add rax, 20000h\r
-\r
-    db 0fh\r
-    db 01h\r
-    db 18h\r
-;    lidt    fword ptr [rax]\r
-\r
-    db 48h\r
-    db 0c7h\r
-    db 0c0h\r
-    dd 21000h\r
-;   mov rax, 21000h\r
-    db 50h\r
-;   push rax\r
-\r
-; ret\r
-    db 0c3h\r
-\r
-Empty8042InputBuffer:\r
-        mov cx,0\r
-Empty8042Loop:\r
-        out     DELAY_PORT,ax               ; Delay 1us\r
-        in      al,KBD_STATUS_PORT          ; Read the 8042 Status Port\r
-        and     al,02h                      ; Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               ; Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; data\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-gdtr    dw GDT_END - GDT_BASE - 1   ; GDT limit\r
-        dd 0                        ; (GDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   global descriptor table (GDT)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-public GDT_BASE\r
-GDT_BASE:\r
-; null descriptor\r
-NULL_SEL            equ $-GDT_BASE          ; Selector [0x0]\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
-\r
-; linear data segment descriptor\r
-LINEAR_SEL      equ $-GDT_BASE          ; Selector [0x8]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; linear code segment descriptor\r
-LINEAR_CODE_SEL equ $-GDT_BASE          ; Selector [0x10]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system data segment descriptor\r
-SYS_DATA_SEL    equ $-GDT_BASE          ; Selector [0x18]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system code segment descriptor\r
-SYS_CODE_SEL    equ $-GDT_BASE          ; Selector [0x20]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE3_SEL  equ $-GDT_BASE          ; Selector [0x28]\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-;\r
-; system data segment descriptor\r
-;\r
-SYS_DATA64_SEL    equ $-GDT_BASE          ; Selector [0x30]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; P | DPL [1..2] | 1   | 1   | C | R | A\r
-        db 0CFh         ; G | D   | L    | AVL | Segment [19..16]\r
-        db 0\r
-\r
-;\r
-; system code segment descriptor\r
-;\r
-SYS_CODE64_SEL    equ $-GDT_BASE          ; Selector [0x38]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; P | DPL [1..2] | 1   | 1   | C | R | A\r
-        db 0AFh         ; G | D   | L    | AVL | Segment [19..16]\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE4_SEL  equ $-GDT_BASE            ; Selector [0x40]\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-GDT_END:\r
-\r
-        align 02h\r
-\r
-\r
-\r
-idtr            dw IDT_END - IDT_BASE - 1   ; IDT limit\r
-        dq 0                        ; (IDT base gets set above)\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   interrupt descriptor table (IDT)\r
-;\r
-;   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-;       mappings.  This implementation only uses the system timer and all other\r
-;       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-;       for convenience.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-;idt_tag db "IDT",0     \r
-        align 02h\r
-\r
-public IDT_BASE\r
-IDT_BASE:\r
-; divide by zero (INT 0)\r
-DIV_ZERO_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; debug exception (INT 1)\r
-DEBUG_EXCEPT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; NMI (INT 2)\r
-NMI_SEL             equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; soft breakpoint (INT 3)\r
-BREAKPOINT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; overflow (INT 4)\r
-OVERFLOW_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; bounds check (INT 5)\r
-BOUNDS_CHECK_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; invalid opcode (INT 6)\r
-INVALID_OPCODE_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; device not available (INT 7)\r
-DEV_NOT_AVAIL_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; double fault (INT 8)\r
-DOUBLE_FAULT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Coprocessor segment overrun - reserved (INT 9)\r
-RSVD_INTR_SEL1      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; invalid TSS (INT 0ah)\r
-INVALID_TSS_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; segment not present (INT 0bh)\r
-SEG_NOT_PRESENT_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; stack fault (INT 0ch)\r
-STACK_FAULT_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; general protection (INT 0dh)\r
-GP_FAULT_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; page fault (INT 0eh)\r
-PAGE_FAULT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Intel reserved - do not use (INT 0fh)\r
-RSVD_INTR_SEL2      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; floating point error (INT 10h)\r
-FLT_POINT_ERR_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; alignment check (INT 11h)\r
-ALIGNMENT_CHECK_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; machine check (INT 12h)\r
-MACHINE_CHECK_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; SIMD floating-point exception (INT 13h)\r
-SIMD_EXCEPTION_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        db (85 * 16) dup(0)\r
-        \r
-; IRQ 0 (System timer) - (INT 68h)\r
-IRQ0_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-IRQ1_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-IRQ2_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 3 (COM 2) - (INT 6bh)\r
-IRQ3_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 4 (COM 1) - (INT 6ch)\r
-IRQ4_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 5 (LPT 2) - (INT 6dh)\r
-IRQ5_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 6 (Floppy controller) - (INT 6eh)\r
-IRQ6_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 7 (LPT 1) - (INT 6fh)\r
-IRQ7_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 8 (RTC Alarm) - (INT 70h)\r
-IRQ8_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 9 - (INT 71h)\r
-IRQ9_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 10 - (INT 72h)\r
-IRQ10_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 11 - (INT 73h)\r
-IRQ11_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 12 (PS/2 mouse) - (INT 74h)\r
-IRQ12_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 13 (Floating point error) - (INT 75h)\r
-IRQ13_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 14 (Secondary IDE) - (INT 76h)\r
-IRQ14_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 15 (Primary IDE) - (INT 77h)\r
-IRQ15_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-IDT_END:\r
-\r
-        align 02h\r
-\r
-MemoryMapSize   dd  0\r
-MemoryMap   dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        org 0fe0h\r
-MyStack:    \r
-        ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        ;    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        ;    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        ;    8259.c\r
-                \r
-        int 8\r
-        iret\r
-        \r
-        int 9\r
-        iret\r
-        \r
-        int 10\r
-        iret\r
-        \r
-        int 11\r
-        iret\r
-        \r
-        int 12\r
-        iret\r
-        \r
-        int 13\r
-        iret\r
-        \r
-        int 14\r
-        iret\r
-        \r
-        int 15\r
-        iret\r
-        \r
-        \r
-        org 0ffeh\r
-BlockSignature:\r
-        dw  0aa55h\r
-\r
-        end \r
diff --git a/DuetPkg/BootSector/st32_64.S b/DuetPkg/BootSector/st32_64.S
deleted file mode 100644 (file)
index 18c53f8..0000000
+++ /dev/null
@@ -1,1157 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    st32_64.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                        FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                        FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                        BLOCK_SIZE, 0x0200\r
-.equ                        BLOCK_MASK, 0x01ff\r
-.equ                        BLOCK_SHIFT, 9\r
-\r
-       .org 0x0\r
-\r
-.global _start\r
-_start:\r
-\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId:               .ascii  "INTEL   "    # OemId                           - 8 bytes\r
-SectorSize:          .word  0              # Sector Size                     - 2 bytes\r
-SectorsPerCluster:   .byte  0              # Sector Per Cluster              - 1 byte\r
-ReservedSectors:     .word  0              # Reserved Sectors                - 2 bytes\r
-NoFats:              .byte  0              # Number of FATs                  - 1 byte\r
-RootEntries:         .word  0              # Root Entries                    - 2 bytes\r
-Sectors:             .word  0              # Number of Sectors               - 2 bytes\r
-Media:               .byte  0              # Media                           - 1 byte\r
-SectorsPerFat16:     .word  0              # Sectors Per FAT for FAT12/FAT16 - 2 byte\r
-SectorsPerTrack:     .word  0              # Sectors Per Track               - 2 bytes\r
-Heads:               .word  0              # Heads                           - 2 bytes\r
-HiddenSectors:       .long  0              # Hidden Sectors                  - 4 bytes\r
-LargeSectors:        .long  0              # Large Sectors                   - 4 bytes\r
-\r
-#******************************************************************************\r
-#\r
-#The structure for FAT32 starting at offset 36 of the boot sector. (At this point, \r
-#the BPB/boot sector for FAT12 and FAT16 differs from the BPB/boot sector for FAT32.)\r
-#\r
-#******************************************************************************\r
-\r
-SectorsPerFat32:     .long  0              # Sectors Per FAT for FAT32       - 4 bytes\r
-ExtFlags:            .word  0              # Mirror Flag                     - 2 bytes\r
-FSVersion:           .word  0              # File System Version             - 2 bytes\r
-RootCluster:         .long  0              # 1st Cluster Number of Root Dir  - 4 bytes\r
-FSInfo:              .word  0              # Sector Number of FSINFO         - 2 bytes\r
-BkBootSector:        .word  0              # Sector Number of Bk BootSector  - 2 bytes\r
-Reserved:            .fill 12,1,0          # Reserved Field                  - 12 bytes\r
-PhysicalDrive:       .byte  0              # Physical Drive Number           - 1 byte\r
-Reserved1:           .byte  0              # Reserved Field                  - 1 byte\r
-Signature:           .byte  0              # Extended Boot Signature         - 1 byte\r
-VolId:               .ascii  "    "        # Volume Serial Number            - 4 bytes\r
-FatLabel:            .ascii  "           " # Volume Label                    - 11 bytes\r
-FileSystemType:      .ascii  "FAT32   "    # File System Type                - 8 bytes\r
-\r
-\r
-BootSectorEntryPoint: \r
-      # ASSUME  ds:@code\r
-      # ASSUME  ss:@code\r
-      # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      # cx = Start Cluster of EfiLdr\r
-      # dx = Start Cluster of Efivar.bin\r
-\r
-# Re use the BPB data stored in Boot Sector\r
-        movw    $0x7c00,%bp\r
-\r
-        pushw   %cx\r
-# Read Efivar.bin\r
-#       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        movw    $0x1900,%ax\r
-        movw    %ax,%es\r
-        testw   %dx,%dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        movb    $1,%al\r
-NoVarStore: \r
-        pushw   %es\r
-# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        movb    %al, %es:(4)\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize: \r
-        movw    %dx,%di\r
-        cmpl    $0x4000, %ds:2(%di)\r
-        movb    $2,%al\r
-        jne     NoVarStore\r
-\r
-LoadVarStore: \r
-        movb    $0,%al\r
-        movb    %al, %es:(4)\r
-        movw    (%di), %cx\r
-#       ES:DI = 1500:0\r
-        xorw    %di,%di\r
-        pushw   %es\r
-        movw    $0x1500,%ax\r
-        movw    %ax,%es\r
-        call    ReadFile\r
-SaveVolumeId: \r
-        popw    %es\r
-        movw    VolId(%bp), %ax\r
-        movw    %ax, %es:(0)                    # Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        movw    VolId+2(%bp), %ax\r
-        movw    %ax, %es:(2)\r
-\r
-# Read Efildr\r
-        popw    %cx\r
-#       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-#       ES:DI = 2000:0, first cluster will be read again\r
-        xorw    %di,%di                             # di = 0\r
-        movw    $0x2000,%ax\r
-        movw    %ax,%es\r
-        call    ReadFile\r
-        movw    %cs,%ax\r
-        movw    %ax, %cs:JumpSegment\r
-\r
-CheckEm64T: \r
-        movl $0x80000001,%eax\r
-#        cpuid\r
-        .word 0xA20F\r
-        btl  $29,%edx\r
-        jc   CheckEm64TPass\r
-        pushw %cs\r
-        popw %ds\r
-        leaw Em64String,%si\r
-        movw $18,%cx\r
-        jmp  PrintStringAndHalt\r
-CheckEm64TPass: \r
-JumpFarInstruction: \r
-        .byte 0xea\r
-JumpOffset: \r
-        .word 0x200\r
-JumpSegment: \r
-        .word 0x2000\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# ReadFile\r
-#\r
-# Arguments:\r
-#   CX    = Start Cluster of File\r
-#   ES:DI = Buffer to store file content read from disk\r
-#\r
-# Return:\r
-#   (ES << 4 + DI) = end of file content Buffer\r
-#\r
-# ****************************************************************************\r
-ReadFile: \r
-# si      = NumberOfClusters\r
-# cx      = ClusterNumber\r
-# dx      = CachedFatSectorNumber\r
-# ds:0000 = CacheFatSectorBuffer\r
-# es:di   = Buffer to load file\r
-# bx      = NextClusterNumber\r
-        pusha\r
-        movw    $1,%si                              # NumberOfClusters = 1\r
-        pushw   %cx                                 # Push Start Cluster onto stack\r
-        movw    $0xfff,%dx                          # CachedFatSectorNumber = 0xfff\r
-FatChainLoop: \r
-        movw    %cx,%ax                             # ax = ClusterNumber    \r
-        andw    $0xfff8,%ax                         # ax = ax & 0xfff8\r
-        cmpw    $0xfff8,%ax                         # See if this is the last cluster\r
-        je      FoundLastCluster                    # Jump if last cluster found\r
-        movw    %cx,%ax                             # ax = ClusterNumber\r
-        shlw    $2, %ax                             # FatOffset = ClusterNumber * 2\r
-        pushw   %si                                 # Save si\r
-        movw    %ax,%si                             # si = FatOffset\r
-        shrw    $BLOCK_SHIFT, %ax                   # ax = FatOffset >> BLOCK_SHIFT\r
-        addw    ReservedSectors(%bp), %ax           # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        andw    $BLOCK_MASK, %si                    # si = FatOffset & BLOCK_MASK\r
-        cmpw    %dx,%ax                             # Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        movw    $2,%bx\r
-        pushw   %es\r
-        pushw   %ds\r
-        popw    %es\r
-        call    ReadBlocks                          # Read 2 blocks starting at AX storing at ES:DI\r
-        popw    %es\r
-        movw    %ax,%dx                             # CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead: \r
-        movw    (%si), %bx                          # bx = NextClusterNumber\r
-        movw    %cx,%ax                             # ax = ClusterNumber\r
-        popw    %si                                 # Restore si\r
-        decw    %bx                                 # bx = NextClusterNumber - 1\r
-        cmpw    %cx,%bx                             # See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        incw    %bx                                 # bx = NextClusterNumber\r
-        incw    %si                                 # NumberOfClusters++\r
-        movw    %bx,%cx                             # ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters: \r
-        incw    %bx\r
-        popw    %ax                                 # ax = StartCluster\r
-        pushw   %bx                                 # StartCluster = NextClusterNumber\r
-        movw    %bx,%cx                             # ClusterNumber = NextClusterNumber\r
-        subw    $2,%ax                              # ax = StartCluster - 2\r
-        xorb    %bh,%bh\r
-        movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-        mulw    %bx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-        addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        pushw   %ax                                 # save start sector\r
-        movw    %si,%ax                             # ax = NumberOfClusters\r
-        mulw    %bx                                 # ax = NumberOfClusters * SectorsPerCluster\r
-        movw    %ax,%bx                             # bx = Number of Sectors\r
-        popw    %ax                                 # ax = Start Sector\r
-        call    ReadBlocks\r
-        movw    $1,%si                              # NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster: \r
-        popw    %cx\r
-        popa\r
-        ret\r
-\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-        pusha\r
-        addl    LBAOffsetForBootSector(%bp), %eax   # Add LBAOffsetForBootSector to Start LBA\r
-        addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-        movl    %eax,%esi                           # esi = Start LBA\r
-        movw    %bx,%cx                             # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-        movw    $0x7bfc,%bp                         # bp = 0x7bfc\r
-        movl    %esi,%eax                           # eax = Start LBA\r
-        xorl    %edx,%edx                           # edx = 0\r
-        movzwl  (%bp), %ebx                         # bx = MaxSector\r
-        divl    %ebx                                # ax = StartLBA / MaxSector\r
-        incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-\r
-        movw    (%bp), %bx                          # bx = MaxSector\r
-        subw    %dx,%bx                             # bx = MaxSector - Sector\r
-        incw    %bx                                 # bx = MaxSector - Sector + 1\r
-        cmpw    %bx,%cx                             # Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        movw    %cx,%bx                             # bx = Blocks\r
-LimitTransfer: \r
-        pushw   %ax                                 # save ax\r
-        movw    %es,%ax                             # ax = es\r
-        shrw    $(BLOCK_SHIFT-4), %ax               # ax = Number of blocks into mem system\r
-        andw    $0x7f,%ax                           # ax = Number of blocks into current seg\r
-        addw    %bx,%ax                             # ax = End Block number of transfer\r
-        cmpw    $0x80,%ax                           # See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               # Branch if not crossing 64K boundry\r
-        subw    $0x80,%ax                           # ax = Number of blocks past 64K boundry\r
-        subw    %ax,%bx                             # Decrease transfer size by block overage\r
-NotCrossing64KBoundry: \r
-        popw    %ax                                 # restore ax\r
-\r
-        pushw   %cx\r
-        movb    %dl,%cl                             # cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xorw    %dx,%dx                             # dx = 0\r
-        divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    # dx = ax % (MaxHead + 1) = Head\r
-\r
-        pushw   %bx                                 # Save number of blocks to transfer\r
-        movb    %dl,%dh                             # dh = Head\r
-        movw    $0x7c00,%bp                         # bp = 0x7c00\r
-        movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-        movb    %al,%ch                             # ch = Cylinder\r
-        movb    %bl,%al                             # al = Blocks\r
-        movb    $2,%ah                              # ah = Function 2\r
-        movw    %di,%bx                             # es:bx = Buffer address\r
-        int     $0x13\r
-        jc      DiskError\r
-        popw    %bx\r
-        popw    %cx\r
-        movzwl  %bx,%ebx\r
-        addl    %ebx,%esi                           # StartLBA = StartLBA + NumberOfBlocks\r
-        subw    %bx,%cx                             # Blocks = Blocks - NumberOfBlocks\r
-        movw    %es,%ax\r
-        shlw    $(BLOCK_SHIFT-4), %bx\r
-        addw    %bx,%ax\r
-        movw    %ax,%es                             # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmpw    $0,%cx\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError: \r
-        pushw %cs\r
-        popw %ds\r
-        leaw ErrorString,%si\r
-        movw $7,%cx\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt: \r
-        movw $0xb800,%ax\r
-        movw %ax,%es\r
-        movw $160,%di\r
-        rep\r
-        movsw\r
-Halt: \r
-        jmp   Halt\r
-\r
-ErrorString: \r
-        .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!',0x0c\r
-\r
-        .org     0x01fa\r
-LBAOffsetForBootSector: \r
-        .long 0x0\r
-\r
-        .org    0x01fe\r
-        .word 0xaa55\r
-\r
-#******************************************************************************\r
-#******************************************************************************\r
-#******************************************************************************\r
-\r
-.equ                 DELAY_PORT, 0x0ed # Port to use for 1uS delay\r
-.equ                 KBD_CONTROL_PORT, 0x060 # 8042 control port     \r
-.equ                 KBD_STATUS_PORT, 0x064 # 8042 status port      \r
-.equ                 WRITE_DATA_PORT_CMD, 0x0d1 # 8042 command to write the data port\r
-.equ                 ENABLE_A20_CMD, 0x0df # 8042 command to enable A20\r
-\r
-        .org     0x200\r
-        jmp start\r
-Em64String: \r
-.byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
-\r
-start:  \r
-        movw %cs,%ax\r
-        movw %ax,%ds\r
-        movw %ax,%es\r
-        movw %ax,%ss\r
-        movw $MyStack, %sp\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[160],'a'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        movl $0,%ebx\r
-        leal MemoryMap, %edi\r
-MemMapLoop: \r
-        movl $0xe820,%eax\r
-        movl $20,%ecx\r
-        movl $0x534d4150, %edx  # SMAP\r
-        int $0x15\r
-        jc  MemMapDone\r
-        addl $20,%edi\r
-        cmpl $0,%ebx\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone: \r
-        leal MemoryMap, %eax\r
-        subl %eax,%edi                      # Get the address of the memory map\r
-        movl %edi, MemoryMapSize            # Save the size of the memory map\r
-\r
-        xorl    %ebx,%ebx\r
-        movw    %cs,%bx                     # BX=segment\r
-        shll    $4,%ebx                     # BX="linear" address of segment base\r
-        leal    GDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of gdt\r
-        movl    %eax, (gdtr + 2)            # Put address of gdt into the gdtr\r
-        leal    IDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of idt\r
-        movl    %eax, (idtr + 2)            # Put address of idt into the idtr\r
-        leal    MemoryMapSize(%ebx), %edx   # Physical base address of the memory map\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[162],'b'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-#\r
-# Enable A20 Gate \r
-#\r
-\r
-        movw $0x2401,%ax                    # Enable A20 Gate\r
-        int $0x15\r
-        jnc A20GateEnabled                  # Jump if it suceeded\r
-\r
-#\r
-# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-#\r
-\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        movb    $WRITE_DATA_PORT_CMD, %al   # 8042 cmd to write output port\r
-        outb    %al, $KBD_STATUS_PORT       # Send command to the 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        movb    $ENABLE_A20_CMD, %al        # gate address bit 20 on\r
-        outb    %al, $KBD_CONTROL_PORT      # Send command to thre 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        movw    $25,%cx                     # Delay 25 uS for the command to complete on the 8042\r
-Delay25uS: \r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        loop    Delay25uS\r
-Timeout8042: \r
-\r
-\r
-A20GateEnabled: \r
-\r
-#\r
-# DISABLE INTERRUPTS - Entering Protected Mode\r
-#\r
-\r
-        cli\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[164],'c'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-    leal OffsetIn32BitProtectedMode, %eax\r
-    addl $0x20000+0x6,%eax\r
-    movl %eax, OffsetIn32BitProtectedMode \r
-\r
-    leal OffsetInLongMode, %eax\r
-    addl $0x20000+0x6,%eax\r
-    movl %eax, OffsetInLongMode \r
-\r
-    #\r
-    # load GDT\r
-    #\r
-    .byte 0x66\r
-    lgdt    gdtr\r
-\r
-    #\r
-    # Enable Protect Mode (set CR0.PE=1)\r
-    #\r
-    movl  %cr0, %eax      # Read CR0.\r
-    orl   $0x1,%eax       # Set PE=1\r
-    movl  %eax, %cr0      # Write CR0.\r
-    .byte 0x66\r
-    .byte 0xea                        # jmp far 16:32\r
-OffsetIn32BitProtectedMode: \r
-    .long 0x0000000                   # offset $+8   (In32BitProtectedMode)\r
-    .word 0x10                        # selector  (flat CS)\r
-In32BitProtectedMode: \r
-\r
-#\r
-# Entering Long Mode\r
-#\r
-    .byte 0x66\r
-    movw $8,%ax\r
-    movw %ax,%ds\r
-    movw %ax,%es\r
-    movw %ax,%ss\r
-\r
-    #\r
-    # Enable the 64-bit page-translation-table entries by\r
-    # setting CR4.PAE=1 (this is _required_ before activating\r
-    # long mode). Paging is not enabled until after long mode\r
-    # is enabled.\r
-    #\r
-    .byte 0xf\r
-    .byte 0x20\r
-    .byte 0xe0\r
-#    mov eax, cr4\r
-    btsl $5,%eax\r
-    .byte 0xf\r
-    .byte 0x22\r
-    .byte 0xe0\r
-#    mov cr4, eax\r
-\r
-    #\r
-    # This is the Trapolean Page Tables that are guarenteed\r
-    #  under 4GB.\r
-    #\r
-    # Address Map:\r
-    #    10000 ~    12000 - efildr (loaded)\r
-    #    20000 ~    21000 - start64.com\r
-    #    21000 ~    22000 - efi64.com\r
-    #    22000 ~    90000 - efildr\r
-    #    90000 ~    96000 - 4G pagetable (will be reload later)\r
-    #\r
-    .byte 0xb8\r
-    .long 0x90000\r
-#    mov eax, 90000h\r
-    movl %eax, %cr3\r
-\r
-    #\r
-    # Enable long mode (set EFER.LME=1).\r
-    #\r
-    .byte 0xb9\r
-    .long 0xc0000080\r
-#    mov   ecx, 0c0000080h ; EFER MSR number.\r
-    .byte 0xf\r
-    .byte 0x32\r
-#    rdmsr                 ; Read EFER.\r
-    .byte 0xf\r
-    .byte 0xba\r
-    .byte 0xe8\r
-    .byte 0x8\r
-#    bts   eax, 8          ; Set LME=1.\r
-    .byte 0xf\r
-    .byte 0x30\r
-#    wrmsr                 ; Write EFER.\r
-\r
-    #\r
-    # Enable paging to activate long mode (set CR0.PG=1)\r
-    #\r
-    movl  %cr0, %eax      # Read CR0.\r
-    .byte 0xf\r
-    .byte 0xba\r
-    .byte 0xe8\r
-    .byte 0x1f\r
-#    bts   eax, 31         ; Set PG=1.\r
-    movl  %eax, %cr0      # Write CR0.\r
-    jmp   GoToLongMode\r
-GoToLongMode: \r
-\r
-    .byte 0x67\r
-    .byte 0xea                  # Far Jump $+9:Selector to reload CS\r
-OffsetInLongMode: \r
-    .long 00000000              #   $+9 Offset is ensuing instruction boundary\r
-    .word 0x38                  #   Selector is our code selector, 38h\r
-\r
-InLongMode: \r
-    .byte 0x66\r
-    movw    $0x30,%ax\r
-    movw    %ax,%ds\r
-\r
-    .byte 0x66\r
-    movw    $0x18,%ax\r
-    movw    %ax,%es\r
-    movw    %ax,%ss\r
-    movw    %ax,%ds\r
-\r
-    .byte 0xbd\r
-    .long 0x400000\r
-#    mov ebp,000400000h                  ; Destination of EFILDR32\r
-    .byte 0xbb\r
-    .long 0x70000\r
-#    mov ebx,000070000h                  ; Length of copy\r
-\r
-    #\r
-    # load idt later\r
-    #\r
-    .byte 0x48\r
-    .byte 0x33\r
-    .byte 0xc0\r
-#    xor rax, rax\r
-    .byte 0x66\r
-     movw $idtr, %ax\r
-    .byte 0x48\r
-    .byte 0x5\r
-    .long 0x20000\r
-#    add rax, 20000h\r
-\r
-    .byte 0xf\r
-    .byte 0x1\r
-    .byte 0x18\r
-#    lidt    fword ptr [rax]\r
-\r
-    .byte 0x48\r
-    .byte 0xc7\r
-    .byte 0xc0\r
-    .long 0x21000\r
-#   mov rax, 21000h\r
-    .byte 0x50\r
-#   push rax\r
-\r
-# ret\r
-    .byte 0xc3\r
-\r
-Empty8042InputBuffer: \r
-        movw $0,%cx\r
-Empty8042Loop: \r
-        outw    %ax, $DELAY_PORT            # Delay 1us\r
-        inb     $KBD_STATUS_PORT, %al       # Read the 8042 Status Port\r
-        andb    $0x2,%al                    # Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               # Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-##############################################################################\r
-# data\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-        gdtr:    .word  GDT_END - GDT_BASE - 1  # GDT limit \r
-        .long 0                     # (GDT base gets set above)\r
-##############################################################################\r
-#   global descriptor table (GDT)\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-GDT_BASE: \r
-# null descriptor\r
-.equ                NULL_SEL, .-GDT_BASE    # Selector [0x0]\r
-        .word 0         # limit 15:0\r
-        .word 0         # base 15:0\r
-        .byte 0         # base 23:16\r
-        .byte 0         # type\r
-        .byte 0         # limit 19:16, flags\r
-        .byte 0         # base 31:24\r
-\r
-# linear data segment descriptor\r
-.equ            LINEAR_SEL, .-GDT_BASE  # Selector [0x8]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# linear code segment descriptor\r
-.equ            LINEAR_CODE_SEL, .-GDT_BASE # Selector [0x10]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system data segment descriptor\r
-.equ            SYS_DATA_SEL, .-GDT_BASE # Selector [0x18]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system code segment descriptor\r
-.equ            SYS_CODE_SEL, .-GDT_BASE # Selector [0x20]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE3_SEL, .-GDT_BASE  # Selector [0x28]\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-#\r
-# system data segment descriptor\r
-#\r
-.equ              SYS_DATA64_SEL, .-GDT_BASE # Selector [0x30]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # P | DPL [1..2] | 1   | 1   | C | R | A\r
-        .byte 0xCF      # G | D   | L    | AVL | Segment [19..16]\r
-        .byte 0\r
-\r
-#\r
-# system code segment descriptor\r
-#\r
-.equ              SYS_CODE64_SEL, .-GDT_BASE # Selector [0x38]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # P | DPL [1..2] | 1   | 1   | C | R | A\r
-        .byte 0xAF      # G | D   | L    | AVL | Segment [19..16]\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE4_SEL, .-GDT_BASE    # Selector [0x40]\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-GDT_END: \r
-\r
-        .p2align 1\r
-\r
-\r
-\r
-idtr:   .long  IDT_END - IDT_BASE - 1 # IDT limit\r
-        .quad 0                     # (IDT base gets set above)\r
-\r
-##############################################################################\r
-#   interrupt descriptor table (IDT)\r
-#\r
-#   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-#       mappings.  This implementation only uses the system timer and all other\r
-#       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-#       for convenience.\r
-##############################################################################\r
-\r
-#idt_tag db "IDT",0     \r
-        .p2align 1\r
-\r
-\r
-IDT_BASE: \r
-# divide by zero (INT 0)\r
-.equ                DIV_ZERO_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# debug exception (INT 1)\r
-.equ                DEBUG_EXCEPT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# NMI (INT 2)\r
-.equ                NMI_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# soft breakpoint (INT 3)\r
-.equ                BREAKPOINT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# overflow (INT 4)\r
-.equ                OVERFLOW_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# bounds check (INT 5)\r
-.equ                BOUNDS_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# invalid opcode (INT 6)\r
-.equ                INVALID_OPCODE_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# device not available (INT 7)\r
-.equ                DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# double fault (INT 8)\r
-.equ                DOUBLE_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Coprocessor segment overrun - reserved (INT 9)\r
-.equ                RSVD_INTR_SEL1, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# invalid TSS (INT 0ah)\r
-.equ                INVALID_TSS_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# segment not present (INT 0bh)\r
-.equ                SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# stack fault (INT 0ch)\r
-.equ                STACK_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# general protection (INT 0dh)\r
-.equ                GP_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# page fault (INT 0eh)\r
-.equ                PAGE_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Intel reserved - do not use (INT 0fh)\r
-.equ                RSVD_INTR_SEL2, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# floating point error (INT 10h)\r
-.equ                FLT_POINT_ERR_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# alignment check (INT 11h)\r
-.equ                ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# machine check (INT 12h)\r
-.equ                MACHINE_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# SIMD floating-point exception (INT 13h)\r
-.equ                SIMD_EXCEPTION_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        .fill 85 * 16, 1, 0   # db (85 * 16) dup(0)\r
-\r
-# IRQ 0 (System timer) - (INT 68h)\r
-.equ                IRQ0_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-.equ                IRQ1_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-.equ                IRQ2_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 3 (COM 2) - (INT 6bh)\r
-.equ                IRQ3_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 4 (COM 1) - (INT 6ch)\r
-.equ                IRQ4_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 5 (LPT 2) - (INT 6dh)\r
-.equ                IRQ5_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 6 (Floppy controller) - (INT 6eh)\r
-.equ                IRQ6_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 7 (LPT 1) - (INT 6fh)\r
-.equ                IRQ7_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 8 (RTC Alarm) - (INT 70h)\r
-.equ                IRQ8_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 9 - (INT 71h)\r
-.equ                IRQ9_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 10 - (INT 72h)\r
-.equ                 IRQ10_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 11 - (INT 73h)\r
-.equ                 IRQ11_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 12 (PS/2 mouse) - (INT 74h)\r
-.equ                 IRQ12_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 13 (Floating point error) - (INT 75h)\r
-.equ                 IRQ13_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 14 (Secondary IDE) - (INT 76h)\r
-.equ                 IRQ14_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 15 (Primary IDE) - (INT 77h)\r
-.equ                 IRQ15_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-IDT_END: \r
-\r
-        .p2align 1\r
-\r
-MemoryMapSize:  .long 0\r
-MemoryMap:  .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        .org 0x0fe0\r
-MyStack:    \r
-        # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        #    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        #    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        #    8259.c\r
-\r
-        int $8\r
-        iret\r
-\r
-        int $9\r
-        iret\r
-\r
-        int $10\r
-        iret\r
-\r
-        int $11\r
-        iret\r
-\r
-        int $12\r
-        iret\r
-\r
-        int $13\r
-        iret\r
-\r
-        int $14\r
-        iret\r
-\r
-        int $15\r
-        iret\r
-\r
-\r
-        .org 0x0ffe\r
-BlockSignature: \r
-        .word 0xaa55\r
-\r
diff --git a/DuetPkg/BootSector/st32_64.asm b/DuetPkg/BootSector/st32_64.asm
deleted file mode 100644 (file)
index 9761dc8..0000000
+++ /dev/null
@@ -1,1156 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    st32_64.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE    EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT   EQU     5\r
-BLOCK_SIZE                  EQU     0200h\r
-BLOCK_MASK                  EQU     01ffh\r
-BLOCK_SHIFT                 EQU     9\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId               db  "INTEL   "    ; OemId                           - 8 bytes\r
-SectorSize          dw  0             ; Sector Size                     - 2 bytes\r
-SectorsPerCluster   db  0             ; Sector Per Cluster              - 1 byte\r
-ReservedSectors     dw  0             ; Reserved Sectors                - 2 bytes\r
-NoFats              db  0             ; Number of FATs                  - 1 byte\r
-RootEntries         dw  0             ; Root Entries                    - 2 bytes\r
-Sectors             dw  0             ; Number of Sectors               - 2 bytes\r
-Media               db  0             ; Media                           - 1 byte\r
-SectorsPerFat16     dw  0             ; Sectors Per FAT for FAT12/FAT16 - 2 byte\r
-SectorsPerTrack     dw  0             ; Sectors Per Track               - 2 bytes\r
-Heads               dw  0             ; Heads                           - 2 bytes\r
-HiddenSectors       dd  0             ; Hidden Sectors                  - 4 bytes\r
-LargeSectors        dd  0             ; Large Sectors                   - 4 bytes\r
-\r
-;******************************************************************************\r
-;\r
-;The structure for FAT32 starting at offset 36 of the boot sector. (At this point, \r
-;the BPB/boot sector for FAT12 and FAT16 differs from the BPB/boot sector for FAT32.)\r
-;\r
-;******************************************************************************\r
-\r
-SectorsPerFat32     dd  0             ; Sectors Per FAT for FAT32       - 4 bytes\r
-ExtFlags            dw  0             ; Mirror Flag                     - 2 bytes\r
-FSVersion           dw  0             ; File System Version             - 2 bytes\r
-RootCluster         dd  0             ; 1st Cluster Number of Root Dir  - 4 bytes\r
-FSInfo              dw  0             ; Sector Number of FSINFO         - 2 bytes\r
-BkBootSector        dw  0             ; Sector Number of Bk BootSector  - 2 bytes\r
-Reserved            db  12 dup(0)     ; Reserved Field                  - 12 bytes\r
-PhysicalDrive       db  0             ; Physical Drive Number           - 1 byte\r
-Reserved1           db  0             ; Reserved Field                  - 1 byte\r
-Signature           db  0             ; Extended Boot Signature         - 1 byte\r
-VolId               db  "    "        ; Volume Serial Number            - 4 bytes\r
-FatLabel            db  "           " ; Volume Label                    - 11 bytes\r
-FileSystemType      db  "FAT32   "    ; File System Type                - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-      ; ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      ; cx = Start Cluster of EfiLdr\r
-      ; dx = Start Cluster of Efivar.bin\r
-\r
-; Re use the BPB data stored in Boot Sector\r
-        mov     bp,07c00h\r
-\r
-\r
-        push    cx\r
-; Read Efivar.bin\r
-;       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        mov     ax,01900h\r
-        mov     es,ax\r
-        test    dx,dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        mov     al,1\r
-NoVarStore:\r
-        push    es\r
-; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        mov     byte ptr es:[4],al\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize:\r
-        mov     di,dx\r
-        cmp     dword ptr ds:[di+2], 04000h\r
-        mov     al,2\r
-        jne     NoVarStore\r
-\r
-LoadVarStore:\r
-        mov     al,0\r
-        mov     byte ptr es:[4],al\r
-        mov     cx,word ptr[di]\r
-;       ES:DI = 1500:0\r
-        xor     di,di\r
-        push    es\r
-        mov     ax,01500h\r
-        mov     es,ax\r
-        call    ReadFile\r
-SaveVolumeId:\r
-        pop     es\r
-        mov     ax,word ptr [bp+VolId]\r
-        mov     word ptr es:[0],ax                  ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        mov     ax,word ptr [bp+VolId+2]\r
-        mov     word ptr es:[2],ax\r
-\r
-; Read Efildr\r
-        pop     cx\r
-;       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-;       ES:DI = 2000:0, first cluster will be read again\r
-        xor     di,di                               ; di = 0\r
-        mov     ax,02000h\r
-        mov     es,ax\r
-        call    ReadFile\r
-        mov     ax,cs\r
-        mov     word ptr cs:[JumpSegment],ax\r
-\r
-CheckEm64T:\r
-        mov  eax, 080000001h\r
-;        cpuid\r
-        dw   0A20Fh\r
-        bt   edx, 29\r
-        jc   CheckEm64TPass\r
-        push cs\r
-        pop  ds\r
-        lea  si, [Em64String]\r
-        mov  cx, 18\r
-        jmp  PrintStringAndHalt\r
-CheckEm64TPass:\r
-JumpFarInstruction:\r
-        db      0eah\r
-JumpOffset:\r
-        dw      0200h\r
-JumpSegment:\r
-        dw      2000h\r
-\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; ReadFile\r
-;\r
-; Arguments:\r
-;   CX    = Start Cluster of File\r
-;   ES:DI = Buffer to store file content read from disk\r
-;\r
-; Return:\r
-;   (ES << 4 + DI) = end of file content Buffer\r
-;\r
-; ****************************************************************************\r
-ReadFile:\r
-; si      = NumberOfClusters\r
-; cx      = ClusterNumber\r
-; dx      = CachedFatSectorNumber\r
-; ds:0000 = CacheFatSectorBuffer\r
-; es:di   = Buffer to load file\r
-; bx      = NextClusterNumber\r
-        pusha\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        push    cx                                  ; Push Start Cluster onto stack\r
-        mov     dx,0fffh                            ; CachedFatSectorNumber = 0xfff\r
-FatChainLoop:\r
-        mov     ax,cx                               ; ax = ClusterNumber    \r
-        and     ax,0fff8h                           ; ax = ax & 0xfff8\r
-        cmp     ax,0fff8h                           ; See if this is the last cluster\r
-        je      FoundLastCluster                    ; Jump if last cluster found\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        shl     ax,2                                ; FatOffset = ClusterNumber * 4\r
-        push    si                                  ; Save si\r
-        mov     si,ax                               ; si = FatOffset\r
-        shr     ax,BLOCK_SHIFT                      ; ax = FatOffset >> BLOCK_SHIFT\r
-        add     ax,word ptr [bp+ReservedSectors]    ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        and     si,BLOCK_MASK                       ; si = FatOffset & BLOCK_MASK\r
-        cmp     ax,dx                               ; Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        mov     bx,2                                \r
-        push    es\r
-        push    ds\r
-        pop     es\r
-        call    ReadBlocks                          ; Read 2 blocks starting at AX storing at ES:DI\r
-        pop     es\r
-        mov     dx,ax                               ; CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead:\r
-        mov     bx,word ptr [si]                    ; bx = NextClusterNumber\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        pop     si                                  ; Restore si\r
-        dec     bx                                  ; bx = NextClusterNumber - 1\r
-        cmp     bx,cx                               ; See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        inc     bx                                  ; bx = NextClusterNumber\r
-        inc     si                                  ; NumberOfClusters++\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters:\r
-        inc     bx\r
-        pop     ax                                  ; ax = StartCluster\r
-        push    bx                                  ; StartCluster = NextClusterNumber\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        sub     ax,2                                ; ax = StartCluster - 2\r
-        xor     bh,bh                               \r
-        mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-        mul     bx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-        add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        push    ax                                  ; save start sector\r
-        mov     ax,si                               ; ax = NumberOfClusters\r
-        mul     bx                                  ; ax = NumberOfClusters * SectorsPerCluster\r
-        mov     bx,ax                               ; bx = Number of Sectors\r
-        pop     ax                                  ; ax = Start Sector\r
-        call    ReadBlocks\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster:\r
-        pop     cx\r
-        popa\r
-        ret\r
-\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-        pusha\r
-        add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-        add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-        mov     esi,eax                             ; esi = Start LBA\r
-        mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-        mov     bp,07bfch                           ; bp = 0x7bfc\r
-        mov     eax,esi                             ; eax = Start LBA\r
-        xor     edx,edx                             ; edx = 0\r
-        movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-        div     ebx                                 ; ax = StartLBA / MaxSector\r
-        inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-\r
-        mov     bx,word ptr [bp]                    ; bx = MaxSector\r
-        sub     bx,dx                               ; bx = MaxSector - Sector\r
-        inc     bx                                  ; bx = MaxSector - Sector + 1\r
-        cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-        push    ax                                  ; save ax\r
-        mov     ax,es                               ; ax = es\r
-        shr     ax,(BLOCK_SHIFT-4)                  ; ax = Number of blocks into mem system\r
-        and     ax,07fh                             ; ax = Number of blocks into current seg\r
-        add     ax,bx                               ; ax = End Block number of transfer\r
-        cmp     ax,080h                             ; See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               ; Branch if not crossing 64K boundry\r
-        sub     ax,080h                             ; ax = Number of blocks past 64K boundry\r
-        sub     bx,ax                               ; Decrease transfer size by block overage\r
-NotCrossing64KBoundry:\r
-        pop     ax                                  ; restore ax\r
-\r
-        push    cx\r
-        mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xor     dx,dx                               ; dx = 0\r
-        div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    ; dx = ax % (MaxHead + 1) = Head\r
-\r
-        push    bx                                  ; Save number of blocks to transfer\r
-        mov     dh,dl                               ; dh = Head\r
-        mov     bp,07c00h                           ; bp = 0x7c00\r
-        mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-        mov     ch,al                               ; ch = Cylinder\r
-        mov     al,bl                               ; al = Blocks\r
-        mov     ah,2                                ; ah = Function 2\r
-        mov     bx,di                               ; es:bx = Buffer address\r
-        int     013h\r
-        jc      DiskError\r
-        pop     bx\r
-        pop     cx\r
-        movzx   ebx,bx\r
-        add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-        sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-        mov     ax,es\r
-        shl     bx,(BLOCK_SHIFT-4)\r
-        add     ax,bx\r
-        mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmp     cx,0\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError:\r
-        push cs\r
-        pop  ds\r
-        lea  si, [ErrorString]\r
-        mov  cx, 7\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt:\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  di,160\r
-        rep  movsw\r
-Halt:\r
-        jmp   Halt\r
-\r
-ErrorString:\r
-        db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-        org     01fah\r
-LBAOffsetForBootSector:\r
-        dd      0h\r
-\r
-        org     01feh\r
-        dw      0aa55h\r
-\r
-;******************************************************************************\r
-;******************************************************************************\r
-;******************************************************************************\r
-\r
-DELAY_PORT           equ     0edh    ; Port to use for 1uS delay\r
-KBD_CONTROL_PORT     equ     060h    ; 8042 control port     \r
-KBD_STATUS_PORT      equ     064h    ; 8042 status port      \r
-WRITE_DATA_PORT_CMD  equ     0d1h    ; 8042 command to write the data port\r
-ENABLE_A20_CMD       equ     0dfh    ; 8042 command to enable A20\r
-\r
-        org     200h\r
-        jmp start\r
-Em64String:\r
-        db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch\r
-\r
-start:  \r
-        mov ax,cs\r
-        mov ds,ax\r
-        mov es,ax\r
-        mov ss,ax\r
-        mov sp,MyStack\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[160],'a'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        mov ebx,0\r
-        lea edi,MemoryMap\r
-MemMapLoop:\r
-        mov eax,0e820h\r
-        mov ecx,20\r
-        mov edx,'SMAP'\r
-        int 15h\r
-        jc  MemMapDone\r
-        add edi,20\r
-        cmp ebx,0\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone:\r
-        lea eax,MemoryMap\r
-        sub edi,eax                         ; Get the address of the memory map\r
-        mov dword ptr [MemoryMapSize],edi   ; Save the size of the memory map\r
-\r
-        xor     ebx,ebx\r
-        mov     bx,cs                       ; BX=segment\r
-        shl     ebx,4                       ; BX="linear" address of segment base\r
-        lea     eax,[GDT_BASE + ebx]        ; EAX=PHYSICAL address of gdt\r
-        mov     dword ptr [gdtr + 2],eax    ; Put address of gdt into the gdtr\r
-        lea     eax,[IDT_BASE + ebx]        ; EAX=PHYSICAL address of idt\r
-        mov     dword ptr [idtr + 2],eax    ; Put address of idt into the idtr\r
-        lea     edx,[MemoryMapSize + ebx]   ; Physical base address of the memory map\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[162],'b'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-;\r
-; Enable A20 Gate \r
-;\r
-\r
-        mov ax,2401h                        ; Enable A20 Gate\r
-        int 15h\r
-        jnc A20GateEnabled                  ; Jump if it suceeded\r
-\r
-;\r
-; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-;\r
-\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        mov     al,WRITE_DATA_PORT_CMD      ; 8042 cmd to write output port\r
-        out     KBD_STATUS_PORT,al          ; Send command to the 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        mov     al,ENABLE_A20_CMD           ; gate address bit 20 on\r
-        out     KBD_CONTROL_PORT,al         ; Send command to thre 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        mov     cx,25                       ; Delay 25 uS for the command to complete on the 8042\r
-Delay25uS:\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        loop    Delay25uS                       \r
-Timeout8042:\r
-\r
-\r
-A20GateEnabled:\r
-\r
-;\r
-; DISABLE INTERRUPTS - Entering Protected Mode\r
-;\r
-\r
-        cli                             \r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[164],'c'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-    lea eax, OffsetIn32BitProtectedMode\r
-    add eax, 20000h + 6h\r
-    mov dword ptr[OffsetIn32BitProtectedMode], eax\r
-\r
-    lea eax, OffsetInLongMode\r
-    add eax, 20000h + 6h\r
-    mov dword ptr[OffsetInLongMode], eax\r
-\r
-    ;\r
-    ; load GDT\r
-    ;\r
-    db      66h     \r
-    lgdt    fword ptr [gdtr]\r
-\r
-    ;\r
-    ; Enable Protect Mode (set CR0.PE=1)\r
-    ;\r
-    mov   eax, cr0        ; Read CR0.\r
-    or    eax, 1h         ; Set PE=1\r
-    mov   cr0, eax        ; Write CR0.\r
-    db    066h\r
-    db    0eah                        ; jmp far 16:32\r
-OffsetIn32BitProtectedMode:\r
-    dd    00000000h                   ; offset $+8   (In32BitProtectedMode)\r
-    dw    10h                         ; selector  (flat CS)\r
-In32BitProtectedMode:\r
-\r
-;\r
-; Entering Long Mode\r
-;\r
-    db   66h\r
-    mov  ax, 8\r
-    mov  ds, ax\r
-    mov  es, ax\r
-    mov  ss, ax\r
-\r
-    ;\r
-    ; Enable the 64-bit page-translation-table entries by\r
-    ; setting CR4.PAE=1 (this is _required_ before activating\r
-    ; long mode). Paging is not enabled until after long mode\r
-    ; is enabled.\r
-    ;\r
-    db 0fh\r
-    db 20h\r
-    db 0e0h\r
-;    mov eax, cr4\r
-    bts eax, 5\r
-    db 0fh\r
-    db 22h\r
-    db 0e0h\r
-;    mov cr4, eax\r
-\r
-    ;\r
-    ; This is the Trapolean Page Tables that are guarenteed\r
-    ;  under 4GB.\r
-    ;\r
-    ; Address Map:\r
-    ;    10000 ~    12000 - efildr (loaded)\r
-    ;    20000 ~    21000 - start64.com\r
-    ;    21000 ~    22000 - efi64.com\r
-    ;    22000 ~    90000 - efildr\r
-    ;    90000 ~    96000 - 4G pagetable (will be reload later)\r
-    ;\r
-    db  0b8h\r
-    dd  90000h\r
-;    mov eax, 90000h\r
-    mov cr3, eax\r
-\r
-    ;\r
-    ; Enable long mode (set EFER.LME=1).\r
-    ;\r
-    db  0b9h\r
-    dd  0c0000080h\r
-;    mov   ecx, 0c0000080h ; EFER MSR number.\r
-    db 0fh\r
-    db 32h\r
-;    rdmsr                 ; Read EFER.\r
-    db    0fh\r
-    db    0bah\r
-    db    0e8h\r
-    db    08h\r
-;    bts   eax, 8          ; Set LME=1.\r
-    db 0fh\r
-    db 30h\r
-;    wrmsr                 ; Write EFER.\r
-\r
-    ;\r
-    ; Enable paging to activate long mode (set CR0.PG=1)\r
-    ;\r
-    mov   eax, cr0        ; Read CR0.\r
-    db    0fh\r
-    db    0bah\r
-    db    0e8h\r
-    db    01fh\r
-;    bts   eax, 31         ; Set PG=1.\r
-    mov   cr0, eax        ; Write CR0.\r
-    jmp   GoToLongMode\r
-GoToLongMode:\r
-\r
-    db      067h\r
-    db      0eah                ; Far Jump $+9:Selector to reload CS\r
-OffsetInLongMode:\r
-    dd      00000000            ;   $+9 Offset is ensuing instruction boundary\r
-    dw      038h                ;   Selector is our code selector, 38h\r
-\r
-InLongMode:\r
-    db   66h\r
-    mov     ax, 30h\r
-    mov     ds, ax\r
-\r
-    db   66h\r
-    mov     ax, 18h\r
-    mov     es, ax\r
-    mov     ss, ax\r
-    mov     ds, ax\r
-\r
-    db 0bdh\r
-    dd 400000h\r
-;    mov ebp,000400000h                  ; Destination of EFILDR32\r
-    db 0bbh\r
-    dd 70000h\r
-;    mov ebx,000070000h                  ; Length of copy\r
-\r
-    ;\r
-    ; load idt later\r
-    ;\r
-    db 48h\r
-    db 33h\r
-    db 0c0h\r
-;    xor rax, rax\r
-    db 66h\r
-    mov ax, offset idtr\r
-    db 48h\r
-    db 05h\r
-    dd 20000h\r
-;    add rax, 20000h\r
-\r
-    db 0fh\r
-    db 01h\r
-    db 18h\r
-;    lidt    fword ptr [rax]\r
-\r
-    db 48h\r
-    db 0c7h\r
-    db 0c0h\r
-    dd 21000h\r
-;   mov rax, 21000h\r
-    db 50h\r
-;   push rax\r
-\r
-; ret\r
-    db 0c3h\r
-\r
-Empty8042InputBuffer:\r
-        mov cx,0\r
-Empty8042Loop:\r
-        out     DELAY_PORT,ax               ; Delay 1us\r
-        in      al,KBD_STATUS_PORT          ; Read the 8042 Status Port\r
-        and     al,02h                      ; Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               ; Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; data\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-gdtr    dw GDT_END - GDT_BASE - 1   ; GDT limit\r
-        dd 0                        ; (GDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   global descriptor table (GDT)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-public GDT_BASE\r
-GDT_BASE:\r
-; null descriptor\r
-NULL_SEL            equ $-GDT_BASE          ; Selector [0x0]\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
-\r
-; linear data segment descriptor\r
-LINEAR_SEL      equ $-GDT_BASE          ; Selector [0x8]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; linear code segment descriptor\r
-LINEAR_CODE_SEL equ $-GDT_BASE          ; Selector [0x10]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system data segment descriptor\r
-SYS_DATA_SEL    equ $-GDT_BASE          ; Selector [0x18]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system code segment descriptor\r
-SYS_CODE_SEL    equ $-GDT_BASE          ; Selector [0x20]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE3_SEL  equ $-GDT_BASE          ; Selector [0x28]\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-;\r
-; system data segment descriptor\r
-;\r
-SYS_DATA64_SEL    equ $-GDT_BASE          ; Selector [0x30]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; P | DPL [1..2] | 1   | 1   | C | R | A\r
-        db 0CFh         ; G | D   | L    | AVL | Segment [19..16]\r
-        db 0\r
-\r
-;\r
-; system code segment descriptor\r
-;\r
-SYS_CODE64_SEL    equ $-GDT_BASE          ; Selector [0x38]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; P | DPL [1..2] | 1   | 1   | C | R | A\r
-        db 0AFh         ; G | D   | L    | AVL | Segment [19..16]\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE4_SEL  equ $-GDT_BASE            ; Selector [0x40]\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-GDT_END:\r
-\r
-        align 02h\r
-\r
-\r
-\r
-idtr            dw IDT_END - IDT_BASE - 1   ; IDT limit\r
-        dq 0                        ; (IDT base gets set above)\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   interrupt descriptor table (IDT)\r
-;\r
-;   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-;       mappings.  This implementation only uses the system timer and all other\r
-;       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-;       for convenience.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-;idt_tag db "IDT",0     \r
-        align 02h\r
-\r
-public IDT_BASE\r
-IDT_BASE:\r
-; divide by zero (INT 0)\r
-DIV_ZERO_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; debug exception (INT 1)\r
-DEBUG_EXCEPT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; NMI (INT 2)\r
-NMI_SEL             equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; soft breakpoint (INT 3)\r
-BREAKPOINT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; overflow (INT 4)\r
-OVERFLOW_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; bounds check (INT 5)\r
-BOUNDS_CHECK_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; invalid opcode (INT 6)\r
-INVALID_OPCODE_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; device not available (INT 7)\r
-DEV_NOT_AVAIL_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; double fault (INT 8)\r
-DOUBLE_FAULT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Coprocessor segment overrun - reserved (INT 9)\r
-RSVD_INTR_SEL1      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; invalid TSS (INT 0ah)\r
-INVALID_TSS_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; segment not present (INT 0bh)\r
-SEG_NOT_PRESENT_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; stack fault (INT 0ch)\r
-STACK_FAULT_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; general protection (INT 0dh)\r
-GP_FAULT_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; page fault (INT 0eh)\r
-PAGE_FAULT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Intel reserved - do not use (INT 0fh)\r
-RSVD_INTR_SEL2      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; floating point error (INT 10h)\r
-FLT_POINT_ERR_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; alignment check (INT 11h)\r
-ALIGNMENT_CHECK_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; machine check (INT 12h)\r
-MACHINE_CHECK_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; SIMD floating-point exception (INT 13h)\r
-SIMD_EXCEPTION_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        db (85 * 16) dup(0)\r
-        \r
-; IRQ 0 (System timer) - (INT 68h)\r
-IRQ0_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-IRQ1_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-IRQ2_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 3 (COM 2) - (INT 6bh)\r
-IRQ3_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 4 (COM 1) - (INT 6ch)\r
-IRQ4_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 5 (LPT 2) - (INT 6dh)\r
-IRQ5_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 6 (Floppy controller) - (INT 6eh)\r
-IRQ6_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 7 (LPT 1) - (INT 6fh)\r
-IRQ7_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 8 (RTC Alarm) - (INT 70h)\r
-IRQ8_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 9 - (INT 71h)\r
-IRQ9_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 10 - (INT 72h)\r
-IRQ10_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 11 - (INT 73h)\r
-IRQ11_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 12 (PS/2 mouse) - (INT 74h)\r
-IRQ12_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 13 (Floating point error) - (INT 75h)\r
-IRQ13_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 14 (Secondary IDE) - (INT 76h)\r
-IRQ14_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 15 (Primary IDE) - (INT 77h)\r
-IRQ15_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-IDT_END:\r
-\r
-        align 02h\r
-\r
-MemoryMapSize   dd  0\r
-MemoryMap   dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        org 0fe0h\r
-MyStack:    \r
-        ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        ;    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        ;    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        ;    8259.c\r
-                \r
-        int 8\r
-        iret\r
-        \r
-        int 9\r
-        iret\r
-        \r
-        int 10\r
-        iret\r
-        \r
-        int 11\r
-        iret\r
-        \r
-        int 12\r
-        iret\r
-        \r
-        int 13\r
-        iret\r
-        \r
-        int 14\r
-        iret\r
-        \r
-        int 15\r
-        iret\r
-        \r
-        \r
-        org 0ffeh\r
-BlockSignature:\r
-        dw  0aa55h\r
-\r
-        end \r
diff --git a/DuetPkg/BootSector/start.S b/DuetPkg/BootSector/start.S
deleted file mode 100644 (file)
index f96d06e..0000000
+++ /dev/null
@@ -1,919 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    start.S\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-    \r
-.equ                        FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                        FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                        BLOCK_SIZE, 0x0200\r
-.equ                        BLOCK_MASK, 0x01ff\r
-.equ                        BLOCK_SHIFT, 9\r
-\r
-       .org 0x0\r
-\r
-.global _start\r
-_start:\r
-\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId:              .ascii   "INTEL   "       # OemId               - 8 bytes\r
-\r
-SectorSize:         .word  0                  # Sector Size         - 16 bits\r
-SectorsPerCluster:  .byte  0                  # Sector Per Cluster  - 8 bits\r
-ReservedSectors:    .word  0                  # Reserved Sectors    - 16 bits\r
-NoFats:             .byte  0                  # Number of FATs      - 8 bits\r
-RootEntries:        .word  0                  # Root Entries        - 16 bits\r
-Sectors:            .word  0                  # Number of Sectors   - 16 bits\r
-Media:              .byte  0                  # Media               - 8 bits  - ignored\r
-SectorsPerFat:      .word  0                  # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:    .word  0                  # Sectors Per Track   - 16 bits - ignored\r
-Heads:              .word  0                  # Heads               - 16 bits - ignored\r
-HiddenSectors:      .long  0                  # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:       .long  0                  # Large Sectors       - 32 bits \r
-PhysicalDrive:      .byte  0                  # PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead:        .byte  0                  # Current Head        - 8 bits\r
-Signature:          .byte  0                  # Signature           - 8 bits  - ignored\r
-VolId:              .ascii "    "             # Volume Serial Number- 4 bytes\r
-FatLabel:           .ascii "           "      # Label               - 11 bytes\r
-SystemId:           .ascii "FAT12   "         # SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-        #ASSUME ds:@code\r
-        #ASSUME ss:@code\r
-      # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      # cx = Start Cluster of EfiLdr\r
-      # dx = Start Cluster of Efivar.bin\r
-\r
-# Re use the BPB data stored in Boot Sector\r
-        movw    $0x7c00, %bp\r
-\r
-        pushw   %cx\r
-# Read Efivar.bin\r
-#       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        movw    $0x1900, %ax\r
-        movw    %ax, %es\r
-        testw   %dx, %dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        movb    $1, %al\r
-NoVarStore: \r
-        pushw   %es\r
-# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        movb    %al, %es:(4)\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize: \r
-        movw    %dx, %di\r
-        cmpl    $0x4000, %ds:2(%di)\r
-        movb    $2, %al\r
-        jne     NoVarStore\r
-\r
-LoadVarStore: \r
-        movb    $0, %al\r
-        movb    %al, %es:(4)\r
-        movw    (%di), %cx\r
-#       ES:DI = 1500:0\r
-        xorw    %di, %di\r
-        pushw   %es\r
-        movw    $0x1500, %ax\r
-        movw    %ax, %es\r
-        call    ReadFile\r
-SaveVolumeId: \r
-        popw    %es\r
-        movw    VolId(%bp), %ax\r
-        movw    %ax, %es:(0)                    # Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        movw    VolId+2(%bp), %ax\r
-        movw    %ax, %es:(2)\r
-\r
-# Read Efildr\r
-        popw    %cx\r
-#       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-#       ES:DI = 2000:0, first cluster will be read again\r
-        xorw    %di, %di                            # di = 0\r
-        movw    $0x2000, %ax\r
-        movw    %ax, %es\r
-        call    ReadFile\r
-        movw    %cs, %ax\r
-        movw    %ax, %cs:JumpSegment\r
-\r
-JumpFarInstruction: \r
-        .byte   0xea\r
-JumpOffset: \r
-        .word   0x200\r
-JumpSegment: \r
-        .word   0x2000\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# ReadFile\r
-#\r
-# Arguments:\r
-#   CX    = Start Cluster of File\r
-#   ES:DI = Buffer to store file content read from disk\r
-#\r
-# Return:\r
-#   (ES << 4 + DI) = end of file content Buffer\r
-#\r
-# ****************************************************************************\r
-ReadFile: \r
-# si      = NumberOfClusters\r
-# cx      = ClusterNumber\r
-# dx      = CachedFatSectorNumber\r
-# ds:0000 = CacheFatSectorBuffer\r
-# es:di   = Buffer to load file\r
-# bx      = NextClusterNumber\r
-        pusha\r
-        movw    $1, %si                             # NumberOfClusters = 1\r
-        pushw   %cx                                 # Push Start Cluster onto stack\r
-        movw    $0xfff, %dx                         # CachedFatSectorNumber = 0xfff\r
-FatChainLoop: \r
-        movw    %cx, %ax                            # ax = ClusterNumber    \r
-        andw    $0xff8, %ax                         # ax = ax & 0xff8\r
-        cmpw    $0xff8, %ax                         # See if this is the last cluster\r
-        je      FoundLastCluster                    # Jump if last cluster found\r
-        movw    %cx, %ax                            # ax = ClusterNumber\r
-        shlw    %ax                                 # ax = ClusterNumber * 2\r
-        addw    %cx, %ax                            # ax = ClusterNumber * 2 + ClusterNumber = ClusterNumber * 3\r
-        shrw    %ax                                 # FatOffset = ClusterNumber*3 / 2\r
-        pushw   %si                                 # Save si\r
-        movw    %ax, %si                            # si = FatOffset\r
-        shrw    $BLOCK_SHIFT, %ax                   # ax = FatOffset >> BLOCK_SHIFT\r
-        addw    ReservedSectors(%bp), %ax           # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        andw    $BLOCK_MASK,%si                     # si = FatOffset & BLOCK_MASK\r
-        cmpw    %dx, %ax                            # Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        movw    $2, %bx\r
-        pushw   %es\r
-        pushw   %ds\r
-        popw    %es\r
-        call    ReadBlocks                          # Read 2 blocks starting at AX storing at ES:DI\r
-        popw    %es\r
-        movw    %ax, %dx                            # CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead: \r
-        movw    (%si), %bx                          # bx = NextClusterNumber\r
-        movw    %cx, %ax                            # ax = ClusterNumber\r
-        andw    $1, %ax                             # See if this is an odd cluster number\r
-        je      EvenFatEntry\r
-        shrw    $4, %bx                             # NextClusterNumber = NextClusterNumber >> 4\r
-EvenFatEntry: \r
-        andw    $0xfff, %bx                         # Strip upper 4 bits of NextClusterNumber\r
-        popw    %si                                 # Restore si\r
-        decw    %bx                                 # bx = NextClusterNumber - 1\r
-        cmpw    %cx, %bx                            # See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        incw    %bx                                 # bx = NextClusterNumber\r
-        incw    %si                                 # NumberOfClusters++\r
-        movw    %bx, %cx                            # ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters: \r
-        incw    %bx\r
-        popw    %ax                                 # ax = StartCluster\r
-        pushw   %bx                                 # StartCluster = NextClusterNumber\r
-        movw    %bx, %cx                            # ClusterNumber = NextClusterNumber\r
-        subw    $2, %ax                             # ax = StartCluster - 2\r
-        xorb    %bh, %bh\r
-        movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-        mulw    %bx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-        addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        pushw   %ax                                 # save start sector\r
-        movw    %si, %ax                            # ax = NumberOfClusters\r
-        mulw    %bx                                 # ax = NumberOfClusters * SectorsPerCluster\r
-        movw    %ax, %bx                            # bx = Number of Sectors\r
-        popw    %ax                                 # ax = Start Sector\r
-        call    ReadBlocks\r
-        movw    $1, %si                             # NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster: \r
-        popw    %cx\r
-        popa\r
-        ret\r
-\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-        pusha\r
-        addl    LBAOffsetForBootSector(%bp), %eax   # Add LBAOffsetForBootSector to Start LBA\r
-        addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-        movl    %eax, %esi                          # esi = Start LBA\r
-        movw    %bx, %cx                            # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-        movw    $0x7bfc, %bp                        # bp = 0x7bfc\r
-        movl    %esi, %eax                          # eax = Start LBA\r
-        xorl    %edx, %edx                          # edx = 0\r
-        movzwl  (%bp), %ebx                         # bx = MaxSector\r
-        divl    %ebx                                # ax = StartLBA / MaxSector\r
-        incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-\r
-        movw    (%bp), %bx                          # bx = MaxSector\r
-        subw    %dx, %bx                            # bx = MaxSector - Sector\r
-        incw    %bx                                 # bx = MaxSector - Sector + 1\r
-        cmpw    %bx, %cx                            # Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        movw    %cx, %bx                            # bx = Blocks\r
-LimitTransfer: \r
-        pushw   %ax                                 # save ax\r
-        movw    %es, %ax                            # ax = es\r
-        shrw    $(BLOCK_SHIFT-4), %ax               # ax = Number of blocks into mem system\r
-        andw    $0x7f, %ax                          # ax = Number of blocks into current seg\r
-        addw    %bx, %ax                            # ax = End Block number of transfer\r
-        cmpw    $0x80, %ax                          # See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               # Branch if not crossing 64K boundry\r
-        subw    $0x80, %ax                          # ax = Number of blocks past 64K boundry\r
-        subw    %ax, %bx                            # Decrease transfer size by block overage\r
-NotCrossing64KBoundry: \r
-        popw    %ax                                 # restore ax\r
-\r
-        pushw   %cx\r
-        movb    %dl, %cl                            # cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xorw    %dx, %dx                            # dx = 0\r
-        divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    # dx = ax % (MaxHead + 1) = Head\r
-\r
-        pushw   %bx                                 # Save number of blocks to transfer\r
-        movb    %dl, %dh                            # dh = Head\r
-        movw    $0x7c00, %bp                        # bp = 0x7c00\r
-        movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-        movb    %al, %ch                            # ch = Cylinder\r
-        movb    %bl, %al                            # al = Blocks\r
-        movb    $2, %ah                             # ah = Function 2\r
-        movw    %di, %bx                            # es:bx = Buffer address\r
-        int     $0x13\r
-        jc      DiskError\r
-        popw    %bx\r
-        popw    %cx\r
-        movzwl  %bx, %ebx\r
-        addl    %ebx, %esi                          # StartLBA = StartLBA + NumberOfBlocks\r
-        subw    %bx, %cx                            # Blocks = Blocks - NumberOfBlocks\r
-        movw    %es, %ax\r
-        shlw    $(BLOCK_SHIFT-4), %bx\r
-        addw    %bx, %ax\r
-        movw    %ax, %es                            # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmpw    $0, %cx\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError: \r
-        pushw %cs\r
-        popw %ds\r
-        leaw ErrorString, %si\r
-        movw $7, %cx\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt: \r
-        movw $0xb800, %ax\r
-        movw %ax, %es\r
-        movw $160, %di\r
-        rep\r
-        movsw\r
-Halt: \r
-        jmp   Halt\r
-\r
-ErrorString: \r
-        .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!',0x0c\r
-\r
-        .org     0x01fa\r
-LBAOffsetForBootSector: \r
-        .long   0x0\r
-\r
-        .org    0x01fe\r
-        .word   0xaa55\r
-\r
-#******************************************************************************\r
-#******************************************************************************\r
-#******************************************************************************\r
-\r
-.equ                 DELAY_PORT, 0x0ed           # Port to use for 1uS delay\r
-.equ                 KBD_CONTROL_PORT, 0x060     # 8042 control port     \r
-.equ                 KBD_STATUS_PORT, 0x064      # 8042 status port      \r
-.equ                 WRITE_DATA_PORT_CMD, 0x0d1  # 8042 command to write the data port\r
-.equ                 ENABLE_A20_CMD, 0x0df       # 8042 command to enable A20\r
-\r
-        .org     0x200\r
-        jmp start\r
-Em64String: \r
-        .byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
-\r
-start:  \r
-        movw %cs, %ax\r
-        movw %ax, %ds\r
-        movw %ax, %es\r
-        movw %ax, %ss\r
-        movw $MyStack, %sp\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[160],'a'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        movl $0, %ebx\r
-        leal MemoryMap, %edi\r
-MemMapLoop: \r
-        movl $0xe820, %eax\r
-        movl $20, %ecx\r
-        movl $0x534d4150, %edx  # SMAP\r
-        int $0x15\r
-        jc  MemMapDone\r
-        addl $20, %edi\r
-        cmpl $0, %ebx\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone: \r
-        leal MemoryMap, %eax\r
-        subl %eax, %edi                     # Get the address of the memory map\r
-        movl %edi, MemoryMapSize            # Save the size of the memory map\r
-\r
-        xorl    %ebx, %ebx\r
-        movw    %cs, %bx                    # BX=segment\r
-        shll    $4, %ebx                    # BX="linear" address of segment base\r
-        leal    GDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of gdt\r
-        movl    %eax, (gdtr + 2)            # Put address of gdt into the gdtr\r
-        leal    IDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of idt\r
-        movl    %eax, (idtr + 2)            # Put address of idt into the idtr\r
-        leal    MemoryMapSize(%ebx), %edx   # Physical base address of the memory map\r
-\r
-        addl $0x1000, %ebx                  # Source of EFI32\r
-        movl %ebx, JUMP+2\r
-        addl $0x1000, %ebx\r
-        movl %ebx, %esi                     # Source of EFILDR32\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[162],'b'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-#\r
-# Enable A20 Gate \r
-#\r
-\r
-        movw $0x2401, %ax                   # Enable A20 Gate\r
-        int $0x15\r
-        jnc A20GateEnabled                  # Jump if it suceeded\r
-\r
-#\r
-# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-#\r
-\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        mov     $WRITE_DATA_PORT_CMD, %al   # 8042 cmd to write output port\r
-        out     %al, $KBD_STATUS_PORT       # Send command to the 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        mov     $ENABLE_A20_CMD, %al        # gate address bit 20 on\r
-        out     %al, $KBD_CONTROL_PORT      # Send command to thre 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        movw    $25, %cx                    # Delay 25 uS for the command to complete on the 8042\r
-Delay25uS: \r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        loop    Delay25uS\r
-Timeout8042: \r
-\r
-\r
-A20GateEnabled: \r
-        movw    $0x0008, %bx                # Flat data descriptor\r
-\r
-#\r
-# DISABLE INTERRUPTS - Entering Protected Mode\r
-#\r
-\r
-        cli\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[164],'c'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        .byte   0x66\r
-        lgdt    gdtr\r
-        .byte   0x66\r
-        lidt    idtr\r
-\r
-        movl    %cr0, %eax\r
-        orb     $1, %al\r
-        movl    %eax, %cr0\r
-JUMP: \r
-# jmp far 0010:00020000\r
-        .byte 0x66\r
-        .byte 0xea\r
-        .long 0x00020000\r
-        .word 0x0010\r
-\r
-Empty8042InputBuffer: \r
-        movw $0, %cx\r
-Empty8042Loop: \r
-        outw    %ax, $DELAY_PORT            # Delay 1us\r
-        in      $KBD_STATUS_PORT, %al       # Read the 8042 Status Port\r
-        andb    $0x2, %al                   # Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               # Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-##############################################################################\r
-# data\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-        gdtr:    .long  GDT_END - GDT_BASE - 1  # GDT limit \r
-        .long 0                                 # (GDT base gets set above)\r
-##############################################################################\r
-#   global descriptor table (GDT)\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-GDT_BASE: \r
-# null descriptor\r
-.equ                NULL_SEL, .-GDT_BASE\r
-        .word 0         # limit 15:0\r
-        .word 0         # base 15:0\r
-        .byte 0         # base 23:16\r
-        .byte 0         # type\r
-        .byte 0         # limit 19:16, flags\r
-        .byte 0         # base 31:24\r
-\r
-# linear data segment descriptor\r
-.equ            LINEAR_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# linear code segment descriptor\r
-.equ            LINEAR_CODE_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system data segment descriptor\r
-.equ            SYS_DATA_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system code segment descriptor\r
-.equ            SYS_CODE_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE3_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE4_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE5_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-GDT_END: \r
-\r
-        .p2align 1\r
-\r
-\r
-\r
-idtr:  .long  IDT_END - IDT_BASE - 1 # IDT limit\r
-        .long 0                      # (IDT base gets set above)\r
-##############################################################################\r
-#   interrupt descriptor table (IDT)\r
-#\r
-#   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-#       mappings.  This implementation only uses the system timer and all other\r
-#       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-#       for convenience.\r
-##############################################################################\r
-\r
-#idt_tag db "IDT",0     \r
-        .p2align 1\r
-\r
-IDT_BASE: \r
-# divide by zero (INT 0)\r
-.equ                DIV_ZERO_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# debug exception (INT 1)\r
-.equ                DEBUG_EXCEPT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# NMI (INT 2)\r
-.equ                NMI_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# soft breakpoint (INT 3)\r
-.equ                BREAKPOINT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# overflow (INT 4)\r
-.equ                OVERFLOW_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# bounds check (INT 5)\r
-.equ                BOUNDS_CHECK_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# invalid opcode (INT 6)\r
-.equ                INVALID_OPCODE_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# device not available (INT 7)\r
-.equ                DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
-         .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# double fault (INT 8)\r
-.equ                DOUBLE_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# Coprocessor segment overrun - reserved (INT 9)\r
-.equ                RSVD_INTR_SEL1, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# invalid TSS (INT 0x0a)\r
-.equ                INVALID_TSS_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# segment not present (INT 0x0b)\r
-.equ                SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# stack fault (INT 0x0c)\r
-.equ                STACK_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# general protection (INT 0x0d)\r
-.equ                GP_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# page fault (INT 0x0e)\r
-.equ                PAGE_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# Intel reserved - do not use (INT 0x0f)\r
-.equ                RSVD_INTR_SEL2, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# floating point error (INT 0x10)\r
-.equ                FLT_POINT_ERR_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# alignment check (INT 0x11)\r
-.equ                ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# machine check (INT 0x12)\r
-.equ                MACHINE_CHECK_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# SIMD floating-point exception (INT 0x13)\r
-.equ                SIMD_EXCEPTION_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-    .fill 85 * 8, 1, 0   # db (85 * 8) dup(0)\r
-\r
-# IRQ 0 (System timer) - (INT 0x68)\r
-.equ                IRQ0_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 1 (8042 Keyboard controller) - (INT 0x69)\r
-.equ                IRQ1_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 0x6a)\r
-.equ                IRQ2_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 3 (COM 2) - (INT 0x6b)\r
-.equ                IRQ3_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 4 (COM 1) - (INT 0x6c)\r
-.equ                IRQ4_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 5 (LPT 2) - (INT 0x6d)\r
-.equ                IRQ5_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 6 (Floppy controller) - (INT 0x6e)\r
-.equ                IRQ6_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 7 (LPT 1) - (INT 0x6f)\r
-.equ                IRQ7_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 8 (RTC Alarm) - (INT 0x70)\r
-.equ                IRQ8_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 9 - (INT 0x71)\r
-.equ                IRQ9_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 10 - (INT 0x72)\r
-.equ                 IRQ10_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 11 - (INT 0x73)\r
-.equ                 IRQ11_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 12 (PS/2 mouse) - (INT 0x74)\r
-.equ                 IRQ12_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-        \r
-# IRQ 13 (Floating point error) - (INT 0x75)\r
-.equ                 IRQ13_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 14 (Secondary IDE) - (INT 0x76)\r
-.equ                 IRQ14_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 15 (Primary IDE) - (INT 0x77)\r
-.equ                 IRQ15_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .long SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e |  0x80 # (10001110)type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-IDT_END: \r
-\r
-        .p2align 1\r
-\r
-MemoryMapSize:  .long 0\r
-MemoryMap:  .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        .org 0x0fe0\r
-MyStack:    \r
-        # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        #    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        #    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        #    8259.c\r
-\r
-        int $8\r
-        iret\r
-\r
-        int $9\r
-        iret\r
-\r
-        int $10\r
-        iret\r
-\r
-        int $11\r
-        iret\r
-\r
-        int $12\r
-        iret\r
-\r
-        int $13\r
-        iret\r
-\r
-        int $14\r
-        iret\r
-\r
-        int $15\r
-        iret\r
-\r
-\r
-        .org 0x0ffe\r
-BlockSignature: \r
-        .word 0xaa55\r
-\r
-\r
diff --git a/DuetPkg/BootSector/start.asm b/DuetPkg/BootSector/start.asm
deleted file mode 100644 (file)
index 9cc05ff..0000000
+++ /dev/null
@@ -1,916 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    start.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE    EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT   EQU     5\r
-BLOCK_SIZE                  EQU     0200h\r
-BLOCK_MASK                  EQU     01ffh\r
-BLOCK_SHIFT                 EQU     9\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-PhysicalDrive     db  0             ; PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead       db  0             ; Current Head        - 8 bits\r
-Signature         db  0             ; Signature           - 8 bits  - ignored\r
-VolId             db  "    "        ; Volume Serial Number- 4 bytes\r
-FatLabel          db  "           " ; Label               - 11 bytes\r
-SystemId          db  "FAT12   "    ; SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-      ; ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      ; cx = Start Cluster of EfiLdr\r
-      ; dx = Start Cluster of Efivar.bin\r
-\r
-; Re use the BPB data stored in Boot Sector\r
-        mov     bp,07c00h\r
-\r
-        push    cx\r
-; Read Efivar.bin\r
-;       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        mov     ax,01900h\r
-        mov     es,ax\r
-        test    dx,dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        mov     al,1\r
-NoVarStore:\r
-        push    es\r
-; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        mov     byte ptr es:[4],al\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize:\r
-        mov     di,dx\r
-        cmp     dword ptr ds:[di+2], 04000h\r
-        mov     al,2\r
-        jne     NoVarStore\r
-\r
-LoadVarStore:\r
-        mov     al,0\r
-        mov     byte ptr es:[4],al\r
-        mov     cx,word ptr[di]\r
-;       ES:DI = 1500:0\r
-        xor     di,di\r
-        push    es\r
-        mov     ax,01500h\r
-        mov     es,ax\r
-        call    ReadFile\r
-SaveVolumeId:\r
-        pop     es\r
-        mov     ax,word ptr [bp+VolId]\r
-        mov     word ptr es:[0],ax                  ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        mov     ax,word ptr [bp+VolId+2]\r
-        mov     word ptr es:[2],ax\r
-\r
-; Read Efildr\r
-        pop     cx\r
-;       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-;       ES:DI = 2000:0, first cluster will be read again\r
-        xor     di,di                               ; di = 0\r
-        mov     ax,02000h\r
-        mov     es,ax\r
-        call    ReadFile\r
-        mov     ax,cs\r
-        mov     word ptr cs:[JumpSegment],ax\r
-\r
-JumpFarInstruction:\r
-        db      0eah\r
-JumpOffset:\r
-        dw      0200h\r
-JumpSegment:\r
-        dw      2000h\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; ReadFile\r
-;\r
-; Arguments:\r
-;   CX    = Start Cluster of File\r
-;   ES:DI = Buffer to store file content read from disk\r
-;\r
-; Return:\r
-;   (ES << 4 + DI) = end of file content Buffer\r
-;\r
-; ****************************************************************************\r
-ReadFile:\r
-; si      = NumberOfClusters\r
-; cx      = ClusterNumber\r
-; dx      = CachedFatSectorNumber\r
-; ds:0000 = CacheFatSectorBuffer\r
-; es:di   = Buffer to load file\r
-; bx      = NextClusterNumber\r
-        pusha\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        push    cx                                  ; Push Start Cluster onto stack\r
-        mov     dx,0fffh                            ; CachedFatSectorNumber = 0xfff\r
-FatChainLoop:\r
-        mov     ax,cx                               ; ax = ClusterNumber    \r
-        and     ax,0ff8h                            ; ax = ax & 0xff8\r
-        cmp     ax,0ff8h                            ; See if this is the last cluster\r
-        je      FoundLastCluster                    ; Jump if last cluster found\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        shl     ax,1                                ; ax = ClusterNumber * 2\r
-        add     ax,cx                               ; ax = ClusterNumber * 2 + ClusterNumber = ClusterNumber * 3\r
-        shr     ax,1                                ; FatOffset = ClusterNumber*3 / 2\r
-        push    si                                  ; Save si\r
-        mov     si,ax                               ; si = FatOffset\r
-        shr     ax,BLOCK_SHIFT                      ; ax = FatOffset >> BLOCK_SHIFT\r
-        add     ax,word ptr [bp+ReservedSectors]    ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        and     si,BLOCK_MASK                       ; si = FatOffset & BLOCK_MASK\r
-        cmp     ax,dx                               ; Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        mov     bx,2                                \r
-        push    es\r
-        push    ds\r
-        pop     es\r
-        call    ReadBlocks                          ; Read 2 blocks starting at AX storing at ES:DI\r
-        pop     es\r
-        mov     dx,ax                               ; CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead:\r
-        mov     bx,word ptr [si]                    ; bx = NextClusterNumber\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        and     ax,1                                ; See if this is an odd cluster number\r
-        je      EvenFatEntry\r
-        shr     bx,4                                ; NextClusterNumber = NextClusterNumber >> 4\r
-EvenFatEntry:\r
-        and     bx,0fffh                            ; Strip upper 4 bits of NextClusterNumber\r
-        pop     si                                  ; Restore si\r
-        dec     bx                                  ; bx = NextClusterNumber - 1\r
-        cmp     bx,cx                               ; See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        inc     bx                                  ; bx = NextClusterNumber\r
-        inc     si                                  ; NumberOfClusters++\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters:\r
-        inc     bx\r
-        pop     ax                                  ; ax = StartCluster\r
-        push    bx                                  ; StartCluster = NextClusterNumber\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        sub     ax,2                                ; ax = StartCluster - 2\r
-        xor     bh,bh                               \r
-        mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-        mul     bx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-        add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        push    ax                                  ; save start sector\r
-        mov     ax,si                               ; ax = NumberOfClusters\r
-        mul     bx                                  ; ax = NumberOfClusters * SectorsPerCluster\r
-        mov     bx,ax                               ; bx = Number of Sectors\r
-        pop     ax                                  ; ax = Start Sector\r
-        call    ReadBlocks\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster:\r
-        pop     cx\r
-        popa\r
-        ret\r
-\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-        pusha\r
-        add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-        add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-        mov     esi,eax                             ; esi = Start LBA\r
-        mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-        mov     bp,07bfch                           ; bp = 0x7bfc\r
-        mov     eax,esi                             ; eax = Start LBA\r
-        xor     edx,edx                             ; edx = 0\r
-        movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-        div     ebx                                 ; ax = StartLBA / MaxSector\r
-        inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-\r
-        mov     bx,word ptr [bp]                    ; bx = MaxSector\r
-        sub     bx,dx                               ; bx = MaxSector - Sector\r
-        inc     bx                                  ; bx = MaxSector - Sector + 1\r
-        cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-        push    ax                                  ; save ax\r
-        mov     ax,es                               ; ax = es\r
-        shr     ax,(BLOCK_SHIFT-4)                  ; ax = Number of blocks into mem system\r
-        and     ax,07fh                             ; ax = Number of blocks into current seg\r
-        add     ax,bx                               ; ax = End Block number of transfer\r
-        cmp     ax,080h                             ; See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               ; Branch if not crossing 64K boundry\r
-        sub     ax,080h                             ; ax = Number of blocks past 64K boundry\r
-        sub     bx,ax                               ; Decrease transfer size by block overage\r
-NotCrossing64KBoundry:\r
-        pop     ax                                  ; restore ax\r
-\r
-        push    cx\r
-        mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xor     dx,dx                               ; dx = 0\r
-        div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    ; dx = ax % (MaxHead + 1) = Head\r
-\r
-        push    bx                                  ; Save number of blocks to transfer\r
-        mov     dh,dl                               ; dh = Head\r
-        mov     bp,07c00h                           ; bp = 0x7c00\r
-        mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-        mov     ch,al                               ; ch = Cylinder\r
-        mov     al,bl                               ; al = Blocks\r
-        mov     ah,2                                ; ah = Function 2\r
-        mov     bx,di                               ; es:bx = Buffer address\r
-        int     013h\r
-        jc      DiskError\r
-        pop     bx\r
-        pop     cx\r
-        movzx   ebx,bx\r
-        add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-        sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-        mov     ax,es\r
-        shl     bx,(BLOCK_SHIFT-4)\r
-        add     ax,bx\r
-        mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmp     cx,0\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError:\r
-        push cs\r
-        pop  ds\r
-        lea  si, [ErrorString]\r
-        mov  cx, 7\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt:\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  di,160\r
-        rep  movsw\r
-Halt:\r
-        jmp   Halt\r
-\r
-ErrorString:\r
-        db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-        org     01fah\r
-LBAOffsetForBootSector:\r
-        dd      0h\r
-\r
-        org     01feh\r
-        dw      0aa55h\r
-\r
-;******************************************************************************\r
-;******************************************************************************\r
-;******************************************************************************\r
-\r
-DELAY_PORT           equ     0edh    ; Port to use for 1uS delay\r
-KBD_CONTROL_PORT     equ     060h    ; 8042 control port     \r
-KBD_STATUS_PORT      equ     064h    ; 8042 status port      \r
-WRITE_DATA_PORT_CMD  equ     0d1h    ; 8042 command to write the data port\r
-ENABLE_A20_CMD       equ     0dfh    ; 8042 command to enable A20\r
-\r
-        org     200h\r
-        jmp start\r
-Em64String:\r
-        db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch\r
-\r
-start:  \r
-        mov ax,cs\r
-        mov ds,ax\r
-        mov es,ax\r
-        mov ss,ax\r
-        mov sp,MyStack\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[160],'a'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        mov ebx,0\r
-        lea edi,MemoryMap\r
-MemMapLoop:\r
-        mov eax,0e820h\r
-        mov ecx,20\r
-        mov edx,'SMAP'\r
-        int 15h\r
-        jc  MemMapDone\r
-        add edi,20\r
-        cmp ebx,0\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone:\r
-        lea eax,MemoryMap\r
-        sub edi,eax                         ; Get the address of the memory map\r
-        mov dword ptr [MemoryMapSize],edi   ; Save the size of the memory map\r
-\r
-        xor     ebx,ebx\r
-        mov     bx,cs                       ; BX=segment\r
-        shl     ebx,4                       ; BX="linear" address of segment base\r
-        lea     eax,[GDT_BASE + ebx]        ; EAX=PHYSICAL address of gdt\r
-        mov     dword ptr [gdtr + 2],eax    ; Put address of gdt into the gdtr\r
-        lea     eax,[IDT_BASE + ebx]        ; EAX=PHYSICAL address of idt\r
-        mov     dword ptr [idtr + 2],eax    ; Put address of idt into the idtr\r
-        lea     edx,[MemoryMapSize + ebx]   ; Physical base address of the memory map\r
-\r
-        add ebx,01000h                      ; Source of EFI32\r
-        mov dword ptr [JUMP+2],ebx\r
-        add ebx,01000h\r
-        mov esi,ebx                         ; Source of EFILDR32\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[162],'b'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-;\r
-; Enable A20 Gate \r
-;\r
-\r
-        mov ax,2401h                        ; Enable A20 Gate\r
-        int 15h\r
-        jnc A20GateEnabled                  ; Jump if it suceeded\r
-\r
-;\r
-; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-;\r
-\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        mov     al,WRITE_DATA_PORT_CMD      ; 8042 cmd to write output port\r
-        out     KBD_STATUS_PORT,al          ; Send command to the 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        mov     al,ENABLE_A20_CMD           ; gate address bit 20 on\r
-        out     KBD_CONTROL_PORT,al         ; Send command to thre 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        mov     cx,25                       ; Delay 25 uS for the command to complete on the 8042\r
-Delay25uS:\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        loop    Delay25uS                       \r
-Timeout8042:\r
-\r
-\r
-A20GateEnabled:\r
-        mov     bx,0008h                    ; Flat data descriptor\r
-;\r
-; DISABLE INTERRUPTS - Entering Protected Mode\r
-;\r
-\r
-        cli                             \r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[164],'c'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        db      66h     \r
-        lgdt    fword ptr [gdtr]\r
-        db      66h     \r
-        lidt    fword ptr [idtr]\r
-\r
-        mov     eax,cr0\r
-        or      al,1\r
-        mov     cr0,eax\r
-JUMP:\r
-; jmp far 0010:00020000\r
-        db  066h\r
-        db  0eah\r
-        dd  000020000h\r
-        dw  00010h\r
-\r
-Empty8042InputBuffer:\r
-        mov cx,0\r
-Empty8042Loop:\r
-        out     DELAY_PORT,ax               ; Delay 1us\r
-        in      al,KBD_STATUS_PORT          ; Read the 8042 Status Port\r
-        and     al,02h                      ; Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               ; Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; data\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-gdtr    dw GDT_END - GDT_BASE - 1   ; GDT limit\r
-        dd 0                        ; (GDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   global descriptor table (GDT)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-public GDT_BASE\r
-GDT_BASE:\r
-; null descriptor\r
-NULL_SEL            equ $-GDT_BASE\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
-\r
-; linear data segment descriptor\r
-LINEAR_SEL      equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; linear code segment descriptor\r
-LINEAR_CODE_SEL equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system data segment descriptor\r
-SYS_DATA_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system code segment descriptor\r
-SYS_CODE_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE3_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE4_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE5_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-GDT_END:\r
-\r
-        align 02h\r
-\r
-\r
-\r
-idtr            dw IDT_END - IDT_BASE - 1   ; IDT limit\r
-        dd 0                        ; (IDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   interrupt descriptor table (IDT)\r
-;\r
-;   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-;       mappings.  This implementation only uses the system timer and all other\r
-;       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-;       for convenience.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-;idt_tag db "IDT",0     \r
-        align 02h\r
-\r
-public IDT_BASE\r
-IDT_BASE:\r
-; divide by zero (INT 0)\r
-DIV_ZERO_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; debug exception (INT 1)\r
-DEBUG_EXCEPT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; NMI (INT 2)\r
-NMI_SEL             equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; soft breakpoint (INT 3)\r
-BREAKPOINT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; overflow (INT 4)\r
-OVERFLOW_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; bounds check (INT 5)\r
-BOUNDS_CHECK_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; invalid opcode (INT 6)\r
-INVALID_OPCODE_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; device not available (INT 7)\r
-DEV_NOT_AVAIL_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; double fault (INT 8)\r
-DOUBLE_FAULT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Coprocessor segment overrun - reserved (INT 9)\r
-RSVD_INTR_SEL1      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; invalid TSS (INT 0ah)\r
-INVALID_TSS_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; segment not present (INT 0bh)\r
-SEG_NOT_PRESENT_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; stack fault (INT 0ch)\r
-STACK_FAULT_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; general protection (INT 0dh)\r
-GP_FAULT_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; page fault (INT 0eh)\r
-PAGE_FAULT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Intel reserved - do not use (INT 0fh)\r
-RSVD_INTR_SEL2      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; floating point error (INT 10h)\r
-FLT_POINT_ERR_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; alignment check (INT 11h)\r
-ALIGNMENT_CHECK_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; machine check (INT 12h)\r
-MACHINE_CHECK_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; SIMD floating-point exception (INT 13h)\r
-SIMD_EXCEPTION_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        db (85 * 8) dup(0)\r
-        \r
-; IRQ 0 (System timer) - (INT 68h)\r
-IRQ0_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-IRQ1_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-IRQ2_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 3 (COM 2) - (INT 6bh)\r
-IRQ3_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 4 (COM 1) - (INT 6ch)\r
-IRQ4_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 5 (LPT 2) - (INT 6dh)\r
-IRQ5_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 6 (Floppy controller) - (INT 6eh)\r
-IRQ6_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 7 (LPT 1) - (INT 6fh)\r
-IRQ7_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 8 (RTC Alarm) - (INT 70h)\r
-IRQ8_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 9 - (INT 71h)\r
-IRQ9_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 10 - (INT 72h)\r
-IRQ10_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 11 - (INT 73h)\r
-IRQ11_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 12 (PS/2 mouse) - (INT 74h)\r
-IRQ12_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 13 (Floating point error) - (INT 75h)\r
-IRQ13_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 14 (Secondary IDE) - (INT 76h)\r
-IRQ14_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 15 (Primary IDE) - (INT 77h)\r
-IRQ15_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-IDT_END:\r
-\r
-        align 02h\r
-\r
-MemoryMapSize   dd  0\r
-MemoryMap   dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        org 0fe0h\r
-MyStack:    \r
-        ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        ;    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        ;    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        ;    8259.c\r
-                \r
-        int 8\r
-        iret\r
-        \r
-        int 9\r
-        iret\r
-        \r
-        int 10\r
-        iret\r
-        \r
-        int 11\r
-        iret\r
-        \r
-        int 12\r
-        iret\r
-        \r
-        int 13\r
-        iret\r
-        \r
-        int 14\r
-        iret\r
-        \r
-        int 15\r
-        iret\r
-        \r
-        \r
-        org 0ffeh\r
-BlockSignature:\r
-        dw  0aa55h\r
-\r
-        end \r
diff --git a/DuetPkg/BootSector/start16.S b/DuetPkg/BootSector/start16.S
deleted file mode 100644 (file)
index a4cb151..0000000
+++ /dev/null
@@ -1,910 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    start16.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-        #.MODEL small\r
-        .stack: \r
-        .486p: \r
-        .code16 \r
-\r
-.equ                        FAT_DIRECTORY_ENTRY_SIZE,   0x0020\r
-.equ                        FAT_DIRECTORY_ENTRY_SHIFT,  5\r
-.equ                        BLOCK_SIZE,                 0x0200\r
-.equ                        BLOCK_MASK,                 0x01ff\r
-.equ                        BLOCK_SHIFT,                9\r
-\r
-        .org 0x00\r
-\r
-.global _start\r
-_start:\r
-\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId:             .ascii  "INTEL   "    # OemId               - 8 bytes\r
-\r
-SectorSize:        .word  0              # Sector Size         - 16 bits\r
-SectorsPerCluster: .byte  0              # Sector Per Cluster  - 8 bits\r
-ReservedSectors:   .word  0              # Reserved Sectors    - 16 bits\r
-NoFats:            .byte  0              # Number of FATs      - 8 bits\r
-RootEntries:       .word  0              # Root Entries        - 16 bits\r
-Sectors:           .word  0              # Number of Sectors   - 16 bits\r
-Media:             .byte  0              # Media               - 8 bits  - ignored\r
-SectorsPerFat:     .word  0              # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:   .word  0              # Sectors Per Track   - 16 bits - ignored\r
-Heads:             .word  0              # Heads               - 16 bits - ignored\r
-HiddenSectors:     .long  0              # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:      .long  0              # Large Sectors       - 32 bits \r
-PhysicalDrive:     .byte  0              # PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead:       .byte  0              # Current Head        - 8 bits\r
-Signature:         .byte  0              # Signature           - 8 bits  - ignored\r
-VolId:             .ascii  "    "        # Volume Serial Number- 4 bytes\r
-FatLabel:          .ascii  "           " # Label               - 11 bytes\r
-SystemId:          .ascii  "FAT16   "    # SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-        #ASSUME ds:@code\r
-        #ASSUME ss:@code\r
-      # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      # cx = Start Cluster of EfiLdr\r
-      # dx = Start Cluster of Efivar.bin\r
-\r
-# Re use the BPB data stored in Boot Sector\r
-        movw    $0x7c00, %bp\r
-\r
-        pushw   %cx\r
-# Read Efivar.bin\r
-#       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        movw    $0x1900, %ax\r
-        movw    %ax, %es\r
-        testw   %dx, %dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        movb    $1, %al\r
-NoVarStore: \r
-        pushw   %es\r
-# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        movb    %al, %es:4\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize: \r
-        movw    %dx, %di\r
-        cmpl    $0x4000, %ds:2(%di)\r
-        movb    $2, %al\r
-        jne     NoVarStore\r
-\r
-LoadVarStore: \r
-        movb    $0, %al\r
-        movb    %al, %es:4\r
-        movw    (%di), %cx\r
-#       ES:DI = 1500:0\r
-        xorw    %di, %di\r
-        pushw   %es\r
-        movw    $0x1500, %ax\r
-        movw    %ax, %es\r
-        call    ReadFile\r
-SaveVolumeId: \r
-        popw    %es\r
-        movw    VolId(%bp), %ax\r
-        movw    %ax, %es:0                      # Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        movw    VolId+2(%bp), %ax\r
-        movw    %ax, %es:2\r
-\r
-# Read Efildr\r
-        popw    %cx\r
-#       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-#       ES:DI = 2000:0, first cluster will be read again\r
-        xorw    %di, %di                            # di = 0\r
-        movw    $0x2000, %ax\r
-        movw    %ax, %es\r
-        call    ReadFile\r
-        movw    %cs, %ax\r
-        movw    %ax, %cs:JumpSegment\r
-\r
-JumpFarInstruction: \r
-        .byte   0xea\r
-JumpOffset: \r
-        .word   0x200\r
-JumpSegment: \r
-        .word   0x2000\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# ReadFile\r
-#\r
-# Arguments:\r
-#   CX    = Start Cluster of File\r
-#   ES:DI = Buffer to store file content read from disk\r
-#\r
-# Return:\r
-#   (ES << 4 + DI) = end of file content Buffer\r
-#\r
-# ****************************************************************************\r
-ReadFile: \r
-# si      = NumberOfClusters\r
-# cx      = ClusterNumber\r
-# dx      = CachedFatSectorNumber\r
-# ds:0000 = CacheFatSectorBuffer\r
-# es:di   = Buffer to load file\r
-# bx      = NextClusterNumber\r
-        pusha\r
-        movw    $1, %si                             # NumberOfClusters = 1\r
-        pushw   %cx                                 # Push Start Cluster onto stack\r
-        movw    $0xfff, %dx                         # CachedFatSectorNumber = 0xfff\r
-FatChainLoop: \r
-        movw    %cx, %ax                            # ax = ClusterNumber    \r
-        andw    $0xfff8, %ax                        # ax = ax & 0xfff8\r
-        cmpw    $0xfff8, %ax                        # See if this is the last cluster\r
-        je      FoundLastCluster                    # Jump if last cluster found\r
-        movw    %cx, %ax                            # ax = ClusterNumber\r
-        shlw    %ax                                 # FatOffset = ClusterNumber * 2\r
-        pushw   %si                                 # Save si\r
-        movw    %ax, %si                            # si = FatOffset\r
-        shrw    $BLOCK_SHIFT, %ax                   # ax = FatOffset >> BLOCK_SHIFT\r
-        addw    ReservedSectors(%bp), %ax           # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        andw    $BLOCK_MASK, %si                    # si = FatOffset & BLOCK_MASK\r
-        cmpw    %dx, %ax                            # Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        movw    $2, %bx\r
-        pushw   %es\r
-        pushw   %ds\r
-        popw    %es\r
-        call    ReadBlocks                          # Read 2 blocks starting at AX storing at ES:DI\r
-        popw    %es\r
-        movw    %ax, %dx                            # CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead: \r
-        movw    (%si), %bx                          # bx = NextClusterNumber\r
-        movw    %cx, %ax                            # ax = ClusterNumber\r
-        popw    %si                                 # Restore si\r
-        decw    %bx                                 # bx = NextClusterNumber - 1\r
-        cmpw    %cx, %bx                            # See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        incw    %bx                                 # bx = NextClusterNumber\r
-        incw    %si                                 # NumberOfClusters++\r
-        movw    %bx, %cx                            # ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters: \r
-        incw    %bx\r
-        popw    %ax                                 # ax = StartCluster\r
-        pushw   %bx                                 # StartCluster = NextClusterNumber\r
-        movw    %bx, %cx                            # ClusterNumber = NextClusterNumber\r
-        subw    $2, %ax                             # ax = StartCluster - 2\r
-        xorb    %bh, %bh\r
-        movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-        mulw    %bx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-        addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        pushw   %ax                                 # save start sector\r
-        movw    %si, %ax                            # ax = NumberOfClusters\r
-        mulw    %bx                                 # ax = NumberOfClusters * SectorsPerCluster\r
-        movw    %ax, %bx                            # bx = Number of Sectors\r
-        popw    %ax                                 # ax = Start Sector\r
-        call    ReadBlocks\r
-        movw    $1, %si                             # NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster: \r
-        popw    %cx\r
-        popa\r
-        ret\r
-\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-        pusha\r
-        addl    LBAOffsetForBootSector(%bp), %eax            # Add LBAOffsetForBootSector to Start LBA\r
-        addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-        movl    %eax, %esi                          # esi = Start LBA\r
-        movw    %bx, %cx                            # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-        movw    $0x7bfc, %bp                        # bp = 0x7bfc\r
-        movl    %esi, %eax                          # eax = Start LBA\r
-        xorl    %edx, %edx                          # edx = 0\r
-        movzwl  (%bp), %ebx                         # bx = MaxSector\r
-        divl    %ebx                                # ax = StartLBA / MaxSector\r
-        incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-\r
-        movw    (%bp), %bx                          # bx = MaxSector\r
-        subw    %dx, %bx                            # bx = MaxSector - Sector\r
-        incw    %bx                                 # bx = MaxSector - Sector + 1\r
-        cmpw    %bx, %cx                            # Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        movw    %cx, %bx                            # bx = Blocks\r
-LimitTransfer: \r
-        pushw   %ax                                 # save ax\r
-        movw    %es, %ax                            # ax = es\r
-        shrw    $(BLOCK_SHIFT-4), %ax               # ax = Number of blocks into mem system\r
-        andw    $0x7f, %ax                          # ax = Number of blocks into current seg\r
-        addw    %bx, %ax                            # ax = End Block number of transfer\r
-        cmpw    $0x80, %ax                          # See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               # Branch if not crossing 64K boundry\r
-        subw    $0x80, %ax                          # ax = Number of blocks past 64K boundry\r
-        subw    %ax, %bx                            # Decrease transfer size by block overage\r
-NotCrossing64KBoundry: \r
-        popw    %ax                                 # restore ax\r
-\r
-        pushw   %cx\r
-        movb    %dl, %cl                            # cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xorw    %dx, %dx                            # dx = 0\r
-        divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    # dx = ax % (MaxHead + 1) = Head\r
-\r
-        pushw   %bx                                 # Save number of blocks to transfer\r
-        movb    %dl, %dh                            # dh = Head\r
-        movw    $0x7c00, %bp                        # bp = 0x7c00\r
-        movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-        movb    %al, %ch                            # ch = Cylinder\r
-        movb    %bl, %al                            # al = Blocks\r
-        movb    $2, %ah                             # ah = Function 2\r
-        movw    %di, %bx                            # es:bx = Buffer address\r
-        int     $0x13\r
-        jc      DiskError\r
-        popw    %bx\r
-        popw    %cx\r
-        movzwl  %bx, %ebx\r
-        addl    %ebx, %esi                          # StartLBA = StartLBA + NumberOfBlocks\r
-        subw    %bx, %cx                            # Blocks = Blocks - NumberOfBlocks\r
-        movw    %es, %ax\r
-        shlw    $(BLOCK_SHIFT-4), %bx\r
-        addw    %bx, %ax\r
-        movw    %ax, %es                            # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmpw    $0, %cx\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError: \r
-        pushw %cs\r
-        popw %ds\r
-        leaw ErrorString, %si\r
-        movw $7, %cx\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt: \r
-        movw $0xb800, %ax\r
-        movw %ax, %es\r
-        movw $160, %di\r
-        rep\r
-        movsw\r
-Halt: \r
-        jmp   Halt\r
-\r
-ErrorString: \r
-        .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!', 0x0c\r
-\r
-        # .org     0x01fa # Just for passing build.\r
-LBAOffsetForBootSector: \r
-        .long   0x0\r
-\r
-        # .org     0x01fe # Just for passing build.\r
-        .word   0xaa55\r
-\r
-#******************************************************************************\r
-#******************************************************************************\r
-#******************************************************************************\r
-\r
-.equ                 DELAY_PORT,            0x0ed     # Port to use for 1uS delay\r
-.equ                 KBD_CONTROL_PORT,      0x060     # 8042 control port     \r
-.equ                 KBD_STATUS_PORT,       0x064     # 8042 status port      \r
-.equ                 WRITE_DATA_PORT_CMD,   0x0d1     # 8042 command to write the data port\r
-.equ                 ENABLE_A20_CMD,        0x0df     # 8042 command to enable A20\r
-\r
-        # .org     0x0200 # Just for passing build.\r
-        jmp start\r
-Em64String: \r
-        .byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
-\r
-start:  \r
-        movw %cs, %ax\r
-        movw %ax, %ds\r
-        movw %ax, %es\r
-        movw %ax, %ss\r
-        movw $MyStack, %sp\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[160],'a'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        movl $0, %ebx\r
-        leal MemoryMap, %edi\r
-MemMapLoop: \r
-        movl $0xe820, %eax\r
-        movl $20, %ecx\r
-        movl $0x534d4150, %edx  # 0x534d4150  stands for 'SMAP'\r
-        int $0x15\r
-        jc  MemMapDone\r
-        addl $20, %edi\r
-        cmpl $0, %ebx\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone: \r
-        leal MemoryMap, %eax\r
-        subl %eax, %edi                     # Get the address of the memory map\r
-        movl %edi, MemoryMapSize            # Save the size of the memory map\r
-\r
-        xorl    %ebx, %ebx\r
-        movw    %cs, %bx                    # BX=segment\r
-        shll    $4, %ebx                    # BX="linear" address of segment base\r
-        leal    GDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of gdt\r
-        movl    %eax, gdtr + 2              # Put address of gdt into the gdtr\r
-        leal    IDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of idt\r
-        movl    %eax, idtr + 2              # Put address of idt into the idtr\r
-        leal    MemoryMapSize(%ebx), %edx   # Physical base address of the memory map\r
-\r
-        addl $0x1000, %ebx                  # Source of EFI32\r
-        movl %ebx, JUMP+2\r
-        addl $0x1000, %ebx\r
-        movl %ebx, %esi                     # Source of EFILDR32\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[162],'b'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-#\r
-# Enable A20 Gate \r
-#\r
-\r
-        movw $0x2401, %ax                   # Enable A20 Gate\r
-        int $0x15\r
-        jnc A20GateEnabled                  # Jump if it suceeded\r
-\r
-#\r
-# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-#\r
-\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        movb    $WRITE_DATA_PORT_CMD, %al   # 8042 cmd to write output port\r
-        outb    %al, $KBD_STATUS_PORT       # Send command to the 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        movb    $ENABLE_A20_CMD, %al        # gate address bit 20 on\r
-        outb    %al, $KBD_CONTROL_PORT      # Send command to thre 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        movw    $25, %cx                    # Delay 25 uS for the command to complete on the 8042\r
-Delay25uS: \r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        loop    Delay25uS\r
-Timeout8042: \r
-\r
-\r
-A20GateEnabled: \r
-        movw    $0x0008, %bx                # Flat data descriptor\r
-#\r
-# DISABLE INTERRUPTS - Entering Protected Mode\r
-#\r
-\r
-        cli\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[164],'c'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        .byte   0x66\r
-        lgdt    gdtr\r
-        .byte   0x66\r
-        lidt    idtr\r
-\r
-        movl    %cr0, %eax\r
-        orb     $1, %al\r
-        movl    %eax, %cr0\r
-JUMP: \r
-# jmp far 0010:00020000\r
-        .byte 0x66\r
-        .byte 0xea\r
-        .long 0x00020000\r
-        .word 0x0010\r
-\r
-Empty8042InputBuffer: \r
-        movw $0, %cx\r
-Empty8042Loop: \r
-        outw    %ax, $DELAY_PORT            # Delay 1us\r
-        inb     $KBD_STATUS_PORT, %al       # Read the 8042 Status Port\r
-        andb    $0x2, %al                   # Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               # Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-##############################################################################\r
-# data\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-gdtr:   .word  GDT_END - GDT_BASE - 1       # GDT limit\r
-        .long 0                             # (GDT base gets set above)\r
-##############################################################################\r
-#   global descriptor table (GDT)\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-GDT_BASE: \r
-# null descriptor\r
-.equ                NULL_SEL, .-GDT_BASE\r
-        .word 0         # limit 15:0\r
-        .word 0         # base 15:0\r
-        .byte 0         # base 23:16\r
-        .byte 0         # type\r
-        .byte 0         # limit 19:16, flags\r
-        .byte 0         # base 31:24\r
-\r
-# linear data segment descriptor\r
-.equ            LINEAR_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# linear code segment descriptor\r
-.equ            LINEAR_CODE_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system data segment descriptor\r
-.equ            SYS_DATA_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system code segment descriptor\r
-.equ            SYS_CODE_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE3_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE4_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE5_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-GDT_END: \r
-\r
-        .p2align 1\r
-\r
-\r
-\r
-idtr:   .word IDT_END - IDT_BASE - 1  # IDT limit\r
-        .long 0                       # (IDT base gets set above)\r
-##############################################################################\r
-#   interrupt descriptor table (IDT)\r
-#\r
-#   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-#       mappings.  This implementation only uses the system timer and all other\r
-#       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-#       for convenience.\r
-##############################################################################\r
-\r
-#idt_tag db "IDT",0     \r
-        .p2align 1\r
-\r
-IDT_BASE: \r
-# divide by zero (INT 0)\r
-.equ                DIV_ZERO_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# debug exception (INT 1)\r
-.equ                DEBUG_EXCEPT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# NMI (INT 2)\r
-.equ                NMI_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# soft breakpoint (INT 3)\r
-.equ                BREAKPOINT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# overflow (INT 4)\r
-.equ                OVERFLOW_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# bounds check (INT 5)\r
-.equ                BOUNDS_CHECK_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# invalid opcode (INT 6)\r
-.equ                INVALID_OPCODE_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# device not available (INT 7)\r
-.equ                DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# double fault (INT 8)\r
-.equ                DOUBLE_FAULT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# Coprocessor segment overrun - reserved (INT 9)\r
-.equ                RSVD_INTR_SEL1, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# invalid TSS (INT 0ah)\r
-.equ                INVALID_TSS_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# segment not present (INT 0bh)\r
-.equ                SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# stack fault (INT 0ch)\r
-.equ                STACK_FAULT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# general protection (INT 0dh)\r
-.equ                GP_FAULT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# page fault (INT 0eh)\r
-.equ                PAGE_FAULT_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# Intel reserved - do not use (INT 0fh)\r
-.equ                RSVD_INTR_SEL2, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# floating point error (INT 10h)\r
-.equ                FLT_POINT_ERR_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# alignment check (INT 11h)\r
-.equ                ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# machine check (INT 12h)\r
-.equ                MACHINE_CHECK_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# SIMD floating-point exception (INT 13h)\r
-.equ                SIMD_EXCEPTION_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        .fill  85 * 8, 1, 0\r
-\r
-# IRQ 0 (System timer) - (INT 68h)\r
-.equ                IRQ0_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-.equ                IRQ1_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-.equ                IRQ2_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 3 (COM 2) - (INT 6bh)\r
-.equ                IRQ3_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 4 (COM 1) - (INT 6ch)\r
-.equ                IRQ4_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 5 (LPT 2) - (INT 6dh)\r
-.equ                IRQ5_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 6 (Floppy controller) - (INT 6eh)\r
-.equ                IRQ6_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 7 (LPT 1) - (INT 6fh)\r
-.equ                IRQ7_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 8 (RTC Alarm) - (INT 70h)\r
-.equ                IRQ8_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 9 - (INT 71h)\r
-.equ                IRQ9_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 10 - (INT 72h)\r
-.equ                 IRQ10_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 11 - (INT 73h)\r
-.equ                 IRQ11_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 12 (PS/2 mouse) - (INT 74h)\r
-.equ                 IRQ12_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 13 (Floating point error) - (INT 75h)\r
-.equ                 IRQ13_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 14 (Secondary IDE) - (INT 76h)\r
-.equ                 IRQ14_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-# IRQ 15 (Primary IDE) - (INT 77h)\r
-.equ                 IRQ15_SEL, .-IDT_BASE\r
-        .word 0             # offset 15:0\r
-        .word SYS_CODE_SEL  # selector 15:0\r
-        .byte 0             # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # (10001110)type = 386 interrupt gate, present\r
-        .word 0             # offset 31:16\r
-\r
-IDT_END: \r
-\r
-        .p2align 1\r
-\r
-MemoryMapSize:  .long 0\r
-MemoryMap:  .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        .org 0x0fe0\r
-MyStack:    \r
-        # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        #    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        #    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        #    8259.c\r
-\r
-        int $8\r
-        iret\r
-\r
-        int $9\r
-        iret\r
-\r
-        int $10\r
-        iret\r
-\r
-        int $11\r
-        iret\r
-\r
-        int $12\r
-        iret\r
-\r
-        int $13\r
-        iret\r
-\r
-        int $14\r
-        iret\r
-\r
-        int $15\r
-        iret\r
-\r
-\r
-        .org 0x0ffe\r
-BlockSignature: \r
-        .word 0xaa55\r
diff --git a/DuetPkg/BootSector/start16.asm b/DuetPkg/BootSector/start16.asm
deleted file mode 100644 (file)
index 05d0b2d..0000000
+++ /dev/null
@@ -1,909 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    start16.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE    EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT   EQU     5\r
-BLOCK_SIZE                  EQU     0200h\r
-BLOCK_MASK                  EQU     01ffh\r
-BLOCK_SHIFT                 EQU     9\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-PhysicalDrive     db  0             ; PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead       db  0             ; Current Head        - 8 bits\r
-Signature         db  0             ; Signature           - 8 bits  - ignored\r
-VolId             db  "    "        ; Volume Serial Number- 4 bytes\r
-FatLabel          db  "           " ; Label               - 11 bytes\r
-SystemId          db  "FAT16   "    ; SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-      ; ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      ; cx = Start Cluster of EfiLdr\r
-      ; dx = Start Cluster of Efivar.bin\r
-\r
-; Re use the BPB data stored in Boot Sector\r
-        mov     bp,07c00h\r
-\r
-        push    cx\r
-; Read Efivar.bin\r
-;       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        mov     ax,01900h\r
-        mov     es,ax\r
-        test    dx,dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        mov     al,1\r
-NoVarStore:\r
-        push    es\r
-; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        mov     byte ptr es:[4],al\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize:\r
-        mov     di,dx\r
-        cmp     dword ptr ds:[di+2], 04000h\r
-        mov     al,2\r
-        jne     NoVarStore\r
-\r
-LoadVarStore:\r
-        mov     al,0\r
-        mov     byte ptr es:[4],al\r
-        mov     cx,word ptr[di]\r
-;       ES:DI = 1500:0\r
-        xor     di,di\r
-        push    es\r
-        mov     ax,01500h\r
-        mov     es,ax\r
-        call    ReadFile\r
-SaveVolumeId:\r
-        pop     es\r
-        mov     ax,word ptr [bp+VolId]\r
-        mov     word ptr es:[0],ax                  ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        mov     ax,word ptr [bp+VolId+2]\r
-        mov     word ptr es:[2],ax\r
-\r
-; Read Efildr\r
-        pop     cx\r
-;       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-;       ES:DI = 2000:0, first cluster will be read again\r
-        xor     di,di                               ; di = 0\r
-        mov     ax,02000h\r
-        mov     es,ax\r
-        call    ReadFile\r
-        mov     ax,cs\r
-        mov     word ptr cs:[JumpSegment],ax\r
-\r
-JumpFarInstruction:\r
-        db      0eah\r
-JumpOffset:\r
-        dw      0200h\r
-JumpSegment:\r
-        dw      2000h\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; ReadFile\r
-;\r
-; Arguments:\r
-;   CX    = Start Cluster of File\r
-;   ES:DI = Buffer to store file content read from disk\r
-;\r
-; Return:\r
-;   (ES << 4 + DI) = end of file content Buffer\r
-;\r
-; ****************************************************************************\r
-ReadFile:\r
-; si      = NumberOfClusters\r
-; cx      = ClusterNumber\r
-; dx      = CachedFatSectorNumber\r
-; ds:0000 = CacheFatSectorBuffer\r
-; es:di   = Buffer to load file\r
-; bx      = NextClusterNumber\r
-        pusha\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        push    cx                                  ; Push Start Cluster onto stack\r
-        mov     dx,0fffh                            ; CachedFatSectorNumber = 0xfff\r
-FatChainLoop:\r
-        mov     ax,cx                               ; ax = ClusterNumber    \r
-        and     ax,0fff8h                           ; ax = ax & 0xfff8\r
-        cmp     ax,0fff8h                           ; See if this is the last cluster\r
-        je      FoundLastCluster                    ; Jump if last cluster found\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        shl     ax,1                                ; FatOffset = ClusterNumber * 2\r
-        push    si                                  ; Save si\r
-        mov     si,ax                               ; si = FatOffset\r
-        shr     ax,BLOCK_SHIFT                      ; ax = FatOffset >> BLOCK_SHIFT\r
-        add     ax,word ptr [bp+ReservedSectors]    ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        and     si,BLOCK_MASK                       ; si = FatOffset & BLOCK_MASK\r
-        cmp     ax,dx                               ; Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        mov     bx,2                                \r
-        push    es\r
-        push    ds\r
-        pop     es\r
-        call    ReadBlocks                          ; Read 2 blocks starting at AX storing at ES:DI\r
-        pop     es\r
-        mov     dx,ax                               ; CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead:\r
-        mov     bx,word ptr [si]                    ; bx = NextClusterNumber\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        pop     si                                  ; Restore si\r
-        dec     bx                                  ; bx = NextClusterNumber - 1\r
-        cmp     bx,cx                               ; See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        inc     bx                                  ; bx = NextClusterNumber\r
-        inc     si                                  ; NumberOfClusters++\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters:\r
-        inc     bx\r
-        pop     ax                                  ; ax = StartCluster\r
-        push    bx                                  ; StartCluster = NextClusterNumber\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        sub     ax,2                                ; ax = StartCluster - 2\r
-        xor     bh,bh                               \r
-        mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-        mul     bx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-        add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        push    ax                                  ; save start sector\r
-        mov     ax,si                               ; ax = NumberOfClusters\r
-        mul     bx                                  ; ax = NumberOfClusters * SectorsPerCluster\r
-        mov     bx,ax                               ; bx = Number of Sectors\r
-        pop     ax                                  ; ax = Start Sector\r
-        call    ReadBlocks\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster:\r
-        pop     cx\r
-        popa\r
-        ret\r
-\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-        pusha\r
-        add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-        add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-        mov     esi,eax                             ; esi = Start LBA\r
-        mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-        mov     bp,07bfch                           ; bp = 0x7bfc\r
-        mov     eax,esi                             ; eax = Start LBA\r
-        xor     edx,edx                             ; edx = 0\r
-        movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-        div     ebx                                 ; ax = StartLBA / MaxSector\r
-        inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-\r
-        mov     bx,word ptr [bp]                    ; bx = MaxSector\r
-        sub     bx,dx                               ; bx = MaxSector - Sector\r
-        inc     bx                                  ; bx = MaxSector - Sector + 1\r
-        cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-        push    ax                                  ; save ax\r
-        mov     ax,es                               ; ax = es\r
-        shr     ax,(BLOCK_SHIFT-4)                  ; ax = Number of blocks into mem system\r
-        and     ax,07fh                             ; ax = Number of blocks into current seg\r
-        add     ax,bx                               ; ax = End Block number of transfer\r
-        cmp     ax,080h                             ; See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               ; Branch if not crossing 64K boundry\r
-        sub     ax,080h                             ; ax = Number of blocks past 64K boundry\r
-        sub     bx,ax                               ; Decrease transfer size by block overage\r
-NotCrossing64KBoundry:\r
-        pop     ax                                  ; restore ax\r
-\r
-        push    cx\r
-        mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xor     dx,dx                               ; dx = 0\r
-        div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    ; dx = ax % (MaxHead + 1) = Head\r
-\r
-        push    bx                                  ; Save number of blocks to transfer\r
-        mov     dh,dl                               ; dh = Head\r
-        mov     bp,07c00h                           ; bp = 0x7c00\r
-        mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-        mov     ch,al                               ; ch = Cylinder\r
-        mov     al,bl                               ; al = Blocks\r
-        mov     ah,2                                ; ah = Function 2\r
-        mov     bx,di                               ; es:bx = Buffer address\r
-        int     013h\r
-        jc      DiskError\r
-        pop     bx\r
-        pop     cx\r
-        movzx   ebx,bx\r
-        add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-        sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-        mov     ax,es\r
-        shl     bx,(BLOCK_SHIFT-4)\r
-        add     ax,bx\r
-        mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmp     cx,0\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError:\r
-        push cs\r
-        pop  ds\r
-        lea  si, [ErrorString]\r
-        mov  cx, 7\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt:\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  di,160\r
-        rep  movsw\r
-Halt:\r
-        jmp   Halt\r
-\r
-ErrorString:\r
-        db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-        org     01fah\r
-LBAOffsetForBootSector:\r
-        dd      0h\r
-\r
-        org     01feh\r
-        dw      0aa55h\r
-\r
-;******************************************************************************\r
-;******************************************************************************\r
-;******************************************************************************\r
-\r
-DELAY_PORT           equ     0edh    ; Port to use for 1uS delay\r
-KBD_CONTROL_PORT     equ     060h    ; 8042 control port     \r
-KBD_STATUS_PORT      equ     064h    ; 8042 status port      \r
-WRITE_DATA_PORT_CMD  equ     0d1h    ; 8042 command to write the data port\r
-ENABLE_A20_CMD       equ     0dfh    ; 8042 command to enable A20\r
-\r
-        org     200h\r
-        jmp start\r
-Em64String:\r
-        db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch\r
-\r
-start:  \r
-        mov ax,cs\r
-        mov ds,ax\r
-        mov es,ax\r
-        mov ss,ax\r
-        mov sp,MyStack\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[160],'a'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        mov ebx,0\r
-        lea edi,MemoryMap\r
-MemMapLoop:\r
-        mov eax,0e820h\r
-        mov ecx,20\r
-        mov edx,'SMAP'\r
-        int 15h\r
-        jc  MemMapDone\r
-        add edi,20\r
-        cmp ebx,0\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone:\r
-        lea eax,MemoryMap\r
-        sub edi,eax                         ; Get the address of the memory map\r
-        mov dword ptr [MemoryMapSize],edi   ; Save the size of the memory map\r
-\r
-        xor     ebx,ebx\r
-        mov     bx,cs                       ; BX=segment\r
-        shl     ebx,4                       ; BX="linear" address of segment base\r
-        lea     eax,[GDT_BASE + ebx]        ; EAX=PHYSICAL address of gdt\r
-        mov     dword ptr [gdtr + 2],eax    ; Put address of gdt into the gdtr\r
-        lea     eax,[IDT_BASE + ebx]        ; EAX=PHYSICAL address of idt\r
-        mov     dword ptr [idtr + 2],eax    ; Put address of idt into the idtr\r
-        lea     edx,[MemoryMapSize + ebx]   ; Physical base address of the memory map\r
-\r
-        add ebx,01000h                      ; Source of EFI32\r
-        mov dword ptr [JUMP+2],ebx\r
-        add ebx,01000h\r
-        mov esi,ebx                         ; Source of EFILDR32\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[162],'b'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-;\r
-; Enable A20 Gate \r
-;\r
-\r
-        mov ax,2401h                        ; Enable A20 Gate\r
-        int 15h\r
-        jnc A20GateEnabled                  ; Jump if it suceeded\r
-\r
-;\r
-; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-;\r
-\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        mov     al,WRITE_DATA_PORT_CMD      ; 8042 cmd to write output port\r
-        out     KBD_STATUS_PORT,al          ; Send command to the 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        mov     al,ENABLE_A20_CMD           ; gate address bit 20 on\r
-        out     KBD_CONTROL_PORT,al         ; Send command to thre 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        mov     cx,25                       ; Delay 25 uS for the command to complete on the 8042\r
-Delay25uS:\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        loop    Delay25uS                       \r
-Timeout8042:\r
-\r
-\r
-A20GateEnabled:\r
-        mov     bx,0008h                    ; Flat data descriptor\r
-;\r
-; DISABLE INTERRUPTS - Entering Protected Mode\r
-;\r
-\r
-        cli                             \r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[164],'c'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        db      66h     \r
-        lgdt    fword ptr [gdtr]\r
-        db      66h     \r
-        lidt    fword ptr [idtr]\r
-\r
-        mov     eax,cr0\r
-        or      al,1\r
-        mov     cr0,eax\r
-JUMP:\r
-; jmp far 0010:00020000\r
-        db  066h\r
-        db  0eah\r
-        dd  000020000h\r
-        dw  00010h\r
-\r
-Empty8042InputBuffer:\r
-        mov cx,0\r
-Empty8042Loop:\r
-        out     DELAY_PORT,ax               ; Delay 1us\r
-        in      al,KBD_STATUS_PORT          ; Read the 8042 Status Port\r
-        and     al,02h                      ; Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               ; Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; data\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-gdtr    dw GDT_END - GDT_BASE - 1   ; GDT limit\r
-        dd 0                        ; (GDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   global descriptor table (GDT)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-public GDT_BASE\r
-GDT_BASE:\r
-; null descriptor\r
-NULL_SEL            equ $-GDT_BASE\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
-\r
-; linear data segment descriptor\r
-LINEAR_SEL      equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; linear code segment descriptor\r
-LINEAR_CODE_SEL equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system data segment descriptor\r
-SYS_DATA_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system code segment descriptor\r
-SYS_CODE_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE3_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE4_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE5_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-GDT_END:\r
-\r
-        align 02h\r
-\r
-\r
-\r
-idtr            dw IDT_END - IDT_BASE - 1   ; IDT limit\r
-        dd 0                        ; (IDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   interrupt descriptor table (IDT)\r
-;\r
-;   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-;       mappings.  This implementation only uses the system timer and all other\r
-;       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-;       for convenience.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-;idt_tag db "IDT",0     \r
-        align 02h\r
-\r
-public IDT_BASE\r
-IDT_BASE:\r
-; divide by zero (INT 0)\r
-DIV_ZERO_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; debug exception (INT 1)\r
-DEBUG_EXCEPT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; NMI (INT 2)\r
-NMI_SEL             equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; soft breakpoint (INT 3)\r
-BREAKPOINT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; overflow (INT 4)\r
-OVERFLOW_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; bounds check (INT 5)\r
-BOUNDS_CHECK_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; invalid opcode (INT 6)\r
-INVALID_OPCODE_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; device not available (INT 7)\r
-DEV_NOT_AVAIL_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; double fault (INT 8)\r
-DOUBLE_FAULT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Coprocessor segment overrun - reserved (INT 9)\r
-RSVD_INTR_SEL1      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; invalid TSS (INT 0ah)\r
-INVALID_TSS_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; segment not present (INT 0bh)\r
-SEG_NOT_PRESENT_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; stack fault (INT 0ch)\r
-STACK_FAULT_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; general protection (INT 0dh)\r
-GP_FAULT_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; page fault (INT 0eh)\r
-PAGE_FAULT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Intel reserved - do not use (INT 0fh)\r
-RSVD_INTR_SEL2      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; floating point error (INT 10h)\r
-FLT_POINT_ERR_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; alignment check (INT 11h)\r
-ALIGNMENT_CHECK_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; machine check (INT 12h)\r
-MACHINE_CHECK_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; SIMD floating-point exception (INT 13h)\r
-SIMD_EXCEPTION_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        db (85 * 8) dup(0)\r
-        \r
-; IRQ 0 (System timer) - (INT 68h)\r
-IRQ0_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-IRQ1_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-IRQ2_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 3 (COM 2) - (INT 6bh)\r
-IRQ3_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 4 (COM 1) - (INT 6ch)\r
-IRQ4_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 5 (LPT 2) - (INT 6dh)\r
-IRQ5_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 6 (Floppy controller) - (INT 6eh)\r
-IRQ6_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 7 (LPT 1) - (INT 6fh)\r
-IRQ7_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 8 (RTC Alarm) - (INT 70h)\r
-IRQ8_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 9 - (INT 71h)\r
-IRQ9_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 10 - (INT 72h)\r
-IRQ10_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 11 - (INT 73h)\r
-IRQ11_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 12 (PS/2 mouse) - (INT 74h)\r
-IRQ12_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 13 (Floating point error) - (INT 75h)\r
-IRQ13_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 14 (Secondary IDE) - (INT 76h)\r
-IRQ14_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 15 (Primary IDE) - (INT 77h)\r
-IRQ15_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-IDT_END:\r
-\r
-        align 02h\r
-\r
-MemoryMapSize   dd  0\r
-MemoryMap   dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        org 0fe0h\r
-MyStack:    \r
-        ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        ;    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        ;    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        ;    8259.c\r
-                \r
-        int 8\r
-        iret\r
-        \r
-        int 9\r
-        iret\r
-        \r
-        int 10\r
-        iret\r
-        \r
-        int 11\r
-        iret\r
-        \r
-        int 12\r
-        iret\r
-        \r
-        int 13\r
-        iret\r
-        \r
-        int 14\r
-        iret\r
-        \r
-        int 15\r
-        iret\r
-        \r
-        \r
-        org 0ffeh\r
-BlockSignature:\r
-        dw  0aa55h\r
-\r
-        end \r
diff --git a/DuetPkg/BootSector/start32.S b/DuetPkg/BootSector/start32.S
deleted file mode 100644 (file)
index dc683f5..0000000
+++ /dev/null
@@ -1,927 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    start32.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-        #.MODEL small\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                        FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                        FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                        BLOCK_SIZE, 0x0200\r
-.equ                        BLOCK_MASK, 0x01ff\r
-.equ                        BLOCK_SHIFT, 9\r
-\r
-        .org 0x0\r
-\r
-.global _start\r
-_start:\r
-\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId:               .ascii  "INTEL   "    # OemId                           - 8 bytes\r
-SectorSize:          .word  0              # Sector Size                     - 2 bytes\r
-SectorsPerCluster:   .byte  0              # Sector Per Cluster              - 1 byte\r
-ReservedSectors:     .word  0              # Reserved Sectors                - 2 bytes\r
-NoFats:              .byte  0              # Number of FATs                  - 1 byte\r
-RootEntries:         .word  0              # Root Entries                    - 2 bytes\r
-Sectors:             .word  0              # Number of Sectors               - 2 bytes\r
-Media:               .byte  0              # Media                           - 1 byte\r
-SectorsPerFat16:     .word  0              # Sectors Per FAT for FAT12/FAT16 - 2 byte\r
-SectorsPerTrack:     .word  0              # Sectors Per Track               - 2 bytes\r
-Heads:               .word  0              # Heads                           - 2 bytes\r
-HiddenSectors:       .long  0              # Hidden Sectors                  - 4 bytes\r
-LargeSectors:        .long  0              # Large Sectors                   - 4 bytes\r
-\r
-#******************************************************************************\r
-#\r
-#The structure for FAT32 starting at offset 36 of the boot sector. (At this point, \r
-#the BPB/boot sector for FAT12 and FAT16 differs from the BPB/boot sector for FAT32.)\r
-#\r
-#******************************************************************************\r
-\r
-SectorsPerFat32:     .long  0              # Sectors Per FAT for FAT32       - 4 bytes\r
-ExtFlags:            .word  0              # Mirror Flag                     - 2 bytes\r
-FSVersion:           .word  0              # File System Version             - 2 bytes\r
-RootCluster:         .long  0              # 1st Cluster Number of Root Dir  - 4 bytes\r
-FSInfo:              .word  0              # Sector Number of FSINFO         - 2 bytes\r
-BkBootSector:        .word  0              # Sector Number of Bk BootSector  - 2 bytes\r
-Reserved:            .fill 12,1,0          # Reserved Field                  - 12 bytes\r
-PhysicalDrive:       .byte  0              # Physical Drive Number           - 1 byte\r
-Reserved1:           .byte  0              # Reserved Field                  - 1 byte\r
-Signature:           .byte  0              # Extended Boot Signature         - 1 byte\r
-VolId:               .ascii  "    "        # Volume Serial Number            - 4 bytes\r
-FatLabel:            .ascii  "           " # Volume Label                    - 11 bytes\r
-FileSystemType:      .ascii  "FAT32   "    # File System Type                - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-        #ASSUME ds:@code\r
-        #ASSUME ss:@code\r
-      # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      # cx = Start Cluster of EfiLdr\r
-      # dx = Start Cluster of Efivar.bin\r
-\r
-# Re use the BPB data stored in Boot Sector\r
-        movw    $0x7c00, %bp\r
-\r
-\r
-        pushw   %cx\r
-# Read Efivar.bin\r
-#       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        movw    $0x1900, %ax\r
-        movw    %ax, %es\r
-        testw   %dx, %dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        movb    $1, %al\r
-NoVarStore: \r
-        pushw   %es\r
-# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        movb    %al, %es:4\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize: \r
-        movw    %dx, %di\r
-        cmpl    $0x4000, %ds:2(%di)\r
-        movb    $2, %al\r
-        jne     NoVarStore\r
-\r
-LoadVarStore: \r
-        movb    $0, %al\r
-        movb    %al, %es:4\r
-        movw    (%di), %cx\r
-#       ES:DI = 1500:0\r
-        xorw    %di, %di\r
-        pushw   %es\r
-        movw    $0x1500, %ax\r
-        movw    %ax, %es\r
-        call    ReadFile\r
-SaveVolumeId: \r
-        popw    %es\r
-        movw    VolId(%bp), %ax\r
-        movw    %ax, %es:0                       # Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        movw    VolId+2(%bp), %ax\r
-        movw    %ax, %es:2\r
-\r
-# Read Efildr\r
-        popw    %cx\r
-#       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-#       ES:DI = 2000:0, first cluster will be read again\r
-        xorw    %di, %di                            # di = 0\r
-        movw    $0x2000, %ax\r
-        movw    %ax, %es\r
-        call    ReadFile\r
-        movw    %cs, %ax\r
-        movw    %ax, %cs:JumpSegment\r
-JumpFarInstruction: \r
-        .byte   0xea\r
-JumpOffset: \r
-        .word   0x200\r
-JumpSegment: \r
-        .word   0x2000\r
-\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# ReadFile\r
-#\r
-# Arguments:\r
-#   CX    = Start Cluster of File\r
-#   ES:DI = Buffer to store file content read from disk\r
-#\r
-# Return:\r
-#   (ES << 4 + DI) = end of file content Buffer\r
-#\r
-# ****************************************************************************\r
-ReadFile: \r
-# si      = NumberOfClusters\r
-# cx      = ClusterNumber\r
-# dx      = CachedFatSectorNumber\r
-# ds:0000 = CacheFatSectorBuffer\r
-# es:di   = Buffer to load file\r
-# bx      = NextClusterNumber\r
-        pusha\r
-        movw    $1, %si                             # NumberOfClusters = 1\r
-        pushw   %cx                                 # Push Start Cluster onto stack\r
-        movw    $0xfff, %dx                         # CachedFatSectorNumber = 0xfff\r
-FatChainLoop: \r
-        movw    %cx, %ax                            # ax = ClusterNumber    \r
-        andw    $0xfff8, %ax                        # ax = ax & 0xfff8\r
-        cmpw    $0xfff8, %ax                        # See if this is the last cluster\r
-        je      FoundLastCluster                    # Jump if last cluster found\r
-        movw    %cx, %ax                            # ax = ClusterNumber\r
-        shlw    $2, %ax                             # FatOffset = ClusterNumber * 4\r
-        pushw   %si                                 # Save si\r
-        movw    %ax, %si                            # si = FatOffset\r
-        shrw    $BLOCK_SHIFT, %ax                   # ax = FatOffset >> BLOCK_SHIFT\r
-        addw    ReservedSectors(%bp), %ax           # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        andw    $BLOCK_MASK, %si                    # si = FatOffset & BLOCK_MASK\r
-        cmpw    %dx, %ax                            # Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        movw    $2, %bx\r
-        pushw   %es\r
-        pushw   %ds\r
-        popw    %es\r
-        call    ReadBlocks                          # Read 2 blocks starting at AX storing at ES:DI\r
-        popw    %es\r
-        movw    %ax, %dx                            # CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead: \r
-        movw    (%si), %bx                          # bx = NextClusterNumber\r
-        movw    %cx, %ax                            # ax = ClusterNumber\r
-        popw    %si                                 # Restore si\r
-        decw    %bx                                 # bx = NextClusterNumber - 1\r
-        cmpw    %cx, %bx                            # See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        incw    %bx                                 # bx = NextClusterNumber\r
-        incw    %si                                 # NumberOfClusters++\r
-        movw    %bx, %cx                            # ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters: \r
-        incw    %bx\r
-        popw    %ax                                 # ax = StartCluster\r
-        pushw   %bx                                 # StartCluster = NextClusterNumber\r
-        movw    %bx, %cx                            # ClusterNumber = NextClusterNumber\r
-        subw    $2, %ax                             # ax = StartCluster - 2\r
-        xorb    %bh, %bh\r
-        movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-        mulw    %bx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-        addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        pushw   %ax                                 # save start sector\r
-        movw    %si, %ax                            # ax = NumberOfClusters\r
-        mulw    %bx                                 # ax = NumberOfClusters * SectorsPerCluster\r
-        movw    %ax, %bx                            # bx = Number of Sectors\r
-        popw    %ax                                 # ax = Start Sector\r
-        call    ReadBlocks\r
-        movw    $1, %si                             # NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster: \r
-        popw    %cx\r
-        popa\r
-        ret\r
-\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-        pusha\r
-        addl    LBAOffsetForBootSector(%bp), %eax            # Add LBAOffsetForBootSector to Start LBA\r
-        addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-        movl    %eax, %esi                          # esi = Start LBA\r
-        movw    %bx, %cx                            # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-        movw    $0x7bfc, %bp                        # bp = 0x7bfc\r
-        movl    %esi, %eax                          # eax = Start LBA\r
-        xorl    %edx, %edx                          # edx = 0\r
-        movzwl  (%bp), %ebx                         # bx = MaxSector\r
-        divl    %ebx                                # ax = StartLBA / MaxSector\r
-        incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-\r
-        movw    (%bp), %bx                          # bx = MaxSector\r
-        subw    %dx, %bx                            # bx = MaxSector - Sector\r
-        incw    %bx                                 # bx = MaxSector - Sector + 1\r
-        cmpw    %bx, %cx                            # Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        movw    %cx, %bx                            # bx = Blocks\r
-LimitTransfer: \r
-        pushw   %ax                                 # save ax\r
-        movw    %es, %ax                            # ax = es\r
-        shrw    $(BLOCK_SHIFT-4), %ax                # ax = Number of blocks into mem system\r
-        andw    $0x7f, %ax                          # ax = Number of blocks into current seg\r
-        addw    %bx, %ax                            # ax = End Block number of transfer\r
-        cmpw    $0x80, %ax                          # See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               # Branch if not crossing 64K boundry\r
-        subw    $0x80, %ax                          # ax = Number of blocks past 64K boundry\r
-        subw    %ax, %bx                            # Decrease transfer size by block overage\r
-NotCrossing64KBoundry: \r
-        popw    %ax                                 # restore ax\r
-\r
-        pushw   %cx\r
-        movb    %dl, %cl                            # cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xorw    %dx, %dx                            # dx = 0\r
-        divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    # dx = ax % (MaxHead + 1) = Head\r
-\r
-        pushw   %bx                                 # Save number of blocks to transfer\r
-        movb    %dl, %dh                            # dh = Head\r
-        movw    $0x7c00, %bp                        # bp = 0x7c00\r
-        movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-        movb    %al, %ch                            # ch = Cylinder\r
-        movb    %bl, %al                            # al = Blocks\r
-        movb    $2, %ah                             # ah = Function 2\r
-        movw    %di, %bx                            # es:bx = Buffer address\r
-        int     $0x13\r
-        jc      DiskError\r
-        popw    %bx\r
-        popw    %cx\r
-        movzwl  %bx, %ebx\r
-        addl    %ebx, %esi                          # StartLBA = StartLBA + NumberOfBlocks\r
-        subw    %bx, %cx                            # Blocks = Blocks - NumberOfBlocks\r
-        movw    %es, %ax\r
-        shlw    $(BLOCK_SHIFT-4), %bx\r
-        addw    %bx, %ax\r
-        movw    %ax, %es                            # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmpw    $0, %cx\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError: \r
-        pushw %cs\r
-        popw %ds\r
-        leaw ErrorString, %si\r
-        movw $7, %cx\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt: \r
-        movw $0xb800, %ax\r
-        movw %ax, %es\r
-        movw $160, %di\r
-        rep\r
-        movsw\r
-Halt: \r
-        jmp   Halt\r
-\r
-ErrorString: \r
-        .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!', 0x0c\r
-\r
-        .org     0x01fa\r
-LBAOffsetForBootSector: \r
-        .long   0x0\r
-\r
-        .org    0x01fe\r
-        .word   0xaa55\r
-\r
-#******************************************************************************\r
-#******************************************************************************\r
-#******************************************************************************\r
-\r
-.equ                 DELAY_PORT, 0x0ed           # Port to use for 1uS delay\r
-.equ                 KBD_CONTROL_PORT, 0x060     # 8042 control port     \r
-.equ                 KBD_STATUS_PORT, 0x064      # 8042 status port      \r
-.equ                 WRITE_DATA_PORT_CMD, 0x0d1  # 8042 command to write the data port\r
-.equ                 ENABLE_A20_CMD, 0x0df       # 8042 command to enable A20\r
-\r
-        .org    0x200\r
-        jmp start\r
-Em64String: \r
-        .byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
-\r
-start:  \r
-        movw %cs, %ax\r
-        movw %ax, %ds\r
-        movw %ax, %es\r
-        movw %ax, %ss\r
-        movw $MyStack, %sp\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[160],'a'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        movl $0, %ebx\r
-        leal MemoryMap, %edi\r
-MemMapLoop: \r
-        movl $0xe820, %eax\r
-        movl $20, %ecx\r
-        movl $0x534d4150, %edx  # 0x534d4150 = 'SMAP' \r
-        int  $0x15\r
-        jc  MemMapDone\r
-        addl $20, %edi\r
-        cmpl $0, %ebx\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone: \r
-        leal MemoryMap, %eax\r
-        subl %eax, %edi                     # Get the address of the memory map\r
-        movl %edi, MemoryMapSize            # Save the size of the memory map\r
-\r
-        xorl    %ebx, %ebx\r
-        movw    %cs, %bx                    # BX=segment\r
-        shll    $4, %ebx                    # BX="linear" address of segment base\r
-        leal    GDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of gdt\r
-        movl    %eax, gdtr + 2            # Put address of gdt into the gdtr\r
-        leal    IDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of idt\r
-        movl    %eax, idtr + 2            # Put address of idt into the idtr\r
-        leal    MemoryMapSize(%ebx), %edx   # Physical base address of the memory map\r
-\r
-        addl $0x1000, %ebx                  # Source of EFI32\r
-        movl %ebx, JUMP+2\r
-        addl $0x1000, %ebx\r
-        movl %ebx, %esi                     # Source of EFILDR32\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[162],'b'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-#\r
-# Enable A20 Gate \r
-#\r
-\r
-        movw $0x2401, %ax                   # Enable A20 Gate\r
-        int $0x15\r
-        jnc A20GateEnabled                  # Jump if it suceeded\r
-\r
-#\r
-# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-#\r
-\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        movb    $WRITE_DATA_PORT_CMD, %al   # 8042 cmd to write output port\r
-        outb    %al, $KBD_STATUS_PORT       # Send command to the 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        movb    $ENABLE_A20_CMD, %al        # gate address bit 20 on\r
-        outb    %al, $KBD_CONTROL_PORT      # Send command to thre 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        movw    $25, %cx                    # Delay 25 uS for the command to complete on the 8042\r
-Delay25uS: \r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        loopl   Delay25uS\r
-Timeout8042: \r
-\r
-\r
-A20GateEnabled: \r
-        movw    $0x0008, %bx                # Flat data descriptor\r
-#\r
-# DISABLE INTERRUPTS - Entering Protected Mode\r
-#\r
-\r
-        cli\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[164],'c'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        .byte   0x66\r
-        lgdt    gdtr\r
-        .byte   0x66\r
-        lidt    idtr\r
-\r
-        movl    %cr0, %eax\r
-        orb     $1, %al\r
-        movl    %eax, %cr0\r
-JUMP: \r
-# jmp far 0010:00020000\r
-        .byte 0x66\r
-        .byte 0xea\r
-        .long 0x00020000\r
-        .word 0x0010\r
-\r
-Empty8042InputBuffer: \r
-        movw $0, %cx\r
-Empty8042Loop: \r
-        outw    %ax, $DELAY_PORT            # Delay 1us\r
-        inb     $KBD_STATUS_PORT, %al       # Read the 8042 Status Port\r
-        andb    $0x2, %al                   # Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               # Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-##############################################################################\r
-# data\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-gdtr:    .word GDT_END - GDT_BASE - 1   \r
-        .long 0                     # (GDT base gets set above)\r
-##############################################################################\r
-#   global descriptor table (GDT)\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-GDT_BASE: \r
-# null descriptor\r
-.equ                NULL_SEL, .-GDT_BASE\r
-        .word 0         # limit 15:0\r
-        .word 0         # base 15:0\r
-        .byte 0         # base 23:16\r
-        .byte 0         # type\r
-        .byte 0         # limit 19:16, flags\r
-        .byte 0         # base 31:24\r
-\r
-# linear data segment descriptor\r
-.equ            LINEAR_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF      # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# linear code segment descriptor\r
-.equ            LINEAR_CODE_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF      # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system data segment descriptor\r
-.equ            SYS_DATA_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF      # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system code segment descriptor\r
-.equ            SYS_CODE_SEL, .-GDT_BASE\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF      # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE3_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE4_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE5_SEL, .-GDT_BASE\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-GDT_END: \r
-\r
-        .p2align 1\r
-\r
-\r
-\r
-idtr:            .word IDT_END - IDT_BASE - 1  \r
-        .long 0                     # (IDT base gets set above)\r
-##############################################################################\r
-#   interrupt descriptor table (IDT)\r
-#\r
-#   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-#       mappings.  This implementation only uses the system timer and all other\r
-#       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-#       for convenience.\r
-##############################################################################\r
-\r
-#idt_tag db "IDT",0     \r
-        .p2align 1\r
-\r
-IDT_BASE: \r
-# divide by zero (INT 0)\r
-.equ                DIV_ZERO_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# debug exception (INT 1)\r
-.equ                DEBUG_EXCEPT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# NMI (INT 2)\r
-.equ                NMI_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# soft breakpoint (INT 3)\r
-.equ                BREAKPOINT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# overflow (INT 4)\r
-.equ                OVERFLOW_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# bounds check (INT 5)\r
-.equ                BOUNDS_CHECK_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# invalid opcode (INT 6)\r
-.equ                INVALID_OPCODE_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# device not available (INT 7)\r
-.equ                DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# double fault (INT 8)\r
-.equ                DOUBLE_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# Coprocessor segment overrun - reserved (INT 9)\r
-.equ                RSVD_INTR_SEL1, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# invalid TSS (INT 0ah)\r
-.equ                INVALID_TSS_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# segment not present (INT 0bh)\r
-.equ                SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# stack fault (INT 0ch)\r
-.equ                STACK_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# general protection (INT 0dh)\r
-.equ                GP_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# page fault (INT 0eh)\r
-.equ                PAGE_FAULT_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# Intel reserved - do not use (INT 0fh)\r
-.equ                RSVD_INTR_SEL2, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# floating point error (INT 10h)\r
-.equ                FLT_POINT_ERR_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# alignment check (INT 11h)\r
-.equ                ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# machine check (INT 12h)\r
-.equ                MACHINE_CHECK_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# SIMD floating-point exception (INT 13h)\r
-.equ                SIMD_EXCEPTION_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        .fill 85 * 8, 1, 0\r
-\r
-# IRQ 0 (System timer) - (INT 68h)\r
-.equ                IRQ0_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-.equ                IRQ1_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-.equ                IRQ2_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 3 (COM 2) - (INT 6bh)\r
-.equ                IRQ3_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 4 (COM 1) - (INT 6ch)\r
-.equ                IRQ4_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 5 (LPT 2) - (INT 6dh)\r
-.equ                IRQ5_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 6 (Floppy controller) - (INT 6eh)\r
-.equ                IRQ6_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 7 (LPT 1) - (INT 6fh)\r
-.equ                IRQ7_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 8 (RTC Alarm) - (INT 70h)\r
-.equ                IRQ8_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 9 - (INT 71h)\r
-.equ                IRQ9_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 10 - (INT 72h)\r
-.equ                 IRQ10_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 11 - (INT 73h)\r
-.equ                 IRQ11_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 12 (PS/2 mouse) - (INT 74h)\r
-.equ                 IRQ12_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 13 (Floating point error) - (INT 75h)\r
-.equ                 IRQ13_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 14 (Secondary IDE) - (INT 76h)\r
-.equ                 IRQ14_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-# IRQ 15 (Primary IDE) - (INT 77h)\r
-.equ                 IRQ15_SEL, .-IDT_BASE\r
-        .word 0            # offset 15:0\r
-        .word SYS_CODE_SEL # selector 15:0\r
-        .byte 0            # 0 for interrupt gate\r
-        .byte 0x0e | 0x80  # type = 386 interrupt gate, present\r
-        .word 0            # offset 31:16\r
-\r
-IDT_END: \r
-\r
-        .p2align 1\r
-\r
-MemoryMapSize:  .long 0\r
-MemoryMap:  .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        .org 0x0fe0\r
-MyStack:    \r
-        # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        #    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        #    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        #    8259.c\r
-\r
-        int $8\r
-        iret\r
-\r
-        int $9\r
-        iret\r
-\r
-        int $10\r
-        iret\r
-\r
-        int $11\r
-        iret\r
-\r
-        int $12\r
-        iret\r
-\r
-        int $13\r
-        iret\r
-\r
-        int $14\r
-        iret\r
-\r
-        int $15\r
-        iret\r
-\r
-\r
-        .org 0x0ffe\r
-BlockSignature: \r
-        .word 0xaa55\r
-\r
-\r
diff --git a/DuetPkg/BootSector/start32.asm b/DuetPkg/BootSector/start32.asm
deleted file mode 100644 (file)
index aaf04b8..0000000
+++ /dev/null
@@ -1,924 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    start32.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE    EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT   EQU     5\r
-BLOCK_SIZE                  EQU     0200h\r
-BLOCK_MASK                  EQU     01ffh\r
-BLOCK_SHIFT                 EQU     9\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId               db  "INTEL   "    ; OemId                           - 8 bytes\r
-SectorSize          dw  0             ; Sector Size                     - 2 bytes\r
-SectorsPerCluster   db  0             ; Sector Per Cluster              - 1 byte\r
-ReservedSectors     dw  0             ; Reserved Sectors                - 2 bytes\r
-NoFats              db  0             ; Number of FATs                  - 1 byte\r
-RootEntries         dw  0             ; Root Entries                    - 2 bytes\r
-Sectors             dw  0             ; Number of Sectors               - 2 bytes\r
-Media               db  0             ; Media                           - 1 byte\r
-SectorsPerFat16     dw  0             ; Sectors Per FAT for FAT12/FAT16 - 2 byte\r
-SectorsPerTrack     dw  0             ; Sectors Per Track               - 2 bytes\r
-Heads               dw  0             ; Heads                           - 2 bytes\r
-HiddenSectors       dd  0             ; Hidden Sectors                  - 4 bytes\r
-LargeSectors        dd  0             ; Large Sectors                   - 4 bytes\r
-\r
-;******************************************************************************\r
-;\r
-;The structure for FAT32 starting at offset 36 of the boot sector. (At this point, \r
-;the BPB/boot sector for FAT12 and FAT16 differs from the BPB/boot sector for FAT32.)\r
-;\r
-;******************************************************************************\r
-\r
-SectorsPerFat32     dd  0             ; Sectors Per FAT for FAT32       - 4 bytes\r
-ExtFlags            dw  0             ; Mirror Flag                     - 2 bytes\r
-FSVersion           dw  0             ; File System Version             - 2 bytes\r
-RootCluster         dd  0             ; 1st Cluster Number of Root Dir  - 4 bytes\r
-FSInfo              dw  0             ; Sector Number of FSINFO         - 2 bytes\r
-BkBootSector        dw  0             ; Sector Number of Bk BootSector  - 2 bytes\r
-Reserved            db  12 dup(0)     ; Reserved Field                  - 12 bytes\r
-PhysicalDrive       db  0             ; Physical Drive Number           - 1 byte\r
-Reserved1           db  0             ; Reserved Field                  - 1 byte\r
-Signature           db  0             ; Extended Boot Signature         - 1 byte\r
-VolId               db  "    "        ; Volume Serial Number            - 4 bytes\r
-FatLabel            db  "           " ; Volume Label                    - 11 bytes\r
-FileSystemType      db  "FAT32   "    ; File System Type                - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-      ; ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      ; cx = Start Cluster of EfiLdr\r
-      ; dx = Start Cluster of Efivar.bin\r
-\r
-; Re use the BPB data stored in Boot Sector\r
-        mov     bp,07c00h\r
-\r
-\r
-        push    cx\r
-; Read Efivar.bin\r
-;       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        mov     ax,01900h\r
-        mov     es,ax\r
-        test    dx,dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        mov     al,1\r
-NoVarStore:\r
-        push    es\r
-; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        mov     byte ptr es:[4],al\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize:\r
-        mov     di,dx\r
-        cmp     dword ptr ds:[di+2], 04000h\r
-        mov     al,2\r
-        jne     NoVarStore\r
-\r
-LoadVarStore:\r
-        mov     al,0\r
-        mov     byte ptr es:[4],al\r
-        mov     cx,word ptr[di]\r
-;       ES:DI = 1500:0\r
-        xor     di,di\r
-        push    es\r
-        mov     ax,01500h\r
-        mov     es,ax\r
-        call    ReadFile\r
-SaveVolumeId:\r
-        pop     es\r
-        mov     ax,word ptr [bp+VolId]\r
-        mov     word ptr es:[0],ax                  ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        mov     ax,word ptr [bp+VolId+2]\r
-        mov     word ptr es:[2],ax\r
-\r
-; Read Efildr\r
-        pop     cx\r
-;       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-;       ES:DI = 2000:0, first cluster will be read again\r
-        xor     di,di                               ; di = 0\r
-        mov     ax,02000h\r
-        mov     es,ax\r
-        call    ReadFile\r
-        mov     ax,cs\r
-        mov     word ptr cs:[JumpSegment],ax\r
-JumpFarInstruction:\r
-        db      0eah\r
-JumpOffset:\r
-        dw      0200h\r
-JumpSegment:\r
-        dw      2000h\r
-\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; ReadFile\r
-;\r
-; Arguments:\r
-;   CX    = Start Cluster of File\r
-;   ES:DI = Buffer to store file content read from disk\r
-;\r
-; Return:\r
-;   (ES << 4 + DI) = end of file content Buffer\r
-;\r
-; ****************************************************************************\r
-ReadFile:\r
-; si      = NumberOfClusters\r
-; cx      = ClusterNumber\r
-; dx      = CachedFatSectorNumber\r
-; ds:0000 = CacheFatSectorBuffer\r
-; es:di   = Buffer to load file\r
-; bx      = NextClusterNumber\r
-        pusha\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        push    cx                                  ; Push Start Cluster onto stack\r
-        mov     dx,0fffh                            ; CachedFatSectorNumber = 0xfff\r
-FatChainLoop:\r
-        mov     ax,cx                               ; ax = ClusterNumber    \r
-        and     ax,0fff8h                           ; ax = ax & 0xfff8\r
-        cmp     ax,0fff8h                           ; See if this is the last cluster\r
-        je      FoundLastCluster                    ; Jump if last cluster found\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        shl     ax,2                                ; FatOffset = ClusterNumber * 4\r
-        push    si                                  ; Save si\r
-        mov     si,ax                               ; si = FatOffset\r
-        shr     ax,BLOCK_SHIFT                      ; ax = FatOffset >> BLOCK_SHIFT\r
-        add     ax,word ptr [bp+ReservedSectors]    ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        and     si,BLOCK_MASK                       ; si = FatOffset & BLOCK_MASK\r
-        cmp     ax,dx                               ; Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        mov     bx,2                                \r
-        push    es\r
-        push    ds\r
-        pop     es\r
-        call    ReadBlocks                          ; Read 2 blocks starting at AX storing at ES:DI\r
-        pop     es\r
-        mov     dx,ax                               ; CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead:\r
-        mov     bx,word ptr [si]                    ; bx = NextClusterNumber\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        pop     si                                  ; Restore si\r
-        dec     bx                                  ; bx = NextClusterNumber - 1\r
-        cmp     bx,cx                               ; See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        inc     bx                                  ; bx = NextClusterNumber\r
-        inc     si                                  ; NumberOfClusters++\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters:\r
-        inc     bx\r
-        pop     ax                                  ; ax = StartCluster\r
-        push    bx                                  ; StartCluster = NextClusterNumber\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        sub     ax,2                                ; ax = StartCluster - 2\r
-        xor     bh,bh                               \r
-        mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-        mul     bx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-        add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        push    ax                                  ; save start sector\r
-        mov     ax,si                               ; ax = NumberOfClusters\r
-        mul     bx                                  ; ax = NumberOfClusters * SectorsPerCluster\r
-        mov     bx,ax                               ; bx = Number of Sectors\r
-        pop     ax                                  ; ax = Start Sector\r
-        call    ReadBlocks\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster:\r
-        pop     cx\r
-        popa\r
-        ret\r
-\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-        pusha\r
-        add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-        add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-        mov     esi,eax                             ; esi = Start LBA\r
-        mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-        mov     bp,07bfch                           ; bp = 0x7bfc\r
-        mov     eax,esi                             ; eax = Start LBA\r
-        xor     edx,edx                             ; edx = 0\r
-        movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-        div     ebx                                 ; ax = StartLBA / MaxSector\r
-        inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-\r
-        mov     bx,word ptr [bp]                    ; bx = MaxSector\r
-        sub     bx,dx                               ; bx = MaxSector - Sector\r
-        inc     bx                                  ; bx = MaxSector - Sector + 1\r
-        cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-        push    ax                                  ; save ax\r
-        mov     ax,es                               ; ax = es\r
-        shr     ax,(BLOCK_SHIFT-4)                  ; ax = Number of blocks into mem system\r
-        and     ax,07fh                             ; ax = Number of blocks into current seg\r
-        add     ax,bx                               ; ax = End Block number of transfer\r
-        cmp     ax,080h                             ; See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               ; Branch if not crossing 64K boundry\r
-        sub     ax,080h                             ; ax = Number of blocks past 64K boundry\r
-        sub     bx,ax                               ; Decrease transfer size by block overage\r
-NotCrossing64KBoundry:\r
-        pop     ax                                  ; restore ax\r
-\r
-        push    cx\r
-        mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xor     dx,dx                               ; dx = 0\r
-        div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    ; dx = ax % (MaxHead + 1) = Head\r
-\r
-        push    bx                                  ; Save number of blocks to transfer\r
-        mov     dh,dl                               ; dh = Head\r
-        mov     bp,07c00h                           ; bp = 0x7c00\r
-        mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-        mov     ch,al                               ; ch = Cylinder\r
-        mov     al,bl                               ; al = Blocks\r
-        mov     ah,2                                ; ah = Function 2\r
-        mov     bx,di                               ; es:bx = Buffer address\r
-        int     013h\r
-        jc      DiskError\r
-        pop     bx\r
-        pop     cx\r
-        movzx   ebx,bx\r
-        add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-        sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-        mov     ax,es\r
-        shl     bx,(BLOCK_SHIFT-4)\r
-        add     ax,bx\r
-        mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmp     cx,0\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError:\r
-        push cs\r
-        pop  ds\r
-        lea  si, [ErrorString]\r
-        mov  cx, 7\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt:\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  di,160\r
-        rep  movsw\r
-Halt:\r
-        jmp   Halt\r
-\r
-ErrorString:\r
-        db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-        org     01fah\r
-LBAOffsetForBootSector:\r
-        dd      0h\r
-\r
-        org     01feh\r
-        dw      0aa55h\r
-\r
-;******************************************************************************\r
-;******************************************************************************\r
-;******************************************************************************\r
-\r
-DELAY_PORT           equ     0edh    ; Port to use for 1uS delay\r
-KBD_CONTROL_PORT     equ     060h    ; 8042 control port     \r
-KBD_STATUS_PORT      equ     064h    ; 8042 status port      \r
-WRITE_DATA_PORT_CMD  equ     0d1h    ; 8042 command to write the data port\r
-ENABLE_A20_CMD       equ     0dfh    ; 8042 command to enable A20\r
-\r
-        org     200h\r
-        jmp start\r
-Em64String:\r
-        db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch\r
-\r
-start:  \r
-        mov ax,cs\r
-        mov ds,ax\r
-        mov es,ax\r
-        mov ss,ax\r
-        mov sp,MyStack\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[160],'a'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        mov ebx,0\r
-        lea edi,MemoryMap\r
-MemMapLoop:\r
-        mov eax,0e820h\r
-        mov ecx,20\r
-        mov edx,'SMAP'\r
-        int 15h\r
-        jc  MemMapDone\r
-        add edi,20\r
-        cmp ebx,0\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone:\r
-        lea eax,MemoryMap\r
-        sub edi,eax                         ; Get the address of the memory map\r
-        mov dword ptr [MemoryMapSize],edi   ; Save the size of the memory map\r
-\r
-        xor     ebx,ebx\r
-        mov     bx,cs                       ; BX=segment\r
-        shl     ebx,4                       ; BX="linear" address of segment base\r
-        lea     eax,[GDT_BASE + ebx]        ; EAX=PHYSICAL address of gdt\r
-        mov     dword ptr [gdtr + 2],eax    ; Put address of gdt into the gdtr\r
-        lea     eax,[IDT_BASE + ebx]        ; EAX=PHYSICAL address of idt\r
-        mov     dword ptr [idtr + 2],eax    ; Put address of idt into the idtr\r
-        lea     edx,[MemoryMapSize + ebx]   ; Physical base address of the memory map\r
-\r
-        add ebx,01000h                      ; Source of EFI32\r
-        mov dword ptr [JUMP+2],ebx\r
-        add ebx,01000h\r
-        mov esi,ebx                         ; Source of EFILDR32\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[162],'b'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-;\r
-; Enable A20 Gate \r
-;\r
-\r
-        mov ax,2401h                        ; Enable A20 Gate\r
-        int 15h\r
-        jnc A20GateEnabled                  ; Jump if it suceeded\r
-\r
-;\r
-; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-;\r
-\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        mov     al,WRITE_DATA_PORT_CMD      ; 8042 cmd to write output port\r
-        out     KBD_STATUS_PORT,al          ; Send command to the 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        mov     al,ENABLE_A20_CMD           ; gate address bit 20 on\r
-        out     KBD_CONTROL_PORT,al         ; Send command to thre 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        mov     cx,25                       ; Delay 25 uS for the command to complete on the 8042\r
-Delay25uS:\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        loop    Delay25uS                       \r
-Timeout8042:\r
-\r
-\r
-A20GateEnabled:\r
-        mov     bx,0008h                    ; Flat data descriptor\r
-;\r
-; DISABLE INTERRUPTS - Entering Protected Mode\r
-;\r
-\r
-        cli                             \r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[164],'c'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        db      66h     \r
-        lgdt    fword ptr [gdtr]\r
-        db      66h     \r
-        lidt    fword ptr [idtr]\r
-\r
-        mov     eax,cr0\r
-        or      al,1\r
-        mov     cr0,eax\r
-JUMP:\r
-; jmp far 0010:00020000\r
-        db  066h\r
-        db  0eah\r
-        dd  000020000h\r
-        dw  00010h\r
-\r
-Empty8042InputBuffer:\r
-        mov cx,0\r
-Empty8042Loop:\r
-        out     DELAY_PORT,ax               ; Delay 1us\r
-        in      al,KBD_STATUS_PORT          ; Read the 8042 Status Port\r
-        and     al,02h                      ; Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               ; Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; data\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-gdtr    dw GDT_END - GDT_BASE - 1   ; GDT limit\r
-        dd 0                        ; (GDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   global descriptor table (GDT)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-public GDT_BASE\r
-GDT_BASE:\r
-; null descriptor\r
-NULL_SEL            equ $-GDT_BASE\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
-\r
-; linear data segment descriptor\r
-LINEAR_SEL      equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; linear code segment descriptor\r
-LINEAR_CODE_SEL equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system data segment descriptor\r
-SYS_DATA_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system code segment descriptor\r
-SYS_CODE_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE3_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE4_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE5_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-GDT_END:\r
-\r
-        align 02h\r
-\r
-\r
-\r
-idtr            dw IDT_END - IDT_BASE - 1   ; IDT limit\r
-        dd 0                        ; (IDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   interrupt descriptor table (IDT)\r
-;\r
-;   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-;       mappings.  This implementation only uses the system timer and all other\r
-;       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-;       for convenience.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-;idt_tag db "IDT",0     \r
-        align 02h\r
-\r
-public IDT_BASE\r
-IDT_BASE:\r
-; divide by zero (INT 0)\r
-DIV_ZERO_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; debug exception (INT 1)\r
-DEBUG_EXCEPT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; NMI (INT 2)\r
-NMI_SEL             equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; soft breakpoint (INT 3)\r
-BREAKPOINT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; overflow (INT 4)\r
-OVERFLOW_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; bounds check (INT 5)\r
-BOUNDS_CHECK_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; invalid opcode (INT 6)\r
-INVALID_OPCODE_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; device not available (INT 7)\r
-DEV_NOT_AVAIL_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; double fault (INT 8)\r
-DOUBLE_FAULT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Coprocessor segment overrun - reserved (INT 9)\r
-RSVD_INTR_SEL1      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; invalid TSS (INT 0ah)\r
-INVALID_TSS_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; segment not present (INT 0bh)\r
-SEG_NOT_PRESENT_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; stack fault (INT 0ch)\r
-STACK_FAULT_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; general protection (INT 0dh)\r
-GP_FAULT_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; page fault (INT 0eh)\r
-PAGE_FAULT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Intel reserved - do not use (INT 0fh)\r
-RSVD_INTR_SEL2      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; floating point error (INT 10h)\r
-FLT_POINT_ERR_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; alignment check (INT 11h)\r
-ALIGNMENT_CHECK_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; machine check (INT 12h)\r
-MACHINE_CHECK_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; SIMD floating-point exception (INT 13h)\r
-SIMD_EXCEPTION_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        db (85 * 8) dup(0)\r
-        \r
-; IRQ 0 (System timer) - (INT 68h)\r
-IRQ0_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-IRQ1_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-IRQ2_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 3 (COM 2) - (INT 6bh)\r
-IRQ3_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 4 (COM 1) - (INT 6ch)\r
-IRQ4_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 5 (LPT 2) - (INT 6dh)\r
-IRQ5_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 6 (Floppy controller) - (INT 6eh)\r
-IRQ6_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 7 (LPT 1) - (INT 6fh)\r
-IRQ7_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 8 (RTC Alarm) - (INT 70h)\r
-IRQ8_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 9 - (INT 71h)\r
-IRQ9_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 10 - (INT 72h)\r
-IRQ10_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 11 - (INT 73h)\r
-IRQ11_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 12 (PS/2 mouse) - (INT 74h)\r
-IRQ12_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 13 (Floating point error) - (INT 75h)\r
-IRQ13_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 14 (Secondary IDE) - (INT 76h)\r
-IRQ14_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-; IRQ 15 (Primary IDE) - (INT 77h)\r
-IRQ15_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-\r
-IDT_END:\r
-\r
-        align 02h\r
-\r
-MemoryMapSize   dd  0\r
-MemoryMap   dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        org 0fe0h\r
-MyStack:    \r
-        ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        ;    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        ;    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        ;    8259.c\r
-                \r
-        int 8\r
-        iret\r
-        \r
-        int 9\r
-        iret\r
-        \r
-        int 10\r
-        iret\r
-        \r
-        int 11\r
-        iret\r
-        \r
-        int 12\r
-        iret\r
-        \r
-        int 13\r
-        iret\r
-        \r
-        int 14\r
-        iret\r
-        \r
-        int 15\r
-        iret\r
-        \r
-        \r
-        org 0ffeh\r
-BlockSignature:\r
-        dw  0aa55h\r
-\r
-        end \r
diff --git a/DuetPkg/BootSector/start64.S b/DuetPkg/BootSector/start64.S
deleted file mode 100644 (file)
index 75626b8..0000000
+++ /dev/null
@@ -1,1149 +0,0 @@
-#------------------------------------------------------------------------------\r
-#*\r
-#*   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-#*   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
-#*    start64.asm\r
-#*  \r
-#*   Abstract:\r
-#*\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-        .stack: \r
-        .486p: \r
-        .code16\r
-\r
-.equ                        FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
-.equ                        FAT_DIRECTORY_ENTRY_SHIFT, 5\r
-.equ                        BLOCK_SIZE, 0x0200\r
-.equ                        BLOCK_MASK, 0x01ff\r
-.equ                        BLOCK_SHIFT, 9\r
-\r
-        .org 0x0\r
-\r
-.global _start\r
-_start:\r
-\r
-Ia32Jump: \r
-  jmp   BootSectorEntryPoint  # JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId:              .ascii  "INTEL   "        # OemId               - 8 bytes\r
-\r
-SectorSize:         .word  0                  # Sector Size         - 16 bits\r
-SectorsPerCluster:  .byte  0                  # Sector Per Cluster  - 8 bits\r
-ReservedSectors:    .word  0                  # Reserved Sectors    - 16 bits\r
-NoFats:             .byte  0                  # Number of FATs      - 8 bits\r
-RootEntries:        .word  0                  # Root Entries        - 16 bits\r
-Sectors:            .word  0                  # Number of Sectors   - 16 bits\r
-Media:              .byte  0                  # Media               - 8 bits  - ignored\r
-SectorsPerFat:      .word  0                  # Sectors Per FAT     - 16 bits\r
-SectorsPerTrack:    .word  0                  # Sectors Per Track   - 16 bits - ignored\r
-Heads:              .word  0                  # Heads               - 16 bits - ignored\r
-HiddenSectors:      .long  0                  # Hidden Sectors      - 32 bits - ignored\r
-LargeSectors:       .long  0                  # Large Sectors       - 32 bits \r
-PhysicalDrive:      .byte  0                  # PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead:        .byte  0                  # Current Head        - 8 bits\r
-Signature:          .byte  0                  # Signature           - 8 bits  - ignored\r
-VolId:              .ascii "    "             # Volume Serial Number- 4 bytes\r
-FatLabel:           .ascii "           "      # Label               - 11 bytes\r
-SystemId:           .ascii "FAT12   "         # SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint: \r
-      # ASSUME  ds:@code"\r
-      # ASSUME  ss:@code"\r
-      # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      # cx = Start Cluster of EfiLdr\r
-      # dx = Start Cluster of Efivar.bin\r
-\r
-# Re use the BPB data stored in Boot Sector\r
-        movw    $0x7c00,%bp\r
-\r
-        pushw   %cx\r
-# Read Efivar.bin\r
-#       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        movw    $0x1900,%ax\r
-        movw    %ax,%es\r
-        testw   %dx,%dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        movb    $1,%al\r
-NoVarStore: \r
-        pushw   %es\r
-# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        movb    %al, %es:(4)\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize: \r
-        movw    %dx,%di\r
-        cmpl    $0x4000, %ds:2(%di)\r
-        movb    $2,%al\r
-        jne     NoVarStore\r
-\r
-LoadVarStore: \r
-        movb    $0,%al\r
-        movb    %al, %es:(4)\r
-        movw    (%di), %cx\r
-#       ES:DI = 1500:0\r
-        xorw    %di,%di\r
-        pushw   %es\r
-        movw    $0x1500,%ax\r
-        movw    %ax,%es\r
-        call    ReadFile\r
-SaveVolumeId: \r
-        popw    %es\r
-        movw    VolId(%bp), %ax\r
-        movw    %ax, %es:(0) \r
-        movw    VolId+2(%bp), %ax\r
-        movw    %ax, %es:(2)\r
-\r
-# Read Efildr\r
-        popw    %cx\r
-#       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-#       ES:DI = 2000:0, first cluster will be read again\r
-        xorw    %di,%di                             # di = 0\r
-        movw    $0x2000,%ax\r
-        movw    %ax,%es\r
-        call    ReadFile\r
-        movw    %cs,%ax\r
-        movw    %ax, %cs:JumpSegment\r
-\r
-CheckEm64T: \r
-        movl $0x80000001,%eax\r
-#        cpuid\r
-        .word 0xA20F\r
-        btl  $29,%edx\r
-        jc   CheckEm64TPass\r
-        pushw %cs\r
-        popw %ds\r
-        leaw Em64String,%si\r
-        movw $18,%cx\r
-        jmp  PrintStringAndHalt\r
-CheckEm64TPass: \r
-JumpFarInstruction: \r
-        .byte 0xea\r
-JumpOffset: \r
-        .word 0x200\r
-JumpSegment: \r
-        .word 0x2000\r
-\r
-\r
-\r
-# ****************************************************************************\r
-# ReadFile\r
-#\r
-# Arguments:\r
-#   CX    = Start Cluster of File\r
-#   ES:DI = Buffer to store file content read from disk\r
-#\r
-# Return:\r
-#   (ES << 4 + DI) = end of file content Buffer\r
-#\r
-# ****************************************************************************\r
-ReadFile: \r
-# si      = NumberOfClusters\r
-# cx      = ClusterNumber\r
-# dx      = CachedFatSectorNumber\r
-# ds:0000 = CacheFatSectorBuffer\r
-# es:di   = Buffer to load file\r
-# bx      = NextClusterNumber\r
-        pusha\r
-        movw    $1,%si                              # NumberOfClusters = 1\r
-        pushw   %cx                                 # Push Start Cluster onto stack\r
-        movw    $0xfff,%dx                          # CachedFatSectorNumber = 0xfff\r
-FatChainLoop: \r
-        movw    %cx,%ax                             # ax = ClusterNumber    \r
-        andw    $0xff8,%ax                          # ax = ax & 0xff8\r
-        cmpw    $0xff8,%ax                          # See if this is the last cluster\r
-        je      FoundLastCluster                    # Jump if last cluster found\r
-        movw    %cx,%ax                             # ax = ClusterNumber\r
-        shlw    %ax                                 # ax = ClusterNumber * 2\r
-        addw    %cx,%ax                             # ax = ClusterNumber * 2 + ClusterNumber = ClusterNumber * 3\r
-        shrw    %ax                                 # FatOffset = ClusterNumber*3 / 2\r
-        pushw   %si                                 # Save si\r
-        movw    %ax,%si                             # si = FatOffset\r
-        shrw    $BLOCK_SHIFT, %ax                   # ax = FatOffset >> BLOCK_SHIFT\r
-        addw    ReservedSectors(%bp), %ax           # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        andw    $BLOCK_MASK, %si                    # si = FatOffset & BLOCK_MASK\r
-        cmpw    %dx,%ax                             # Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        movw    $2,%bx\r
-        pushw   %es\r
-        pushw   %ds\r
-        popw    %es\r
-        call    ReadBlocks                          # Read 2 blocks starting at AX storing at ES:DI\r
-        popw    %es\r
-        movw    %ax,%dx                             # CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead: \r
-        movw    (%si), %bx                          # bx = NextClusterNumber\r
-        movw    %cx,%ax                             # ax = ClusterNumber\r
-        andw    $1,%ax                              # See if this is an odd cluster number\r
-        je      EvenFatEntry\r
-        shrw    $4,%bx                              # NextClusterNumber = NextClusterNumber >> 4\r
-EvenFatEntry: \r
-        andw    $0xfff,%bx                          # Strip upper 4 bits of NextClusterNumber\r
-        popw    %si                                 # Restore si\r
-        decw    %bx                                 # bx = NextClusterNumber - 1\r
-        cmpw    %cx,%bx                             # See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        incw    %bx                                 # bx = NextClusterNumber\r
-        incw    %si                                 # NumberOfClusters++\r
-        movw    %bx,%cx                             # ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters: \r
-        incw    %bx\r
-        popw    %ax                                 # ax = StartCluster\r
-        pushw   %bx                                 # StartCluster = NextClusterNumber\r
-        movw    %bx,%cx                             # ClusterNumber = NextClusterNumber\r
-        subw    $2,%ax                              # ax = StartCluster - 2\r
-        xorb    %bh,%bh\r
-        movb    SectorsPerCluster(%bp), %bl         # bx = SectorsPerCluster\r
-        mulw    %bx                                 # ax = (StartCluster - 2) * SectorsPerCluster\r
-        addw    (%bp), %ax                          # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        pushw   %ax                                 # save start sector\r
-        movw    %si,%ax                             # ax = NumberOfClusters\r
-        mulw    %bx                                 # ax = NumberOfClusters * SectorsPerCluster\r
-        movw    %ax,%bx                             # bx = Number of Sectors\r
-        popw    %ax                                 # ax = Start Sector\r
-        call    ReadBlocks\r
-        movw    $1,%si                              # NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster: \r
-        popw    %cx\r
-        popa\r
-        ret\r
-\r
-\r
-# ****************************************************************************\r
-# ReadBlocks - Reads a set of blocks from a block device\r
-#\r
-# AX    = Start LBA\r
-# BX    = Number of Blocks to Read\r
-# ES:DI = Buffer to store sectors read from disk\r
-# ****************************************************************************\r
-\r
-# cx = Blocks\r
-# bx = NumberOfBlocks\r
-# si = StartLBA\r
-\r
-ReadBlocks: \r
-        pusha\r
-        addl    LBAOffsetForBootSector(%bp), %eax   # Add LBAOffsetForBootSector to Start LBA\r
-        addl    HiddenSectors(%bp), %eax            # Add HiddenSectors to Start LBA\r
-        movl    %eax,%esi                           # esi = Start LBA\r
-        movw    %bx,%cx                             # cx = Number of blocks to read\r
-ReadCylinderLoop: \r
-        movw    $0x7bfc,%bp                         # bp = 0x7bfc\r
-        movl    %esi,%eax                           # eax = Start LBA\r
-        xorl    %edx,%edx                           # edx = 0\r
-        movzwl  (%bp), %ebx                         # bx = MaxSector\r
-        divl    %ebx                                # ax = StartLBA / MaxSector\r
-        incw    %dx                                 # dx = (StartLBA % MaxSector) + 1\r
-\r
-        movw    (%bp), %bx                          # bx = MaxSector\r
-        subw    %dx,%bx                             # bx = MaxSector - Sector\r
-        incw    %bx                                 # bx = MaxSector - Sector + 1\r
-        cmpw    %bx,%cx                             # Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        movw    %cx,%bx                             # bx = Blocks\r
-LimitTransfer: \r
-        pushw   %ax                                 # save ax\r
-        movw    %es,%ax                             # ax = es\r
-        shrw    $(BLOCK_SHIFT-4), %ax               # ax = Number of blocks into mem system\r
-        andw    $0x7f,%ax                           # ax = Number of blocks into current seg\r
-        addw    %bx,%ax                             # ax = End Block number of transfer\r
-        cmpw    $0x80,%ax                           # See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               # Branch if not crossing 64K boundry\r
-        subw    $0x80,%ax                           # ax = Number of blocks past 64K boundry\r
-        subw    %ax,%bx                             # Decrease transfer size by block overage\r
-NotCrossing64KBoundry: \r
-        popw    %ax                                 # restore ax\r
-\r
-        pushw   %cx\r
-        movb    %dl,%cl                             # cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xorw    %dx,%dx                             # dx = 0\r
-        divw    2(%bp)                              # ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    # dx = ax % (MaxHead + 1) = Head\r
-\r
-        pushw   %bx                                 # Save number of blocks to transfer\r
-        movb    %dl,%dh                             # dh = Head\r
-        movw    $0x7c00,%bp                         # bp = 0x7c00\r
-        movb    PhysicalDrive(%bp), %dl             # dl = Drive Number\r
-        movb    %al,%ch                             # ch = Cylinder\r
-        movb    %bl,%al                             # al = Blocks\r
-        movb    $2,%ah                              # ah = Function 2\r
-        movw    %di,%bx                             # es:bx = Buffer address\r
-        int     $0x13\r
-        jc      DiskError\r
-        popw    %bx\r
-        popw    %cx\r
-        movzwl  %bx,%ebx\r
-        addl    %ebx,%esi                           # StartLBA = StartLBA + NumberOfBlocks\r
-        subw    %bx,%cx                             # Blocks = Blocks - NumberOfBlocks\r
-        movw    %es,%ax\r
-        shlw    $(BLOCK_SHIFT-4), %bx\r
-        addw    %bx,%ax\r
-        movw    %ax,%es                             # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmpw    $0,%cx\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError: \r
-        pushw %cs\r
-        popw %ds\r
-        leaw ErrorString,%si\r
-        movw $7,%cx\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt: \r
-        movw $0xb800,%ax\r
-        movw %ax,%es\r
-        movw $160,%di\r
-        rep \r
-        movsw       \r
-Halt: \r
-        jmp   Halt\r
-\r
-ErrorString: \r
-        .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!',0x0c\r
-\r
-        .org     0x01fa\r
-LBAOffsetForBootSector: \r
-        .long 0x0\r
-\r
-        .org    0x01fe\r
-        .word 0xaa55\r
-\r
-#******************************************************************************\r
-#******************************************************************************\r
-#******************************************************************************\r
-\r
-.equ                 DELAY_PORT, 0x0ed           # Port to use for 1uS delay\r
-.equ                 KBD_CONTROL_PORT, 0x060     # 8042 control port     \r
-.equ                 KBD_STATUS_PORT, 0x064      # 8042 status port      \r
-.equ                 WRITE_DATA_PORT_CMD, 0x0d1  # 8042 command to write the data port\r
-.equ                 ENABLE_A20_CMD, 0x0df       # 8042 command to enable A20\r
-\r
-        .org     0x200\r
-        jmp start\r
-Em64String: \r
-.byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
-\r
-start:  \r
-        movw %cs,%ax\r
-        movw %ax,%ds\r
-        movw %ax,%es\r
-        movw %ax,%ss\r
-        movw $MyStack, %sp\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[160],'a'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-        movl $0,%ebx\r
-        leal MemoryMap, %edi\r
-MemMapLoop: \r
-        movl $0xe820,%eax\r
-        movl $20,%ecx\r
-        movl $0x534d4150, %edx  # SMAP\r
-        int $0x15\r
-        jc  MemMapDone\r
-        addl $20,%edi\r
-        cmpl $0,%ebx\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone: \r
-        leal MemoryMap, %eax\r
-        subl %eax,%edi                      # Get the address of the memory map\r
-        movl %edi, MemoryMapSize            # Save the size of the memory map\r
-\r
-        xorl    %ebx,%ebx\r
-        movw    %cs,%bx                     # BX=segment\r
-        shll    $4,%ebx                     # BX="linear" address of segment base\r
-        leal    GDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of gdt\r
-        movl    %eax, (gdtr + 2)            # Put address of gdt into the gdtr\r
-        leal    IDT_BASE(%ebx), %eax        # EAX=PHYSICAL address of idt\r
-        movl    %eax, (idtr + 2)            # Put address of idt into the idtr\r
-        leal    MemoryMapSize(%ebx), %edx   # Physical base address of the memory map\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[162],'b'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-#\r
-# Enable A20 Gate \r
-#\r
-\r
-        movw $0x2401,%ax                    # Enable A20 Gate\r
-        int $0x15\r
-        jnc A20GateEnabled                  # Jump if it suceeded\r
-\r
-#\r
-# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-#\r
-\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        movb    $WRITE_DATA_PORT_CMD, %al   # 8042 cmd to write output port\r
-        outb    %al, $KBD_STATUS_PORT       # Send command to the 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 # Jump if the 8042 timed out\r
-        movb    $ENABLE_A20_CMD, %al        # gate address bit 20 on\r
-        outb    %al, $KBD_CONTROL_PORT      # Send command to thre 8042\r
-        call    Empty8042InputBuffer        # Empty the Input Buffer on the 8042 controller\r
-        movw    $25,%cx                     # Delay 25 uS for the command to complete on the 8042\r
-Delay25uS: \r
-        outw    %ax, $DELAY_PORT            # Delay 1 uS\r
-        loop    Delay25uS\r
-Timeout8042: \r
-\r
-\r
-A20GateEnabled: \r
-\r
-#\r
-# DISABLE INTERRUPTS - Entering Protected Mode\r
-#\r
-\r
-        cli\r
-\r
-#        mov ax,0b800h\r
-#        mov es,ax\r
-#        mov byte ptr es:[164],'c'\r
-#        mov ax,cs\r
-#        mov es,ax\r
-\r
-    leal OffsetIn32BitProtectedMode, %eax\r
-    addl $0x20000+0x6,%eax\r
-    movl %eax, OffsetIn32BitProtectedMode \r
-\r
-    leal OffsetInLongMode, %eax\r
-    addl $0x20000+0x6,%eax\r
-    movl %eax, OffsetInLongMode \r
-\r
-    #\r
-    # load GDT\r
-    #\r
-    .byte 0x66\r
-    lgdt    gdtr\r
-\r
-    #\r
-    # Enable Protect Mode (set CR0.PE=1)\r
-    #\r
-    movl  %cr0, %eax      # Read CR0.\r
-    orl   $0x1,%eax       # Set PE=1\r
-    movl  %eax, %cr0      # Write CR0.\r
-    .byte 0x66\r
-    .byte 0xea                        # jmp far 16:32\r
-OffsetIn32BitProtectedMode: \r
-    .long 0x0000000                   # offset $+8   (In32BitProtectedMode)\r
-    .word 0x10                        # selector  (flat CS)\r
-In32BitProtectedMode: \r
-\r
-#\r
-# Entering Long Mode\r
-#\r
-    .byte 0x66\r
-    movw $8,%ax\r
-    movw %ax,%ds\r
-    movw %ax,%es\r
-    movw %ax,%ss\r
-\r
-    #\r
-    # Enable the 64-bit page-translation-table entries by\r
-    # setting CR4.PAE=1 (this is _required_ before activating\r
-    # long mode). Paging is not enabled until after long mode\r
-    # is enabled.\r
-    #\r
-    .byte 0xf\r
-    .byte 0x20\r
-    .byte 0xe0\r
-#    mov eax, cr4\r
-    btsl $5,%eax\r
-    .byte 0xf\r
-    .byte 0x22\r
-    .byte 0xe0\r
-#    mov cr4, eax\r
-\r
-    #\r
-    # This is the Trapolean Page Tables that are guarenteed\r
-    #  under 4GB.\r
-    #\r
-    # Address Map:\r
-    #    10000 ~    12000 - efildr (loaded)\r
-    #    20000 ~    21000 - start64.com\r
-    #    21000 ~    22000 - efi64.com\r
-    #    22000 ~    90000 - efildr\r
-    #    90000 ~    96000 - 4G pagetable (will be reload later)\r
-    #\r
-    .byte 0xb8\r
-    .long 0x90000\r
-#    mov eax, 90000h\r
-    movl %eax, %cr3\r
-\r
-    #\r
-    # Enable long mode (set EFER.LME=1).\r
-    #\r
-    .byte 0xb9\r
-    .long 0xc0000080\r
-#    mov   ecx, 0c0000080h ; EFER MSR number.\r
-    .byte 0xf\r
-    .byte 0x32\r
-#    rdmsr                 ; Read EFER.\r
-    .byte 0xf\r
-    .byte 0xba\r
-    .byte 0xe8\r
-    .byte 0x8\r
-#    bts   eax, 8          ; Set LME=1.\r
-    .byte 0xf\r
-    .byte 0x30\r
-#    wrmsr                 ; Write EFER.\r
-\r
-    #\r
-    # Enable paging to activate long mode (set CR0.PG=1)\r
-    #\r
-    movl  %cr0, %eax      # Read CR0.\r
-    .byte 0xf\r
-    .byte 0xba\r
-    .byte 0xe8\r
-    .byte 0x1f\r
-#    bts   eax, 31         ; Set PG=1.\r
-    movl  %eax, %cr0      # Write CR0.\r
-    jmp   GoToLongMode\r
-GoToLongMode: \r
-\r
-    .byte 0x67\r
-    .byte 0xea                  # Far Jump $+9:Selector to reload CS\r
-OffsetInLongMode: \r
-    .long 00000000              #   $+9 Offset is ensuing instruction boundary\r
-    .word 0x38                  #   Selector is our code selector, 38h\r
-\r
-InLongMode: \r
-    .byte 0x66\r
-    movw    $0x30,%ax\r
-    movw    %ax,%ds\r
-\r
-    .byte 0x66\r
-    movw    $0x18,%ax\r
-    movw    %ax,%es\r
-    movw    %ax,%ss\r
-    movw    %ax,%ds\r
-\r
-    .byte 0xbd\r
-    .long 0x400000\r
-#    mov ebp,000400000h                  ; Destination of EFILDR32\r
-    .byte 0xbb\r
-    .long 0x70000\r
-#    mov ebx,000070000h                  ; Length of copy\r
-\r
-    #\r
-    # load idt later\r
-    #\r
-    .byte 0x48\r
-    .byte 0x33\r
-    .byte 0xc0\r
-#    xor rax, rax\r
-    .byte 0x66\r
-     movw $idtr, %ax\r
-    .byte 0x48\r
-    .byte 0x5\r
-    .long 0x20000\r
-#    add rax, 20000h\r
-\r
-    .byte 0xf\r
-    .byte 0x1\r
-    .byte 0x18\r
-#    lidt    fword ptr [rax]\r
-\r
-    .byte 0x48\r
-    .byte 0xc7\r
-    .byte 0xc0\r
-    .long 0x21000\r
-#   mov rax, 21000h\r
-    .byte 0x50\r
-#   push rax\r
-\r
-# ret\r
-    .byte 0xc3\r
-\r
-Empty8042InputBuffer: \r
-        movw $0,%cx\r
-Empty8042Loop: \r
-        outw    %ax, $DELAY_PORT            # Delay 1us\r
-        inb     $KBD_STATUS_PORT, %al       # Read the 8042 Status Port\r
-        andb    $0x2,%al                    # Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               # Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-##############################################################################\r
-# data\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-        gdtr:    .long  GDT_END - GDT_BASE - 1  # GDT limit \r
-        .long 0                     # (GDT base gets set above)\r
-##############################################################################\r
-#   global descriptor table (GDT)\r
-##############################################################################\r
-\r
-        .p2align 1\r
-\r
-GDT_BASE: \r
-# null descriptor\r
-.equ                NULL_SEL, .-GDT_BASE    # Selector [0x0]\r
-        .word 0         # limit 15:0\r
-        .word 0         # base 15:0\r
-        .byte 0         # base 23:16\r
-        .byte 0         # type\r
-        .byte 0         # limit 19:16, flags\r
-        .byte 0         # base 31:24\r
-\r
-# linear data segment descriptor\r
-.equ            LINEAR_SEL, .-GDT_BASE  # Selector [0x8]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# linear code segment descriptor\r
-.equ            LINEAR_CODE_SEL, .-GDT_BASE # Selector [0x10]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system data segment descriptor\r
-.equ            SYS_DATA_SEL, .-GDT_BASE # Selector [0x18]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# system code segment descriptor\r
-.equ            SYS_CODE_SEL, .-GDT_BASE # Selector [0x20]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # present, ring 0, data, expand-up, writable\r
-        .byte 0xCF              # page-granular, 32-bit\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE3_SEL, .-GDT_BASE  # Selector [0x28]\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-#\r
-# system data segment descriptor\r
-#\r
-.equ              SYS_DATA64_SEL, .-GDT_BASE # Selector [0x30]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x92      # P | DPL [1..2] | 1   | 1   | C | R | A\r
-        .byte 0xCF      # G | D   | L    | AVL | Segment [19..16]\r
-        .byte 0\r
-\r
-#\r
-# system code segment descriptor\r
-#\r
-.equ              SYS_CODE64_SEL, .-GDT_BASE # Selector [0x38]\r
-        .word 0xFFFF    # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0x9A      # P | DPL [1..2] | 1   | 1   | C | R | A\r
-        .byte 0xAF      # G | D   | L    | AVL | Segment [19..16]\r
-        .byte 0\r
-\r
-# spare segment descriptor\r
-.equ        SPARE4_SEL, .-GDT_BASE    # Selector [0x40]\r
-        .word 0         # limit 0xFFFFF\r
-        .word 0         # base 0\r
-        .byte 0\r
-        .byte 0         # present, ring 0, data, expand-up, writable\r
-        .byte 0         # page-granular, 32-bit\r
-        .byte 0\r
-\r
-GDT_END: \r
-\r
-        .p2align 1\r
-\r
-\r
-\r
-idtr:   .long  IDT_END - IDT_BASE - 1 # IDT limit\r
-        .quad 0                       # (IDT base gets set above)\r
-\r
-##############################################################################\r
-#   interrupt descriptor table (IDT)\r
-#\r
-#   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-#       mappings.  This implementation only uses the system timer and all other\r
-#       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-#       for convenience.\r
-##############################################################################\r
-\r
-#idt_tag db "IDT",0     \r
-        .p2align 1\r
-\r
-\r
-IDT_BASE: \r
-# divide by zero (INT 0)\r
-.equ                DIV_ZERO_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# debug exception (INT 1)\r
-.equ                DEBUG_EXCEPT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# NMI (INT 2)\r
-.equ                NMI_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# soft breakpoint (INT 3)\r
-.equ                BREAKPOINT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# overflow (INT 4)\r
-.equ                OVERFLOW_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# bounds check (INT 5)\r
-.equ                BOUNDS_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# invalid opcode (INT 6)\r
-.equ                INVALID_OPCODE_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# device not available (INT 7)\r
-.equ                DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# double fault (INT 8)\r
-.equ                DOUBLE_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Coprocessor segment overrun - reserved (INT 9)\r
-.equ                RSVD_INTR_SEL1, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# invalid TSS (INT 0ah)\r
-.equ                INVALID_TSS_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# segment not present (INT 0bh)\r
-.equ                SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# stack fault (INT 0ch)\r
-.equ                STACK_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# general protection (INT 0dh)\r
-.equ                GP_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# page fault (INT 0eh)\r
-.equ                PAGE_FAULT_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Intel reserved - do not use (INT 0fh)\r
-.equ                RSVD_INTR_SEL2, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# floating point error (INT 10h)\r
-.equ                FLT_POINT_ERR_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# alignment check (INT 11h)\r
-.equ                ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# machine check (INT 12h)\r
-.equ                MACHINE_CHECK_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# SIMD floating-point exception (INT 13h)\r
-.equ                SIMD_EXCEPTION_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        .fill 85 * 16, 1, 0   # db (85 * 16) dup(0)\r
-\r
-# IRQ 0 (System timer) - (INT 68h)\r
-.equ                IRQ0_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-.equ                IRQ1_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-.equ                IRQ2_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 3 (COM 2) - (INT 6bh)\r
-.equ                IRQ3_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 4 (COM 1) - (INT 6ch)\r
-.equ                IRQ4_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 5 (LPT 2) - (INT 6dh)\r
-.equ                IRQ5_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 6 (Floppy controller) - (INT 6eh)\r
-.equ                IRQ6_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 7 (LPT 1) - (INT 6fh)\r
-.equ                IRQ7_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 8 (RTC Alarm) - (INT 70h)\r
-.equ                IRQ8_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 9 - (INT 71h)\r
-.equ                IRQ9_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 10 - (INT 72h)\r
-.equ                 IRQ10_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 11 - (INT 73h)\r
-.equ                 IRQ11_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 12 (PS/2 mouse) - (INT 74h)\r
-.equ                 IRQ12_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 13 (Floating point error) - (INT 75h)\r
-.equ                 IRQ13_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 14 (Secondary IDE) - (INT 76h)\r
-.equ                 IRQ14_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-# IRQ 15 (Primary IDE) - (INT 77h)\r
-.equ                 IRQ15_SEL, .-IDT_BASE\r
-        .word 0               # offset 15:0\r
-        .long SYS_CODE64_SEL  # selector 15:0\r
-        .byte 0               # 0 for interrupt gate\r
-        .byte 0x0e | 0x80     # type = 386 interrupt gate, present\r
-        .word 0               # offset 31:16\r
-        .long 0               # offset 63:32\r
-        .long 0               # 0 for reserved\r
-\r
-IDT_END: \r
-\r
-        .p2align 1\r
-\r
-MemoryMapSize:  .long 0\r
-MemoryMap:  .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-        .long 0,0,0,0,0,0,0,0\r
-\r
-        .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        .org 0x0fe0\r
-MyStack:    \r
-        # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        #    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        #    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        #    8259.c\r
-\r
-        int $8\r
-        iret\r
-\r
-        int $9\r
-        iret\r
-\r
-        int $10\r
-        iret\r
-\r
-        int $11\r
-        iret\r
-\r
-        int $12\r
-        iret\r
-\r
-        int $13\r
-        iret\r
-\r
-        int $14\r
-        iret\r
-\r
-        int $15\r
-        iret\r
-\r
-\r
-        .org 0x0ffe\r
-BlockSignature: \r
-        .word 0xaa55\r
-\r
diff --git a/DuetPkg/BootSector/start64.asm b/DuetPkg/BootSector/start64.asm
deleted file mode 100644 (file)
index e368bf3..0000000
+++ /dev/null
@@ -1,1147 +0,0 @@
-;------------------------------------------------------------------------------\r
-;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-;*   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
-;*    start64.asm\r
-;*  \r
-;*   Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-        .model  small\r
-        .stack\r
-        .486p\r
-        .code\r
-\r
-FAT_DIRECTORY_ENTRY_SIZE    EQU     020h\r
-FAT_DIRECTORY_ENTRY_SHIFT   EQU     5\r
-BLOCK_SIZE                  EQU     0200h\r
-BLOCK_MASK                  EQU     01ffh\r
-BLOCK_SHIFT                 EQU     9\r
-\r
-        org 0h\r
-Ia32Jump:\r
-  jmp   BootSectorEntryPoint  ; JMP inst    - 3 bytes\r
-  nop\r
-\r
-OemId             db  "INTEL   "    ; OemId               - 8 bytes\r
-\r
-SectorSize        dw  0             ; Sector Size         - 16 bits\r
-SectorsPerCluster db  0             ; Sector Per Cluster  - 8 bits\r
-ReservedSectors   dw  0             ; Reserved Sectors    - 16 bits\r
-NoFats            db  0             ; Number of FATs      - 8 bits\r
-RootEntries       dw  0             ; Root Entries        - 16 bits\r
-Sectors           dw  0             ; Number of Sectors   - 16 bits\r
-Media             db  0             ; Media               - 8 bits  - ignored\r
-SectorsPerFat     dw  0             ; Sectors Per FAT     - 16 bits\r
-SectorsPerTrack   dw  0             ; Sectors Per Track   - 16 bits - ignored\r
-Heads             dw  0             ; Heads               - 16 bits - ignored\r
-HiddenSectors     dd  0             ; Hidden Sectors      - 32 bits - ignored\r
-LargeSectors      dd  0             ; Large Sectors       - 32 bits \r
-PhysicalDrive     db  0             ; PhysicalDriveNumber - 8 bits  - ignored\r
-CurrentHead       db  0             ; Current Head        - 8 bits\r
-Signature         db  0             ; Signature           - 8 bits  - ignored\r
-VolId             db  "    "        ; Volume Serial Number- 4 bytes\r
-FatLabel          db  "           " ; Label               - 11 bytes\r
-SystemId          db  "FAT12   "    ; SystemId            - 8 bytes\r
-\r
-BootSectorEntryPoint:\r
-        ASSUME  ds:@code\r
-        ASSUME  ss:@code\r
-      ; ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
-      ; cx = Start Cluster of EfiLdr\r
-      ; dx = Start Cluster of Efivar.bin\r
-\r
-; Re use the BPB data stored in Boot Sector\r
-        mov     bp,07c00h\r
-\r
-        push    cx\r
-; Read Efivar.bin\r
-;       1000:dx    = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
-        mov     ax,01900h\r
-        mov     es,ax\r
-        test    dx,dx\r
-        jnz     CheckVarStoreSize\r
-\r
-        mov     al,1\r
-NoVarStore:\r
-        push    es\r
-; Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
-        mov     byte ptr es:[4],al\r
-        jmp     SaveVolumeId\r
-\r
-CheckVarStoreSize:\r
-        mov     di,dx\r
-        cmp     dword ptr ds:[di+2], 04000h\r
-        mov     al,2\r
-        jne     NoVarStore\r
-\r
-LoadVarStore:\r
-        mov     al,0\r
-        mov     byte ptr es:[4],al\r
-        mov     cx,word ptr[di]\r
-;       ES:DI = 1500:0\r
-        xor     di,di\r
-        push    es\r
-        mov     ax,01500h\r
-        mov     es,ax\r
-        call    ReadFile\r
-SaveVolumeId:\r
-        pop     es\r
-        mov     ax,word ptr [bp+VolId]\r
-        mov     word ptr es:[0],ax                  ; Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
-        mov     ax,word ptr [bp+VolId+2]\r
-        mov     word ptr es:[2],ax\r
-\r
-; Read Efildr\r
-        pop     cx\r
-;       cx    = Start Cluster of Efildr -> BS.com has filled already\r
-;       ES:DI = 2000:0, first cluster will be read again\r
-        xor     di,di                               ; di = 0\r
-        mov     ax,02000h\r
-        mov     es,ax\r
-        call    ReadFile\r
-        mov     ax,cs\r
-        mov     word ptr cs:[JumpSegment],ax\r
-\r
-CheckEm64T:\r
-        mov  eax, 080000001h\r
-;        cpuid\r
-        dw   0A20Fh\r
-        bt   edx, 29\r
-        jc   CheckEm64TPass\r
-        push cs\r
-        pop  ds\r
-        lea  si, [Em64String]\r
-        mov  cx, 18\r
-        jmp  PrintStringAndHalt\r
-CheckEm64TPass:\r
-JumpFarInstruction:\r
-        db      0eah\r
-JumpOffset:\r
-        dw      0200h\r
-JumpSegment:\r
-        dw      2000h\r
-\r
-\r
-\r
-; ****************************************************************************\r
-; ReadFile\r
-;\r
-; Arguments:\r
-;   CX    = Start Cluster of File\r
-;   ES:DI = Buffer to store file content read from disk\r
-;\r
-; Return:\r
-;   (ES << 4 + DI) = end of file content Buffer\r
-;\r
-; ****************************************************************************\r
-ReadFile:\r
-; si      = NumberOfClusters\r
-; cx      = ClusterNumber\r
-; dx      = CachedFatSectorNumber\r
-; ds:0000 = CacheFatSectorBuffer\r
-; es:di   = Buffer to load file\r
-; bx      = NextClusterNumber\r
-        pusha\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        push    cx                                  ; Push Start Cluster onto stack\r
-        mov     dx,0fffh                            ; CachedFatSectorNumber = 0xfff\r
-FatChainLoop:\r
-        mov     ax,cx                               ; ax = ClusterNumber    \r
-        and     ax,0ff8h                            ; ax = ax & 0xff8\r
-        cmp     ax,0ff8h                            ; See if this is the last cluster\r
-        je      FoundLastCluster                    ; Jump if last cluster found\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        shl     ax,1                                ; ax = ClusterNumber * 2\r
-        add     ax,cx                               ; ax = ClusterNumber * 2 + ClusterNumber = ClusterNumber * 3\r
-        shr     ax,1                                ; FatOffset = ClusterNumber*3 / 2\r
-        push    si                                  ; Save si\r
-        mov     si,ax                               ; si = FatOffset\r
-        shr     ax,BLOCK_SHIFT                      ; ax = FatOffset >> BLOCK_SHIFT\r
-        add     ax,word ptr [bp+ReservedSectors]    ; ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
-        and     si,BLOCK_MASK                       ; si = FatOffset & BLOCK_MASK\r
-        cmp     ax,dx                               ; Compare FatSectorNumber to CachedFatSectorNumber\r
-        je      SkipFatRead\r
-        mov     bx,2                                \r
-        push    es\r
-        push    ds\r
-        pop     es\r
-        call    ReadBlocks                          ; Read 2 blocks starting at AX storing at ES:DI\r
-        pop     es\r
-        mov     dx,ax                               ; CachedFatSectorNumber = FatSectorNumber\r
-SkipFatRead:\r
-        mov     bx,word ptr [si]                    ; bx = NextClusterNumber\r
-        mov     ax,cx                               ; ax = ClusterNumber\r
-        and     ax,1                                ; See if this is an odd cluster number\r
-        je      EvenFatEntry\r
-        shr     bx,4                                ; NextClusterNumber = NextClusterNumber >> 4\r
-EvenFatEntry:\r
-        and     bx,0fffh                            ; Strip upper 4 bits of NextClusterNumber\r
-        pop     si                                  ; Restore si\r
-        dec     bx                                  ; bx = NextClusterNumber - 1\r
-        cmp     bx,cx                               ; See if (NextClusterNumber-1)==ClusterNumber\r
-        jne     ReadClusters\r
-        inc     bx                                  ; bx = NextClusterNumber\r
-        inc     si                                  ; NumberOfClusters++\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        jmp     FatChainLoop\r
-ReadClusters:\r
-        inc     bx\r
-        pop     ax                                  ; ax = StartCluster\r
-        push    bx                                  ; StartCluster = NextClusterNumber\r
-        mov     cx,bx                               ; ClusterNumber = NextClusterNumber\r
-        sub     ax,2                                ; ax = StartCluster - 2\r
-        xor     bh,bh                               \r
-        mov     bl,byte ptr [bp+SectorsPerCluster]  ; bx = SectorsPerCluster\r
-        mul     bx                                  ; ax = (StartCluster - 2) * SectorsPerCluster\r
-        add     ax, word ptr [bp]                   ; ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
-        push    ax                                  ; save start sector\r
-        mov     ax,si                               ; ax = NumberOfClusters\r
-        mul     bx                                  ; ax = NumberOfClusters * SectorsPerCluster\r
-        mov     bx,ax                               ; bx = Number of Sectors\r
-        pop     ax                                  ; ax = Start Sector\r
-        call    ReadBlocks\r
-        mov     si,1                                ; NumberOfClusters = 1\r
-        jmp     FatChainLoop\r
-FoundLastCluster:\r
-        pop     cx\r
-        popa\r
-        ret\r
-\r
-\r
-; ****************************************************************************\r
-; ReadBlocks - Reads a set of blocks from a block device\r
-;\r
-; AX    = Start LBA\r
-; BX    = Number of Blocks to Read\r
-; ES:DI = Buffer to store sectors read from disk\r
-; ****************************************************************************\r
-\r
-; cx = Blocks\r
-; bx = NumberOfBlocks\r
-; si = StartLBA\r
-\r
-ReadBlocks:\r
-        pusha\r
-        add     eax,dword ptr [bp+LBAOffsetForBootSector]    ; Add LBAOffsetForBootSector to Start LBA\r
-        add     eax,dword ptr [bp+HiddenSectors]    ; Add HiddenSectors to Start LBA\r
-        mov     esi,eax                             ; esi = Start LBA\r
-        mov     cx,bx                               ; cx = Number of blocks to read\r
-ReadCylinderLoop:\r
-        mov     bp,07bfch                           ; bp = 0x7bfc\r
-        mov     eax,esi                             ; eax = Start LBA\r
-        xor     edx,edx                             ; edx = 0\r
-        movzx   ebx,word ptr [bp]                   ; bx = MaxSector\r
-        div     ebx                                 ; ax = StartLBA / MaxSector\r
-        inc     dx                                  ; dx = (StartLBA % MaxSector) + 1\r
-\r
-        mov     bx,word ptr [bp]                    ; bx = MaxSector\r
-        sub     bx,dx                               ; bx = MaxSector - Sector\r
-        inc     bx                                  ; bx = MaxSector - Sector + 1\r
-        cmp     cx,bx                               ; Compare (Blocks) to (MaxSector - Sector + 1)\r
-        jg      LimitTransfer\r
-        mov     bx,cx                               ; bx = Blocks\r
-LimitTransfer:\r
-        push    ax                                  ; save ax\r
-        mov     ax,es                               ; ax = es\r
-        shr     ax,(BLOCK_SHIFT-4)                  ; ax = Number of blocks into mem system\r
-        and     ax,07fh                             ; ax = Number of blocks into current seg\r
-        add     ax,bx                               ; ax = End Block number of transfer\r
-        cmp     ax,080h                             ; See if it crosses a 64K boundry\r
-        jle     NotCrossing64KBoundry               ; Branch if not crossing 64K boundry\r
-        sub     ax,080h                             ; ax = Number of blocks past 64K boundry\r
-        sub     bx,ax                               ; Decrease transfer size by block overage\r
-NotCrossing64KBoundry:\r
-        pop     ax                                  ; restore ax\r
-\r
-        push    cx\r
-        mov     cl,dl                               ; cl = (StartLBA % MaxSector) + 1 = Sector\r
-        xor     dx,dx                               ; dx = 0\r
-        div     word ptr [bp+2]                     ; ax = ax / (MaxHead + 1) = Cylinder  \r
-                                                    ; dx = ax % (MaxHead + 1) = Head\r
-\r
-        push    bx                                  ; Save number of blocks to transfer\r
-        mov     dh,dl                               ; dh = Head\r
-        mov     bp,07c00h                           ; bp = 0x7c00\r
-        mov     dl,byte ptr [bp+PhysicalDrive]      ; dl = Drive Number\r
-        mov     ch,al                               ; ch = Cylinder\r
-        mov     al,bl                               ; al = Blocks\r
-        mov     ah,2                                ; ah = Function 2\r
-        mov     bx,di                               ; es:bx = Buffer address\r
-        int     013h\r
-        jc      DiskError\r
-        pop     bx\r
-        pop     cx\r
-        movzx   ebx,bx\r
-        add     esi,ebx                             ; StartLBA = StartLBA + NumberOfBlocks\r
-        sub     cx,bx                               ; Blocks = Blocks - NumberOfBlocks\r
-        mov     ax,es\r
-        shl     bx,(BLOCK_SHIFT-4)\r
-        add     ax,bx\r
-        mov     es,ax                               ; es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
-        cmp     cx,0\r
-        jne     ReadCylinderLoop\r
-        popa\r
-        ret\r
-\r
-DiskError:\r
-        push cs\r
-        pop  ds\r
-        lea  si, [ErrorString]\r
-        mov  cx, 7\r
-        jmp  PrintStringAndHalt\r
-\r
-PrintStringAndHalt:\r
-        mov  ax,0b800h\r
-        mov  es,ax\r
-        mov  di,160\r
-        rep  movsw\r
-Halt:\r
-        jmp   Halt\r
-\r
-ErrorString:\r
-        db 'S', 0ch, 'E', 0ch, 'r', 0ch, 'r', 0ch, 'o', 0ch, 'r', 0ch, '!', 0ch\r
-\r
-        org     01fah\r
-LBAOffsetForBootSector:\r
-        dd      0h\r
-\r
-        org     01feh\r
-        dw      0aa55h\r
-\r
-;******************************************************************************\r
-;******************************************************************************\r
-;******************************************************************************\r
-\r
-DELAY_PORT           equ     0edh    ; Port to use for 1uS delay\r
-KBD_CONTROL_PORT     equ     060h    ; 8042 control port     \r
-KBD_STATUS_PORT      equ     064h    ; 8042 status port      \r
-WRITE_DATA_PORT_CMD  equ     0d1h    ; 8042 command to write the data port\r
-ENABLE_A20_CMD       equ     0dfh    ; 8042 command to enable A20\r
-\r
-        org     200h\r
-        jmp start\r
-Em64String:\r
-        db 'E', 0ch, 'm', 0ch, '6', 0ch, '4', 0ch, 'T', 0ch, ' ', 0ch, 'U', 0ch, 'n', 0ch, 's', 0ch, 'u', 0ch, 'p', 0ch, 'p', 0ch, 'o', 0ch, 'r', 0ch, 't', 0ch, 'e', 0ch, 'd', 0ch, '!', 0ch\r
-\r
-start:  \r
-        mov ax,cs\r
-        mov ds,ax\r
-        mov es,ax\r
-        mov ss,ax\r
-        mov sp,MyStack\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[160],'a'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-        mov ebx,0\r
-        lea edi,MemoryMap\r
-MemMapLoop:\r
-        mov eax,0e820h\r
-        mov ecx,20\r
-        mov edx,'SMAP'\r
-        int 15h\r
-        jc  MemMapDone\r
-        add edi,20\r
-        cmp ebx,0\r
-        je  MemMapDone\r
-        jmp MemMapLoop\r
-MemMapDone:\r
-        lea eax,MemoryMap\r
-        sub edi,eax                         ; Get the address of the memory map\r
-        mov dword ptr [MemoryMapSize],edi   ; Save the size of the memory map\r
-\r
-        xor     ebx,ebx\r
-        mov     bx,cs                       ; BX=segment\r
-        shl     ebx,4                       ; BX="linear" address of segment base\r
-        lea     eax,[GDT_BASE + ebx]        ; EAX=PHYSICAL address of gdt\r
-        mov     dword ptr [gdtr + 2],eax    ; Put address of gdt into the gdtr\r
-        lea     eax,[IDT_BASE + ebx]        ; EAX=PHYSICAL address of idt\r
-        mov     dword ptr [idtr + 2],eax    ; Put address of idt into the idtr\r
-        lea     edx,[MemoryMapSize + ebx]   ; Physical base address of the memory map\r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[162],'b'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-;\r
-; Enable A20 Gate \r
-;\r
-\r
-        mov ax,2401h                        ; Enable A20 Gate\r
-        int 15h\r
-        jnc A20GateEnabled                  ; Jump if it suceeded\r
-\r
-;\r
-; If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
-;\r
-\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        mov     al,WRITE_DATA_PORT_CMD      ; 8042 cmd to write output port\r
-        out     KBD_STATUS_PORT,al          ; Send command to the 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        jnz     Timeout8042                 ; Jump if the 8042 timed out\r
-        mov     al,ENABLE_A20_CMD           ; gate address bit 20 on\r
-        out     KBD_CONTROL_PORT,al         ; Send command to thre 8042\r
-        call    Empty8042InputBuffer        ; Empty the Input Buffer on the 8042 controller\r
-        mov     cx,25                       ; Delay 25 uS for the command to complete on the 8042\r
-Delay25uS:\r
-        out     DELAY_PORT,ax               ; Delay 1 uS\r
-        loop    Delay25uS                       \r
-Timeout8042:\r
-\r
-\r
-A20GateEnabled:\r
-\r
-;\r
-; DISABLE INTERRUPTS - Entering Protected Mode\r
-;\r
-\r
-        cli                             \r
-\r
-;        mov ax,0b800h\r
-;        mov es,ax\r
-;        mov byte ptr es:[164],'c'\r
-;        mov ax,cs\r
-;        mov es,ax\r
-\r
-    lea eax, OffsetIn32BitProtectedMode\r
-    add eax, 20000h + 6h\r
-    mov dword ptr[OffsetIn32BitProtectedMode], eax\r
-\r
-    lea eax, OffsetInLongMode\r
-    add eax, 20000h + 6h\r
-    mov dword ptr[OffsetInLongMode], eax\r
-\r
-    ;\r
-    ; load GDT\r
-    ;\r
-    db      66h     \r
-    lgdt    fword ptr [gdtr]\r
-\r
-    ;\r
-    ; Enable Protect Mode (set CR0.PE=1)\r
-    ;\r
-    mov   eax, cr0        ; Read CR0.\r
-    or    eax, 1h         ; Set PE=1\r
-    mov   cr0, eax        ; Write CR0.\r
-    db    066h\r
-    db    0eah                        ; jmp far 16:32\r
-OffsetIn32BitProtectedMode:\r
-    dd    00000000h                   ; offset $+8   (In32BitProtectedMode)\r
-    dw    10h                         ; selector  (flat CS)\r
-In32BitProtectedMode:\r
-\r
-;\r
-; Entering Long Mode\r
-;\r
-    db   66h\r
-    mov  ax, 8\r
-    mov  ds, ax\r
-    mov  es, ax\r
-    mov  ss, ax\r
-\r
-    ;\r
-    ; Enable the 64-bit page-translation-table entries by\r
-    ; setting CR4.PAE=1 (this is _required_ before activating\r
-    ; long mode). Paging is not enabled until after long mode\r
-    ; is enabled.\r
-    ;\r
-    db 0fh\r
-    db 20h\r
-    db 0e0h\r
-;    mov eax, cr4\r
-    bts eax, 5\r
-    db 0fh\r
-    db 22h\r
-    db 0e0h\r
-;    mov cr4, eax\r
-\r
-    ;\r
-    ; This is the Trapolean Page Tables that are guarenteed\r
-    ;  under 4GB.\r
-    ;\r
-    ; Address Map:\r
-    ;    10000 ~    12000 - efildr (loaded)\r
-    ;    20000 ~    21000 - start64.com\r
-    ;    21000 ~    22000 - efi64.com\r
-    ;    22000 ~    90000 - efildr\r
-    ;    90000 ~    96000 - 4G pagetable (will be reload later)\r
-    ;\r
-    db  0b8h\r
-    dd  90000h\r
-;    mov eax, 90000h\r
-    mov cr3, eax\r
-\r
-    ;\r
-    ; Enable long mode (set EFER.LME=1).\r
-    ;\r
-    db  0b9h\r
-    dd  0c0000080h\r
-;    mov   ecx, 0c0000080h ; EFER MSR number.\r
-    db 0fh\r
-    db 32h\r
-;    rdmsr                 ; Read EFER.\r
-    db    0fh\r
-    db    0bah\r
-    db    0e8h\r
-    db    08h\r
-;    bts   eax, 8          ; Set LME=1.\r
-    db 0fh\r
-    db 30h\r
-;    wrmsr                 ; Write EFER.\r
-\r
-    ;\r
-    ; Enable paging to activate long mode (set CR0.PG=1)\r
-    ;\r
-    mov   eax, cr0        ; Read CR0.\r
-    db    0fh\r
-    db    0bah\r
-    db    0e8h\r
-    db    01fh\r
-;    bts   eax, 31         ; Set PG=1.\r
-    mov   cr0, eax        ; Write CR0.\r
-    jmp   GoToLongMode\r
-GoToLongMode:\r
-\r
-    db      067h\r
-    db      0eah                ; Far Jump $+9:Selector to reload CS\r
-OffsetInLongMode:\r
-    dd      00000000            ;   $+9 Offset is ensuing instruction boundary\r
-    dw      038h                ;   Selector is our code selector, 38h\r
-\r
-InLongMode:\r
-    db   66h\r
-    mov     ax, 30h\r
-    mov     ds, ax\r
-\r
-    db   66h\r
-    mov     ax, 18h\r
-    mov     es, ax\r
-    mov     ss, ax\r
-    mov     ds, ax\r
-\r
-    db 0bdh\r
-    dd 400000h\r
-;    mov ebp,000400000h                  ; Destination of EFILDR32\r
-    db 0bbh\r
-    dd 70000h\r
-;    mov ebx,000070000h                  ; Length of copy\r
-\r
-    ;\r
-    ; load idt later\r
-    ;\r
-    db 48h\r
-    db 33h\r
-    db 0c0h\r
-;    xor rax, rax\r
-    db 66h\r
-    mov ax, offset idtr\r
-    db 48h\r
-    db 05h\r
-    dd 20000h\r
-;    add rax, 20000h\r
-\r
-    db 0fh\r
-    db 01h\r
-    db 18h\r
-;    lidt    fword ptr [rax]\r
-\r
-    db 48h\r
-    db 0c7h\r
-    db 0c0h\r
-    dd 21000h\r
-;   mov rax, 21000h\r
-    db 50h\r
-;   push rax\r
-\r
-; ret\r
-    db 0c3h\r
-\r
-Empty8042InputBuffer:\r
-        mov cx,0\r
-Empty8042Loop:\r
-        out     DELAY_PORT,ax               ; Delay 1us\r
-        in      al,KBD_STATUS_PORT          ; Read the 8042 Status Port\r
-        and     al,02h                      ; Check the Input Buffer Full Flag\r
-        loopnz  Empty8042Loop               ; Loop until the input buffer is empty or a timout of 65536 uS\r
-        ret\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-; data\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-gdtr    dw GDT_END - GDT_BASE - 1   ; GDT limit\r
-        dd 0                        ; (GDT base gets set above)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   global descriptor table (GDT)\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-        align 02h\r
-\r
-public GDT_BASE\r
-GDT_BASE:\r
-; null descriptor\r
-NULL_SEL            equ $-GDT_BASE          ; Selector [0x0]\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
-\r
-; linear data segment descriptor\r
-LINEAR_SEL      equ $-GDT_BASE          ; Selector [0x8]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; linear code segment descriptor\r
-LINEAR_CODE_SEL equ $-GDT_BASE          ; Selector [0x10]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system data segment descriptor\r
-SYS_DATA_SEL    equ $-GDT_BASE          ; Selector [0x18]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; system code segment descriptor\r
-SYS_CODE_SEL    equ $-GDT_BASE          ; Selector [0x20]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE3_SEL  equ $-GDT_BASE          ; Selector [0x28]\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-;\r
-; system data segment descriptor\r
-;\r
-SYS_DATA64_SEL    equ $-GDT_BASE          ; Selector [0x30]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; P | DPL [1..2] | 1   | 1   | C | R | A\r
-        db 0CFh         ; G | D   | L    | AVL | Segment [19..16]\r
-        db 0\r
-\r
-;\r
-; system code segment descriptor\r
-;\r
-SYS_CODE64_SEL    equ $-GDT_BASE          ; Selector [0x38]\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; P | DPL [1..2] | 1   | 1   | C | R | A\r
-        db 0AFh         ; G | D   | L    | AVL | Segment [19..16]\r
-        db 0\r
-\r
-; spare segment descriptor\r
-SPARE4_SEL  equ $-GDT_BASE            ; Selector [0x40]\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
-\r
-GDT_END:\r
-\r
-        align 02h\r
-\r
-\r
-\r
-idtr            dw IDT_END - IDT_BASE - 1   ; IDT limit\r
-        dq 0                        ; (IDT base gets set above)\r
-\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-;   interrupt descriptor table (IDT)\r
-;\r
-;   Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
-;       mappings.  This implementation only uses the system timer and all other\r
-;       IRQs will remain masked.  The descriptors for vectors 33+ are provided\r
-;       for convenience.\r
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
-\r
-;idt_tag db "IDT",0     \r
-        align 02h\r
-\r
-public IDT_BASE\r
-IDT_BASE:\r
-; divide by zero (INT 0)\r
-DIV_ZERO_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; debug exception (INT 1)\r
-DEBUG_EXCEPT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; NMI (INT 2)\r
-NMI_SEL             equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; soft breakpoint (INT 3)\r
-BREAKPOINT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; overflow (INT 4)\r
-OVERFLOW_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; bounds check (INT 5)\r
-BOUNDS_CHECK_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; invalid opcode (INT 6)\r
-INVALID_OPCODE_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; device not available (INT 7)\r
-DEV_NOT_AVAIL_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; double fault (INT 8)\r
-DOUBLE_FAULT_SEL    equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Coprocessor segment overrun - reserved (INT 9)\r
-RSVD_INTR_SEL1      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; invalid TSS (INT 0ah)\r
-INVALID_TSS_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; segment not present (INT 0bh)\r
-SEG_NOT_PRESENT_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; stack fault (INT 0ch)\r
-STACK_FAULT_SEL     equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; general protection (INT 0dh)\r
-GP_FAULT_SEL        equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; page fault (INT 0eh)\r
-PAGE_FAULT_SEL      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Intel reserved - do not use (INT 0fh)\r
-RSVD_INTR_SEL2      equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; floating point error (INT 10h)\r
-FLT_POINT_ERR_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; alignment check (INT 11h)\r
-ALIGNMENT_CHECK_SEL equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; machine check (INT 12h)\r
-MACHINE_CHECK_SEL   equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; SIMD floating-point exception (INT 13h)\r
-SIMD_EXCEPTION_SEL  equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
-        db (85 * 16) dup(0)\r
-        \r
-; IRQ 0 (System timer) - (INT 68h)\r
-IRQ0_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
-IRQ1_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
-IRQ2_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 3 (COM 2) - (INT 6bh)\r
-IRQ3_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 4 (COM 1) - (INT 6ch)\r
-IRQ4_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 5 (LPT 2) - (INT 6dh)\r
-IRQ5_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 6 (Floppy controller) - (INT 6eh)\r
-IRQ6_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 7 (LPT 1) - (INT 6fh)\r
-IRQ7_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 8 (RTC Alarm) - (INT 70h)\r
-IRQ8_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 9 - (INT 71h)\r
-IRQ9_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 10 - (INT 72h)\r
-IRQ10_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 11 - (INT 73h)\r
-IRQ11_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 12 (PS/2 mouse) - (INT 74h)\r
-IRQ12_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 13 (Floating point error) - (INT 75h)\r
-IRQ13_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 14 (Secondary IDE) - (INT 76h)\r
-IRQ14_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-; IRQ 15 (Primary IDE) - (INT 77h)\r
-IRQ15_SEL            equ $-IDT_BASE\r
-        dw 0            ; offset 15:0\r
-        dw SYS_CODE64_SEL ; selector 15:0\r
-        db 0            ; 0 for interrupt gate\r
-        db 0eh OR 80h   ; (10001110)type = 386 interrupt gate, present\r
-        dw 0            ; offset 31:16\r
-        dd 0            ; offset 63:32\r
-        dd 0            ; 0 for reserved\r
-\r
-IDT_END:\r
-\r
-        align 02h\r
-\r
-MemoryMapSize   dd  0\r
-MemoryMap   dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0\r
-\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-        dd  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
-\r
-        org 0fe0h\r
-MyStack:    \r
-        ; below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
-        ;    back to INT 08h - 0fh  when in real mode...  It is 'org'ed to a\r
-        ;    known low address (20f00) so it can be set up by PlMapIrqToVect in\r
-        ;    8259.c\r
-                \r
-        int 8\r
-        iret\r
-        \r
-        int 9\r
-        iret\r
-        \r
-        int 10\r
-        iret\r
-        \r
-        int 11\r
-        iret\r
-        \r
-        int 12\r
-        iret\r
-        \r
-        int 13\r
-        iret\r
-        \r
-        int 14\r
-        iret\r
-        \r
-        int 15\r
-        iret\r
-        \r
-        \r
-        org 0ffeh\r
-BlockSignature:\r
-        dw  0aa55h\r
-\r
-        end \r
diff --git a/DuetPkg/CreateBootDisk.bat b/DuetPkg/CreateBootDisk.bat
deleted file mode 100644 (file)
index cee04b8..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-@echo off\r
-@REM ## @file\r
-@REM #\r
-@REM #  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
-@REM #\r
-@REM #  This program and the accompanying materials\r
-@REM #  are licensed and made available under the terms and conditions of the BSD License\r
-@REM #  which accompanies this distribution. The full text of the license may be found at\r
-@REM #  http://opensource.org/licenses/bsd-license.php\r
-@REM #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-@REM #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-@REM #\r
-@REM #\r
-@REM ##\r
-\r
-@REM Set up environment at first.\r
-\r
-set BASETOOLS_DIR=%EDK_TOOLS_BIN%\r
-set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin\r
-set DISK_LABEL=DUET\r
-set PROCESSOR=""\r
-set STEP=1\r
-\r
-if "%1"=="" goto Help\r
-if "%2"=="" goto Help\r
-if "%3"=="" goto Help\r
-if "%4"=="" goto Set_BootDisk\r
-if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4\r
-if "%5"=="step2" @set STEP=2\r
-:Set_BootDisk\r
-set EFI_BOOT_DISK=%2\r
-if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32\r
-if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64\r
-if %PROCESSOR%=="" goto WrongArch\r
-call %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
-set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%\r
-\r
-if "%1"=="floppy" goto CreateFloppy\r
-if "%1"=="file" goto CreateFile\r
-if "%1"=="usb" goto CreateUsb\r
-if "%1"=="ide" goto CreateIde\r
-\r
-goto Help\r
-\r
-:CreateFloppy\r
-if NOT "%3"=="FAT12" goto WrongFATType\r
-echo Start to create floppy boot disk ...\r
-echo Format %EFI_BOOT_DISK% ...\r
-echo.> FormatCommandInput.txt\r
-echo.n>> FormatCommandInput.txt\r
-format /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL\r
-del FormatCommandInput.txt\r
-echo Create boot sector ...\r
-%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com\r
-copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com\r
-%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f\r
-@REM @del FDBS.com\r
-%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com\r
-del FDBs-1.com\r
-echo Done.\r
-copy %BUILD_DIR%\FV\EfiLdr %EFI_BOOT_DISK%\r
-goto CreateBootFile\r
-\r
-:CreateFile\r
-if NOT "%3"=="FAT12" goto WrongFATType\r
-echo Start to create file boot disk ...\r
-echo Create boot sector ...\r
-%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o FDBs.com\r
-copy %BOOTSECTOR_BIN_DIR%\Bootsect.com FDBs-1.com\r
-%BASETOOLS_DIR%\Bootsectimage.exe -g FDBs.com FDBs-1.com -f\r
-REM @del FDBS.com\r
-%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i FDBs-1.com\r
-del FDBs-1.com\r
-echo Done.\r
-goto end\r
-\r
-:CreateUsb\r
-echo Start to create usb boot disk ...\r
-if "%3"=="FAT16" goto CreateUsb_FAT16\r
-if "%3"=="FAT32" goto CreateUsb_FAT32\r
-if "%3"=="FAT12" goto WrongFATType\r
-\r
-:CreateUsb_FAT16\r
-if "%STEP%"=="2" goto CreateUsb_FAT16_step2\r
-echo Format %EFI_BOOT_DISK% ...\r
-echo.> FormatCommandInput.txt\r
-format /FS:FAT /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL\r
-del FormatCommandInput.txt\r
-echo Create boot sector ...\r
-%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs16.com\r
-copy %BOOTSECTOR_BIN_DIR%\Bs16.com Bs16-1.com\r
-%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs16.com Bs16-1.com -f\r
-%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs16-1.com\r
-del Bs16-1.com\r
-%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com\r
-echo Done.\r
-echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!\r
-goto end\r
-\r
-:CreateUsb_FAT16_step2\r
-copy %BUILD_DIR%\FV\EfiLdr16 %EFI_BOOT_DISK%\r
-goto CreateBootFile\r
-\r
-:CreateUsb_FAT32\r
-if "%STEP%"=="2" goto CreateUsb_FAT32_step2\r
-echo Format %EFI_BOOT_DISK% ...\r
-echo.> FormatCommandInput.txt\r
-format /FS:FAT32 /v:%DISK_LABEL% /q %EFI_BOOT_DISK% < FormatCommandInput.txt > NUL\r
-del FormatCommandInput.txt\r
-echo Create boot sector ...\r
-%BASETOOLS_DIR%\Genbootsector.exe -i %EFI_BOOT_DISK% -o UsbBs32.com\r
-copy %BOOTSECTOR_BIN_DIR%\Bs32.com Bs32-1.com\r
-%BASETOOLS_DIR%\Bootsectimage.exe -g UsbBs32.com Bs32-1.com -f\r
-del UsbBs32.com\r
-%BASETOOLS_DIR%\Genbootsector.exe -o %EFI_BOOT_DISK% -i Bs32-1.com\r
-del Bs32-1.com\r
-%BASETOOLS_DIR%\Genbootsector.exe -m -o %EFI_BOOT_DISK% -i %BOOTSECTOR_BIN_DIR%\Mbr.com\r
-echo Done.\r
-echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN!\r
-goto end\r
-\r
-:CreateUsb_FAT32_step2\r
-copy %BUILD_DIR%\FV\EfiLdr20 %EFI_BOOT_DISK%\r
-goto CreateBootFile\r
-\r
-:CreateIde\r
-goto end\r
-\r
-:CreateBootFile\r
-mkdir %EFI_BOOT_DISK%\efi\boot\r
-copy %WORKSPACE%\ShellBinPkg\UefiShell\%PROCESSOR%\Shell.efi %EFI_BOOT_DISK%\efi\boot\boot%PROCESSOR%.efi /y\r
-goto end\r
-\r
-:WrongFATType\r
-echo Wrong FAT type %3 for %1\r
-goto end\r
-\r
-:WrongArch\r
-echo Error! Wrong architecture.\r
-goto Help\r
-\r
-:Help\r
-echo "Usage: CreateBootDisk [usb|floppy|ide] DiskNumber [FAT12|FAT16|FAT32] [IA32|X64]"\r
-:end\r
-echo on\r
diff --git a/DuetPkg/CreateBootDisk.sh b/DuetPkg/CreateBootDisk.sh
deleted file mode 100755 (executable)
index 897ba9b..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-#! /bin/sh
-
-## @file
-#
-#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-#  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.
-#
-#
-##
-
-# Set up environment at fisrt.
-
-if [ -z "$EDK_TOOLS_PATH" ]
-then
-export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
-else
-export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin
-fi
-
-export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
-export DISK_LABEL=DUET
-export PROCESS_MARK=TRUE
-
-if [ \
-     -z "$*" -o \
-     "$*" = "-?" -o \
-     "$*" = "-h" -o \
-     "$*" = "--help" \
-   ]
-then
-    echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64]"
-    echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
-    PROCESS_MARK=FALSE
-fi
-
-case "$5" in
-   IA32)
-     export PROCESSOR=IA32
-     ;;
-   X64)
-     export PROCESSOR=X64
-     ;;
-   *)
-     echo Invalid Architecture string, should be only IA32 or X64
-     return 1
-esac
-
-. $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh
-export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLCHAIN
-
-
-export EFI_BOOT_MEDIA=$2
-export EFI_BOOT_DEVICE=$3
-
-if [ "$PROCESS_MARK" = TRUE ]
-then
-    case "$1" in
-        floppy)
-            if [ "$4" = FAT12 ]
-            then
-                echo Start to create floppy boot disk ...
-                echo Format $EFI_BOOT_MEDIA ...
-                ## Format floppy disk
-                umount $EFI_BOOT_MEDIA
-                mkfs.msdos $EFI_BOOT_DEVICE
-                mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
-                echo Create boot sector ...
-                ## Linux version of GenBootSector has not pass build yet.
-                $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
-                cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
-                $BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
-                $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
-                rm FDBs-1.com
-                cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
-
-                mkdir -p $EFI_BOOT_MEDIA/efi
-                mkdir -p $EFI_BOOT_MEDIA/efi/boot
-                if [ "$5" = IA32 ]
-                then
-                    cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-                else
-                    if [ "$5" = X64 ]
-                    then
-                        cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-                    else
-                        echo Wrong Arch!
-                    fi
-                fi
-                echo Done.
-            else
-                echo "Wrong FAT type $4 for floppy!"
-            fi
-            ;;
-
-        file) # CreateFile
-            if [ "$4" = FAT12 ]
-                then
-                echo "Start to create file boot disk ..."
-                dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
-                mkfs.msdos -F 12 $EFI_BOOT_MEDIA
-
-                mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
-                mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
-                if [ "$5" = IA32 ]
-                then
-                    mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi ::/efi/boot/boot$5.efi
-                elif [ "$5" = X64 ]
-                then
-                    mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi ::/efi/boot/boot$5.efi
-                else
-                    echo Wrong Arch!
-                fi
-                mdir -i $EFI_BOOT_MEDIA -s ::
-
-                ## Linux version of GenBootSector has not pass build yet.
-                $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
-                cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
-                $BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
-                $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
-                rm $EFI_BOOT_MEDIA.bs[0-1]
-                echo Done.
-            else
-                echo "Wrong FAT type" $4 "for floppy!"
-            fi
-            ;;
-
-        usb) # CreateUsb
-
-            if [ "$4" = FAT16 ]
-            then
-                if [ "$6" = step2 ]
-                then
-                    cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
-                    mkdir $EFI_BOOT_MEDIA/efi/boot
-                    if [ "$5" = IA32 ]
-                    then
-                        cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-                    else
-                        if [ "$5" = X64 ]
-                        then
-                            cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-                        else
-                            echo Wrong Arch!
-                        fi
-                    fi
-                    echo "step2 Done!"
-                else
-                    echo Format $EFI_BOOT_DEVICE ...
-                    #Do format command.
-                    echo Create boot sector ...
-                    ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
-                    $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
-                    cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
-                    $BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
-                    $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
-                    rm Bs16-1.com
-                    $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
-                    echo Done.
-                    echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
-                fi
-            elif [ "$4" = FAT32 ]
-            then
-                if [ "$6" = step2 ]
-                then
-                    cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
-                    mkdir $EFI_BOOT_MEDIA/efi/boot
-                    if [ "$5" = IA32 ]
-                    then
-                        cp $WORKSPACE/ShellBinPkg/UefiShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-                    else
-                        if [ "$5" = X64 ]
-                        then
-                            cp $WORKSPACE/ShellBinPkg/UefiShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/boot$5.efi
-                        else
-                            echo Wrong Arch!
-                        fi
-                    fi
-                    echo "step2 Done!"
-                else
-                    echo Format $EFI_BOOT_DEVICE ...
-                    #Do format command.
-                    echo Create boot sector ...
-                    ## Linux version of GenBootSector & Bootsectimage has not pass build yet.
-                    $BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
-                    cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
-                    $BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
-                    $BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
-                    rm Bs32-1.com
-                    $BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
-                    echo Done.
-                    echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
-                fi
-            else
-                echo "Wrong FAT type $1 for floppy!"
-            fi
-
-            ;;
-
-        ide) # CreateIde
-        echo "Not support yet!"
-        ;;
-        *)
-        echo "Arg1 should be [floppy | file | usb | ide] !"
-
-    esac
-fi
diff --git a/DuetPkg/DuetPkg.dec b/DuetPkg/DuetPkg.dec
deleted file mode 100644 (file)
index 0958af3..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file \r
-#\r
-# This Package provides all definitions(including functions, MACROs, structures and library classes)\r
-# and libraries instances, which are only used by Duet platform.\r
-#\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials are licensed and made available under\r
-# the terms and conditions of the BSD License which accompanies this distribution.\r
-# 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
-\r
-[Defines]\r
-  DEC_SPECIFICATION              = 0x00010005\r
-  PACKAGE_NAME                   = DuetPkg\r
-  PACKAGE_GUID                   = 151B568B-B390-4cf1-ABD6-228E0AB96F57\r
-  PACKAGE_VERSION                = 0.4\r
-\r
-[Includes]\r
-  Include\r
-\r
-[Guids]\r
-  gEfiPciExpressBaseAddressGuid = {0x3677d529, 0x326f, 0x4603, {0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0 }}\r
-  gEfiAcpiDescriptionGuid       = {0x3c699197, 0x093c, 0x4c69, {0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9 }}\r
-  gEfiFlashMapHobGuid           = { 0xb091e7d2, 0x5a0, 0x4198, {0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 }}\r
-  \r
-  ## Include/Guid/PciOptionRomTable.h\r
-  gEfiPciOptionRomTableGuid     = { 0x7462660F, 0x1CBD, 0x48DA, { 0xAD, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1C }}\r
-\r
-  ## Include/Guid/ConsoleOutConfig.h\r
-  gDuetConsoleOutConfigGuid     = { 0xED150714, 0xDF30, 0x407D, { 0xB2, 0x4A, 0x4B, 0x74, 0x2F, 0xD5, 0xCE, 0xA2 }}\r
-  \r
-  ## Include/Guid/DxeCoreFileName.h\r
-  gDxeCoreFileNameGuid          = { 0xD6A2CB7F, 0x6A18, 0x4e2f, { 0xB4, 0x3B, 0x99, 0x20, 0xA7, 0x33, 0x70, 0x0A }}\r
-\r
-  ## Include/Guid/LdrMemoryDescriptor.h\r
-  gLdrMemoryDescriptorGuid      = { 0x7701d7e5, 0x7d1d, 0x4432, { 0xa4, 0x68, 0x67, 0x3d, 0xab, 0x8a, 0xde, 0x60 }}\r
diff --git a/DuetPkg/DuetPkg.fdf b/DuetPkg/DuetPkg.fdf
deleted file mode 100644 (file)
index f51af8a..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-## @file\r
-# This is DUET FDF file with UEFI HII features enabled\r
-#\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#    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
-################################################################################\r
-#\r
-# FV Section\r
-#\r
-# [FV] section is used to define what components or modules are placed within a flash\r
-# device file.  This section also defines order the components and modules are positioned\r
-# within the image.  The [FV] section consists of define statements, set statements and\r
-# module statements.\r
-#\r
-################################################################################\r
-[FV.DuetEfiMainFv]\r
-BlockSize          = 0x10000\r
-FvAlignment        = 16         #FV alignment and FV attributes setting.\r
-ERASE_POLARITY     = 1\r
-MEMORY_MAPPED      = TRUE\r
-STICKY_WRITE       = TRUE\r
-LOCK_CAP           = TRUE\r
-LOCK_STATUS        = TRUE\r
-WRITE_DISABLED_CAP = TRUE\r
-WRITE_ENABLED_CAP  = TRUE\r
-WRITE_STATUS       = TRUE\r
-WRITE_LOCK_CAP     = TRUE\r
-WRITE_LOCK_STATUS  = TRUE\r
-READ_DISABLED_CAP  = TRUE\r
-READ_ENABLED_CAP   = TRUE\r
-READ_STATUS        = TRUE\r
-READ_LOCK_CAP      = TRUE\r
-READ_LOCK_STATUS   = TRUE\r
-\r
-APRIORI DXE {\r
-  INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
-  INF  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf\r
-}\r
-\r
-INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
-INF  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
-INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-\r
-INF  DuetPkg/FSVariable/FSVariable.inf\r
-INF  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
-INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
-INF  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
-INF  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
-INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
-INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-INF  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
-\r
-INF  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
-INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
-INF  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
-INF  DuetPkg/SmbiosGenDxe/SmbiosGen.inf\r
-#INF  DuetPkg/FvbRuntimeService/DUETFwh.inf\r
-INF  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
-INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-INF  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
-INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
-INF  UefiCpuPkg/CpuDxe/CpuDxe.inf\r
-\r
-INF  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf\r
-INF  DuetPkg/AcpiResetDxe/Reset.inf\r
-INF  DuetPkg/LegacyMetronome/Metronome.inf\r
-INF  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf\r
-INF  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
-INF  DuetPkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf\r
-INF  DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf\r
-INF  IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf\r
-INF  IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf\r
-\r
-  # IDE/AHCI Support\r
-INF  DuetPkg/SataControllerDxe/SataControllerDxe.inf\r
-INF  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf\r
-INF  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf\r
-INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
-INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
-\r
-  # Usb Support\r
-INF  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
-INF  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
-INF  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
-INF  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
-INF  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
-\r
-  # ISA Support\r
-INF  PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf\r
-INF  IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf\r
-INF  IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf\r
-INF  IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf\r
-INF  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf\r
-\r
-INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
-INF  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
-INF  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
-INF  DuetPkg/BiosVideoThunkDxe/BiosVideo.inf\r
-\r
-INF  FatPkg/EnhancedFatDxe/Fat.inf\r
-\r
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {\r
-    SECTION RAW = MdeModulePkg/Logo/Logo.bmp\r
-  }\r
-\r
-[Rule.Common.DXE_CORE]\r
-  FILE DXE_CORE = $(NAMED_GUID) {\r
-      PE32     PE32           $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-  }\r
-\r
-[Rule.Common.UEFI_DRIVER]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-  }\r
-\r
-[Rule.Common.DXE_DRIVER]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-  }\r
-\r
-[Rule.Common.DXE_RUNTIME_DRIVER]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-  }\r
-\r
-[Rule.Common.UEFI_APPLICATION]\r
-  FILE APPLICATION = $(NAMED_GUID) {\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-  }\r
-\r
-[Rule.Common.UEFI_DRIVER.BINARY]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      |.depex\r
-        PE32     PE32                    |.efi\r
-  }\r
-\r
diff --git a/DuetPkg/DuetPkgIa32.dsc b/DuetPkg/DuetPkgIa32.dsc
deleted file mode 100644 (file)
index 06cc61d..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-## @file\r
-#  An EFI/Framework Emulation Platform with UEFI HII interface supported.\r
-#\r
-#  Developer's UEFI Emulation. DUET provides an EFI/UEFI IA32/X64 environment on legacy BIOS,\r
-#  to help developing and debugging native EFI/UEFI drivers.\r
-#\r
-#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
-  PLATFORM_NAME                  = DuetPkg\r
-  PLATFORM_GUID                  = 199E24E0-0989-42aa-87F2-611A8C397E72\r
-  PLATFORM_VERSION               = 0.4\r
-  DSC_SPECIFICATION              = 0x00010005\r
-  OUTPUT_DIRECTORY               = Build/DuetPkgIA32\r
-  SUPPORTED_ARCHITECTURES        = IA32\r
-  BUILD_TARGETS                  = DEBUG\r
-  SKUID_IDENTIFIER               = DEFAULT\r
-  FLASH_DEFINITION               = DuetPkg/DuetPkg.fdf\r
-!if $(TOOL_CHAIN_TAG) == GCC47 || $(TOOL_CHAIN_TAG) == GCC48 || $(TOOL_CHAIN_TAG) == GCC49 || $(TOOL_CHAIN_TAG) == GCC5\r
-  POSTBUILD                      = DuetPkg/PostBuild.sh\r
-!else\r
-  POSTBUILD                      = DuetPkg/PostBuild.bat\r
-!endif\r
-\r
-################################################################################\r
-#\r
-# Library Class section - list of all Library Classes needed by this Platform.\r
-#\r
-################################################################################\r
-[LibraryClasses]\r
-  #\r
-  # Entry point\r
-  #\r
-  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
-  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
-  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
-  UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
-  #\r
-  # Basic\r
-  #\r
-  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
-  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
-  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf\r
-  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
-  PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf\r
-  PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf\r
-  PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf\r
-  CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
-  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
-  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
-  #\r
-  # UEFI & PI\r
-  #\r
-  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
-  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
-  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
-  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
-  UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
-  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
-  UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
-  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
-  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
-\r
-  #\r
-  # Generic Modules\r
-  #\r
-  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
-  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
-  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
-  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
-  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf\r
-  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf\r
-  SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
-  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
-  CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
-  #\r
-  # Platform\r
-  #\r
-  PlatformBdsLib|DuetPkg/Library/DuetBdsLib/PlatformBds.inf\r
-  TimerLib|DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf\r
-  #\r
-  # Misc\r
-  #\r
-  PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
-  ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
-  PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf\r
-  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
-  MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf\r
-  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
-  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf\r
-  MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf\r
-  SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf\r
-  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
-\r
-  #\r
-  # To save size, use NULL library for DebugLib and ReportStatusCodeLib.\r
-  # If need status code output, do library instance overriden as below DxeMain.inf does\r
-  #\r
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
-  ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf\r
-\r
-[LibraryClasses.common.DXE_CORE]\r
-  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
-  MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
-\r
-################################################################################\r
-#\r
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform\r
-#\r
-################################################################################\r
-[PcdsFixedAtBuild]\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x0\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
-\r
-[PcdsFeatureFlag]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE\r
-\r
-###################################################################################################\r
-#\r
-# Components Section - list of the modules and components that will be processed by compilation\r
-#                      tools and the EDK II tools to generate PE32/PE32+/Coff image files.\r
-#\r
-# Note: The EDK II DSC file is not used to specify how compiled binary images get placed\r
-#       into firmware volume images. This section is just a list of modules to compile from\r
-#       source into UEFI-compliant binaries.\r
-#       It is the FDF file that contains information on combining binary files into firmware\r
-#       volume images, whose concept is beyond UEFI and is described in PI specification.\r
-#       Binary modules do not need to be listed in this section, as they should be\r
-#       specified in the FDF file. For example: Shell binary (Shell_Full.efi), FAT binary (Fat.efi),\r
-#       Logo (Logo.bmp), and etc.\r
-#       There may also be modules listed in this section that are not required in the FDF file,\r
-#       When a module listed here is excluded from FDF file, then UEFI-compliant binary will be\r
-#       generated for it, but the binary will not be put into any firmware volume.\r
-#\r
-###################################################################################################\r
-[Components]\r
-  DuetPkg/DxeIpl/DxeIpl.inf {\r
-    <LibraryClasses>\r
-      #\r
-      # If no following overriden for ReportStatusCodeLib library class,\r
-      # All other module can *not* output debug information even they are use not NULL library\r
-      # instance for DebugLib and ReportStatusCodeLib\r
-      #\r
-      ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
-  }\r
-\r
-  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
-    #\r
-    # Enable debug output for DxeCore module, this is a sample for how to enable debug output\r
-    # for a module. If need turn on debug output for other module, please copy following overriden\r
-    # PCD and library instance to other module's override section.\r
-    #\r
-    <PcdsFixedAtBuild>\r
-      gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07\r
-      gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F\r
-      gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042\r
-    <LibraryClasses>\r
-      DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-      ReportStatusCodeLib|DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeCoreReportStatusCodeLibFromHob.inf\r
-  }\r
-\r
-  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
-  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
-  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
-  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-\r
-  DuetPkg/FSVariable/FSVariable.inf\r
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
-  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
-  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
-  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf {\r
-    <LibraryClasses>\r
-      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-  }\r
-  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
-  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
-\r
-  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
-  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
-  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
-  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
-\r
-\r
-  DuetPkg/SmbiosGenDxe/SmbiosGen.inf\r
-  #DuetPkg/FvbRuntimeService/DUETFwh.inf\r
-  DuetPkg/EfiLdr/EfiLdr.inf {\r
-    <LibraryClasses>\r
-      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-      NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
-  }\r
-  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
-    <LibraryClasses>\r
-      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-  }\r
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
-  UefiCpuPkg/CpuDxe/CpuDxe.inf\r
-  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf\r
-  DuetPkg/AcpiResetDxe/Reset.inf\r
-  DuetPkg/LegacyMetronome/Metronome.inf\r
-\r
-  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
-  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf\r
-  DuetPkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf\r
-  DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf\r
-  IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf\r
-  IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf\r
-\r
-  # IDE/AHCI Support\r
-  DuetPkg/SataControllerDxe/SataControllerDxe.inf\r
-  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf\r
-  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
-\r
-  # Usb Support\r
-  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
-  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
-\r
-  # ISA Support\r
-  PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf\r
-\r
-  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
-  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
-  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
-  FatPkg/EnhancedFatDxe/Fat.inf\r
-\r
-  # Bios Thunk\r
-  DuetPkg/BiosVideoThunkDxe/BiosVideo.inf\r
-\r
-  #\r
-  # Sample Application\r
-  #\r
-  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
-\r
-###################################################################################################\r
-#\r
-# BuildOptions Section - Define the module specific tool chain flags that should be used as\r
-#                        the default flags for a module. These flags are appended to any\r
-#                        standard flags that are defined by the build process. They can be\r
-#                        applied for any modules or only those modules with the specific\r
-#                        module style (EDK or EDKII) specified in [Components] section.\r
-#\r
-###################################################################################################\r
-[BuildOptions]\r
-  MSFT:*_*_*_CC_FLAGS = /FAsc /FR$(@R).SBR\r
-\r
diff --git a/DuetPkg/DuetPkgX64.dsc b/DuetPkg/DuetPkgX64.dsc
deleted file mode 100644 (file)
index ee97dc2..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-## @file\r
-#  An EFI/Framework Emulation Platform with UEFI HII interface supported.\r
-#\r
-#  Developer's UEFI Emulation. DUET provides an EFI/UEFI IA32/X64 environment on legacy BIOS,\r
-#  to help developing and debugging native EFI/UEFI drivers.\r
-#\r
-#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
-  PLATFORM_NAME                  = DuetPkg\r
-  PLATFORM_GUID                  = 199E24E0-0989-42aa-87F2-611A8C397E72\r
-  PLATFORM_VERSION               = 0.4\r
-  DSC_SPECIFICATION              = 0x00010005\r
-  OUTPUT_DIRECTORY               = Build/DuetPkgX64\r
-  SUPPORTED_ARCHITECTURES        = X64\r
-  BUILD_TARGETS                  = DEBUG\r
-  SKUID_IDENTIFIER               = DEFAULT\r
-  FLASH_DEFINITION               = DuetPkg/DuetPkg.fdf\r
-!if $(TOOL_CHAIN_TAG) == GCC47 || $(TOOL_CHAIN_TAG) == GCC48 || $(TOOL_CHAIN_TAG) == GCC49 || $(TOOL_CHAIN_TAG) == GCC5\r
-  POSTBUILD                      = DuetPkg/PostBuild.sh\r
-!else\r
-  POSTBUILD                      = DuetPkg/PostBuild.bat\r
-!endif\r
-\r
-################################################################################\r
-#\r
-# Library Class section - list of all Library Classes needed by this Platform.\r
-#\r
-################################################################################\r
-[LibraryClasses]\r
-  #\r
-  # Entry point\r
-  #\r
-  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
-  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
-  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
-  UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
-  #\r
-  # Basic\r
-  #\r
-  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
-  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
-  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf\r
-  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
-  PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf\r
-  PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf\r
-  PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf\r
-  CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
-  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
-  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
-  #\r
-  # UEFI & PI\r
-  #\r
-  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
-  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
-  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
-  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
-  UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
-  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
-  UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
-  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
-  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
-\r
-  #\r
-  # Generic Modules\r
-  #\r
-  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
-  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
-  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
-  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
-  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf\r
-  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf\r
-  SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
-  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
-  CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
-  #\r
-  # Platform\r
-  #\r
-  PlatformBdsLib|DuetPkg/Library/DuetBdsLib/PlatformBds.inf\r
-  TimerLib|DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf\r
-  #\r
-  # Misc\r
-  #\r
-  PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
-  ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
-  PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf\r
-  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
-  MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf\r
-  LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf\r
-  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
-  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf\r
-  MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf\r
-  SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf\r
-  UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
-\r
-  #\r
-  # To save size, use NULL library for DebugLib and ReportStatusCodeLib.\r
-  # If need status code output, do library instance overriden as below DxeMain.inf does\r
-  #\r
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
-  ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf\r
-\r
-[LibraryClasses.common.DXE_CORE]\r
-  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
-  MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
-\r
-################################################################################\r
-#\r
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform\r
-#\r
-################################################################################\r
-[PcdsFixedAtBuild]\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x0\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
-\r
-[PcdsFeatureFlag]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE\r
-\r
-###################################################################################################\r
-#\r
-# Components Section - list of the modules and components that will be processed by compilation\r
-#                      tools and the EDK II tools to generate PE32/PE32+/Coff image files.\r
-#\r
-# Note: The EDK II DSC file is not used to specify how compiled binary images get placed\r
-#       into firmware volume images. This section is just a list of modules to compile from\r
-#       source into UEFI-compliant binaries.\r
-#       It is the FDF file that contains information on combining binary files into firmware\r
-#       volume images, whose concept is beyond UEFI and is described in PI specification.\r
-#       Binary modules do not need to be listed in this section, as they should be\r
-#       specified in the FDF file. For example: Shell binary (Shell_Full.efi), FAT binary (Fat.efi),\r
-#       Logo (Logo.bmp), and etc.\r
-#       There may also be modules listed in this section that are not required in the FDF file,\r
-#       When a module listed here is excluded from FDF file, then UEFI-compliant binary will be\r
-#       generated for it, but the binary will not be put into any firmware volume.\r
-#\r
-###################################################################################################\r
-[Components]\r
-  DuetPkg/DxeIpl/DxeIpl.inf {\r
-    <LibraryClasses>\r
-      #\r
-      # If no following overriden for ReportStatusCodeLib library class,\r
-      # All other module can *not* output debug information even they are use not NULL library\r
-      # instance for DebugLib and ReportStatusCodeLib\r
-      #\r
-      ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
-  }\r
-\r
-  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
-    #\r
-    # Enable debug output for DxeCore module, this is a sample for how to enable debug output\r
-    # for a module. If need turn on debug output for other module, please copy following overriden\r
-    # PCD and library instance to other module's override section.\r
-    #\r
-    <PcdsFixedAtBuild>\r
-      gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07\r
-      gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F\r
-      gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042\r
-    <LibraryClasses>\r
-      DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-      ReportStatusCodeLib|DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeCoreReportStatusCodeLibFromHob.inf\r
-  }\r
-\r
-  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
-  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
-  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
-  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-\r
-  DuetPkg/FSVariable/FSVariable.inf\r
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
-  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
-  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
-  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf {\r
-    <LibraryClasses>\r
-      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-  }\r
-  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
-  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
-\r
-  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
-  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
-  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
-  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
-\r
-\r
-  DuetPkg/SmbiosGenDxe/SmbiosGen.inf\r
-  #DuetPkg/FvbRuntimeService/DUETFwh.inf\r
-  DuetPkg/EfiLdr/EfiLdr.inf {\r
-    <LibraryClasses>\r
-      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-      NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
-  }\r
-  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
-    <LibraryClasses>\r
-      PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-  }\r
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
-  UefiCpuPkg/CpuDxe/CpuDxe.inf\r
-  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf\r
-  DuetPkg/AcpiResetDxe/Reset.inf\r
-  DuetPkg/LegacyMetronome/Metronome.inf\r
-\r
-  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
-  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf\r
-  DuetPkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf\r
-  DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf\r
-  IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf\r
-  IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf\r
-\r
-  # IDE/AHCI Support\r
-  DuetPkg/SataControllerDxe/SataControllerDxe.inf\r
-  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf\r
-  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
-\r
-  # Usb Support\r
-  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
-  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
-  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
-\r
-  # ISA Support\r
-  PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf\r
-\r
-  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
-  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
-  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
-  FatPkg/EnhancedFatDxe/Fat.inf\r
-\r
-  # Bios Thunk\r
-  DuetPkg/BiosVideoThunkDxe/BiosVideo.inf\r
-\r
-  #\r
-  # Sample Application\r
-  #\r
-  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
-\r
-###################################################################################################\r
-#\r
-# BuildOptions Section - Define the module specific tool chain flags that should be used as\r
-#                        the default flags for a module. These flags are appended to any\r
-#                        standard flags that are defined by the build process. They can be\r
-#                        applied for any modules or only those modules with the specific\r
-#                        module style (EDK or EDKII) specified in [Components] section.\r
-#\r
-###################################################################################################\r
-[BuildOptions]\r
-  MSFT:*_*_*_CC_FLAGS = /FAsc /FR$(@R).SBR\r
-\r
diff --git a/DuetPkg/DxeIpl/Debug.c b/DuetPkg/DxeIpl/Debug.c
deleted file mode 100644 (file)
index 800f008..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  Debug.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#include "DxeIpl.h"\r
-#include <Library/SerialPortLib.h>\r
-#include "SerialStatusCode.h"\r
-#include "Debug.h"\r
-\r
-UINT8 *mCursor;\r
-UINT8 mHeaderIndex = 10;\r
-\r
-\r
-VOID\r
-PrintHeader (\r
-  CHAR8 Char\r
-  )\r
-{\r
-  *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;\r
-  mHeaderIndex += 2;\r
-}\r
-\r
-VOID\r
-ClearScreen (\r
-  VOID\r
-  )\r
-{\r
-  UINT32 Index;\r
-\r
-  mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r
-  for (Index = 0; Index < 80 * 49; Index++) {\r
-    *mCursor = ' ';\r
-    mCursor += 2;\r
-  }\r
-  mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PrintString (\r
-  IN CONST CHAR8  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  UINTN           Index;\r
-  CHAR8           PrintBuffer[1000];\r
-  VA_LIST         Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);\r
-  VA_END (Marker);\r
-\r
-  for (Index = 0; PrintBuffer[Index] != 0; Index++) {\r
-    if (PrintBuffer[Index] == '\n') {\r
-      mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r
-    } else {\r
-      *mCursor = (UINT8) PrintBuffer[Index];\r
-      mCursor += 2;\r
-    }\r
-  }\r
-\r
-  //\r
-  // All information also output to serial port.\r
-  //\r
-  SerialPortWrite ((UINT8 *) PrintBuffer, Index);\r
-}\r
-\r
diff --git a/DuetPkg/DxeIpl/Debug.h b/DuetPkg/DxeIpl/Debug.h
deleted file mode 100644 (file)
index 81bb826..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  Debug.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#ifndef _EFILDR_DEBUG_H_\r
-#define _EFILDR_DEBUG_H_\r
-\r
-VOID\r
-PrintHeader (\r
-  CHAR8 Char\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-PrintString (\r
-  IN CONST CHAR8  *FormatString,\r
-  ...\r
-  );\r
-\r
-VOID \r
-ClearScreen (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/DxeIpl/DxeInit.c b/DuetPkg/DxeIpl/DxeInit.c
deleted file mode 100644 (file)
index b9a40a8..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  DxeInit.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#include "DxeIpl.h"\r
-\r
-#include "LegacyTable.h"\r
-#include "HobGeneration.h"\r
-#include "PpisNeededByDxeCore.h"\r
-#include "Debug.h"\r
-\r
-/*\r
---------------------------------------------------------\r
- Memory Map: (XX=32,64)\r
---------------------------------------------------------\r
-0x0\r
-        IVT\r
-0x400\r
-        BDA\r
-0x500\r
-\r
-0x7C00\r
-        BootSector\r
-0x10000\r
-        EfiLdr (relocate by efiXX.COM)\r
-0x15000\r
-        Efivar.bin (Load by StartXX.COM)\r
-0x20000\r
-        StartXX.COM (E820 table, Temporary GDT, Temporary IDT)\r
-0x21000\r
-        EfiXX.COM (Temporary Interrupt Handler)\r
-0x22000\r
-        EfiLdr.efi + DxeIpl.Z + DxeMain.Z + BFV.Z\r
-0x86000\r
-        MemoryFreeUnder1M (For legacy driver DMA)\r
-0x90000\r
-        Temporary 4G PageTable for X64 (6 page)\r
-0x9F800\r
-        EBDA\r
-0xA0000\r
-        VGA\r
-0xC0000\r
-        OPROM\r
-0xE0000\r
-        FIRMEWARE\r
-0x100000 (1M)\r
-        Temporary Stack (1M)\r
-0x200000\r
-\r
-MemoryAbove1MB.PhysicalStart <-----------------------------------------------------+\r
-        ...                                                                        |\r
-        ...                                                                        |\r
-                        <- Phit.EfiMemoryBottom -------------------+               |\r
-        HOB                                                        |               |\r
-                        <- Phit.EfiFreeMemoryBottom                |               |\r
-                                                                   |     MemoryFreeAbove1MB.ResourceLength\r
-                        <- Phit.EfiFreeMemoryTop ------+           |               |\r
-        MemoryDescriptor (For ACPINVS, ACPIReclaim)    |    4M = CONSUMED_MEMORY   |\r
-                                                       |           |               |\r
-        Permament 4G PageTable for IA32 or      MemoryAllocation   |               |\r
-        Permament 64G PageTable for X64                |           |               |\r
-                        <------------------------------+           |               |\r
-        Permament Stack (0x20 Pages = 128K)                        |               |\r
-                        <- Phit.EfiMemoryTop ----------+-----------+---------------+\r
-        NvFV (64K)                                                                 |\r
-                                                                                 MMIO\r
-        FtwFV (128K)                                                               |  \r
-                        <----------------------------------------------------------+<---------+\r
-        DxeCore                                                                    |          |\r
-                                                                                DxeCore       |\r
-        DxeIpl                                                                     |   Allocated in EfiLdr\r
-                        <----------------------------------------------------------+          |\r
-        BFV                                                                      MMIO         |\r
-                        <- Top of Free Memory reported by E820 --------------------+<---------+\r
-        ACPINVS        or\r
-        ACPIReclaim    or\r
-        Reserved\r
-                        <- Memory Top on RealMemory\r
-\r
-0x100000000 (4G)\r
-\r
-MemoryFreeAbove4G.Physicalstart <--------------------------------------------------+\r
-                                                                                   |\r
-                                                                                   |\r
-                                                                  MemoryFreeAbove4GB.ResourceLength\r
-                                                                                   |\r
-                                                                                   |\r
-                                <--------------------------------------------------+\r
-*/\r
-\r
-VOID\r
-EnterDxeMain (\r
-  IN VOID *StackTop,\r
-  IN VOID *DxeCoreEntryPoint,\r
-  IN VOID *Hob,\r
-  IN VOID *PageTable\r
-  );\r
-\r
-VOID\r
-DxeInit (\r
-  IN EFILDRHANDOFF  *Handoff\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    This is the entry point after this code has been loaded into memory. \r
-\r
-Arguments:\r
-\r
-\r
-Returns:\r
-\r
-    Calls into EFI Firmware\r
-\r
---*/\r
-{\r
-  VOID                  *StackTop;\r
-  VOID                  *StackBottom;\r
-  VOID                  *PageTableBase;\r
-  VOID                  *MemoryTopOnDescriptor;\r
-  VOID                  *MemoryDescriptor;\r
-  VOID                  *NvStorageBase;\r
-  EFILDRHANDOFF         HandoffCopy;\r
-\r
-  CopyMem ((VOID*) &HandoffCopy, (VOID*) Handoff, sizeof (EFILDRHANDOFF));\r
-  Handoff = &HandoffCopy;\r
-\r
-  ClearScreen();\r
-\r
-  PrintString (\r
-    "Enter DxeIpl ...\n"\r
-    "Handoff:\n"\r
-    "Handoff.BfvBase = %p, BfvLength = %x\n"\r
-    "Handoff.DxeIplImageBase = %p, DxeIplImageSize = %x\n"\r
-    "Handoff.DxeCoreImageBase = %p, DxeCoreImageSize = %x\n",\r
-    Handoff->BfvBase, Handoff->BfvSize,\r
-    Handoff->DxeIplImageBase, Handoff->DxeIplImageSize,\r
-    Handoff->DxeCoreImageBase, Handoff->DxeCoreImageSize\r
-    );\r
-\r
-  //\r
-  // Hob Generation Guild line:\r
-  //   * Don't report FV as physical memory\r
-  //   * MemoryAllocation Hob should only cover physical memory\r
-  //   * Use ResourceDescriptor Hob to report physical memory or Firmware Device and they shouldn't be overlapped\r
-  PrintString ("Prepare Cpu HOB information ...\n");\r
-  PrepareHobCpu ();\r
-\r
-  //\r
-  // 1. BFV\r
-  //\r
-  PrintString ("Prepare BFV HOB information ...\n");\r
-  PrepareHobBfv (Handoff->BfvBase, Handoff->BfvSize);\r
-\r
-  //\r
-  // 2. Updates Memory information, and get the top free address under 4GB\r
-  //\r
-  PrintString ("Prepare Memory HOB information ...\n");\r
-  MemoryTopOnDescriptor = PrepareHobMemory (Handoff->MemDescCount, Handoff->MemDesc);\r
-  \r
-  //\r
-  // 3. Put [NV], [Stack], [PageTable], [MemDesc], [HOB] just below the [top free address under 4GB]\r
-  //\r
-  \r
-  //   3.1 NV data\r
-  PrintString ("Prepare NV Storage information ...\n");\r
-  NvStorageBase = PrepareHobNvStorage (MemoryTopOnDescriptor);\r
-  PrintString ("NV Storage Base = %p\n", NvStorageBase);\r
-  //   3.2 Stack\r
-  StackTop = NvStorageBase;\r
-  StackBottom = PrepareHobStack (StackTop);\r
-  PrintString ("Stack Top=0x%x, Stack Bottom=0x%x\n", StackTop, StackBottom);\r
-  //   3.3 Page Table\r
-  PageTableBase = PreparePageTable (StackBottom, gHob->Cpu.SizeOfMemorySpace);\r
-  //   3.4 MemDesc (will be used in PlatformBds)\r
-  MemoryDescriptor = PrepareHobMemoryDescriptor (PageTableBase, Handoff->MemDescCount, Handoff->MemDesc);\r
-  //   3.5 Copy the Hob itself to EfiMemoryBottom, and update the PHIT Hob\r
-  PrepareHobPhit (StackTop, MemoryDescriptor);\r
-\r
-  //\r
-  // 4. Register the memory occupied by DxeCore and DxeIpl together as DxeCore\r
-  //\r
-  PrintString ("Prepare DxeCore memory Hob ...\n");\r
-  PrepareHobDxeCore (\r
-    Handoff->DxeCoreEntryPoint,\r
-    (EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase,\r
-    (UINTN)Handoff->DxeIplImageBase + (UINTN)Handoff->DxeIplImageSize - (UINTN)Handoff->DxeCoreImageBase\r
-    );\r
-\r
-  PrepareHobLegacyTable (gHob);\r
-  \r
-  PreparePpisNeededByDxeCore (gHob);\r
-\r
-  CompleteHobGeneration ();\r
-\r
-  //\r
-  // Print Hob Info\r
-  //\r
-  ClearScreen();\r
-  PrintString (\r
-    "HobStart = %p\n"\r
-    "Memory Top = %lx, Bottom = %lx\n"\r
-    "Free Memory Top = %lx, Bottom = %lx\n"\r
-    "NvStorageFvb = %lx, Length = %lx\n"\r
-    "BfvResource = %lx, Length = %lx\n"\r
-    "NvStorageFvResource = %lx, Length = %lx\n"\r
-    "NvStorage = %lx, Length = %lx\n"\r
-    "NvFtwFvResource = %lx, Length = %lx\n"\r
-    "NvFtwWorking = %lx, Length = %lx\n"\r
-    "NvFtwSpare = %lx, Length = %lx\n"\r
-    "Stack = %lx, StackLength = %lx\n"\r
-    "PageTable = %p\n"\r
-    "MemoryFreeUnder1MB = %lx, MemoryFreeUnder1MBLength = %lx\n"\r
-    "MemoryAbove1MB = %lx, MemoryAbove1MBLength = %lx\n"\r
-    "MemoryAbove4GB = %lx, MemoryAbove4GBLength = %lx\n"\r
-    "DxeCore = %lx, DxeCoreLength = %lx\n"\r
-    "MemoryAllocation = %lx, MemoryLength = %lx\n"\r
-    "$",\r
-    gHob,\r
-    gHob->Phit.EfiMemoryTop, gHob->Phit.EfiMemoryBottom,\r
-    gHob->Phit.EfiFreeMemoryTop, gHob->Phit.EfiFreeMemoryBottom,\r
-    gHob->NvStorageFvb.FvbInfo.Entries[0].Base, gHob->NvFtwFvb.FvbInfo.Entries[0].Length,\r
-    gHob->BfvResource.PhysicalStart, gHob->BfvResource.ResourceLength,\r
-    gHob->NvStorageFvResource.PhysicalStart, gHob->NvStorageFvResource.ResourceLength,\r
-    gHob->NvStorage.FvbInfo.Entries[0].Base, gHob->NvStorage.FvbInfo.Entries[0].Length,\r
-    gHob->NvFtwFvResource.PhysicalStart, gHob->NvFtwFvResource.ResourceLength,\r
-    gHob->NvFtwWorking.FvbInfo.Entries[0].Base, gHob->NvFtwWorking.FvbInfo.Entries[0].Length,\r
-    gHob->NvFtwSpare.FvbInfo.Entries[0].Base, gHob->NvFtwSpare.FvbInfo.Entries[0].Length,\r
-    gHob->Stack.AllocDescriptor.MemoryBaseAddress, gHob->Stack.AllocDescriptor.MemoryLength,\r
-    PageTableBase,\r
-    gHob->MemoryFreeUnder1MB.PhysicalStart, gHob->MemoryFreeUnder1MB.ResourceLength,\r
-    gHob->MemoryAbove1MB.PhysicalStart, gHob->MemoryAbove1MB.ResourceLength,\r
-    gHob->MemoryAbove4GB.PhysicalStart, gHob->MemoryAbove4GB.ResourceLength,\r
-    gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress, gHob->DxeCore.MemoryAllocationHeader.MemoryLength,\r
-    gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress, gHob->MemoryAllocation.AllocDescriptor.MemoryLength\r
-    );\r
-\r
-  ClearScreen();\r
-  PrintString (\r
-    "\n\n\n\n\n\n\n\n\n\n"\r
-    "                         WELCOME TO EFI WORLD!\n"\r
-    );\r
-  \r
-  EnterDxeMain (StackTop, Handoff->DxeCoreEntryPoint, gHob, PageTableBase);\r
-  PrintString ("Fail to enter DXE main!\n");\r
\r
-  //\r
-  // Should never get here\r
-  //\r
-  CpuDeadLoop ();\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-_ModuleEntryPoint (\r
-  IN EFILDRHANDOFF  *Handoff\r
-  )\r
-{\r
-  DxeInit(Handoff);\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/DxeIpl/DxeIpl.h b/DuetPkg/DxeIpl/DxeIpl.h
deleted file mode 100644 (file)
index 581c2e6..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/** @file\r
-  Internal header file for DxeIpl module.\r
-  \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#ifndef _DUET_DXEIPL_H_\r
-#define _DUET_DXEIPL_H_\r
-\r
-#include <FrameworkPei.h>\r
-\r
-#include "EfiLdrHandoff.h"\r
-#include "EfiFlashMap.h"\r
-\r
-#include <Guid/MemoryTypeInformation.h>\r
-#include <Guid/PciExpressBaseAddress.h>\r
-#include <Guid/AcpiDescription.h>\r
-\r
-#include <Guid/MemoryAllocationHob.h>\r
-#include <Guid/Acpi.h>\r
-#include <Guid/SmBios.h>\r
-#include <Guid/Mps.h>\r
-#include <Guid/FlashMapHob.h>\r
-#include <Guid/SystemNvDataGuid.h>\r
-#include <Guid/VariableFormat.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Guid/DxeCoreFileName.h>\r
-#include <Guid/LdrMemoryDescriptor.h>\r
-\r
-#include <Protocol/Decompress.h>\r
-#include <Protocol/StatusCode.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/IoLib.h>\r
-\r
-#endif // _DUET_DXEIPL_H_\r
-\r
diff --git a/DuetPkg/DxeIpl/DxeIpl.inf b/DuetPkg/DxeIpl/DxeIpl.inf
deleted file mode 100644 (file)
index ba7a2c2..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-## @file\r
-# \r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#    DxeIpl.inf\r
-#\r
-#  Abstract:\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeIpl\r
-  FILE_GUID                      = 2119BBD7-9432-4f47-B5E2-5C4EA31B6BDC\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  BaseMemoryLib\r
-  PrintLib\r
-  SerialPortLib\r
-  ReportStatusCodeLib\r
-  IoLib\r
-\r
-[Guids]\r
-  gEfiVariableGuid\r
-  gDxeCoreFileNameGuid\r
-  gLdrMemoryDescriptorGuid\r
-\r
-[Sources]\r
-  DxeIpl.h\r
-  DxeInit.c\r
-  LegacyTable.c\r
-  LegacyTable.h\r
-  PpisNeededByDxeCore.c\r
-  PpisNeededByDxeCore.h\r
-  HobGeneration.c\r
-  HobGeneration.h\r
-  SerialStatusCode.c\r
-  SerialStatusCode.h\r
-  Debug.c\r
-  Debug.h\r
-  \r
-[Sources.x64]\r
-  X64/EnterDxeCore.c\r
-  X64/Paging.c\r
-  X64/VirtualMemory.h\r
-\r
-[Sources.Ia32]\r
-  Ia32/EnterDxeCore.c\r
-  Ia32/Paging.c\r
-  Ia32/VirtualMemory.h\r
-\r
-[Depex]\r
-  TRUE\r
diff --git a/DuetPkg/DxeIpl/HobGeneration.c b/DuetPkg/DxeIpl/HobGeneration.c
deleted file mode 100644 (file)
index 03e44d5..0000000
+++ /dev/null
@@ -1,1000 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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
-  HobGeneration.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-#include "DxeIpl.h"\r
-#include "HobGeneration.h"\r
-#include "PpisNeededByDxeCore.h"\r
-#include "FlashLayout.h"\r
-#include "Debug.h"\r
-\r
-#define EFI_CPUID_EXTENDED_FUNCTION  0x80000000\r
-#define CPUID_EXTENDED_ADD_SIZE      0x80000008\r
-#define EBDA_VALUE_ADDRESS           0x40E\r
-\r
-HOB_TEMPLATE  gHobTemplate = {\r
-  { // Phit\r
-    {  // Header\r
-      EFI_HOB_TYPE_HANDOFF,                 // HobType\r
-      sizeof (EFI_HOB_HANDOFF_INFO_TABLE),  // HobLength\r
-      0                                     // Reserved\r
-    },\r
-    EFI_HOB_HANDOFF_TABLE_VERSION,          // Version\r
-    BOOT_WITH_FULL_CONFIGURATION,           // BootMode\r
-    0,                                      // EfiMemoryTop\r
-    0,                                      // EfiMemoryBottom\r
-    0,                                      // EfiFreeMemoryTop\r
-    0,                                      // EfiFreeMemoryBottom\r
-    0                                       // EfiEndOfHobList\r
-  }, \r
-  { // Bfv\r
-    {\r
-      EFI_HOB_TYPE_FV,                      // HobType\r
-      sizeof (EFI_HOB_FIRMWARE_VOLUME),     // HobLength\r
-      0                                     // Reserved\r
-    },\r
-    0,                                      // BaseAddress\r
-    0                                       // Length\r
-  },\r
-  { // BfvResource\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,     // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR), // HobLength\r
-      0                                     // Reserved\r
-    },\r
-    {\r
-      0                                     // Owner Guid\r
-    },\r
-    EFI_RESOURCE_FIRMWARE_DEVICE,           // ResourceType\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT    |\r
-     EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
-     EFI_RESOURCE_ATTRIBUTE_TESTED |\r
-     EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE),  // ResourceAttribute\r
-    0,                                              // PhysicalStart\r
-    0                                               // ResourceLength\r
-  },\r
-  { // Cpu\r
-    { // Header\r
-      EFI_HOB_TYPE_CPU,                     // HobType\r
-      sizeof (EFI_HOB_CPU),                 // HobLength\r
-      0                                     // Reserved\r
-    },\r
-    52,                                     // SizeOfMemorySpace - Architecture Max\r
-    16,                                     // SizeOfIoSpace,\r
-    {\r
-      0, 0, 0, 0, 0, 0                      // Reserved[6]\r
-    }\r
-  },\r
-  {   // Stack HOB\r
-    {   // header\r
-      EFI_HOB_TYPE_MEMORY_ALLOCATION,               // Hob type\r
-      sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK),     // Hob size\r
-      0                                             // reserved\r
-    },\r
-    {\r
-      EFI_HOB_MEMORY_ALLOC_STACK_GUID,\r
-      0x0,                                          // EFI_PHYSICAL_ADDRESS  MemoryBaseAddress;\r
-      0x0,                                          // UINT64                MemoryLength;\r
-      EfiBootServicesData,                          // EFI_MEMORY_TYPE       MemoryType;  \r
-      {0, 0, 0, 0}                                  // Reserved              Reserved[4]; \r
-    }\r
-  },\r
-  { // MemoryAllocation for HOB's & Images\r
-    {\r
-      EFI_HOB_TYPE_MEMORY_ALLOCATION,               // HobType\r
-      sizeof (EFI_HOB_MEMORY_ALLOCATION),           // HobLength\r
-      0                                             // Reserved\r
-    },\r
-    {\r
-      {\r
-        0, //EFI_HOB_MEMORY_ALLOC_MODULE_GUID       // Name\r
-      },\r
-      0x0,                                          // EFI_PHYSICAL_ADDRESS  MemoryBaseAddress;\r
-      0x0,                                          // UINT64                MemoryLength;\r
-      EfiBootServicesData,                          // EFI_MEMORY_TYPE       MemoryType;  \r
-      {\r
-        0, 0, 0, 0                                  // Reserved              Reserved[4]; \r
-      }\r
-    }\r
-   },\r
-  { // MemoryFreeUnder1MB for unused memory that DXE core will claim\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,             // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR),         // HobLength\r
-      0                                             // Reserved\r
-    },\r
-    {\r
-      0                                             // Owner Guid\r
-    },\r
-    EFI_RESOURCE_SYSTEM_MEMORY,                     // ResourceType\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT                 |\r
-     EFI_RESOURCE_ATTRIBUTE_TESTED                  |\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
-    0x0,                                            // PhysicalStart\r
-    0                                               // ResourceLength\r
-  },\r
-  { // MemoryFreeAbove1MB for unused memory that DXE core will claim\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,             // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR),         // HobLength\r
-      0                                             // Reserved\r
-    },\r
-    {\r
-      0                                             // Owner Guid\r
-    },\r
-    EFI_RESOURCE_SYSTEM_MEMORY,                     // ResourceType\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT                 |\r
-     EFI_RESOURCE_ATTRIBUTE_TESTED                  |\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
-    0x0,                                            // PhysicalStart\r
-    0                                               // ResourceLength\r
-  },\r
-  { // MemoryFreeAbove4GB for unused memory that DXE core will claim\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,             // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR),         // HobLength\r
-      0                                             // Reserved\r
-    },\r
-    {\r
-      0                                             // Owner Guid\r
-    },\r
-    EFI_RESOURCE_SYSTEM_MEMORY,                     // ResourceType\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
-    0x0,                                            // PhysicalStart\r
-    0                                               // ResourceLength\r
-  },\r
-  {   // Memory Allocation Module for DxeCore\r
-    {   // header\r
-      EFI_HOB_TYPE_MEMORY_ALLOCATION,               // Hob type\r
-      sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE),    // Hob size\r
-      0                                             // reserved\r
-    },\r
-    {\r
-      EFI_HOB_MEMORY_ALLOC_MODULE_GUID,\r
-      0x0,                                          // EFI_PHYSICAL_ADDRESS  MemoryBaseAddress;\r
-      0x0,                                          // UINT64                MemoryLength;\r
-      EfiBootServicesCode,                          // EFI_MEMORY_TYPE       MemoryType;  \r
-      {\r
-        0, 0, 0, 0                                  // UINT8                 Reserved[4]; \r
-      },\r
-    },\r
-    DXE_CORE_FILE_NAME_GUID,\r
-    0x0                                             //  EFI_PHYSICAL_ADDRESS of EntryPoint;\r
-  },\r
-  { // MemoryDxeCore\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,             // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR),         // HobLength\r
-      0                                             // Reserved\r
-    },\r
-    {\r
-      0                                             // Owner Guid\r
-    },\r
-    EFI_RESOURCE_SYSTEM_MEMORY,                     // ResourceType\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT                 |\r
-//     EFI_RESOURCE_ATTRIBUTE_TESTED                  | // Do not mark as TESTED, or DxeCore will find it and use it before check Allocation\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
-    0x0,                                            // PhysicalStart\r
-    0                                               // ResourceLength\r
-  },\r
-  { // Memory Map Hints to reduce fragmentation in the memory map\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,                    // Hob type\r
-        sizeof (MEMORY_TYPE_INFORMATION_HOB),           // Hob size\r
-        0,                                              // reserved\r
-      },\r
-      EFI_MEMORY_TYPE_INFORMATION_GUID\r
-    },\r
-    {\r
-      {\r
-        EfiACPIReclaimMemory,\r
-        0x80\r
-      },  // 0x80 pages = 512k for ASL\r
-      {\r
-        EfiACPIMemoryNVS,\r
-        0x100\r
-      },  // 0x100 pages = 1024k for S3, SMM, etc\r
-      {\r
-        EfiReservedMemoryType,\r
-        0x04\r
-      },  // 16k for BIOS Reserved\r
-      {\r
-        EfiRuntimeServicesData,\r
-        0x100\r
-      },\r
-      {\r
-        EfiRuntimeServicesCode,\r
-        0x100\r
-      },\r
-      {\r
-        EfiBootServicesCode,\r
-        0x200\r
-      },\r
-      {\r
-        EfiBootServicesData,\r
-        0x200\r
-      },\r
-      {\r
-        EfiLoaderCode,\r
-        0x100\r
-      },\r
-      {\r
-        EfiLoaderData,\r
-        0x100\r
-      },\r
-      {\r
-        EfiMaxMemoryType,\r
-        0\r
-      }\r
-    }\r
-  },\r
-  { // Pointer to ACPI Table\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (TABLE_HOB),                // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_ACPI_TABLE_GUID\r
-    },\r
-    0\r
-  },\r
-  { // Pointer to ACPI20 Table\r
-    {\r
-      {  \r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (TABLE_HOB),                // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_ACPI_20_TABLE_GUID\r
-    },\r
-    0\r
-  },\r
-  { // Pointer to SMBIOS Table\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (TABLE_HOB),                // Hob size\r
-        0                                  // reserved\r
-      },\r
-      SMBIOS_TABLE_GUID\r
-    },\r
-    0\r
-  },\r
-  { // Pointer to MPS Table\r
-    {\r
-      {\r
-         EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (TABLE_HOB),                // Hob size\r
-        0,                                 // reserved\r
-      },\r
-      EFI_MPS_TABLE_GUID\r
-    },\r
-    0\r
-  },\r
-  /**\r
-  { // Pointer to FlushInstructionCache\r
-    EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-    sizeof (PROTOCOL_HOB),             // Hob size\r
-    0,                                 // reserved\r
-    EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID,\r
-    NULL\r
-  },\r
-  { // Pointer to TransferControl\r
-    EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-    sizeof (PROTOCOL_HOB),             // Hob size\r
-    0,                                 // reserved\r
-    EFI_PEI_TRANSFER_CONTROL_GUID,\r
-    NULL\r
-  },\r
-  { // Pointer to PeCoffLoader\r
-    EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-    sizeof (PROTOCOL_HOB),             // Hob size\r
-    0,                                 // reserved\r
-    EFI_PEI_PE_COFF_LOADER_GUID,\r
-    NULL\r
-  },\r
-  { // Pointer to EfiDecompress\r
-    EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-    sizeof (PROTOCOL_HOB),             // Hob size\r
-    0,                                 // reserved\r
-    EFI_DECOMPRESS_PROTOCOL_GUID,\r
-    NULL\r
-  },\r
-  { // Pointer to TianoDecompress\r
-    EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-    sizeof (PROTOCOL_HOB),             // Hob size\r
-    0,                                 // reserved\r
-    EFI_TIANO_DECOMPRESS_PROTOCOL_GUID,\r
-    NULL\r
-  },\r
-  **/\r
-  { // Pointer to ReportStatusCode\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (PROTOCOL_HOB),             // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID\r
-    },\r
-    0\r
-  },\r
-  { // EFILDR Memory Descriptor\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (MEMORY_DESC_HOB),          // Hob size\r
-        0                                  // reserved\r
-      },\r
-      LDR_MEMORY_DESCRIPTOR_GUID\r
-    },\r
-    0,\r
-    NULL\r
-  },\r
-  { // Pci Express Base Address Hob\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (PCI_EXPRESS_BASE_HOB),     // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_PCI_EXPRESS_BASE_ADDRESS_GUID\r
-    },\r
-    {\r
-      0,\r
-      0,\r
-      0,\r
-    }\r
-  },\r
-  { // Acpi Description Hob\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (ACPI_DESCRIPTION_HOB),     // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_ACPI_DESCRIPTION_GUID\r
-    },\r
-    {\r
-      {\r
-        0,\r
-      },\r
-    }\r
-  },\r
-  { // NV Storage FV Resource\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,     // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR), // HobLength\r
-      0                                     // Reserved\r
-    },\r
-    {\r
-      0                                     // Owner Guid\r
-    },\r
-    EFI_RESOURCE_FIRMWARE_DEVICE,           // ResourceType\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT    |\r
-     EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
-     EFI_RESOURCE_ATTRIBUTE_TESTED |\r
-     EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE),  // ResourceAttribute\r
-    0,                                              // PhysicalStart (Fixed later)\r
-    NV_STORAGE_FVB_SIZE                             // ResourceLength\r
-  },\r
-  { // FVB holding NV Storage\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (FVB_HOB),\r
-        0\r
-      },\r
-      EFI_FLASH_MAP_HOB_GUID\r
-    },\r
-    {\r
-      {0, 0, 0},                       // Reserved[3]\r
-      EFI_FLASH_AREA_GUID_DEFINED,     // AreaType\r
-      EFI_SYSTEM_NV_DATA_FV_GUID ,     // AreaTypeGuid\r
-      1,\r
-      {\r
-        {\r
-          EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV, // SubAreaData.Attributes\r
-          0,                             // SubAreaData.Reserved\r
-          0,                             // SubAreaData.Base (Fixed later)\r
-          NV_STORAGE_FVB_SIZE,           // SubAreaData.Length\r
-          EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID // SubAreaData.FileSystem\r
-        }\r
-      }, \r
-      0,                               // VolumeSignature (Fixed later)\r
-      NV_STORAGE_FILE_PATH,            // Mapped file without padding\r
-                                       //  TotalFVBSize = FileSize + PaddingSize = multiple of BLOCK_SIZE\r
-      NV_STORAGE_SIZE + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH,\r
-                                       // ActuralSize\r
-      EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH\r
-    }\r
-  },\r
-  { // NV Storage Hob\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (FVB_HOB),                  // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_FLASH_MAP_HOB_GUID\r
-    },\r
-    {\r
-      {0, 0, 0},                       // Reserved[3]\r
-      EFI_FLASH_AREA_EFI_VARIABLES,    // AreaType\r
-      { 0 },                           // AreaTypeGuid\r
-      1,\r
-      {\r
-        {\r
-          EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV, // SubAreaData.Attributes\r
-          0,                             // SubAreaData.Reserved\r
-          0,                             // SubAreaData.Base (Fixed later)\r
-          NV_STORAGE_SIZE,               // SubAreaData.Length\r
-          EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID // SubAreaData.FileSystem\r
-        }\r
-      }, \r
-      0,\r
-      NV_STORAGE_FILE_PATH,\r
-      NV_STORAGE_SIZE,\r
-      0\r
-    }\r
-  },\r
-  { // NV Ftw FV Resource\r
-    {\r
-      EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,     // HobType\r
-      sizeof (EFI_HOB_RESOURCE_DESCRIPTOR), // HobLength\r
-      0                                     // Reserved\r
-    },\r
-    {\r
-      0                                     // Owner Guid\r
-    },\r
-    EFI_RESOURCE_FIRMWARE_DEVICE,           // ResourceType\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT    |\r
-     EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
-     EFI_RESOURCE_ATTRIBUTE_TESTED |\r
-     EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE),  // ResourceAttribute\r
-    0,                                              // PhysicalStart (Fixed later)\r
-    NV_FTW_FVB_SIZE                                 // ResourceLength\r
-  },  \r
-  { // FVB holding FTW spaces including Working & Spare space\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (FVB_HOB),\r
-        0\r
-      },\r
-      EFI_FLASH_MAP_HOB_GUID\r
-    },\r
-    {\r
-      {0, 0, 0},                       // Reserved[3]\r
-      EFI_FLASH_AREA_GUID_DEFINED,     // AreaType\r
-      EFI_SYSTEM_NV_DATA_FV_GUID,      // AreaTypeGuid\r
-      1,\r
-      {\r
-        {\r
-          EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV, // SubAreaData.Attributes\r
-          0,                             // SubAreaData.Reserved\r
-          0,                             // SubAreaData.Base (Fixed later)\r
-          NV_FTW_FVB_SIZE,               // SubAreaData.Length\r
-          EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID   // SubAreaData.FileSystem\r
-        }\r
-      }, \r
-      0,\r
-      L"",                             // Empty String indicates using memory\r
-      0,\r
-      0\r
-    }\r
-  },\r
-  { // NV Ftw working Hob\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (FVB_HOB),                  // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_FLASH_MAP_HOB_GUID\r
-    },\r
-    {\r
-      {0, 0, 0},                       // Reserved[3]\r
-      EFI_FLASH_AREA_FTW_STATE,        // AreaType\r
-      { 0 },                           // AreaTypeGuid\r
-      1,\r
-      {\r
-        {\r
-          EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV, // SubAreaData.Attributes\r
-          0,                             // SubAreaData.Reserved\r
-          0,                             // SubAreaData.Base (Fixed later)\r
-          NV_FTW_WORKING_SIZE,           // SubAreaData.Length\r
-          EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID // SubAreaData.FileSystem\r
-        }\r
-      }, \r
-      0,                               // VolumeSignature\r
-      L"",\r
-      0,\r
-      0\r
-    }\r
-  },\r
-  { // NV Ftw spare Hob\r
-    {\r
-      {\r
-        EFI_HOB_TYPE_GUID_EXTENSION,       // Hob type\r
-        sizeof (FVB_HOB),                  // Hob size\r
-        0                                  // reserved\r
-      },\r
-      EFI_FLASH_MAP_HOB_GUID\r
-    },\r
-    {\r
-      {0, 0, 0},                       // Reserved[3]\r
-      EFI_FLASH_AREA_FTW_BACKUP,       // AreaType\r
-      { 0 },                           // AreaTypeGuid\r
-      1,\r
-      {\r
-        {\r
-          EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV, // SubAreaData.Attributes\r
-          0,                             // SubAreaData.Reserved\r
-          0,                             // SubAreaData.Base (Fixed later)\r
-          NV_FTW_SPARE_SIZE,             // SubAreaData.Length\r
-          EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID // SubAreaData.FileSystem\r
-        }\r
-      }, \r
-      0,\r
-      L"",\r
-      0,\r
-      0\r
-    }\r
-  },\r
-  { // EndOfHobList\r
-    EFI_HOB_TYPE_END_OF_HOB_LIST,      // HobType\r
-    sizeof (EFI_HOB_GENERIC_HEADER),   // HobLength\r
-    0                                  // Reserved\r
-  }\r
-};\r
-\r
-HOB_TEMPLATE  *gHob = &gHobTemplate;\r
-\r
-VOID *\r
-PrepareHobMemory (\r
-  IN UINTN                    NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor\r
-  )\r
-/*++\r
-Description:\r
-  Update the Hob filling MemoryFreeUnder1MB, MemoryAbove1MB, MemoryAbove4GB\r
-\r
-Arguments:\r
-  NumberOfMemoryMapEntries - Count of Memory Descriptors\r
-  EfiMemoryDescriptor      - Point to the buffer containing NumberOfMemoryMapEntries Memory Descriptors\r
-\r
-Return:\r
-  VOID * : The end address of MemoryAbove1MB (or the top free memory under 4GB)\r
---*/\r
-{\r
-  UINTN                Index;\r
-  UINT64               EbdaAddress;\r
-\r
-  //\r
-  // Prepare Low Memory\r
-  // 0x18 pages is 72 KB.\r
-  //\r
-  EbdaAddress = ((UINT64)(*(UINT16 *)(UINTN)(EBDA_VALUE_ADDRESS))) << 4;\r
-  if (EbdaAddress < 0x9A000 || EbdaAddress > EFI_MEMORY_BELOW_1MB_END) {\r
-    //\r
-    // EBDA should not go below 0x9A000 in any implementation,\r
-    // so add check here to make sure EBDA_VALUE_ADDRESS has a valid value.\r
-    //\r
-    EbdaAddress = EFI_MEMORY_BELOW_1MB_END;\r
-  }\r
-  gHob->MemoryFreeUnder1MB.ResourceLength = EbdaAddress - EFI_MEMORY_BELOW_1MB_START;\r
-  gHob->MemoryFreeUnder1MB.PhysicalStart  = EFI_MEMORY_BELOW_1MB_START;\r
-\r
-  //\r
-  // Prepare High Memory\r
-  // Assume Memory Map is ordered from low to high\r
-  //\r
-  gHob->MemoryAbove1MB.PhysicalStart   = 0;\r
-  gHob->MemoryAbove1MB.ResourceLength  = 0;\r
-  gHob->MemoryAbove4GB.PhysicalStart   = 0;\r
-  gHob->MemoryAbove4GB.ResourceLength  = 0;\r
-\r
-  for (Index = 0; Index < NumberOfMemoryMapEntries; Index++) {\r
-    //\r
-    // Skip regions below 1MB\r
-    //\r
-    if (EfiMemoryDescriptor[Index].PhysicalStart < 0x100000) {\r
-      continue;\r
-    }\r
-    //\r
-    // Process regions above 1MB\r
-    //\r
-    if (EfiMemoryDescriptor[Index].PhysicalStart >= 0x100000) {\r
-      if (EfiMemoryDescriptor[Index].Type == EfiConventionalMemory) {\r
-        if (gHob->MemoryAbove1MB.PhysicalStart == 0) {\r
-          gHob->MemoryAbove1MB.PhysicalStart = EfiMemoryDescriptor[Index].PhysicalStart;\r
-          gHob->MemoryAbove1MB.ResourceLength = LShiftU64 (EfiMemoryDescriptor[Index].NumberOfPages, EFI_PAGE_SHIFT);\r
-        } else if (gHob->MemoryAbove1MB.PhysicalStart + gHob->MemoryAbove1MB.ResourceLength == EfiMemoryDescriptor[Index].PhysicalStart) {\r
-          gHob->MemoryAbove1MB.ResourceLength += LShiftU64 (EfiMemoryDescriptor[Index].NumberOfPages, EFI_PAGE_SHIFT);\r
-        }\r
-      }\r
-      if ((EfiMemoryDescriptor[Index].Type == EfiReservedMemoryType) ||\r
-          (EfiMemoryDescriptor[Index].Type >= EfiACPIReclaimMemory) ) {\r
-        continue;\r
-      }\r
-      if ((EfiMemoryDescriptor[Index].Type == EfiRuntimeServicesCode) ||\r
-          (EfiMemoryDescriptor[Index].Type == EfiRuntimeServicesData)) {\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // Process region above 4GB\r
-    //\r
-    if (EfiMemoryDescriptor[Index].PhysicalStart >= 0x100000000LL) {\r
-      if (EfiMemoryDescriptor[Index].Type == EfiConventionalMemory) {\r
-        if (gHob->MemoryAbove4GB.PhysicalStart == 0) {\r
-          gHob->MemoryAbove4GB.PhysicalStart  = EfiMemoryDescriptor[Index].PhysicalStart;\r
-          gHob->MemoryAbove4GB.ResourceLength = LShiftU64 (EfiMemoryDescriptor[Index].NumberOfPages, EFI_PAGE_SHIFT);\r
-        }\r
-        if (gHob->MemoryAbove4GB.PhysicalStart + gHob->MemoryAbove4GB.ResourceLength == \r
-            EfiMemoryDescriptor[Index].PhysicalStart) {\r
-          gHob->MemoryAbove4GB.ResourceLength += LShiftU64 (EfiMemoryDescriptor[Index].NumberOfPages, EFI_PAGE_SHIFT);\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  if (gHob->MemoryAbove4GB.ResourceLength == 0) {\r
-    //\r
-    // If there is no memory above 4GB then change the resource descriptor HOB\r
-    //  into another type. I'm doing this as it's unclear if a resource\r
-    //  descriptor HOB of length zero is valid. Spec does not say it's illegal,\r
-    //  but code in EDK does not seem to handle this case.\r
-    //\r
-    gHob->MemoryAbove4GB.Header.HobType = EFI_HOB_TYPE_UNUSED;\r
-  }\r
-\r
-  return (VOID *)(UINTN)(gHob->MemoryAbove1MB.PhysicalStart + gHob->MemoryAbove1MB.ResourceLength);\r
-}\r
-\r
-VOID *\r
-PrepareHobStack (\r
-  IN VOID *StackTop\r
-  )\r
-{\r
-  gHob->Stack.AllocDescriptor.MemoryLength      = EFI_MEMORY_STACK_PAGE_NUM * EFI_PAGE_SIZE;\r
-  gHob->Stack.AllocDescriptor.MemoryBaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)StackTop - gHob->Stack.AllocDescriptor.MemoryLength;\r
-\r
-  return (VOID *)(UINTN)gHob->Stack.AllocDescriptor.MemoryBaseAddress;\r
-}\r
-\r
-VOID *\r
-PrepareHobMemoryDescriptor (\r
-  VOID                          *MemoryDescriptorTop,\r
-  UINTN                         MemDescCount,\r
-  EFI_MEMORY_DESCRIPTOR         *MemDesc\r
-  )\r
-{\r
-  gHob->MemoryDescriptor.MemDescCount = MemDescCount;\r
-  gHob->MemoryDescriptor.MemDesc      = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryDescriptorTop - MemDescCount * sizeof(EFI_MEMORY_DESCRIPTOR));\r
-  //\r
-  // Make MemoryDescriptor.MemDesc page aligned\r
-  //\r
-  gHob->MemoryDescriptor.MemDesc      = (EFI_MEMORY_DESCRIPTOR *)((UINTN) gHob->MemoryDescriptor.MemDesc & ~EFI_PAGE_MASK);\r
-\r
-  CopyMem (gHob->MemoryDescriptor.MemDesc, MemDesc, MemDescCount * sizeof(EFI_MEMORY_DESCRIPTOR));\r
-\r
-  return gHob->MemoryDescriptor.MemDesc;\r
-}\r
-\r
-VOID\r
-PrepareHobBfv (\r
-  VOID  *Bfv,\r
-  UINTN BfvLength\r
-  )\r
-{\r
-  //UINTN BfvLengthPageSize;\r
-\r
-  //\r
-  // Calculate BFV location at top of the memory region.\r
-  // This is like a RAM Disk. Align to page boundary.\r
-  //\r
-  //BfvLengthPageSize = EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (BfvLength));\r
\r
-  gHob->Bfv.BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Bfv;\r
-  gHob->Bfv.Length = BfvLength;\r
-\r
-  //\r
-  // Resource descriptor for the FV\r
-  //\r
-  gHob->BfvResource.PhysicalStart = gHob->Bfv.BaseAddress;\r
-  gHob->BfvResource.ResourceLength = gHob->Bfv.Length;\r
-}\r
-\r
-VOID\r
-PrepareHobDxeCore (\r
-  VOID                  *DxeCoreEntryPoint,\r
-  EFI_PHYSICAL_ADDRESS  DxeCoreImageBase,\r
-  UINT64                DxeCoreLength\r
-  )\r
-{\r
-  gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress = DxeCoreImageBase;\r
-  gHob->DxeCore.MemoryAllocationHeader.MemoryLength = DxeCoreLength;\r
-  gHob->DxeCore.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)DxeCoreEntryPoint;\r
-\r
-\r
-  gHob->MemoryDxeCore.PhysicalStart   = DxeCoreImageBase;\r
-  gHob->MemoryDxeCore.ResourceLength  = DxeCoreLength;  \r
-}\r
-\r
-VOID *\r
-PrepareHobNvStorage (\r
-  VOID *NvStorageTop\r
-  )\r
-/*\r
-  Initialize Block-Aligned Firmware Block.\r
-\r
-  Variable:\r
-           +-------------------+\r
-           |     FV_Header     |\r
-           +-------------------+\r
-           |                   |\r
-           |VAR_STORAGE(0x4000)|\r
-           |                   |\r
-           +-------------------+\r
-  FTW:\r
-           +-------------------+\r
-           |     FV_Header     |\r
-           +-------------------+\r
-           |                   |\r
-           |   Working(0x2000) |\r
-           |                   |\r
-           +-------------------+\r
-           |                   |\r
-           |   Spare(0x10000)  |\r
-           |                   |\r
-           +-------------------+\r
-*/\r
-{\r
-  STATIC VARIABLE_STORE_HEADER VarStoreHeader = {\r
-    VARIABLE_STORE_SIGNATURE,\r
-    0xffffffff,                 // will be fixed in Variable driver\r
-    VARIABLE_STORE_FORMATTED,\r
-    VARIABLE_STORE_HEALTHY,\r
-    0,\r
-    0\r
-  };\r
-  \r
-  STATIC EFI_FIRMWARE_VOLUME_HEADER NvStorageFvbHeader = {\r
-    {\r
-      0,\r
-    },  // ZeroVector[16]\r
-    EFI_SYSTEM_NV_DATA_FV_GUID,\r
-    NV_STORAGE_FVB_SIZE,\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
-    EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH,\r
-    0,  // CheckSum\r
-    0,  // ExtHeaderOffset\r
-    {\r
-      0,\r
-    },  // Reserved[1]\r
-    1,  // Revision\r
-    {\r
-      {\r
-        NV_STORAGE_FVB_BLOCK_NUM,\r
-        FV_BLOCK_SIZE,\r
-      }\r
-    }\r
-  };\r
-\r
-  STATIC EFI_FV_BLOCK_MAP_ENTRY BlockMapEntryEnd = {0, 0};\r
-\r
-  EFI_PHYSICAL_ADDRESS StorageFvbBase;\r
-  EFI_PHYSICAL_ADDRESS FtwFvbBase;\r
-\r
-  UINT16               *Ptr;\r
-  UINT16               Checksum;\r
-\r
-\r
-  //\r
-  // Use first 16-byte Reset Vector of FVB to store extra information\r
-  //   UINT32 Offset 0 stores the volume signature\r
-  //   UINT8  Offset 4 : should init the Variable Store Header if non-zero\r
-  //\r
-  gHob->NvStorageFvb.FvbInfo.VolumeId   = *(UINT32 *) (UINTN) (NV_STORAGE_STATE);\r
-  gHob->NvStorage.   FvbInfo.VolumeId   = *(UINT32 *) (UINTN) (NV_STORAGE_STATE);\r
-\r
-  //\r
-  // *(NV_STORAGE_STATE + 4):\r
-  //   2 - Size error\r
-  //   1 - File not exist\r
-  //   0 - File exist with correct size\r
-  //\r
-  if (*(UINT8 *) (UINTN) (NV_STORAGE_STATE + 4) == 2) {\r
-    ClearScreen ();\r
-    PrintString ("Error: Size of Efivar.bin should be 16k!\n");\r
-    CpuDeadLoop();\r
-  }\r
-  \r
-  if (*(UINT8 *) (UINTN) (NV_STORAGE_STATE + 4) != 0) {\r
-    //\r
-    // Efivar.bin doesn't exist\r
-    //  1. Init variable storage header to valid header\r
-    //\r
-    CopyMem (\r
-      (VOID *) (UINTN) NV_STORAGE_START,\r
-      &VarStoreHeader,\r
-      sizeof (VARIABLE_STORE_HEADER)\r
-    );\r
-    //\r
-    //  2. set all bits in variable storage body to 1\r
-    //\r
-    SetMem (\r
-      (VOID *) (UINTN) (NV_STORAGE_START + sizeof (VARIABLE_STORE_HEADER)),\r
-      NV_STORAGE_SIZE - sizeof (VARIABLE_STORE_HEADER),\r
-      0xff\r
-    );\r
-  }\r
-\r
-  //\r
-  // Relocate variable storage\r
-  // \r
-  //  1. Init FVB Header to valid header: First 0x48 bytes\r
-  //     In real platform, these fields are fixed by tools\r
-  //\r
-  //\r
-  Checksum = 0;\r
-  for (\r
-    Ptr = (UINT16 *) &NvStorageFvbHeader; \r
-    Ptr < (UINT16 *) ((UINTN) (UINT8 *) &NvStorageFvbHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-    ++Ptr\r
-    ) {\r
-    Checksum = (UINT16) (Checksum + (*Ptr));\r
-  }\r
-  NvStorageFvbHeader.Checksum = (UINT16) (0x10000 - Checksum);\r
-  StorageFvbBase = (EFI_PHYSICAL_ADDRESS)(((UINTN)NvStorageTop - NV_STORAGE_FVB_SIZE - NV_FTW_FVB_SIZE) & ~EFI_PAGE_MASK);\r
-  CopyMem ((VOID *) (UINTN) StorageFvbBase, &NvStorageFvbHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-  CopyMem (\r
-    (VOID *) (UINTN) (StorageFvbBase + sizeof (EFI_FIRMWARE_VOLUME_HEADER)),\r
-    &BlockMapEntryEnd,\r
-    sizeof (EFI_FV_BLOCK_MAP_ENTRY)\r
-  );\r
-  \r
-  //\r
-  //  2. Relocate variable data\r
-  //\r
-  CopyMem (\r
-    (VOID *) (UINTN) (StorageFvbBase + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH),\r
-    (VOID *) (UINTN) NV_STORAGE_START,\r
-    NV_STORAGE_SIZE\r
-  );\r
-\r
-  //\r
-  //  3. Set the remaining memory to 0xff\r
-  //\r
-  SetMem (\r
-    (VOID *) (UINTN) (StorageFvbBase + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH + NV_STORAGE_SIZE),\r
-    NV_STORAGE_FVB_SIZE - NV_STORAGE_SIZE - EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH,\r
-    0xff\r
-  );\r
-\r
-  //\r
-  // Create the FVB holding NV Storage in memory\r
-  //\r
-  gHob->NvStorageFvResource.PhysicalStart =\r
-    gHob->NvStorageFvb.FvbInfo.Entries[0].Base = StorageFvbBase;\r
-  //\r
-  // Create the NV Storage Hob\r
-  //\r
-  gHob->NvStorage.FvbInfo.Entries[0].Base = StorageFvbBase + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH;\r
-\r
-  //\r
-  // Create the FVB holding FTW spaces\r
-  //\r
-  FtwFvbBase = (EFI_PHYSICAL_ADDRESS)((UINTN) StorageFvbBase + NV_STORAGE_FVB_SIZE);\r
-  gHob->NvFtwFvResource.PhysicalStart =\r
-    gHob->NvFtwFvb.FvbInfo.Entries[0].Base = FtwFvbBase;\r
-  //\r
-  // Put FTW Working in front\r
-  //\r
-  gHob->NvFtwWorking.FvbInfo.Entries[0].Base = FtwFvbBase + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH;\r
-\r
-  //\r
-  // Put FTW Spare area after FTW Working area\r
-  //\r
-  gHob->NvFtwSpare.FvbInfo.Entries[0].Base = \r
-    (EFI_PHYSICAL_ADDRESS)((UINTN) FtwFvbBase + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH + NV_FTW_WORKING_SIZE);\r
-  \r
-  return (VOID *)(UINTN)StorageFvbBase;\r
-}\r
-\r
-VOID\r
-PrepareHobPhit (\r
-  VOID *MemoryTop,\r
-  VOID *FreeMemoryTop\r
-  )\r
-{\r
-  gHob->Phit.EfiMemoryTop        = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryTop;\r
-  gHob->Phit.EfiMemoryBottom     = gHob->Phit.EfiMemoryTop - CONSUMED_MEMORY;\r
-  gHob->Phit.EfiFreeMemoryTop    = (EFI_PHYSICAL_ADDRESS)(UINTN)FreeMemoryTop;\r
-  gHob->Phit.EfiFreeMemoryBottom = gHob->Phit.EfiMemoryBottom + sizeof(HOB_TEMPLATE);\r
-\r
-  CopyMem ((VOID *)(UINTN)gHob->Phit.EfiMemoryBottom, gHob, sizeof(HOB_TEMPLATE));\r
-  gHob = (HOB_TEMPLATE *)(UINTN)gHob->Phit.EfiMemoryBottom;\r
-\r
-  gHob->Phit.EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)&gHob->EndOfHobList;\r
-}\r
-\r
-VOID\r
-PrepareHobCpu (\r
-  VOID\r
-  )\r
-{\r
-  UINT32  CpuidEax;\r
-\r
-  //\r
-  // Create a CPU hand-off information\r
-  //\r
-  gHob->Cpu.SizeOfMemorySpace = 36;\r
-\r
-  AsmCpuid (EFI_CPUID_EXTENDED_FUNCTION, &CpuidEax, NULL, NULL, NULL);\r
-  if (CpuidEax >= CPUID_EXTENDED_ADD_SIZE) {\r
-    AsmCpuid (CPUID_EXTENDED_ADD_SIZE, &CpuidEax, NULL, NULL, NULL);\r
-    gHob->Cpu.SizeOfMemorySpace = (UINT8)(CpuidEax & 0xFF);\r
-  }\r
-}\r
-\r
-VOID\r
-CompleteHobGeneration (\r
-  VOID\r
-  )\r
-{\r
-  gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress  = gHob->Phit.EfiFreeMemoryTop;\r
-  //\r
-  // Reserve all the memory under Stack above FreeMemoryTop as allocated\r
-  //\r
-  gHob->MemoryAllocation.AllocDescriptor.MemoryLength       = gHob->Stack.AllocDescriptor.MemoryBaseAddress - gHob->Phit.EfiFreeMemoryTop;\r
-\r
-  //\r
-  // adjust Above1MB ResourceLength\r
-  //\r
-  if (gHob->MemoryAbove1MB.PhysicalStart + gHob->MemoryAbove1MB.ResourceLength > gHob->Phit.EfiMemoryTop) {\r
-    gHob->MemoryAbove1MB.ResourceLength = gHob->Phit.EfiMemoryTop - gHob->MemoryAbove1MB.PhysicalStart;\r
-  }\r
-}\r
-\r
diff --git a/DuetPkg/DxeIpl/HobGeneration.h b/DuetPkg/DxeIpl/HobGeneration.h
deleted file mode 100644 (file)
index f9f8f31..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  HobGeneration.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#ifndef _DXELDR_HOB_GENERATION_H_\r
-#define _DXELDR_HOB_GENERATION_H_\r
-\r
-#include "DxeIpl.h"\r
-\r
-#define EFI_MEMORY_BELOW_1MB_START     0x86000\r
-#define EFI_MEMORY_BELOW_1MB_END       0x9F800\r
-#define EFI_MEMORY_STACK_PAGE_NUM      0x20\r
-#define CONSUMED_MEMORY                0x100000 * 80\r
-\r
-#define NV_STORAGE_START               0x15000\r
-#define NV_STORAGE_STATE               0x19000\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  EFI_MEMORY_TYPE_INFORMATION   Info[10];\r
-} MEMORY_TYPE_INFORMATION_HOB;\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  EFI_PHYSICAL_ADDRESS          Table;\r
-} TABLE_HOB;\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  EFI_PHYSICAL_ADDRESS          Interface;\r
-} PROTOCOL_HOB;\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE                         Hob;\r
-  // Note: we get only one PCI Segment now.\r
-  EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION  PciExpressBaseAddressInfo;\r
-} PCI_EXPRESS_BASE_HOB;\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  EFI_ACPI_DESCRIPTION          AcpiDescription;\r
-} ACPI_DESCRIPTION_HOB;\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  EFI_FLASH_MAP_FS_ENTRY_DATA   FvbInfo;\r
-} FVB_HOB;\r
-\r
-typedef struct {\r
-  EFI_HOB_HANDOFF_INFO_TABLE        Phit;\r
-  EFI_HOB_FIRMWARE_VOLUME           Bfv;\r
-  EFI_HOB_RESOURCE_DESCRIPTOR       BfvResource;\r
-  EFI_HOB_CPU                       Cpu;\r
-  EFI_HOB_MEMORY_ALLOCATION_STACK   Stack;\r
-  EFI_HOB_MEMORY_ALLOCATION         MemoryAllocation;\r
-  EFI_HOB_RESOURCE_DESCRIPTOR       MemoryFreeUnder1MB;\r
-  EFI_HOB_RESOURCE_DESCRIPTOR       MemoryAbove1MB;\r
-  EFI_HOB_RESOURCE_DESCRIPTOR       MemoryAbove4GB;\r
-  EFI_HOB_MEMORY_ALLOCATION_MODULE  DxeCore;\r
-  EFI_HOB_RESOURCE_DESCRIPTOR       MemoryDxeCore;\r
-  MEMORY_TYPE_INFORMATION_HOB       MemoryTypeInfo;\r
-  TABLE_HOB                         Acpi;\r
-  TABLE_HOB                         Acpi20;\r
-  TABLE_HOB                         Smbios;\r
-  TABLE_HOB                         Mps;\r
-  /**\r
-  PROTOCOL_HOB                      FlushInstructionCache;\r
-  PROTOCOL_HOB                      TransferControl;\r
-  PROTOCOL_HOB                      PeCoffLoader;\r
-  PROTOCOL_HOB                      EfiDecompress;\r
-  PROTOCOL_HOB                      TianoDecompress;\r
-  **/\r
-  PROTOCOL_HOB                      SerialStatusCode;\r
-  MEMORY_DESC_HOB                   MemoryDescriptor;\r
-  PCI_EXPRESS_BASE_HOB              PciExpress;\r
-  ACPI_DESCRIPTION_HOB              AcpiInfo;\r
-  \r
-  EFI_HOB_RESOURCE_DESCRIPTOR       NvStorageFvResource;\r
-\r
-  FVB_HOB                           NvStorageFvb;\r
-  FVB_HOB                           NvStorage;\r
-  \r
-  EFI_HOB_RESOURCE_DESCRIPTOR       NvFtwFvResource;\r
-  FVB_HOB                           NvFtwFvb;\r
-  FVB_HOB                           NvFtwWorking;\r
-  FVB_HOB                           NvFtwSpare;\r
-  \r
-  EFI_HOB_GENERIC_HEADER            EndOfHobList;\r
-} HOB_TEMPLATE;\r
-\r
-#pragma pack()\r
-\r
-extern HOB_TEMPLATE  *gHob;\r
-\r
-VOID *\r
-PrepareHobStack (\r
-  IN VOID *StackTop\r
-  );\r
-\r
-VOID\r
-PrepareHobBfv (\r
-  VOID  *Bfv,\r
-  UINTN BfvLength\r
-  );\r
-\r
-VOID *\r
-PrepareHobMemory (\r
-  IN UINTN                    NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor\r
-  );\r
-\r
-VOID\r
-PrepareHobDxeCore (\r
-  VOID                  *DxeCoreEntryPoint,\r
-  EFI_PHYSICAL_ADDRESS  DxeCoreImageBase,\r
-  UINT64                DxeCoreLength\r
-  );\r
-\r
-VOID *\r
-PreparePageTable (\r
-  VOID  *PageNumberTop,\r
-  UINT8 SizeOfMemorySpace\r
-  );\r
-\r
-VOID *\r
-PrepareHobMemoryDescriptor (\r
-  VOID                          *MemoryDescriptorTop,\r
-  UINTN                         MemDescCount,\r
-  EFI_MEMORY_DESCRIPTOR         *MemDesc\r
-  );\r
-\r
-VOID\r
-PrepareHobPhit (\r
-  VOID *MemoryTop,\r
-  VOID *FreeMemoryTop\r
-  );\r
-\r
-VOID *\r
-PrepareHobNvStorage (\r
-  VOID *NvStorageTop\r
-  );\r
-\r
-VOID\r
-PrepareHobCpu (\r
-  VOID\r
-  );\r
-\r
-VOID\r
-CompleteHobGeneration (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/DxeIpl/Ia32/EnterDxeCore.c b/DuetPkg/DxeIpl/Ia32/EnterDxeCore.c
deleted file mode 100644 (file)
index aff0ac6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @file\r
-  IA32 specific code to enter DxeCore\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#include "DxeIpl.h"\r
-\r
-VOID\r
-EnterDxeMain (\r
-  IN VOID *StackTop,\r
-  IN VOID *DxeCoreEntryPoint,\r
-  IN VOID *Hob,\r
-  IN VOID *PageTable\r
-  )\r
-{\r
-  SwitchStack (\r
-    (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
-    Hob,\r
-    NULL,\r
-    StackTop\r
-    );\r
-}\r
diff --git a/DuetPkg/DxeIpl/Ia32/Paging.c b/DuetPkg/DxeIpl/Ia32/Paging.c
deleted file mode 100644 (file)
index eb44042..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-  Paging.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#include "DxeIpl.h"\r
-#include "HobGeneration.h"\r
-#include "VirtualMemory.h"\r
-#include "Debug.h"\r
-\r
-#define EFI_PAGE_SIZE_4K      0x1000\r
-#define EFI_PAGE_SIZE_4M      0x400000\r
-\r
-//\r
-// Create 4G 4M-page table\r
-// PDE (31:22)   :  1024 entries\r
-//\r
-#define EFI_MAX_ENTRY_NUM     1024\r
-\r
-#define EFI_PDE_ENTRY_NUM     EFI_MAX_ENTRY_NUM\r
-\r
-#define EFI_PDE_PAGE_NUM      1\r
-\r
-#define EFI_PAGE_NUMBER_4M    (EFI_PDE_PAGE_NUM)\r
-\r
-//\r
-// Create 4M 4K-page table\r
-// PTE (21:12)   :  1024 entries\r
-//\r
-#define EFI_PTE_ENTRY_NUM     EFI_MAX_ENTRY_NUM\r
-#define EFI_PTE_PAGE_NUM      1\r
-\r
-#define EFI_PAGE_NUMBER_4K    (EFI_PTE_PAGE_NUM)\r
-\r
-#define EFI_PAGE_NUMBER       (EFI_PAGE_NUMBER_4M + EFI_PAGE_NUMBER_4K)\r
-\r
-VOID\r
-EnableNullPointerProtection (\r
-  UINT8 *PageTable\r
-  )\r
-{\r
-  IA32_PAGE_TABLE_ENTRY_4K                      *PageTableEntry4KB;\r
-\r
-  PageTableEntry4KB = (IA32_PAGE_TABLE_ENTRY_4K *)((UINTN)PageTable + EFI_PAGE_NUMBER_4M * EFI_PAGE_SIZE_4K);\r
-\r
-  //\r
-  // Fill in the Page Table entries\r
-  // Mark 0~4K as not present\r
-  //\r
-  PageTableEntry4KB->Bits.Present = 0;\r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-Ia32Create4KPageTables (\r
-  UINT8 *PageTable\r
-  )\r
-{\r
-  UINT64                                        PageAddress;\r
-  UINTN                                         PTEIndex;\r
-  IA32_PAGE_DIRECTORY_ENTRY_4K                  *PageDirectoryEntry4KB;\r
-  IA32_PAGE_TABLE_ENTRY_4K                      *PageTableEntry4KB;\r
-\r
-  PageAddress = 0;\r
-\r
-  //\r
-  //  Page Table structure 2 level 4K.\r
-  //\r
-  //  Page Table 4K  : PageDirectoryEntry4K      : bits 31-22\r
-  //                   PageTableEntry            : bits 21-12\r
-  //\r
-\r
-  PageTableEntry4KB = (IA32_PAGE_TABLE_ENTRY_4K *)((UINTN)PageTable + EFI_PAGE_NUMBER_4M * EFI_PAGE_SIZE_4K);\r
-  PageDirectoryEntry4KB = (IA32_PAGE_DIRECTORY_ENTRY_4K *)((UINTN)PageTable);\r
-\r
-  PageDirectoryEntry4KB->Uint32 = (UINT32)(UINTN)PageTableEntry4KB;\r
-  PageDirectoryEntry4KB->Bits.ReadWrite = 0;\r
-  PageDirectoryEntry4KB->Bits.Present = 1;\r
-  PageDirectoryEntry4KB->Bits.MustBeZero = 1;\r
-\r
-  for (PTEIndex = 0; PTEIndex < EFI_PTE_ENTRY_NUM; PTEIndex++, PageTableEntry4KB++) {\r
-    //\r
-    // Fill in the Page Table entries\r
-    //\r
-    PageTableEntry4KB->Uint32 = (UINT32)PageAddress;\r
-    PageTableEntry4KB->Bits.ReadWrite = 1;\r
-    PageTableEntry4KB->Bits.Present = 1;\r
-\r
-    PageAddress += EFI_PAGE_SIZE_4K;\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-Ia32Create4MPageTables (\r
-  UINT8 *PageTable\r
-  )\r
-{\r
-  UINT32                                        PageAddress;\r
-  UINT8                                         *TempPageTable;\r
-  UINTN                                         PDEIndex;\r
-  IA32_PAGE_TABLE_ENTRY_4M                      *PageDirectoryEntry4MB;\r
-\r
-  TempPageTable = PageTable;\r
-\r
-  PageAddress = 0;\r
-\r
-  //\r
-  //  Page Table structure 1 level 4MB.\r
-  //\r
-  //  Page Table 4MB : PageDirectoryEntry4M      : bits 31-22\r
-  //\r
-\r
-  PageDirectoryEntry4MB = (IA32_PAGE_TABLE_ENTRY_4M *)TempPageTable;\r
-\r
-  for (PDEIndex = 0; PDEIndex < EFI_PDE_ENTRY_NUM; PDEIndex++, PageDirectoryEntry4MB++) {\r
-    //\r
-    // Fill in the Page Directory entries\r
-    //\r
-    PageDirectoryEntry4MB->Uint32 = (UINT32)PageAddress;\r
-    PageDirectoryEntry4MB->Bits.ReadWrite = 1;\r
-    PageDirectoryEntry4MB->Bits.Present = 1;\r
-    PageDirectoryEntry4MB->Bits.MustBe1 = 1;\r
-\r
-    PageAddress += EFI_PAGE_SIZE_4M;\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-VOID *\r
-PreparePageTable (\r
-  VOID  *PageNumberTop,\r
-  UINT8 SizeOfMemorySpace \r
-  )\r
-/*++\r
-Description:\r
-  Generate pagetable below PageNumberTop, \r
-  and return the bottom address of pagetable for putting other things later.\r
---*/\r
-{\r
-  VOID *PageNumberBase;\r
-\r
-  PageNumberBase = (VOID *)((UINTN)PageNumberTop - EFI_PAGE_NUMBER * EFI_PAGE_SIZE_4K);\r
-  ZeroMem (PageNumberBase, EFI_PAGE_NUMBER * EFI_PAGE_SIZE_4K);\r
-\r
-  Ia32Create4MPageTables (PageNumberBase);\r
-  Ia32Create4KPageTables (PageNumberBase);\r
-  //\r
-  // Not enable NULL Pointer Protection if using INTX call\r
-  //\r
-//  EnableNullPointerProtection (PageNumberBase);\r
-\r
-  return PageNumberBase;\r
-}\r
diff --git a/DuetPkg/DxeIpl/Ia32/VirtualMemory.h b/DuetPkg/DxeIpl/Ia32/VirtualMemory.h
deleted file mode 100644 (file)
index 0b5fc0e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  VirtualMemory.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-  \r
-#ifndef _VIRTUAL_MEMORY_H_\r
-#define _VIRTUAL_MEMORY_H_\r
-\r
-#pragma pack(1)\r
-\r
-//\r
-// Page Directory Entry 4K\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT32  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
-    UINT32  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT32  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT32  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT32  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT32  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
-    UINT32  MustBeZero:3;             // Must Be Zero\r
-    UINT32  Available:3;              // Available for use by system software\r
-    UINT32  PageTableBaseAddress:20;  // Page Table Base Address\r
-  } Bits;\r
-  UINT32    Uint32;\r
-} IA32_PAGE_DIRECTORY_ENTRY_4K;\r
-\r
-//\r
-// Page Table Entry 4K\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT32  Present:1;                // 0 = Not present in memory, 1 = Present in memory \r
-    UINT32  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT32  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT32  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT32  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT32  Accessed:1;               // 0 = Not accessed (cleared by software), 1 = Accessed (set by CPU)\r
-    UINT32  Dirty:1;                  // 0 = Not written to (cleared by software), 1 = Written to (set by CPU)\r
-    UINT32  PAT:1;                    // 0 = Disable PAT, 1 = Enable PAT\r
-    UINT32  Global:1;                 // Ignored\r
-    UINT32  Available:3;              // Available for use by system software\r
-    UINT32  PageTableBaseAddress:20;  // Page Table Base Address\r
-  } Bits;\r
-  UINT32    Uint32;\r
-} IA32_PAGE_TABLE_ENTRY_4K;\r
-\r
-//\r
-// Page Table Entry 4M\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT32  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
-    UINT32  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT32  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT32  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT32  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT32  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
-    UINT32  Dirty:1;                  // 0 = Not Dirty, 1 = written by processor on access to page\r
-    UINT32  MustBe1:1;                // Must be 1 \r
-    UINT32  Global:1;                 // 0 = Not global page, 1 = global page TLB not cleared on CR3 write\r
-    UINT32  Available:3;              // Available for use by system software\r
-    UINT32  PAT:1;                    //\r
-    UINT32  MustBeZero:9;             // Must be zero;\r
-    UINT32  PageTableBaseAddress:10;  // Page Table Base Address\r
-  } Bits;\r
-  UINT32    Uint32;\r
-} IA32_PAGE_TABLE_ENTRY_4M;\r
-\r
-#pragma pack()\r
-\r
-#endif \r
diff --git a/DuetPkg/DxeIpl/LegacyTable.c b/DuetPkg/DxeIpl/LegacyTable.c
deleted file mode 100644 (file)
index 1c822f8..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-  LegacyTable.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#include "DxeIpl.h"\r
-#include "HobGeneration.h"\r
-#include "Debug.h"\r
-\r
-#define MPS_PTR           SIGNATURE_32('_','M','P','_')\r
-#define SMBIOS_PTR        SIGNATURE_32('_','S','M','_')\r
-\r
-#define EBDA_BASE_ADDRESS 0x40E\r
-\r
-VOID *\r
-FindAcpiRsdPtr (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                           Address;\r
-  UINTN                           Index;\r
-\r
-  //\r
-  // First Seach 0x0e0000 - 0x0fffff for RSD Ptr\r
-  //\r
-  for (Address = 0xe0000; Address < 0xfffff; Address += 0x10) {\r
-    if (*(UINT64 *)(Address) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {\r
-      return (VOID *)Address;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Search EBDA\r
-  //\r
-\r
-  Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;\r
-  for (Index = 0; Index < 0x400 ; Index += 16) {\r
-    if (*(UINT64 *)(Address + Index) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {\r
-      return (VOID *)Address;\r
-    }\r
-  }\r
-  return NULL;\r
-}\r
-\r
-VOID *\r
-FindSMBIOSPtr (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                           Address;\r
-\r
-  //\r
-  // First Seach 0x0f0000 - 0x0fffff for SMBIOS Ptr\r
-  //\r
-  for (Address = 0xf0000; Address < 0xfffff; Address += 0x10) {\r
-    if (*(UINT32 *)(Address) == SMBIOS_PTR) {\r
-      return (VOID *)Address;\r
-    }\r
-  }\r
-  return NULL;\r
-}\r
-\r
-VOID *\r
-FindMPSPtr (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                           Address;\r
-  UINTN                           Index;\r
-\r
-  //\r
-  // First Seach 0x0e0000 - 0x0fffff for MPS Ptr\r
-  //\r
-  for (Address = 0xe0000; Address < 0xfffff; Address += 0x10) {\r
-    if (*(UINT32 *)(Address) == MPS_PTR) {\r
-      return (VOID *)Address;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Search EBDA\r
-  //\r
-\r
-  Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;\r
-  for (Index = 0; Index < 0x400 ; Index += 16) {\r
-    if (*(UINT32 *)(Address + Index) == MPS_PTR) {\r
-      return (VOID *)Address;\r
-    }\r
-  }\r
-  return NULL;\r
-}\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  EFI_ACPI_DESCRIPTION_HEADER  Header;\r
-  UINT32                       Entry;\r
-} RSDT_TABLE;\r
-\r
-typedef struct {\r
-  EFI_ACPI_DESCRIPTION_HEADER  Header;\r
-  UINT64                       Entry;\r
-} XSDT_TABLE;\r
-\r
-#pragma pack()\r
-\r
-VOID\r
-ScanTableInRSDT (\r
-  RSDT_TABLE                   *Rsdt,\r
-  UINT32                       Signature,\r
-  EFI_ACPI_DESCRIPTION_HEADER  **FoundTable\r
-  )\r
-{\r
-  UINTN                         Index;\r
-  UINT32                        EntryCount;\r
-  UINT32                        *EntryPtr;\r
-  EFI_ACPI_DESCRIPTION_HEADER   *Table;\r
-  \r
-  *FoundTable = NULL;\r
-  \r
-  EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);\r
-  \r
-  EntryPtr = &Rsdt->Entry;\r
-  for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {\r
-    Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));\r
-    if (Table->Signature == Signature) {\r
-      *FoundTable = Table;\r
-      break;\r
-    }\r
-  }\r
-  \r
-  return;\r
-}\r
-\r
-VOID\r
-ScanTableInXSDT (\r
-  XSDT_TABLE                   *Xsdt,\r
-  UINT32                       Signature,\r
-  EFI_ACPI_DESCRIPTION_HEADER  **FoundTable\r
-  )\r
-{\r
-  UINTN                        Index;\r
-  UINT32                       EntryCount;\r
-  UINT64                       EntryPtr;\r
-  UINTN                        BasePtr;\r
-  EFI_ACPI_DESCRIPTION_HEADER  *Table;\r
-  \r
-  *FoundTable = NULL;\r
-  \r
-  EntryCount = (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);\r
-  \r
-  BasePtr = (UINTN)(&(Xsdt->Entry));\r
-  for (Index = 0; Index < EntryCount; Index ++) {\r
-    CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));\r
-    Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));\r
-    if (Table->Signature == Signature) {\r
-      *FoundTable = Table;\r
-      break;\r
-    }\r
-  }\r
-  \r
-  return;\r
-}\r
-\r
-VOID *\r
-FindAcpiPtr (\r
-  IN HOB_TEMPLATE  *Hob,\r
-  UINT32           Signature\r
-  )\r
-{\r
-  EFI_ACPI_DESCRIPTION_HEADER                    *AcpiTable;\r
-  EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER   *Rsdp;\r
-  RSDT_TABLE                                     *Rsdt;\r
-  XSDT_TABLE                                     *Xsdt;\r
\r
-  AcpiTable = NULL;\r
-\r
-  //\r
-  // Check ACPI2.0 table\r
-  //\r
-  if ((int)Hob->Acpi20.Table != -1) {\r
-    Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)Hob->Acpi20.Table;\r
-    Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;\r
-    Xsdt = NULL;\r
-    if ((Rsdp->Revision >= 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) {\r
-      Xsdt = (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress;\r
-    }\r
-    //\r
-    // Check Xsdt\r
-    //\r
-    if (Xsdt != NULL) {\r
-      ScanTableInXSDT (Xsdt, Signature, &AcpiTable);\r
-    }\r
-    //\r
-    // Check Rsdt\r
-    //\r
-    if ((AcpiTable == NULL) && (Rsdt != NULL)) {\r
-      ScanTableInRSDT (Rsdt, Signature, &AcpiTable);\r
-    }\r
-  }\r
-  \r
-  //\r
-  // Check ACPI1.0 table\r
-  //\r
-  if ((AcpiTable == NULL) && ((int)Hob->Acpi.Table != -1)) {\r
-    Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)Hob->Acpi.Table;\r
-    Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;\r
-    //\r
-    // Check Rsdt\r
-    //\r
-    if (Rsdt != NULL) {\r
-      ScanTableInRSDT (Rsdt, Signature, &AcpiTable);\r
-    }\r
-  }\r
-\r
-  return AcpiTable;\r
-}\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  UINT64  BaseAddress;\r
-  UINT16  PciSegmentGroupNumber;\r
-  UINT8   StartBusNumber;\r
-  UINT8   EndBusNumber;\r
-  UINT32  Reserved;\r
-} MCFG_STRUCTURE;\r
-#pragma pack()\r
-\r
-VOID\r
-PrepareMcfgTable (\r
-  IN HOB_TEMPLATE  *Hob\r
-  )\r
-{\r
-  EFI_ACPI_DESCRIPTION_HEADER  *McfgTable;\r
-  MCFG_STRUCTURE               *Mcfg;\r
-  UINTN                        McfgCount;\r
-  UINTN                        Index;\r
-\r
-  McfgTable = FindAcpiPtr (Hob, EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE);\r
-  if (McfgTable == NULL) {\r
-    return ;\r
-  }\r
-\r
-  Mcfg = (MCFG_STRUCTURE *)((UINTN)McfgTable + sizeof(EFI_ACPI_DESCRIPTION_HEADER) + sizeof(UINT64));\r
-  McfgCount = (McfgTable->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER) - sizeof(UINT64)) / sizeof(MCFG_STRUCTURE);\r
-\r
-  //\r
-  // Fill PciExpress info on Hob\r
-  // Note: Only for 1st segment\r
-  //\r
-  for (Index = 0; Index < McfgCount; Index++) {\r
-    if (Mcfg[Index].PciSegmentGroupNumber == 0) {\r
-      Hob->PciExpress.PciExpressBaseAddressInfo.PciExpressBaseAddress = Mcfg[Index].BaseAddress;\r
-      break;\r
-    }\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-PrepareFadtTable (\r
-  IN HOB_TEMPLATE  *Hob\r
-  )\r
-{\r
-  EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE   *Fadt;\r
-  EFI_ACPI_DESCRIPTION                        *AcpiDescription;\r
-\r
-  Fadt = FindAcpiPtr (Hob, EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE);\r
-  if (Fadt == NULL) {\r
-    return ;\r
-  }\r
-\r
-  AcpiDescription = &Hob->AcpiInfo.AcpiDescription;\r
-  //\r
-  // Fill AcpiDescription according to FADT\r
-  // Currently, only for PM_TMR\r
-  //\r
-  AcpiDescription->PM_TMR_LEN = Fadt->PmTmrLen;\r
-  AcpiDescription->TMR_VAL_EXT = (UINT8)((Fadt->Flags & 0x100) != 0);\r
\r
-  //\r
-  // For fields not included in ACPI 1.0 spec, we get the value based on table length\r
-  //\r
-  if (Fadt->Header.Length >= OFFSET_OF (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE, XPmTmrBlk) + sizeof (Fadt->XPmTmrBlk)) {\r
-    CopyMem (\r
-      &AcpiDescription->PM_TMR_BLK,\r
-      &Fadt->XPmTmrBlk,\r
-      sizeof(EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE)\r
-      );\r
-  }\r
-  if (Fadt->Header.Length >= OFFSET_OF (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE, ResetValue) + sizeof (Fadt->ResetValue)) {\r
-    CopyMem (\r
-      &AcpiDescription->RESET_REG,\r
-      &Fadt->ResetReg,\r
-      sizeof(EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE)\r
-      );\r
-    AcpiDescription->RESET_VALUE = Fadt->ResetValue;\r
-  }\r
-\r
-  if (AcpiDescription->PM_TMR_BLK.Address == 0) {\r
-    AcpiDescription->PM_TMR_BLK.Address          = Fadt->PmTmrBlk;\r
-    AcpiDescription->PM_TMR_BLK.AddressSpaceId   = EFI_ACPI_3_0_SYSTEM_IO;\r
-  }\r
-\r
-  //\r
-  // It's possible that the PM_TMR_BLK.RegisterBitWidth is always 32,\r
-  //  we need to set the correct RegisterBitWidth value according to the TMR_VAL_EXT\r
-  //  A zero indicates TMR_VAL is implemented as a 24-bit value. \r
-  //  A one indicates TMR_VAL is implemented as a 32-bit value\r
-  //\r
-  AcpiDescription->PM_TMR_BLK.RegisterBitWidth = (UINT8) ((AcpiDescription->TMR_VAL_EXT == 0) ? 24 : 32);\r
-  \r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-PrepareHobLegacyTable (\r
-  IN HOB_TEMPLATE  *Hob\r
-  )\r
-{\r
-  CHAR8    PrintBuffer[256];\r
-\r
-  Hob->Acpi.Table   = (EFI_PHYSICAL_ADDRESS)(UINTN)FindAcpiRsdPtr ();\r
-  AsciiSPrint (PrintBuffer, 256, "\nAcpiTable=0x%x ", (UINT32)(UINTN)Hob->Acpi.Table);\r
-  PrintString (PrintBuffer);\r
-  Hob->Acpi20.Table = (EFI_PHYSICAL_ADDRESS)(UINTN)FindAcpiRsdPtr ();\r
-  Hob->Smbios.Table = (EFI_PHYSICAL_ADDRESS)(UINTN)FindSMBIOSPtr ();\r
-  AsciiSPrint (PrintBuffer, 256, "SMBIOS Table=0x%x ", (UINT32)(UINTN)Hob->Smbios.Table);\r
-  PrintString (PrintBuffer);\r
-  Hob->Mps.Table    = (EFI_PHYSICAL_ADDRESS)(UINTN)FindMPSPtr ();\r
-  AsciiSPrint (PrintBuffer, 256, "MPS Table=0x%x\n", (UINT32)(UINTN)Hob->Mps.Table);\r
-  PrintString (PrintBuffer);\r
-\r
-  PrepareMcfgTable (Hob);\r
-\r
-  PrepareFadtTable (Hob);\r
-\r
-  return ;\r
-}\r
-\r
diff --git a/DuetPkg/DxeIpl/LegacyTable.h b/DuetPkg/DxeIpl/LegacyTable.h
deleted file mode 100644 (file)
index 755ce25..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  LegacyTable.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#ifndef _DXELDR_LEGACY_TABLE_H_\r
-#define _DXELDR_LEGACY_TABLE_H_\r
-\r
-#include "HobGeneration.h"\r
-\r
-VOID\r
-PrepareHobLegacyTable (\r
-  IN HOB_TEMPLATE  *Hob\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/DxeIpl/PpisNeededByDxeCore.c b/DuetPkg/DxeIpl/PpisNeededByDxeCore.c
deleted file mode 100644 (file)
index e08a148..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  PpisNeededByDxeCore.c\r
-\r
-Abstract:\r
-  \r
-Revision History:\r
-\r
-**/\r
-\r
-#include "PpisNeededByDxeCore.h"\r
-#include "HobGeneration.h"\r
-#include "SerialStatusCode.h"\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PreparePpisNeededByDxeCore (\r
-  IN HOB_TEMPLATE  *Hob\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine adds the PPI/Protocol Hobs that are consumed by the DXE Core.\r
-  Normally these come from PEI, but since our PEI was 32-bit we need an\r
-  alternate source. That is this driver.\r
-\r
-  This driver does not consume PEI or DXE services and thus updates the \r
-  Phit (HOB list) directly\r
-\r
-Arguments:\r
-\r
-  HobStart - Pointer to the beginning of the HOB List from PEI\r
-\r
-Returns:\r
-\r
-  This function should after it has add it's HOBs\r
-\r
---*/\r
-{\r
-  EFI_REPORT_STATUS_CODE                    ReportStatusCode;\r
-\r
-  InstallSerialStatusCode (&ReportStatusCode);\r
-  Hob->SerialStatusCode.Interface = (EFI_PHYSICAL_ADDRESS) (UINTN) ReportStatusCode;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/DuetPkg/DxeIpl/PpisNeededByDxeCore.h b/DuetPkg/DxeIpl/PpisNeededByDxeCore.h
deleted file mode 100644 (file)
index c7bd013..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PpisNeededByDxeCore.h\r
-\r
-Abstract:\r
-  \r
-Revision History:\r
-\r
-**/\r
-\r
-#ifndef _DXELDR_PPIS_NEEDED_BY_DXE_CORE_H_\r
-#define _DXELDR_PPIS_NEEDED_BY_DXE_CORE_H_\r
-\r
-#include "DxeIpl.h"\r
-#include "HobGeneration.h"\r
-\r
-//EFI_STATUS\r
-//InstallEfiPeiTransferControl (\r
-//  IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This\r
-//  );\r
-\r
-//EFI_STATUS\r
-//InstallEfiPeiFlushInstructionCache (\r
-//  IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL  **This\r
-//  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PreparePpisNeededByDxeCore (\r
-  IN  HOB_TEMPLATE  *HobStart\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine adds the PPI/Protocol Hobs that are consumed by the DXE Core.\r
-  Normally these come from PEI, but since our PEI was 32-bit we need an\r
-  alternate source. That is this driver.\r
-\r
-  This driver does not consume PEI or DXE services and thus updates the \r
-  Phit (HOB list) directly\r
-\r
-Arguments:\r
-\r
-  HobStart - Pointer to the beginning of the HOB List from PEI\r
-\r
-Returns:\r
-\r
-  This function should after it has add it's HOBs\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/DuetPkg/DxeIpl/SerialStatusCode.c b/DuetPkg/DxeIpl/SerialStatusCode.c
deleted file mode 100644 (file)
index 1595932..0000000
+++ /dev/null
@@ -1,760 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  SerialStatusCode.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#include <Library/SerialPortLib.h>\r
-#include "SerialStatusCode.h"\r
-\r
-//\r
-// All of the lookup tables are only needed in debug.\r
-//\r
-\r
-typedef struct {\r
-  UINT32                  Value;\r
-  CHAR8                   *Token;\r
-} STATUS_CODE_LOOKUP_TABLE;\r
-\r
-STATUS_CODE_LOOKUP_TABLE mSeverityToken[] = {\r
-  { EFI_ERROR_MINOR,                "ERROR_MINOR" },\r
-  { EFI_ERROR_MAJOR,                "ERROR_MAJOR" },\r
-  { EFI_ERROR_UNRECOVERED,          "ERROR_UNRECOVERED" },\r
-  { EFI_ERROR_UNCONTAINED,          "ERROR_UNCONTAINED" },\r
-  { 0xFFFFFFFF,                     "ERROR_UNRECOGNIZED"  }\r
-  };\r
-\r
-STATUS_CODE_LOOKUP_TABLE mClassSubClassToken[] = {\r
-  { EFI_COMPUTING_UNIT_UNSPECIFIED,             "COMPUTING_UNIT_UNSPECIFIED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR,          "COMPUTING_UNIT_HOST_PROCESSOR" },\r
-  { EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR,          "COMPUTING_UNIT_FIRMWARE_PROCESSOR" },\r
-  { EFI_COMPUTING_UNIT_IO_PROCESSOR,            "COMPUTING_UNIT_IO_PROCESSOR" },\r
-  { EFI_COMPUTING_UNIT_CACHE,                   "COMPUTING_UNIT_CACHE" },\r
-  { EFI_COMPUTING_UNIT_MEMORY,            "COMPUTING_UNIT_MEMORY" },\r
-  { EFI_COMPUTING_UNIT_CHIPSET,           "COMPUTING_UNIT_CHIPSET" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED,           "PERIPHERAL_UNSPECIFIED" },\r
-  { EFI_PERIPHERAL_KEYBOARD,              "PERIPHERAL_KEYBOARD" },\r
-  { EFI_PERIPHERAL_MOUSE,                 "PERIPHERAL_MOUSE" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE,          "PERIPHERAL_LOCAL_CONSOLE" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE,          "PERIPHERAL_REMOTE_CONSOLE" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT,          "PERIPHERAL_SERIAL_PORT" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT,          "PERIPHERAL_PARALLEL_PORT" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA,          "PERIPHERAL_FIXED_MEDIA" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA,          "PERIPHERAL_REMOVABLE_MEDIA" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT,          "PERIPHERAL_AUDIO_INPUT" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT,          "PERIPHERAL_AUDIO_OUTPUT" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE,          "PERIPHERAL_LCD_DEVICE" },\r
-  { EFI_IO_BUS_UNSPECIFIED,          "IO_BUS_UNSPECIFIED" },\r
-  { EFI_IO_BUS_PCI,          "IO_BUS_PCI" },\r
-  { EFI_IO_BUS_USB,          "IO_BUS_USB" },\r
-  { EFI_IO_BUS_IBA,          "IO_BUS_IBA" },\r
-  { EFI_IO_BUS_AGP,          "IO_BUS_AGP" },\r
-  { EFI_IO_BUS_PC_CARD,          "IO_BUS_PC_CARD" },\r
-  { EFI_IO_BUS_LPC,          "IO_BUS_LPC" },\r
-  { EFI_IO_BUS_SCSI,          "IO_BUS_SCSI" },\r
-  { EFI_IO_BUS_ATA_ATAPI,          "IO_BUS_ATA_ATAPI" },\r
-  { EFI_IO_BUS_FC,          "IO_BUS_FC" },\r
-  { EFI_IO_BUS_IP_NETWORK,          "IO_BUS_IP_NETWORK" },\r
-  { EFI_IO_BUS_SMBUS,          "IO_BUS_SMBUS" },\r
-  { EFI_IO_BUS_I2C,          "IO_BUS_I2C" },\r
-  { EFI_SOFTWARE_UNSPECIFIED,          "SOFTWARE_UNSPECIFIED" },\r
-  { EFI_SOFTWARE_SEC,          "SOFTWARE_SEC" },\r
-  { EFI_SOFTWARE_PEI_CORE,          "SOFTWARE_PEI_CORE" },\r
-  { EFI_SOFTWARE_PEI_MODULE,          "SOFTWARE_PEI_MODULE" },\r
-  { EFI_SOFTWARE_DXE_CORE,          "SOFTWARE_DXE_CORE" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE,          "SOFTWARE_EFI_BOOT_SERVICE" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE,          "SOFTWARE_EFI_RUNTIME_SERVICE" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER,          "SOFTWARE_DXE_BS_DRIVER" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER,          "SOFTWARE_DXE_RT_DRIVER" },\r
-  { EFI_SOFTWARE_SMM_DRIVER,         "SOFTWARE_SMM_DRIVER" },\r
-  { EFI_SOFTWARE_RT,          "SOFTWARE_EFI_RT" },\r
-  { EFI_SOFTWARE_AL,          "SOFTWARE_EFI_AL" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION,          "SOFTWARE_EFI_APPLICATION" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER,          "SOFTWARE_EFI_OS_LOADER" },\r
-  { 0xFFFFFFFF,          "ERROR_UNRECOGNIZED"  }\r
-  };\r
-\r
-STATUS_CODE_LOOKUP_TABLE mOperationToken[] = {\r
-  { EFI_COMPUTING_UNIT_UNSPECIFIED          | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_UNSPECIFIED          | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_UNSPECIFIED          | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_UNSPECIFIED          | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_UNSPECIFIED          | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_INVALID_TYPE,          "INVALID_TYPE" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_INVALID_SPEED,          "INVALID_SPEED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_MISMATCH,          "MISMATCH" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_TIMER_EXPIRED,          "TIMER_EXPIRED" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_SELF_TEST,          "SELF_TEST" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_INTERNAL,          "INTERNAL" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_THERMAL,          "THERMAL" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_LOW_VOLTAGE,          "LOW_VOLTAGE" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_HIGH_VOLTAGE,          "HIGH_VOLTAGE" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_CACHE,          "CACHE" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_MICROCODE_UPDATE,          "MICROCODE_UPDATE" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_NO_MICROCODE_UPDATE,          "NO_MICROCODE_UPDATE" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_CORRECTABLE,         "1XECC" },\r
-  { EFI_COMPUTING_UNIT_HOST_PROCESSOR       | EFI_CU_HP_EC_UNCORRECTABLE,          "2XECC" },\r
-  { EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR   | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR   | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR   | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR   | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR   | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_COMPUTING_UNIT_IO_PROCESSOR         | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_IO_PROCESSOR         | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_IO_PROCESSOR         | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_IO_PROCESSOR         | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_IO_PROCESSOR         | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_CACHE_EC_INVALID_TYPE,          "INVALID_TYPE" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_CACHE_EC_INVALID_SPEED,          "INVALID_SPEED" },\r
-  { EFI_COMPUTING_UNIT_CACHE                | EFI_CU_CACHE_EC_INVALID_SIZE,          "INVALID_SIZE" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_INVALID_TYPE,          "INVALID_TYPE" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_INVALID_SPEED,          "INVALID_SPEED" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_CORRECTABLE,          "1XECC" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_UNCORRECTABLE,        "2XECC" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_SPD_FAIL,          "SPD_FAIL" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_INVALID_SIZE,          "INVALID_SIZE" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_MISMATCH,          "MISMATCH" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_S3_RESUME_FAIL,          "S3_RESUME_FAIL" },\r
-  { EFI_COMPUTING_UNIT_MEMORY               | EFI_CU_MEMORY_EC_UPDATE_FAIL,          "UPDATE_FAIL" },\r
-  { EFI_COMPUTING_UNIT_CHIPSET              | EFI_CU_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_COMPUTING_UNIT_CHIPSET              | EFI_CU_EC_DISABLED,          "DISABLED" },\r
-  { EFI_COMPUTING_UNIT_CHIPSET              | EFI_CU_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_COMPUTING_UNIT_CHIPSET              | EFI_CU_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_COMPUTING_UNIT_CHIPSET              | EFI_CU_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_UNSPECIFIED              | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_KEYBOARD_EC_LOCKED,          "LOCKED" },\r
-  { EFI_PERIPHERAL_KEYBOARD                 | EFI_P_KEYBOARD_EC_STUCK_KEY,          "STUCK_KEY" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_MOUSE                    | EFI_P_MOUSE_EC_LOCKED,          "LOCKED" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_LOCAL_CONSOLE            | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_REMOTE_CONSOLE           | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_SERIAL_PORT              | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_PARALLEL_PORT            | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_FIXED_MEDIA              | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_REMOVABLE_MEDIA          | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_INPUT              | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_AUDIO_OUTPUT             | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_DISABLED,          "DISABLED" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_INPUT_ERROR,          "INPUT_ERROR" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_OUTPUT_ERROR,          "OUTPUT_ERROR" },\r
-  { EFI_PERIPHERAL_LCD_DEVICE               | EFI_P_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_UNSPECIFIED                  | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_PCI_EC_PERR,          "PERR" },\r
-  { EFI_IO_BUS_PCI                          | EFI_IOB_PCI_EC_SERR,          "SERR" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_USB                          | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_IBA                          | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_AGP                          | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_PC_CARD                      | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_LPC                          | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_SCSI                         | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_ATA_ATAPI                    | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_FC                           | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_IP_NETWORK                   | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_SMBUS                        | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_DISABLED,          "DISABLED" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_NOT_SUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_NOT_DETECTED,          "NOT_DETECTED" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_NOT_CONFIGURED,          "NOT_CONFIGURED" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_INTERFACE_ERROR,          "INTERFACE_ERROR" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_CONTROLLER_ERROR,          "CONTROLLER_ERROR" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_READ_ERROR,          "READ_ERROR" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_WRITE_ERROR,          "WRITE_ERROR" },\r
-  { EFI_IO_BUS_I2C                          | EFI_IOB_EC_RESOURCE_CONFLICT,          "RESOURCE_CONFLICT" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_UNSPECIFIED                | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_SEC                    | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_PEI_CORE               | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_PEI_MODULE             | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_DXE_CORE               | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_BOOT_SERVICE           | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_RUNTIME_SERVICE        | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_DXE_BS_DRIVER          | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_DXE_RT_DRIVER          | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_SMM_DRIVER                    | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_RT                     | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_AL                     | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_APPLICATION        | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_NON_SPECIFIC,          "NON_SPECIFIC" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_LOAD_ERROR,          "LOAD_ERROR" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_INVALID_PARAMETER,          "INVALID_PARAMETER" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_UNSUPPORTED,          "NOT_SUPPORTED" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_INVALID_BUFFER,          "INVALID_BUFFER" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_OUT_OF_RESOURCES,          "OUT_OF_RESOURCES" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_ABORTED,          "ABORTED" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE,          "ILLEGAL_SOFTWARE_STATE" },\r
-  { EFI_SOFTWARE_EFI_OS_LOADER              | EFI_SW_EC_ILLEGAL_HARDWARE_STATE,          "ILLEGAL_HARDWARE_STATE" },\r
-  { 0xFFFFFFFF,                              "ERROR_UNRECOGNIZED"                }\r
-  };\r
-\r
-\r
-EFI_STATUS\r
-MatchString (\r
-  IN  STATUS_CODE_LOOKUP_TABLE  *Table,\r
-  IN  UINT32                    Value,\r
-  OUT CHAR8                     **Token\r
-  );\r
-\r
-//\r
-// Function implemenations\r
-//\r
-\r
-//\r
-// Match is only needed for debug.\r
-//\r
-\r
-EFI_STATUS\r
-MatchString (\r
-  IN  STATUS_CODE_LOOKUP_TABLE  *Table,\r
-  IN  UINT32                    Value,\r
-  OUT CHAR8                     **Token\r
-  )\r
-/*++\r
-\r
-Routine Description: \r
-\r
-  Search the input table for a matching value and return the token associated\r
-  with that value.  Well formed tables will have the last value == 0 and will \r
-  return a default token.\r
-\r
-Arguments:  \r
-\r
-  Table     Pointer to first entry in an array of table entries.\r
-  Value     Value to look up.\r
-  Token     String to return.\r
-\r
-Returns:  \r
-\r
-  EFI_SUCCESS   The function always returns success.\r
-\r
---*/\r
-{\r
-  UINTN         Current;\r
-  \r
-  Current = 0;\r
-  *Token = 0;\r
-\r
-  while (!*Token) {\r
-    //\r
-    // Found token if values match or current entry is the last entry.\r
-    //\r
-    if ((Table[Current].Value == (-1)) ||\r
-        (Table[Current].Value == Value)) {\r
-      *Token = Table[Current].Token;\r
-    }\r
-    Current++;\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI \r
-SerialReportStatusCode (\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
-  Provide a serial port print\r
-\r
-Arguments:\r
-\r
-  PeiServices - General purpose services available to every PEIM.\r
-    \r
-Returns:\r
-\r
-  Status -  EFI_SUCCESS if the interface could be successfully\r
-            installed\r
-\r
---*/\r
-{\r
-  CHAR8                   Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-  UINT32                  LineNumber;\r
-  CHAR8                   *Filename;\r
-  CHAR8                   *Description;\r
-  CHAR8                   *Format;\r
-  BASE_LIST               Marker;\r
-  UINT32                  ErrorLevel;\r
-  UINTN                   CharCount = 0;\r
-\r
-  Buffer[0] = '\0';\r
-\r
-  if (Data != NULL && \r
-      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
-    //\r
-    // Processes PEI_ASSERT ()\r
-    //\r
-    CharCount = AsciiSPrint (\r
-      Buffer,\r
-      sizeof (Buffer),\r
-      "\nPEI_ASSERT!: %a (%d): %a\n",\r
-      Filename,\r
-      LineNumber,\r
-      Description\r
-      );\r
-\r
-  } else if (Data != NULL &&\r
-             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-    //\r
-    // Process PEI_DEBUG () macro to Serial\r
-    //\r
-    CharCount = AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
-\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { \r
-    //\r
-    // Process Errors\r
-    //\r
-    CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "ERROR: C%x:V%x I%x", CodeType, Value, Instance);\r
-    //\r
-    // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r
-    //\r
-    if (CallerId) {\r
-      CharCount += AsciiSPrint (&Buffer[CharCount - 1], (sizeof (Buffer) - (sizeof(Buffer[0]) * CharCount)), " %g", CallerId);\r
-    }\r
-    if (Data) {\r
-      CharCount += AsciiSPrint (&Buffer[CharCount - 1], (sizeof (Buffer) - (sizeof(Buffer[0]) * CharCount)), " %x", Data);\r
-    }\r
-    CharCount += AsciiSPrint (&Buffer[CharCount - 1], (sizeof (Buffer) - (sizeof(Buffer[0]) * CharCount)), "\n");\r
-\r
-  }\r
-\r
-  if (Buffer[0] != '\0') {\r
-    //\r
-    // Callout to platform Lib function to do print.\r
-    //\r
-    SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
-  }\r
-\r
-  //\r
-  // Debug code to display human readable code information.\r
-  //\r
-    {\r
-      CHAR8       *SeverityToken;\r
-      CHAR8       *SubClassToken;\r
-      CHAR8       *OperationToken;\r
-\r
-      if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { \r
-        //\r
-        // Get the severity token\r
-        //\r
-        MatchString (\r
-          mSeverityToken,\r
-          (CodeType & EFI_STATUS_CODE_SEVERITY_MASK),\r
-          &SeverityToken\r
-          );\r
-    \r
-        //\r
-        // Get the Class/SubClass token\r
-        //\r
-        MatchString (\r
-          mClassSubClassToken,\r
-          (Value & (EFI_STATUS_CODE_CLASS_MASK | EFI_STATUS_CODE_SUBCLASS_MASK)),\r
-          &SubClassToken\r
-          );\r
-    \r
-        //\r
-        // Get the operation token\r
-        //\r
-        MatchString (\r
-          mOperationToken,\r
-          (Value & (EFI_STATUS_CODE_CLASS_MASK | EFI_STATUS_CODE_SUBCLASS_MASK | EFI_STATUS_CODE_OPERATION_MASK)),\r
-          &OperationToken\r
-          );\r
-    \r
-        //\r
-        // Concatenate the instance\r
-        //\r
-        CharCount = AsciiSPrint (\r
-          Buffer,\r
-          sizeof (Buffer),\r
-          "%a:%a:%a:%d\n",\r
-          SeverityToken,\r
-          SubClassToken,\r
-          OperationToken,\r
-          Instance\r
-          );\r
-\r
-        SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
-      }\r
-    }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-VOID\r
-InstallSerialStatusCode (\r
-  IN EFI_REPORT_STATUS_CODE    *ReportStatusCode\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize Serial Port and Status Code Handler\r
-\r
-Arguments: \r
-\r
-  ReportStatusCode - A pointer to the handler\r
-\r
-Returns: \r
-\r
-  None\r
-\r
---*/\r
-{\r
-  SerialPortInitialize();\r
-  *ReportStatusCode = SerialReportStatusCode;\r
-}\r
diff --git a/DuetPkg/DxeIpl/SerialStatusCode.h b/DuetPkg/DxeIpl/SerialStatusCode.h
deleted file mode 100644 (file)
index 7146927..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  SerialStatusCode.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#ifndef _DXELDR_SERIAL_STATUS_CODE_H_\r
-#define _DXELDR_SERIAL_STATUS_CODE_H_\r
-\r
-//\r
-// Statements that include other files\r
-//\r
-#include "DxeIpl.h"\r
-\r
-//\r
-// GUID consumed\r
-//\r
-\r
-\r
-VOID\r
-InstallSerialStatusCode (\r
-  IN EFI_REPORT_STATUS_CODE    *ReportStatusCode\r
-  );\r
-\r
-#endif \r
diff --git a/DuetPkg/DxeIpl/X64/EnterDxeCore.c b/DuetPkg/DxeIpl/X64/EnterDxeCore.c
deleted file mode 100644 (file)
index 10376b5..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/** @file\r
-  x64 specific code to enter DxeCore\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#include "DxeIpl.h"\r
-\r
-VOID\r
-EnterDxeMain (\r
-  IN VOID *StackTop,\r
-  IN VOID *DxeCoreEntryPoint,\r
-  IN VOID *Hob,\r
-  IN VOID *PageTable\r
-  )\r
-{\r
-  AsmWriteCr3 ((UINTN) PageTable);\r
-  SwitchStack (\r
-    (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
-    Hob,\r
-    NULL,\r
-    StackTop\r
-    );\r
-}\r
diff --git a/DuetPkg/DxeIpl/X64/Paging.c b/DuetPkg/DxeIpl/X64/Paging.c
deleted file mode 100644 (file)
index 3b4de18..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-  Paging.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#include "HobGeneration.h"\r
-#include "VirtualMemory.h"\r
-\r
-//\r
-// Create 2M-page table\r
-// PML4 (47:39)\r
-// PDPTE (38:30)\r
-// PDE (29:21)\r
-//\r
-\r
-#define EFI_2M_PAGE_BITS_NUM    21\r
-#define EFI_MAX_ENTRY_BITS_NUM  9\r
-\r
-#define EFI_PAGE_SIZE_4K        0x1000\r
-#define EFI_PAGE_SIZE_2M        (1 << EFI_2M_PAGE_BITS_NUM)\r
-\r
-#ifndef MIN\r
-  #define MIN(a, b)               ((a) < (b) ? (a) : (b))\r
-#endif\r
-#define ENTRY_NUM(x)            ((UINTN)1 << (x))\r
-\r
-UINT8 gPML4BitsNum;\r
-UINT8 gPDPTEBitsNum;\r
-UINT8 gPDEBitsNum;\r
-\r
-UINTN gPageNum2M;\r
-UINTN gPageNum4K;\r
-\r
-VOID\r
-EnableNullPointerProtection (\r
-  UINT8                       *PageTable\r
-  )\r
-{\r
-  X64_PAGE_TABLE_ENTRY_4K *PageTableEntry4KB;\r
-\r
-  PageTableEntry4KB = (X64_PAGE_TABLE_ENTRY_4K *) (PageTable + gPageNum2M * EFI_PAGE_SIZE_4K);\r
-  //\r
-  // Fill in the Page Table entries\r
-  // Mark 0~4K as not present\r
-  //\r
-  PageTableEntry4KB->Bits.Present = 0;\r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-X64Create4KPageTables (\r
-  UINT8                       *PageTable\r
-  )\r
-/*++\r
-Routine Description:\r
-  Create 4K-Page-Table for the low 2M memory.\r
-  This will change the previously created 2M-Page-Table-Entry.\r
---*/\r
-{\r
-  UINT64                                        PageAddress;\r
-  UINTN                                         PTEIndex;\r
-  X64_PAGE_DIRECTORY_ENTRY_4K                   *PageDirectoryEntry4KB;\r
-  X64_PAGE_TABLE_ENTRY_4K                       *PageTableEntry4KB;\r
-\r
-  //\r
-  //  Page Table structure 4 level 4K.\r
-  //\r
-  //                   PageMapLevel4Entry        : bits 47-39\r
-  //                   PageDirectoryPointerEntry : bits 38-30\r
-  //  Page Table 4K  : PageDirectoryEntry4K      : bits 29-21\r
-  //                   PageTableEntry            : bits 20-12\r
-  //\r
-\r
-  PageTableEntry4KB = (X64_PAGE_TABLE_ENTRY_4K *)(PageTable + gPageNum2M * EFI_PAGE_SIZE_4K);\r
-\r
-  PageDirectoryEntry4KB = (X64_PAGE_DIRECTORY_ENTRY_4K *) (PageTable + 2 * EFI_PAGE_SIZE_4K);\r
-  PageDirectoryEntry4KB->Uint64 = (UINT64)(UINTN)PageTableEntry4KB;\r
-  PageDirectoryEntry4KB->Bits.ReadWrite = 1;\r
-  PageDirectoryEntry4KB->Bits.Present = 1;\r
-  PageDirectoryEntry4KB->Bits.MustBeZero = 0;\r
-\r
-  for (PTEIndex = 0, PageAddress = 0; \r
-       PTEIndex < ENTRY_NUM (EFI_MAX_ENTRY_BITS_NUM); \r
-       PTEIndex++, PageTableEntry4KB++, PageAddress += EFI_PAGE_SIZE_4K\r
-      ) {\r
-    //\r
-    // Fill in the Page Table entries\r
-    //\r
-    PageTableEntry4KB->Uint64 = (UINT64)PageAddress;\r
-    PageTableEntry4KB->Bits.ReadWrite = 1;\r
-    PageTableEntry4KB->Bits.Present = 1;\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-X64Create2MPageTables (\r
-  UINT8 *PageTable\r
-  )\r
-{\r
-  UINT64                                        PageAddress;\r
-  UINT8                                         *TempPageTable;\r
-  UINTN                                         PML4Index;\r
-  UINTN                                         PDPTEIndex;\r
-  UINTN                                         PDEIndex;\r
-  X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K     *PageMapLevel4Entry;\r
-  X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K     *PageDirectoryPointerEntry;\r
-  X64_PAGE_TABLE_ENTRY_2M                       *PageDirectoryEntry2MB;\r
-\r
-  TempPageTable = PageTable;\r
-  PageAddress   = 0;\r
-\r
-  //\r
-  //  Page Table structure 3 level 2MB.\r
-  //\r
-  //                   PageMapLevel4Entry        : bits 47-39\r
-  //                   PageDirectoryPointerEntry : bits 38-30\r
-  //  Page Table 2MB : PageDirectoryEntry2M      : bits 29-21\r
-  //\r
-\r
-  PageMapLevel4Entry = (X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *)TempPageTable;\r
-\r
-  for (PML4Index = 0; PML4Index < ENTRY_NUM (gPML4BitsNum); PML4Index++, PageMapLevel4Entry++) {\r
-    //\r
-    // Each PML4 entry points to a page of Page Directory Pointer entires.\r
-    //  \r
-    TempPageTable += EFI_PAGE_SIZE_4K;\r
-    PageDirectoryPointerEntry = (X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K *)TempPageTable;\r
-\r
-    //\r
-    // Make a PML4 Entry\r
-    //\r
-    PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)(TempPageTable);\r
-    PageMapLevel4Entry->Bits.ReadWrite = 1;\r
-    PageMapLevel4Entry->Bits.Present = 1;\r
-\r
-    for (PDPTEIndex = 0; PDPTEIndex < ENTRY_NUM (gPDPTEBitsNum); PDPTEIndex++, PageDirectoryPointerEntry++) {\r
-      //\r
-      // Each Directory Pointer entries points to a page of Page Directory entires.\r
-      //       \r
-      TempPageTable += EFI_PAGE_SIZE_4K;\r
-      PageDirectoryEntry2MB = (X64_PAGE_TABLE_ENTRY_2M *)TempPageTable;\r
-\r
-      //\r
-      // Fill in a Page Directory Pointer Entries\r
-      //\r
-      PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)(TempPageTable);\r
-      PageDirectoryPointerEntry->Bits.ReadWrite = 1;\r
-      PageDirectoryPointerEntry->Bits.Present = 1;\r
-\r
-      for (PDEIndex = 0; PDEIndex < ENTRY_NUM (gPDEBitsNum); PDEIndex++, PageDirectoryEntry2MB++) {\r
-        //\r
-        // Fill in the Page Directory entries\r
-        //\r
-        PageDirectoryEntry2MB->Uint64 = (UINT64)PageAddress;\r
-        PageDirectoryEntry2MB->Bits.ReadWrite = 1;\r
-        PageDirectoryEntry2MB->Bits.Present = 1;\r
-        PageDirectoryEntry2MB->Bits.MustBe1 = 1;\r
-\r
-        PageAddress += EFI_PAGE_SIZE_2M;\r
-      }\r
-    }\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-VOID *\r
-PreparePageTable (\r
-  VOID  *PageNumberTop,\r
-  UINT8 SizeOfMemorySpace\r
-  )\r
-/*++\r
-Description:\r
-  Generate pagetable below PageNumberTop, \r
-  and return the bottom address of pagetable for putting other things later.\r
---*/\r
-{\r
-  VOID  *PageNumberBase;\r
-\r
-  SizeOfMemorySpace -= EFI_2M_PAGE_BITS_NUM;\r
-  gPDEBitsNum        = (UINT8) MIN (SizeOfMemorySpace, EFI_MAX_ENTRY_BITS_NUM);\r
-  SizeOfMemorySpace  = (UINT8) (SizeOfMemorySpace - gPDEBitsNum);\r
-  gPDPTEBitsNum      = (UINT8) MIN (SizeOfMemorySpace, EFI_MAX_ENTRY_BITS_NUM);\r
-  SizeOfMemorySpace  = (UINT8) (SizeOfMemorySpace - gPDPTEBitsNum);\r
-  gPML4BitsNum       = SizeOfMemorySpace;\r
-  if (gPML4BitsNum > EFI_MAX_ENTRY_BITS_NUM) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Suppose we have:\r
-  // 2MPage:\r
-  //   Entry:       PML4   ->     PDPTE     ->     PDE    -> Page\r
-  //   EntryNum:     a              b               c\r
-  // then\r
-  //   Occupy4KPage: 1              a              a*b\r
-  // \r
-  // 2M 4KPage:\r
-  //   Entry:       PTE    ->     Page\r
-  //   EntryNum:    512\r
-  // then\r
-  //   Occupy4KPage: 1\r
-  //   \r
-\r
-  gPageNum2M = 1 + ENTRY_NUM (gPML4BitsNum) + ENTRY_NUM (gPML4BitsNum + gPDPTEBitsNum);\r
-  gPageNum4K = 1;\r
-\r
-\r
-  PageNumberBase = (VOID *)((UINTN)PageNumberTop - (gPageNum2M + gPageNum4K) * EFI_PAGE_SIZE_4K);\r
-  ZeroMem (PageNumberBase, (gPageNum2M + gPageNum4K) * EFI_PAGE_SIZE_4K);\r
-\r
-  X64Create2MPageTables (PageNumberBase);\r
-  X64Create4KPageTables (PageNumberBase);\r
-  //\r
-  // Not enable NULL Pointer Protection if using INTx call\r
-  //\r
-//  EnableNullPointerProtection (PageNumberBase);\r
-\r
-  return PageNumberBase;\r
-}\r
diff --git a/DuetPkg/DxeIpl/X64/VirtualMemory.h b/DuetPkg/DxeIpl/X64/VirtualMemory.h
deleted file mode 100644 (file)
index 204f04e..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  VirtualMemory.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-  \r
-#ifndef _VIRTUAL_MEMORY_H_\r
-#define _VIRTUAL_MEMORY_H_\r
-\r
-#pragma pack(1)\r
-\r
-//\r
-// Page Map Level 4 Offset (PML4) and\r
-// Page Directory Pointer Table (PDPE) entries 4K & 2M\r
-//\r
-\r
-typedef union {\r
-  struct {\r
-    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
-    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
-    UINT64  Reserved:1;               // Reserved\r
-    UINT64  MustBeZero:2;             // Must Be Zero\r
-    UINT64  Available:3;              // Available for use by system software\r
-    UINT64  PageTableBaseAddress:40;  // Page Table Base Address\r
-    UINT64  AvabilableHigh:11;        // Available for use by system software\r
-    UINT64  Nx:1;                     // No Execute bit\r
-  } Bits;\r
-  UINT64    Uint64;\r
-} X64_PAGE_MAP_AND_DIRECTORY_POINTER_2MB_4K;\r
-\r
-//\r
-// Page Directory Entry 4K\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
-    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
-    UINT64  MustBeZero:3;             // Must Be Zero\r
-    UINT64  Available:3;              // Available for use by system software\r
-    UINT64  PageTableBaseAddress:40;  // Page Table Base Address\r
-    UINT64  AvabilableHigh:11;        // Available for use by system software\r
-    UINT64  Nx:1;                     // No Execute bit\r
-  } Bits;\r
-  UINT64    Uint64;\r
-} X64_PAGE_DIRECTORY_ENTRY_4K;\r
-\r
-//\r
-// Page Table Entry 4K\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
-    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
-    UINT64  Dirty:1;                  // 0 = Not Dirty, 1 = written by processor on access to page\r
-    UINT64  PAT:1;                    // 0 = Ignore Page Attribute Table \r
-    UINT64  Global:1;                 // 0 = Not global page, 1 = global page TLB not cleared on CR3 write\r
-    UINT64  Available:3;              // Available for use by system software\r
-    UINT64  PageTableBaseAddress:40;  // Page Table Base Address\r
-    UINT64  AvabilableHigh:11;        // Available for use by system software\r
-    UINT64  Nx:1;                     // 0 = Execute Code, 1 = No Code Execution\r
-  } Bits;\r
-  UINT64    Uint64;\r
-} X64_PAGE_TABLE_ENTRY_4K;\r
-\r
-//\r
-// Page Table Entry 2M\r
-//\r
-typedef union {\r
-  struct {\r
-    UINT64  Present:1;                // 0 = Not present in memory, 1 = Present in memory\r
-    UINT64  ReadWrite:1;              // 0 = Read-Only, 1= Read/Write\r
-    UINT64  UserSupervisor:1;         // 0 = Supervisor, 1=User\r
-    UINT64  WriteThrough:1;           // 0 = Write-Back caching, 1=Write-Through caching\r
-    UINT64  CacheDisabled:1;          // 0 = Cached, 1=Non-Cached\r
-    UINT64  Accessed:1;               // 0 = Not accessed, 1 = Accessed (set by CPU)\r
-    UINT64  Dirty:1;                  // 0 = Not Dirty, 1 = written by processor on access to page\r
-    UINT64  MustBe1:1;                // Must be 1 \r
-    UINT64  Global:1;                 // 0 = Not global page, 1 = global page TLB not cleared on CR3 write\r
-    UINT64  Available:3;              // Available for use by system software\r
-    UINT64  PAT:1;                    //\r
-    UINT64  MustBeZero:8;             // Must be zero;\r
-    UINT64  PageTableBaseAddress:31;  // Page Table Base Address\r
-    UINT64  AvabilableHigh:11;        // Available for use by system software\r
-    UINT64  Nx:1;                     // 0 = Execute Code, 1 = No Code Execution\r
-  } Bits;\r
-  UINT64    Uint64;\r
-} X64_PAGE_TABLE_ENTRY_2M;\r
-\r
-#pragma pack()\r
-\r
-#endif \r
diff --git a/DuetPkg/EfiLdr/Debug.c b/DuetPkg/EfiLdr/Debug.c
deleted file mode 100644 (file)
index 0727292..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  Debug.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-#include "EfiLdr.h"\r
-#include "Debug.h"\r
-\r
-UINT8 *mCursor;\r
-UINT8 mHeaderIndex = 10;\r
-\r
-\r
-VOID\r
-PrintHeader (\r
-  CHAR8 Char\r
-  )\r
-{\r
-  *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;\r
-  mHeaderIndex += 2;\r
-}\r
-\r
-VOID\r
-ClearScreen (\r
-  VOID\r
-  )\r
-{\r
-  UINT32 Index;\r
-\r
-  mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r
-  for (Index = 0; Index < 80 * 49; Index++) {\r
-    *mCursor = ' ';\r
-    mCursor += 2;\r
-  }\r
-  mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PrintString (\r
-  IN CONST CHAR8  *FormatString,\r
-  ...\r
-  )\r
-{\r
-  UINTN           Index;\r
-  CHAR8           PrintBuffer[256];\r
-  VA_LIST         Marker;\r
-\r
-  VA_START (Marker, FormatString);\r
-  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);\r
-  VA_END (Marker);\r
-\r
-  for (Index = 0; PrintBuffer[Index] != 0; Index++) {\r
-    if (PrintBuffer[Index] == '\n') {\r
-      mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r
-    } else {\r
-      *mCursor = (UINT8) PrintBuffer[Index];\r
-      mCursor += 2;\r
-    }\r
-  }\r
-\r
-  //\r
-  // All information also output to serial port.\r
-  //\r
-  SerialPortWrite ((UINT8 *) PrintBuffer, Index);\r
-}\r
-\r
diff --git a/DuetPkg/EfiLdr/Debug.h b/DuetPkg/EfiLdr/Debug.h
deleted file mode 100644 (file)
index 4252f31..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  Debug.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _EFILDR_DEBUG_H_\r
-#define _EFILDR_DEBUG_H_\r
-\r
-VOID\r
-PrintHeader (\r
-  CHAR8 Char\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-PrintString (\r
-  IN CONST CHAR8  *FormatString,\r
-  ...\r
-  );\r
-\r
-VOID \r
-ClearScreen (\r
-  VOID\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/EfiLdr/EfiLdr.h b/DuetPkg/EfiLdr/EfiLdr.h
deleted file mode 100644 (file)
index 4f21cf3..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  EfiLdr.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _DUET_EFI_LOADER_H_\r
-#define _DUET_EFI_LOADER_H_\r
-\r
-#include "Uefi.h"\r
-#include "EfiLdrHandoff.h"\r
-\r
-#include <Protocol/LoadedImage.h>\r
-#include <IndustryStandard/PeImage.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/SerialPortLib.h>\r
-\r
-#define INT15_E820_AddressRangeMemory   1\r
-#define INT15_E820_AddressRangeReserved 2\r
-#define INT15_E820_AddressRangeACPI     3\r
-#define INT15_E820_AddressRangeNVS      4\r
-\r
-#define EFI_FIRMWARE_BASE_ADDRESS  0x00200000\r
-\r
-#define EFI_DECOMPRESSED_BUFFER_ADDRESS 0x00600000\r
-\r
-#define EFI_MAX_MEMORY_DESCRIPTORS 64\r
-\r
-#define LOADED_IMAGE_SIGNATURE     SIGNATURE_32('l','d','r','i')\r
-\r
-typedef struct {\r
-  UINTN                       Signature;\r
-  CHAR16                      *Name;          // Displayable name\r
-  UINTN                       Type;\r
-\r
-  BOOLEAN                     Started;        // If entrypoint has been called\r
-  VOID                        *StartImageContext;\r
-\r
-  EFI_IMAGE_ENTRY_POINT       EntryPoint;     // The image's entry point\r
-  EFI_LOADED_IMAGE_PROTOCOL   Info;           // loaded image protocol\r
-\r
-  // \r
-  EFI_PHYSICAL_ADDRESS        ImageBasePage;  // Location in memory\r
-  UINTN                       NoPages;        // Number of pages \r
-  UINT8                       *ImageBase;     // As a char pointer\r
-  UINT8                       *ImageEof;      // End of memory image\r
-\r
-  // relocate info\r
-  UINT8                       *ImageAdjust;   // Bias for reloc calculations\r
-  UINTN                       StackAddress;\r
-  UINT8                       *FixupData;     //  Original fixup data\r
-} EFILDR_LOADED_IMAGE;\r
-\r
-#pragma pack(4)\r
-typedef struct {          \r
-  UINT64       BaseAddress;\r
-  UINT64       Length;\r
-  UINT32       Type;\r
-} BIOS_MEMORY_MAP_ENTRY;\r
-#pragma pack()\r
-\r
-typedef struct {          \r
-  UINT32                MemoryMapSize;\r
-  BIOS_MEMORY_MAP_ENTRY MemoryMapEntry[1];\r
-} BIOS_MEMORY_MAP;\r
-\r
-typedef\r
-VOID\r
-(EFIAPI * EFI_MAIN_ENTRYPOINT) (\r
-    IN EFILDRHANDOFF  *Handoff\r
-    );\r
-\r
-#endif //_DUET_EFI_LOADER_H_\r
diff --git a/DuetPkg/EfiLdr/EfiLdr.inf b/DuetPkg/EfiLdr/EfiLdr.inf
deleted file mode 100644 (file)
index b5a46db..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-## @file\r
-# \r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#    EfiLdr.inf\r
-#\r
-#  Abstract:\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EfiLoader\r
-  FILE_GUID                      = A9620E5C-5FA1-40b7-8B21-50B632F88F38\r
-  MODULE_TYPE                    = UEFI_APPLICATION\r
-  VERSION_STRING                 = 1.0\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  BaseMemoryLib\r
-  PrintLib\r
-  SerialPortLib\r
-\r
-[Sources]\r
-  Debug.h\r
-  PeLoader.h\r
-  Support.h\r
-  EfiLdrHandoff.h\r
-  EfiLdr.h\r
-  EfiLoader.c\r
-  Debug.c\r
-  PeLoader.c\r
-  Support.c\r
-  #TianoDecompress.c\r
-  #TianoDecompress.h\r
-  LzmaDecompress.h\r
-\r
-[Guids]\r
-  gTianoCustomDecompressGuid\r
-\r
-[BuildOptions]\r
-  MSFT:*_*_*_DLINK_FLAGS = /BASE:0x10000\r
diff --git a/DuetPkg/EfiLdr/EfiLdrHandoff.h b/DuetPkg/EfiLdr/EfiLdrHandoff.h
deleted file mode 100644 (file)
index 3e5210f..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  EfiLdrHandoff.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _EFILDR_HANDOFF_H_\r
-#define _EFILDR_HANDOFF_H_\r
-\r
-#define EFILDR_BASE_SEGMENT 0x2000\r
-#define EFILDR_LOAD_ADDRESS        (EFILDR_BASE_SEGMENT << 4)\r
-#define EFILDR_HEADER_ADDRESS      (EFILDR_LOAD_ADDRESS+0x2000)\r
-\r
-#define EFILDR_CB_VA        0x00\r
-\r
-typedef struct _EFILDRHANDOFF {\r
-    UINTN                    MemDescCount;\r
-    EFI_MEMORY_DESCRIPTOR   *MemDesc;\r
-    VOID                    *BfvBase;\r
-    UINTN                   BfvSize;\r
-    VOID                    *DxeIplImageBase;\r
-    UINTN                   DxeIplImageSize;\r
-    VOID                    *DxeCoreImageBase;\r
-    UINTN                   DxeCoreImageSize;\r
-    VOID                    *DxeCoreEntryPoint;\r
-} EFILDRHANDOFF;\r
-\r
-typedef struct {\r
-    UINT32       CheckSum;\r
-    UINT32       Offset;\r
-    UINT32       Length;\r
-    UINT8        FileName[52];\r
-} EFILDR_IMAGE;\r
-\r
-typedef struct {          \r
-    UINT32       Signature;     \r
-    UINT32       HeaderCheckSum;\r
-    UINT32       FileLength;\r
-    UINT32       NumberOfImages;\r
-} EFILDR_HEADER;\r
-\r
-#endif\r
diff --git a/DuetPkg/EfiLdr/EfiLoader.c b/DuetPkg/EfiLdr/EfiLoader.c
deleted file mode 100644 (file)
index ac950b5..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  EfiLoader.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#include "EfiLdr.h"\r
-#include "Support.h"\r
-#include "Debug.h"\r
-#include "PeLoader.h"\r
-#include "LzmaDecompress.h"\r
-\r
-EFILDR_LOADED_IMAGE    DxeCoreImage;\r
-EFILDR_LOADED_IMAGE    DxeIplImage;\r
-\r
-VOID\r
-SystemHang (\r
-  CHAR8        *Message\r
-  )\r
-{\r
-  PrintString (\r
-    "%s## FATAL ERROR ##: Fail to load DUET images! System hang!\n",\r
-    Message\r
-    );\r
-  CpuDeadLoop();\r
-}\r
-\r
-VOID\r
-EfiLoader (\r
-  UINT32    BiosMemoryMapBaseAddress\r
-  )\r
-{\r
-  BIOS_MEMORY_MAP       *BiosMemoryMap;    \r
-  EFILDR_IMAGE          *EFILDRImage;\r
-  EFI_MEMORY_DESCRIPTOR EfiMemoryDescriptor[EFI_MAX_MEMORY_DESCRIPTORS];\r
-  EFI_STATUS            Status;\r
-  UINTN                 NumberOfMemoryMapEntries;\r
-  UINT32                DestinationSize;\r
-  UINT32                ScratchSize;\r
-  UINTN                 BfvPageNumber;\r
-  UINTN                 BfvBase;\r
-  EFI_MAIN_ENTRYPOINT   EfiMainEntrypoint;\r
-  EFILDRHANDOFF         Handoff;\r
-  UINTN                 Index;\r
-\r
-  ClearScreen();\r
-  \r
-  PrintHeader ('A');\r
-  \r
-  PrintString ("Enter DUET Loader...\n");\r
-  PrintString ("BiosMemoryMapBaseAddress = %x\n", (UINTN) BiosMemoryMapBaseAddress);\r
-\r
-  //\r
-  // Add all EfiConventionalMemory descriptors to the table.  If there are partial pages, then\r
-  // round the start address up to the next page, and round the length down to a page boundary.\r
-  //\r
-  BiosMemoryMap = (BIOS_MEMORY_MAP *) (UINTN) BiosMemoryMapBaseAddress;\r
-  NumberOfMemoryMapEntries = 0;\r
-  GenMemoryMap (&NumberOfMemoryMapEntries, EfiMemoryDescriptor, BiosMemoryMap);\r
-\r
-  PrintString ("Get %d entries of memory map!\n", NumberOfMemoryMapEntries);\r
-\r
-  //\r
-  // Get information on where the image is in memory\r
-  //\r
-  EFILDRImage  = (EFILDR_IMAGE *)(UINTN)(EFILDR_HEADER_ADDRESS + sizeof(EFILDR_HEADER));\r
-\r
-\r
-  //\r
-  // Point to the 4th image (Bfv)\r
-  //\r
-  EFILDRImage += 3;\r
-\r
-  //\r
-  // Decompress the image\r
-  //\r
-  PrintString (\r
-    "Decompress BFV image, Image Address = %x Offset = %x\n", \r
-    (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-    (UINTN) EFILDRImage->Offset\r
-    );\r
-  Status = LzmaUefiDecompressGetInfo (\r
-             (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-             EFILDRImage->Length,\r
-             &DestinationSize, \r
-             &ScratchSize\r
-             );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to get decompress information for BFV!\n");\r
-  }\r
-  \r
-  PrintString ("BFV decompress: DestinationSize = %x, ScratchSize = %x\n", (UINTN) DestinationSize, (UINTN) ScratchSize);\r
-  Status =  LzmaUefiDecompress (\r
-    (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-    EFILDRImage->Length,\r
-    (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS, \r
-    (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)\r
-    );\r
-  \r
-\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to decompress BFV!\n");\r
-  }\r
-\r
-  BfvPageNumber = EFI_SIZE_TO_PAGES (DestinationSize);\r
-  BfvBase = (UINTN) FindSpace (BfvPageNumber, &NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesData, EFI_MEMORY_WB);\r
-  if (BfvBase == 0) {\r
-    SystemHang ("Failed to find free space to hold decompressed BFV\n");\r
-  }\r
-  ZeroMem ((VOID *)(UINTN)BfvBase, BfvPageNumber * EFI_PAGE_SIZE);\r
-  CopyMem ((VOID *)(UINTN)BfvBase, (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS, DestinationSize);\r
-\r
-  PrintHeader ('B');\r
-\r
-  //\r
-  // Point to the 2nd image (DxeIpl)\r
-  //\r
-    \r
-  EFILDRImage -= 2;\r
-\r
-  //\r
-  // Decompress the image\r
-  //\r
-  PrintString (\r
-    "Decompress DxeIpl image, Image Address = %x Offset = %x\n", \r
-    (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-    (UINTN) EFILDRImage->Offset\r
-    );\r
-\r
-  Status = LzmaUefiDecompressGetInfo (\r
-             (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-             EFILDRImage->Length,\r
-             &DestinationSize, \r
-             &ScratchSize\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to get decompress information for DxeIpl!\n");\r
-  }\r
-\r
-  Status = LzmaUefiDecompress (\r
-             (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-             EFILDRImage->Length,\r
-             (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS,\r
-             (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to decompress DxeIpl image\n");\r
-  }\r
-\r
-  PrintString ("Start load DxeIpl PE image\n");  \r
-\r
-  //\r
-  // Load and relocate the EFI PE/COFF Firmware Image \r
-  //\r
-  Status = EfiLdrPeCoffLoadPeImage (\r
-             (VOID *)(UINTN)(EFI_DECOMPRESSED_BUFFER_ADDRESS), \r
-             &DxeIplImage, \r
-             &NumberOfMemoryMapEntries, \r
-             EfiMemoryDescriptor\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to load and relocate DxeIpl PE image!\n");\r
-  }\r
-  PrintString (\r
-    "DxeIpl PE image is successed loaded at %lx, entry=%p\n",\r
-    DxeIplImage.ImageBasePage,\r
-    DxeIplImage.EntryPoint\r
-    );\r
-\r
-PrintHeader ('C');\r
-\r
-  //\r
-  // Point to the 3rd image (DxeMain)\r
-  //\r
-  EFILDRImage++;\r
-\r
-  //\r
-  // Decompress the image\r
-  //\r
-  PrintString (\r
-    "Decompress DxeMain FV image, Image Address = %x Offset = %x\n",\r
-    (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-    (UINTN) EFILDRImage->Offset\r
-    );\r
-\r
-  Status = LzmaUefiDecompressGetInfo (\r
-             (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-             EFILDRImage->Length,\r
-             &DestinationSize, \r
-             &ScratchSize\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to get decompress information for DxeMain FV image!\n");\r
-  }\r
-\r
-  Status = LzmaUefiDecompress (\r
-             (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-              EFILDRImage->Length,\r
-             (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS,\r
-             (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to decompress DxeMain FV image!\n");\r
-  }\r
-\r
-  //\r
-  // Load and relocate the EFI PE/COFF Firmware Image \r
-  //\r
-  Status = EfiLdrPeCoffLoadPeImage (\r
-             (VOID *)(UINTN)(EFI_DECOMPRESSED_BUFFER_ADDRESS), \r
-             &DxeCoreImage, \r
-             &NumberOfMemoryMapEntries, \r
-             EfiMemoryDescriptor\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    SystemHang ("Failed to load/relocate DxeMain!\n");\r
-  }\r
-  PrintString (\r
-    "DxeCore PE image is successed loaded at %lx, entry=%p\n",\r
-    DxeCoreImage.ImageBasePage,\r
-    DxeCoreImage.EntryPoint\r
-    );\r
-\r
-PrintHeader ('E');\r
-\r
-  //\r
-  // Display the table of memory descriptors.\r
-  //\r
-  PrintString ("\nEFI Memory Descriptors\n");   \r
-  for (Index = 0; Index < NumberOfMemoryMapEntries; Index++) {\r
-    PrintString (\r
-      "Type = %x Start = %08lx NumberOfPages = %08lx\n",\r
-      EfiMemoryDescriptor[Index].Type, EfiMemoryDescriptor[Index].PhysicalStart, EfiMemoryDescriptor[Index].NumberOfPages\r
-      );\r
-  }\r
-\r
-  //\r
-  // Jump to EFI Firmware\r
-  //\r
-\r
-  if (DxeIplImage.EntryPoint != NULL) {\r
-\r
-    Handoff.MemDescCount      = NumberOfMemoryMapEntries;\r
-    Handoff.MemDesc           = EfiMemoryDescriptor;\r
-    Handoff.BfvBase           = (VOID *)(UINTN)BfvBase;\r
-    Handoff.BfvSize           = BfvPageNumber * EFI_PAGE_SIZE;\r
-    Handoff.DxeIplImageBase   = (VOID *)(UINTN)DxeIplImage.ImageBasePage;\r
-    Handoff.DxeIplImageSize   = DxeIplImage.NoPages * EFI_PAGE_SIZE;\r
-    Handoff.DxeCoreImageBase  = (VOID *)(UINTN)DxeCoreImage.ImageBasePage;\r
-    Handoff.DxeCoreImageSize  = DxeCoreImage.NoPages * EFI_PAGE_SIZE;\r
-    Handoff.DxeCoreEntryPoint = (VOID *)(UINTN)DxeCoreImage.EntryPoint;\r
-\r
-    PrintString ("Transfer to DxeIpl ...EntryPoint = %p\n", DxeIplImage.EntryPoint);\r
-    \r
-    EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT) DxeIplImage.EntryPoint;\r
-    EfiMainEntrypoint (&Handoff);\r
-  }\r
-\r
-PrintHeader ('F');\r
-\r
-  //\r
-  // There was a problem loading the image, so HALT the system.\r
-  //\r
-\r
-  SystemHang ("Failed to jump to DxeIpl!\n");\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-_ModuleEntryPoint (\r
-  UINT32    BiosMemoryMapBaseAddress\r
-  )\r
-{\r
-  SerialPortInitialize ();\r
-  EfiLoader(BiosMemoryMapBaseAddress);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/DuetPkg/EfiLdr/LzmaDecompress.h b/DuetPkg/EfiLdr/LzmaDecompress.h
deleted file mode 100644 (file)
index e244df7..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/** @file\r
-  LZMA Decompress Library header file\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#ifndef __LZMADECOMPRESS_H__\r
-#define __LZMADECOMPRESS_H__\r
-\r
-/**\r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
-  \r
-  @param Source           The source buffer containing the compressed data.\r
-  @param SourceSize       The size of source buffer\r
-  @param DestinationSize  The size of destination buffer.\r
-  @param ScratchSize      The size of scratch buffer.\r
-\r
-  @retval RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successfully retrieved.\r
-  @retval RETURN_INVALID_PARAMETER - The source data is corrupted\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaUefiDecompressGetInfo (\r
-  IN  CONST VOID  *Source,\r
-  IN  UINT32      SourceSize,\r
-  OUT UINT32      *DestinationSize,\r
-  OUT UINT32      *ScratchSize\r
-  );\r
-\r
-/**\r
-  Decompresses a Lzma compressed source buffer.\r
-\r
-  Extracts decompressed data to its original form.\r
-  If the compressed source data specified by Source is successfully decompressed \r
-  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data \r
-  specified by Source is not in a valid compressed data format,\r
-  then RETURN_INVALID_PARAMETER is returned.\r
-\r
-  @param  Source      The source buffer containing the compressed data.\r
-  @param  SourceSize  The size of source buffer.\r
-  @param  Destination The destination buffer to store the decompressed data\r
-  @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
-                      This is an optional parameter that may be NULL if the \r
-                      required scratch buffer size is 0.\r
-                     \r
-  @retval  RETURN_SUCCESS Decompression completed successfully, and \r
-                          the uncompressed buffer is returned in Destination.\r
-  @retval  RETURN_INVALID_PARAMETER \r
-                          The source buffer specified by Source is corrupted \r
-                          (not in a valid compressed format).\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-LzmaUefiDecompress (\r
-  IN CONST VOID  *Source,\r
-  IN UINTN       SourceSize,\r
-  IN OUT VOID    *Destination,\r
-  IN OUT VOID    *Scratch\r
-  );\r
-  \r
-#endif // __LZMADECOMPRESS_H__\r
-\r
diff --git a/DuetPkg/EfiLdr/PeLoader.c b/DuetPkg/EfiLdr/PeLoader.c
deleted file mode 100644 (file)
index 5f13212..0000000
+++ /dev/null
@@ -1,635 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-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
-  PeLoader.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-#include "EfiLdr.h"\r
-#include "Debug.h"\r
-#include "Support.h"\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffLoadPeRelocate (\r
-  IN EFILDR_LOADED_IMAGE      *Image,\r
-  IN EFI_IMAGE_DATA_DIRECTORY *RelocDir,\r
-  IN UINTN                     Adjust,\r
-  IN UINTN                    *NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor\r
-  );\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffImageRead (\r
-    IN VOID                 *FHand,\r
-    IN UINTN                Offset,\r
-    IN OUT UINTN            ReadSize,\r
-    OUT VOID                *Buffer\r
-    );\r
-\r
-VOID *\r
-EfiLdrPeCoffImageAddress (\r
-  IN EFILDR_LOADED_IMAGE     *Image,\r
-  IN UINTN                   Address\r
-  );\r
-\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffSetImageType (\r
-  IN OUT EFILDR_LOADED_IMAGE      *Image,\r
-  IN UINTN                        ImageType\r
-  );\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffCheckImageMachineType (\r
-  IN UINT16           MachineType\r
-  );\r
-\r
-EFI_STATUS\r
-EfiLdrGetPeImageInfo (\r
-  IN  VOID                    *FHand,\r
-  OUT UINT64                  *ImageBase,\r
-  OUT UINT32                  *ImageSize\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_IMAGE_DOS_HEADER              DosHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION   PeHdr;\r
-\r
-  ZeroMem (&DosHdr, sizeof(DosHdr));\r
-  ZeroMem (&PeHdr, sizeof(PeHdr));\r
-\r
-  //\r
-  // Read image headers\r
-  //\r
-\r
-  EfiLdrPeCoffImageRead (FHand, 0, sizeof(DosHdr), &DosHdr);\r
-  if (DosHdr.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  EfiLdrPeCoffImageRead (FHand, DosHdr.e_lfanew, sizeof(PeHdr), &PeHdr);\r
-\r
-  if (PeHdr.Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-    \r
-  //\r
-  // Verify machine type\r
-  //\r
-\r
-  Status = EfiLdrPeCoffCheckImageMachineType (PeHdr.Pe32.FileHeader.Machine);\r
-  if (EFI_ERROR(Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    *ImageBase = (UINT32)PeHdr.Pe32.OptionalHeader.ImageBase;\r
-  } else if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-    *ImageBase = PeHdr.Pe32Plus.OptionalHeader.ImageBase;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  *ImageSize = PeHdr.Pe32.OptionalHeader.SizeOfImage;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffLoadPeImage (\r
-  IN VOID                     *FHand,\r
-  IN EFILDR_LOADED_IMAGE      *Image,\r
-  IN UINTN                    *NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor\r
-  )\r
-{\r
-  EFI_IMAGE_DOS_HEADER            DosHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER_UNION PeHdr;\r
-  EFI_IMAGE_SECTION_HEADER        *FirstSection;\r
-  EFI_IMAGE_SECTION_HEADER        *Section;\r
-  UINTN                           Index;\r
-  EFI_STATUS                      Status;\r
-  UINT8                           *Base;\r
-  UINT8                           *End;\r
-  EFI_IMAGE_DATA_DIRECTORY        *DirectoryEntry;\r
-  UINTN                           DirCount;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY TempDebugEntry;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;\r
-  UINTN                           CodeViewSize;\r
-  UINTN                           CodeViewOffset;\r
-  UINTN                           CodeViewFileOffset;\r
-  UINTN                           OptionalHeaderSize;\r
-  UINTN                           PeHeaderSize;\r
-  UINT32                          NumberOfRvaAndSizes;\r
-  EFI_IMAGE_DATA_DIRECTORY        *DataDirectory;\r
-  UINT64                          ImageBase;\r
-  CHAR8                           PrintBuffer[256];\r
-\r
-  ZeroMem (&DosHdr, sizeof(DosHdr));\r
-  ZeroMem (&PeHdr, sizeof(PeHdr));\r
-\r
-  //\r
-  // Read image headers\r
-  //\r
-\r
-  EfiLdrPeCoffImageRead (FHand, 0, sizeof(DosHdr), &DosHdr);\r
-  if (DosHdr.e_magic != EFI_IMAGE_DOS_SIGNATURE) {\r
-    AsciiSPrint (PrintBuffer, 256, "PeCoffLoadPeImage: Dos header signature not found\n");\r
-    PrintString (PrintBuffer);\r
-    PrintHeader ('F');\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  EfiLdrPeCoffImageRead (FHand, DosHdr.e_lfanew, sizeof(PeHdr), &PeHdr);\r
-\r
-  if (PeHdr.Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {\r
-    AsciiSPrint (PrintBuffer, 256, "PeCoffLoadPeImage: PE image header signature not found\n");\r
-    PrintString (PrintBuffer);\r
-    PrintHeader ('G');\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-    \r
-  //\r
-  // Set the image subsystem type\r
-  //\r
-\r
-  Status = EfiLdrPeCoffSetImageType (Image, PeHdr.Pe32.OptionalHeader.Subsystem);\r
-  if (EFI_ERROR(Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "PeCoffLoadPeImage: Subsystem type not known\n");\r
-    PrintString (PrintBuffer);\r
-    PrintHeader ('H');\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Verify machine type\r
-  //\r
-\r
-  Status = EfiLdrPeCoffCheckImageMachineType (PeHdr.Pe32.FileHeader.Machine);\r
-  if (EFI_ERROR(Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "PeCoffLoadPeImage: Incorrect machine type\n");\r
-    PrintString (PrintBuffer);\r
-    PrintHeader ('I');\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Compute the amount of memory needed to load the image and \r
-  // allocate it.  This will include all sections plus the codeview debug info.\r
-  // Since the codeview info is actually outside of the image, we calculate\r
-  // its size seperately and add it to the total.\r
-  //\r
-  // Memory starts off as data\r
-  //\r
-\r
-  CodeViewSize       = 0;\r
-  CodeViewFileOffset = 0;\r
-  if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(PeHdr.Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-  } else if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-    DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(PeHdr.Pe32Plus.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  for (DirCount = 0; \r
-       (DirCount < DirectoryEntry->Size / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) && (CodeViewSize == 0);\r
-       DirCount++) {\r
-    Status = EfiLdrPeCoffImageRead (\r
-               FHand, \r
-               DirectoryEntry->VirtualAddress + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY),\r
-               sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY),\r
-               &TempDebugEntry\r
-               );\r
-    if (!EFI_ERROR (Status)) {\r
-      if (TempDebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
-        CodeViewSize = TempDebugEntry.SizeOfData;\r
-        CodeViewFileOffset = TempDebugEntry.FileOffset;\r
-      }\r
-    }\r
-  }\r
-    \r
-  CodeViewOffset = PeHdr.Pe32.OptionalHeader.SizeOfImage + PeHdr.Pe32.OptionalHeader.SectionAlignment;\r
-  Image->NoPages = EFI_SIZE_TO_PAGES (CodeViewOffset + CodeViewSize);\r
-\r
-  //\r
-  // Compute the amount of memory needed to load the image and \r
-  // allocate it.  Memory starts off as data\r
-  //\r
-\r
-  Image->ImageBasePage = (EFI_PHYSICAL_ADDRESS)FindSpace (Image->NoPages, NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesCode, EFI_MEMORY_WB);\r
-  if (Image->ImageBasePage == 0) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    PrintHeader ('J');\r
-    return Status;\r
-  }\r
-\r
-  AsciiSPrint (PrintBuffer, 256, "LoadPe: new image base %lx\n", Image->ImageBasePage);\r
-  PrintString (PrintBuffer);\r
-  Image->Info.ImageBase = (VOID *)(UINTN)Image->ImageBasePage;\r
-  Image->Info.ImageSize = (Image->NoPages << EFI_PAGE_SHIFT) - 1;\r
-  Image->ImageBase      = (UINT8 *)(UINTN)Image->ImageBasePage;\r
-  Image->ImageEof       = Image->ImageBase + Image->Info.ImageSize;\r
-  Image->ImageAdjust    = Image->ImageBase;\r
-\r
-  //\r
-  // Copy the Image header to the base location\r
-  //\r
-  Status = EfiLdrPeCoffImageRead (\r
-             FHand, \r
-             0, \r
-             PeHdr.Pe32.OptionalHeader.SizeOfHeaders, \r
-             Image->ImageBase\r
-             );\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    PrintHeader ('K');\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Load each directory of the image into memory... \r
-  //  Save the address of the Debug directory for later\r
-  //\r
-  if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    NumberOfRvaAndSizes = PeHdr.Pe32.OptionalHeader.NumberOfRvaAndSizes;\r
-    DataDirectory = PeHdr.Pe32.OptionalHeader.DataDirectory;\r
-  } else {\r
-    NumberOfRvaAndSizes = PeHdr.Pe32Plus.OptionalHeader.NumberOfRvaAndSizes;\r
-    DataDirectory = PeHdr.Pe32Plus.OptionalHeader.DataDirectory;\r
-  }\r
-  DebugEntry = NULL;\r
-  for (Index = 0; Index < NumberOfRvaAndSizes; Index++) {\r
-    if ((DataDirectory[Index].VirtualAddress != 0) && (DataDirectory[Index].Size != 0)) {\r
-      Status = EfiLdrPeCoffImageRead (\r
-                 FHand,\r
-                 DataDirectory[Index].VirtualAddress,\r
-                 DataDirectory[Index].Size,\r
-                 Image->ImageBase + DataDirectory[Index].VirtualAddress\r
-                 );\r
-      if (EFI_ERROR(Status)) {\r
-        return Status;\r
-      }\r
-      if (Index == EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
-        DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (Image->ImageBase + DataDirectory[Index].VirtualAddress);\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Load each section of the image\r
-  //\r
-\r
-  // BUGBUG: change this to use the in memory copy\r
-  if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    OptionalHeaderSize = sizeof(EFI_IMAGE_OPTIONAL_HEADER32);\r
-    PeHeaderSize       = sizeof(EFI_IMAGE_NT_HEADERS32);\r
-  } else {\r
-    OptionalHeaderSize = sizeof(EFI_IMAGE_OPTIONAL_HEADER64);\r
-    PeHeaderSize       = sizeof(EFI_IMAGE_NT_HEADERS64);\r
-  }\r
-  FirstSection = (EFI_IMAGE_SECTION_HEADER *) (\r
-                   Image->ImageBase +\r
-                   DosHdr.e_lfanew + \r
-                   PeHeaderSize + \r
-                   PeHdr.Pe32.FileHeader.SizeOfOptionalHeader - \r
-                   OptionalHeaderSize\r
-                   );\r
-\r
-  Section = FirstSection;\r
-  for (Index=0; Index < PeHdr.Pe32.FileHeader.NumberOfSections; Index += 1) {\r
-\r
-    //\r
-    // Compute sections address\r
-    //\r
-\r
-    Base = EfiLdrPeCoffImageAddress (Image, (UINTN)Section->VirtualAddress);\r
-    End = EfiLdrPeCoffImageAddress (Image, (UINTN)(Section->VirtualAddress + Section->Misc.VirtualSize));\r
-        \r
-    if (EFI_ERROR(Status) || !Base || !End) {\r
-//      DEBUG((D_LOAD|D_ERROR, "LoadPe: Section %d was not loaded\n", Index));\r
-    PrintHeader ('L');\r
-      return EFI_LOAD_ERROR;\r
-    }\r
-\r
-//    DEBUG((D_LOAD, "LoadPe: Section %d, loaded at %x\n", Index, Base));\r
-\r
-    //\r
-    // Read the section\r
-    //\r
\r
-    if (Section->SizeOfRawData) {\r
-      Status = EfiLdrPeCoffImageRead (FHand, Section->PointerToRawData, Section->SizeOfRawData, Base);\r
-      if (EFI_ERROR(Status)) {\r
-PrintHeader ('M');\r
-        return Status;\r
-      }\r
-    }\r
-\r
-    //\r
-    // If raw size is less then virt size, zero fill the remaining\r
-    //\r
-\r
-    if (Section->SizeOfRawData < Section->Misc.VirtualSize) {\r
-      ZeroMem (\r
-        Base + Section->SizeOfRawData, \r
-        Section->Misc.VirtualSize - Section->SizeOfRawData\r
-        );\r
-    }\r
-\r
-    //\r
-    // Next Section\r
-    //\r
-\r
-    Section += 1;\r
-  }\r
-\r
-  //\r
-  // Copy in CodeView information if it exists\r
-  //\r
-  if (CodeViewSize != 0) {\r
-    Status = EfiLdrPeCoffImageRead (FHand, CodeViewFileOffset, CodeViewSize, Image->ImageBase + CodeViewOffset);\r
-    DebugEntry->RVA = (UINT32) (CodeViewOffset);\r
-  }\r
-\r
-  //\r
-  // Apply relocations only if needed\r
-  //\r
-  if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-    ImageBase = (UINT64)PeHdr.Pe32.OptionalHeader.ImageBase;\r
-  } else {\r
-    ImageBase = PeHdr.Pe32Plus.OptionalHeader.ImageBase;\r
-  }\r
-  if ((UINTN)(Image->ImageBase) != (UINTN) (ImageBase)) {\r
-    Status = EfiLdrPeCoffLoadPeRelocate (\r
-               Image,\r
-               &DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC],\r
-               (UINTN) Image->ImageBase - (UINTN)ImageBase,\r
-               NumberOfMemoryMapEntries,\r
-               EfiMemoryDescriptor\r
-               );\r
-\r
-    if (EFI_ERROR(Status)) {\r
-      PrintHeader ('N');\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Use exported EFI specific interface if present, else use the image's entry point\r
-  //\r
-  Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)\r
-                        (EfiLdrPeCoffImageAddress(\r
-                           Image, \r
-                           PeHdr.Pe32.OptionalHeader.AddressOfEntryPoint\r
-                           ));\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffLoadPeRelocate (\r
-  IN EFILDR_LOADED_IMAGE      *Image,\r
-  IN EFI_IMAGE_DATA_DIRECTORY *RelocDir,\r
-  IN UINTN                     Adjust,\r
-  IN UINTN                    *NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor\r
-  )\r
-{\r
-  EFI_IMAGE_BASE_RELOCATION   *RelocBase;\r
-  EFI_IMAGE_BASE_RELOCATION   *RelocBaseEnd;\r
-  UINT16                      *Reloc;\r
-  UINT16                      *RelocEnd;\r
-  UINT8                       *Fixup;\r
-  UINT8                       *FixupBase;\r
-  UINT16                      *F16;\r
-  UINT32                      *F32;\r
-  UINT64                      *F64;\r
-  UINT8                       *FixupData;\r
-  UINTN                       NoFixupPages;\r
-\r
-  //\r
-  // Find the relocation block\r
-  //\r
-\r
-  RelocBase = EfiLdrPeCoffImageAddress (Image, RelocDir->VirtualAddress);\r
-  RelocBaseEnd = EfiLdrPeCoffImageAddress (Image, RelocDir->VirtualAddress + RelocDir->Size);\r
-  if (!RelocBase || !RelocBaseEnd) {\r
-PrintHeader ('O');\r
-    return EFI_LOAD_ERROR;\r
-  }\r
-\r
-  NoFixupPages = EFI_SIZE_TO_PAGES(RelocDir->Size / sizeof(UINT16) * sizeof(UINTN));\r
-  Image->FixupData = (UINT8*) FindSpace (NoFixupPages, NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesData, EFI_MEMORY_WB);\r
-  if (Image->FixupData == 0) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Run the whole relocation block\r
-  //\r
-\r
-  FixupData = Image->FixupData;\r
-  while (RelocBase < RelocBaseEnd) {\r
-           \r
-    Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof(EFI_IMAGE_BASE_RELOCATION));\r
-    RelocEnd = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock);\r
-    FixupBase = EfiLdrPeCoffImageAddress (Image, RelocBase->VirtualAddress);\r
-    if ((UINT8 *) RelocEnd < Image->ImageBase || (UINT8 *) RelocEnd > Image->ImageEof) {\r
-PrintHeader ('P');\r
-      return EFI_LOAD_ERROR;\r
-    }\r
-\r
-    //\r
-    // Run this relocation record\r
-    //\r
-\r
-    while (Reloc < RelocEnd) {\r
-\r
-      Fixup = FixupBase + (*Reloc & 0xFFF);\r
-      switch ((*Reloc) >> 12) {\r
-\r
-      case EFI_IMAGE_REL_BASED_ABSOLUTE:\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_HIGH:\r
-        F16 = (UINT16 *) Fixup;\r
-        *F16  = (UINT16) (*F16 + (UINT16)(((UINT32)Adjust) >> 16));\r
-        if (FixupData != NULL) {\r
-          *(UINT16 *) FixupData = *F16;\r
-          FixupData = FixupData + sizeof(UINT16);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_LOW:\r
-        F16 = (UINT16 *) Fixup;\r
-        *F16 = (UINT16) (*F16 + (UINT16) Adjust);\r
-        if (FixupData != NULL) {\r
-          *(UINT16 *) FixupData = *F16;\r
-          FixupData = FixupData + sizeof(UINT16);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_HIGHLOW:\r
-        F32 = (UINT32 *) Fixup;\r
-        *F32 = *F32 + (UINT32) Adjust;\r
-        if (FixupData != NULL) {\r
-          FixupData = ALIGN_POINTER(FixupData, sizeof(UINT32));\r
-          *(UINT32 *) FixupData = *F32;\r
-          FixupData = FixupData + sizeof(UINT32);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_DIR64:\r
-        F64 = (UINT64 *) Fixup;\r
-        *F64 = *F64 + (UINT64) Adjust;\r
-        if (FixupData != NULL) {\r
-          FixupData = ALIGN_POINTER(FixupData, sizeof(UINT64));\r
-          *(UINT64 *) FixupData = *F64;\r
-          FixupData = FixupData + sizeof(UINT64);\r
-        }\r
-        break;\r
-\r
-      case EFI_IMAGE_REL_BASED_HIGHADJ:\r
-        CpuDeadLoop();                 // BUGBUG: not done\r
-        break;\r
-\r
-      default:\r
-//        DEBUG((D_LOAD|D_ERROR, "PeRelocate: unknown fixed type\n"));\r
-PrintHeader ('Q');\r
-        CpuDeadLoop();\r
-        return EFI_LOAD_ERROR;\r
-      }\r
-\r
-      // Next reloc record\r
-      Reloc += 1;\r
-    }\r
-\r
-    // next reloc block\r
-    RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;\r
-  }\r
-\r
-  //\r
-  // Add Fixup data to whole Image (assume Fixup data just below the image), so that there is no hole in the descriptor.\r
-  // Because only NoPages or ImageBasePage will be used in EfiLoader(), we update these 2 fields.\r
-  //\r
-  Image->NoPages += NoFixupPages;\r
-  Image->ImageBasePage -= (NoFixupPages << EFI_PAGE_SHIFT);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffImageRead (\r
-  IN VOID                 *FHand,\r
-  IN UINTN                Offset,\r
-  IN OUT UINTN            ReadSize,\r
-  OUT VOID                *Buffer\r
-  )\r
-{\r
-  CopyMem (Buffer, (VOID *)((UINTN)FHand + Offset), ReadSize);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID *\r
-EfiLdrPeCoffImageAddress (\r
-  IN EFILDR_LOADED_IMAGE     *Image,\r
-  IN UINTN                   Address\r
-  )\r
-{\r
-  UINT8        *FixedAddress;\r
-\r
-  FixedAddress = Image->ImageAdjust + Address;\r
-\r
-  if ((FixedAddress < Image->ImageBase) || (FixedAddress > Image->ImageEof)) {\r
-//    DEBUG((D_LOAD|D_ERROR, "PeCoffImageAddress: pointer is outside of image\n"));\r
-    FixedAddress = NULL;\r
-  }\r
-\r
-//  DEBUG((\r
-//    D_LOAD,\r
-//    "PeCoffImageAddress: ImageBase %x, ImageEof %x, Address %x, FixedAddress %x\n", \r
-//    Image->ImageBase,\r
-//    Image->ImageEof,\r
-//    Address,\r
-//    FixedAddress\r
-//    ));\r
-    return FixedAddress;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffSetImageType (\r
-  IN OUT EFILDR_LOADED_IMAGE      *Image,\r
-  IN UINTN                        ImageType\r
-  )\r
-{\r
-  EFI_MEMORY_TYPE                 CodeType;\r
-  EFI_MEMORY_TYPE                 DataType;\r
-\r
-  switch (ImageType) {\r
-  case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:\r
-    CodeType = EfiLoaderCode;\r
-    DataType = EfiLoaderData;\r
-    break;\r
-\r
-  case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:\r
-    CodeType = EfiBootServicesCode;\r
-    DataType = EfiBootServicesData;\r
-    break;\r
-\r
-  case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
-    CodeType = EfiRuntimeServicesCode;\r
-    DataType = EfiRuntimeServicesData;\r
-    break;\r
-\r
-  default:\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Image->Type = ImageType;\r
-  Image->Info.ImageCodeType = CodeType;    \r
-  Image->Info.ImageDataType = DataType;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffCheckImageMachineType (\r
-  IN UINT16           MachineType\r
-  )\r
-{\r
-  EFI_STATUS          Status;\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-\r
-#ifdef MDE_CPU_IA32\r
-  if (MachineType == EFI_IMAGE_MACHINE_IA32) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-#endif\r
-\r
-#ifdef MDE_CPU_X64\r
-  if (MachineType == EFI_IMAGE_MACHINE_X64) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-#endif\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/DuetPkg/EfiLdr/PeLoader.h b/DuetPkg/EfiLdr/PeLoader.h
deleted file mode 100644 (file)
index c6c2398..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PeLoader.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _EFILDR_PELOADER_H_\r
-#define _EFILDR_PELOADER_H_\r
-\r
-#include "EfiLdr.h"\r
-\r
-EFI_STATUS\r
-EfiLdrGetPeImageInfo (\r
-  IN VOID                     *FHand,\r
-  OUT UINT64                  *ImageBase,\r
-  OUT UINT32                  *ImageSize\r
-  );\r
-\r
-EFI_STATUS\r
-EfiLdrPeCoffLoadPeImage (\r
-  IN VOID                     *FHand,\r
-  IN EFILDR_LOADED_IMAGE      *Image,\r
-  IN UINTN                    *NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor\r
-  );\r
-\r
-\r
-#endif\r
diff --git a/DuetPkg/EfiLdr/Support.c b/DuetPkg/EfiLdr/Support.c
deleted file mode 100644 (file)
index a0c9046..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  Support.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-#include "EfiLdr.h"\r
-\r
-EFI_STATUS\r
-EfiAddMemoryDescriptor(\r
-  UINTN                 *NoDesc,\r
-  EFI_MEMORY_DESCRIPTOR *Desc,\r
-  EFI_MEMORY_TYPE       Type,\r
-  EFI_PHYSICAL_ADDRESS  BaseAddress,\r
-  UINT64                NoPages,\r
-  UINT64                Attribute\r
-  )\r
-{\r
-  UINTN  NumberOfDesc;\r
-  UINT64 Temp;\r
-  UINTN  Index;\r
-\r
-  if (NoPages == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // See if the new memory descriptor needs to be carved out of an existing memory descriptor\r
-  //\r
-\r
-  NumberOfDesc = *NoDesc;\r
-  for (Index = 0; Index < NumberOfDesc; Index++) {\r
-\r
-    if (Desc[Index].Type == EfiConventionalMemory) {\r
-\r
-      Temp = DivU64x32 ((BaseAddress - Desc[Index].PhysicalStart), EFI_PAGE_SIZE) + NoPages;\r
-\r
-      if ((Desc[Index].PhysicalStart < BaseAddress) && (Desc[Index].NumberOfPages >= Temp)) {\r
-        if (Desc[Index].NumberOfPages > Temp) {\r
-          Desc[*NoDesc].Type          = EfiConventionalMemory;\r
-          Desc[*NoDesc].PhysicalStart = BaseAddress + MultU64x32 (NoPages, EFI_PAGE_SIZE);\r
-          Desc[*NoDesc].NumberOfPages = Desc[Index].NumberOfPages - Temp;\r
-          Desc[*NoDesc].VirtualStart  = 0;\r
-          Desc[*NoDesc].Attribute     = Desc[Index].Attribute;\r
-          *NoDesc = *NoDesc + 1;\r
-        }\r
-        Desc[Index].NumberOfPages = Temp - NoPages;\r
-      }\r
-\r
-      if ((Desc[Index].PhysicalStart == BaseAddress) && (Desc[Index].NumberOfPages == NoPages)) {\r
-        Desc[Index].Type      = Type;\r
-        Desc[Index].Attribute = Attribute;\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      if ((Desc[Index].PhysicalStart == BaseAddress) && (Desc[Index].NumberOfPages > NoPages)) {\r
-        Desc[Index].NumberOfPages -= NoPages;\r
-        Desc[Index].PhysicalStart += MultU64x32 (NoPages, EFI_PAGE_SIZE);\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Add the new memory descriptor\r
-  //\r
-\r
-  Desc[*NoDesc].Type          = Type;\r
-  Desc[*NoDesc].PhysicalStart = BaseAddress;\r
-  Desc[*NoDesc].NumberOfPages = NoPages;\r
-  Desc[*NoDesc].VirtualStart  = 0;\r
-  Desc[*NoDesc].Attribute     = Attribute;\r
-  *NoDesc = *NoDesc + 1;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINTN\r
-FindSpace (\r
-  UINTN                       NoPages,\r
-  IN UINTN                    *NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor,\r
-  EFI_MEMORY_TYPE             Type,\r
-  UINT64                      Attribute\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS        MaxPhysicalStart;\r
-  UINT64                      MaxNoPages;\r
-  UINTN                       Index;\r
-  EFI_MEMORY_DESCRIPTOR       *CurrentMemoryDescriptor;\r
-\r
-  MaxPhysicalStart = 0;\r
-  MaxNoPages       = 0;\r
-  CurrentMemoryDescriptor = NULL;\r
-  for (Index = 0; Index < *NumberOfMemoryMapEntries; Index++) {\r
-    if (EfiMemoryDescriptor[Index].PhysicalStart + LShiftU64(EfiMemoryDescriptor[Index].NumberOfPages, EFI_PAGE_SHIFT) <= 0x100000) {\r
-      continue;\r
-    }\r
-    if ((EfiMemoryDescriptor[Index].Type == EfiConventionalMemory) && \r
-        (EfiMemoryDescriptor[Index].NumberOfPages >= NoPages)) {\r
-      if (EfiMemoryDescriptor[Index].PhysicalStart > MaxPhysicalStart) {\r
-        if (EfiMemoryDescriptor[Index].PhysicalStart + LShiftU64(EfiMemoryDescriptor[Index].NumberOfPages, EFI_PAGE_SHIFT) <= 0x100000000ULL) {\r
-          MaxPhysicalStart = EfiMemoryDescriptor[Index].PhysicalStart;\r
-          MaxNoPages       = EfiMemoryDescriptor[Index].NumberOfPages;\r
-          CurrentMemoryDescriptor = &EfiMemoryDescriptor[Index];\r
-        }\r
-      }\r
-    }\r
-    if ((EfiMemoryDescriptor[Index].Type == EfiReservedMemoryType) ||\r
-        (EfiMemoryDescriptor[Index].Type >= EfiACPIReclaimMemory) ) {\r
-      continue;\r
-    }\r
-    if ((EfiMemoryDescriptor[Index].Type == EfiRuntimeServicesCode) ||\r
-        (EfiMemoryDescriptor[Index].Type == EfiRuntimeServicesData)) {\r
-      break;\r
-    }\r
-  }\r
\r
-  if (MaxPhysicalStart == 0) {\r
-    return 0;\r
-  }\r
-\r
-  if (MaxNoPages != NoPages) {\r
-    CurrentMemoryDescriptor->NumberOfPages = MaxNoPages - NoPages;\r
-    EfiMemoryDescriptor[*NumberOfMemoryMapEntries].Type          = Type;\r
-    EfiMemoryDescriptor[*NumberOfMemoryMapEntries].PhysicalStart = MaxPhysicalStart + LShiftU64(MaxNoPages - NoPages, EFI_PAGE_SHIFT);\r
-    EfiMemoryDescriptor[*NumberOfMemoryMapEntries].NumberOfPages = NoPages;\r
-    EfiMemoryDescriptor[*NumberOfMemoryMapEntries].VirtualStart  = 0;\r
-    EfiMemoryDescriptor[*NumberOfMemoryMapEntries].Attribute     = Attribute;\r
-    *NumberOfMemoryMapEntries = *NumberOfMemoryMapEntries + 1;\r
-  } else {\r
-    CurrentMemoryDescriptor->Type      = Type;\r
-    CurrentMemoryDescriptor->Attribute = Attribute;\r
-  }\r
-\r
-  return (UINTN)(MaxPhysicalStart + LShiftU64(MaxNoPages - NoPages, EFI_PAGE_SHIFT));\r
-}\r
-\r
-VOID\r
-GenMemoryMap (\r
-  UINTN                 *NumberOfMemoryMapEntries,\r
-  EFI_MEMORY_DESCRIPTOR *EfiMemoryDescriptor,\r
-  BIOS_MEMORY_MAP       *BiosMemoryMap\r
-  )\r
-{\r
-  UINT64                BaseAddress;\r
-  UINT64                Length;\r
-  EFI_MEMORY_TYPE       Type;\r
-  UINTN                 Index;\r
-  UINTN                 Attr;\r
-  UINT64                Ceiling;\r
-\r
-  Ceiling = 0xFFFFFFFF;\r
-  for (Index = 0; Index < BiosMemoryMap->MemoryMapSize / sizeof(BIOS_MEMORY_MAP_ENTRY); Index++) {\r
-\r
-    switch (BiosMemoryMap->MemoryMapEntry[Index].Type) { \r
-    case (INT15_E820_AddressRangeMemory):\r
-      Type = EfiConventionalMemory;\r
-      Attr = EFI_MEMORY_WB;\r
-      break;\r
-    case (INT15_E820_AddressRangeReserved):\r
-      Type = EfiReservedMemoryType;\r
-      Attr = EFI_MEMORY_UC;\r
-      break;\r
-    case (INT15_E820_AddressRangeACPI):\r
-      Type = EfiACPIReclaimMemory;\r
-      Attr = EFI_MEMORY_WB;\r
-      break;\r
-    case (INT15_E820_AddressRangeNVS):\r
-      Type = EfiACPIMemoryNVS;\r
-      Attr = EFI_MEMORY_UC;\r
-      break;\r
-    default:\r
-      // We should not get here, according to ACPI 2.0 Spec.\r
-      // BIOS behaviour of the Int15h, E820h\r
-      Type = EfiReservedMemoryType;\r
-      Attr = EFI_MEMORY_UC;\r
-      break;\r
-    }\r
-    if (Type == EfiConventionalMemory) {\r
-      BaseAddress = BiosMemoryMap->MemoryMapEntry[Index].BaseAddress;\r
-      Length      = BiosMemoryMap->MemoryMapEntry[Index].Length;\r
-      if (BaseAddress & EFI_PAGE_MASK) {\r
-        Length      = Length + (BaseAddress & EFI_PAGE_MASK) - EFI_PAGE_SIZE;\r
-        BaseAddress = LShiftU64 (RShiftU64 (BaseAddress, EFI_PAGE_SHIFT) + 1, EFI_PAGE_SHIFT);\r
-      }\r
-    } else {\r
-      BaseAddress = BiosMemoryMap->MemoryMapEntry[Index].BaseAddress;\r
-      Length      = BiosMemoryMap->MemoryMapEntry[Index].Length + (BaseAddress & EFI_PAGE_MASK);\r
-      BaseAddress = LShiftU64 (RShiftU64 (BaseAddress, EFI_PAGE_SHIFT), EFI_PAGE_SHIFT);\r
-      if (Length & EFI_PAGE_MASK) {\r
-        Length = LShiftU64 (RShiftU64 (Length, EFI_PAGE_SHIFT) + 1, EFI_PAGE_SHIFT);\r
-      }\r
-      //\r
-      // Update Memory Ceiling\r
-      //\r
-      if ((BaseAddress >= 0x100000) && (BaseAddress < 0x100000000ULL)) {\r
-        if (Ceiling > BaseAddress) {\r
-          Ceiling = BaseAddress;\r
-        }\r
-      }\r
-    }\r
-    EfiAddMemoryDescriptor (\r
-      NumberOfMemoryMapEntries,\r
-      EfiMemoryDescriptor,\r
-      Type,\r
-      (EFI_PHYSICAL_ADDRESS)BaseAddress,\r
-      RShiftU64 (Length, EFI_PAGE_SHIFT),\r
-      Attr\r
-      );\r
-  }\r
-\r
-  //\r
-  // Update MemoryMap according to Ceiling\r
-  //\r
-  for (Index = 0; Index < *NumberOfMemoryMapEntries; Index++) {\r
-    if ((EfiMemoryDescriptor[Index].Type == EfiConventionalMemory) &&\r
-        (EfiMemoryDescriptor[Index].PhysicalStart > 0x100000) && \r
-        (EfiMemoryDescriptor[Index].PhysicalStart < 0x100000000ULL)) {\r
-      if (EfiMemoryDescriptor[Index].PhysicalStart >= Ceiling) {\r
-        EfiMemoryDescriptor[Index].Type = EfiReservedMemoryType;\r
-      }\r
-    }\r
-  }\r
-}\r
diff --git a/DuetPkg/EfiLdr/Support.h b/DuetPkg/EfiLdr/Support.h
deleted file mode 100644 (file)
index 6c5789a..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  Support.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-#ifndef _EFILDR_SUPPORT_H_\r
-#define _EFILDR_SUPPORT_H_\r
-\r
-EFI_STATUS\r
-EfiAddMemoryDescriptor(\r
-  UINTN                 *NoDesc,\r
-  EFI_MEMORY_DESCRIPTOR *Desc,\r
-  EFI_MEMORY_TYPE       Type,\r
-  EFI_PHYSICAL_ADDRESS  BaseAddress,\r
-  UINT64                NoPages,\r
-  UINT64                Attribute\r
-  );\r
-\r
-UINTN\r
-FindSpace(\r
-  UINTN                       NoPages,\r
-  IN UINTN                    *NumberOfMemoryMapEntries,\r
-  IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor,\r
-  EFI_MEMORY_TYPE             Type,\r
-  UINT64                      Attribute\r
-  );\r
-\r
-VOID\r
-GenMemoryMap (\r
-  UINTN                 *NumberOfMemoryMapEntries,\r
-  EFI_MEMORY_DESCRIPTOR *EfiMemoryDescriptor,\r
-  BIOS_MEMORY_MAP       *BiosMemoryMap\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/EfiLdr/TianoDecompress.c b/DuetPkg/EfiLdr/TianoDecompress.c
deleted file mode 100644 (file)
index 695f516..0000000
+++ /dev/null
@@ -1,990 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  Decompress.c\r
-\r
-Abstract:\r
-\r
-  Decompressor. Algorithm Ported from OPSD code (Decomp.asm)\r
-  \r
---*/\r
-#include <TianoDecompress.h>\r
-//\r
-// Decompression algorithm begins here\r
-//\r
-#define BITBUFSIZ 32\r
-#define MAXMATCH  256\r
-#define THRESHOLD 3\r
-#define CODE_BIT  16\r
-#define BAD_TABLE - 1\r
-\r
-//\r
-// C: Char&Len Set; P: Position Set; T: exTra Set\r
-//\r
-#define NC      (0xff + MAXMATCH + 2 - THRESHOLD)\r
-#define CBIT    9\r
-#define MAXPBIT 5\r
-#define TBIT    5\r
-#define MAXNP   ((1U << MAXPBIT) - 1)\r
-#define NT      (CODE_BIT + 3)\r
-#if NT > MAXNP\r
-#define NPT NT\r
-#else\r
-#define NPT MAXNP\r
-#endif\r
-\r
-typedef struct {\r
-  UINT8   *mSrcBase;  // Starting address of compressed data\r
-  UINT8   *mDstBase;  // Starting address of decompressed data\r
-  UINT32  mOutBuf;\r
-  UINT32  mInBuf;\r
-\r
-  UINT16  mBitCount;\r
-  UINT32  mBitBuf;\r
-  UINT32  mSubBitBuf;\r
-  UINT16  mBlockSize;\r
-  UINT32  mCompSize;\r
-  UINT32  mOrigSize;\r
-\r
-  UINT16  mBadTableFlag;\r
-\r
-  UINT16  mLeft[2 * NC - 1];\r
-  UINT16  mRight[2 * NC - 1];\r
-  UINT8   mCLen[NC];\r
-  UINT8   mPTLen[NPT];\r
-  UINT16  mCTable[4096];\r
-  UINT16  mPTTable[256];\r
-\r
-  //\r
-  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
-  // For EFI 1.1 de/compression algorithm, mPBit = 4\r
-  // For Tiano de/compression algorithm, mPBit = 5\r
-  //\r
-  UINT8   mPBit;\r
-} SCRATCH_DATA;\r
-\r
-VOID\r
-FillBuf (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfBits\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  NumOfBits  - The number of bits to shift and read.\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  Sd->mBitBuf = (UINT32) LShiftU64 (((UINT64)Sd->mBitBuf), NumOfBits);\r
-\r
-  while (NumOfBits > Sd->mBitCount) {\r
-    NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount);\r
-    Sd->mBitBuf |= (UINT32) LShiftU64 (((UINT64)Sd->mSubBitBuf), NumOfBits);\r
-\r
-    if (Sd->mCompSize > 0) {\r
-      //\r
-      // Get 1 byte into SubBitBuf\r
-      //\r
-      Sd->mCompSize--;\r
-      Sd->mSubBitBuf  = 0;\r
-      Sd->mSubBitBuf  = Sd->mSrcBase[Sd->mInBuf++];\r
-      Sd->mBitCount   = 8;\r
-\r
-    } else {\r
-      //\r
-      // No more bits from the source, just pad zero bit.\r
-      //\r
-      Sd->mSubBitBuf  = 0;\r
-      Sd->mBitCount   = 8;\r
-\r
-    }\r
-  }\r
-\r
-  Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
-  Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
-}\r
-\r
-UINT32\r
-GetBits (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfBits\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
-  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
-  popped out.\r
-\r
-Arguments:\r
-\r
-  Sd            - The global scratch data.\r
-  NumOfBits     - The number of bits to pop and read.\r
-\r
-Returns:\r
-\r
-  The bits that are popped out.\r
-\r
---*/\r
-{\r
-  UINT32  OutBits;\r
-\r
-  OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
-\r
-  FillBuf (Sd, NumOfBits);\r
-\r
-  return OutBits;\r
-}\r
-\r
-UINT16\r
-MakeTable (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfChar,\r
-  IN  UINT8         *BitLen,\r
-  IN  UINT16        TableBits,\r
-  OUT UINT16        *Table\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Creates Huffman Code mapping table according to code length array.\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  NumOfChar - Number of symbols in the symbol set\r
-  BitLen    - Code length array\r
-  TableBits - The width of the mapping table\r
-  Table     - The table\r
-  \r
-Returns:\r
-  \r
-  0         - OK.\r
-  BAD_TABLE - The table is corrupted.\r
-\r
---*/\r
-{\r
-  UINT16  Count[17];\r
-  UINT16  Weight[17];\r
-  UINT16  Start[18];\r
-  UINT16  *Pointer;\r
-  UINT16  Index3;\r
-  volatile UINT16  Index;\r
-  UINT16  Len;\r
-  UINT16  Char;\r
-  UINT16  JuBits;\r
-  UINT16  Avail;\r
-  UINT16  NextCode;\r
-  UINT16  Mask;\r
-  UINT16  WordOfStart;\r
-  UINT16  WordOfCount;\r
-\r
-  for (Index = 1; Index <= 16; Index++) {\r
-    Count[Index] = 0;\r
-  }  \r
-\r
-  for (Index = 0; Index < NumOfChar; Index++) {\r
-    Count[BitLen[Index]]++;\r
-  }\r
-\r
-  Start[1] = 0;\r
-\r
-  for (Index = 1; Index <= 16; Index++) {\r
-    WordOfStart = Start[Index];\r
-    WordOfCount = Count[Index];\r
-    Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index)));\r
-  }\r
-\r
-  if (Start[17] != 0) {\r
-    /*(1U << 16)*/\r
-    return (UINT16) BAD_TABLE;\r
-  }\r
-\r
-  JuBits = (UINT16) (16 - TableBits);\r
-\r
-  for (Index = 1; Index <= TableBits; Index++) {\r
-    Start[Index] >>= JuBits;\r
-    Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
-  }\r
-\r
-  while (Index <= 16) {\r
-    Weight[Index] = (UINT16) (1U << (16 - Index));\r
-    Index++;\r
-  }\r
-\r
-  Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
-\r
-  if (Index != 0) {\r
-    Index3 = (UINT16) (1U << TableBits);\r
-    while (Index != Index3) {\r
-      Table[Index++] = 0;\r
-    }\r
-  }\r
-\r
-  Avail = NumOfChar;\r
-  Mask  = (UINT16) (1U << (15 - TableBits));\r
-\r
-  for (Char = 0; Char < NumOfChar; Char++) {\r
-\r
-    Len = BitLen[Char];\r
-    if (Len == 0) {\r
-      continue;\r
-    }\r
-\r
-    NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
-\r
-    if (Len <= TableBits) {\r
-\r
-      for (Index = Start[Len]; Index < NextCode; Index++) {\r
-        Table[Index] = Char;\r
-      }\r
-\r
-    } else {\r
-\r
-      Index3  = Start[Len];\r
-      Pointer = &Table[Index3 >> JuBits];\r
-      Index   = (UINT16) (Len - TableBits);\r
-\r
-      while (Index != 0) {\r
-        if (*Pointer == 0) {\r
-          Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
-          *Pointer = Avail++;\r
-        }\r
-\r
-        if (Index3 & Mask) {\r
-          Pointer = &Sd->mRight[*Pointer];\r
-        } else {\r
-          Pointer = &Sd->mLeft[*Pointer];\r
-        }\r
-\r
-        Index3 <<= 1;\r
-        Index--;\r
-      }\r
-\r
-      *Pointer = Char;\r
-\r
-    }\r
-\r
-    Start[Len] = NextCode;\r
-  }\r
-  //\r
-  // Succeeds\r
-  //\r
-  return 0;\r
-}\r
-\r
-UINT32\r
-DecodeP (\r
-  IN  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decodes a position value.\r
-\r
-Arguments:\r
-\r
-  Sd      - the global scratch data\r
-\r
-Returns:\r
-\r
-  The position value decoded.\r
-\r
---*/\r
-{\r
-  UINT16  Val;\r
-  UINT32  Mask;\r
-  UINT32  Pos;\r
-\r
-  Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
-\r
-  if (Val >= MAXNP) {\r
-    Mask = 1U << (BITBUFSIZ - 1 - 8);\r
-\r
-    do {\r
-\r
-      if (Sd->mBitBuf & Mask) {\r
-        Val = Sd->mRight[Val];\r
-      } else {\r
-        Val = Sd->mLeft[Val];\r
-      }\r
-\r
-      Mask >>= 1;\r
-    } while (Val >= MAXNP);\r
-  }\r
-  //\r
-  // Advance what we have read\r
-  //\r
-  FillBuf (Sd, Sd->mPTLen[Val]);\r
-\r
-  Pos = Val;\r
-  if (Val > 1) {\r
-    Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
-  }\r
-\r
-  return Pos;\r
-}\r
-\r
-UINT16\r
-ReadPTLen (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        nn,\r
-  IN  UINT16        nbit,\r
-  IN  UINT16        Special\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads code lengths for the Extra Set or the Position Set\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  nn        - Number of symbols\r
-  nbit      - Number of bits needed to represent nn\r
-  Special   - The special symbol that needs to be taken care of \r
-\r
-Returns:\r
-\r
-  0         - OK.\r
-  BAD_TABLE - Table is corrupted.\r
-\r
---*/\r
-{\r
-  UINT16  Number;\r
-  UINT16  CharC;\r
-  volatile UINT16  Index;\r
-  UINT32  Mask;\r
-\r
-  Number = (UINT16) GetBits (Sd, nbit);\r
-\r
-  if (Number == 0) {\r
-    CharC = (UINT16) GetBits (Sd, nbit);\r
-\r
-    for (Index = 0; Index < 256; Index++) {\r
-      Sd->mPTTable[Index] = CharC;\r
-    }\r
-\r
-    for (Index = 0; Index < nn; Index++) {\r
-      Sd->mPTLen[Index] = 0;\r
-    }\r
-\r
-    return 0;\r
-  }\r
-\r
-  Index = 0;\r
-\r
-  while (Index < Number) {\r
-\r
-    CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
-\r
-    if (CharC == 7) {\r
-      Mask = 1U << (BITBUFSIZ - 1 - 3);\r
-      while (Mask & Sd->mBitBuf) {\r
-        Mask >>= 1;\r
-        CharC += 1;\r
-      }\r
-    }\r
-\r
-    FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
-\r
-    Sd->mPTLen[Index++] = (UINT8) CharC;\r
-\r
-    if (Index == Special) {\r
-      CharC = (UINT16) GetBits (Sd, 2);\r
-      while ((INT16) (--CharC) >= 0) {\r
-        Sd->mPTLen[Index++] = 0;\r
-      }\r
-    }\r
-  }\r
-\r
-  while (Index < nn) {\r
-    Sd->mPTLen[Index++] = 0;\r
-  }\r
-\r
-  return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
-}\r
-\r
-VOID\r
-ReadCLen (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads code lengths for Char&Len Set.\r
-\r
-Arguments:\r
-\r
-  Sd    - the global scratch data\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
-{\r
-  UINT16  Number;\r
-  UINT16  CharC;\r
-  volatile UINT16  Index;\r
-  UINT32  Mask;\r
-\r
-  Number = (UINT16) GetBits (Sd, CBIT);\r
-\r
-  if (Number == 0) {\r
-    CharC = (UINT16) GetBits (Sd, CBIT);\r
-\r
-    for (Index = 0; Index < NC; Index++) {\r
-      Sd->mCLen[Index] = 0;\r
-    }\r
-\r
-    for (Index = 0; Index < 4096; Index++) {\r
-      Sd->mCTable[Index] = CharC;\r
-    }\r
-\r
-    return ;\r
-  }\r
-\r
-  Index = 0;\r
-  while (Index < Number) {\r
-\r
-    CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
-    if (CharC >= NT) {\r
-      Mask = 1U << (BITBUFSIZ - 1 - 8);\r
-\r
-      do {\r
-\r
-        if (Mask & Sd->mBitBuf) {\r
-          CharC = Sd->mRight[CharC];\r
-        } else {\r
-          CharC = Sd->mLeft[CharC];\r
-        }\r
-\r
-        Mask >>= 1;\r
-\r
-      } while (CharC >= NT);\r
-    }\r
-    //\r
-    // Advance what we have read\r
-    //\r
-    FillBuf (Sd, Sd->mPTLen[CharC]);\r
-\r
-    if (CharC <= 2) {\r
-\r
-      if (CharC == 0) {\r
-        CharC = 1;\r
-      } else if (CharC == 1) {\r
-        CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
-      } else if (CharC == 2) {\r
-        CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
-      }\r
-\r
-      while ((INT16) (--CharC) >= 0) {\r
-        Sd->mCLen[Index++] = 0;\r
-      }\r
-\r
-    } else {\r
-\r
-      Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
-\r
-    }\r
-  }\r
-\r
-  while (Index < NC) {\r
-    Sd->mCLen[Index++] = 0;\r
-  }\r
-\r
-  MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
-\r
-  return ;\r
-}\r
-\r
-UINT16\r
-DecodeC (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decode a character/length value.\r
-\r
-Arguments:\r
-\r
-  Sd    - The global scratch data.\r
-\r
-Returns:\r
-\r
-  The value decoded.\r
-\r
---*/\r
-{\r
-  UINT16  Index2;\r
-  UINT32  Mask;\r
-\r
-  if (Sd->mBlockSize == 0) {\r
-    //\r
-    // Starting a new block\r
-    //\r
-    Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
-    Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
-    if (Sd->mBadTableFlag != 0) {\r
-      return 0;\r
-    }\r
-\r
-    ReadCLen (Sd);\r
-\r
-    Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));\r
-    if (Sd->mBadTableFlag != 0) {\r
-      return 0;\r
-    }\r
-  }\r
-\r
-  Sd->mBlockSize--;\r
-  Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
-\r
-  if (Index2 >= NC) {\r
-    Mask = 1U << (BITBUFSIZ - 1 - 12);\r
-\r
-    do {\r
-      if (Sd->mBitBuf & Mask) {\r
-        Index2 = Sd->mRight[Index2];\r
-      } else {\r
-        Index2 = Sd->mLeft[Index2];\r
-      }\r
-\r
-      Mask >>= 1;\r
-    } while (Index2 >= NC);\r
-  }\r
-  //\r
-  // Advance what we have read\r
-  //\r
-  FillBuf (Sd, Sd->mCLen[Index2]);\r
-\r
-  return Index2;\r
-}\r
-\r
-VOID\r
-Decode (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decode the source data and put the resulting data into the destination buffer.\r
-\r
-Arguments:\r
-\r
-  Sd            - The global scratch data\r
-\r
-Returns: (VOID)\r
-\r
- --*/\r
-{\r
-  UINT16  BytesRemain;\r
-  UINT32  DataIdx;\r
-  UINT16  CharC;\r
-\r
-  BytesRemain = (UINT16) (-1);\r
-\r
-  DataIdx     = 0;\r
-\r
-  for (;;) {\r
-    CharC = DecodeC (Sd);\r
-    if (Sd->mBadTableFlag != 0) {\r
-      goto Done ;\r
-    }\r
-\r
-    if (CharC < 256) {\r
-      //\r
-      // Process an Original character\r
-      //\r
-      if (Sd->mOutBuf >= Sd->mOrigSize) {\r
-        goto Done ;\r
-      } else {\r
-        Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
-      }\r
-\r
-    } else {\r
-      //\r
-      // Process a Pointer\r
-      //\r
-      CharC       = (UINT16) (CharC - (BIT8 - THRESHOLD));\r
-\r
-      BytesRemain = CharC;\r
-\r
-      DataIdx     = Sd->mOutBuf - DecodeP (Sd) - 1;\r
-\r
-      BytesRemain--;\r
-      while ((INT16) (BytesRemain) >= 0) {\r
-        Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
-        if (Sd->mOutBuf >= Sd->mOrigSize) {\r
-          goto Done ;\r
-        }\r
-\r
-        BytesRemain--;\r
-      }\r
-    }\r
-  }\r
-\r
-Done:\r
-  return ;\r
-}\r
-\r
-EFI_STATUS\r
-GetInfo (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  OUT     UINT32  *DstSize,\r
-  OUT     UINT32  *ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successfully retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  UINT8 *Src;\r
-\r
-  *ScratchSize  = sizeof (SCRATCH_DATA);\r
-\r
-  Src           = Source;\r
-  if (SrcSize < 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-Decompress (\r
-  IN      VOID    *Source,\r
-  IN      UINT32  SrcSize,\r
-  IN OUT  VOID    *Destination,\r
-  IN      UINT32  DstSize,\r
-  IN OUT  VOID    *Scratch,\r
-  IN      UINT32  ScratchSize,\r
-  IN      UINT8   Version\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-  Version     - The version of de/compression algorithm.\r
-                Version 1 for EFI 1.1 de/compression algorithm.\r
-                Version 2 for Tiano de/compression algorithm.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  UINT32        CompSize;\r
-  UINT32        OrigSize;\r
-  EFI_STATUS    Status;\r
-  SCRATCH_DATA  *Sd;\r
-  UINT8         *Src;\r
-  UINT8         *Dst;\r
-  volatile UINT32  Index;\r
-  \r
-  Status  = EFI_SUCCESS;\r
-  Src     = Source;\r
-  Dst     = Destination;\r
-\r
-  if (ScratchSize < sizeof (SCRATCH_DATA)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Sd = (SCRATCH_DATA *) Scratch;\r
-\r
-  if (SrcSize < 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  CompSize  = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
-  OrigSize  = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
-\r
-  //\r
-  // If compressed file size is 0, return\r
-  //\r
-  if (OrigSize == 0) {\r
-    return Status;\r
-  }\r
-\r
-  if (SrcSize < CompSize + 8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (DstSize != OrigSize) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Src = Src + 8;\r
-\r
-  for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
-    ((UINT8 *) Sd)[Index] = 0;\r
-  }\r
-  \r
-  //\r
-  // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
-  // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4\r
-  // For Tiano de/compression algorithm(Version 2), mPBit = 5\r
-  //\r
-  switch (Version) {\r
-  case 1:\r
-    Sd->mPBit = 4;\r
-    break;\r
-\r
-  case 2:\r
-    Sd->mPBit = 5;\r
-    break;\r
-\r
-  default:\r
-    //\r
-    // Currently, only have 2 versions\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Sd->mSrcBase  = Src;\r
-  Sd->mDstBase  = Dst;\r
-  Sd->mCompSize = CompSize;\r
-  Sd->mOrigSize = OrigSize;\r
-\r
-  //\r
-  // Fill the first BITBUFSIZ bits\r
-  //\r
-  FillBuf (Sd, BITBUFSIZ);\r
-\r
-  //\r
-  // Decompress it\r
-  //\r
-  Decode (Sd);\r
-\r
-  if (Sd->mBadTableFlag != 0) {\r
-    //\r
-    // Something wrong with the source\r
-    //\r
-    Status = EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EfiGetInfo (\r
-  IN      VOID                    *Source,\r
-  IN      UINT32                  SrcSize,\r
-  OUT     UINT32                  *DstSize,\r
-  OUT     UINT32                  *ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation is same as that  of EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successfully retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  return GetInfo (\r
-          Source,\r
-          SrcSize,\r
-          DstSize,\r
-          ScratchSize\r
-          );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EfiDecompress (\r
-  IN      VOID                    *Source,\r
-  IN      UINT32                  SrcSize,\r
-  IN OUT  VOID                    *Destination,\r
-  IN      UINT32                  DstSize,\r
-  IN OUT  VOID                    *Scratch,\r
-  IN      UINT32                  ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  //\r
-  // For EFI 1.1 de/compression algorithm, the version is 1.\r
-  //\r
-  return Decompress (\r
-          Source,\r
-          SrcSize,\r
-          Destination,\r
-          DstSize,\r
-          Scratch,\r
-          ScratchSize,\r
-          1\r
-          );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-TianoGetInfo (\r
-  IN      VOID                          *Source,\r
-  IN      UINT32                        SrcSize,\r
-  OUT     UINT32                        *DstSize,\r
-  OUT     UINT32                        *ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successfully retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  return GetInfo (\r
-          Source,\r
-          SrcSize,\r
-          DstSize,\r
-          ScratchSize\r
-          );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-TianoDecompress (\r
-  IN      VOID                          *Source,\r
-  IN      UINT32                        SrcSize,\r
-  IN OUT  VOID                          *Destination,\r
-  IN      UINT32                        DstSize,\r
-  IN OUT  VOID                          *Scratch,\r
-  IN      UINT32                        ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation is same as that  of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-{\r
-  //\r
-  // For Tiano de/compression algorithm, the version is 2.\r
-  //\r
-  return Decompress (\r
-          Source,\r
-          SrcSize,\r
-          Destination,\r
-          DstSize,\r
-          Scratch,\r
-          ScratchSize,\r
-          2\r
-          );\r
-}\r
-\r
diff --git a/DuetPkg/EfiLdr/TianoDecompress.h b/DuetPkg/EfiLdr/TianoDecompress.h
deleted file mode 100644 (file)
index e9cb016..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/** @file\r
-  Internal include file for Base UEFI Decompress Library.\r
-\r
-  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-  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:  BaseUefiCustomDecompressLibInternals.h\r
-\r
-**/\r
-\r
-#ifndef __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__\r
-#define __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__\r
-\r
-#include <PiPei.h>\r
-\r
-#include <Library/UefiDecompressLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-TianoGetInfo (\r
-  IN      VOID                          *Source,\r
-  IN      UINT32                        SrcSize,\r
-  OUT     UINT32                        *DstSize,\r
-  OUT     UINT32                        *ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  DstSize     - The size of destination buffer.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The size of destination buffer and the size of scratch buffer are successfully retrieved.\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-TianoDecompress (\r
-  IN      VOID                          *Source,\r
-  IN      UINT32                        SrcSize,\r
-  IN OUT  VOID                          *Destination,\r
-  IN      UINT32                        DstSize,\r
-  IN OUT  VOID                          *Scratch,\r
-  IN      UINT32                        ScratchSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation is same as that  of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  This        - The protocol instance pointer\r
-  Source      - The source buffer containing the compressed data.\r
-  SrcSize     - The size of source buffer\r
-  Destination - The destination buffer to store the decompressed data\r
-  DstSize     - The size of destination buffer.\r
-  Scratch     - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  ScratchSize - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Decompression is successfull\r
-  EFI_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/DuetPkg/EfiLdr/efildr.c b/DuetPkg/EfiLdr/efildr.c
deleted file mode 100644 (file)
index 2b40aca..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  EfiLdr.c\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
---*/\r
-\r
-//\r
-// BUGBUG, include all C files\r
-//\r
-#include "EfiLoader.c"\r
-#include "PeLoader.c"\r
-#include "Support.c"\r
-#include "Debug.c"\r
-\r
diff --git a/DuetPkg/FSVariable/FSVariable.c b/DuetPkg/FSVariable/FSVariable.c
deleted file mode 100644 (file)
index 5feeade..0000000
+++ /dev/null
@@ -1,1992 +0,0 @@
-/*++\r
-\r
-Caution: This file is used for Duet platform only, do not use them in real platform.\r
-All variable code, variable metadata, and variable data used by Duet platform are on \r
-disk. They can be changed by user. BIOS is not able to protoect those.\r
-Duet trusts all meta data from disk. If variable code, variable metadata and variable\r
-data is modified in inproper way, the behavior is undefined.\r
-\r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
-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
-  FSVariable.c\r
-\r
-Abstract:\r
-\r
-  Provide support functions for variable services.\r
-\r
---*/\r
-\r
-#include "FSVariable.h"\r
-\r
-VARIABLE_STORE_HEADER mStoreHeaderTemplate = {\r
-  VARIABLE_STORE_SIGNATURE,\r
-  VOLATILE_VARIABLE_STORE_SIZE,\r
-  VARIABLE_STORE_FORMATTED,\r
-  VARIABLE_STORE_HEALTHY,\r
-  0,\r
-  0\r
-};\r
-\r
-//\r
-// Don't use module globals after the SetVirtualAddress map is signaled\r
-//\r
-VARIABLE_GLOBAL  *mGlobal;\r
-\r
-/**\r
-  Update the variable region with Variable information. These are the same \r
-  arguments as the EFI Variable services.\r
-\r
-  @param[in] VariableName       Name of variable\r
-\r
-  @param[in] VendorGuid         Guid of variable\r
-\r
-  @param[in] Data               Variable data\r
-\r
-  @param[in] DataSize           Size of data. 0 means delete\r
-\r
-  @param[in] Attributes         Attribues of the variable\r
-\r
-  @param[in] Variable           The variable information which is used to keep track of variable usage.\r
-\r
-  @retval EFI_SUCCESS           The update operation is success.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  Variable region is full, can not write other data into this region.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UpdateVariable (\r
-  IN      CHAR16                 *VariableName,\r
-  IN      EFI_GUID               *VendorGuid,\r
-  IN      VOID                   *Data,\r
-  IN      UINTN                  DataSize,\r
-  IN      UINT32                 Attributes OPTIONAL,\r
-  IN      VARIABLE_POINTER_TRACK *Variable\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-OnVirtualAddressChangeFsv (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-OnSimpleFileSystemInstall (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  );\r
-\r
-BOOLEAN\r
-IsValidVariableHeader (\r
-  IN  VARIABLE_HEADER   *Variable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code checks if variable header is valid or not.\r
-\r
-Arguments:\r
-  Variable        Pointer to the Variable Header.\r
-\r
-Returns:\r
-  TRUE            Variable header is valid.\r
-  FALSE           Variable header is not valid.\r
-\r
---*/\r
-{\r
-  if (Variable == NULL || Variable->StartId != VARIABLE_DATA) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-VARIABLE_STORE_STATUS\r
-GetVariableStoreStatus (\r
-  IN VARIABLE_STORE_HEADER *VarStoreHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code gets the current status of Variable Store.\r
-\r
-Arguments:\r
-\r
-  VarStoreHeader  Pointer to the Variable Store Header.\r
-\r
-Returns:\r
-\r
-  EfiRaw        Variable store status is raw\r
-  EfiValid      Variable store status is valid\r
-  EfiInvalid    Variable store status is invalid\r
-\r
---*/\r
-{\r
-  if (CompareGuid (&VarStoreHeader->Signature, &mStoreHeaderTemplate.Signature) &&\r
-      (VarStoreHeader->Format == mStoreHeaderTemplate.Format) &&\r
-      (VarStoreHeader->State == mStoreHeaderTemplate.State)\r
-     ) {\r
-    return EfiValid;\r
-  } else if (((UINT32 *)(&VarStoreHeader->Signature))[0] == VAR_DEFAULT_VALUE_32 &&\r
-             ((UINT32 *)(&VarStoreHeader->Signature))[1] == VAR_DEFAULT_VALUE_32 &&\r
-             ((UINT32 *)(&VarStoreHeader->Signature))[2] == VAR_DEFAULT_VALUE_32 &&\r
-             ((UINT32 *)(&VarStoreHeader->Signature))[3] == VAR_DEFAULT_VALUE_32 &&\r
-             VarStoreHeader->Size == VAR_DEFAULT_VALUE_32 &&\r
-             VarStoreHeader->Format == VAR_DEFAULT_VALUE &&\r
-             VarStoreHeader->State == VAR_DEFAULT_VALUE\r
-          ) {\r
-\r
-    return EfiRaw;\r
-  } else {\r
-    return EfiInvalid;\r
-  }\r
-}\r
-\r
-UINT8 *\r
-GetVariableDataPtr (\r
-  IN  VARIABLE_HEADER   *Variable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code gets the pointer to the variable data.\r
-\r
-Arguments:\r
-\r
-  Variable            Pointer to the Variable Header.\r
-\r
-Returns:\r
-\r
-  UINT8*              Pointer to Variable Data\r
-\r
---*/\r
-{\r
-  //\r
-  // Be careful about pad size for alignment\r
-  //\r
-  return (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (Variable) + Variable->NameSize + GET_PAD_SIZE (Variable->NameSize));\r
-}\r
-\r
-VARIABLE_HEADER *\r
-GetNextVariablePtr (\r
-  IN  VARIABLE_HEADER   *Variable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code gets the pointer to the next variable header.\r
-\r
-Arguments:\r
-\r
-  Variable              Pointer to the Variable Header.\r
-\r
-Returns:\r
-\r
-  VARIABLE_HEADER*      Pointer to next variable header.\r
-\r
---*/\r
-{\r
-  if (!IsValidVariableHeader (Variable)) {\r
-    return NULL;\r
-  }\r
-  //\r
-  // Be careful about pad size for alignment\r
-  //\r
-  return (VARIABLE_HEADER *) ((UINTN) GetVariableDataPtr (Variable) + Variable->DataSize + GET_PAD_SIZE (Variable->DataSize));\r
-}\r
-\r
-VARIABLE_HEADER *\r
-GetEndPointer (\r
-  IN VARIABLE_STORE_HEADER       *VarStoreHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code gets the pointer to the last variable memory pointer byte\r
-\r
-Arguments:\r
-\r
-  VarStoreHeader        Pointer to the Variable Store Header.\r
-\r
-Returns:\r
-\r
-  VARIABLE_HEADER*      Pointer to last unavailable Variable Header\r
-\r
---*/\r
-{\r
-  //\r
-  // The end of variable store\r
-  //\r
-  return (VARIABLE_HEADER *) ((UINTN) VarStoreHeader + VarStoreHeader->Size);\r
-}\r
-\r
-BOOLEAN\r
-ExistNewerVariable (\r
-  IN  VARIABLE_HEADER         *Variable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check if exist newer variable when doing reclaim\r
-\r
-Arguments:\r
-\r
-  Variable                    Pointer to start position\r
-\r
-Returns:\r
-\r
-  TRUE - Exists another variable, which is newer than the current one\r
-  FALSE  - Doesn't exist another vairable which is newer than the current one\r
-\r
---*/\r
-{\r
-  VARIABLE_HEADER       *NextVariable;\r
-  CHAR16                *VariableName;\r
-  EFI_GUID              *VendorGuid;\r
-  \r
-  VendorGuid   = &Variable->VendorGuid;\r
-  VariableName = GET_VARIABLE_NAME_PTR(Variable);\r
-  \r
-  NextVariable = GetNextVariablePtr (Variable);\r
-  while (IsValidVariableHeader (NextVariable)) {\r
-    if ((NextVariable->State == VAR_ADDED) || (NextVariable->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION))) {\r
-      //\r
-      // If match Guid and Name\r
-      //\r
-      if (CompareGuid (VendorGuid, &NextVariable->VendorGuid)) {\r
-         if (CompareMem (VariableName, GET_VARIABLE_NAME_PTR (NextVariable), StrSize (VariableName)) == 0) {\r
-           return TRUE;\r
-         }\r
-       }\r
-    }\r
-    NextVariable = GetNextVariablePtr (NextVariable);\r
-  }\r
-  return FALSE;\r
-}\r
-\r
-EFI_STATUS\r
-Reclaim (\r
-  IN  VARIABLE_STORAGE_TYPE StorageType,\r
-  IN  VARIABLE_HEADER       *CurrentVariable OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Variable store garbage collection and reclaim operation\r
-\r
-Arguments:\r
-\r
-  IsVolatile                  The variable store is volatile or not,\r
-                              if it is non-volatile, need FTW\r
-  CurrentVairable             If it is not NULL, it means not to process\r
-                              current variable for Reclaim.\r
-\r
-Returns:\r
-\r
-  EFI STATUS\r
-\r
---*/\r
-{\r
-  VARIABLE_HEADER       *Variable;\r
-  VARIABLE_HEADER       *NextVariable;\r
-  VARIABLE_STORE_HEADER *VariableStoreHeader;\r
-  UINT8                 *ValidBuffer;\r
-  UINTN                 ValidBufferSize;\r
-  UINTN                 VariableSize;\r
-  UINT8                 *CurrPtr;\r
-  EFI_STATUS            Status;\r
-\r
-  VariableStoreHeader = (VARIABLE_STORE_HEADER *) mGlobal->VariableBase[StorageType];\r
-\r
-  //\r
-  // Start Pointers for the variable.\r
-  //\r
-  Variable        = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
-\r
-  //\r
-  // recaluate the total size of Common/HwErr type variables in non-volatile area.\r
-  //\r
-  if (!StorageType) {\r
-    mGlobal->CommonVariableTotalSize = 0;\r
-    mGlobal->HwErrVariableTotalSize  = 0;\r
-  }\r
-  //\r
-  // To make the reclaim, here we just allocate a memory that equal to the original memory\r
-  //\r
-  ValidBufferSize = sizeof (VARIABLE_STORE_HEADER) + VariableStoreHeader->Size;\r
-\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  ValidBufferSize,\r
-                  (VOID**) &ValidBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  CurrPtr = ValidBuffer;\r
-\r
-  //\r
-  // Copy variable store header\r
-  //\r
-  CopyMem (CurrPtr, VariableStoreHeader, sizeof (VARIABLE_STORE_HEADER));\r
-  CurrPtr += sizeof (VARIABLE_STORE_HEADER);\r
-\r
-  //\r
-  // Start Pointers for the variable.\r
-  //\r
-  Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
-\r
-  \r
-  ValidBufferSize = sizeof (VARIABLE_STORE_HEADER);\r
-  while (IsValidVariableHeader (Variable)) {\r
-    NextVariable = GetNextVariablePtr (Variable);\r
-    //\r
-    // State VAR_ADDED or VAR_IN_DELETED_TRANSITION are to kept,\r
-    // The CurrentVariable, is also saved, as SetVariable may fail due to lack of space\r
-    //\r
-    if (Variable->State == VAR_ADDED) {\r
-      VariableSize = (UINTN) NextVariable - (UINTN) Variable;\r
-      CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);\r
-      ValidBufferSize += VariableSize;\r
-      CurrPtr += VariableSize;\r
-      if ((!StorageType) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-        mGlobal->HwErrVariableTotalSize += VariableSize;\r
-      } else if ((!StorageType) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-        mGlobal->CommonVariableTotalSize += VariableSize;\r
-      }\r
-    } else if (Variable->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION)) {\r
-      //\r
-      // As variables that with the same guid and name may exist in NV due to power failure during SetVariable,\r
-      // we will only save the latest valid one\r
-      //\r
-      if (!ExistNewerVariable(Variable)) {\r
-        VariableSize = (UINTN) NextVariable - (UINTN) Variable;\r
-        CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);\r
-        //\r
-        // If CurrentVariable == Variable, mark as VAR_IN_DELETED_TRANSITION\r
-        //\r
-        if (Variable != CurrentVariable){\r
-          ((VARIABLE_HEADER *)CurrPtr)->State = VAR_ADDED;\r
-        }\r
-        CurrPtr += VariableSize;\r
-        ValidBufferSize += VariableSize;\r
-        if ((!StorageType) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-          mGlobal->HwErrVariableTotalSize += VariableSize;\r
-        } else if ((!StorageType) && ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-          mGlobal->CommonVariableTotalSize += VariableSize;\r
-        }\r
-      }\r
-    }\r
-    Variable = NextVariable;\r
-  }\r
-\r
-  mGlobal->LastVariableOffset[StorageType] = ValidBufferSize;\r
-\r
-  //\r
-  // TODO: cannot restore to original state, basic FTW needed\r
-  //\r
-  Status = mGlobal->VariableStore[StorageType]->Erase (\r
-                                                  mGlobal->VariableStore[StorageType]\r
-                                                  );\r
-  Status = mGlobal->VariableStore[StorageType]->Write (\r
-                                                    mGlobal->VariableStore[StorageType],\r
-                                                    0,\r
-                                                    ValidBufferSize,\r
-                                                    ValidBuffer\r
-                                                    );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If error, then reset the last variable offset to zero.\r
-    //\r
-    mGlobal->LastVariableOffset[StorageType] = 0;\r
-  };\r
-\r
-  gBS->FreePool (ValidBuffer);\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-FindVariable (\r
-  IN  CHAR16                  *VariableName,\r
-  IN  EFI_GUID                *VendorGuid,\r
-  OUT VARIABLE_POINTER_TRACK  *PtrTrack\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code finds variable in storage blocks (Volatile or Non-Volatile)\r
-\r
-Arguments:\r
-\r
-  VariableName                Name of the variable to be found\r
-  VendorGuid                  Vendor GUID to be found.\r
-  PtrTrack                    Variable Track Pointer structure that contains\r
-                              Variable Information.\r
-                              Contains the pointer of Variable header.\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER       - Invalid parameter\r
-  EFI_SUCCESS                 - Find the specified variable\r
-  EFI_NOT_FOUND               - Not found\r
-\r
---*/\r
-{\r
-  VARIABLE_HEADER         *Variable;\r
-  VARIABLE_STORE_HEADER   *VariableStoreHeader;\r
-  UINTN                   Index;\r
-  VARIABLE_HEADER         *InDeleteVariable;\r
-  UINTN                   InDeleteIndex;\r
-  VARIABLE_HEADER         *InDeleteStartPtr;\r
-  VARIABLE_HEADER         *InDeleteEndPtr;\r
-\r
-  if (VariableName[0] != 0 && VendorGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  InDeleteVariable = NULL;\r
-  InDeleteIndex    = (UINTN)-1;\r
-  InDeleteStartPtr = NULL;\r
-  InDeleteEndPtr   = NULL;\r
-\r
-  for (Index = 0; Index < MaxType; Index ++) {\r
-    //\r
-    // 0: Non-Volatile, 1: Volatile\r
-    //\r
-    VariableStoreHeader = (VARIABLE_STORE_HEADER *) mGlobal->VariableBase[Index];\r
-\r
-    //\r
-    // Start Pointers for the variable.\r
-    // Actual Data Pointer where data can be written.\r
-    //\r
-    Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
-\r
-    //\r
-    // Find the variable by walk through non-volatile and volatile variable store\r
-    //\r
-    PtrTrack->StartPtr = Variable;\r
-    PtrTrack->EndPtr   = GetEndPointer (VariableStoreHeader);\r
-\r
-    while ((Variable < PtrTrack->EndPtr) && IsValidVariableHeader (Variable)) {\r
-      if (Variable->State == VAR_ADDED) {\r
-        if (!EfiAtRuntime () || (Variable->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
-          if (VariableName[0] == 0) {\r
-            PtrTrack->CurrPtr = Variable;\r
-            PtrTrack->Type    = (VARIABLE_STORAGE_TYPE) Index;\r
-            return EFI_SUCCESS;\r
-          } else {\r
-            if (CompareGuid (VendorGuid, &Variable->VendorGuid)) {\r
-              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), StrSize (VariableName))) {\r
-                PtrTrack->CurrPtr = Variable;\r
-                PtrTrack->Type    = (VARIABLE_STORAGE_TYPE) Index;\r
-                return EFI_SUCCESS;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      } else if (Variable->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION)) {\r
-        //\r
-        // VAR_IN_DELETED_TRANSITION should also be checked.\r
-        //\r
-        if (!EfiAtRuntime () || (Variable->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
-          if (VariableName[0] == 0) {\r
-            InDeleteVariable = Variable;\r
-            InDeleteIndex    = Index;\r
-            InDeleteStartPtr = PtrTrack->StartPtr;\r
-            InDeleteEndPtr   = PtrTrack->EndPtr;\r
-          } else {\r
-            if (CompareGuid (VendorGuid, &Variable->VendorGuid)) {\r
-              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), StrSize (VariableName))) {\r
-                InDeleteVariable = Variable;\r
-                InDeleteIndex    = Index;\r
-                InDeleteStartPtr = PtrTrack->StartPtr;\r
-                InDeleteEndPtr   = PtrTrack->EndPtr;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-\r
-      Variable = GetNextVariablePtr (Variable);\r
-    }\r
-    //\r
-    // While (...)\r
-    //\r
-  }\r
-  //\r
-  // for (...)\r
-  //\r
-\r
-  //\r
-  // if VAR_IN_DELETED_TRANSITION found, and VAR_ADDED not found,\r
-  // we return it.\r
-  //\r
-  if (InDeleteVariable != NULL) {\r
-    PtrTrack->CurrPtr  = InDeleteVariable;\r
-    PtrTrack->Type     = (VARIABLE_STORAGE_TYPE) InDeleteIndex;\r
-    PtrTrack->StartPtr = InDeleteStartPtr;\r
-    PtrTrack->EndPtr   = InDeleteEndPtr;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  PtrTrack->CurrPtr = NULL;\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Get index from supported language codes according to language string.\r
-\r
-  This code is used to get corresponding index in supported language codes. It can handle\r
-  RFC4646 and ISO639 language tags.\r
-  In ISO639 language tags, take 3-characters as a delimitation to find matched string and calculate the index.\r
-  In RFC4646 language tags, take semicolon as a delimitation to find matched string and calculate the index.\r
-\r
-  For example:\r
-    SupportedLang  = "engfraengfra"\r
-    Lang           = "eng"\r
-    Iso639Language = TRUE\r
-  The return value is "0".\r
-  Another example:\r
-    SupportedLang  = "en;fr;en-US;fr-FR"\r
-    Lang           = "fr-FR"\r
-    Iso639Language = FALSE\r
-  The return value is "3".\r
-\r
-  @param  SupportedLang               Platform supported language codes.\r
-  @param  Lang                        Configured language.\r
-  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
-\r
-  @retval the index of language in the language codes.\r
-\r
-**/\r
-UINTN\r
-GetIndexFromSupportedLangCodes(\r
-  IN  CHAR8            *SupportedLang,\r
-  IN  CHAR8            *Lang,\r
-  IN  BOOLEAN          Iso639Language\r
-  ) \r
-{\r
-  UINTN    Index;\r
-  UINTN    CompareLength;\r
-  UINTN    LanguageLength;\r
-\r
-  if (Iso639Language) {\r
-    CompareLength = ISO_639_2_ENTRY_SIZE;\r
-    for (Index = 0; Index < AsciiStrLen (SupportedLang); Index += CompareLength) {\r
-      if (AsciiStrnCmp (Lang, SupportedLang + Index, CompareLength) == 0) {\r
-        //\r
-        // Successfully find the index of Lang string in SupportedLang string.\r
-        //\r
-        Index = Index / CompareLength;\r
-        return Index;\r
-      }\r
-    }\r
-    ASSERT (FALSE);\r
-    return 0;\r
-  } else {\r
-    //\r
-    // Compare RFC4646 language code\r
-    //\r
-    Index = 0;\r
-    for (LanguageLength = 0; Lang[LanguageLength] != '\0'; LanguageLength++);\r
-\r
-    for (Index = 0; *SupportedLang != '\0'; Index++, SupportedLang += CompareLength) {\r
-      //\r
-      // Skip ';' characters in SupportedLang\r
-      //\r
-      for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);\r
-      //\r
-      // Determine the length of the next language code in SupportedLang\r
-      //\r
-      for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);\r
-      \r
-      if ((CompareLength == LanguageLength) && \r
-          (AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {\r
-        //\r
-        // Successfully find the index of Lang string in SupportedLang string.\r
-        //\r
-        return Index;\r
-      }\r
-    }\r
-    ASSERT (FALSE);\r
-    return 0;\r
-  }\r
-}\r
-\r
-/**\r
-  Get language string from supported language codes according to index.\r
-\r
-  This code is used to get corresponding language string in supported language codes. It can handle\r
-  RFC4646 and ISO639 language tags.\r
-  In ISO639 language tags, take 3-characters as a delimitation. Find language string according to the index.\r
-  In RFC4646 language tags, take semicolon as a delimitation. Find language string according to the index.\r
-\r
-  For example:\r
-    SupportedLang  = "engfraengfra"\r
-    Index          = "1"\r
-    Iso639Language = TRUE\r
-  The return value is "fra".\r
-  Another example:\r
-    SupportedLang  = "en;fr;en-US;fr-FR"\r
-    Index          = "1"\r
-    Iso639Language = FALSE\r
-  The return value is "fr".\r
-\r
-  @param  SupportedLang               Platform supported language codes.\r
-  @param  Index                       the index in supported language codes.\r
-  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
-\r
-  @retval the language string in the language codes.\r
-\r
-**/\r
-CHAR8 *\r
-GetLangFromSupportedLangCodes (\r
-  IN  CHAR8            *SupportedLang,\r
-  IN  UINTN            Index,\r
-  IN  BOOLEAN          Iso639Language\r
-)\r
-{\r
-  UINTN    SubIndex;\r
-  UINTN    CompareLength;\r
-  CHAR8    *Supported;\r
-\r
-  SubIndex  = 0;\r
-  Supported = SupportedLang;\r
-  if (Iso639Language) {\r
-    //\r
-    // according to the index of Lang string in SupportedLang string to get the language.\r
-    // As this code will be invoked in RUNTIME, therefore there is not memory allocate/free operation.\r
-    // In driver entry, it pre-allocates a runtime attribute memory to accommodate this string.\r
-    //\r
-    CompareLength = ISO_639_2_ENTRY_SIZE;\r
-    mGlobal->Lang[CompareLength] = '\0';\r
-    return CopyMem (mGlobal->Lang, SupportedLang + Index * CompareLength, CompareLength);\r
-\r
-  } else {\r
-    while (TRUE) {\r
-      //\r
-      // take semicolon as delimitation, sequentially traverse supported language codes.\r
-      //\r
-      for (CompareLength = 0; *Supported != ';' && *Supported != '\0'; CompareLength++) {\r
-        Supported++;\r
-      }\r
-      if ((*Supported == '\0') && (SubIndex != Index)) {\r
-        //\r
-        // Have completed the traverse, but not find corrsponding string.\r
-        // This case is not allowed to happen.\r
-        //\r
-        ASSERT(FALSE);\r
-        return NULL;\r
-      }\r
-      if (SubIndex == Index) {\r
-        //\r
-        // according to the index of Lang string in SupportedLang string to get the language.\r
-        // As this code will be invoked in RUNTIME, therefore there is not memory allocate/free operation.\r
-        // In driver entry, it pre-allocates a runtime attribute memory to accommodate this string.\r
-        //\r
-        mGlobal->PlatformLang[CompareLength] = '\0';\r
-        return CopyMem (mGlobal->PlatformLang, Supported - CompareLength, CompareLength);\r
-      }\r
-      SubIndex++;\r
-\r
-      //\r
-      // Skip ';' characters in Supported\r
-      //\r
-      for (; *Supported != '\0' && *Supported == ';'; Supported++);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Returns a pointer to an allocated buffer that contains the best matching language \r
-  from a set of supported languages.  \r
-  \r
-  This function supports both ISO 639-2 and RFC 4646 language codes, but language \r
-  code types may not be mixed in a single call to this function. This function\r
-  supports a variable argument list that allows the caller to pass in a prioritized\r
-  list of language codes to test against all the language codes in SupportedLanguages.\r
-\r
-  If SupportedLanguages is NULL, then ASSERT().\r
-\r
-  @param[in]  SupportedLanguages  A pointer to a Null-terminated ASCII string that\r
-                                  contains a set of language codes in the format \r
-                                  specified by Iso639Language.\r
-  @param[in]  Iso639Language      If TRUE, then all language codes are assumed to be\r
-                                  in ISO 639-2 format.  If FALSE, then all language\r
-                                  codes are assumed to be in RFC 4646 language format\r
-  @param[in]  ...                 A variable argument list that contains pointers to \r
-                                  Null-terminated ASCII strings that contain one or more\r
-                                  language codes in the format specified by Iso639Language.\r
-                                  The first language code from each of these language\r
-                                  code lists is used to determine if it is an exact or\r
-                                  close match to any of the language codes in \r
-                                  SupportedLanguages.  Close matches only apply to RFC 4646\r
-                                  language codes, and the matching algorithm from RFC 4647\r
-                                  is used to determine if a close match is present.  If \r
-                                  an exact or close match is found, then the matching\r
-                                  language code from SupportedLanguages is returned.  If\r
-                                  no matches are found, then the next variable argument\r
-                                  parameter is evaluated.  The variable argument list \r
-                                  is terminated by a NULL.\r
-\r
-  @retval NULL   The best matching language could not be found in SupportedLanguages.\r
-  @retval NULL   There are not enough resources available to return the best matching \r
-                 language.\r
-  @retval Other  A pointer to a Null-terminated ASCII string that is the best matching \r
-                 language in SupportedLanguages.\r
-\r
-**/\r
-CHAR8 *\r
-EFIAPI\r
-VariableGetBestLanguage (\r
-  IN CONST CHAR8  *SupportedLanguages, \r
-  IN BOOLEAN      Iso639Language,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST      Args;\r
-  CHAR8        *Language;\r
-  UINTN        CompareLength;\r
-  UINTN        LanguageLength;\r
-  CONST CHAR8  *Supported;\r
-  CHAR8        *Buffer;\r
-\r
-  ASSERT (SupportedLanguages != NULL);\r
-\r
-  VA_START (Args, Iso639Language);\r
-  while ((Language = VA_ARG (Args, CHAR8 *)) != NULL) {\r
-    //\r
-    // Default to ISO 639-2 mode\r
-    //\r
-    CompareLength  = 3;\r
-    LanguageLength = MIN (3, AsciiStrLen (Language));\r
-\r
-    //\r
-    // If in RFC 4646 mode, then determine the length of the first RFC 4646 language code in Language\r
-    //\r
-    if (!Iso639Language) {\r
-      for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++);\r
-    }\r
-\r
-    //\r
-    // Trim back the length of Language used until it is empty\r
-    //\r
-    while (LanguageLength > 0) {\r
-      //\r
-      // Loop through all language codes in SupportedLanguages\r
-      //\r
-      for (Supported = SupportedLanguages; *Supported != '\0'; Supported += CompareLength) {\r
-        //\r
-        // In RFC 4646 mode, then Loop through all language codes in SupportedLanguages\r
-        //\r
-        if (!Iso639Language) {\r
-          //\r
-          // Skip ';' characters in Supported\r
-          //\r
-          for (; *Supported != '\0' && *Supported == ';'; Supported++);\r
-          //\r
-          // Determine the length of the next language code in Supported\r
-          //\r
-          for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++);\r
-          //\r
-          // If Language is longer than the Supported, then skip to the next language\r
-          //\r
-          if (LanguageLength > CompareLength) {\r
-            continue;\r
-          }\r
-        }\r
-        //\r
-        // See if the first LanguageLength characters in Supported match Language\r
-        //\r
-        if (AsciiStrnCmp (Supported, Language, LanguageLength) == 0) {\r
-          VA_END (Args);\r
-\r
-          Buffer = Iso639Language ? mGlobal->Lang : mGlobal->PlatformLang;\r
-          Buffer[CompareLength] = '\0';\r
-          return CopyMem (Buffer, Supported, CompareLength);\r
-        }\r
-      }\r
-\r
-      if (Iso639Language) {\r
-        //\r
-        // If ISO 639 mode, then each language can only be tested once\r
-        //\r
-        LanguageLength = 0;\r
-      } else {\r
-        //\r
-        // If RFC 4646 mode, then trim Language from the right to the next '-' character \r
-        //\r
-        for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);\r
-      }\r
-    }\r
-  }\r
-  VA_END (Args);\r
-\r
-  //\r
-  // No matches were found \r
-  //\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Hook the operations in PlatformLangCodes, LangCodes, PlatformLang and Lang.\r
-\r
-  When setting Lang/LangCodes, simultaneously update PlatformLang/PlatformLangCodes.\r
-\r
-  According to UEFI spec, PlatformLangCodes/LangCodes are only set once in firmware initialization,\r
-  and are read-only. Therefore, in variable driver, only store the original value for other use.\r
-\r
-  @param[in] VariableName       Name of variable\r
-\r
-  @param[in] Data               Variable data\r
-\r
-  @param[in] DataSize           Size of data. 0 means delete\r
-\r
-**/\r
-VOID\r
-AutoUpdateLangVariable(\r
-  IN  CHAR16             *VariableName,\r
-  IN  VOID               *Data,\r
-  IN  UINTN              DataSize\r
-  )\r
-{\r
-  EFI_STATUS             Status;\r
-  CHAR8                  *BestPlatformLang;\r
-  CHAR8                  *BestLang;\r
-  UINTN                  Index;\r
-  UINT32                 Attributes;\r
-  VARIABLE_POINTER_TRACK Variable;\r
-  BOOLEAN                SetLanguageCodes;\r
-\r
-  //\r
-  // Don't do updates for delete operation\r
-  //\r
-  if (DataSize == 0) {\r
-    return;\r
-  }\r
-\r
-  SetLanguageCodes = FALSE;\r
-\r
-  if (StrCmp (VariableName, L"PlatformLangCodes") == 0) {\r
-    //\r
-    // PlatformLangCodes is a volatile variable, so it can not be updated at runtime.\r
-    //\r
-    if (EfiAtRuntime ()) {\r
-      return;\r
-    }\r
-\r
-    SetLanguageCodes = TRUE;\r
-\r
-    //\r
-    // According to UEFI spec, PlatformLangCodes is only set once in firmware initialization, and is read-only\r
-    // Therefore, in variable driver, only store the original value for other use.\r
-    //\r
-    if (mGlobal->PlatformLangCodes != NULL) {\r
-      FreePool (mGlobal->PlatformLangCodes);\r
-    }\r
-    mGlobal->PlatformLangCodes = AllocateRuntimeCopyPool (DataSize, Data);\r
-    ASSERT (mGlobal->PlatformLangCodes != NULL);\r
-\r
-    //\r
-    // PlatformLang holds a single language from PlatformLangCodes, \r
-    // so the size of PlatformLangCodes is enough for the PlatformLang.\r
-    //\r
-    if (mGlobal->PlatformLang != NULL) {\r
-      FreePool (mGlobal->PlatformLang);\r
-    }\r
-    mGlobal->PlatformLang = AllocateRuntimePool (DataSize);\r
-    ASSERT (mGlobal->PlatformLang != NULL);\r
-\r
-  } else if (StrCmp (VariableName, L"LangCodes") == 0) {\r
-    //\r
-    // LangCodes is a volatile variable, so it can not be updated at runtime.\r
-    //\r
-    if (EfiAtRuntime ()) {\r
-      return;\r
-    }\r
-\r
-    SetLanguageCodes = TRUE;\r
-\r
-    //\r
-    // According to UEFI spec, LangCodes is only set once in firmware initialization, and is read-only\r
-    // Therefore, in variable driver, only store the original value for other use.\r
-    //\r
-    if (mGlobal->LangCodes != NULL) {\r
-      FreePool (mGlobal->LangCodes);\r
-    }\r
-    mGlobal->LangCodes = AllocateRuntimeCopyPool (DataSize, Data);\r
-    ASSERT (mGlobal->LangCodes != NULL);\r
-  }\r
-\r
-  if (SetLanguageCodes \r
-      && (mGlobal->PlatformLangCodes != NULL)\r
-      && (mGlobal->LangCodes != NULL)) {\r
-    //\r
-    // Update Lang if PlatformLang is already set\r
-    // Update PlatformLang if Lang is already set\r
-    //\r
-    Status = FindVariable (L"PlatformLang", &gEfiGlobalVariableGuid, &Variable);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Update Lang\r
-      //\r
-      VariableName = L"PlatformLang";\r
-      Data         = GetVariableDataPtr (Variable.CurrPtr);\r
-      DataSize     = Variable.CurrPtr->DataSize;\r
-    } else {\r
-      Status = FindVariable (L"Lang", &gEfiGlobalVariableGuid, &Variable);\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Update PlatformLang\r
-        //\r
-        VariableName = L"Lang";\r
-        Data         = GetVariableDataPtr (Variable.CurrPtr);\r
-        DataSize     = Variable.CurrPtr->DataSize;\r
-      } else {\r
-        //\r
-        // Neither PlatformLang nor Lang is set, directly return\r
-        //\r
-        return;\r
-      }\r
-    }\r
-  }\r
-  \r
-  //\r
-  // According to UEFI spec, "Lang" and "PlatformLang" is NV|BS|RT attributions.\r
-  //\r
-  Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;\r
-\r
-  if (StrCmp (VariableName, L"PlatformLang") == 0) {\r
-    //\r
-    // Update Lang when PlatformLangCodes/LangCodes were set.\r
-    //\r
-    if ((mGlobal->PlatformLangCodes != NULL) && (mGlobal->LangCodes != NULL)) {\r
-      //\r
-      // When setting PlatformLang, firstly get most matched language string from supported language codes.\r
-      //\r
-      BestPlatformLang = VariableGetBestLanguage (mGlobal->PlatformLangCodes, FALSE, Data, NULL);\r
-      if (BestPlatformLang != NULL) {\r
-        //\r
-        // Get the corresponding index in language codes.\r
-        //\r
-        Index = GetIndexFromSupportedLangCodes (mGlobal->PlatformLangCodes, BestPlatformLang, FALSE);\r
-\r
-        //\r
-        // Get the corresponding ISO639 language tag according to RFC4646 language tag.\r
-        //\r
-        BestLang = GetLangFromSupportedLangCodes (mGlobal->LangCodes, Index, TRUE);\r
-\r
-        //\r
-        // Successfully convert PlatformLang to Lang, and set the BestLang value into Lang variable simultaneously.\r
-        //\r
-        FindVariable(L"Lang", &gEfiGlobalVariableGuid, &Variable);\r
-\r
-        Status = UpdateVariable (L"Lang", &gEfiGlobalVariableGuid, BestLang, ISO_639_2_ENTRY_SIZE + 1, Attributes, &Variable);\r
-\r
-        DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a\n", BestPlatformLang, BestLang));\r
-\r
-        ASSERT_EFI_ERROR(Status);\r
-      }\r
-    }\r
-\r
-  } else if (StrCmp (VariableName, L"Lang") == 0) {\r
-    //\r
-    // Update PlatformLang when PlatformLangCodes/LangCodes were set.\r
-    //\r
-    if ((mGlobal->PlatformLangCodes != NULL) && (mGlobal->LangCodes != NULL)) {\r
-      //\r
-      // When setting Lang, firstly get most matched language string from supported language codes.\r
-      //\r
-      BestLang = VariableGetBestLanguage (mGlobal->LangCodes, TRUE, Data, NULL);\r
-      if (BestLang != NULL) {\r
-        //\r
-        // Get the corresponding index in language codes.\r
-        //\r
-        Index = GetIndexFromSupportedLangCodes (mGlobal->LangCodes, BestLang, TRUE);\r
-\r
-        //\r
-        // Get the corresponding RFC4646 language tag according to ISO639 language tag.\r
-        //\r
-        BestPlatformLang = GetLangFromSupportedLangCodes (mGlobal->PlatformLangCodes, Index, FALSE);\r
-\r
-        //\r
-        // Successfully convert Lang to PlatformLang, and set the BestPlatformLang value into PlatformLang variable simultaneously.\r
-        //\r
-        FindVariable(L"PlatformLang", &gEfiGlobalVariableGuid, &Variable);\r
-\r
-        Status = UpdateVariable (L"PlatformLang", &gEfiGlobalVariableGuid, BestPlatformLang, \r
-                                 AsciiStrSize (BestPlatformLang), Attributes, &Variable);\r
-\r
-        DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));\r
-        ASSERT_EFI_ERROR (Status);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Update the variable region with Variable information. These are the same \r
-  arguments as the EFI Variable services.\r
-\r
-  @param[in] VariableName       Name of variable\r
-\r
-  @param[in] VendorGuid         Guid of variable\r
-\r
-  @param[in] Data               Variable data\r
-\r
-  @param[in] DataSize           Size of data. 0 means delete\r
-\r
-  @param[in] Attributes         Attribues of the variable\r
-\r
-  @param[in] Variable           The variable information which is used to keep track of variable usage.\r
-\r
-  @retval EFI_SUCCESS           The update operation is success.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  Variable region is full, can not write other data into this region.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UpdateVariable (\r
-  IN      CHAR16                 *VariableName,\r
-  IN      EFI_GUID               *VendorGuid,\r
-  IN      VOID                   *Data,\r
-  IN      UINTN                  DataSize,\r
-  IN      UINT32                 Attributes OPTIONAL,\r
-  IN      VARIABLE_POINTER_TRACK *Variable\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  VARIABLE_HEADER                     *NextVariable;\r
-  UINTN                               VarNameOffset;\r
-  UINTN                               VarDataOffset;\r
-  UINTN                               VarNameSize;\r
-  UINTN                               VarSize;\r
-  UINT8                               State;\r
-  BOOLEAN                             Reclaimed;\r
-  VARIABLE_STORAGE_TYPE               StorageType;\r
-\r
-  Reclaimed         = FALSE;\r
-\r
-  if (Variable->CurrPtr != NULL) {  \r
-    //\r
-    // Update/Delete existing variable\r
-    //\r
-    \r
-    if (EfiAtRuntime ()) {              \r
-      //\r
-      // If EfiAtRuntime and the variable is Volatile and Runtime Access,  \r
-      // the volatile is ReadOnly, and SetVariable should be aborted and \r
-      // return EFI_WRITE_PROTECTED.\r
-      //\r
-      if (Variable->Type == Volatile) {\r
-        return EFI_WRITE_PROTECTED;\r
-      }\r
-      //\r
-      // Only variable have NV attribute can be updated/deleted in Runtime\r
-      //\r
-      if (!(Variable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE)) {\r
-        return EFI_INVALID_PARAMETER;      \r
-      }\r
-    }\r
-    \r
-    //\r
-    // Setting a data variable with no access, or zero DataSize attributes\r
-    // specified causes it to be deleted.\r
-    //\r
-    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
-      //\r
-      // Found this variable in storage\r
-      //\r
-      State = Variable->CurrPtr->State;\r
-      State &= VAR_DELETED;\r
-\r
-      Status = mGlobal->VariableStore[Variable->Type]->Write (\r
-                                                        mGlobal->VariableStore[Variable->Type],\r
-                                                        VARIABLE_MEMBER_OFFSET (State, (UINTN) Variable->CurrPtr - (UINTN) Variable->StartPtr),\r
-                                                        sizeof (Variable->CurrPtr->State),\r
-                                                        &State\r
-                                                        );\r
-      //\r
-      // NOTE: Write operation at least can write data to memory cache\r
-      //       Discard file writing failure here.\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-    \r
-    //\r
-    // Found this variable in storage\r
-    // If the variable is marked valid and the same data has been passed in\r
-    // then return to the caller immediately.\r
-    //\r
-    if ((Variable->CurrPtr->DataSize == DataSize) &&\r
-        (CompareMem (Data, GetVariableDataPtr (Variable->CurrPtr), DataSize) == 0)\r
-          ) {\r
-      return EFI_SUCCESS;\r
-    } else if ((Variable->CurrPtr->State == VAR_ADDED) ||\r
-               (Variable->CurrPtr->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION))) {\r
-      //\r
-      // Mark the old variable as in delete transition\r
-      //\r
-      State = Variable->CurrPtr->State;\r
-      State &= VAR_IN_DELETED_TRANSITION;\r
-\r
-      Status = mGlobal->VariableStore[Variable->Type]->Write (\r
-                                                        mGlobal->VariableStore[Variable->Type],\r
-                                                        VARIABLE_MEMBER_OFFSET (State, (UINTN) Variable->CurrPtr - (UINTN) Variable->StartPtr),\r
-                                                        sizeof (Variable->CurrPtr->State),\r
-                                                        &State\r
-                                                        );\r
-      //\r
-      // NOTE: Write operation at least can write data to memory cache\r
-      //       Discard file writing failure here.\r
-      //\r
-    }\r
-  } else {\r
-    //\r
-    // Create a new variable\r
-    //  \r
-    \r
-    //\r
-    // Make sure we are trying to create a new variable.\r
-    // Setting a data variable with no access, or zero DataSize attributes means to delete it.    \r
-    //\r
-    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
-      return EFI_NOT_FOUND;\r
-    }    \r
-    //\r
-    // Only variable have NV|RT attribute can be created in Runtime\r
-    //\r
-    if (EfiAtRuntime () &&\r
-        (!(Attributes & EFI_VARIABLE_RUNTIME_ACCESS) || !(Attributes & EFI_VARIABLE_NON_VOLATILE))) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }        \r
-    \r
-  } \r
-\r
-  //\r
-  // Function part - create a new variable and copy the data.\r
-  // Both update a variable and create a variable will come here.  \r
-  // We can firstly write all the data in memory, then write them to file\r
-  // This can reduce the times of write operation\r
-  //\r
-  \r
-  NextVariable = (VARIABLE_HEADER *) mGlobal->Scratch;\r
-\r
-  NextVariable->StartId     = VARIABLE_DATA;\r
-  NextVariable->Attributes  = Attributes;\r
-  NextVariable->State       = VAR_ADDED;\r
-  NextVariable->Reserved    = 0;\r
-  VarNameOffset             = sizeof (VARIABLE_HEADER);\r
-  VarNameSize               = StrSize (VariableName);\r
-  CopyMem (\r
-    (UINT8 *) ((UINTN) NextVariable + VarNameOffset),\r
-    VariableName,\r
-    VarNameSize\r
-    );\r
-  VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);\r
-  CopyMem (\r
-    (UINT8 *) ((UINTN) NextVariable + VarDataOffset),\r
-    Data,\r
-    DataSize\r
-    );\r
-  CopyMem (&NextVariable->VendorGuid, VendorGuid, sizeof (EFI_GUID));\r
-  //\r
-  // There will be pad bytes after Data, the NextVariable->NameSize and\r
-  // NextVariable->DataSize should not include pad size so that variable\r
-  // service can get actual size in GetVariable\r
-  //\r
-  NextVariable->NameSize  = (UINT32)VarNameSize;\r
-  NextVariable->DataSize  = (UINT32)DataSize;\r
-\r
-  //\r
-  // The actual size of the variable that stores in storage should\r
-  // include pad size.\r
-  // VarDataOffset: offset from begin of current variable header\r
-  //\r
-  VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);\r
-\r
-  StorageType = (Attributes & EFI_VARIABLE_NON_VOLATILE) ? NonVolatile : Volatile;\r
-\r
-  if ((UINT32) (VarSize + mGlobal->LastVariableOffset[StorageType]) >\r
-      ((VARIABLE_STORE_HEADER *) mGlobal->VariableBase[StorageType])->Size\r
-      ) {\r
-    if ((StorageType == NonVolatile) && EfiAtRuntime ()) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    //\r
-    // Perform garbage collection & reclaim operation\r
-    //\r
-    Status = Reclaim (StorageType, Variable->CurrPtr);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Reclaim error\r
-      // we cannot restore to original state, fetal error, report to user\r
-      //\r
-      DEBUG ((EFI_D_ERROR, "FSVariable: Recalim error (fetal error) - %r\n", Status));\r
-      return Status;\r
-    }\r
-    //\r
-    // If still no enough space, return out of resources\r
-    //\r
-    if ((UINT32) (VarSize + mGlobal->LastVariableOffset[StorageType]) >\r
-        ((VARIABLE_STORE_HEADER *) mGlobal->VariableBase[StorageType])->Size\r
-       ) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    Reclaimed = TRUE;\r
-  }\r
-  Status = mGlobal->VariableStore[StorageType]->Write (\r
-                                                  mGlobal->VariableStore[StorageType],\r
-                                                  mGlobal->LastVariableOffset[StorageType],\r
-                                                  VarSize,\r
-                                                  NextVariable\r
-                                                  );\r
-  //\r
-  // NOTE: Write operation at least can write data to memory cache\r
-  //       Discard file writing failure here.\r
-  //\r
-  mGlobal->LastVariableOffset[StorageType] += VarSize;\r
-\r
-  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {\r
-    mGlobal->HwErrVariableTotalSize += VarSize;\r
-  } else {\r
-    mGlobal->CommonVariableTotalSize += VarSize;\r
-  }\r
-\r
-  //\r
-  // Mark the old variable as deleted\r
-  //\r
-  if (!Reclaimed && !EFI_ERROR (Status) && Variable->CurrPtr != NULL) {\r
-    State = Variable->CurrPtr->State;\r
-    State &= VAR_DELETED;\r
-\r
-    Status = mGlobal->VariableStore[StorageType]->Write (\r
-                                                    mGlobal->VariableStore[StorageType],\r
-                                                    VARIABLE_MEMBER_OFFSET (State, (UINTN) Variable->CurrPtr - (UINTN) Variable->StartPtr),\r
-                                                    sizeof (Variable->CurrPtr->State),\r
-                                                    &State\r
-                                                    );\r
-    //\r
-    // NOTE: Write operation at least can write data to memory cache\r
-    //       Discard file writing failure here.\r
-    //\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DuetGetVariable (\r
-  IN      CHAR16            *VariableName,\r
-  IN      EFI_GUID          *VendorGuid,\r
-  OUT     UINT32            *Attributes OPTIONAL,\r
-  IN OUT  UINTN             *DataSize,\r
-  OUT     VOID              *Data OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code finds variable in storage blocks (Volatile or Non-Volatile)\r
-\r
-Arguments:\r
-\r
-  VariableName                    Name of Variable to be found\r
-  VendorGuid                      Variable vendor GUID\r
-  Attributes OPTIONAL             Attribute value of the variable found\r
-  DataSize                        Size of Data found. If size is less than the\r
-                                  data, this value contains the required size.\r
-  Data                            The buffer to return the contents of the variable. May be NULL\r
-                                  with a zero DataSize in order to determine the size buffer needed.\r
-\r
-Returns:\r
-\r
-  EFI STATUS\r
-\r
---*/\r
-{\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  UINTN                   VarDataSize;\r
-  EFI_STATUS              Status;\r
-\r
-  if (VariableName == NULL || VendorGuid == NULL || DataSize == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (VariableName[0] == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Find existing variable\r
-  //\r
-  Status = FindVariable (VariableName, VendorGuid, &Variable);\r
-\r
-  if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get data size\r
-  //\r
-  VarDataSize = Variable.CurrPtr->DataSize;\r
-  if (*DataSize >= VarDataSize) {\r
-    if (Data == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr), VarDataSize);\r
-\r
-    if (Attributes != NULL) {\r
-      *Attributes = Variable.CurrPtr->Attributes;\r
-    }\r
-\r
-    *DataSize = VarDataSize;\r
-\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    *DataSize = VarDataSize;\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetNextVariableName (\r
-  IN OUT  UINTN             *VariableNameSize,\r
-  IN OUT  CHAR16            *VariableName,\r
-  IN OUT  EFI_GUID          *VendorGuid\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code Finds the Next available variable\r
-\r
-Arguments:\r
-\r
-  VariableNameSize            The size of the VariableName buffer. The size must be large\r
-                              enough to fit input string supplied in VariableName buffer.\r
-  VariableName                Pointer to variable name\r
-  VendorGuid                  Variable Vendor Guid\r
-\r
-Returns:\r
-\r
-  EFI STATUS\r
-\r
---*/\r
-{\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  UINTN                   VarNameSize;\r
-  EFI_STATUS              Status;\r
-  UINTN                   MaxLen;\r
-\r
-  if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Calculate the possible maximum length of name string, including the Null terminator.\r
-  //\r
-  MaxLen = *VariableNameSize / sizeof (CHAR16);\r
-  if ((MaxLen == 0) || (StrnLenS (VariableName, MaxLen) == MaxLen)) {\r
-    //\r
-    // Null-terminator is not found in the first VariableNameSize bytes of the input VariableName buffer,\r
-    // follow spec to return EFI_INVALID_PARAMETER.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = FindVariable (VariableName, VendorGuid, &Variable);\r
-\r
-  if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
-    //\r
-    // For VariableName is an empty string, FindVariable() will try to find and return\r
-    // the first qualified variable, and if FindVariable() returns error (EFI_NOT_FOUND)\r
-    // as no any variable is found, still go to return the error (EFI_NOT_FOUND).\r
-    //\r
-    if (VariableName[0] != 0) {\r
-      //\r
-      // For VariableName is not an empty string, and FindVariable() returns error as\r
-      // VariableName and VendorGuid are not a name and GUID of an existing variable,\r
-      // there is no way to get next variable, follow spec to return EFI_INVALID_PARAMETER.\r
-      //\r
-      Status = EFI_INVALID_PARAMETER;\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  if (VariableName[0] != 0) {\r
-    //\r
-    // If variable name is not NULL, get next variable\r
-    //\r
-    Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
-  }\r
-\r
-  while (TRUE) {\r
-    //\r
-    // The order we find variable is: 1). NonVolatile; 2). Volatile\r
-    // If both volatile and non-volatile variable store are parsed,\r
-    // return not found\r
-    //\r
-    if (Variable.CurrPtr >= Variable.EndPtr || Variable.CurrPtr == NULL) {\r
-      if (Variable.Type == Volatile) {\r
-        //\r
-        // Since we met the end of Volatile storage, we have parsed all the stores.\r
-        //\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      //\r
-      // End of NonVolatile, continue to parse Volatile\r
-      //\r
-      Variable.Type = Volatile;\r
-      Variable.StartPtr = (VARIABLE_HEADER *) ((VARIABLE_STORE_HEADER *) mGlobal->VariableBase[Volatile] + 1);\r
-      Variable.EndPtr   = (VARIABLE_HEADER *) GetEndPointer ((VARIABLE_STORE_HEADER *) mGlobal->VariableBase[Volatile]);\r
-\r
-      Variable.CurrPtr = Variable.StartPtr;\r
-      if (!IsValidVariableHeader (Variable.CurrPtr)) {\r
-        continue;\r
-      }\r
-    }\r
-    //\r
-    // Variable is found\r
-    //\r
-    if (IsValidVariableHeader (Variable.CurrPtr) &&\r
-        ((Variable.CurrPtr->State == VAR_ADDED) ||\r
-         (Variable.CurrPtr->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION)))) {\r
-      if (!EfiAtRuntime () || (Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
-        VarNameSize = Variable.CurrPtr->NameSize;\r
-        if (VarNameSize <= *VariableNameSize) {\r
-          CopyMem (\r
-            VariableName,\r
-            GET_VARIABLE_NAME_PTR (Variable.CurrPtr),\r
-            VarNameSize\r
-            );\r
-          CopyMem (\r
-            VendorGuid,\r
-            &Variable.CurrPtr->VendorGuid,\r
-            sizeof (EFI_GUID)\r
-            );\r
-          Status = EFI_SUCCESS;\r
-        } else {\r
-          Status = EFI_BUFFER_TOO_SMALL;\r
-        }\r
-\r
-        *VariableNameSize = VarNameSize;\r
-        return Status;\r
-      }\r
-    }\r
-\r
-    Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SetVariable (\r
-  IN CHAR16                  *VariableName,\r
-  IN EFI_GUID                *VendorGuid,\r
-  IN UINT32                  Attributes,\r
-  IN UINTN                   DataSize,\r
-  IN VOID                    *Data\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code sets variable in storage blocks (Volatile or Non-Volatile)\r
-\r
-Arguments:\r
-\r
-  VariableName                    Name of Variable to be found\r
-  VendorGuid                      Variable vendor GUID\r
-  Attributes                      Attribute value of the variable found\r
-  DataSize                        Size of Data found. If size is less than the\r
-                                  data, this value contains the required size.\r
-  Data                            Data pointer\r
-\r
-Returns:\r
-  \r
-  EFI_INVALID_PARAMETER           - Invalid parameter\r
-  EFI_SUCCESS                     - Set successfully\r
-  EFI_OUT_OF_RESOURCES            - Resource not enough to set variable\r
-  EFI_NOT_FOUND                   - Not found\r
-  EFI_DEVICE_ERROR                - Variable can not be saved due to hardware failure\r
-  EFI_WRITE_PROTECTED             - Variable is read-only\r
-\r
---*/\r
-{\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Check input parameters\r
-  // \r
-  if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if (DataSize != 0 && Data == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Not support authenticated variable write yet.\r
-  //\r
-  if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  //  Make sure if runtime bit is set, boot service bit is set also\r
-  //\r
-  if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  //\r
-  //  The size of the VariableName, including the Unicode Null in bytes plus\r
-  //  the DataSize is limited to maximum size of PcdGet32 (PcdMaxHardwareErrorVariableSize)\r
-  //  bytes for HwErrRec, and PcdGet32 (PcdMaxVariableSize) bytes for the others.\r
-  //\r
-  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-    if ((DataSize > PcdGet32(PcdMaxHardwareErrorVariableSize)) ||                                                       \r
-        (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32(PcdMaxHardwareErrorVariableSize))) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // According to UEFI spec, HARDWARE_ERROR_RECORD variable name convention should be L"HwErrRecXXXX"\r
-    //\r
-    if (StrnCmp(VariableName, L"HwErrRec", StrLen(L"HwErrRec")) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } else {\r
-    if ((DataSize > PcdGet32(PcdMaxVariableSize)) ||\r
-        (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32(PcdMaxVariableSize))) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }  \r
-  }  \r
-\r
-  //\r
-  // Check whether the input variable is already existed\r
-  //\r
-  Status = FindVariable (VariableName, VendorGuid, &Variable);\r
-\r
-  //\r
-  // Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang\r
-  //\r
-  AutoUpdateLangVariable (VariableName, Data, DataSize);\r
-\r
-  Status = UpdateVariable (VariableName, VendorGuid, Data, DataSize, Attributes, &Variable);\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-QueryVariableInfo (\r
-  IN  UINT32                 Attributes,\r
-  OUT UINT64                 *MaximumVariableStorageSize,\r
-  OUT UINT64                 *RemainingVariableStorageSize,\r
-  OUT UINT64                 *MaximumVariableSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code returns information about the EFI variables.\r
-\r
-Arguments:\r
-\r
-  Attributes                      Attributes bitmask to specify the type of variables\r
-                                  on which to return information.\r
-  MaximumVariableStorageSize      Pointer to the maximum size of the storage space available\r
-                                  for the EFI variables associated with the attributes specified.\r
-  RemainingVariableStorageSize    Pointer to the remaining size of the storage space available\r
-                                  for the EFI variables associated with the attributes specified.\r
-  MaximumVariableSize             Pointer to the maximum size of the individual EFI variables\r
-                                  associated with the attributes specified.\r
-\r
-Returns:\r
-\r
-  EFI STATUS\r
-  EFI_INVALID_PARAMETER           - An invalid combination of attribute bits was supplied.\r
-  EFI_SUCCESS                     - Query successfully.\r
-  EFI_UNSUPPORTED                 - The attribute is not supported on this platform.\r
-\r
---*/\r
-{\r
-  VARIABLE_HEADER        *Variable;\r
-  VARIABLE_HEADER        *NextVariable;\r
-  UINT64                 VariableSize;\r
-  VARIABLE_STORE_HEADER  *VariableStoreHeader;\r
-  UINT64                 CommonVariableTotalSize;\r
-  UINT64                 HwErrVariableTotalSize;\r
-\r
-  CommonVariableTotalSize = 0;\r
-  HwErrVariableTotalSize = 0;\r
-\r
-  if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL || Attributes == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == 0) {\r
-    //\r
-    // Make sure the Attributes combination is supported by the platform.\r
-    //\r
-    return EFI_UNSUPPORTED;  \r
-  } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
-    //\r
-    // Make sure if runtime bit is set, boot service bit is set also.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  } else if (EfiAtRuntime () && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
-    //\r
-    // Make sure RT Attribute is set if we are in Runtime phase.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  } else if ((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-    //\r
-    // Make sure Hw Attribute is set with NV.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  } else if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
-    //\r
-    // Not support authentiated variable write yet.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  VariableStoreHeader = (VARIABLE_STORE_HEADER *) mGlobal->VariableBase[\r
-                                (Attributes & EFI_VARIABLE_NON_VOLATILE) ? NonVolatile : Volatile\r
-                                ];\r
-  //\r
-  // Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize\r
-  // with the storage size (excluding the storage header size).\r
-  //\r
-  *MaximumVariableStorageSize   = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);\r
-\r
-  //\r
-  // Harware error record variable needs larger size.\r
-  //\r
-  if ((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-    *MaximumVariableStorageSize = PcdGet32(PcdHwErrStorageSize);\r
-    *MaximumVariableSize = PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER);\r
-  } else {\r
-    if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
-      ASSERT (PcdGet32(PcdHwErrStorageSize) < VariableStoreHeader->Size);\r
-      *MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize);\r
-    }\r
-\r
-    //\r
-    // Let *MaximumVariableSize be PcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
-    //\r
-    *MaximumVariableSize = PcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER);\r
-  }\r
-  \r
-  //\r
-  // Point to the starting address of the variables.\r
-  //\r
-  Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
-\r
-  //\r
-  // Now walk through the related variable store.\r
-  //\r
-  while ((Variable < GetEndPointer (VariableStoreHeader)) && IsValidVariableHeader (Variable)) {\r
-    NextVariable = GetNextVariablePtr (Variable);\r
-    VariableSize = (UINT64) (UINTN) NextVariable - (UINT64) (UINTN) Variable;\r
-\r
-    if (EfiAtRuntime ()) {\r
-      //\r
-      // we don't take the state of the variables in mind\r
-      // when calculating RemainingVariableStorageSize,\r
-      // since the space occupied by variables not marked with\r
-      // VAR_ADDED is not allowed to be reclaimed in Runtime.\r
-      //\r
-      if ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-        HwErrVariableTotalSize += VariableSize;\r
-      } else {\r
-        CommonVariableTotalSize += VariableSize;\r
-      }\r
-    } else {\r
-      //\r
-      // Only care about Variables with State VAR_ADDED,because\r
-      // the space not marked as VAR_ADDED is reclaimable now.\r
-      //\r
-      if ((Variable->State == VAR_ADDED) || (Variable->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION))) {\r
-        if ((Variable->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-          HwErrVariableTotalSize += VariableSize;\r
-        } else {\r
-          CommonVariableTotalSize += VariableSize;\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Go to the next one\r
-    //\r
-    Variable = NextVariable;\r
-  }\r
-  \r
-  if ((Attributes  & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD){\r
-    *RemainingVariableStorageSize = *MaximumVariableStorageSize - HwErrVariableTotalSize;\r
-  } else {\r
-    *RemainingVariableStorageSize = *MaximumVariableStorageSize - CommonVariableTotalSize;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-VariableServiceInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function does initialization for variable services\r
-\r
-Arguments:\r
-\r
-  ImageHandle   - The firmware allocated handle for the EFI image.\r
-  SystemTable   - A pointer to the EFI System Table.\r
-\r
-Returns:\r
-\r
-  Status code.\r
-\r
-  EFI_NOT_FOUND     - Variable store area not found.\r
-  EFI_SUCCESS       - Variable services successfully initialized.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_HANDLE                      NewHandle;\r
-  VS_DEV                          *Dev;\r
-  EFI_PEI_HOB_POINTERS            GuidHob;\r
-  VARIABLE_HEADER                 *Variable;\r
-  VARIABLE_HEADER                 *NextVariable;\r
-  VARIABLE_STORE_HEADER           *VariableStoreHeader;\r
-  EFI_FLASH_MAP_FS_ENTRY_DATA     *FlashMapEntryData;\r
-  EFI_FLASH_SUBAREA_ENTRY         VariableStoreEntry;\r
-  UINT64                          BaseAddress;\r
-  UINT64                          Length;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
-\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  (UINTN) sizeof (VARIABLE_GLOBAL),\r
-                  (VOID**) &mGlobal\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  ZeroMem (mGlobal, (UINTN) sizeof (VARIABLE_GLOBAL));\r
-\r
-  GuidHob.Raw = GetHobList ();\r
-  FlashMapEntryData = NULL;\r
-  while ((GuidHob.Raw = GetNextGuidHob (&gEfiFlashMapHobGuid, GuidHob.Raw)) != NULL) {\r
-    FlashMapEntryData = (EFI_FLASH_MAP_FS_ENTRY_DATA *) GET_GUID_HOB_DATA (GuidHob.Guid);\r
-    if (FlashMapEntryData->AreaType == EFI_FLASH_AREA_EFI_VARIABLES) {\r
-      break;\r
-    }\r
-    GuidHob.Raw = GET_NEXT_HOB (GuidHob); \r
-  }\r
-\r
-  if (FlashMapEntryData == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "FSVariable: Could not find flash area for variable!\n"));\r
-    Status = EFI_NOT_FOUND;\r
-    return Status;\r
-  }\r
-  \r
-  CopyMem(\r
-    (VOID*)&VariableStoreEntry,\r
-    (VOID*)&FlashMapEntryData->Entries[0],\r
-    sizeof(EFI_FLASH_SUBAREA_ENTRY)\r
-    );\r
-\r
-  //\r
-  // Mark the variable storage region of the FLASH as RUNTIME\r
-  //\r
-  BaseAddress = VariableStoreEntry.Base & (~EFI_PAGE_MASK);\r
-  Length      = VariableStoreEntry.Length + (VariableStoreEntry.Base - BaseAddress);\r
-  Length      = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);\r
-  Status      = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    return Status;\r
-  }\r
-  Status = gDS->SetMemorySpaceAttributes (\r
-                  BaseAddress,\r
-                  Length,\r
-                  GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    return Status;\r
-  }\r
-\r
-  Status = FileStorageConstructor (\r
-             &mGlobal->VariableStore[NonVolatile], \r
-             &mGlobal->GoVirtualChildEvent[NonVolatile],\r
-             VariableStoreEntry.Base,\r
-             (UINT32) VariableStoreEntry.Length,\r
-             FlashMapEntryData->VolumeId,\r
-             FlashMapEntryData->FilePath\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Volatile Storage\r
-  //\r
-  Status = MemStorageConstructor (\r
-             &mGlobal->VariableStore[Volatile],\r
-             &mGlobal->GoVirtualChildEvent[Volatile],\r
-             VOLATILE_VARIABLE_STORE_SIZE\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Scratch\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  VARIABLE_SCRATCH_SIZE,\r
-                  &mGlobal->Scratch\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // 1. NV Storage\r
-  //\r
-  Dev = DEV_FROM_THIS (mGlobal->VariableStore[NonVolatile]);\r
-  VariableStoreHeader = (VARIABLE_STORE_HEADER *) VAR_DATA_PTR (Dev);\r
-  if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {\r
-    if (~VariableStoreHeader->Size == 0) {\r
-      VariableStoreHeader->Size = (UINT32) VariableStoreEntry.Length;\r
-    }\r
-  }\r
-  //\r
-  // Calculate LastVariableOffset\r
-  //\r
-  Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1);\r
-  while (IsValidVariableHeader (Variable)) {\r
-    UINTN VariableSize = 0;\r
-    NextVariable = GetNextVariablePtr (Variable);\r
-    VariableSize = NextVariable - Variable;\r
-    if ((NextVariable->Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-      mGlobal->HwErrVariableTotalSize += HEADER_ALIGN (VariableSize);\r
-    } else {\r
-      mGlobal->CommonVariableTotalSize += HEADER_ALIGN (VariableSize);\r
-    }\r
-    Variable = NextVariable;\r
-  }\r
-\r
-  mGlobal->LastVariableOffset[NonVolatile] = (UINTN) Variable - (UINTN) VariableStoreHeader;\r
-  mGlobal->VariableBase[NonVolatile]       = VariableStoreHeader;\r
-\r
-  //\r
-  // Reclaim if remaining space is too small\r
-  //\r
-  if ((VariableStoreHeader->Size - mGlobal->LastVariableOffset[NonVolatile]) < VARIABLE_RECLAIM_THRESHOLD) {\r
-    Status = Reclaim (NonVolatile, NULL);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Reclaim error\r
-      // we cannot restore to original state\r
-      //\r
-      DEBUG ((EFI_D_ERROR, "FSVariable: Reclaim error (fatal error) - %r\n", Status));\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-  \r
-  //\r
-  // 2. Volatile Storage\r
-  //\r
-  Dev = DEV_FROM_THIS (mGlobal->VariableStore[Volatile]);\r
-  VariableStoreHeader = (VARIABLE_STORE_HEADER *) VAR_DATA_PTR (Dev);\r
-  mGlobal->VariableBase[Volatile] = VAR_DATA_PTR (Dev);  \r
-  mGlobal->LastVariableOffset[Volatile] = sizeof (VARIABLE_STORE_HEADER);\r
-  //\r
-  // init store_header & body in memory.\r
-  //\r
-  mGlobal->VariableStore[Volatile]->Erase (mGlobal->VariableStore[Volatile]);\r
-  mGlobal->VariableStore[Volatile]->Write (\r
-                                   mGlobal->VariableStore[Volatile],\r
-                                   0,\r
-                                   sizeof (VARIABLE_STORE_HEADER),\r
-                                   &mStoreHeaderTemplate\r
-                                   );\r
-\r
-\r
-  SystemTable->RuntimeServices->GetVariable         = DuetGetVariable;\r
-  SystemTable->RuntimeServices->GetNextVariableName = GetNextVariableName;\r
-  SystemTable->RuntimeServices->SetVariable         = SetVariable;\r
-\r
-  SystemTable->RuntimeServices->QueryVariableInfo   = QueryVariableInfo;\r
-\r
-  //\r
-  // Now install the Variable Runtime Architectural Protocol on a new handle\r
-  //\r
-  NewHandle = NULL;\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &NewHandle,\r
-                  &gEfiVariableArchProtocolGuid,\r
-                  NULL,\r
-                  &gEfiVariableWriteArchProtocolGuid,\r
-                  NULL,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-VOID\r
-EFIAPI\r
-OnVirtualAddressChangeFsv (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  for (Index = 0; Index < MaxType; Index++) {\r
-    mGlobal->GoVirtualChildEvent[Index] (Event, mGlobal->VariableStore[Index]);\r
-    EfiConvertPointer (0, (VOID**) &mGlobal->VariableStore[Index]);\r
-    EfiConvertPointer (0, &mGlobal->VariableBase[Index]);\r
-  }\r
-  EfiConvertPointer (0, (VOID **) &mGlobal->PlatformLangCodes);\r
-  EfiConvertPointer (0, (VOID **) &mGlobal->LangCodes);\r
-  EfiConvertPointer (0, (VOID **) &mGlobal->PlatformLang);\r
-  EfiConvertPointer (0, &mGlobal->Scratch);\r
-  EfiConvertPointer (0, (VOID**) &mGlobal);\r
-}\r
diff --git a/DuetPkg/FSVariable/FSVariable.h b/DuetPkg/FSVariable/FSVariable.h
deleted file mode 100644 (file)
index cb37c29..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*++\r
-\r
-Caution: This file is used for Duet platform only, do not use them in real platform.\r
-All variable code, variable metadata, and variable data used by Duet platform are on \r
-disk. They can be changed by user. BIOS is not able to protoect those.\r
-Duet trusts all meta data from disk. If variable code, variable metadata and variable\r
-data is modified in inproper way, the behavior is undefined.\r
-\r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
-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
-  FSVariable.h\r
-  \r
-Abstract:\r
-\r
---*/\r
-\r
-#ifndef _FS_VARIABLE_H\r
-#define _FS_VARIABLE_H\r
-\r
-//\r
-// Statements that include other header files\r
-//\r
-#include <PiDxe.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <Guid/HobList.h>\r
-#include <Guid/FlashMapHob.h>\r
-#include <Guid/VariableFormat.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Protocol/Variable.h>\r
-#include <Protocol/VariableWrite.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/BlockIo.h>\r
-\r
-\r
-#include "EfiFlashMap.h"\r
-#include "VariableStorage.h"\r
-\r
-#define VOLATILE_VARIABLE_STORE_SIZE  FixedPcdGet32(PcdVariableStoreSize)\r
-#define VARIABLE_SCRATCH_SIZE         MAX(FixedPcdGet32(PcdMaxVariableSize), FixedPcdGet32(PcdMaxHardwareErrorVariableSize))\r
-#define VARIABLE_RECLAIM_THRESHOLD    (1024)\r
-///\r
-/// The size of a 3 character ISO639 language code.\r
-///\r
-#define ISO_639_2_ENTRY_SIZE    3\r
-\r
-#define GET_VARIABLE_NAME_PTR(a)  (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r
-\r
-typedef enum {\r
-  Physical,\r
-  Virtual\r
-} VARIABLE_POINTER_TYPE;\r
-\r
-typedef enum {\r
-  NonVolatile,\r
-  Volatile,\r
-  MaxType\r
-} VARIABLE_STORAGE_TYPE;\r
-\r
-typedef struct {\r
-  VARIABLE_HEADER         *CurrPtr;\r
-  VARIABLE_HEADER         *EndPtr;\r
-  VARIABLE_HEADER         *StartPtr;\r
-  VARIABLE_STORAGE_TYPE   Type;\r
-} VARIABLE_POINTER_TRACK;\r
-\r
-#define VARIABLE_MEMBER_OFFSET(Member, StartOffset) \\r
-        ( sizeof (VARIABLE_STORE_HEADER) + (StartOffset) + \\r
-          (UINTN) ((UINT8 *) &((VARIABLE_HEADER*) 0)->Member - (UINT8 *) &((VARIABLE_HEADER*) 0)->StartId) \\r
-        )\r
-\r
-\r
-typedef struct {\r
-  EFI_EVENT_NOTIFY   GoVirtualChildEvent[MaxType];\r
-  VARIABLE_STORAGE   *VariableStore[MaxType];       // Instance of VariableStorage\r
-  VOID               *VariableBase[MaxType];        // Start address of variable storage\r
-  UINTN              LastVariableOffset[MaxType];   // The position to write new variable to (index from VariableBase)\r
-  VOID               *Scratch;                      // Buffer used during reclaim\r
-  UINTN              CommonVariableTotalSize;\r
-  UINTN              HwErrVariableTotalSize;\r
-  CHAR8              *PlatformLangCodes;\r
-  CHAR8              *LangCodes;\r
-  CHAR8              *PlatformLang;\r
-  CHAR8              Lang[ISO_639_2_ENTRY_SIZE + 1];\r
-} VARIABLE_GLOBAL;\r
-\r
-//\r
-// Functions\r
-//\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-VariableServiceInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-VariableClassAddressChangeEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DuetGetVariable (\r
-  IN      CHAR16            *VariableName,\r
-  IN      EFI_GUID          *VendorGuid,\r
-  OUT     UINT32            *Attributes OPTIONAL,\r
-  IN OUT  UINTN             *DataSize,\r
-  OUT     VOID              *Data OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetNextVariableName (\r
-  IN OUT  UINTN             *VariableNameSize,\r
-  IN OUT  CHAR16            *VariableName,\r
-  IN OUT  EFI_GUID          *VendorGuid\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SetVariable (\r
-  IN CHAR16                  *VariableName,\r
-  IN EFI_GUID                *VendorGuid,\r
-  IN UINT32                  Attributes,\r
-  IN UINTN                   DataSize,\r
-  IN VOID                    *Data\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-QueryVariableInfo (\r
-  IN  UINT32                 Attributes,\r
-  OUT UINT64                 *MaximumVariableStorageSize,\r
-  OUT UINT64                 *RemainingVariableStorageSize,\r
-  OUT UINT64                 *MaximumVariableSize\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/FSVariable/FSVariable.inf b/DuetPkg/FSVariable/FSVariable.inf
deleted file mode 100644 (file)
index ad9037a..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-## @file\r
-#\r
-# Caution: This file is used for Duet platform only, do not use them in real platform.\r
-# All variable code, variable metadata, and variable data used by Duet platform are on \r
-# disk. They can be changed by user. BIOS is not able to protoect those.\r
-# Duet trusts all meta data from disk. If variable code, variable metadata and variable\r
-# data is modified in inproper way, the behavior is undefined.\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#   FSVariable.inf\r
-#\r
-#  Abstract:\r
-#\r
-#    Component description file for variable module\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = FSVariable\r
-  FILE_GUID                      = A36495C1-C205-414e-B71F-4BE3476D699C\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = VariableServiceInitialize\r
-  \r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[Sources]\r
-  FSVariable.h\r
-  VariableStorage.h\r
-  FSVariable.c\r
-  FileStorage.c\r
-  MemStorage.c\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  UefiBootServicesTableLib\r
-  UefiRuntimeLib\r
-  DebugLib\r
-  UefiLib\r
-  HobLib\r
-  DxeServicesTableLib\r
-  DevicePathLib\r
-  UefiDriverEntryPoint\r
-  MemoryAllocationLib\r
-\r
-[Guids]\r
-  gEfiFlashMapHobGuid\r
-  gEfiVariableGuid\r
-  gEfiGlobalVariableGuid                        ## PRODUCES ## Variable Guid\r
-  \r
-[Protocols]\r
-  gEfiVariableArchProtocolGuid\r
-  gEfiVariableWriteArchProtocolGuid\r
-  gEfiSimpleFileSystemProtocolGuid\r
-  gEfiBlockIoProtocolGuid\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize\r
-\r
-[Depex]\r
-  TRUE\r
diff --git a/DuetPkg/FSVariable/FileStorage.c b/DuetPkg/FSVariable/FileStorage.c
deleted file mode 100644 (file)
index d07c0bb..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/*++\r
-\r
-Caution: This file is used for Duet platform only, do not use them in real platform.\r
-All variable code, variable metadata, and variable data used by Duet platform are on \r
-disk. They can be changed by user. BIOS is not able to protoect those.\r
-Duet trusts all meta data from disk. If variable code, variable metadata and variable\r
-data is modified in inproper way, the behavior is undefined.\r
-\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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
-    FileStorage.c\r
-\r
-Abstract:\r
-\r
-    handles variable store/reads on file\r
-\r
-Revision History\r
-\r
---*/\r
-#include "FSVariable.h"\r
-\r
-VOID             *mSFSRegistration;\r
-\r
-//\r
-// Prototypes\r
-//\r
-\r
-VOID\r
-EFIAPI\r
-OnVirtualAddressChangeFs (\r
-  IN EFI_EVENT            Event,\r
-  IN VOID                 *Context\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FileEraseStore(\r
-  IN VARIABLE_STORAGE     *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FileWriteStore (\r
-  IN VARIABLE_STORAGE     *This,\r
-  IN UINTN                Offset,\r
-  IN UINTN                BufferSize,\r
-  IN VOID                 *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-OpenStore (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Device,\r
-  IN  CHAR16                    *FilePathName,\r
-  IN  UINT64                    OpenMode,\r
-  OUT EFI_FILE_PROTOCOL         **File\r
-  );\r
-\r
-//\r
-// Implementation below:\r
-//\r
-VOID\r
-FileClose (\r
-  IN  EFI_FILE_PROTOCOL          *File\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  Status = File->Flush (File);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = File->Close (File);\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-EFI_STATUS\r
-CheckStore (\r
-  IN  EFI_HANDLE                 SimpleFileSystemHandle,\r
-  IN  UINT32                     VolumeId,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL   **Device\r
-  )\r
-{\r
-#define BLOCK_SIZE              0x200\r
-#define FAT16_VOLUME_ID_OFFSET  39\r
-#define FAT32_VOLUME_ID_OFFSET  67\r
-  EFI_STATUS                      Status;\r
-  EFI_BLOCK_IO_PROTOCOL           *BlkIo;\r
-  UINT8                           BootSector[BLOCK_SIZE];\r
-\r
-  *Device = NULL;\r
-  Status  = gBS->HandleProtocol (\r
-                   SimpleFileSystemHandle,\r
-                   &gEfiBlockIoProtocolGuid, // BlockIo should be supported if it supports SimpleFileSystem\r
-                   (VOID*)&BlkIo\r
-                   );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrHandle;\r
-  }\r
-  if (!BlkIo->Media->MediaPresent) {\r
-    DEBUG ((EFI_D_ERROR, "FileStorage: Media not present!\n"));\r
-    Status = EFI_NO_MEDIA;\r
-    goto ErrHandle;\r
-  }\r
-  if (BlkIo->Media->ReadOnly) {\r
-    DEBUG ((EFI_D_ERROR, "FileStorage: Media is read-only!\n"));\r
-    Status = EFI_ACCESS_DENIED;\r
-    goto ErrHandle;\r
-  }\r
-\r
-  Status = BlkIo->ReadBlocks(\r
-                    BlkIo,\r
-                    BlkIo->Media->MediaId,\r
-                    0,\r
-                    BLOCK_SIZE,\r
-                    BootSector\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-  if ((*(UINT32 *) &BootSector[FAT16_VOLUME_ID_OFFSET] != VolumeId) &&\r
-      (*(UINT32 *) &BootSector[FAT32_VOLUME_ID_OFFSET] != VolumeId)\r
-      ) {\r
-    Status = EFI_NOT_FOUND;\r
-    goto ErrHandle;\r
-  }\r
-\r
-  *Device = DuplicateDevicePath (DevicePathFromHandle (SimpleFileSystemHandle));\r
-  ASSERT (*Device != NULL);\r
-\r
-ErrHandle:\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-CheckStoreExists (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *Device\r
-  )\r
-{\r
-  EFI_HANDLE                        Handle;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *Volume;\r
-  EFI_STATUS                        Status;\r
-\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  &Device, \r
-                  &Handle\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID **) &Volume\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-// this routine is still running in BS period, no limitation\r
-// call FileInitStorage(), which load variable content file to memory\r
-// read the store_header, init store_header if it has not been inited (read sth. about format/heathy)\r
-// reclaim space using scratch memory\r
-\r
-VOID\r
-EFIAPI\r
-OnSimpleFileSystemInstall (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     HandleSize;\r
-  EFI_HANDLE                Handle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Device;\r
-  VS_DEV                    *Dev;\r
-  EFI_FILE_PROTOCOL         *File;\r
-  UINTN                     NumBytes;\r
-\r
-  Dev = (VS_DEV *) Context;\r
-  \r
-  if (VAR_FILE_DEVICEPATH (Dev) != NULL &&\r
-      !EFI_ERROR (CheckStoreExists (VAR_FILE_DEVICEPATH (Dev)))\r
-     ) {\r
-    DEBUG ((EFI_D_ERROR, "FileStorage: Already mapped!\n"));\r
-    return ;\r
-  }\r
-\r
-  while (TRUE) {\r
-    HandleSize = sizeof (EFI_HANDLE);\r
-    Status = gBS->LocateHandle (\r
-                    ByRegisterNotify,\r
-                    NULL,\r
-                    mSFSRegistration,\r
-                    &HandleSize,\r
-                    &Handle\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return ;\r
-    }\r
-    \r
-    Status = CheckStore (Handle, VAR_FILE_VOLUMEID (Dev), &Device);\r
-    if (!EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  VAR_FILE_DEVICEPATH (Dev) = Device;\r
-  Status = OpenStore (\r
-             VAR_FILE_DEVICEPATH (Dev), \r
-             VAR_FILE_FILEPATH (Dev), \r
-             EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ | EFI_FILE_MODE_CREATE,\r
-             &File\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  NumBytes = Dev->Size;\r
-  Status = File->Write (File, &NumBytes, VAR_DATA_PTR (Dev));\r
-  ASSERT_EFI_ERROR (Status);\r
-  FileClose (File);\r
-  DEBUG ((EFI_D_ERROR, "FileStorage: Mapped to file!\n"));\r
-}\r
-\r
-EFI_STATUS\r
-FileStorageConstructor (\r
-  OUT VARIABLE_STORAGE      **VarStore,\r
-  OUT EFI_EVENT_NOTIFY      *GoVirtualEvent,\r
-  IN  EFI_PHYSICAL_ADDRESS  NvStorageBase,\r
-  IN  UINTN                 Size,\r
-  IN  UINT32                VolumeId,\r
-  IN  CHAR16                *FilePath\r
-  )\r
-{\r
-  VS_DEV                    *Dev;\r
-  EFI_STATUS                Status;\r
-  EFI_EVENT                 Event;\r
-\r
-  Status = gBS->AllocatePool (EfiRuntimeServicesData, sizeof(VS_DEV), (VOID **) &Dev);\r
-  ASSERT_EFI_ERROR (Status);\r
-  ZeroMem (Dev, sizeof(VS_DEV));\r
-\r
-  Dev->Signature          = VS_DEV_SIGNATURE;\r
-  Dev->Size               = Size;\r
-  VAR_DATA_PTR (Dev)      = (UINT8 *) (UINTN) NvStorageBase;\r
-  VAR_FILE_VOLUMEID (Dev) = VolumeId;\r
-  StrCpy (VAR_FILE_FILEPATH (Dev), FilePath);\r
-  Dev->VarStore.Erase     = FileEraseStore;\r
-  Dev->VarStore.Write     = FileWriteStore;\r
-\r
-  DEBUG ((EFI_D_ERROR, "FileStorageConstructor(0x%0x:0x%0x): added!\n", NvStorageBase, Size));\r
-\r
-  // add notify on SFS's installation.\r
-\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  OnSimpleFileSystemInstall,\r
-                  Dev,\r
-                  &Event\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->RegisterProtocolNotify (\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  Event,\r
-                  &mSFSRegistration\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  *VarStore       = &Dev->VarStore;\r
-  *GoVirtualEvent = OnVirtualAddressChangeFs;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FileEraseStore(\r
-  IN VARIABLE_STORAGE   *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  VS_DEV                  *Dev;\r
-  EFI_FILE_PROTOCOL       *File;\r
-  UINTN                   NumBytes;\r
-\r
-  Status = EFI_SUCCESS;\r
-  Dev    = DEV_FROM_THIS(This);\r
-\r
-  SetMem (VAR_DATA_PTR (Dev), Dev->Size, VAR_DEFAULT_VALUE);\r
-\r
-  if (!EfiAtRuntime () && VAR_FILE_DEVICEPATH (Dev) != NULL) {\r
-    Status = OpenStore (\r
-               VAR_FILE_DEVICEPATH (Dev), \r
-               VAR_FILE_FILEPATH (Dev), \r
-               EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ,\r
-               &File\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-    NumBytes = Dev->Size;\r
-    Status = File->Write (File, &NumBytes, VAR_DATA_PTR (Dev));\r
-    ASSERT_EFI_ERROR (Status);\r
-    FileClose (File);\r
-  }\r
-  \r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FileWriteStore (\r
-  IN VARIABLE_STORAGE     *This,\r
-  IN UINTN                Offset,\r
-  IN UINTN                BufferSize,\r
-  IN VOID                 *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  VS_DEV                  *Dev;\r
-  EFI_FILE_PROTOCOL       *File;\r
-\r
-  Status = EFI_SUCCESS;\r
-  Dev    = DEV_FROM_THIS(This);\r
-\r
-  ASSERT (Buffer != NULL);\r
-  ASSERT (Offset + BufferSize <= Dev->Size);\r
-\r
-  CopyMem (VAR_DATA_PTR (Dev) + Offset, Buffer, BufferSize);\r
-  \r
-  if (!EfiAtRuntime () && VAR_FILE_DEVICEPATH (Dev) != NULL) {\r
-    Status = OpenStore (\r
-               VAR_FILE_DEVICEPATH (Dev), \r
-               VAR_FILE_FILEPATH (Dev), \r
-               EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ,\r
-               &File\r
-               );\r
-    Status = File->SetPosition (File, Offset);\r
-    ASSERT_EFI_ERROR (Status);\r
-    Status = File->Write (File, &BufferSize, Buffer);\r
-    ASSERT_EFI_ERROR (Status);\r
-    FileClose (File);\r
-  }\r
-  return Status;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-OnVirtualAddressChangeFs (\r
-  IN EFI_EVENT            Event,\r
-  IN VOID                 *Context\r
-  )\r
-{\r
-  VS_DEV  *Dev;\r
-\r
-  Dev = DEV_FROM_THIS (Context);\r
-\r
-  EfiConvertPointer (0, (VOID **) &VAR_DATA_PTR (Dev));\r
-  EfiConvertPointer (0, (VOID **) &Dev->VarStore.Erase);\r
-  EfiConvertPointer (0, (VOID **) &Dev->VarStore.Write);\r
-}\r
-\r
-EFI_STATUS\r
-OpenStore (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *Device,\r
-  IN  CHAR16                    *FilePathName,\r
-  IN  UINT64                    OpenMode,\r
-  OUT EFI_FILE_PROTOCOL         **File\r
-  )\r
-{\r
-  EFI_HANDLE                        Handle;\r
-  EFI_FILE_HANDLE                   Root;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *Volume;\r
-  EFI_STATUS                        Status;\r
-\r
-  *File = NULL;\r
-\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  &Device, \r
-                  &Handle\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID **) &Volume\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open the root directory of the volume\r
-  //\r
-  Root = NULL;\r
-  Status = Volume->OpenVolume (\r
-                     Volume,\r
-                     &Root\r
-                     );\r
-  ASSERT_EFI_ERROR (Status);\r
-  ASSERT (Root != NULL);\r
-\r
-  //\r
-  // Open file\r
-  //\r
-  Status = Root->Open (\r
-                   Root,\r
-                   File,\r
-                   FilePathName,\r
-                   OpenMode,\r
-                   0\r
-                   );\r
-  if (EFI_ERROR (Status)) {\r
-    *File = NULL;\r
-  }\r
-\r
-  //\r
-  // Close the Root directory\r
-  //\r
-  Root->Close (Root);\r
-  return Status;\r
-}\r
diff --git a/DuetPkg/FSVariable/MemStorage.c b/DuetPkg/FSVariable/MemStorage.c
deleted file mode 100644 (file)
index cc0d546..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*++\r
-\r
-Caution: This file is used for Duet platform only, do not use them in real platform.\r
-All variable code, variable metadata, and variable data used by Duet platform are on \r
-disk. They can be changed by user. BIOS is not able to protoect those.\r
-Duet trusts all meta data from disk. If variable code, variable metadata and variable\r
-data is modified in inproper way, the behavior is undefined.\r
-\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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
-    MemStorage.c\r
-\r
-Abstract:\r
-\r
-    handles variable store/reads with emulated memory\r
-\r
-Revision History\r
-\r
---*/\r
-#include "FSVariable.h"\r
-\r
-VOID\r
-EFIAPI\r
-OnVirtualAddressChangeMs (\r
-  IN EFI_EVENT            Event,\r
-  IN VOID                 *Context\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MemEraseStore(\r
-  IN VARIABLE_STORAGE   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MemWriteStore (\r
-  IN VARIABLE_STORAGE   *This,\r
-  IN UINTN                Offset,\r
-  IN UINTN                BufferSize,\r
-  IN VOID                 *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-MemStorageConstructor (\r
-  OUT VARIABLE_STORAGE          **VarStore,\r
-  OUT EFI_EVENT_NOTIFY          *GoVirtualEvent,\r
-  IN  UINTN                     Size\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  VS_DEV                      *Dev;\r
-\r
-  Status = gBS->AllocatePool (EfiRuntimeServicesData, sizeof(VS_DEV), (VOID **) &Dev);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  ZeroMem (Dev, sizeof(VS_DEV));\r
-\r
-  Dev->Signature   = VS_DEV_SIGNATURE;\r
-  Dev->Size        = Size;\r
-\r
-  Dev->VarStore.Erase    = MemEraseStore;\r
-  Dev->VarStore.Write    = MemWriteStore;\r
-\r
-  Status = gBS->AllocatePool (EfiRuntimeServicesData, Size, (VOID **) &VAR_DATA_PTR (Dev));\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  DEBUG ((EFI_D_ERROR, "VStorage: Size = 0x%x\n", Size));\r
-  \r
-  *VarStore       = &Dev->VarStore;\r
-  *GoVirtualEvent = OnVirtualAddressChangeMs;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-OnVirtualAddressChangeMs (\r
-  IN EFI_EVENT            Event,\r
-  IN VOID                 *Context\r
-  )\r
-{\r
-  VS_DEV                  *Dev;\r
-\r
-  Dev = DEV_FROM_THIS (Context);\r
-\r
-  EfiConvertPointer (0, (VOID **)&VAR_DATA_PTR (Dev));\r
-  EfiConvertPointer (0, (VOID **)&Dev->VarStore.Erase);\r
-  EfiConvertPointer (0, (VOID **)&Dev->VarStore.Write);\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MemEraseStore(\r
-  IN VARIABLE_STORAGE   *This\r
-  )\r
-{\r
-  VS_DEV              *Dev;\r
-\r
-  Dev = DEV_FROM_THIS(This);\r
-  SetMem (VAR_DATA_PTR (Dev), Dev->Size, VAR_DEFAULT_VALUE);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MemWriteStore (\r
-  IN VARIABLE_STORAGE     *This,\r
-  IN UINTN                Offset,\r
-  IN UINTN                BufferSize,\r
-  IN VOID                 *UserBuffer\r
-  )\r
-{\r
-  VS_DEV              *Dev;\r
-\r
-  Dev = DEV_FROM_THIS(This);\r
-\r
-  ASSERT (Offset + BufferSize < Dev->Size);\r
-\r
-  // For better performance\r
-  if (VAR_DATA_PTR (Dev) + Offset != UserBuffer) {\r
-    CopyMem (VAR_DATA_PTR (Dev) + Offset, UserBuffer, BufferSize);\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/FSVariable/VariableStorage.h b/DuetPkg/FSVariable/VariableStorage.h
deleted file mode 100644 (file)
index 48cbd5d..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*++\r
-\r
-Caution: This file is used for Duet platform only, do not use them in real platform.\r
-All variable code, variable metadata, and variable data used by Duet platform are on \r
-disk. They can be changed by user. BIOS is not able to protoect those.\r
-Duet trusts all meta data from disk. If variable code, variable metadata and variable\r
-data is modified in inproper way, the behavior is undefined.\r
-\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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
-    VariableStorage.h\r
-\r
-Abstract:\r
-\r
-    handles variable store/reads with memory and file\r
-\r
-Revision History\r
-\r
---*/\r
-#ifndef _VARIABLE_STORAGE_H_\r
-#define _VARIABLE_STORAGE_H_\r
-\r
-#define VAR_DEFAULT_VALUE           (0xff)\r
-#define VAR_DEFAULT_VALUE_16        SIGNATURE_16 (VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE)\r
-#define VAR_DEFAULT_VALUE_32        SIGNATURE_32 (VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE, \\r
-                                                      VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE)\r
-\r
-typedef struct _VARIABLE_STORAGE VARIABLE_STORAGE;\r
-\r
-EFI_STATUS\r
-FileStorageConstructor (\r
-  OUT VARIABLE_STORAGE      **VarStore,\r
-  OUT EFI_EVENT_NOTIFY      *GoVirtualEvent,\r
-  IN  EFI_PHYSICAL_ADDRESS  NvStorageBase,\r
-  IN  UINTN                 Size,\r
-  IN  UINT32                VolumeId,\r
-  IN  CHAR16                *FilePath\r
-  );\r
-\r
-EFI_STATUS\r
-MemStorageConstructor (\r
-  OUT VARIABLE_STORAGE          **VarStore,\r
-  OUT EFI_EVENT_NOTIFY          *GoVirtualEvent,\r
-  IN  UINTN                     Size\r
-  );\r
-\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *ERASE_STORE) (\r
-  IN VARIABLE_STORAGE   *This\r
-  );\r
-\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *WRITE_STORE) (\r
-  IN VARIABLE_STORAGE   *This,\r
-  IN UINTN              Offset,\r
-  IN UINTN              BufferSize,\r
-  IN VOID               *Buffer\r
-  );\r
-\r
-struct _VARIABLE_STORAGE {\r
-\r
-  //\r
-  // Functions to access the storage\r
-  //\r
-  ERASE_STORE           Erase;\r
-  WRITE_STORE           Write;\r
-};\r
-\r
-typedef struct _VS_FILE_INFO {\r
-  UINT8                     *FileData;      // local buffer for reading acceleration\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;    // device having storage file\r
-  UINT32                    VolumeId;\r
-  CHAR16                    FilePath[256];\r
-} VS_FILE_INFO;\r
-\r
-typedef struct _VS_MEM_INFO {\r
-  UINT8                     *MemData;\r
-} VS_MEM_INFO;\r
-\r
-typedef struct _VS_DEV {\r
-  UINT32             Signature;\r
-  VARIABLE_STORAGE   VarStore;\r
-  UINTN              Size;\r
-  \r
-  union {\r
-    //\r
-    // finally visit FileInfo.FileData or MemInfo.MemData\r
-    //\r
-    UINT8            *Data;\r
-    \r
-    VS_FILE_INFO     FileInfo;\r
-    VS_MEM_INFO      MemInfo;\r
-  } Info;\r
-\r
-} VS_DEV;\r
-\r
-#define VS_DEV_SIGNATURE        SIGNATURE_32 ('$', 'V', 'S', 'D')\r
-#define DEV_FROM_THIS(a)        CR (a, VS_DEV, VarStore, VS_DEV_SIGNATURE)\r
-\r
-#define VAR_DATA_PTR(a)         ((a)->Info.Data)\r
-#define VAR_FILE_DEVICEPATH(a)  ((a)->Info.FileInfo.DevicePath)\r
-#define VAR_FILE_VOLUMEID(a)    ((a)->Info.FileInfo.VolumeId)\r
-#define VAR_FILE_FILEPATH(a)    ((a)->Info.FileInfo.FilePath)\r
-\r
-\r
-#endif\r
diff --git a/DuetPkg/FvbRuntimeService/DUETFwh.inf b/DuetPkg/FvbRuntimeService/DUETFwh.inf
deleted file mode 100644 (file)
index 050b80a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#   DUETFwh.inf\r
-#\r
-#  Abstract:\r
-#\r
-#    Component description file for DUET Module\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DuetFwh\r
-  FILE_GUID                      = 46E3256A-E5C1-4d2a-8282-505AFB41CE65\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = FvbInitialize\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[Sources]\r
-  FWBlockService.c\r
-  FwBlockService.h\r
-  FvbInfo.c\r
-  FileIo.c\r
-  FileIo.h\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  UefiRuntimeLib\r
-  HobLib\r
-\r
-[Guids]\r
-  gEfiFlashMapHobGuid\r
-\r
-[Protocols]\r
-  gEfiSimpleFileSystemProtocolGuid\r
-  gEfiFirmwareVolumeBlockProtocolGuid\r
-  gEfiBlockIoProtocolGuid\r
-\r
-[Depex]\r
-  TRUE\r
diff --git a/DuetPkg/FvbRuntimeService/FWBlockService.c b/DuetPkg/FvbRuntimeService/FWBlockService.c
deleted file mode 100644 (file)
index bc66327..0000000
+++ /dev/null
@@ -1,1659 +0,0 @@
-/**@file\r
-Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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
-#include "FWBlockService.h"\r
-#include "EfiFlashMap.h"\r
-#include "FileIo.h"\r
-#include "FlashLayout.h"\r
-\r
-ESAL_FWB_GLOBAL       *mFvbModuleGlobal;\r
-VOID                  *mSFSRegistration;\r
-#define TRY_ASSIGN(var, value)  if(var != NULL) {*var = value;}\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
-\r
-\r
-EFI_STATUS\r
-FlashFdWrite (\r
-  IN     UINTN                            Address,\r
-  IN     EFI_FW_VOL_INSTANCE              *FwhInstance,\r
-  IN OUT UINTN                            *NumBytes,\r
-  IN     UINT8                            *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Writes specified number of bytes from the input buffer to the address\r
-\r
-Arguments:\r
-\r
-Returns: \r
-\r
---*/\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_FILE_PROTOCOL   *File;\r
-  UINTN               FileOffset;\r
-  UINTN               BufferForFile;\r
-  UINTN               Length;\r
-\r
-  Status = EFI_SUCCESS;\r
-  CopyMem ((VOID *) Address, Buffer, *NumBytes);\r
-\r
-  if (!EfiAtRuntime () && (FwhInstance->Device != NULL)) {\r
-    Status = FileOpen (FwhInstance->Device, FwhInstance->MappedFile, &File, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE);\r
-    ASSERT_EFI_ERROR (Status);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (Address - FwhInstance->FvBase[FVB_PHYSICAL] < FwhInstance->Offset) {\r
-        FileOffset = 0;\r
-        BufferForFile = FwhInstance->FvBase[FVB_PHYSICAL] + FwhInstance->Offset;\r
-        Length = *NumBytes - (FwhInstance->Offset - (Address - FwhInstance->FvBase[FVB_PHYSICAL]));\r
-      } else {\r
-        FileOffset = Address - FwhInstance->FvBase[FVB_PHYSICAL] - FwhInstance->Offset;\r
-        BufferForFile = Address;\r
-        Length = *NumBytes;\r
-      }\r
-      \r
-      Status = FileWrite (File, FileOffset, BufferForFile, Length);\r
-      ASSERT_EFI_ERROR (Status);\r
-      FileClose (File);\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-FlashFdErase (\r
-  IN UINTN                                Address,\r
-  IN EFI_FW_VOL_INSTANCE                  *FwhInstance,\r
-  IN UINTN                                LbaLength\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Erase a certain block from address LbaWriteAddress\r
-\r
-Arguments:\r
-\r
-Returns: \r
-\r
---*/\r
-{\r
-  EFI_STATUS           Status;\r
-  EFI_FILE_PROTOCOL    *File;\r
-  UINTN                FileOffset;\r
-  UINTN                BufferForFile;\r
-  UINTN                Length;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  SetMem ((VOID *)Address, LbaLength, 0xff);\r
-\r
-  if (!EfiAtRuntime () && (FwhInstance->Device != NULL)) {\r
-    Status = FileOpen (FwhInstance->Device, FwhInstance->MappedFile, &File, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE);\r
-    ASSERT_EFI_ERROR (Status);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (Address - FwhInstance->FvBase[FVB_PHYSICAL] < FwhInstance->Offset) {\r
-        FileOffset = 0;\r
-        BufferForFile = FwhInstance->FvBase[FVB_PHYSICAL] + FwhInstance->Offset;\r
-        Length = LbaLength - (FwhInstance->Offset - (Address - FwhInstance->FvBase[FVB_PHYSICAL]));\r
-      } else {\r
-        FileOffset = Address - FwhInstance->FvBase[FVB_PHYSICAL] - FwhInstance->Offset;\r
-        BufferForFile = Address;\r
-        Length = LbaLength;\r
-      }\r
-      \r
-      Status = FileWrite (File, FileOffset, BufferForFile, Length);\r
-      ASSERT_EFI_ERROR (Status);\r
-      FileClose (File);\r
-    }\r
-  }\r
-  return Status;\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 (0, (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 (0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);\r
-    FwhInstance = (EFI_FW_VOL_INSTANCE *) ((UINTN)((UINT8 *)FwhInstance) + FwhInstance->VolumeHeader.HeaderLength\r
-                    + (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)));\r
-    Index++;\r
-  }\r
-\r
-  EfiConvertPointer (0, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);\r
-  EfiConvertPointer (0, (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 *) ((UINTN)((UINT8 *)FwhRecord) + FwhRecord->VolumeHeader.HeaderLength \r
-                     + (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)));\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_2                *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  OPTIONAL,\r
-  OUT UINTN                               *LbaLength   OPTIONAL,\r
-  OUT UINTN                               *NumOfBlocks OPTIONAL,\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 for writing\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.BlockMap[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->Length;\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
-\r
-      if (LbaAddress) {\r
-        *LbaAddress = FwhInstance->FvBase[Virtual] + Offset;\r
-      }\r
-\r
-      if (LbaLength) {\r
-        *LbaLength = BlockLength;\r
-      }\r
-\r
-      if (NumOfBlocks) {\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_2  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_FVB2_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, (VOID *) (LbaAddress + BlockOffset), (UINTN) *NumBytes);\r
-\r
-  return Status;\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_2  Attributes;\r
-  UINTN                 LbaAddress;\r
-  UINTN                 LbaLength;\r
-  EFI_FW_VOL_INSTANCE   *FwhInstance;\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS            ReturnStatus;\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
-  //\r
-  // Writes are enabled in the init routine itself\r
-  //\r
-  if (!FwhInstance->WriteEnabled) {\r
-    return EFI_ACCESS_DENIED;\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_FVB2_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
-  ReturnStatus = FlashFdWrite (\r
-                  LbaAddress + BlockOffset,\r
-                  FwhInstance,\r
-                  NumBytes,\r
-                  Buffer\r
-                  );\r
-  if (EFI_ERROR (ReturnStatus)) {\r
-    return ReturnStatus;\r
-  }\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_2  Attributes;\r
-  UINTN                 LbaAddress;\r
-  EFI_FW_VOL_INSTANCE   *FwhInstance;\r
-  UINTN                 LbaLength;\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
-  //\r
-  // Writes are enabled in the init routine itself\r
-  //\r
-  if (!FwhInstance->WriteEnabled) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Check if the FV is write enabled\r
-  //\r
-  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
-\r
-  if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Get the starting address of the block for erase. For debug reasons,\r
-  // LbaWriteAddress may not be the same as LbaAddress.\r
-  //\r
-  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return FlashFdErase (\r
-          LbaAddress,\r
-          FwhInstance,\r
-          LbaLength\r
-          );\r
-}\r
-\r
-EFI_STATUS\r
-FvbSetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  IN OUT EFI_FVB_ATTRIBUTES_2             *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_2 \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_2  OldAttributes;\r
-  EFI_FVB_ATTRIBUTES_2  *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_2 *) &(FwhInstance->VolumeHeader.Attributes);\r
-  OldAttributes = *AttribPtr;\r
-  Capabilities  = OldAttributes & EFI_FVB2_CAPABILITIES;\r
-  OldStatus     = OldAttributes & EFI_FVB2_STATUS;\r
-  NewStatus     = *Attributes & EFI_FVB2_STATUS;\r
-\r
-  //\r
-  // If firmware volume is locked, no status bit can be updated\r
-  //\r
-  if (OldAttributes & EFI_FVB2_LOCK_STATUS) {\r
-    if (OldStatus ^ NewStatus) {\r
-      return EFI_ACCESS_DENIED;\r
-    }\r
-  }\r
-  //\r
-  // Test read disable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test read enable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) {\r
-    if (NewStatus & EFI_FVB2_READ_STATUS) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test write disable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test write enable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) {\r
-    if (NewStatus & EFI_FVB2_WRITE_STATUS) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test lock\r
-  //\r
-  if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) {\r
-    if (NewStatus & EFI_FVB2_LOCK_STATUS) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  *AttribPtr  = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB2_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  CONST 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 CONST 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 CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL          *This,\r
-  OUT      EFI_FVB_ATTRIBUTES_2                        *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 CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL       *This,\r
-  IN OUT   EFI_FVB_ATTRIBUTES_2                     *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 CONST 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, UINTN);\r
-\r
-    //\r
-    // Check input parameters\r
-    //\r
-    if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) {\r
-      VA_END (args);\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, UINTN);\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 CONST 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 CONST 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
-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
-\r
-EFI_STATUS\r
-GetFvbHeader (\r
-  IN OUT EFI_PEI_HOB_POINTERS           *HobList,\r
-  OUT    EFI_FIRMWARE_VOLUME_HEADER     **FwVolHeader,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *BaseAddress     OPTIONAL,\r
-  OUT    UINT32                         *VolumeId        OPTIONAL,\r
-  OUT    CHAR16                         **MappedFile     OPTIONAL,\r
-  OUT    UINT32                         *ActuralSize     OPTIONAL,\r
-  OUT    UINT32                         *Offset          OPTIONAL,\r
-  OUT    BOOLEAN                        *WriteBack       OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_FLASH_MAP_FS_ENTRY_DATA *FlashMapEntry;\r
-  EFI_FLASH_SUBAREA_ENTRY     *FlashMapSubEntry;\r
-\r
-  Status        = EFI_SUCCESS;\r
-  *FwVolHeader  = NULL;\r
-  TRY_ASSIGN (WriteBack, FALSE);\r
-\r
-  DEBUG ((EFI_D_INFO, "Hob start is 0x%x\n", (UINTN)(*HobList).Raw));\r
-  (*HobList).Raw = GetNextGuidHob (&gEfiFlashMapHobGuid, (*HobList).Raw);\r
-  if ((*HobList).Raw == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  FlashMapEntry     = (EFI_FLASH_MAP_FS_ENTRY_DATA *) GET_GUID_HOB_DATA ((*HobList).Guid);\r
-  FlashMapSubEntry  = &FlashMapEntry->Entries[0];\r
-  \r
-  //\r
-  // Check if it is a "FVB" area\r
-  //\r
-  if (!CompareGuid (&FlashMapSubEntry->FileSystem, &gEfiFirmwareVolumeBlockProtocolGuid)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check if it is a "real" flash\r
-  //\r
-  if (FlashMapSubEntry->Attributes != (EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV)) {\r
-    return Status;\r
-  }\r
-\r
-  TRY_ASSIGN (BaseAddress, FlashMapSubEntry->Base);\r
-\r
-  //\r
-  // Cast buffer to FLASH_AREA_INFO to get extra information related to the special FVB driver\r
-  //\r
-  TRY_ASSIGN (VolumeId,    FlashMapEntry->VolumeId);\r
-  TRY_ASSIGN (ActuralSize, FlashMapEntry->ActuralSize);\r
-  TRY_ASSIGN (MappedFile, ((CHAR16 *) FlashMapEntry->FilePath));\r
-  TRY_ASSIGN (Offset,      FlashMapEntry->Offset);\r
-\r
-  DEBUG ((\r
-    EFI_D_INFO, \r
-    "FlashMap HOB: BaseAddress = 0x%x, Length = 0x%x, ActuralLength = 0x%x, Offset = 0x%x\n", \r
-    (UINTN) FlashMapSubEntry->Base, (UINTN) FlashMapSubEntry->Length, \r
-    (UINTN) FlashMapEntry->ActuralSize, (UINTN) FlashMapEntry->Offset\r
-  ));\r
-  DEBUG ((\r
-    EFI_D_INFO,\r
-    "FlashMap HOB: VolumeId = 0x%lx, MappedFile = %s\n",\r
-    (UINTN) FlashMapEntry->VolumeId, (UINTN) FlashMapEntry->FilePath\r
-  ));\r
-  *FwVolHeader  = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (FlashMapSubEntry->Base);\r
-  Status        = ValidateFvHeader (*FwVolHeader);\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Get FvbInfo\r
-    //\r
-    TRY_ASSIGN (WriteBack, TRUE);\r
-    Status = GetFvbInfo (FlashMapSubEntry->Length, FwVolHeader);\r
-    DEBUG ((EFI_D_ERROR, "Fvb: FV header invalid, GetFvbInfo - %r\n", Status));\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-OnSimpleFileSystemInstall (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     HandleSize;\r
-  EFI_HANDLE                Handle;\r
-  UINTN                     Instance;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Device;\r
-  EFI_FILE_PROTOCOL         *File;\r
-  EFI_FW_VOL_INSTANCE       *FwhInstance;\r
-  while (TRUE) {\r
-    HandleSize = sizeof (EFI_HANDLE);\r
-    Status = gBS->LocateHandle (\r
-                    ByRegisterNotify,\r
-                    NULL,\r
-                    mSFSRegistration,\r
-                    &HandleSize,\r
-                    &Handle\r
-                    );\r
-    if (Status == EFI_NOT_FOUND) {\r
-      break;\r
-    }\r
-    DEBUG ((EFI_D_ERROR, "Fwh: New FileSystem Installed!\n"));\r
-    ASSERT_EFI_ERROR (Status);\r
-    //\r
-    // Check if this is the storage we care about, and store it in FwhInstance\r
-    //\r
-    for (Instance = 0; Instance < mFvbModuleGlobal->NumFv; ++Instance) {\r
-      Status = GetFvbInstance (Instance, mFvbModuleGlobal, &FwhInstance, FALSE);\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      if (FwhInstance->MappedFile[0] == L'\0') {\r
-        //\r
-        // The instance of FVB isn't mapped to file.\r
-        //\r
-        continue;\r
-      }\r
-\r
-      if ((FwhInstance->Device != NULL) && \r
-          !EFI_ERROR (CheckStoreExists (FwhInstance->Device))\r
-          ) {\r
-        //\r
-        // The instance of FVB has already associated to a device\r
-        //  and the device is not removed from system.\r
-        //\r
-        DEBUG ((\r
-              EFI_D_ERROR, "Fwh: MappedFile FVB (0x%x:0x%x) - Already mapped, Skip!\n", \r
-              (UINTN) FwhInstance->FvBase[FVB_PHYSICAL],\r
-              (UINTN) FwhInstance->Offset\r
-              ));\r
-        continue;\r
-      }\r
-\r
-      Status = CheckStore (Handle, FwhInstance->VolumeId, &Device);\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Write back memory content to file\r
-        //\r
-        Status = FileOpen (Device, FwhInstance->MappedFile, &File, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ | EFI_FILE_MODE_CREATE);\r
-        ASSERT_EFI_ERROR (Status); \r
-        if (!EFI_ERROR (Status)) {\r
-          DEBUG ((\r
-                EFI_D_ERROR, "Fwh: MappedFile FVB (0x%x:0x%x) - Write back to mapped file!\n", \r
-                (UINTN) FwhInstance->FvBase[FVB_PHYSICAL],\r
-                (UINTN) FwhInstance->Offset\r
-                ));\r
-          Status = FileWrite (\r
-                     File, \r
-                     0, \r
-                     FwhInstance->FvBase[FVB_PHYSICAL] + FwhInstance->Offset, \r
-                     FwhInstance->ActuralSize - FwhInstance->Offset\r
-                     );\r
-          ASSERT_EFI_ERROR (Status); \r
-          if (!EFI_ERROR (Status)) {\r
-            if (FwhInstance->Device != NULL) {\r
-              gBS->FreePool (FwhInstance->Device);\r
-            }\r
-            FwhInstance->Device = Device;\r
-            DEBUG ((\r
-                  EFI_D_ERROR, "Fwh: MappedFile FVB (0x%x:0x%x) - Mapped!\n",\r
-                  (UINTN) FwhInstance->FvBase[FVB_PHYSICAL],\r
-                  (UINTN) FwhInstance->Offset\r
-                  ));\r
-          }\r
-          FileClose (File);\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-VOID\r
-FvbInstallSfsNotify (\r
-  VOID\r
-)\r
-{\r
-  EFI_STATUS Status;\r
-  EFI_EVENT  Event;\r
-\r
-  Status = gBS->CreateEvent (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  OnSimpleFileSystemInstall,\r
-                  NULL,\r
-                  &Event\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->RegisterProtocolNotify (\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  Event,\r
-                  &mSFSRegistration\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\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
-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_PEI_HOB_POINTERS                FirmwareVolumeHobList;\r
-  UINT32                              BufferSize;\r
-  EFI_FV_BLOCK_MAP_ENTRY              *PtrBlockMapEntry;\r
-  UINTN                               LbaAddress;\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
-  UINT32                              VolumeId;\r
-  CHAR16                              *MappedFile;\r
-  UINT32                              ActuralSize;\r
-  UINT32                              Offset;\r
-  BOOLEAN                             WriteBack;\r
-  UINTN                               NumOfBlocks;\r
-  UINTN                               HeaderLength;\r
-  BOOLEAN                             InstallSfsNotify;\r
-\r
-  HeaderLength     = 0;\r
-  InstallSfsNotify = FALSE;\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
-  // Calculate the total size for all firmware volume block instances\r
-  //\r
-  BufferSize            = 0;\r
-  FirmwareVolumeHobList.Raw = GetHobList();\r
-  do {\r
-    Status = GetFvbHeader (&FirmwareVolumeHobList, &FwVolHeader, NULL, NULL, NULL, NULL, NULL, NULL);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    FirmwareVolumeHobList.Raw = GET_NEXT_HOB (FirmwareVolumeHobList);\r
-\r
-    if (FwVolHeader) {\r
-      BufferSize += (FwVolHeader->HeaderLength + sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-    }\r
-  } while (TRUE);\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
-  FirmwareVolumeHobList.Raw   = GetHobList();\r
-  MaxLbaSize                  = 0;\r
-\r
-  //\r
-  // Fill in the private data of each firmware volume block instance\r
-  //\r
-  do {\r
-    Status = GetFvbHeader (\r
-               &FirmwareVolumeHobList, &FwVolHeader, \r
-               &BaseAddress, &VolumeId, &MappedFile, &ActuralSize, &Offset,\r
-               &WriteBack\r
-             );\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    FirmwareVolumeHobList.Raw = GET_NEXT_HOB (FirmwareVolumeHobList);\r
-\r
-    if (!FwVolHeader) {\r
-      continue;\r
-    }\r
-    \r
-    CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);\r
-    FwVolHeader                       = &(FwhInstance->VolumeHeader);\r
-\r
-    FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;\r
-    FwhInstance->FvBase[FVB_VIRTUAL]  = (UINTN) BaseAddress;\r
-    FwhInstance->Device               = NULL;\r
-    FwhInstance->Offset               = Offset;\r
-\r
-    if (*MappedFile != '\0') {\r
-      FwhInstance->VolumeId             = VolumeId;\r
-      FwhInstance->ActuralSize          = ActuralSize;\r
-      StrCpy (FwhInstance->MappedFile, MappedFile);\r
-\r
-      InstallSfsNotify = TRUE;\r
-    } else {\r
-      FwhInstance->VolumeId             = (UINT32) -1;\r
-      FwhInstance->ActuralSize          = (UINT32) -1;\r
-      FwhInstance->MappedFile[0]        = L'\0';\r
-    }\r
-    \r
-    DEBUG ((EFI_D_INFO, "FirmVolume Found! BaseAddress=0x%lx, VolumeId=0x%x, MappedFile=%s, Size=0x%x\n",\r
-           (UINTN) BaseAddress, VolumeId, MappedFile, ActuralSize));\r
-    //\r
-    // We may expose readonly FVB in future.\r
-    //\r
-    FwhInstance->WriteEnabled         = TRUE; // Ken: Why enable write?\r
-    EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);\r
-\r
-    LbaAddress  = (UINTN) FwhInstance->FvBase[0];\r
-    NumOfBlocks = 0;\r
-\r
-    if (FwhInstance->WriteEnabled) {\r
-      for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {\r
-\r
-        LbaAddress += PtrBlockMapEntry->NumBlocks * PtrBlockMapEntry->Length;\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->Length) {\r
-          MaxLbaSize = PtrBlockMapEntry->Length;\r
-        }\r
-\r
-        NumOfBlocks += PtrBlockMapEntry->NumBlocks;\r
-      }\r
-      //\r
-      //  Write back a healthy FV header\r
-      //\r
-      if (WriteBack) {\r
-        Status = FlashFdErase (\r
-                  (UINTN) FwhInstance->FvBase[0],\r
-                  FwhInstance,\r
-                  FwVolHeader->BlockMap->Length\r
-                  );\r
-\r
-        HeaderLength = (UINTN) FwVolHeader->HeaderLength;\r
-\r
-        Status = FlashFdWrite (\r
-                  (UINTN) FwhInstance->FvBase[0],\r
-                  FwhInstance,\r
-                  (UINTN *) &HeaderLength,\r
-                  (UINT8 *) FwVolHeader\r
-                  );\r
-\r
-        FwVolHeader->HeaderLength = (UINT16) HeaderLength;\r
-\r
-        DEBUG ((EFI_D_ERROR, "Fvb (0x%x): FV header invalid, write back - %r\n", (UINTN) FwhInstance->FvBase[0], Status));\r
-      }\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 (IsDevicePathEnd (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
-    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
-  } while (TRUE);\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
-  if (InstallSfsNotify) {\r
-    FvbInstallSfsNotify ();\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/FvbRuntimeService/FileIo.c b/DuetPkg/FvbRuntimeService/FileIo.c
deleted file mode 100644 (file)
index 11d1744..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/**@file\r
-Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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
-    FileIo.c\r
-\r
-Abstract:\r
-\r
-  File operation for Firmware volume block driver\r
-\r
-**/\r
-#include "FileIo.h"\r
-\r
-//\r
-// Variable storage hot plug is supported but there are still some restrictions:\r
-// After plugging the storage back,\r
-// 1. Still use memory as NV if newly plugged storage is not same as the original one\r
-// 2. Still use memory as NV if there are some update operation during storage is unplugged.\r
-//\r
-\r
-\r
-EFI_STATUS\r
-FileWrite (\r
-  IN EFI_FILE_PROTOCOL  *File,\r
-  IN UINTN              Offset,\r
-  IN UINTN              Buffer,\r
-  IN UINTN              Size\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  Status = File->SetPosition (File, Offset);\r
-  ASSERT_EFI_ERROR (Status);\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = File->Write (File, &Size, (VOID *) Buffer);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-CheckStore (\r
-  IN  EFI_HANDLE                 SimpleFileSystemHandle,\r
-  IN  UINT32                     VolumeId,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL   **Device\r
-  )\r
-{\r
-#define BLOCK_SIZE              0x200\r
-#define FAT16_VOLUME_ID_OFFSET  39\r
-#define FAT32_VOLUME_ID_OFFSET  67\r
-  EFI_STATUS                      Status;\r
-  EFI_BLOCK_IO_PROTOCOL           *BlkIo;\r
-  UINT8                           BootSector[BLOCK_SIZE];\r
-\r
-  *Device = NULL;\r
-  Status  = gBS->HandleProtocol (\r
-                   SimpleFileSystemHandle,\r
-                   &gEfiBlockIoProtocolGuid, // BlockIo should be supported if it supports SimpleFileSystem\r
-                   (VOID*)&BlkIo\r
-                   );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrHandle;\r
-  }\r
-  if (!BlkIo->Media->MediaPresent) {\r
-    DEBUG ((EFI_D_ERROR, "FwhMappedFile: Media not present!\n"));\r
-    Status = EFI_NO_MEDIA;\r
-    goto ErrHandle;\r
-  }\r
-  if (BlkIo->Media->ReadOnly) {\r
-    DEBUG ((EFI_D_ERROR, "FwhMappedFile: Media is read-only!\n"));\r
-    Status = EFI_ACCESS_DENIED;\r
-    goto ErrHandle;\r
-  }\r
-\r
-  Status = BlkIo->ReadBlocks(\r
-                    BlkIo,\r
-                    BlkIo->Media->MediaId,\r
-                    0,\r
-                    BLOCK_SIZE,\r
-                    BootSector\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-  if ((*(UINT32 *) &BootSector[FAT16_VOLUME_ID_OFFSET] != VolumeId) &&\r
-      (*(UINT32 *) &BootSector[FAT32_VOLUME_ID_OFFSET] != VolumeId)\r
-      ) {\r
-    Status = EFI_NOT_FOUND;\r
-    goto ErrHandle;\r
-  }\r
-\r
-  *Device = DuplicateDevicePath (DevicePathFromHandle (SimpleFileSystemHandle));\r
-  ASSERT (*Device != NULL);\r
-\r
-ErrHandle:\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-CheckStoreExists (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *Device\r
-  )\r
-{\r
-  EFI_HANDLE                        Handle;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *Volume;\r
-  EFI_STATUS                        Status;\r
-\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  &Device, \r
-                  &Handle\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  &Volume\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-FileClose (\r
-  IN  EFI_FILE_PROTOCOL          *File\r
-  )\r
-{\r
-  File->Flush (File);\r
-  File->Close (File);\r
-}\r
-EFI_STATUS\r
-FileOpen (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *Device,\r
-  IN  CHAR16                     *MappedFile,\r
-  OUT EFI_FILE_PROTOCOL          **File,\r
-  IN  UINT64                     OpenMode\r
-  )\r
-{  \r
-  EFI_HANDLE                        Handle;\r
-  EFI_FILE_HANDLE                   Root;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *Volume;\r
-  EFI_STATUS                        Status;\r
-\r
-  *File = NULL;\r
-\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  &Device, \r
-                  &Handle\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  &Volume\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Open the root directory of the volume\r
-  //\r
-  Root = NULL;\r
-  Status = Volume->OpenVolume (\r
-                     Volume,\r
-                     &Root\r
-                     );\r
-  ASSERT_EFI_ERROR (Status);\r
-  ASSERT (Root != NULL);\r
-\r
-  //\r
-  // Open file\r
-  //\r
-  Status = Root->Open (\r
-                   Root,\r
-                   File,\r
-                   MappedFile,\r
-                   OpenMode,\r
-                   0\r
-                   );\r
-  if (EFI_ERROR (Status)) {\r
-    *File = NULL;\r
-  }\r
-\r
-  //\r
-  // Close the Root directory\r
-  //\r
-  Root->Close (Root);\r
-  return Status;\r
-}\r
diff --git a/DuetPkg/FvbRuntimeService/FileIo.h b/DuetPkg/FvbRuntimeService/FileIo.h
deleted file mode 100644 (file)
index 7323697..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/**@file\r
-Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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
-  FileIo.h\r
-  \r
-Abstract:\r
-\r
-  File operation for Firmware volume block driver\r
-\r
-**/\r
-#ifndef _FW_BLOCK_SERVICE_FILE_IO_H\r
-#define _FW_BLOCK_SERVICE_FILE_IO_H\r
-\r
-#include "FwBlockService.h"\r
-\r
-EFI_STATUS\r
-FileWrite (\r
-  IN EFI_FILE_PROTOCOL  *File,\r
-  IN UINTN              Offset,\r
-  IN UINTN              Buffer,\r
-  IN UINTN              Size\r
-  );\r
-\r
-EFI_STATUS\r
-CheckStore (\r
-  IN  EFI_HANDLE                 SimpleFileSystemHandle,\r
-  IN  UINT32                     VolumeId,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL   **Device\r
-  );\r
-\r
-EFI_STATUS\r
-CheckStoreExists (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *Device\r
-  );\r
-\r
-EFI_STATUS\r
-FileOpen (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL   *Device,\r
-  IN  CHAR16                     *MappedFile,\r
-  OUT EFI_FILE_PROTOCOL          **File,\r
-  IN  UINT64                     OpenMode\r
-  );\r
-\r
-VOID\r
-FileClose (\r
-  IN  EFI_FILE_PROTOCOL          *File\r
-  );\r
-\r
-#endif // _FW_BLOCK_SERVICE_FILE_IO_H\r
diff --git a/DuetPkg/FvbRuntimeService/FvbInfo.c b/DuetPkg/FvbRuntimeService/FvbInfo.c
deleted file mode 100644 (file)
index fa73783..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/**@file\r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-#include "FileIo.h"\r
-#include "FlashLayout.h"\r
-\r
-typedef struct {\r
-  UINT64                      FvLength;\r
-  EFI_FIRMWARE_VOLUME_HEADER  FvbInfo;\r
-  EFI_FV_BLOCK_MAP_ENTRY      End;\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
-  // Systen NvStorage FVB\r
-  //\r
-  {\r
-    NV_STORAGE_FVB_SIZE,\r
-    {\r
-      {\r
-        0,\r
-      },  // ZeroVector[16]\r
-      EFI_SYSTEM_NV_DATA_FV_GUID,\r
-      NV_STORAGE_FVB_SIZE,\r
-      EFI_FVH_SIGNATURE,\r
-      EFI_FVB2_READ_ENABLED_CAP |\r
-        EFI_FVB2_READ_STATUS |\r
-        EFI_FVB2_WRITE_ENABLED_CAP |\r
-        EFI_FVB2_WRITE_STATUS |\r
-        EFI_FVB2_ERASE_POLARITY,\r
-      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
-      0,  // CheckSum\r
-      0,  // ExtHeaderOffset\r
-      {\r
-        0,\r
-      },  // Reserved[1]\r
-      1,  // Revision\r
-      {\r
-        NV_STORAGE_FVB_BLOCK_NUM,\r
-        FV_BLOCK_SIZE,\r
-      }\r
-    },\r
-    {\r
-      0,\r
-      0\r
-    }\r
-  },\r
-  //\r
-  // System FTW FVB\r
-  //\r
-  {\r
-    NV_FTW_FVB_SIZE,\r
-    {\r
-      {\r
-        0,\r
-      },  // ZeroVector[16]\r
-      EFI_SYSTEM_NV_DATA_FV_GUID,\r
-      NV_FTW_FVB_SIZE,\r
-      EFI_FVH_SIGNATURE,\r
-      EFI_FVB2_READ_ENABLED_CAP |\r
-        EFI_FVB2_READ_STATUS |\r
-        EFI_FVB2_WRITE_ENABLED_CAP |\r
-        EFI_FVB2_WRITE_STATUS |\r
-        EFI_FVB2_ERASE_POLARITY,\r
-      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
-      0,  // CheckSum\r
-      0,  // ExtHeaderOffset\r
-      {\r
-        0,\r
-      },  // Reserved[1]\r
-      1,  // Revision\r
-      {\r
-        NV_FTW_FVB_BLOCK_NUM,\r
-        FV_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/DuetPkg/FvbRuntimeService/FwBlockService.h b/DuetPkg/FvbRuntimeService/FwBlockService.h
deleted file mode 100644 (file)
index b14f10a..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/**@file\r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-#ifndef _FW_BLOCK_SERVICE_H\r
-#define _FW_BLOCK_SERVICE_H\r
-\r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiDxe.h>\r
-\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-#include <Guid/EventGroup.h>\r
-#include <Guid/FirmwareFileSystem2.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Guid/SystemNvDataGuid.h>\r
-#include <Guid/FlashMapHob.h>\r
-#include <Guid/HobList.h>\r
-\r
-//\r
-// The Library classes this module consumes\r
-//\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-\r
-#define FWH_READ_LOCK                   (1 << 2)\r
-#define FWH_LOCK_DOWN                   (1 << 1)\r
-#define FWH_WRITE_LOCK                  1\r
-#define FWH_WRITE_STATE_STATUS          (1 << 7)\r
-#define FWH_ERASE_STATUS                (1 << 5)\r
-#define FWH_PROGRAM_STATUS              (1 << 4)\r
-#define FWH_VPP_STATUS                  (1 << 3)\r
-#define STALL_TIME                      5\r
-#define FWH_ERASE_STATUS_BITS           (FWH_ERASE_STATUS || FWH_VPP_STATUS)\r
-#define FWH_WRITE_STATUS_BITS           (FWH_WRITE_STATUS || FWH_VPP_STATUS)\r
-\r
-//\r
-// BugBug: Add documentation here for data structure!!!!\r
-//\r
-#define FVB_PHYSICAL  0\r
-#define FVB_VIRTUAL   1\r
-\r
-#define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \\r
-                              EFI_FVB2_READ_ENABLED_CAP | \\r
-                              EFI_FVB2_WRITE_DISABLED_CAP | \\r
-                              EFI_FVB2_WRITE_ENABLED_CAP | \\r
-                              EFI_FVB2_LOCK_CAP \\r
-                              )\r
-#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
-\r
-typedef struct {\r
-  EFI_LOCK                    FvbDevLock;\r
-  UINTN                       FvBase[2];\r
-  //\r
-  // We can treat VolumeSignature combined with MappedFile \r
-  //  as a unique key to locate the mapped file.\r
-#define MAX_PATH 256\r
-  UINT32                      VolumeId;\r
-  CHAR16                      MappedFile[MAX_PATH];\r
-  UINT32                      ActuralSize;\r
-  UINT32                      Offset;\r
-  \r
-  EFI_DEVICE_PATH_PROTOCOL    *Device; // only used in BS period, won't use after memory map changed\r
-  UINTN                       NumOfBlocks;\r
-  BOOLEAN                     WriteEnabled;\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            SIGNATURE_32 ('F', 'V', 'B', 'C')\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_FW_VOL_BLOCK_DEVICE;\r
-\r
-EFI_STATUS\r
-GetFvbInfo (\r
-  IN  EFI_PHYSICAL_ADDRESS              FvBaseAddress,\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER        **FvbInfo\r
-  );\r
-\r
-EFI_STATUS\r
-EnableFvbWrites (\r
-  IN  BOOLEAN   EnableWrites\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformGetFvbWriteBase (\r
-  IN  UINTN     CurrentBaseAddress,\r
-  IN  UINTN     *NewBaseAddress,\r
-  IN  BOOLEAN   *WriteEnabled\r
-  );\r
-\r
-EFI_STATUS\r
-EnablePlatformFvb (\r
-  VOID\r
-  );\r
-\r
-BOOLEAN\r
-SetPlatformFvbLock (\r
-  IN UINTN  LbaAddress\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
-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
-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
-EFI_STATUS\r
-FvbSetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  IN OUT EFI_FVB_ATTRIBUTES_2             *Attributes,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  );\r
-\r
-EFI_STATUS\r
-FvbGetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  OUT EFI_FVB_ATTRIBUTES_2                *Attributes,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\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
-EFI_STATUS\r
-EFIAPI\r
-FvbInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-FvbClassAddressChangeEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  );\r
-\r
-EFI_STATUS\r
-FvbSpecificInitialize (\r
-  IN  ESAL_FWB_GLOBAL   *mFvbModuleGlobal\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
-// Protocol APIs\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL          *This,\r
-  OUT      EFI_FVB_ATTRIBUTES_2                        *Attributes\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolSetAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL       *This,\r
-  IN OUT   EFI_FVB_ATTRIBUTES_2                     *Attributes\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetPhysicalAddress (\r
-  IN  CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL          *This,\r
-  OUT       EFI_PHYSICAL_ADDRESS                        *Address\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetBlockSize (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
-  IN  EFI_LBA                                     Lba,\r
-  OUT UINTN                                       *BlockSize,\r
-  OUT UINTN                                       *NumOfBlocks\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolRead (\r
-  IN CONST 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
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolWrite (\r
-  IN CONST 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
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolEraseBlocks (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
-  ...  \r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/EfiFlashMap.h b/DuetPkg/Include/EfiFlashMap.h
deleted file mode 100644 (file)
index f36ee3b..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-  EfiFlashMap.h\r
-\r
-Abstract:\r
-\r
-  Defines for the EFI Flash Map functionality\r
-  \r
-**/\r
-\r
-#ifndef _EFI_FLASHMAP_H_\r
-#define _EFI_FLASHMAP_H_\r
-\r
-//\r
-// Definition for flash map GUIDed HOBs\r
-//\r
-typedef UINT32  EFI_FLASH_AREA_ATTRIBUTES;\r
-\r
-#define EFI_FLASH_AREA_FV           0x0001\r
-#define EFI_FLASH_AREA_SUBFV        0x0002\r
-#define EFI_FLASH_AREA_MEMMAPPED_FV 0x0004\r
-#define EFI_FLASH_AREA_REQUIRED     0x0008\r
-#define EFI_FLASH_AREA_CORRUPT      0x0010\r
-\r
-typedef UINT8   EFI_FLASH_AREA_TYPE;\r
-\r
-#define EFI_FLASH_AREA_RECOVERY_BIOS  0x0   // Recovery code\r
-#define EFI_FLASH_AREA_MAIN_BIOS      0x1   // Regular BIOS code\r
-#define EFI_FLASH_AREA_PAL_B          0x2   // PAL-B\r
-#define EFI_FLASH_AREA_RESERVED_03    0x3   // Reserved for backwards compatibility\r
-#define EFI_FLASH_AREA_RESERVED_04    0x4   // Reserved for backwards compatibility\r
-#define EFI_FLASH_AREA_DMI_FRU        0x5   // DMI FRU information\r
-#define EFI_FLASH_AREA_OEM_BINARY     0x6   // OEM Binary Code/data\r
-#define EFI_FLASH_AREA_RESERVED_07    0x7   // Reserved for backwards compatibility\r
-#define EFI_FLASH_AREA_RESERVED_08    0x8   // Reserved for backwards compatibility\r
-#define EFI_FLASH_AREA_RESERVED_09    0x9   // Reserved for backwards compatibility\r
-#define EFI_FLASH_AREA_RESERVED_0A    0x0a  // Reserved for backwards compatibility\r
-#define EFI_FLASH_AREA_EFI_VARIABLES  0x0b  // EFI variables\r
-#define EFI_FLASH_AREA_MCA_LOG        0x0c  // MCA error log\r
-#define EFI_FLASH_AREA_SMBIOS_LOG     0x0d  // SMBIOS error log\r
-#define EFI_FLASH_AREA_FTW_BACKUP     0x0e  // A backup block during FTW operations\r
-#define EFI_FLASH_AREA_FTW_STATE      0x0f  // State information during FTW operations\r
-#define EFI_FLASH_AREA_UNUSED         0x0fd // Not used\r
-#define EFI_FLASH_AREA_GUID_DEFINED   0x0fe // Usage defined by a GUID\r
-#pragma pack(1)\r
-//\r
-// An individual sub-area Entry.\r
-// A single flash area may consist of  more than one sub-area.\r
-//\r
-/**\r
-typedef struct {\r
-  EFI_FLASH_AREA_ATTRIBUTES Attributes;\r
-  UINT32                    Reserved;\r
-  EFI_PHYSICAL_ADDRESS      Base;\r
-  EFI_PHYSICAL_ADDRESS      Length;\r
-  EFI_GUID                  FileSystem;\r
-} EFI_FLASH_SUBAREA_ENTRY;\r
-\r
-typedef struct {\r
-  UINT8                   Reserved[3];\r
-  EFI_FLASH_AREA_TYPE     AreaType;\r
-  EFI_GUID                AreaTypeGuid;\r
-  UINT32                  NumEntries;\r
-  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
-} EFI_FLASH_MAP_ENTRY_DATA;\r
-\r
-typedef struct {\r
-  UINT8                   Reserved[3];\r
-  EFI_FLASH_AREA_TYPE     AreaType;\r
-  EFI_GUID                AreaTypeGuid;\r
-  UINT32                  NumberOfEntries;\r
-  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
-  //\r
-  // Extended Hob data.\r
-  //\r
-  // VolumeId and FilePath indicating a unique file.\r
-  //\r
-  UINT32                  VolumeId;\r
-  CHAR16                  FilePath[256];\r
-  UINT32                  ActuralSize;\r
-  UINT32                  Offset;\r
-} EFI_FLASH_MAP_FS_ENTRY_DATA;\r
-\r
-typedef struct {\r
-  EFI_HOB_GENERIC_HEADER  Header;\r
-  EFI_GUID                Name;\r
-  UINT8                   Reserved[3];\r
-  EFI_FLASH_AREA_TYPE     AreaType;\r
-  EFI_GUID                AreaTypeGuid;\r
-  UINT32                  NumEntries;\r
-  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
-} EFI_HOB_FLASH_MAP_ENTRY_TYPE;\r
-\r
-//\r
-// Internal definitions\r
-//\r
-typedef struct {\r
-  UINT8                   Reserved[3];\r
-  EFI_FLASH_AREA_TYPE     AreaType;\r
-  EFI_GUID                AreaTypeGuid;\r
-  UINT32                  NumberOfEntries;\r
-  EFI_FLASH_SUBAREA_ENTRY SubAreaData;\r
-} EFI_FLASH_AREA_HOB_DATA;\r
-\r
-typedef struct {\r
-  UINTN                     Base;\r
-  UINTN                     Length;\r
-  EFI_FLASH_AREA_ATTRIBUTES Attributes;\r
-  EFI_FLASH_AREA_TYPE       AreaType;\r
-  UINT8                     Reserved[3];\r
-  EFI_GUID                  AreaTypeGuid;\r
-} EFI_FLASH_AREA_DATA;\r
-**/\r
-\r
-typedef struct {\r
-  EFI_FLASH_AREA_ATTRIBUTES Attributes;\r
-  UINT32                    Reserved;\r
-  EFI_PHYSICAL_ADDRESS      Base;\r
-  EFI_PHYSICAL_ADDRESS      Length;\r
-  EFI_GUID                  FileSystem;\r
-} EFI_FLASH_SUBAREA_ENTRY;\r
-\r
-typedef struct {\r
-  UINT8                   Reserved[3];\r
-  EFI_FLASH_AREA_TYPE     AreaType;\r
-  EFI_GUID                AreaTypeGuid;\r
-  UINT32                  NumberOfEntries;\r
-  EFI_FLASH_SUBAREA_ENTRY Entries[1];\r
-  //\r
-  // Extended Hob data.\r
-  //\r
-  // VolumeId and FilePath indicating a unique file.\r
-  //\r
-  UINT32                  VolumeId;\r
-  CHAR16                  FilePath[258];\r
-  UINT32                  ActuralSize;\r
-  UINT32                  Offset;\r
-} EFI_FLASH_MAP_FS_ENTRY_DATA;\r
-\r
-#pragma pack()\r
-\r
-#endif // #ifndef _EFI_FLASHMAP_H_\r
diff --git a/DuetPkg/Include/EfiLdrHandoff.h b/DuetPkg/Include/EfiLdrHandoff.h
deleted file mode 100644 (file)
index 9bbe94e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  EfiLdrHandoff.h\r
-\r
-Abstract:\r
-\r
-Revision History:\r
-\r
-**/\r
-\r
-#ifndef _EFILDR_HANDOFF_H_\r
-#define _EFILDR_HANDOFF_H_\r
-\r
-#include <Base.h>\r
-#include <Uefi.h>\r
-\r
-#define EFILDR_BASE_SEGMENT 0x2000\r
-#define EFILDR_LOAD_ADDRESS        (EFILDR_BASE_SEGMENT << 4)\r
-#define EFILDR_HEADER_ADDRESS      (EFILDR_LOAD_ADDRESS+0x2000)\r
-\r
-#define EFILDR_CB_VA        0x00\r
-\r
-typedef struct _EFILDRHANDOFF {\r
-    UINTN                    MemDescCount;\r
-    EFI_MEMORY_DESCRIPTOR   *MemDesc;\r
-    VOID                    *BfvBase;\r
-    UINTN                   BfvSize;\r
-    VOID                    *DxeIplImageBase;\r
-    UINTN                   DxeIplImageSize;\r
-    VOID                    *DxeCoreImageBase;\r
-    UINTN                   DxeCoreImageSize;\r
-    VOID                    *DxeCoreEntryPoint;\r
-} EFILDRHANDOFF;\r
-\r
-typedef struct {\r
-    UINT32       CheckSum;\r
-    UINT32       Offset;\r
-    UINT32       Length;\r
-    UINT8        FileName[52];\r
-} EFILDR_IMAGE;\r
-\r
-typedef struct {          \r
-    UINT32       Signature;     \r
-    UINT32       HeaderCheckSum;\r
-    UINT32       FileLength;\r
-    UINT32       NumberOfImages;\r
-} EFILDR_HEADER;\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/FlashLayout.h b/DuetPkg/Include/FlashLayout.h
deleted file mode 100644 (file)
index 777adea..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-**/\r
-\r
-#ifndef _EFI_FLASH_LAYOUT\r
-#define _EFI_FLASH_LAYOUT\r
-\r
-#include "EfiFlashMap.h"\r
-\r
-//\r
-// Firmware Volume Information for DUET\r
-//\r
-#define FV_BLOCK_SIZE               0x10000\r
-#define FV_BLOCK_MASK               0x0FFFF\r
-#define EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH  (sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY))\r
-\r
-#define NV_STORAGE_SIZE             0x4000\r
-#define NV_STORAGE_FVB_SIZE         ((NV_STORAGE_SIZE + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH + FV_BLOCK_MASK) & ~FV_BLOCK_MASK)\r
-#define NV_STORAGE_FVB_BLOCK_NUM    (NV_STORAGE_FVB_SIZE / FV_BLOCK_SIZE)\r
-\r
-#define NV_FTW_WORKING_SIZE         0x2000\r
-#define NV_FTW_SPARE_SIZE           0x10000\r
-#define NV_FTW_FVB_SIZE             ((NV_FTW_WORKING_SIZE + NV_FTW_SPARE_SIZE + EFI_RUNTIME_UPDATABLE_FV_HEADER_LENGTH + FV_BLOCK_MASK) & ~FV_BLOCK_MASK)\r
-#define NV_FTW_FVB_BLOCK_NUM        (NV_FTW_FVB_SIZE / FV_BLOCK_SIZE)\r
-\r
-#define NV_STORAGE_FILE_PATH        L".\\Efivar.bin"\r
-#endif // _EFI_FLASH_LAYOUT\r
diff --git a/DuetPkg/Include/Guid/AcpiDescription.h b/DuetPkg/Include/Guid/AcpiDescription.h
deleted file mode 100644 (file)
index 96c7488..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-    AcpiDescription.h\r
-    \r
-Abstract:\r
-\r
-\r
-   GUIDs used for ACPI Description\r
-\r
-**/\r
-\r
-#ifndef _EFI_ACPI_DESCRIPTION_H_\r
-#define _EFI_ACPI_DESCRIPTION_H_\r
-\r
-#include <IndustryStandard/Acpi.h>\r
-\r
-#define EFI_ACPI_DESCRIPTION_GUID \\r
-  { \\r
-  0x3c699197, 0x93c, 0x4c69, {0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9} \\r
-  }\r
-\r
-//\r
-// Following structure defines ACPI Description information.\r
-// This information is platform specific, may be consumed by DXE generic driver.\r
-//\r
-#pragma pack(1)\r
-typedef struct _EFI_ACPI_DESCRIPTION {\r
-  //\r
-  // For Timer\r
-  //\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   PM_TMR_BLK;\r
-  UINT8                                    PM_TMR_LEN;\r
-  UINT8                                    TMR_VAL_EXT;\r
-\r
-  //\r
-  // For RTC\r
-  //\r
-  UINT8                                    DAY_ALRM;\r
-  UINT8                                    MON_ALRM;\r
-  UINT8                                    CENTURY;\r
-\r
-  //\r
-  // For Reset\r
-  //\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   RESET_REG;\r
-  UINT8                                    RESET_VALUE;\r
-\r
-  //\r
-  // For Shutdown\r
-  //\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   PM1a_EVT_BLK;\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   PM1b_EVT_BLK;\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   PM1a_CNT_BLK;\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   PM1b_CNT_BLK;\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   PM2_CNT_BLK;\r
-  UINT8                                    PM1_EVT_LEN;\r
-  UINT8                                    PM1_CNT_LEN;\r
-  UINT8                                    PM2_CNT_LEN;\r
-  UINT8                                    SLP_TYPa;\r
-  UINT8                                    SLP_TYPb;\r
-\r
-  //\r
-  // For sleep\r
-  //\r
-  UINT8                                    SLP1_TYPa;\r
-  UINT8                                    SLP1_TYPb;\r
-  UINT8                                    SLP2_TYPa;\r
-  UINT8                                    SLP2_TYPb;\r
-  UINT8                                    SLP3_TYPa;\r
-  UINT8                                    SLP3_TYPb;\r
-  UINT8                                    SLP4_TYPa;\r
-  UINT8                                    SLP4_TYPb;\r
-\r
-  //\r
-  // GPE\r
-  //\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   GPE0_BLK;\r
-  EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE   GPE1_BLK;\r
-  UINT8                                    GPE0_BLK_LEN;\r
-  UINT8                                    GPE1_BLK_LEN;\r
-  UINT8                                    GPE1_BASE;\r
-\r
-  //\r
-  // IAPC Boot Arch\r
-  //\r
-  UINT16                                   IAPC_BOOT_ARCH;\r
-\r
-  //\r
-  // Flags\r
-  //\r
-  UINT32                                   Flags;\r
-\r
-} EFI_ACPI_DESCRIPTION;\r
-#pragma pack()\r
-\r
-extern EFI_GUID gEfiAcpiDescriptionGuid;\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/Guid/ConsoleOutConfig.h b/DuetPkg/Include/Guid/ConsoleOutConfig.h
deleted file mode 100644 (file)
index 48861a5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/**@file\r
-  Setup Variable data structure for Duet platform.\r
-\r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#ifndef __DUET_CONSOLEOUT_CONFIG_H__\r
-#define __DUET_CONSOLEOUT_CONFIG_H__\r
-\r
-#define DUET_CONSOLEOUT_CONFIG_GUID  \\r
-  { 0xED150714, 0xDF30, 0x407D, { 0xB2, 0x4A, 0x4B, 0x74, 0x2F, 0xD5, 0xCE, 0xA2 } }\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  //\r
-  // Console output mode\r
-  //\r
-  UINT32        ConOutColumn;\r
-  UINT32        ConOutRow;\r
-} DUET_CONSOLEOUT_CONFIG;\r
-#pragma pack()\r
-\r
-extern EFI_GUID   gDuetConsoleOutConfigGuid;\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/Guid/DxeCoreFileName.h b/DuetPkg/Include/Guid/DxeCoreFileName.h
deleted file mode 100644 (file)
index 24c0a15..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/** @file\r
-  Guid is EDKII DxeCore moudle GUID.\r
-\r
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#ifndef __DXE_CORE_FILE_NAME__\r
-#define __DXE_CORE_FILE_NAME__\r
-\r
-#define DXE_CORE_FILE_NAME_GUID \\r
-  { 0xD6A2CB7F, 0x6A18, 0x4e2f, {0xB4, 0x3B, 0x99, 0x20, 0xA7, 0x33, 0x70, 0x0A }}\r
-\r
-extern EFI_GUID gDxeCoreFileNameGuid;\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/Guid/FlashMapHob.h b/DuetPkg/Include/Guid/FlashMapHob.h
deleted file mode 100644 (file)
index 8ae0ad8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
-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
-  FlashMapHob.h\r
-    \r
-Abstract:\r
-\r
-  GUID used for Flash Map HOB entries in the HOB list.\r
-\r
-**/\r
-\r
-#ifndef _FLASH_MAP_HOB_GUID_H_\r
-#define _FLASH_MAP_HOB_GUID_H_\r
-\r
-//\r
-// Definitions for Flash Map\r
-//\r
-#define EFI_FLASH_MAP_HOB_GUID \\r
-  { 0xb091e7d2, 0x5a0, 0x4198, {0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59} }\r
-\r
-extern EFI_GUID gEfiFlashMapHobGuid;\r
-\r
-#endif // _FLASH_MAP_HOB_GUID_H_\r
diff --git a/DuetPkg/Include/Guid/LdrMemoryDescriptor.h b/DuetPkg/Include/Guid/LdrMemoryDescriptor.h
deleted file mode 100644 (file)
index 5fd7aa1..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/** @file\r
-  Guid is for GUIDED HOB of LDR memory descriptor.\r
-\r
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#ifndef __LDR_MEMORY_DESCRIPTOR__\r
-#define __LDR_MEMORY_DESCRIPTOR__\r
-\r
-#define LDR_MEMORY_DESCRIPTOR_GUID \\r
-  { 0x7701d7e5, 0x7d1d, 0x4432, {0xa4, 0x68, 0x67, 0x3d, 0xab, 0x8a, 0xde, 0x60}}\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  UINTN                         MemDescCount;\r
-  EFI_MEMORY_DESCRIPTOR         *MemDesc;\r
-} MEMORY_DESC_HOB;\r
-\r
-#pragma pack()\r
-\r
-extern EFI_GUID gLdrMemoryDescriptorGuid;\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/Guid/PciExpressBaseAddress.h b/DuetPkg/Include/Guid/PciExpressBaseAddress.h
deleted file mode 100644 (file)
index 6ee5a58..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-    PciExpressBaseAddress.h\r
-    \r
-Abstract:\r
-\r
-\r
-   GUIDs used for PciExpress Base Address\r
-\r
-**/\r
-\r
-#ifndef _EFI_PCI_EXPRESS_BASE_ADDRESS_H_\r
-#define _EFI_PCI_EXPRESS_BASE_ADDRESS_H_\r
-\r
-#define EFI_PCI_EXPRESS_BASE_ADDRESS_GUID \\r
-  { \\r
-  0x3677d529, 0x326f, 0x4603, {0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0} \\r
-  }\r
-\r
-//\r
-// Following structure defines PCI Express Base Address information.\r
-// This information is platform specific, and built into hob in PEI phase.\r
-// It can be consumed by PEI PCI driver and DXE PCI driver.\r
-//\r
-#pragma pack(1)\r
-typedef struct _EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION {\r
-  UINT32       HostBridgeNumber;\r
-  UINT32       RootBridgeNumber;\r
-  UINT64       PciExpressBaseAddress;\r
-} EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION;\r
-#pragma pack()\r
-\r
-extern EFI_GUID gEfiPciExpressBaseAddressGuid;\r
-\r
-#endif\r
diff --git a/DuetPkg/Include/Guid/PciOptionRomTable.h b/DuetPkg/Include/Guid/PciOptionRomTable.h
deleted file mode 100644 (file)
index 2325d9b..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/** @file\r
-  GUID and data structure used to describe the list of PCI Option ROMs present in a system.\r
-  \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-\r
-#ifndef __PCI_OPTION_ROM_TABLE_GUID_H_\r
-#define __PCI_OPTION_ROM_TABLE_GUID_H_\r
-\r
-#define EFI_PCI_OPTION_ROM_TABLE_GUID \\r
-  { 0x7462660f, 0x1cbd, 0x48da, {0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c } }\r
-\r
-extern EFI_GUID gEfiPciOptionRomTableGuid;\r
-\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS   RomAddress; \r
-  EFI_MEMORY_TYPE        MemoryType;\r
-  UINT32                 RomLength; \r
-  UINT32                 Seg; \r
-  UINT8                  Bus; \r
-  UINT8                  Dev; \r
-  UINT8                  Func; \r
-  BOOLEAN                ExecutedLegacyBiosImage; \r
-  BOOLEAN                DontLoadEfiRom;\r
-} EFI_PCI_OPTION_ROM_DESCRIPTOR;\r
-\r
-typedef struct {\r
-  UINT64                         PciOptionRomCount;\r
-  EFI_PCI_OPTION_ROM_DESCRIPTOR   *PciOptionRomDescriptors;\r
-} EFI_PCI_OPTION_ROM_TABLE;\r
-\r
-#endif // __PCI_OPTION_ROM_TABLE_GUID_H_\r
-\r
diff --git a/DuetPkg/LegacyMetronome/Metronome.c b/DuetPkg/LegacyMetronome/Metronome.c
deleted file mode 100644 (file)
index 1fd3ecf..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>\r
-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
-  LegacyMetronome.c\r
-\r
-Abstract:\r
-\r
-  This contains the installation function for the driver.\r
-\r
---*/\r
-\r
-#include "Metronome.h"\r
-\r
-//\r
-// Handle for the Metronome Architectural Protocol instance produced by this driver\r
-//\r
-EFI_HANDLE                  mMetronomeHandle = NULL;\r
-\r
-//\r
-// The Metronome Architectural Protocol instance produced by this driver\r
-//\r
-EFI_METRONOME_ARCH_PROTOCOL mMetronome = {\r
-  WaitForTick,\r
-  TICK_PERIOD\r
-};\r
-\r
-//\r
-// Worker Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-WaitForTick (\r
-  IN EFI_METRONOME_ARCH_PROTOCOL  *This,\r
-  IN UINT32                       TickNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Waits for the TickNumber of ticks from a known platform time source.\r
-\r
-Arguments:\r
-\r
-  This                Pointer to the protocol instance.\r
-\r
-Returns: \r
-\r
-  EFI_SUCCESS         If number of ticks occurred.\r
-  EFI_NOT_FOUND       Could not locate CPU IO protocol\r
-\r
---*/\r
-// TODO:    TickNumber - add argument and description to function comment\r
-{\r
-  //\r
-  // Wait for TickNumber toggles of the Refresh bit\r
-  //\r
-  for (; TickNumber != 0x00; TickNumber--) {\r
-    while ((IoRead8(REFRESH_PORT) & REFRESH_ON) == REFRESH_ON);\r
-    while ((IoRead8(REFRESH_PORT) & REFRESH_ON) == REFRESH_OFF);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InstallMetronome (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Install the LegacyMetronome driver.  Loads a Metronome Arch Protocol based\r
-  on the Port 61 timer.\r
-\r
-Arguments:\r
-\r
-  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - Metronome Architectural Protocol Installed\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
-\r
-  //\r
-  // Make sure the Metronome Architectural Protocol is not already installed in the system\r
-  //\r
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiMetronomeArchProtocolGuid);\r
-\r
-  //\r
-  // Program port 61 timer 1 as refresh timer. We could use ACPI timer in the\r
-  // future.\r
-  //\r
-  IoWrite8 (TIMER1_CONTROL_PORT, LOAD_COUNTER1_LSB);\r
-  IoWrite8 (TIMER1_COUNT_PORT, COUNTER1_COUNT);\r
-\r
-  //\r
-  // Install on a new handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mMetronomeHandle,\r
-                  &gEfiMetronomeArchProtocolGuid,\r
-                  &mMetronome,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/DuetPkg/LegacyMetronome/Metronome.h b/DuetPkg/LegacyMetronome/Metronome.h
deleted file mode 100644 (file)
index a543507..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>\r
-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
-  LegacyMetronome.h\r
-\r
-Abstract:\r
-\r
-  Driver implementing the EFI 2.0 metronome protocol using the legacy PORT 61 \r
-  timer.\r
-\r
---*/\r
-\r
-#ifndef _LEGACY_METRONOME_H\r
-#define _LEGACY_METRONOME_H\r
-\r
-//\r
-// Statements that include other files\r
-//\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/Metronome.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/IoLib.h>\r
-\r
-//\r
-// Private definitions\r
-//\r
-#define TICK_PERIOD         300\r
-#define REFRESH_PORT        0x61\r
-#define REFRESH_ON          0x10\r
-#define REFRESH_OFF         0x00\r
-#define TIMER1_CONTROL_PORT 0x43\r
-#define TIMER1_COUNT_PORT   0x41\r
-#define LOAD_COUNTER1_LSB   0x54\r
-#define COUNTER1_COUNT      0x12\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-WaitForTick (\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/DuetPkg/LegacyMetronome/Metronome.inf b/DuetPkg/LegacyMetronome/Metronome.inf
deleted file mode 100644 (file)
index 572fa90..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-## @file\r
-# \r
-# Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#  Abstract:\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = Metronome\r
-  FILE_GUID                      = 07A9330A-F347-11d4-9A49-0090273FC14D\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InstallMetronome\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  UefiBootServicesTableLib\r
-  IoLib\r
-  \r
-[Sources]\r
-  Metronome.c\r
-  Metronome.h\r
-\r
-[Protocols]\r
-  gEfiMetronomeArchProtocolGuid\r
-\r
-[Depex]\r
-  TRUE\r
diff --git a/DuetPkg/Library/DuetBdsLib/BdsPlatform.c b/DuetPkg/Library/DuetBdsLib/BdsPlatform.c
deleted file mode 100644 (file)
index c0dc493..0000000
+++ /dev/null
@@ -1,1731 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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 "BdsPlatform.h"\r
-\r
-#define IS_PCI_ISA_PDECODE(_p)        IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)\r
-\r
-extern BOOLEAN  gConnectAllHappened;\r
-extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;\r
-\r
-EFI_GUID                    *gTableGuidArray[] = {\r
-    &gEfiAcpi20TableGuid, &gEfiAcpiTableGuid, &gEfiSmbiosTableGuid, &gEfiMpsTableGuid\r
-  };\r
-\r
-//\r
-// BDS Platform Functions\r
-//\r
-\r
-VOID\r
-GetSystemTablesFromHob (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Find GUID'ed HOBs that contain EFI_PHYSICAL_ADDRESS of ACPI, SMBIOS, MPs tables\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  None.\r
-\r
---*/\r
-{\r
-  EFI_PEI_HOB_POINTERS        GuidHob;\r
-  EFI_PEI_HOB_POINTERS        HobStart;\r
-  EFI_PHYSICAL_ADDRESS        *Table;\r
-  UINTN                       Index;\r
-\r
-  //\r
-  // Get Hob List\r
-  //\r
-  HobStart.Raw = GetHobList ();\r
-  //\r
-  // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table\r
-  //\r
-  for (Index = 0; Index < ARRAY_SIZE (gTableGuidArray); ++Index) {\r
-    GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);\r
-    if (GuidHob.Raw != NULL) {\r
-      Table = GET_GUID_HOB_DATA (GuidHob.Guid);\r
-      if (Table != NULL) {\r
-        //\r
-        // Check if Mps Table/Smbios Table/Acpi Table exists in E/F seg,\r
-        // According to UEFI Spec, we should make sure Smbios table, \r
-        // ACPI table and Mps tables kept in memory of specified type\r
-        //\r
-        ConvertSystemTable(gTableGuidArray[Index], (VOID**)&Table);\r
-        gBS->InstallConfigurationTable (gTableGuidArray[Index], (VOID *)Table);\r
-      }\r
-    }\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-#if 0\r
-VOID\r
-PrintMemoryMap (\r
-  VOID\r
-  )\r
-{\r
-  EFI_MEMORY_DESCRIPTOR       *MemMap;\r
-  EFI_MEMORY_DESCRIPTOR       *MemMapPtr;\r
-  UINTN                       MemMapSize;\r
-  UINTN                       MapKey, DescriptorSize;\r
-  UINTN                       Index;\r
-  UINT32                      DescriptorVersion;\r
-  UINT64                      Bytes;\r
-  EFI_STATUS                  Status;\r
-\r
-  MemMapSize = 0;\r
-  MemMap     = NULL;\r
-  Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-  MemMapSize += EFI_PAGE_SIZE;\r
-  Status = gBS->AllocatePool (EfiBootServicesData, MemMapSize, &MemMap);\r
-  ASSERT (Status == EFI_SUCCESS);\r
-  Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);\r
-  ASSERT (Status == EFI_SUCCESS);\r
-  MemMapPtr = MemMap;\r
-\r
-  ASSERT (DescriptorVersion == EFI_MEMORY_DESCRIPTOR_VERSION);\r
-\r
-  for (Index = 0; Index < MemMapSize / DescriptorSize; Index ++) {\r
-    Bytes = LShiftU64 (MemMap->NumberOfPages, 12);\r
-    DEBUG ((EFI_D_ERROR, "%lX-%lX  %lX %lX %X\n",\r
-          MemMap->PhysicalStart, \r
-          MemMap->PhysicalStart + Bytes - 1,\r
-          MemMap->NumberOfPages, \r
-          MemMap->Attribute,\r
-          (UINTN)MemMap->Type));\r
-    MemMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemMap + DescriptorSize);\r
-  }\r
-\r
-  gBS->FreePool (MemMapPtr);\r
-}\r
-#endif\r
-\r
-VOID\r
-UpdateMemoryMap (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_PEI_HOB_POINTERS            GuidHob;\r
-  VOID                            *Table;\r
-  MEMORY_DESC_HOB                 MemoryDescHob;\r
-  UINTN                           Index;\r
-  EFI_PHYSICAL_ADDRESS            Memory;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;\r
-  \r
-  GuidHob.Raw = GetFirstGuidHob (&gLdrMemoryDescriptorGuid);\r
-  if (GuidHob.Raw == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));\r
-    return;\r
-  }\r
-  Table = GET_GUID_HOB_DATA (GuidHob.Guid);\r
-  if (Table == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));\r
-    return;\r
-  }\r
-  MemoryDescHob.MemDescCount = *(UINTN *)Table;\r
-  MemoryDescHob.MemDesc      = *(EFI_MEMORY_DESCRIPTOR **)((UINTN)Table + sizeof(UINTN));\r
-\r
-  //\r
-  // Add ACPINVS, ACPIReclaim, and Reserved memory to MemoryMap\r
-  //\r
-  for (Index = 0; Index < MemoryDescHob.MemDescCount; Index++) {\r
-    if (MemoryDescHob.MemDesc[Index].PhysicalStart < 0x100000) {\r
-      continue;\r
-    }\r
-    if (MemoryDescHob.MemDesc[Index].PhysicalStart >= 0x100000000ULL) {\r
-      continue;\r
-    }\r
-    if ((MemoryDescHob.MemDesc[Index].Type == EfiReservedMemoryType) ||\r
-        (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesData) ||\r
-        (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesCode) ||\r
-        (MemoryDescHob.MemDesc[Index].Type == EfiACPIReclaimMemory) ||\r
-        (MemoryDescHob.MemDesc[Index].Type == EfiACPIMemoryNVS)) {\r
-      DEBUG ((EFI_D_ERROR, "PhysicalStart - 0x%016lx, ", MemoryDescHob.MemDesc[Index].PhysicalStart));\r
-      DEBUG ((EFI_D_ERROR, "PageNumber    - 0x%016lx, ", MemoryDescHob.MemDesc[Index].NumberOfPages));\r
-      DEBUG ((EFI_D_ERROR, "Attribute     - 0x%016lx, ", MemoryDescHob.MemDesc[Index].Attribute));\r
-      DEBUG ((EFI_D_ERROR, "Type          - 0x%08x\n", MemoryDescHob.MemDesc[Index].Type));\r
-      if ((MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesData) ||\r
-          (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesCode)) {\r
-        //\r
-        // For RuntimeSevicesData and RuntimeServicesCode, they are BFV or DxeCore.\r
-        // The memory type is assigned in EfiLdr\r
-        //\r
-        Status = gDS->GetMemorySpaceDescriptor (MemoryDescHob.MemDesc[Index].PhysicalStart, &Descriptor);\r
-        if (EFI_ERROR (Status)) {\r
-          continue;\r
-        }\r
-        if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) {\r
-          //\r
-          // BFV or tested DXE core\r
-          //\r
-          continue;\r
-        }\r
-        //\r
-        // Untested DXE Core region, free and remove\r
-        //\r
-        Status = gDS->FreeMemorySpace (\r
-                        MemoryDescHob.MemDesc[Index].PhysicalStart,\r
-                        LShiftU64 (MemoryDescHob.MemDesc[Index].NumberOfPages, EFI_PAGE_SHIFT)\r
-                        );\r
-        if (EFI_ERROR (Status)) {\r
-          DEBUG ((EFI_D_ERROR, "FreeMemorySpace fail - %r!\n", Status));\r
-          continue;\r
-        }\r
-        Status = gDS->RemoveMemorySpace (\r
-                        MemoryDescHob.MemDesc[Index].PhysicalStart,\r
-                        LShiftU64 (MemoryDescHob.MemDesc[Index].NumberOfPages, EFI_PAGE_SHIFT)\r
-                        );\r
-        if (EFI_ERROR (Status)) {\r
-          DEBUG ((EFI_D_ERROR, "RemoveMemorySpace fail - %r!\n", Status));\r
-          continue;\r
-        }\r
-\r
-        //\r
-        // Convert Runtime type to BootTime type\r
-        //\r
-        if (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesData) {\r
-          MemoryDescHob.MemDesc[Index].Type = EfiBootServicesData;\r
-        } else {\r
-          MemoryDescHob.MemDesc[Index].Type = EfiBootServicesCode;\r
-        }\r
-\r
-        //\r
-        // PassThrough, let below code add and alloate.\r
-        //\r
-      }\r
-      //\r
-      // ACPI or reserved memory\r
-      //\r
-      Status = gDS->AddMemorySpace (\r
-                      EfiGcdMemoryTypeSystemMemory,\r
-                      MemoryDescHob.MemDesc[Index].PhysicalStart,\r
-                      LShiftU64 (MemoryDescHob.MemDesc[Index].NumberOfPages, EFI_PAGE_SHIFT),\r
-                      MemoryDescHob.MemDesc[Index].Attribute\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "AddMemorySpace fail - %r!\n", Status));\r
-        if ((MemoryDescHob.MemDesc[Index].Type == EfiACPIReclaimMemory) ||\r
-            (MemoryDescHob.MemDesc[Index].Type == EfiACPIMemoryNVS)) {\r
-          //\r
-          // For EfiACPIReclaimMemory and EfiACPIMemoryNVS, it must success.\r
-          // For EfiReservedMemoryType, there maybe overlap. So skip check here.\r
-          //\r
-//          ASSERT_EFI_ERROR (Status);\r
-        }\r
-        continue;\r
-      }\r
-\r
-      Memory = MemoryDescHob.MemDesc[Index].PhysicalStart;\r
-      Status = gBS->AllocatePages (\r
-                      AllocateAddress,\r
-                      (EFI_MEMORY_TYPE)MemoryDescHob.MemDesc[Index].Type,\r
-                      (UINTN)MemoryDescHob.MemDesc[Index].NumberOfPages,\r
-                      &Memory\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "AllocatePages fail - %r!\n", Status));\r
-        //\r
-        // For the page added, it must be allocated.\r
-        //\r
-//        ASSERT_EFI_ERROR (Status);\r
-        continue;\r
-      }\r
-    }\r
-  }\r
-  \r
-}\r
-\r
-EFI_STATUS\r
-DisableUsbLegacySupport(\r
-  void\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Disabble the USB legacy Support in all Ehci and Uhci.\r
-  This function assume all PciIo handles have been created in system.\r
-  \r
-Arguments:\r
-  None\r
-  \r
-Returns:\r
-  EFI_SUCCESS\r
-  EFI_NOT_FOUND\r
---*/\r
-{\r
-  EFI_STATUS                            Status;\r
-  EFI_HANDLE                            *HandleArray;\r
-  UINTN                                 HandleArrayCount;\r
-  UINTN                                 Index;\r
-  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
-  UINT8                                 Class[3];\r
-  UINT16                                Command;\r
-  UINT32                                HcCapParams;\r
-  UINT32                                ExtendCap;\r
-  UINT32                                Value;\r
-  UINT32                                TimeOut;\r
-  \r
-  //\r
-  // Find the usb host controller \r
-  //   \r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  NULL,\r
-                  &HandleArrayCount,\r
-                  &HandleArray\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < HandleArrayCount; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      HandleArray[Index],\r
-                      &gEfiPciIoProtocolGuid,\r
-                      (VOID **)&PciIo\r
-                      );\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Find the USB host controller controller\r
-        //\r
-        Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);\r
-        if (!EFI_ERROR (Status)) {\r
-          if ((PCI_CLASS_SERIAL == Class[2]) &&\r
-              (PCI_CLASS_SERIAL_USB == Class[1])) {\r
-            if (PCI_IF_UHCI == Class[0]) {\r
-              //\r
-              // Found the UHCI, then disable the legacy support\r
-              //\r
-              Command = 0;\r
-              Status = PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0xC0, 1, &Command);\r
-            } else if (PCI_IF_EHCI == Class[0]) {\r
-              //\r
-              // Found the EHCI, then disable the legacy support\r
-              //\r
-              Status = PciIo->Mem.Read (\r
-                                   PciIo,\r
-                                   EfiPciIoWidthUint32,\r
-                                   0,                   //EHC_BAR_INDEX\r
-                                   (UINT64) 0x08,       //EHC_HCCPARAMS_OFFSET\r
-                                   1,\r
-                                   &HcCapParams\r
-                                   );\r
-              \r
-              ExtendCap = (HcCapParams >> 8) & 0xFF;\r
-              //\r
-              // Disable the SMI in USBLEGCTLSTS firstly\r
-              //\r
-              PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, ExtendCap + 0x4, 1, &Value);\r
-              Value &= 0xFFFF0000;\r
-              PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, ExtendCap + 0x4, 1, &Value);\r
-              \r
-              //\r
-              // Get EHCI Ownership from legacy bios\r
-              //\r
-              PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);\r
-              Value |= (0x1 << 24);\r
-              PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);\r
-\r
-              TimeOut = 40;\r
-              while (TimeOut--) {\r
-                gBS->Stall (500);\r
-\r
-                PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);\r
-\r
-                if ((Value & 0x01010000) == 0x01000000) {\r
-                  break;\r
-                }\r
-              }\r
-            }\r
-          } \r
-        }\r
-      }\r
-    }\r
-  } else {\r
-    return Status;\r
-  }\r
-  gBS->FreePool (HandleArray);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsInit (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Platform Bds init. Include the platform firmware vendor, revision\r
-  and so crc check.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-{\r
-  GetSystemTablesFromHob ();\r
-\r
-  UpdateMemoryMap ();\r
-  \r
-  //\r
-  // Append Usb Keyboard short form DevicePath into "ConInDev" \r
-  //\r
-  BdsLibUpdateConsoleVariable (\r
-    VarConsoleInpDev,\r
-    (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath,\r
-    NULL\r
-    );\r
-}\r
-\r
-UINT64\r
-GetPciExpressBaseAddressForRootBridge (\r
-  IN UINTN    HostBridgeNumber,\r
-  IN UINTN    RootBridgeNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This routine is to get PciExpress Base Address for this RootBridge\r
-\r
-Arguments:\r
-  HostBridgeNumber - The number of HostBridge\r
-  RootBridgeNumber - The number of RootBridge\r
-    \r
-Returns:\r
-  UINT64 - PciExpressBaseAddress for this HostBridge and RootBridge\r
-\r
---*/\r
-{\r
-  EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION *PciExpressBaseAddressInfo;\r
-  UINTN                                    BufferSize;\r
-  UINT32                                   Index;\r
-  UINT32                                   Number;\r
-  EFI_PEI_HOB_POINTERS                     GuidHob;\r
-\r
-  //\r
-  // Get PciExpressAddressInfo Hob\r
-  //\r
-  PciExpressBaseAddressInfo = NULL;\r
-  BufferSize                = 0;\r
-  GuidHob.Raw = GetFirstGuidHob (&gEfiPciExpressBaseAddressGuid);\r
-  if (GuidHob.Raw != NULL) {\r
-    PciExpressBaseAddressInfo = GET_GUID_HOB_DATA (GuidHob.Guid);\r
-    BufferSize                = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);\r
-  } else {\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Search the PciExpress Base Address in the Hob for current RootBridge\r
-  //\r
-  Number = (UINT32)(BufferSize / sizeof(EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION));\r
-  for (Index = 0; Index < Number; Index++) {\r
-    if ((PciExpressBaseAddressInfo[Index].HostBridgeNumber == HostBridgeNumber) &&\r
-        (PciExpressBaseAddressInfo[Index].RootBridgeNumber == RootBridgeNumber)) {\r
-      return PciExpressBaseAddressInfo[Index].PciExpressBaseAddress;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Do not find the PciExpress Base Address in the Hob\r
-  //\r
-  return 0;  \r
-}\r
-\r
-VOID\r
-PatchPciRootBridgeDevicePath (\r
-  IN UINTN    HostBridgeNumber,\r
-  IN UINTN    RootBridgeNumber,\r
-  IN PLATFORM_ROOT_BRIDGE_DEVICE_PATH  *RootBridge\r
-  )\r
-{\r
-  UINT64  PciExpressBase;\r
-\r
-  PciExpressBase = GetPciExpressBaseAddressForRootBridge (HostBridgeNumber, RootBridgeNumber);\r
-  \r
-  DEBUG ((EFI_D_INFO, "Get PciExpress Address from Hob: 0x%X\n", PciExpressBase));\r
-  \r
-  if (PciExpressBase != 0) {\r
-    RootBridge->PciRootBridge.HID = EISA_PNP_ID(0x0A08);\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-ConnectRootBridge (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect RootBridge\r
-\r
-Arguments:\r
-\r
-  None.\r
\r
-Returns:\r
-\r
-  EFI_SUCCESS             - Connect RootBridge successfully.\r
-  EFI_STATUS              - Connect RootBridge fail.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_HANDLE                RootHandle;\r
-\r
-  //\r
-  // Patch Pci Root Bridge Device Path\r
-  //\r
-  PatchPciRootBridgeDevicePath (0, 0, &gPlatformRootBridge0);\r
-\r
-  //\r
-  // Make all the PCI_IO protocols on PCI Seg 0 show up\r
-  //\r
-  BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r
-\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiDevicePathProtocolGuid, \r
-                  &gPlatformRootBridges[0], \r
-                  &RootHandle\r
-                  );\r
-  DEBUG ((EFI_D_INFO, "Pci Root bridge handle is 0x%X\n", RootHandle));\r
-  \r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PrepareLpcBridgeDevicePath (\r
-  IN EFI_HANDLE                DeviceHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add IsaKeyboard to ConIn,\r
-  add IsaSerial to ConOut, ConIn, ErrOut.\r
-  LPC Bridge: 06 01 00\r
-\r
-Arguments:\r
-\r
-  DeviceHandle            - Handle of PCIIO protocol.\r
\r
-Returns:\r
-\r
-  EFI_SUCCESS             - LPC bridge is added to ConOut, ConIn, and ErrOut.\r
-  EFI_STATUS              - No LPC bridge is added.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
-\r
-  DevicePath = NULL;\r
-  Status = gBS->HandleProtocol (\r
-                  DeviceHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID*)&DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  TempDevicePath = DevicePath;\r
-\r
-  //\r
-  // Register Keyboard\r
-  //\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r
-\r
-  BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
-\r
-  //\r
-  // Register COM1\r
-  //\r
-  DevicePath = TempDevicePath;\r
-  gPnp16550ComPortDeviceNode.UID = 0;\r
-\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
-\r
-  BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
-  BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
-  BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
-\r
-  //\r
-  // Register COM2\r
-  //\r
-  DevicePath = TempDevicePath;\r
-  gPnp16550ComPortDeviceNode.UID = 1;\r
-\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
-\r
-  BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
-  BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
-  BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-GetGopDevicePath (\r
-   IN  EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
-   OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r
-   )\r
-{\r
-  UINTN                           Index;\r
-  EFI_STATUS                      Status;\r
-  EFI_HANDLE                      PciDeviceHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL        *TempDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL        *TempPciDevicePath;\r
-  UINTN                           GopHandleCount;\r
-  EFI_HANDLE                      *GopHandleBuffer;\r
-\r
-  if (PciDevicePath == NULL || GopDevicePath == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  //\r
-  // Initialize the GopDevicePath to be PciDevicePath\r
-  //\r
-  *GopDevicePath    = PciDevicePath;\r
-  TempPciDevicePath = PciDevicePath;\r
-\r
-  Status = gBS->LocateDevicePath (\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &TempPciDevicePath,\r
-                  &PciDeviceHandle\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Try to connect this handle, so that GOP driver could start on this \r
-  // device and create child handles with GraphicsOutput Protocol installed\r
-  // on them, then we get device paths of these child handles and select \r
-  // them as possible console device.\r
-  //\r
-  gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);\r
-\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  NULL,\r
-                  &GopHandleCount,\r
-                  &GopHandleBuffer\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Add all the child handles as possible Console Device\r
-    //\r
-    for (Index = 0; Index < GopHandleCount; Index++) {\r
-      Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
-      }\r
-      if (CompareMem (\r
-            PciDevicePath,\r
-            TempDevicePath,\r
-            GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r
-            ) == 0) {\r
-        //\r
-        // In current implementation, we only enable one of the child handles\r
-        // as console device, i.e. sotre one of the child handle's device\r
-        // path to variable "ConOut"\r
-        // In future, we could select all child handles to be console device\r
-        //       \r
-\r
-        *GopDevicePath = TempDevicePath;\r
-\r
-        //\r
-        // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r
-        // Add the integrity GOP device path.\r
-        //\r
-        BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);\r
-        BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);\r
-      }\r
-    }\r
-    gBS->FreePool (GopHandleBuffer);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PreparePciVgaDevicePath (\r
-  IN EFI_HANDLE                DeviceHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add PCI VGA to ConOut.\r
-  PCI VGA: 03 00 00\r
-\r
-Arguments:\r
-\r
-  DeviceHandle            - Handle of PCIIO protocol.\r
\r
-Returns:\r
-\r
-  EFI_SUCCESS             - PCI VGA is added to ConOut.\r
-  EFI_STATUS              - No PCI VGA device is added.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *GopDevicePath;\r
-\r
-  DevicePath    = NULL;\r
-  GopDevicePath = NULL;\r
-  Status = gBS->HandleProtocol (\r
-                  DeviceHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID*)&DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  GetGopDevicePath (DevicePath, &GopDevicePath);\r
-  DevicePath = GopDevicePath;\r
-\r
-  BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PreparePciSerialDevicePath (\r
-  IN EFI_HANDLE                DeviceHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add PCI Serial to ConOut, ConIn, ErrOut.\r
-  PCI Serial: 07 00 02\r
-\r
-Arguments:\r
-\r
-  DeviceHandle            - Handle of PCIIO protocol.\r
\r
-Returns:\r
-\r
-  EFI_SUCCESS             - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
-  EFI_STATUS              - No PCI Serial device is added.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  \r
-  DevicePath = NULL;\r
-  Status = gBS->HandleProtocol (\r
-                  DeviceHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID*)&DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
-\r
-  BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
-  BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
-  BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-DetectAndPreparePlatformPciDevicePath (\r
-  BOOLEAN DetectVgaOnly\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
-\r
-Arguments:\r
-\r
-  DetectVgaOnly           - Only detect VGA device if it's TRUE.\r
\r
-Returns:\r
-\r
-  EFI_SUCCESS             - PCI Device check and Console variable update successfully.\r
-  EFI_STATUS              - PCI Device check or Console variable update fail.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     HandleCount;\r
-  EFI_HANDLE                *HandleBuffer;\r
-  UINTN                     Index;\r
-  EFI_PCI_IO_PROTOCOL       *PciIo;\r
-  PCI_TYPE00                Pci;\r
-\r
-  //\r
-  // Start to check all the PciIo to find all possible device\r
-  //\r
-  HandleCount = 0;\r
-  HandleBuffer = NULL;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiPciIoProtocolGuid,\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->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Check for all PCI device\r
-    //\r
-    Status = PciIo->Pci.Read (\r
-                      PciIo,\r
-                      EfiPciIoWidthUint32,\r
-                      0,\r
-                      sizeof (Pci) / sizeof (UINT32),\r
-                      &Pci\r
-                      );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    if (!DetectVgaOnly) {\r
-      //\r
-      // Here we decide whether it is LPC Bridge\r
-      //\r
-      if ((IS_PCI_LPC (&Pci)) ||\r
-          ((IS_PCI_ISA_PDECODE (&Pci)) && (Pci.Hdr.VendorId == 0x8086) && (Pci.Hdr.DeviceId == 0x7110))) {\r
-        //\r
-        // Add IsaKeyboard to ConIn,\r
-        // add IsaSerial to ConOut, ConIn, ErrOut\r
-        //\r
-        DEBUG ((EFI_D_INFO, "Find the LPC Bridge device\n"));\r
-        PrepareLpcBridgeDevicePath (HandleBuffer[Index]);\r
-        continue;\r
-      }\r
-      //\r
-      // Here we decide which Serial device to enable in PCI bus \r
-      //\r
-      if (IS_PCI_16550SERIAL (&Pci)) {\r
-        //\r
-        // Add them to ConOut, ConIn, ErrOut.\r
-        //\r
-        DEBUG ((EFI_D_INFO, "Find the 16550 SERIAL device\n"));\r
-        PreparePciSerialDevicePath (HandleBuffer[Index]);\r
-        continue;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Here we decide which VGA device to enable in PCI bus \r
-    //\r
-    if (IS_PCI_VGA (&Pci)) {\r
-      //\r
-      // Add them to ConOut.\r
-      //\r
-      DEBUG ((EFI_D_INFO, "Find the VGA device\n"));\r
-      PreparePciVgaDevicePath (HandleBuffer[Index]);\r
-      continue;\r
-    }\r
-  }\r
-  \r
-  gBS->FreePool (HandleBuffer);\r
-  \r
-  return EFI_SUCCESS;\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         - Predefined 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
-  EFI_DEVICE_PATH_PROTOCOL           *VarConout;\r
-  EFI_DEVICE_PATH_PROTOCOL           *VarConin;\r
-  UINTN                              DevicePathSize;\r
-\r
-  //\r
-  // Connect RootBridge\r
-  //\r
-  ConnectRootBridge ();\r
-\r
-  VarConout = BdsLibGetVariableAndSize (\r
-                VarConsoleOut,\r
-                &gEfiGlobalVariableGuid,\r
-                &DevicePathSize\r
-                );\r
-  VarConin = BdsLibGetVariableAndSize (\r
-               VarConsoleInp,\r
-               &gEfiGlobalVariableGuid,\r
-               &DevicePathSize\r
-               );\r
-  \r
-  if (VarConout == NULL || VarConin == NULL) {\r
-    //\r
-    // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
-    //\r
-    DetectAndPreparePlatformPciDevicePath (FALSE);\r
-\r
-    //\r
-    // Have chance to connect the platform default console,\r
-    // the platform default console is the minimum device group\r
-    // the platform should support\r
-    //\r
-    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {\r
-      //\r
-      // Update the console variable with the connect type\r
-      //\r
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
-        BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);\r
-      }\r
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
-        BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);\r
-      }\r
-      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
-        BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);\r
-      }\r
-    }\r
-  } else {\r
-    //\r
-    // Only detect VGA device and add them to ConOut\r
-    //\r
-    DetectAndPreparePlatformPciDevicePath (TRUE);\r
-  }\r
-  \r
-  //\r
-  // The ConIn devices connection will start the USB bus, should disable all\r
-  // Usb legacy support firstly.\r
-  // Caution: Must ensure the PCI bus driver has been started. Since the \r
-  // ConnectRootBridge() will create all the PciIo protocol, it's safe here now\r
-  //\r
-  Status = DisableUsbLegacySupport();\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 predefined 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
-  IN BASEM_MEMORY_TEST           BaseMemoryTest\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
-  BaseMemoryTest   - A pointer to BdsMemoryTest()\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
-    Status = EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
-    if (EFI_ERROR (Status)) {\r
-      DisableQuietBoot ();\r
-      return;\r
-    }\r
-\r
-    //\r
-    // Perform system diagnostic\r
-    //\r
-    Status = BaseMemoryTest (MemoryTestLevel);\r
-    if (EFI_ERROR (Status)) {\r
-      DisableQuietBoot ();\r
-    }\r
-\r
-    return ;\r
-  }\r
-  //\r
-  // Perform system diagnostic\r
-  //\r
-  Status = BaseMemoryTest (MemoryTestLevel);\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsPolicyBehavior (\r
-  IN OUT LIST_ENTRY              *DriverOptionList,\r
-  IN OUT LIST_ENTRY              *BootOptionList,\r
-  IN PROCESS_CAPSULES            ProcessCapsules,\r
-  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The function will execute 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
-  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
-  EFI_EVENT                          UserInputDurationTime;\r
-  UINTN                              Index;\r
-  EFI_INPUT_KEY                      Key;\r
-  EFI_BOOT_MODE                      BootMode;\r
-\r
-  //\r
-  // Init the time out value\r
-  //\r
-  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\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 (&BootMode);\r
-  DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", 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
-  ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\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
-  // Create a 300ms duration event to ensure user has enough input time to enter Setup\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER,\r
-                  0,\r
-                  NULL,\r
-                  NULL,\r
-                  &UserInputDurationTime\r
-                  );\r
-  ASSERT (Status == EFI_SUCCESS);\r
-  Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000);\r
-  ASSERT (Status == EFI_SUCCESS);\r
-  //\r
-  // Memory test and Logo show\r
-  //\r
-  PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\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
-  // BUGBUG: hard code timeout to 5 second to show logo in graphic mode.\r
-  Timeout = 5;  \r
-  if (Timeout != 0) {\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-  }\r
-\r
-  //\r
-  //BdsLibConnectAll ();\r
-  //BdsLibEnumerateAllBootOption (BootOptionList);  \r
-  \r
-  //\r
-  // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot\r
-  // checking code in real production tip.\r
-  //          \r
-  // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device \r
-  // and do enumerate all the default boot options. But in development system board, the boot mode \r
-  // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box\r
-  // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.\r
-  //\r
-  Status = BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
-  if (EFI_ERROR(Status)) {\r
-    //\r
-    // If cannot find "BootOrder" variable,  it may be first boot. \r
-    // Try to connect all devices and enumerate all boot options here.\r
-    //\r
-    BdsLibConnectAll ();\r
-    BdsLibEnumerateAllBootOption (BootOptionList);\r
-  } \r
-\r
-  //\r
-  // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r
-  // BDS should still give user a chance to enter Setup\r
-  // Check whether the user input after the duration time has expired \r
-  //\r
-  gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r
-  gBS->CloseEvent (UserInputDurationTime);\r
-  Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-  \r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Enter Setup if user input \r
-    //\r
-    Timeout = 0xffff;\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-  }\r
-  \r
-  return ;\r
-\r
-}\r
-\r
-VOID\r
-EFIAPI\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 = Option->StatusString;\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
-EFIAPI\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 = Option->StatusString;\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
-\r
-EFI_STATUS\r
-ConvertSystemTable (\r
-  IN     EFI_GUID        *TableGuid,\r
-  IN OUT VOID            **Table\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Convert ACPI Table /Smbios Table /MP Table if its location is lower than Address:0x100000\r
-  Assumption here:\r
-   As in legacy Bios, ACPI/Smbios/MP table is required to place in E/F Seg, \r
-   So here we just check if the range is E/F seg, \r
-   and if Not, assume the Memory type is EfiACPIReclaimMemory/EfiACPIMemoryNVS\r
-\r
-Arguments:\r
-  TableGuid - Guid of the table\r
-  Table     - pointer to the table  \r
-\r
-Returns:\r
-  EFI_SUCEESS - Convert Table successfully\r
-  Other       - Failed\r
-\r
---*/\r
-{\r
-  EFI_STATUS      Status;\r
-  VOID            *AcpiHeader;\r
-  UINTN           AcpiTableLen;\r
-  \r
-  //\r
-  // If match acpi guid (1.0, 2.0, or later), Convert ACPI table according to version. \r
-  //\r
-  AcpiHeader = (VOID*)(UINTN)(*(UINT64 *)(*Table));\r
-  \r
-  if (CompareGuid(TableGuid, &gEfiAcpiTableGuid) || CompareGuid(TableGuid, &gEfiAcpi20TableGuid)){\r
-    if (((EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiHeader)->Reserved == 0x00){\r
-      //\r
-      // If Acpi 1.0 Table, then RSDP structure doesn't contain Length field, use structure size\r
-      //\r
-      AcpiTableLen = sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER);\r
-    } else if (((EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiHeader)->Reserved >= 0x02){\r
-      //\r
-      // If Acpi 2.0 or later, use RSDP Length fied.\r
-      //\r
-      AcpiTableLen = ((EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiHeader)->Length;\r
-    } else {\r
-      //\r
-      // Invalid Acpi Version, return\r
-      //\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    Status = ConvertAcpiTable (AcpiTableLen, Table);\r
-    return Status; \r
-  }\r
-  \r
-  //\r
-  // If matches smbios guid, convert Smbios table.\r
-  //\r
-  if (CompareGuid(TableGuid, &gEfiSmbiosTableGuid)){\r
-    Status = ConvertSmbiosTable (Table);\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // If the table is MP table?\r
-  //\r
-  if (CompareGuid(TableGuid, &gEfiMpsTableGuid)){\r
-    Status = ConvertMpsTable (Table);\r
-    return Status;\r
-  }\r
-  \r
-  return EFI_UNSUPPORTED;\r
-}  \r
-\r
-\r
-EFI_STATUS\r
-ConvertAcpiTable (\r
-  IN     UINTN                       TableLen,\r
-  IN OUT VOID                        **Table\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Convert RSDP of ACPI Table if its location is lower than Address:0x100000\r
-  Assumption here:\r
-   As in legacy Bios, ACPI table is required to place in E/F Seg, \r
-   So here we just check if the range is E/F seg, \r
-   and if Not, assume the Memory type is EfiACPIReclaimMemory/EfiACPIMemoryNVS\r
-\r
-Arguments:\r
-  TableLen  - Acpi RSDP length\r
-  Table     - pointer to the table  \r
-\r
-Returns:\r
-  EFI_SUCEESS - Convert Table successfully\r
-  Other       - Failed\r
-\r
---*/\r
-{\r
-  VOID                  *AcpiTableOri;\r
-  VOID                  *AcpiTableNew;\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  BufferPtr;\r
-\r
-  \r
-  AcpiTableOri    =  (VOID *)(UINTN)(*(UINT64*)(*Table));\r
-  if (((UINTN)AcpiTableOri < 0x100000) && ((UINTN)AcpiTableOri > 0xE0000)) {\r
-    BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS;\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiACPIMemoryNVS,\r
-                    EFI_SIZE_TO_PAGES(TableLen),\r
-                    &BufferPtr\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-    AcpiTableNew = (VOID *)(UINTN)BufferPtr;\r
-    CopyMem (AcpiTableNew, AcpiTableOri, TableLen);\r
-  } else {\r
-    AcpiTableNew = AcpiTableOri;\r
-  }\r
-  //\r
-  // Change configuration table Pointer\r
-  //\r
-  *Table = AcpiTableNew;\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-ConvertSmbiosTable (\r
-  IN OUT VOID        **Table\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Convert Smbios Table if the Location of the SMBios Table is lower than Addres 0x100000\r
-  Assumption here:\r
-   As in legacy Bios, Smbios table is required to place in E/F Seg, \r
-   So here we just check if the range is F seg, \r
-   and if Not, assume the Memory type is EfiACPIMemoryNVS/EfiRuntimeServicesData\r
-Arguments:\r
-  Table     - pointer to the table\r
-\r
-Returns:\r
-  EFI_SUCEESS - Convert Table successfully\r
-  Other       - Failed\r
-\r
---*/\r
-{\r
-  SMBIOS_TABLE_ENTRY_POINT *SmbiosTableNew;\r
-  SMBIOS_TABLE_ENTRY_POINT *SmbiosTableOri;\r
-  EFI_STATUS               Status;\r
-  UINT32                   SmbiosEntryLen;\r
-  UINT32                   BufferLen;\r
-  EFI_PHYSICAL_ADDRESS     BufferPtr;\r
-  \r
-  SmbiosTableNew  = NULL;\r
-  SmbiosTableOri  = NULL;\r
-  \r
-  //\r
-  // Get Smibos configuration Table \r
-  //\r
-  SmbiosTableOri =  (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)(*(UINT64*)(*Table));\r
-  \r
-  if ((SmbiosTableOri == NULL) ||\r
-      ((UINTN)SmbiosTableOri > 0x100000) ||\r
-      ((UINTN)SmbiosTableOri < 0xF0000)){\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Relocate the Smibos memory\r
-  //\r
-  BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS;\r
-  if (SmbiosTableOri->SmbiosBcdRevision != 0x21) {\r
-    SmbiosEntryLen  = SmbiosTableOri->EntryPointLength;\r
-  } else {\r
-    //\r
-    // According to Smbios Spec 2.4, we should set entry point length as 0x1F if version is 2.1\r
-    //\r
-    SmbiosEntryLen = 0x1F;\r
-  }\r
-  BufferLen = SmbiosEntryLen + SYS_TABLE_PAD(SmbiosEntryLen) + SmbiosTableOri->TableLength;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIMemoryNVS,\r
-                  EFI_SIZE_TO_PAGES(BufferLen),\r
-                  &BufferPtr\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  SmbiosTableNew = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)BufferPtr;\r
-  CopyMem (\r
-    SmbiosTableNew, \r
-    SmbiosTableOri,\r
-    SmbiosEntryLen\r
-    );\r
-  // \r
-  // Get Smbios Structure table address, and make sure the start address is 32-bit align\r
-  //\r
-  BufferPtr += SmbiosEntryLen + SYS_TABLE_PAD(SmbiosEntryLen);\r
-  CopyMem (\r
-    (VOID *)(UINTN)BufferPtr, \r
-    (VOID *)(UINTN)(SmbiosTableOri->TableAddress),\r
-    SmbiosTableOri->TableLength\r
-    );\r
-  SmbiosTableNew->TableAddress = (UINT32)BufferPtr;\r
-  SmbiosTableNew->IntermediateChecksum = 0;\r
-  SmbiosTableNew->IntermediateChecksum = \r
-          CalculateCheckSum8 ((UINT8*)SmbiosTableNew + 0x10, SmbiosEntryLen -0x10);\r
-  //\r
-  // Change the SMBIOS pointer\r
-  //\r
-  *Table = SmbiosTableNew;\r
-  \r
-  return EFI_SUCCESS;  \r
-} \r
-\r
-EFI_STATUS\r
-ConvertMpsTable (\r
-  IN OUT VOID          **Table\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Convert MP Table if the Location of the SMBios Table is lower than Addres 0x100000\r
-  Assumption here:\r
-   As in legacy Bios, MP table is required to place in E/F Seg, \r
-   So here we just check if the range is E/F seg, \r
-   and if Not, assume the Memory type is EfiACPIMemoryNVS/EfiRuntimeServicesData\r
-Arguments:\r
-  Table     - pointer to the table\r
-\r
-Returns:\r
-  EFI_SUCEESS - Convert Table successfully\r
-  Other       - Failed\r
-\r
---*/\r
-{\r
-  UINT32                                       Data32;\r
-  UINT32                                       FPLength;\r
-  EFI_LEGACY_MP_TABLE_FLOATING_POINTER         *MpsFloatingPointerOri;\r
-  EFI_LEGACY_MP_TABLE_FLOATING_POINTER         *MpsFloatingPointerNew;\r
-  EFI_LEGACY_MP_TABLE_HEADER                   *MpsTableOri;\r
-  EFI_LEGACY_MP_TABLE_HEADER                   *MpsTableNew;\r
-  VOID                                         *OemTableOri;\r
-  VOID                                         *OemTableNew;\r
-  EFI_STATUS                                   Status;\r
-  EFI_PHYSICAL_ADDRESS                         BufferPtr;\r
-  \r
-  //\r
-  // Get MP configuration Table \r
-  //\r
-  MpsFloatingPointerOri = (EFI_LEGACY_MP_TABLE_FLOATING_POINTER *)(UINTN)(*(UINT64*)(*Table));\r
-  if (!(((UINTN)MpsFloatingPointerOri <= 0x100000) && \r
-        ((UINTN)MpsFloatingPointerOri >= 0xF0000))){\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Get Floating pointer structure length\r
-  //\r
-  FPLength = MpsFloatingPointerOri->Length * 16;\r
-  Data32   = FPLength + SYS_TABLE_PAD (FPLength);\r
-  MpsTableOri = (EFI_LEGACY_MP_TABLE_HEADER *)(UINTN)(MpsFloatingPointerOri->PhysicalAddress);\r
-  if (MpsTableOri != NULL) {\r
-    Data32 += MpsTableOri->BaseTableLength;\r
-    Data32 += MpsTableOri->ExtendedTableLength;\r
-    if (MpsTableOri->OemTablePointer != 0x00) {\r
-      Data32 += SYS_TABLE_PAD (Data32);\r
-      Data32 += MpsTableOri->OemTableSize;\r
-    }\r
-  } else {\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Relocate memory\r
-  //\r
-  BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS;\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiACPIMemoryNVS,\r
-                  EFI_SIZE_TO_PAGES(Data32),\r
-                  &BufferPtr\r
-                  );\r
-  ASSERT_EFI_ERROR (Status); \r
-  MpsFloatingPointerNew = (EFI_LEGACY_MP_TABLE_FLOATING_POINTER *)(UINTN)BufferPtr;\r
-  CopyMem (MpsFloatingPointerNew, MpsFloatingPointerOri, FPLength);\r
-  //\r
-  // If Mp Table exists\r
-  //\r
-  if (MpsTableOri != NULL) {\r
-    //\r
-    // Get Mps table length, including Ext table\r
-    //\r
-    BufferPtr = BufferPtr + FPLength + SYS_TABLE_PAD (FPLength);\r
-    MpsTableNew = (EFI_LEGACY_MP_TABLE_HEADER *)(UINTN)BufferPtr;\r
-    CopyMem (MpsTableNew, MpsTableOri, MpsTableOri->BaseTableLength + MpsTableOri->ExtendedTableLength);\r
-    \r
-    if ((MpsTableOri->OemTableSize != 0x0000) && (MpsTableOri->OemTablePointer != 0x0000)){\r
-        BufferPtr += MpsTableOri->BaseTableLength + MpsTableOri->ExtendedTableLength;\r
-        BufferPtr += SYS_TABLE_PAD (BufferPtr);\r
-        OemTableNew = (VOID *)(UINTN)BufferPtr;\r
-        OemTableOri = (VOID *)(UINTN)MpsTableOri->OemTablePointer;\r
-        CopyMem (OemTableNew, OemTableOri, MpsTableOri->OemTableSize);\r
-        MpsTableNew->OemTablePointer = (UINT32)(UINTN)OemTableNew;\r
-    }\r
-    MpsTableNew->Checksum = 0;\r
-    MpsTableNew->Checksum = CalculateCheckSum8 ((UINT8*)MpsTableNew, MpsTableOri->BaseTableLength);\r
-    MpsFloatingPointerNew->PhysicalAddress = (UINT32)(UINTN)MpsTableNew;\r
-    MpsFloatingPointerNew->Checksum = 0;\r
-    MpsFloatingPointerNew->Checksum = CalculateCheckSum8 ((UINT8*)MpsFloatingPointerNew, FPLength);\r
-  }\r
-  //\r
-  // Change the pointer\r
-  //\r
-  *Table = MpsFloatingPointerNew;\r
-  \r
-  return EFI_SUCCESS;  \r
-} \r
-  \r
-/**\r
-  Lock the ConsoleIn device in system table. All key\r
-  presses will be ignored until the Password is typed in. The only way to\r
-  disable the password is to type it in to a ConIn device.\r
-\r
-  @param  Password        Password used to lock ConIn device.\r
-\r
-  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
-  @retval EFI_UNSUPPORTED Password not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  )\r
-{\r
-    return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  This function locks platform flash that is not allowed to be updated during normal boot path.\r
-  The flash layout is platform specific.\r
-\r
-  **/\r
-VOID\r
-EFIAPI\r
-PlatformBdsLockNonUpdatableFlash (\r
-  VOID\r
-  )\r
-{\r
-  return;\r
-}\r
diff --git a/DuetPkg/Library/DuetBdsLib/BdsPlatform.h b/DuetPkg/Library/DuetBdsLib/BdsPlatform.h
deleted file mode 100644 (file)
index 4abb7b7..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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 _PLATFORM_SPECIFIC_BDS_PLATFORM_H_\r
-#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_\r
-\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-#include <IndustryStandard/Acpi.h>\r
-#include <IndustryStandard/SmBios.h>\r
-#include <IndustryStandard/LegacyBiosMpTable.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/PlatformBdsLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include <Protocol/PciIo.h>\r
-\r
-#include <Guid/Acpi.h>\r
-#include <Guid/SmBios.h>\r
-#include <Guid/Mps.h>\r
-#include <Guid/HobList.h>\r
-#include <Guid/PciExpressBaseAddress.h>\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/LdrMemoryDescriptor.h>\r
-\r
-extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformRootBridges[];\r
-extern ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode;\r
-extern ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode;\r
-extern UART_DEVICE_PATH           gUartDeviceNode;\r
-extern VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode;\r
-//\r
-//\r
-//\r
-#define VarConsoleInpDev        L"ConInDev"\r
-#define VarConsoleInp           L"ConIn"\r
-#define VarConsoleOutDev        L"ConOutDev"\r
-#define VarConsoleOut           L"ConOut"\r
-#define VarErrorOutDev          L"ErrOutDev"\r
-#define VarErrorOut             L"ErrOut"\r
-\r
-#define PCI_DEVICE_PATH_NODE(Func, Dev) \\r
-  { \\r
-    { \\r
-      HARDWARE_DEVICE_PATH, \\r
-      HW_PCI_DP, \\r
-      { \\r
-        (UINT8) (sizeof (PCI_DEVICE_PATH)), \\r
-        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \\r
-      } \\r
-    }, \\r
-    (Func), \\r
-    (Dev) \\r
-  }\r
-\r
-#define PNPID_DEVICE_PATH_NODE(PnpId) \\r
-  { \\r
-    { \\r
-      ACPI_DEVICE_PATH, \\r
-      ACPI_DP, \\r
-      { \\r
-        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \\r
-        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \\r
-      } \\r
-    }, \\r
-    EISA_PNP_ID((PnpId)), \\r
-    0 \\r
-  }\r
-\r
-#define gPciRootBridge \\r
-  PNPID_DEVICE_PATH_NODE(0x0A03)\r
-\r
-#define gPciIsaBridge \\r
-  PCI_DEVICE_PATH_NODE(0, 0x1f)\r
-\r
-#define gP2PBridge \\r
-  PCI_DEVICE_PATH_NODE(0, 0x1e)\r
-\r
-#define gPnpPs2Keyboard \\r
-  PNPID_DEVICE_PATH_NODE(0x0303)\r
-\r
-#define gPnp16550ComPort \\r
-  PNPID_DEVICE_PATH_NODE(0x0501)\r
-\r
-#define gUart \\r
-  { \\r
-    { \\r
-      MESSAGING_DEVICE_PATH, \\r
-      MSG_UART_DP, \\r
-      { \\r
-        (UINT8) (sizeof (UART_DEVICE_PATH)), \\r
-        (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \\r
-      } \\r
-    }, \\r
-    0, \\r
-    115200, \\r
-    8, \\r
-    1, \\r
-    1 \\r
-  }\r
-\r
-#define gPcAnsiTerminal \\r
-  { \\r
-    { \\r
-      MESSAGING_DEVICE_PATH, \\r
-      MSG_VENDOR_DP, \\r
-      { \\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
-      } \\r
-    }, \\r
-    DEVICE_PATH_MESSAGING_PC_ANSI \\r
-  }\r
-\r
-#define gEndEntire \\r
-  { \\r
-    END_DEVICE_PATH_TYPE, \\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE, \\r
-    { \\r
-      END_DEVICE_PATH_LENGTH, \\r
-      0 \\r
-    } \\r
-  }\r
-\r
-#define PCI_CLASS_SCC          0x07\r
-#define PCI_SUBCLASS_SERIAL    0x00\r
-#define PCI_IF_16550           0x02\r
-#define IS_PCI_16550SERIAL(_p)           IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)\r
-\r
-#define EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF\r
-#define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )\r
-//\r
-// Platform Root Bridge\r
-//\r
-typedef struct {\r
-  ACPI_HID_DEVICE_PATH      PciRootBridge;\r
-  EFI_DEVICE_PATH_PROTOCOL  End;\r
-} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  ACPI_HID_DEVICE_PATH      PciRootBridge;\r
-  PCI_DEVICE_PATH           IsaBridge;\r
-  ACPI_HID_DEVICE_PATH      Keyboard;\r
-  EFI_DEVICE_PATH_PROTOCOL  End;\r
-} PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  ACPI_HID_DEVICE_PATH      PciRootBridge;\r
-  PCI_DEVICE_PATH           IsaBridge;\r
-  ACPI_HID_DEVICE_PATH      IsaSerial;\r
-  UART_DEVICE_PATH          Uart;\r
-  VENDOR_DEVICE_PATH        TerminalType;\r
-  EFI_DEVICE_PATH_PROTOCOL  End;\r
-} PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  ACPI_HID_DEVICE_PATH      PciRootBridge;\r
-  PCI_DEVICE_PATH           VgaDevice;\r
-  EFI_DEVICE_PATH_PROTOCOL  End;\r
-} PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  ACPI_HID_DEVICE_PATH      PciRootBridge;\r
-  PCI_DEVICE_PATH           PciBridge;\r
-  PCI_DEVICE_PATH           SerialDevice;\r
-  UART_DEVICE_PATH          Uart;\r
-  VENDOR_DEVICE_PATH        TerminalType;\r
-  EFI_DEVICE_PATH_PROTOCOL  End;\r
-} PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH;\r
-\r
-//\r
-// the short form device path for Usb keyboard\r
-//\r
-#define CLASS_HID           3\r
-#define SUBCLASS_BOOT       1\r
-#define PROTOCOL_KEYBOARD   1\r
-\r
-typedef struct {\r
-  USB_CLASS_DEVICE_PATH           UsbClass;\r
-  EFI_DEVICE_PATH_PROTOCOL        End;\r
-} USB_CLASS_FORMAT_DEVICE_PATH;  \r
-\r
-extern PLATFORM_ROOT_BRIDGE_DEVICE_PATH  gPlatformRootBridge0;\r
-\r
-//\r
-// Platform BDS Functions\r
-//\r
-VOID\r
-PlatformBdsGetDriverOption (\r
-  IN LIST_ENTRY               *BdsDriverLists\r
-  );\r
-\r
-EFI_STATUS\r
-BdsMemoryTest (\r
-  EXTENDMEM_COVERAGE_LEVEL Level\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
-VOID\r
-PlatformBdsConnectSequence (\r
-  VOID\r
-  );\r
-\r
-EFI_STATUS\r
-ProcessCapsules (\r
-  EFI_BOOT_MODE BootMode\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
-  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformBdsNoConsoleAction (\r
-  VOID\r
-  );\r
-\r
-EFI_STATUS\r
-ConvertMpsTable (\r
-  IN OUT  VOID     **Table\r
-  );\r
-  \r
-EFI_STATUS\r
-ConvertSmbiosTable (\r
-  IN OUT VOID       **Table\r
-  );\r
-  \r
-EFI_STATUS\r
-ConvertAcpiTable (\r
- IN      UINTN      TableLen,\r
- IN OUT  VOID       **Table\r
-  );\r
-\r
-EFI_STATUS\r
-ConvertSystemTable (\r
- IN     EFI_GUID   *TableGuid,\r
- IN OUT VOID       **Table\r
-  );\r
-\r
-VOID\r
-PlatformBdsEnterFrontPage (\r
-  IN UINT16                 TimeoutDefault,\r
-  IN BOOLEAN                ConnectAllHappened\r
-  );\r
-\r
-#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_\r
diff --git a/DuetPkg/Library/DuetBdsLib/PlatformBds.inf b/DuetPkg/Library/DuetBdsLib/PlatformBds.inf
deleted file mode 100644 (file)
index 0a20a1a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-## @file\r
-#\r
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#    PlatformBds.inf\r
-#\r
-#  Abstract:\r
-#\r
-#    Component description file for Bds module.\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DuetBds\r
-  FILE_GUID                      = A6F691AC-31C8-4444-854C-E2C1A6950F92\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PlatformBdsLib|DXE_DRIVER\r
-\r
-[Sources]\r
-  BdsPlatform.c\r
-  PlatformData.c\r
-  BdsPlatform.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PcdLib\r
-  GenericBdsLib\r
-  HobLib\r
-  UefiLib\r
-  DevicePathLib\r
-\r
-[Guids]\r
-  gEfiGlobalVariableGuid\r
-  gEfiPciExpressBaseAddressGuid\r
-  gEfiAcpi20TableGuid\r
-  gEfiMpsTableGuid\r
-  gEfiSmbiosTableGuid\r
-  gEfiAcpiTableGuid\r
-  gLdrMemoryDescriptorGuid\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
-\r
diff --git a/DuetPkg/Library/DuetBdsLib/PlatformData.c b/DuetPkg/Library/DuetBdsLib/PlatformData.c
deleted file mode 100644 (file)
index d38f1b4..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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 "BdsPlatform.h"\r
-\r
-//\r
-// Predefined platform default time out value\r
-//\r
-UINT16   gPlatformBootTimeOutDefault = 3;\r
-\r
-ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode  = gPnpPs2Keyboard;\r
-ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode = gPnp16550ComPort;\r
-UART_DEVICE_PATH           gUartDeviceNode            = gUart;\r
-VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode    = gPcAnsiTerminal;\r
-\r
-//\r
-// Predefined platform root bridge\r
-//\r
-PLATFORM_ROOT_BRIDGE_DEVICE_PATH  gPlatformRootBridge0 = {\r
-  gPciRootBridge,\r
-  gEndEntire\r
-};\r
-\r
-EFI_DEVICE_PATH_PROTOCOL          *gPlatformRootBridges[] = {\r
-  (EFI_DEVICE_PATH_PROTOCOL *) &gPlatformRootBridge0,\r
-  NULL\r
-};\r
-\r
-USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {\r
-  {\r
-    {\r
-      MESSAGING_DEVICE_PATH,\r
-      MSG_USB_CLASS_DP,\r
-      {\r
-        (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    0xffff,           // VendorId \r
-    0xffff,           // ProductId \r
-    CLASS_HID,        // DeviceClass \r
-    SUBCLASS_BOOT,    // DeviceSubClass\r
-    PROTOCOL_KEYBOARD // DeviceProtocol\r
-  },\r
-\r
-  { \r
-    END_DEVICE_PATH_TYPE, \r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE, \r
-    {\r
-      END_DEVICE_PATH_LENGTH, \r
-      0\r
-    }\r
-  }\r
-};\r
-\r
-/*\r
-//\r
-// Platform specific Dummy ISA keyboard device path\r
-//\r
-PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH     gDummyIsaKeyboardDevicePath = {\r
-  gPciRootBridge,\r
-  gPciIsaBridge,\r
-  gPnpPs2Keyboard,\r
-  gEndEntire\r
-};\r
-\r
-//\r
-// Platform specific Dummy ISA serial device path\r
-//\r
-PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH   gDummyIsaSerialDevicePath = {\r
-  gPciRootBridge,\r
-  gPciIsaBridge,\r
-  gPnp16550ComPort,\r
-  gUart,\r
-  gPcAnsiTerminal,\r
-  gEndEntire\r
-};\r
-\r
-//\r
-// Platform specific Dummy PCI VGA device path\r
-//\r
-PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH gDummyPciVgaDevicePath = {\r
-  gPciRootBridge,\r
-  PCI_DEVICE_PATH_NODE(0, 0x2),\r
-  gEndEntire\r
-};\r
-\r
-//\r
-// Platform specific Dummy PCI serial device path\r
-//\r
-PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH gDummyPciSerialDevicePath = {\r
-  gPciRootBridge,\r
-  gP2PBridge,\r
-  PCI_DEVICE_PATH_NODE(0, 0x0),\r
-  gUart,\r
-  gPcAnsiTerminal,\r
-  gEndEntire\r
-};\r
-*/\r
-//\r
-// Predefined platform default console device path\r
-//\r
-BDS_CONSOLE_CONNECT_ENTRY         gPlatformConsole[] = {\r
-  //\r
-  // need update dynamically\r
-  //\r
-//  {\r
-//    (EFI_DEVICE_PATH_PROTOCOL *) &gDummyIsaSerialDevicePath,\r
-//    (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
-//  },\r
-//  {\r
-//    (EFI_DEVICE_PATH_PROTOCOL *) &gDummyIsaKeyboardDevicePath,\r
-//    (CONSOLE_IN | STD_ERROR)\r
-//  },\r
-//  {\r
-//    (EFI_DEVICE_PATH_PROTOCOL *) &gDummyPciVgaDevicePath,\r
-//    CONSOLE_OUT\r
-//  },\r
-//  {\r
-//    (EFI_DEVICE_PATH_PROTOCOL *) &gDummyPciSerialDevicePath,\r
-//    (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
-//  },\r
-  {\r
-    (EFI_DEVICE_PATH_PROTOCOL*) &gUsbClassKeyboardDevicePath, \r
-    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
-\r
diff --git a/DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf b/DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf
deleted file mode 100644 (file)
index b9bac9a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-## @file\r
-# Timer Library implementation for Boot Timer moudles that require timer services.\r
-#\r
-# Timer Library that uses CPU resources to provide calibrated\r
-#  delays on IA-32 and x64, and uses ITC on IPF. Note: Because CpuLocalApci\r
-#  and ITC could be programmed by OS, it cannot be used by SMM drivers\r
-#  and runtime drivers, ACPI timer is recommended for SMM drivers and RUNTIME\r
-#  drivers.\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DuetTimerLib\r
-  FILE_GUID                      = 5F9A01F5-726E-4f59-809D-887F4766734E\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = TimerLib\r
-\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64\r
-#\r
-\r
-[Sources.Ia32]\r
-  X86TimerLib.c\r
-\r
-[Sources.X64]\r
-  X86TimerLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  DebugLib\r
-  HobLib\r
-  IoLib\r
-  \r
-[Guids]\r
-  gEfiAcpiDescriptionGuid\r
-  \r
-  \r
diff --git a/DuetPkg/Library/DuetTimerLib/X86TimerLib.c b/DuetPkg/Library/DuetTimerLib/X86TimerLib.c
deleted file mode 100644 (file)
index ca3890c..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/** @file\r
-  Timer Library functions built upon ACPI on IA32/x64.\r
-  \r
-  ACPI power management timer is a 24-bit or 32-bit fixed rate free running count-up\r
-  timer that runs off a 3.579545 MHz clock. \r
-  When startup, Duet will check the FADT to determine whether the PM timer is a \r
-  32-bit or 24-bit timer.\r
-\r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#include <Base.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Guid/AcpiDescription.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/PciLib.h>\r
-\r
-EFI_ACPI_DESCRIPTION *gAcpiDesc          = NULL;\r
-\r
-/**\r
-  Internal function to get Acpi information from HOB.\r
-  \r
-  @return Pointer to ACPI description structure.\r
-**/\r
-EFI_ACPI_DESCRIPTION*\r
-InternalGetApciDescrptionTable (\r
-  VOID\r
-  )\r
-{\r
-  EFI_PEI_HOB_POINTERS  GuidHob;\r
-  \r
-  if (gAcpiDesc != NULL) {\r
-    return gAcpiDesc;\r
-  }\r
-  \r
-  GuidHob.Raw = GetFirstGuidHob (&gEfiAcpiDescriptionGuid);\r
-  if (GuidHob.Raw != NULL) {\r
-    gAcpiDesc = GET_GUID_HOB_DATA (GuidHob.Guid);\r
-    DEBUG ((EFI_D_INFO, "ACPI Timer: PM_TMR_BLK.RegisterBitWidth = 0x%X\n", gAcpiDesc->PM_TMR_BLK.RegisterBitWidth));\r
-    DEBUG ((EFI_D_INFO, "ACPI Timer: PM_TMR_BLK.Address = 0x%X\n", gAcpiDesc->PM_TMR_BLK.Address));\r
-    return gAcpiDesc;\r
-  } else {\r
-    DEBUG ((EFI_D_ERROR, "Fail to get Acpi description table from hob\n"));\r
-    return NULL;\r
-  }\r
-}\r
-\r
-/**\r
-  Internal function to read the current tick counter of ACPI.\r
-\r
-  @return The tick counter read.\r
-\r
-**/\r
-STATIC\r
-UINT32\r
-InternalAcpiGetTimerTick (\r
-  VOID\r
-  )\r
-{\r
-  return IoRead32 ((UINTN)gAcpiDesc->PM_TMR_BLK.Address);\r
-}\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of ticks.\r
-\r
-  Stalls the CPU for at least the given number of ticks. It's invoked by\r
-  MicroSecondDelay() and NanoSecondDelay().\r
-\r
-  @param  Delay     A period of time to delay in ticks.\r
-\r
-**/\r
-STATIC\r
-VOID\r
-InternalAcpiDelay (\r
-  IN      UINT32                    Delay\r
-  )\r
-{\r
-  UINT32                            Ticks;\r
-  UINT32                            Times;\r
-\r
-  Times    = Delay >> (gAcpiDesc->PM_TMR_BLK.RegisterBitWidth - 2);\r
-  Delay   &= (1 << (gAcpiDesc->PM_TMR_BLK.RegisterBitWidth - 2)) - 1;\r
-  do {\r
-    //\r
-    // The target timer count is calculated here\r
-    //\r
-    Ticks    = InternalAcpiGetTimerTick () + Delay;\r
-    Delay    = 1 << (gAcpiDesc->PM_TMR_BLK.RegisterBitWidth - 2);\r
-    //\r
-    // Wait until time out\r
-    // Delay >= 2^23 (if ACPI provide 24-bit timer) or Delay >= 2^31 (if ACPI\r
-    // provide 32-bit timer) could not be handled by this function\r
-    // Timer wrap-arounds are handled correctly by this function\r
-    //\r
-    while (((Ticks - InternalAcpiGetTimerTick ()) & (1 << (gAcpiDesc->PM_TMR_BLK.RegisterBitWidth - 1))) == 0) {\r
-      CpuPause ();\r
-    }\r
-  } while (Times-- > 0);\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
-\r
-  if (InternalGetApciDescrptionTable() == NULL) {\r
-    return MicroSeconds;\r
-  }\r
\r
-  InternalAcpiDelay (\r
-    (UINT32)DivU64x32 (\r
-              MultU64x32 (\r
-                MicroSeconds,\r
-                3579545\r
-                ),\r
-              1000000u\r
-              )\r
-    );\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
-  if (InternalGetApciDescrptionTable() == NULL) {\r
-    return NanoSeconds;\r
-  }\r
-  \r
-  InternalAcpiDelay (\r
-    (UINT32)DivU64x32 (\r
-              MultU64x32 (\r
-                NanoSeconds,\r
-                3579545\r
-                ),\r
-              1000000000u\r
-              )\r
-    );\r
-  return NanoSeconds;\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
-  if (InternalGetApciDescrptionTable() == NULL) {\r
-    return 0;\r
-  }\r
-  \r
-  return (UINT64)InternalAcpiGetTimerTick ();\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
-  if (InternalGetApciDescrptionTable() == NULL) {\r
-    return 0;\r
-  }\r
-  \r
-  if (StartValue != NULL) {\r
-    *StartValue = 0;\r
-  }\r
-\r
-  if (EndValue != NULL) {\r
-    *EndValue = (1 << gAcpiDesc->PM_TMR_BLK.RegisterBitWidth) - 1;\r
-  }\r
-\r
-  return 3579545;\r
-}\r
-\r
-/**\r
-  Converts elapsed ticks of performance counter to time in nanoseconds.\r
-\r
-  This function converts the elapsed ticks of running performance counter to\r
-  time value in unit of nanoseconds.\r
-\r
-  @param  Ticks     The number of elapsed ticks of running performance counter.\r
-\r
-  @return The elapsed time in nanoseconds.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetTimeInNanoSecond (\r
-  IN      UINT64                     Ticks\r
-  )\r
-{\r
-  UINT64  NanoSeconds;\r
-  UINT32  Remainder;\r
-\r
-  //\r
-  //          Ticks\r
-  // Time = --------- x 1,000,000,000\r
-  //        Frequency\r
-  //\r
-  NanoSeconds = MultU64x32 (DivU64x32Remainder (Ticks, 3579545, &Remainder), 1000000000u);\r
-\r
-  //\r
-  // Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000)\r
-  // will not overflow 64-bit.\r
-  //\r
-  NanoSeconds += DivU64x32 (MultU64x32 ((UINT64) Remainder, 1000000000u), 3579545);\r
-\r
-  return NanoSeconds;\r
-}\r
diff --git a/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeCoreReportStatusCodeLibFromHob.inf b/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeCoreReportStatusCodeLibFromHob.inf
deleted file mode 100644 (file)
index 618221a..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-## @file\r
-#  Report status code library for DxeCore.\r
-#\r
-#  DXE core report status code library that retrieves the status code function from\r
-#  a GUIDed HOB and installs report status code protocol for later DXE phase drivers.\r
-#\r
-#  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  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.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeCoreReportStatusCodeLibFromHob\r
-  FILE_GUID                      = 5c7f8702-838f-43df-91e6-7833b6f2a067\r
-  MODULE_TYPE                    = DXE_CORE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = ReportStatusCodeLib|DXE_CORE\r
-\r
-  CONSTRUCTOR                    = DxeCoreReportStatusCodeFromHobLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  ReportStatusCodeLib.c\r
-  DxeSupport.c\r
-  ReportStatusCodeLibInternal.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  UefiBootServicesTableLib\r
-  DebugLib\r
-  DevicePathLib\r
-  HobLib\r
-  \r
-[Guids]\r
-  gEfiStatusCodeSpecificDataGuid\r
-  gEfiStatusCodeDataTypeDebugGuid\r
-\r
-\r
-[Protocols]\r
-  gEfiStatusCodeRuntimeProtocolGuid             # PRODUCES\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask\r
-\r
diff --git a/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeSupport.c b/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/DxeSupport.c
deleted file mode 100644 (file)
index 36b4025..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/** @file\r
-  Report Status Code Library that depends on a GUIDed HOB for report status\r
-  code functionality.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#include "ReportStatusCodeLibInternal.h"\r
-\r
-//\r
-// Handle to install report status code protocol interface\r
-//\r
-EFI_HANDLE               mHandle = NULL;\r
-\r
-//\r
-// Report status protocol interface.\r
-//\r
-EFI_STATUS_CODE_PROTOCOL mStatusProtocol = {\r
-  NULL\r
-};\r
-\r
-/**\r
-  Initializes report status code infrastructure for DXE phase.\r
-\r
-  The constructor function assumes the PEI phase has published the GUIDed HOB\r
-  tagged by gEfiStatusCodeRuntimeProtocolGuid and publish status code runtime\r
-  protocol based on the GUID data. It will ASSERT() if one of these operations\r
-  fails and it will always return EFI_SUCCESS.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DxeCoreReportStatusCodeFromHobLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS           Status;\r
-  EFI_HOB_GUID_TYPE    *GuidHob;\r
-\r
-  GuidHob = GetFirstGuidHob(&gEfiStatusCodeRuntimeProtocolGuid);\r
-  ASSERT (GuidHob != NULL);\r
-  \r
-  mStatusProtocol.ReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) GET_GUID_HOB_DATA (GuidHob));\r
-  ASSERT (mStatusProtocol.ReportStatusCode != NULL);\r
-\r
-  //\r
-  // Install report status protocol interface so that later DXE phase drivers can retrieve the protocol\r
-  // interface to report status code.\r
-  //\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &mHandle,\r
-                  &gEfiStatusCodeRuntimeProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &mStatusProtocol\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Reports a status code with full parameters.\r
-\r
-  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize\r
-  is 0, then an extended data buffer is not reported.  If ExtendedData is not\r
-  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
-  ExtendedData is assumed not have the standard status code header, so this function\r
-  is responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled in\r
-  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a\r
-  GUID of gEfiStatusCodeSpecificDatauid is used.  The status code is reported with\r
-  an instance specified by Instance and a caller ID specified by CallerId.  If\r
-  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
-\r
-  ReportStatusCodeEx()must actively prevent recursion.  If ReportStatusCodeEx()\r
-  is called while processing another any other Report Status Code Library function,\r
-  then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
-  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  If this parameter is NULL, then a caller\r
-                            ID of gEfiCallerIdGuid is used.\r
-  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.\r
-                            If this parameter is NULL, then a the status code\r
-                            standard header is filled in with\r
-                            gEfiStatusCodeSpecificDataGuid.\r
-  @param  ExtendedData      Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate\r
-                                 the extended data section if it was specified.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InternalReportStatusCodeEx (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN UINT32                 Instance,\r
-  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
-  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
-  IN CONST VOID             *ExtendedData      OPTIONAL,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS_CODE_DATA  *StatusCodeData;\r
-\r
-  ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
-  ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
-\r
-  if (gBS == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Allocate space for the Status Code Header and its buffer\r
-  //\r
-  StatusCodeData = NULL;\r
-  gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
-  if (StatusCodeData == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  //\r
-  // Fill in the extended data header\r
-  //\r
-  StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
-  StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
-  if (ExtendedDataGuid == NULL) {\r
-    ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
-  }\r
-  CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
-\r
-  //\r
-  // Fill in the extended data buffer\r
-  //\r
-  CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
-\r
-  //\r
-  // Report the status code\r
-  //\r
-  if (CallerId == NULL) {\r
-    CallerId = &gEfiCallerIdGuid;\r
-  }\r
-  Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
-\r
-  //\r
-  // Free the allocated buffer\r
-  //\r
-  gBS->FreePool (StatusCodeData);\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/ReportStatusCodeLib.c b/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/ReportStatusCodeLib.c
deleted file mode 100644 (file)
index 064a17b..0000000
+++ /dev/null
@@ -1,535 +0,0 @@
-/** @file\r
-  Report Status Code Library for DXE Phase.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#include "ReportStatusCodeLibInternal.h"\r
\r
-/**\r
-  Internal worker function that reports a status code through the Status Code Protocol\r
-\r
-  This function checks to see if a Status Code Protocol is present in the handle\r
-  database.  If a Status Code Protocol is not present, then EFI_UNSUPPORTED is\r
-  returned.  If a Status Code Protocol is present, then it is cached in gStatusCode,\r
-  and the ReportStatusCode() service of the Status Code Protocol is called passing in\r
-  Type, Value, Instance, CallerId, and Data.  The result of this call is returned.\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  This is an optional parameter that may be\r
-                            NULL.\r
-  @param  Data              Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to report the status code.\r
-  @retval  EFI_UNSUPPORTED       Status Code Protocol is not available.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL\r
-  )\r
-{\r
-  //\r
-  // A Status Code Protocol is present in the handle database, so pass in all the\r
-  // parameters to the ReportStatusCode() service of the Status Code Protocol\r
-  //\r
-  return (*mStatusProtocol.ReportStatusCode) (Type, Value, Instance, (EFI_GUID *) CallerId, Data);\r
-}\r
-\r
-\r
-/**\r
-  Computes and returns the size, in bytes, of a device path.\r
-\r
-  @param  DevicePath  A pointer to a device path.\r
-\r
-  @return  The size, in bytes, of DevicePath.\r
-\r
-**/\r
-UINTN\r
-InternalReportStatusCodeDevicePathSize (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  CONST EFI_DEVICE_PATH_PROTOCOL  *Start;\r
-\r
-  //\r
-  // Search for the end of the device path structure\r
-  //\r
-  Start = DevicePath;\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-\r
-  //\r
-  // Subtract the start node from the end node and add in the size of the end node\r
-  //\r
-  return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r
-}\r
-\r
-\r
-/**\r
-  Converts a status code to an 8-bit POST code value.\r
-\r
-  Converts the status code specified by CodeType and Value to an 8-bit POST code\r
-  and returns the 8-bit POST code in PostCode.  If CodeType is an\r
-  EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode\r
-  are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits\r
-  24..26 of Value., and TRUE is returned.  Otherwise, FALSE is returned.\r
-\r
-  If PostCode 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  PostCode  A pointer to the 8-bit POST code value to return.\r
-\r
-  @retval  TRUE   The status code specified by CodeType and Value was converted\r
-                  to an 8-bit POST code and returned in  PostCode.\r
-  @retval  FALSE  The status code specified by CodeType and Value could not be\r
-                  converted to an 8-bit POST code value.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-CodeTypeToPostCode (\r
-  IN  EFI_STATUS_CODE_TYPE   CodeType,\r
-  IN  EFI_STATUS_CODE_VALUE  Value,\r
-  OUT UINT8                  *PostCode\r
-  )\r
-{\r
-  //\r
-  // If PostCode is NULL, then ASSERT()\r
-  //\r
-  ASSERT (PostCode != NULL);\r
-\r
-  //\r
-  // Convert Value to an 8 bit post code\r
-  //\r
-  if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
-      ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)       ) {\r
-    *PostCode  = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
-                          (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
-    return TRUE;\r
-  }\r
-  return FALSE;\r
-}\r
-\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
-BOOLEAN\r
-EFIAPI\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
-\r
-/**\r
-  Extracts DEBUG() information from a status code structure.\r
-\r
-  Converts the status code specified by Data to the DEBUG() arguments specified\r
-  by ErrorLevel, Marker, and Format.  If type GUID in Data is\r
-  EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and\r
-  Format from the optional data area of the status code buffer specified by Data.\r
-  The optional data area of Data contains a 32-bit ErrorLevel followed by Marker\r
-  which is 12 UINTN parameters, followed by a Null-terminated ASCII string for\r
-  the Format.  If the DEBUG() information could be extracted from Data, then\r
-  return TRUE.  Otherwise, FALSE is returned.\r
-\r
-  If Data is NULL, then ASSERT().\r
-  If ErrorLevel is NULL, then ASSERT().\r
-  If Marker is NULL, then ASSERT().\r
-  If Format is NULL, then ASSERT().\r
-\r
-  @param  Data        Pointer to status code data buffer.\r
-  @param  ErrorLevel  Pointer to error level mask for a debug message.\r
-  @param  Marker      Pointer to the variable argument list associated with Format.\r
-  @param  Format      Pointer to a Null-terminated ASCII format string of a\r
-                      debug message.\r
-\r
-  @retval  TRUE   The status code specified by Data was converted DEBUG() arguments\r
-                  specified by ErrorLevel, Marker, and Format.\r
-  @retval  FALSE  The status code specified by Data could not be converted to\r
-                  DEBUG() arguments.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportStatusCodeExtractDebugInfo (\r
-  IN CONST EFI_STATUS_CODE_DATA  *Data,\r
-  OUT UINT32                     *ErrorLevel,\r
-  OUT BASE_LIST                  *Marker,\r
-  OUT CHAR8                      **Format\r
-  )\r
-{\r
-  EFI_DEBUG_INFO  *DebugInfo;\r
-\r
-  ASSERT (Data          != NULL);\r
-  ASSERT (ErrorLevel    != NULL);\r
-  ASSERT (Marker     != NULL);\r
-  ASSERT (Format     != NULL);\r
-\r
-  //\r
-  // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r
-  //\r
-  if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
-    return FALSE;\r
-  }\r
-\r
-  //\r
-  // Retrieve the debug information from the status code record\r
-  //\r
-  DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
-\r
-  *ErrorLevel = DebugInfo->ErrorLevel;\r
-\r
-  //\r
-  // The first 12 * UINTN bytes of the string are really an\r
-  // argument stack to support varargs on the Format string.\r
-  //\r
-  *Marker = (BASE_LIST) (DebugInfo + 1);\r
-  *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code.\r
-\r
-  Reports the status code specified by the parameters Type and Value.  Status\r
-  code also require an instance, caller ID, and extended data.  This function\r
-  passed in a zero instance, NULL extended data, and a caller ID of\r
-  gEfiCallerIdGuid, which is the GUID for the module.\r
-\r
-  ReportStatusCode()must actively prevent recusrsion.  If ReportStatusCode()\r
-  is called while processing another any other Report Status Code Library function,\r
-  then ReportStatusCode() must return immediately.\r
-\r
-  @param  Type   Status code type.\r
-  @param  Value  Status code value.\r
-\r
-  @retval  EFI_SUCCESS       The status code was reported.\r
-  @retval  EFI_DEVICE_ERROR  There status code could not be reported due to a\r
-                             device error.\r
-  @retval  EFI_UNSUPPORTED   Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value\r
-  )\r
-{\r
-  return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with a Device Path Protocol as the extended data.\r
-\r
-  Allocates and fills in the extended data section of a status code with the\r
-  Device Path Protocol specified by DevicePath.  This function is responsible\r
-  for allocating a buffer large enough for the standard header and the device\r
-  path.  The standard header is filled in with a GUID of\r
-  gEfiStatusCodeSpecificDataGuid.  The status code is reported with a zero\r
-  instance and a caller ID of gEfiCallerIdGuid.\r
-\r
-  ReportStatusCodeWithDevicePath()must actively prevent recursion.  If\r
-  ReportStatusCodeWithDevicePath() is called while processing another any other\r
-  Report Status Code Library function, then ReportStatusCodeWithDevicePath()\r
-  must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If DevicePath is NULL, then ASSERT().\r
-\r
-  @param  Type        Status code type.\r
-  @param  Value       Status code value.\r
-  @param  DevicePath  Pointer to the Device Path Protocol to be reported.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported with the extended\r
-                                 data specified by DevicePath.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the\r
-                                 extended data section.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeWithDevicePath (\r
-  IN EFI_STATUS_CODE_TYPE            Type,\r
-  IN EFI_STATUS_CODE_VALUE           Value,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  ASSERT (DevicePath != NULL);\r
-  return ReportStatusCodeWithExtendedData (\r
-           Type,\r
-           Value,\r
-           (VOID *)DevicePath,\r
-           InternalReportStatusCodeDevicePathSize (DevicePath)\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with an extended data buffer.\r
-\r
-  Allocates and fills in the extended data section of a status code with the\r
-  extended data specified by ExtendedData and ExtendedDataSize.  ExtendedData\r
-  is assumed to be one of the data structures specified in Related Definitions.\r
-  These data structure do not have the standard header, so this function is\r
-  responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled\r
-  in with a GUID of  gEfiStatusCodeSpecificDataGuid.  The status code is reported\r
-  with a zero instance and a caller ID of gEfiCallerIdGuid.\r
-\r
-  ReportStatusCodeWithExtendedData()must actively prevent recursion.  If\r
-  ReportStatusCodeWithExtendedData() is called while processing another any other\r
-  Report Status Code Library function, then ReportStatusCodeWithExtendedData()\r
-  must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL, then ASSERT().\r
-  If ExtendedDataSize is 0, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  ExtendedData      Pointer to the extended data buffer to be reported.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer to\r
-                            be reported.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported with the extended\r
-                                 data specified by ExtendedData and ExtendedDataSize.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate the\r
-                                 extended data section.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeWithExtendedData (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN CONST VOID             *ExtendedData,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  ASSERT (ExtendedData     != NULL);\r
-  ASSERT (ExtendedDataSize != 0);\r
-  return ReportStatusCodeEx (\r
-           Type,\r
-           Value,\r
-           0,\r
-           NULL,\r
-           NULL,\r
-           ExtendedData,\r
-           ExtendedDataSize\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Reports a status code with full parameters.\r
-\r
-  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize\r
-  is 0, then an extended data buffer is not reported.  If ExtendedData is not\r
-  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
-  ExtendedData is assumed not have the standard status code header, so this function\r
-  is responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled in\r
-  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a\r
-  GUID of gEfiStatusCodeSpecificDataGuid is used.  The status code is reported with\r
-  an instance specified by Instance and a caller ID specified by CallerId.  If\r
-  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
-\r
-  ReportStatusCodeEx()must actively prevent recursion. If\r
-  ReportStatusCodeEx() is called while processing another any\r
-  other Report Status Code Library function, then\r
-  ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
-  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  If this parameter is NULL, then a caller\r
-                            ID of gEfiCallerIdGuid is used.\r
-  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.\r
-                            If this parameter is NULL, then a the status code\r
-                            standard header is filled in with\r
-                            gEfiStatusCodeSpecificDataGuid.\r
-  @param  ExtendedData      Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate\r
-                                 the extended data section if it was specified.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportStatusCodeEx (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN UINT32                 Instance,\r
-  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
-  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
-  IN CONST VOID             *ExtendedData      OPTIONAL,\r
-  IN UINTN                  ExtendedDataSize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = InternalReportStatusCodeEx (\r
-             Type,\r
-             Value,\r
-             Instance,\r
-             CallerId,\r
-             ExtendedDataGuid,\r
-             ExtendedData,\r
-             ExtendedDataSize\r
-             );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportProgressCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportErrorCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
-}\r
-\r
-\r
-/**\r
-  Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
-\r
-  This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED\r
-  bit of PcdReportStatusCodeProperyMask is set.  Otherwise FALSE is returned.\r
-\r
-  @retval  TRUE   The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is set.\r
-  @retval  FALSE  The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
-                  PcdReportStatusCodeProperyMask is clear.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ReportDebugCodeEnabled (\r
-  VOID\r
-  )\r
-{\r
-  return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
-}\r
diff --git a/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/ReportStatusCodeLibInternal.h b/DuetPkg/Library/DxeCoreReportStatusCodeLibFromHob/ReportStatusCodeLibInternal.h
deleted file mode 100644 (file)
index b2c70ca..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/** @file\r
-  Internal Header file of Report Status Code Library.\r
-\r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  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
-#ifndef __REPORT_STATUS_CODE_LIB_INTERNAL_H__\r
-#define __REPORT_STATUS_CODE_LIB_INTERNAL_H__\r
-\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/HobLib.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Protocol/StatusCode.h>\r
-\r
-/**\r
-  Internal worker function that reports a status code through the Status Code Protocol\r
-\r
-  This function checks to see if a Status Code Protocol is present in the handle\r
-  database.  If a Status Code Protocol is not present, then EFI_UNSUPPORTED is\r
-  returned.  If a Status Code Protocol is present, then it is cached in gStatusCode,\r
-  and the ReportStatusCode() service of the Status Code Protocol is called passing in\r
-  Type, Value, Instance, CallerId, and Data.  The result of this call is returned.\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  This is an optional parameter that may be\r
-                            NULL.\r
-  @param  Data              Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to report the status code.\r
-  @retval  EFI_UNSUPPORTED       Status Code Protocol is not available.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\r
-  IN EFI_STATUS_CODE_TYPE     Type,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN CONST EFI_GUID           *CallerId OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL\r
-  );\r
-\r
-/**\r
-  Reports a status code with full parameters.\r
-\r
-  The function reports a status code.  If ExtendedData is NULL and ExtendedDataSize\r
-  is 0, then an extended data buffer is not reported.  If ExtendedData is not\r
-  NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
-  ExtendedData is assumed not have the standard status code header, so this function\r
-  is responsible for allocating a buffer large enough for the standard header and\r
-  the extended data passed into this function.  The standard header is filled in\r
-  with a GUID specified by ExtendedDataGuid.  If ExtendedDataGuid is NULL, then a\r
-  GUID of gEfiStatusCodeSpecificDatauid is used.  The status code is reported with\r
-  an instance specified by Instance and a caller ID specified by CallerId.  If\r
-  CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
-\r
-  ReportStatusCodeEx()must actively prevent recursion.  If ReportStatusCodeEx()\r
-  is called while processing another any other Report Status Code Library function,\r
-  then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
-\r
-  If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
-  If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
-\r
-  @param  Type              Status code type.\r
-  @param  Value             Status code value.\r
-  @param  Instance          Status code instance number.\r
-  @param  CallerId          Pointer to a GUID that identifies the caller of this\r
-                            function.  If this parameter is NULL, then a caller\r
-                            ID of gEfiCallerIdGuid is used.\r
-  @param  ExtendedDataGuid  Pointer to the GUID for the extended data buffer.\r
-                            If this parameter is NULL, then a the status code\r
-                            standard header is filled in with\r
-                            gEfiStatusCodeSpecificDataGuid.\r
-  @param  ExtendedData      Pointer to the extended data buffer.  This is an\r
-                            optional parameter that may be NULL.\r
-  @param  ExtendedDataSize  The size, in bytes, of the extended data buffer.\r
-\r
-  @retval  EFI_SUCCESS           The status code was reported.\r
-  @retval  EFI_OUT_OF_RESOURCES  There were not enough resources to allocate\r
-                                 the extended data section if it was specified.\r
-  @retval  EFI_UNSUPPORTED       Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InternalReportStatusCodeEx (\r
-  IN EFI_STATUS_CODE_TYPE   Type,\r
-  IN EFI_STATUS_CODE_VALUE  Value,\r
-  IN UINT32                 Instance,\r
-  IN CONST EFI_GUID         *CallerId          OPTIONAL,\r
-  IN CONST EFI_GUID         *ExtendedDataGuid  OPTIONAL,\r
-  IN CONST VOID             *ExtendedData      OPTIONAL,\r
-  IN UINTN                  ExtendedDataSize\r
-  );\r
-\r
-extern EFI_STATUS_CODE_PROTOCOL mStatusProtocol;\r
-\r
-#endif // __REPORT_STATUS_CODE_LIB_INTERNAL__H\r
-\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/ComponentName.c b/DuetPkg/PciBusNoEnumerationDxe/ComponentName.c
deleted file mode 100644 (file)
index dc4280e..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusComponentNameGetControllerName (\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
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName = {\r
-  PciBusComponentNameGetDriverName,\r
-  PciBusComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PciBusComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PciBusComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-EFI_UNICODE_STRING_TABLE mPciBusDriverNameTable[] = {\r
-  { "eng;en", L"PCI Bus Driver" },\r
-  { NULL, NULL }\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusComponentNameGetDriverName (\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 LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mPciBusDriverNameTable, \r
-           DriverName,\r
-           (BOOLEAN)(This == &gPciBusComponentName)\r
-           );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusComponentNameGetControllerName (\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
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciBus.c b/DuetPkg/PciBusNoEnumerationDxe/PciBus.c
deleted file mode 100644 (file)
index b80869c..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciBus.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-//\r
-// PCI Bus Support Function Prototypes\r
-//\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    Controller,\r
-  IN  UINTN                         NumberOfChildren,\r
-  IN  EFI_HANDLE                    *ChildHandleBuffer\r
-  );\r
-\r
-\r
-//\r
-// PCI Bus Driver Global Variables\r
-//\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL                   gPciBusDriverBinding = {\r
-  PciBusDriverBindingSupported,\r
-  PciBusDriverBindingStart,\r
-  PciBusDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-BOOLEAN gFullEnumeration;\r
-\r
-UINT64 gAllOne    = 0xFFFFFFFFFFFFFFFFULL;\r
-UINT64 gAllZero   = 0;\r
\r
-//\r
-// PCI Bus Driver Support Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize the global variables\r
-  publish the driver binding protocol\r
-\r
-Arguments:\r
-\r
-  IN EFI_HANDLE     ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS \r
-  EFI_DEVICE_ERROR \r
-\r
---*/\r
-{\r
-  EFI_STATUS         Status;\r
-\r
-  //\r
-  // Initialize the EFI Driver Library\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gPciBusDriverBinding,\r
-             ImageHandle,\r
-             &gPciBusComponentName,\r
-             &gPciBusComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  InitializePciDevicePool ();\r
-\r
-  gFullEnumeration = TRUE;\r
-  \r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check to see if pci bus driver supports the given controller\r
-\r
-Arguments:\r
-  \r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS\r
-\r
---*/\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
-  EFI_DEV_PATH_PTR                Node;\r
-\r
-  if (RemainingDevicePath != NULL) {\r
-    Node.DevPath = RemainingDevicePath;\r
-    if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||\r
-        Node.DevPath->SubType != HW_PCI_DP         ||\r
-        DevicePathNodeLength(Node.DevPath) != sizeof(PCI_DEVICE_PATH)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\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
-        Controller,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Controller\r
-        );\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciRootBridgeIoProtocolGuid,\r
-                  (VOID **) &PciRootBridgeIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\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
-         Controller,\r
-         &gEfiPciRootBridgeIoProtocolGuid,\r
-         This->DriverBindingHandle,\r
-         Controller\r
-         );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Start to management the controller passed in\r
-\r
-Arguments:\r
-  \r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-\r
-Returns:\r
\r
-\r
---*/\r
-{\r
-  EFI_STATUS                          Status;\r
-\r
-  //\r
-  // Enumerate the entire host bridge\r
-  // After enumeration, a database that records all the device information will be created\r
-  //\r
-  //\r
-  Status = PciEnumerator (Controller);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Enable PCI device specified by remaining device path. BDS or other driver can call the\r
-  // start more than once.\r
-  //\r
-  \r
-  StartPciDevices (Controller, RemainingDevicePath);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    Controller,\r
-  IN  UINTN                         NumberOfChildren,\r
-  IN  EFI_HANDLE                    *ChildHandleBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Stop one or more children created at start of pci bus driver\r
-  if all the the children get closed, close the protocol\r
-\r
-Arguments:\r
-  \r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    Controller,\r
-  IN  UINTN                         NumberOfChildren,\r
-  IN  EFI_HANDLE                    *ChildHandleBuffer\r
-\r
-Returns:\r
-\r
-  \r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       Index;\r
-  BOOLEAN     AllChildrenStopped;\r
-\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiDevicePathProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-    gBS->CloseProtocol (\r
-           Controller,\r
-           &gEfiPciRootBridgeIoProtocolGuid,\r
-           This->DriverBindingHandle,\r
-           Controller\r
-           );\r
-\r
-    DestroyRootBridgeByHandle (\r
-      Controller\r
-      );\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Stop all the children\r
-  //\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    //\r
-    // De register all the pci device\r
-    //\r
-    Status = DeRegisterPciDevice (Controller, ChildHandleBuffer[Index]);\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
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciBus.h b/DuetPkg/PciBusNoEnumerationDxe/PciBus.h
deleted file mode 100644 (file)
index 150196c..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciBus.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_BUS_H\r
-#define _EFI_PCI_BUS_H\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/PciRootBridgeIo.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/Decompress.h>\r
-#include <Protocol/UgaIo.h>\r
-#include <Protocol/LoadedImage.h>\r
-#include <Protocol/BusSpecificDriverOverride.h>\r
-\r
-#include <Guid/PciOptionRomTable.h>\r
-\r
-#include <IndustryStandard/Pci.h>\r
-#include <IndustryStandard/Acpi.h>\r
-#include <IndustryStandard/PeImage.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/PeCoffLib.h>\r
-\r
-//\r
-// Driver Produced Protocol Prototypes\r
-//\r
-\r
-#define VGABASE1  0x3B0\r
-#define VGALIMIT1 0x3BB\r
-\r
-#define VGABASE2  0x3C0\r
-#define VGALIMIT2 0x3DF\r
-\r
-#define ISABASE   0x100\r
-#define ISALIMIT  0x3FF\r
-\r
-typedef enum {\r
-  PciBarTypeUnknown = 0,\r
-  PciBarTypeIo16,\r
-  PciBarTypeIo32,\r
-  PciBarTypeMem32,\r
-  PciBarTypePMem32,\r
-  PciBarTypeMem64,\r
-  PciBarTypePMem64,\r
-  PciBarTypeIo,\r
-  PciBarTypeMem,\r
-  PciBarTypeMaxType\r
-} PCI_BAR_TYPE;\r
-\r
-typedef struct {\r
-  UINT64        BaseAddress;\r
-  UINT64        Length;\r
-  UINT64        Alignment;\r
-  PCI_BAR_TYPE  BarType;\r
-  BOOLEAN       Prefetchable;\r
-  UINT8         MemType;\r
-  UINT8         Offset;\r
-} PCI_BAR;\r
-\r
-#define PCI_IO_DEVICE_SIGNATURE   SIGNATURE_32 ('p','c','i','o')\r
-\r
-#define EFI_BRIDGE_IO32_DECODE_SUPPORTED        0x0001 \r
-#define EFI_BRIDGE_PMEM32_DECODE_SUPPORTED      0x0002 \r
-#define EFI_BRIDGE_PMEM64_DECODE_SUPPORTED      0x0004 \r
-#define EFI_BRIDGE_IO16_DECODE_SUPPORTED        0x0008  \r
-#define EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED   0x0010  \r
-#define EFI_BRIDGE_MEM64_DECODE_SUPPORTED       0x0020\r
-#define EFI_BRIDGE_MEM32_DECODE_SUPPORTED       0x0040\r
-\r
-\r
-typedef struct _PCI_IO_DEVICE {\r
-  UINT32                                    Signature;\r
-  EFI_HANDLE                                Handle;\r
-  EFI_PCI_IO_PROTOCOL                       PciIo;\r
-  LIST_ENTRY                            Link;\r
-\r
-  EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL PciDriverOverride;\r
-  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL           *PciRootBridgeIo;\r
-\r
-  //\r
-  // PCI configuration space header type\r
-  //\r
-  PCI_TYPE00                                Pci;\r
-\r
-  //\r
-  // Bus number, Device number, Function number\r
-  //\r
-  UINT8                                     BusNumber;\r
-  UINT8                                     DeviceNumber;\r
-  UINT8                                     FunctionNumber;\r
-\r
-  //\r
-  // BAR for this PCI Device\r
-  //\r
-  PCI_BAR                                   PciBar[PCI_MAX_BAR];\r
-\r
-  //\r
-  // The bridge device this pci device is subject to\r
-  //\r
-  struct _PCI_IO_DEVICE                     *Parent;\r
-\r
-  //\r
-  // A linked list for children Pci Device if it is bridge device\r
-  //\r
-  LIST_ENTRY                            ChildList;\r
-\r
-  //\r
-  // TRUE if the PCI bus driver creates the handle for this PCI device\r
-  //\r
-  BOOLEAN                                   Registered;\r
-\r
-  //\r
-  // TRUE if the PCI bus driver successfully allocates the resource required by\r
-  // this PCI device\r
-  //\r
-  BOOLEAN                                   Allocated;\r
-\r
-  //\r
-  // The attribute this PCI device currently set\r
-  //\r
-  UINT64                                    Attributes;\r
-\r
-  //\r
-  // The attributes this PCI device actually supports\r
-  //\r
-  UINT64                                    Supports;\r
-\r
-  //\r
-  // The resource decode the bridge supports\r
-  //\r
-  UINT32                                    Decodes;\r
-\r
-  //\r
-  // The OptionRom Size\r
-  //\r
-  UINT64                                    RomSize;\r
-\r
-  //\r
-  // TRUE if there is any EFI driver in the OptionRom\r
-  //\r
-  BOOLEAN                                   BusOverride;\r
-\r
-  //\r
-  //  A list tracking reserved resource on a bridge device\r
-  //\r
-  LIST_ENTRY                            ReservedResourceList;\r
-\r
-  //\r
-  // A list tracking image handle of platform specific overriding driver\r
-  //\r
-  LIST_ENTRY                            OptionRomDriverList;\r
-\r
-  BOOLEAN                                   IsPciExp;\r
-\r
-} PCI_IO_DEVICE;\r
-\r
-\r
-#define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \\r
-  CR (a, PCI_IO_DEVICE, PciIo, PCI_IO_DEVICE_SIGNATURE)\r
-\r
-#define PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS(a) \\r
-  CR (a, PCI_IO_DEVICE, PciDriverOverride, PCI_IO_DEVICE_SIGNATURE)\r
-\r
-#define PCI_IO_DEVICE_FROM_LINK(a) \\r
-  CR (a, PCI_IO_DEVICE, Link, PCI_IO_DEVICE_SIGNATURE)\r
-\r
-//\r
-// Global Variables\r
-//\r
-extern EFI_COMPONENT_NAME_PROTOCOL gPciBusComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  gPciBusComponentName2;\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gPciBusDriverBinding;\r
-\r
-extern BOOLEAN                     gFullEnumeration;\r
-extern UINT64                      gAllOne;\r
-extern UINT64                      gAllZero;\r
-\r
-#include "PciIo.h"\r
-#include "PciCommand.h"\r
-#include "PciDeviceSupport.h"\r
-#include "PciEnumerator.h"\r
-#include "PciEnumeratorSupport.h"\r
-#include "PciDriverOverride.h"\r
-#include "PciRomTable.h"\r
-#include "PciOptionRomSupport.h"\r
-#include "PciPowerManagement.h"\r
-\r
-\r
-#define IS_ISA_BRIDGE(_p)       IS_CLASS2 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA)  \r
-#define IS_INTEL_ISA_BRIDGE(_p) (IS_CLASS2 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE) && ((_p)->Hdr.VendorId == 0x8086) && ((_p)->Hdr.DeviceId == 0x7110))\r
-#define IS_PCI_GFX(_p)     IS_CLASS2 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_OTHER)\r
-\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf b/DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf
deleted file mode 100644 (file)
index 86deb03..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-## @file\r
-# \r
-# Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#  Abstract:\r
-#\r
-##\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PciBusNoEnumerationDxe\r
-  FILE_GUID                      = 35C0C168-2607-4e51-BB53-448E3ED1A87F\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = PciBusEntryPoint\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  BaseLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  BaseMemoryLib\r
-  ReportStatusCodeLib\r
-  DevicePathLib\r
-  PeCoffLib\r
-\r
-[Sources]\r
-  PciBus.h\r
-  PciIo.h\r
-  PciCommand.h\r
-  PciDeviceSupport.h\r
-  PciEnumerator.h\r
-  PciEnumeratorSupport.h\r
-  PciOptionRomSupport.h\r
-  PciRomTable.h\r
-  PciPowerManagement.h\r
-  PciPowerManagement.c\r
-  PciRomTable.c\r
-  PciDriverOverride.h\r
-  PciDriverOverride.c\r
-  PciOptionRomSupport.c\r
-  PciEnumerator.c\r
-  PciEnumeratorSupport.c\r
-  PciCommand.c\r
-  ComponentName.c\r
-  PciDeviceSupport.c\r
-  PciBus.c\r
-  PciIo.c\r
-\r
-[Protocols]\r
-  gEfiPciRootBridgeIoProtocolGuid\r
-  gEfiPciIoProtocolGuid\r
-  gEfiDevicePathProtocolGuid\r
-  gEfiBusSpecificDriverOverrideProtocolGuid\r
-  gEfiDecompressProtocolGuid\r
-  \r
-[Guids]\r
-  gEfiPciOptionRomTableGuid\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciCommand.c b/DuetPkg/PciBusNoEnumerationDxe/PciCommand.c
deleted file mode 100644 (file)
index 203bed3..0000000
+++ /dev/null
@@ -1,453 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciCommand.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-\r
-EFI_STATUS \r
-PciReadCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  OUT UINT16       *Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  *Command = 0;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  return PciIo->Pci.Read (\r
-                PciIo, \r
-                EfiPciIoWidthUint16, \r
-                PCI_COMMAND_OFFSET, \r
-                1, \r
-                Command\r
-                );\r
-}\r
-  \r
-EFI_STATUS \r
-PciSetCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16                Temp;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-  \r
-  Temp = Command;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  return PciIo->Pci.Write (\r
-              PciIo, \r
-              EfiPciIoWidthUint16, \r
-              PCI_COMMAND_OFFSET, \r
-              1, \r
-              &Temp\r
-              );\r
-  \r
-}\r
-\r
-\r
-EFI_STATUS \r
-PciEnableCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16  OldCommand;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  OldCommand = 0;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  PciIo->Pci.Read (\r
-          PciIo, \r
-          EfiPciIoWidthUint16, \r
-          PCI_COMMAND_OFFSET, \r
-          1, \r
-          &OldCommand\r
-          );\r
-\r
-  OldCommand = (UINT16) (OldCommand | Command);\r
-\r
-  return PciIo->Pci.Write (\r
-              PciIo, \r
-              EfiPciIoWidthUint16, \r
-              PCI_COMMAND_OFFSET, \r
-              1, \r
-              &OldCommand\r
-              );\r
-  \r
-}\r
-\r
-\r
-EFI_STATUS \r
-PciDisableCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16  OldCommand;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  OldCommand = 0;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  PciIo->Pci.Read (\r
-          PciIo, \r
-          EfiPciIoWidthUint16, \r
-          PCI_COMMAND_OFFSET, \r
-          1, \r
-          &OldCommand\r
-          );\r
-\r
-  OldCommand = (UINT16) (OldCommand & ~(Command));\r
-\r
-  return PciIo->Pci.Write (\r
-            PciIo, \r
-            EfiPciIoWidthUint16, \r
-            PCI_COMMAND_OFFSET, \r
-            1, \r
-            &OldCommand\r
-           );\r
-  \r
-}\r
-\r
-\r
-\r
-EFI_STATUS \r
-PciSetBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16                Temp;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  Temp = Command;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  return PciIo->Pci.Write (\r
-                PciIo, \r
-                EfiPciIoWidthUint16, \r
-                PCI_BRIDGE_CONTROL_REGISTER_OFFSET, \r
-                1, \r
-                &Temp\r
-               );\r
\r
-}\r
-\r
-\r
-EFI_STATUS \r
-PciEnableBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16  OldCommand;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  OldCommand = 0;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  PciIo->Pci.Read (\r
-          PciIo, \r
-          EfiPciIoWidthUint16, \r
-          PCI_BRIDGE_CONTROL_REGISTER_OFFSET, \r
-          1, \r
-          &OldCommand\r
-          );\r
-\r
-  OldCommand = (UINT16) (OldCommand | Command);\r
-\r
-  return PciIo->Pci.Write (\r
-              PciIo, \r
-              EfiPciIoWidthUint16, \r
-              PCI_BRIDGE_CONTROL_REGISTER_OFFSET, \r
-              1, \r
-              &OldCommand\r
-             );\r
-  \r
-}\r
-\r
-EFI_STATUS \r
-PciDisableBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16  OldCommand;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  OldCommand = 0;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  PciIo->Pci.Read (\r
-          PciIo, \r
-          EfiPciIoWidthUint16, \r
-          PCI_BRIDGE_CONTROL_REGISTER_OFFSET, \r
-          1, \r
-          &OldCommand\r
-          );\r
-\r
-  OldCommand = (UINT16) (OldCommand & ~(Command));\r
-\r
-  return PciIo->Pci.Write (\r
-              PciIo, \r
-              EfiPciIoWidthUint16, \r
-              PCI_BRIDGE_CONTROL_REGISTER_OFFSET, \r
-              1, \r
-              &OldCommand\r
-              );\r
\r
-}\r
-\r
-\r
-\r
-EFI_STATUS \r
-PciReadBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  OUT UINT16       *Command\r
-)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-\r
-  *Command = 0;\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  return PciIo->Pci.Read (\r
-                PciIo, \r
-                EfiPciIoWidthUint16, \r
-                PCI_BRIDGE_CONTROL_REGISTER_OFFSET, \r
-                1, \r
-                Command\r
-                );\r
\r
-}\r
-\r
-BOOLEAN\r
-PciCapabilitySupport (\r
-  IN PCI_IO_DEVICE  *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-  \r
-  None\r
-\r
---*/\r
-// TODO:    PciIoDevice - add argument and description to function comment\r
-{\r
-\r
-  if (PciIoDevice->Pci.Hdr.Status & EFI_PCI_STATUS_CAPABILITY) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-EFI_STATUS\r
-LocateCapabilityRegBlock (\r
-  IN     PCI_IO_DEVICE *PciIoDevice,\r
-  IN     UINT8         CapId,\r
-  IN OUT UINT8         *Offset,\r
-     OUT UINT8         *NextRegBlock OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Locate Capability register.\r
-\r
-Arguments:\r
-\r
-  PciIoDevice         - A pointer to the PCI_IO_DEVICE.\r
-  CapId               - The capability ID.\r
-  Offset              - A pointer to the offset. \r
-                        As input: the default offset; \r
-                        As output: the offset of the found block.\r
-  NextRegBlock        - An optional pointer to return the value of next block.\r
-\r
-Returns:\r
-  \r
-  EFI_UNSUPPORTED     - The Pci Io device is not supported.\r
-  EFI_NOT_FOUND       - The Pci Io device cannot be found.\r
-  EFI_SUCCESS         - The Pci Io device is successfully located.\r
-\r
---*/\r
-{\r
-  UINT8   CapabilityPtr;\r
-  UINT16  CapabilityEntry;\r
-  UINT8   CapabilityID;\r
-\r
-  //\r
-  // To check the capability of this device supports\r
-  //\r
-  if (!PciCapabilitySupport (PciIoDevice)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (*Offset != 0) {\r
-    CapabilityPtr = *Offset;\r
-  } else {\r
-\r
-    CapabilityPtr = 0;\r
-    if (IS_CARDBUS_BRIDGE (&PciIoDevice->Pci)) {\r
-\r
-      PciIoDevice->PciIo.Pci.Read (\r
-                               &PciIoDevice->PciIo,\r
-                               EfiPciIoWidthUint8,\r
-                               EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR,\r
-                               1,\r
-                               &CapabilityPtr\r
-                               );\r
-    } else {\r
-\r
-      PciIoDevice->PciIo.Pci.Read (\r
-                               &PciIoDevice->PciIo,\r
-                               EfiPciIoWidthUint8,\r
-                               PCI_CAPBILITY_POINTER_OFFSET,\r
-                               1,\r
-                               &CapabilityPtr\r
-                               );\r
-    }\r
-  }\r
-\r
-  while ((CapabilityPtr >= 0x40) && ((CapabilityPtr & 0x03) == 0x00)) {\r
-    PciIoDevice->PciIo.Pci.Read (\r
-                             &PciIoDevice->PciIo,\r
-                             EfiPciIoWidthUint16,\r
-                             CapabilityPtr,\r
-                             1,\r
-                             &CapabilityEntry\r
-                             );\r
-\r
-    CapabilityID = (UINT8) CapabilityEntry;\r
-\r
-    if (CapabilityID == CapId) {\r
-      *Offset = CapabilityPtr;\r
-      if (NextRegBlock != NULL) {\r
-        *NextRegBlock = (UINT8) (CapabilityEntry >> 8);\r
-      }\r
-\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    CapabilityPtr = (UINT8) (CapabilityEntry >> 8);\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciCommand.h b/DuetPkg/PciBusNoEnumerationDxe/PciCommand.h
deleted file mode 100644 (file)
index 2c724df..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-    PciCommand.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_COMMAND_H\r
-#define _EFI_PCI_COMMAND_H\r
-\r
-#include "PciBus.h"\r
-\r
-//\r
-// The PCI Command register bits owned by PCI Bus driver.\r
-//\r
-// They should be cleared at the beginning. The other registers\r
-// are owned by chipset, we should not touch them.\r
-//\r
-#define EFI_PCI_COMMAND_BITS_OWNED                          ( \\r
-                EFI_PCI_COMMAND_IO_SPACE                    | \\r
-                EFI_PCI_COMMAND_MEMORY_SPACE                | \\r
-                EFI_PCI_COMMAND_BUS_MASTER                  | \\r
-                EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE | \\r
-                EFI_PCI_COMMAND_VGA_PALETTE_SNOOP           | \\r
-                EFI_PCI_COMMAND_FAST_BACK_TO_BACK             \\r
-                )\r
-\r
-//\r
-// The PCI Bridge Control register bits owned by PCI Bus driver.\r
-// \r
-// They should be cleared at the beginning. The other registers\r
-// are owned by chipset, we should not touch them.\r
-//\r
-#define EFI_PCI_BRIDGE_CONTROL_BITS_OWNED                   ( \\r
-                EFI_PCI_BRIDGE_CONTROL_ISA                  | \\r
-                EFI_PCI_BRIDGE_CONTROL_VGA                  | \\r
-                EFI_PCI_BRIDGE_CONTROL_VGA_16               | \\r
-                EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK      \\r
-                )\r
-\r
-//\r
-// The PCCard Bridge Control register bits owned by PCI Bus driver.\r
-// \r
-// They should be cleared at the beginning. The other registers\r
-// are owned by chipset, we should not touch them.\r
-//\r
-#define EFI_PCCARD_BRIDGE_CONTROL_BITS_OWNED                ( \\r
-                EFI_PCI_BRIDGE_CONTROL_ISA                  | \\r
-                EFI_PCI_BRIDGE_CONTROL_VGA                  | \\r
-                EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK      \\r
-                )\r
-\r
-EFI_STATUS \r
-PciReadCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  OUT UINT16       *Command\r
-);\r
-\r
-  \r
-EFI_STATUS \r
-PciSetCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-);\r
-\r
-EFI_STATUS \r
-PciEnableCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-);\r
-\r
-EFI_STATUS \r
-PciDisableCommandRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-);\r
-\r
-EFI_STATUS \r
-PciDisableBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-);\r
-\r
-\r
-EFI_STATUS \r
-PciEnableBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINT16        Command\r
-);\r
-\r
-EFI_STATUS \r
-PciReadBridgeControlRegister (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  OUT UINT16       *Command\r
-);\r
-\r
-BOOLEAN\r
-PciCapabilitySupport (\r
-  IN PCI_IO_DEVICE  *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciIoDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-LocateCapabilityRegBlock (\r
-  IN     PCI_IO_DEVICE *PciIoDevice,\r
-  IN     UINT8         CapId,\r
-  IN OUT UINT8         *Offset,\r
-     OUT UINT8         *NextRegBlock OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Locate Capability register.\r
-\r
-Arguments:\r
-\r
-  PciIoDevice         - A pointer to the PCI_IO_DEVICE.\r
-  CapId               - The capability ID.\r
-  Offset              - A pointer to the offset. \r
-                        As input: the default offset; \r
-                        As output: the offset of the found block.\r
-  NextRegBlock        - An optional pointer to return the value of next block.\r
-\r
-Returns:\r
-  \r
-  EFI_UNSUPPORTED     - The Pci Io device is not supported.\r
-  EFI_NOT_FOUND       - The Pci Io device cannot be found.\r
-  EFI_SUCCESS         - The Pci Io device is successfully located.\r
-\r
---*/\r
-;\r
-\r
-\r
-#endif\r
-\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciDeviceSupport.c b/DuetPkg/PciBusNoEnumerationDxe/PciDeviceSupport.c
deleted file mode 100644 (file)
index bae266d..0000000
+++ /dev/null
@@ -1,973 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciDeviceSupport.c\r
-  \r
-Abstract:\r
-\r
-  This file provides routine to support Pci device node manipulation\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-//\r
-// This device structure is serviced as a header.\r
-// Its Next field points to the first root bridge device node\r
-//\r
-LIST_ENTRY  gPciDevicePool;\r
-\r
-EFI_STATUS\r
-InitializePciDevicePool (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize the gPciDevicePool\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  InitializeListHead (&gPciDevicePool);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-InsertRootBridge (\r
-  IN PCI_IO_DEVICE *RootBridge\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Insert a root bridge into PCI device pool\r
-\r
-Arguments:\r
-\r
-  RootBridge    - A pointer to the PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  InsertTailList (&gPciDevicePool, &(RootBridge->Link));\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-InsertPciDevice (\r
-  PCI_IO_DEVICE *Bridge,\r
-  PCI_IO_DEVICE *PciDeviceNode\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is used to insert a PCI device node under\r
-  a bridge\r
-\r
-Arguments:\r
-  Bridge        - A pointer to the PCI_IO_DEVICE.\r
-  PciDeviceNode - A pointer to the PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-{\r
-\r
-  InsertTailList (&Bridge->ChildList, &(PciDeviceNode->Link));\r
-  PciDeviceNode->Parent = Bridge;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-DestroyRootBridge (\r
-  IN PCI_IO_DEVICE *RootBridge\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  \r
-Arguments:\r
-\r
-  RootBridge   - A pointer to the PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  DestroyPciDeviceTree (RootBridge);\r
-\r
-  gBS->FreePool (RootBridge);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-DestroyPciDeviceTree (\r
-  IN PCI_IO_DEVICE *Bridge\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Destroy all the pci device node under the bridge.\r
-  Bridge itself is not included.\r
-\r
-Arguments:\r
-\r
-  Bridge   - A pointer to the PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  LIST_ENTRY  *CurrentLink;\r
-  PCI_IO_DEVICE   *Temp;\r
-\r
-  while (!IsListEmpty (&Bridge->ChildList)) {\r
-\r
-    CurrentLink = Bridge->ChildList.ForwardLink;\r
-\r
-    //\r
-    // Remove this node from the linked list\r
-    //\r
-    RemoveEntryList (CurrentLink);\r
-\r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-\r
-    if (IS_PCI_BRIDGE (&(Temp->Pci))) {\r
-      DestroyPciDeviceTree (Temp);\r
-    }\r
-    gBS->FreePool (Temp);\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-DestroyRootBridgeByHandle (\r
-  EFI_HANDLE Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Destroy all device nodes under the root bridge\r
-  specified by Controller. \r
-  The root bridge itself is also included.\r
-\r
-Arguments:\r
-\r
-  Controller   - An efi handle.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  LIST_ENTRY  *CurrentLink;\r
-  PCI_IO_DEVICE   *Temp;\r
-\r
-  CurrentLink = gPciDevicePool.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &gPciDevicePool) {\r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-\r
-    if (Temp->Handle == Controller) {\r
-\r
-      RemoveEntryList (CurrentLink);\r
-\r
-      DestroyPciDeviceTree (Temp);\r
-\r
-      gBS->FreePool(Temp);\r
-\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-RegisterPciDevice (\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  PCI_IO_DEVICE                  *PciIoDevice,\r
-  OUT EFI_HANDLE                     *Handle OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function registers the PCI IO device. It creates a handle for this PCI IO device \r
-  (if the handle does not exist), attaches appropriate protocols onto the handle, does\r
-  necessary initialization, and sets up parent/child relationship with its bus controller.\r
-\r
-Arguments:\r
-\r
-  Controller    - An EFI handle for the PCI bus controller.\r
-  PciIoDevice   - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.\r
-  Handle        - A pointer to hold the EFI handle for the PCI IO device.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS   - The PCI device is successfully registered.\r
-  Others        - An error occurred when registering the PCI device.\r
-\r
---*/\r
-{\r
-  EFI_STATUS          Status;\r
-  UINT8               PciExpressCapRegOffset;\r
-\r
-  //\r
-  // Install the pciio protocol, device path protocol and \r
-  // Bus Specific Driver Override Protocol\r
-  //\r
-\r
-  if (PciIoDevice->BusOverride) {\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &PciIoDevice->Handle,             \r
-                  &gEfiDevicePathProtocolGuid,\r
-                  PciIoDevice->DevicePath,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  &PciIoDevice->PciIo,\r
-                  &gEfiBusSpecificDriverOverrideProtocolGuid,\r
-                  &PciIoDevice->PciDriverOverride,\r
-                  NULL\r
-                  );\r
-  } else {\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &PciIoDevice->Handle,             \r
-                  &gEfiDevicePathProtocolGuid,\r
-                  PciIoDevice->DevicePath,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  &PciIoDevice->PciIo,\r
-                  NULL\r
-                  );\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  } else {\r
-    Status = gBS->OpenProtocol (\r
-                    Controller,           \r
-                    &gEfiPciRootBridgeIoProtocolGuid, \r
-                    (VOID **)&(PciIoDevice->PciRootBridgeIo),\r
-                    gPciBusDriverBinding.DriverBindingHandle,\r
-                    PciIoDevice->Handle,   \r
-                    EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  if (Handle != NULL) {\r
-    *Handle = PciIoDevice->Handle;\r
-  }\r
-\r
-  //\r
-  // Detect if PCI Express Device\r
-  //\r
-  PciExpressCapRegOffset = 0;\r
-  Status = LocateCapabilityRegBlock (\r
-             PciIoDevice,\r
-             EFI_PCI_CAPABILITY_ID_PCIEXP,\r
-             &PciExpressCapRegOffset,\r
-             NULL\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    PciIoDevice->IsPciExp = TRUE;\r
-    DEBUG ((EFI_D_ERROR, "PciExp - %x (B-%x, D-%x, F-%x)\n", PciIoDevice->IsPciExp, PciIoDevice->BusNumber, PciIoDevice->DeviceNumber, PciIoDevice->FunctionNumber));\r
-  }\r
-  \r
-  //\r
-  // Indicate the pci device is registered\r
-  //\r
-  PciIoDevice->Registered = TRUE;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-DeRegisterPciDevice (\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  EFI_HANDLE                     Handle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is used to de-register the PCI device from the EFI,\r
-  That includes un-installing PciIo protocol from the specified PCI \r
-  device handle.\r
-\r
-Arguments:\r
-\r
-  Controller   - An efi handle.\r
-  Handle       - An efi handle.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_PCI_IO_PROTOCOL             *PciIo;\r
-  EFI_STATUS                      Status;\r
-  PCI_IO_DEVICE                   *PciIoDevice;\r
-  PCI_IO_DEVICE                   *Node;\r
-  LIST_ENTRY                  *CurrentLink;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  gPciBusDriverBinding.DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo);\r
-\r
-    //\r
-    // If it is already de-registered\r
-    //\r
-    if (!PciIoDevice->Registered) {\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    //\r
-    // If it is PPB, first de-register its children\r
-    //\r
-\r
-    if (IS_PCI_BRIDGE (&(PciIoDevice->Pci))) {\r
-\r
-      CurrentLink = PciIoDevice->ChildList.ForwardLink;\r
-\r
-      while (CurrentLink && CurrentLink != &PciIoDevice->ChildList) {\r
-        Node    = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-        Status  = DeRegisterPciDevice (Controller, Node->Handle);\r
-\r
-        if (EFI_ERROR (Status)) {\r
-          return Status;\r
-        }\r
-\r
-        CurrentLink = CurrentLink->ForwardLink;\r
-      }\r
-    }\r
-\r
-    //\r
-    // First disconnect this device\r
-    //\r
-//    PciIoDevice->PciIo.Attributes(&(PciIoDevice->PciIo),\r
-//                                    EfiPciIoAttributeOperationDisable,\r
-//                                    EFI_PCI_DEVICE_ENABLE,\r
-//                                    NULL\r
-//                                    );\r
-       \r
-    //\r
-    // Close the child handle\r
-    //\r
-    Status = gBS->CloseProtocol (\r
-                    Controller,\r
-                    &gEfiPciRootBridgeIoProtocolGuid,\r
-                    gPciBusDriverBinding.DriverBindingHandle,\r
-                    Handle\r
-                    );\r
-\r
-    //\r
-    // Un-install the device path protocol and pci io protocol\r
-    //\r
-    if (PciIoDevice->BusOverride) {\r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      Handle,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      PciIoDevice->DevicePath,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      &PciIoDevice->PciIo,\r
-                      &gEfiBusSpecificDriverOverrideProtocolGuid,\r
-                      &PciIoDevice->PciDriverOverride,\r
-                      NULL\r
-                      );\r
-    } else {\r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      Handle,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      PciIoDevice->DevicePath,\r
-                      &gEfiPciIoProtocolGuid,\r
-                      &PciIoDevice->PciIo,\r
-                      NULL\r
-                      );\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      gBS->OpenProtocol (\r
-            Controller,\r
-            &gEfiPciRootBridgeIoProtocolGuid,\r
-            (VOID **) &PciRootBridgeIo,\r
-            gPciBusDriverBinding.DriverBindingHandle,\r
-            Handle,\r
-            EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-            );\r
-      return Status;\r
-    }\r
-    \r
-    //\r
-    // The Device Driver should disable this device after disconnect\r
-    // so the Pci Bus driver will not touch this device any more.\r
-    // Restore the register field to the original value\r
-    //\r
-    PciIoDevice->Registered = FALSE;\r
-    PciIoDevice->Handle     = NULL;\r
-  } else {\r
-\r
-    //\r
-    // Handle may be closed before\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EnableBridgeAttributes (\r
-  IN PCI_IO_DEVICE                       *PciIoDevice\r
-  )\r
-{\r
-  PCI_TYPE01                PciData;\r
-\r
-  //\r
-  // NOTE: We should not set EFI_PCI_DEVICE_ENABLE for a bridge\r
-  //       directly, because some legacy BIOS will NOT assign\r
-  //       IO or Memory resource for a bridge who has no child\r
-  //       device. So we add check IO or Memory here.\r
-  //\r
-\r
-  PciIoDevice->PciIo.Pci.Read (\r
-                           &PciIoDevice->PciIo,\r
-                           EfiPciIoWidthUint8,\r
-                           0,\r
-                           sizeof (PciData),\r
-                           &PciData\r
-                           );\r
-\r
-  if ((((PciData.Bridge.IoBase & 0xF) == 0) &&\r
-        (PciData.Bridge.IoBase != 0 || PciData.Bridge.IoLimit != 0)) ||\r
-      (((PciData.Bridge.IoBase & 0xF) == 1) &&\r
-        ((PciData.Bridge.IoBase & 0xF0) != 0 || (PciData.Bridge.IoLimit & 0xF0) != 0 || PciData.Bridge.IoBaseUpper16 != 0 || PciData.Bridge.IoLimitUpper16 != 0))) {\r
-    PciIoDevice->PciIo.Attributes(\r
-                         &(PciIoDevice->PciIo),\r
-                         EfiPciIoAttributeOperationEnable,\r
-                         (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),\r
-                         NULL\r
-                         );\r
-  }\r
-  if ((PciData.Bridge.MemoryBase & 0xFFF0) != 0 || (PciData.Bridge.MemoryLimit & 0xFFF0) != 0) {\r
-    PciIoDevice->PciIo.Attributes(\r
-                         &(PciIoDevice->PciIo),\r
-                         EfiPciIoAttributeOperationEnable,\r
-                         (EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),\r
-                         NULL\r
-                         );\r
-  }\r
-  if ((((PciData.Bridge.PrefetchableMemoryBase & 0xF) == 0) &&\r
-        (PciData.Bridge.PrefetchableMemoryBase != 0 || PciData.Bridge.PrefetchableMemoryLimit != 0)) ||\r
-      (((PciData.Bridge.PrefetchableMemoryBase & 0xF) == 1) &&\r
-        ((PciData.Bridge.PrefetchableMemoryBase & 0xFFF0) != 0 || (PciData.Bridge.PrefetchableMemoryLimit & 0xFFF0) != 0 || PciData.Bridge.PrefetchableBaseUpper32 != 0 || PciData.Bridge.PrefetchableLimitUpper32 != 0))) {\r
-    PciIoDevice->PciIo.Attributes(\r
-                         &(PciIoDevice->PciIo),\r
-                         EfiPciIoAttributeOperationEnable,\r
-                         (EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),\r
-                         NULL\r
-                         );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS \r
-StartPciDevicesOnBridge (\r
-  IN EFI_HANDLE                          Controller,\r
-  IN PCI_IO_DEVICE                       *RootBridge,\r
-  IN EFI_DEVICE_PATH_PROTOCOL            *RemainingDevicePath \r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Start to manage the PCI device on specified the root bridge or PCI-PCI Bridge\r
-\r
-Arguments:\r
-\r
-  Controller          - An efi handle.\r
-  RootBridge          - A pointer to the PCI_IO_DEVICE.\r
-  RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.\r
-  NumberOfChildren    - Children number.\r
-  ChildHandleBuffer   - A pointer to the child handle buffer.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE             *Temp;\r
-  PCI_IO_DEVICE             *PciIoDevice;\r
-  EFI_DEV_PATH_PTR          Node;\r
-  EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;\r
-  EFI_STATUS                Status;\r
-  LIST_ENTRY            *CurrentLink;\r
-\r
-  CurrentLink = RootBridge->ChildList.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &RootBridge->ChildList) {\r
-\r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-    if (RemainingDevicePath != NULL) {\r
-\r
-      Node.DevPath = RemainingDevicePath;\r
-\r
-      if (Node.Pci->Device != Temp->DeviceNumber || \r
-          Node.Pci->Function != Temp->FunctionNumber) {\r
-        CurrentLink = CurrentLink->ForwardLink;\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // Check if the device has been assigned with required resource\r
-      //\r
-      if (!Temp->Allocated) {\r
-        return EFI_NOT_READY;\r
-      }\r
-      \r
-      //\r
-      // Check if the current node has been registered before\r
-      // If it is not, register it\r
-      //\r
-      if (!Temp->Registered) {\r
-        PciIoDevice = Temp;\r
-\r
-        Status = RegisterPciDevice (\r
-                  Controller,\r
-                  PciIoDevice,\r
-                  NULL\r
-                  );\r
-\r
-      }\r
-      \r
-      //\r
-      // Get the next device path\r
-      //\r
-      CurrentDevicePath = NextDevicePathNode (RemainingDevicePath);\r
-      if (IsDevicePathEnd (CurrentDevicePath)) {\r
-        return EFI_SUCCESS;\r
-      }\r
-  \r
-      //\r
-      // If it is a PPB\r
-      //\r
-      if (IS_PCI_BRIDGE (&(Temp->Pci))) {\r
-        Status = StartPciDevicesOnBridge (\r
-                  Controller,\r
-                  Temp,\r
-                  CurrentDevicePath\r
-                  );\r
-        EnableBridgeAttributes (Temp);\r
-\r
-        return Status;\r
-      } else {\r
-\r
-        //\r
-        // Currently, the PCI bus driver only support PCI-PCI bridge\r
-        //\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-\r
-    } else {\r
-\r
-      //\r
-      // If remaining device path is NULL,\r
-      // try to enable all the pci devices under this bridge\r
-      //\r
-\r
-      if (!Temp->Registered && Temp->Allocated) {\r
-\r
-        PciIoDevice = Temp;\r
-\r
-        Status = RegisterPciDevice (\r
-                  Controller,\r
-                  PciIoDevice,\r
-                  NULL\r
-                  );\r
-\r
-      }\r
-\r
-      if (IS_PCI_BRIDGE (&(Temp->Pci))) {\r
-        Status = StartPciDevicesOnBridge ( \r
-                   Controller,\r
-                   Temp,\r
-                   RemainingDevicePath\r
-                   );\r
-        EnableBridgeAttributes (Temp);\r
-      }\r
-\r
-      CurrentLink = CurrentLink->ForwardLink;\r
-      continue;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-StartPciDevices (\r
-  IN EFI_HANDLE                         Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL           *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Start to manage the PCI device according to RemainingDevicePath\r
-  If RemainingDevicePath == NULL, the PCI bus driver will start \r
-  to manage all the PCI devices it found previously\r
-\r
-Arguments:\r
-  Controller          - An efi handle.\r
-  RemainingDevicePath - A pointer to the EFI_DEVICE_PATH_PROTOCOL.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_DEV_PATH_PTR  Node;\r
-  PCI_IO_DEVICE     *RootBridge;\r
-  LIST_ENTRY    *CurrentLink;\r
-\r
-  if (RemainingDevicePath != NULL) {\r
-\r
-    //\r
-    // Check if the RemainingDevicePath is valid\r
-    //\r
-    Node.DevPath = RemainingDevicePath;\r
-    if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||\r
-        Node.DevPath->SubType != HW_PCI_DP         ||\r
-        DevicePathNodeLength (Node.DevPath) != sizeof (PCI_DEVICE_PATH)\r
-        ) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  CurrentLink = gPciDevicePool.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &gPciDevicePool) {\r
-\r
-    RootBridge = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-    //\r
-    // Locate the right root bridge to start\r
-    //\r
-    if (RootBridge->Handle == Controller) {\r
-      StartPciDevicesOnBridge (\r
-        Controller,\r
-        RootBridge,\r
-        RemainingDevicePath\r
-        );\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-CreateRootBridge (\r
-  IN EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-  RootBridgeHandle   - An efi handle.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  EFI_STATUS                      Status;\r
-  PCI_IO_DEVICE                   *Dev;\r
-\r
-  Dev = NULL;\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (PCI_IO_DEVICE),\r
-                  (VOID **) &Dev\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return NULL;\r
-  }\r
-\r
-  ZeroMem (Dev, sizeof (PCI_IO_DEVICE));\r
-  Dev->Signature  = PCI_IO_DEVICE_SIGNATURE;\r
-  Dev->Handle     = RootBridgeHandle;\r
-  InitializeListHead (&Dev->ChildList);\r
-\r
-  return Dev;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-GetRootBridgeByHandle (\r
-  EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-\r
-  RootBridgeHandle    - An efi handle.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE   *RootBridgeDev;\r
-  LIST_ENTRY  *CurrentLink;\r
-\r
-  CurrentLink = gPciDevicePool.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &gPciDevicePool) {\r
-\r
-    RootBridgeDev = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-    if (RootBridgeDev->Handle == RootBridgeHandle) {\r
-      return RootBridgeDev;\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-BOOLEAN\r
-RootBridgeExisted (\r
-  IN EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function searches if RootBridgeHandle has already existed\r
-  in current device pool.\r
-\r
-  If so, it means the given root bridge has been already enumerated.\r
-\r
-Arguments:\r
-\r
-  RootBridgeHandle   - An efi handle.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE *Bridge;\r
-\r
-  Bridge = GetRootBridgeByHandle (RootBridgeHandle);\r
-\r
-  if (Bridge != NULL) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-BOOLEAN\r
-PciDeviceExisted (\r
-  IN PCI_IO_DEVICE    *Bridge,\r
-  IN PCI_IO_DEVICE    *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-Arguments:\r
-\r
-  Bridge       - A pointer to the PCI_IO_DEVICE.\r
-  PciIoDevice  - A pointer to the PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  PCI_IO_DEVICE   *Temp;\r
-  LIST_ENTRY  *CurrentLink;\r
-\r
-  CurrentLink = Bridge->ChildList.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &Bridge->ChildList) {\r
-\r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-\r
-    if (Temp == PciIoDevice) {\r
-      return TRUE;\r
-    }\r
-\r
-    if (!IsListEmpty (&Temp->ChildList)) {\r
-      if (PciDeviceExisted (Temp, PciIoDevice)) {\r
-        return TRUE;\r
-      }\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-ActiveVGADeviceOnTheSameSegment (\r
-  IN PCI_IO_DEVICE        *VgaDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-  VgaDevice    - A pointer to the PCI_IO_DEVICE.\r
-  \r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  LIST_ENTRY  *CurrentLink;\r
-  PCI_IO_DEVICE   *Temp;\r
-\r
-  CurrentLink = gPciDevicePool.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &gPciDevicePool) {\r
-\r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-\r
-    if (Temp->PciRootBridgeIo->SegmentNumber == VgaDevice->PciRootBridgeIo->SegmentNumber) {\r
-\r
-      Temp = ActiveVGADeviceOnTheRootBridge (Temp);\r
-\r
-      if (Temp != NULL) {\r
-        return Temp;\r
-      }\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-ActiveVGADeviceOnTheRootBridge (\r
-  IN PCI_IO_DEVICE        *RootBridge\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-  RootBridge    - A pointer to the PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  LIST_ENTRY  *CurrentLink;\r
-  PCI_IO_DEVICE   *Temp;\r
-\r
-  CurrentLink = RootBridge->ChildList.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &RootBridge->ChildList) {\r
-\r
-    Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);\r
-\r
-    if (IS_PCI_VGA(&Temp->Pci) && \r
-        (Temp->Attributes &\r
-         (EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY |\r
-          EFI_PCI_IO_ATTRIBUTE_VGA_IO     |\r
-          EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))) {\r
-      return Temp;\r
-    }\r
-\r
-    if (IS_PCI_BRIDGE (&Temp->Pci)) {\r
-\r
-      Temp = ActiveVGADeviceOnTheRootBridge (Temp);\r
-\r
-      if (Temp != NULL) {\r
-        return Temp;\r
-      }\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return NULL;\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciDeviceSupport.h b/DuetPkg/PciBusNoEnumerationDxe/PciDeviceSupport.h
deleted file mode 100644 (file)
index 7fbe4bb..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciDeviceSupport.h\r
-  \r
-Abstract:\r
-\r
-  \r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_DEVICE_SUPPORT_H\r
-#define _EFI_PCI_DEVICE_SUPPORT_H\r
-\r
-EFI_STATUS\r
-InitializePciDevicePool (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-InsertPciDevice (\r
-  PCI_IO_DEVICE *Bridge,\r
-  PCI_IO_DEVICE *PciDeviceNode\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Bridge        - TODO: add argument description\r
-  PciDeviceNode - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DestroyPciDeviceTree (\r
-  IN PCI_IO_DEVICE *Bridge\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Bridge  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DestroyRootBridgeByHandle (\r
-  EFI_HANDLE Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Controller  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-RegisterPciDevice (\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  PCI_IO_DEVICE                  *PciIoDevice,\r
-  OUT EFI_HANDLE                     *Handle OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function registers the PCI IO device. It creates a handle for this PCI IO device \r
-  (if the handle does not exist), attaches appropriate protocols onto the handle, does\r
-  necessary initialization, and sets up parent/child relationship with its bus controller.\r
-\r
-Arguments:\r
-\r
-  Controller    - An EFI handle for the PCI bus controller.\r
-  PciIoDevice   - A PCI_IO_DEVICE pointer to the PCI IO device to be registered.\r
-  Handle        - A pointer to hold the EFI handle for the PCI IO device.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS   - The PCI device is successfully registered.\r
-  Others        - An error occurred when registering the PCI device.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-DeRegisterPciDevice (\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  EFI_HANDLE                     Handle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Controller  - TODO: add argument description\r
-  Handle      - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-StartPciDevices (\r
-  IN EFI_HANDLE                         Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL           *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Controller          - TODO: add argument description\r
-  RemainingDevicePath - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-PCI_IO_DEVICE *\r
-CreateRootBridge (\r
-  IN EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  RootBridgeHandle  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-PCI_IO_DEVICE *\r
-GetRootBridgeByHandle (\r
-  EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  RootBridgeHandle  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS \r
-InsertRootBridge (\r
-  PCI_IO_DEVICE *RootBridge\r
-);\r
-\r
-EFI_STATUS \r
-DestroyRootBridge ( \r
-   IN PCI_IO_DEVICE *RootBridge \r
-);\r
-\r
-BOOLEAN\r
-RootBridgeExisted (\r
-  IN EFI_HANDLE RootBridgeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  RootBridgeHandle  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-BOOLEAN\r
-PciDeviceExisted (\r
-  IN PCI_IO_DEVICE    *Bridge,\r
-  IN PCI_IO_DEVICE    *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Bridge      - TODO: add argument description\r
-  PciIoDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-PCI_IO_DEVICE *\r
-ActiveVGADeviceOnTheSameSegment (\r
-  IN PCI_IO_DEVICE        *VgaDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  VgaDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-PCI_IO_DEVICE *\r
-ActiveVGADeviceOnTheRootBridge (\r
-  IN PCI_IO_DEVICE        *RootBridge\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  RootBridge  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciDriverOverride.c b/DuetPkg/PciBusNoEnumerationDxe/PciDriverOverride.c
deleted file mode 100644 (file)
index 388ee94..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciDriverOverride.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetDriver(\r
-  IN     EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL          *This,\r
-  IN OUT EFI_HANDLE                                         *DriverImageHandle\r
-  );\r
-\r
-\r
-\r
-EFI_STATUS\r
-InitializePciDriverOverrideInstance (\r
-  PCI_IO_DEVICE  *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initializes a PCI Driver Override Instance\r
-\r
-Arguments:\r
-  \r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-{\r
-  PciIoDevice->PciDriverOverride.GetDriver = GetDriver;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetDriver (\r
-  IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL              *This,\r
-  IN OUT EFI_HANDLE                                         *DriverImageHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get a overriding driver image\r
-\r
-Arguments:\r
-  \r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE             *PciIoDevice;\r
-  LIST_ENTRY            *CurrentLink;\r
-  PCI_DRIVER_OVERRIDE_LIST  *Node;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_DRIVER_OVERRIDE_THIS (This);\r
-\r
-  CurrentLink = PciIoDevice->OptionRomDriverList.ForwardLink;\r
-\r
-  while (CurrentLink && CurrentLink != &PciIoDevice->OptionRomDriverList) {\r
-\r
-    Node = DRIVER_OVERRIDE_FROM_LINK (CurrentLink);\r
-\r
-    if (*DriverImageHandle == NULL) {\r
-\r
-      *DriverImageHandle = Node->DriverImageHandle;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    if (*DriverImageHandle == Node->DriverImageHandle) {\r
-\r
-      if (CurrentLink->ForwardLink == &PciIoDevice->OptionRomDriverList ||\r
-          CurrentLink->ForwardLink == NULL) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      //\r
-      // Get next node\r
-      //\r
-      Node                = DRIVER_OVERRIDE_FROM_LINK (CurrentLink->ForwardLink);\r
-      *DriverImageHandle  = Node->DriverImageHandle;\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    CurrentLink = CurrentLink->ForwardLink;\r
-  }\r
-\r
-  return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-EFI_STATUS\r
-AddDriver (\r
-  IN PCI_IO_DEVICE     *PciIoDevice,\r
-  IN EFI_HANDLE        DriverImageHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add a overriding driver image\r
-\r
-Arguments:\r
-  \r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_LOADED_IMAGE_PROTOCOL     *LoadedImage;\r
-  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
-  PCI_DRIVER_OVERRIDE_LIST      *Node;\r
-\r
-  Status = gBS->HandleProtocol (DriverImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Node = AllocatePool (sizeof (PCI_DRIVER_OVERRIDE_LIST));\r
-  if (Node == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Node->Signature         = DRIVER_OVERRIDE_SIGNATURE;\r
-  Node->DriverImageHandle = DriverImageHandle;\r
-\r
-  InsertTailList (&PciIoDevice->OptionRomDriverList, &(Node->Link));\r
-\r
-  PciIoDevice->BusOverride  = TRUE;\r
-\r
-\r
-  ImageContext.Handle    = LoadedImage->ImageBase;\r
-  ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r
-\r
-  //\r
-  // Get information about the image \r
-  //\r
-  Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (ImageContext.Machine != EFI_IMAGE_MACHINE_EBC) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciDriverOverride.h b/DuetPkg/PciBusNoEnumerationDxe/PciDriverOverride.h
deleted file mode 100644 (file)
index fa2d339..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciDriverOverride.h\r
-  \r
-Abstract:\r
-\r
-  \r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_DRIVER_OVERRRIDE_H\r
-#define _EFI_PCI_DRIVER_OVERRRIDE_H\r
-\r
-#include "PciBus.h"\r
-\r
-#define DRIVER_OVERRIDE_SIGNATURE SIGNATURE_32 ('d', 'r', 'o', 'v')\r
-\r
-typedef struct {\r
-  UINT32          Signature;\r
-  LIST_ENTRY  Link;\r
-  EFI_HANDLE      DriverImageHandle;\r
-} PCI_DRIVER_OVERRIDE_LIST;\r
-\r
-\r
-#define DRIVER_OVERRIDE_FROM_LINK(a) \\r
-  CR (a, PCI_DRIVER_OVERRIDE_LIST, Link, DRIVER_OVERRIDE_SIGNATURE)\r
-\r
-\r
-EFI_STATUS\r
-InitializePciDriverOverrideInstance (\r
-  PCI_IO_DEVICE  *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciIoDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-AddDriver (\r
-  IN PCI_IO_DEVICE     *PciIoDevice,\r
-  IN EFI_HANDLE        DriverImageHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciIoDevice       - TODO: add argument description\r
-  DriverImageHandle - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetDriver (\r
-  IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL              *This,\r
-  IN OUT EFI_HANDLE                                         *DriverImageHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This              - TODO: add argument description\r
-  DriverImageHandle - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumerator.c b/DuetPkg/PciBusNoEnumerationDxe/PciEnumerator.c
deleted file mode 100644 (file)
index 9f7dd47..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciEnumerator.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-EFI_STATUS\r
-PciEnumerator (\r
-  IN EFI_HANDLE                    Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine is used to enumerate entire pci bus system \r
-  in a given platform\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  //\r
-  // This PCI bus driver depends on the legacy BIOS\r
-  // to do the resource allocation\r
-  //\r
-  gFullEnumeration = FALSE;\r
-\r
-  return PciEnumeratorLight (Controller) ;\r
-  \r
-}\r
-\r
-\r
-\r
-\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumerator.h b/DuetPkg/PciBusNoEnumerationDxe/PciEnumerator.h
deleted file mode 100644 (file)
index f1125df..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciEnumerator.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_ENUMERATOR_H\r
-#define _EFI_PCI_ENUMERATOR_H\r
-\r
-EFI_STATUS\r
-PciEnumerator (\r
-  IN EFI_HANDLE                    Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Controller  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
deleted file mode 100644 (file)
index ca300cf..0000000
+++ /dev/null
@@ -1,1385 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-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
-  PciEnumeratorSupport.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-EFI_STATUS \r
-InitializePPB (\r
-  IN PCI_IO_DEVICE *PciIoDevice \r
-);\r
-\r
-EFI_STATUS \r
-InitializeP2C (\r
-  IN PCI_IO_DEVICE *PciIoDevice \r
-);\r
-\r
-PCI_IO_DEVICE* \r
-CreatePciIoDevice (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-);\r
-\r
-\r
-PCI_IO_DEVICE*\r
-GatherP2CInfo (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-);\r
-\r
-UINTN\r
-PciParseBar (\r
-  IN PCI_IO_DEVICE  *PciIoDevice,\r
-  IN UINTN          Offset,\r
-  IN UINTN          BarIndex\r
-);\r
-\r
-\r
-EFI_STATUS\r
-PciSearchDevice (\r
-  IN PCI_IO_DEVICE                      *Bridge,\r
-  PCI_TYPE00                            *Pci,\r
-  UINT8                                 Bus,\r
-  UINT8                                 Device,\r
-  UINT8                                 Func,\r
-  PCI_IO_DEVICE                         **PciDevice\r
-);\r
-\r
-\r
-EFI_STATUS \r
-DetermineDeviceAttribute (\r
-  IN PCI_IO_DEVICE                      *PciIoDevice\r
-);\r
-\r
-EFI_STATUS \r
-BarExisted (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINTN         Offset,\r
-  OUT UINT32       *BarLengthValue,\r
-  OUT UINT32       *OriginalBarValue\r
-  );\r
-\r
-\r
-\r
-EFI_DEVICE_PATH_PROTOCOL*\r
-CreatePciDevicePath(\r
-  IN  EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
-  IN  PCI_IO_DEVICE            *PciIoDevice \r
-);\r
-\r
-PCI_IO_DEVICE* \r
-GatherDeviceInfo (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-);\r
-\r
-PCI_IO_DEVICE* \r
-GatherPPBInfo (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-);\r
-\r
-EFI_STATUS\r
-PciDevicePresent (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  PCI_TYPE00                          *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine is used to check whether the pci device is present\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT64      Address;\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Create PCI address map in terms of Bus, Device and Func\r
-  //\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);\r
-\r
-  //\r
-  // Read the Vendor Id register\r
-  //\r
-  Status = PciRootBridgeIo->Pci.Read (\r
-                                  PciRootBridgeIo,\r
-                                  EfiPciWidthUint32,\r
-                                  Address,\r
-                                  1,\r
-                                  Pci\r
-                                  );\r
-\r
-  if (!EFI_ERROR (Status) && (Pci->Hdr).VendorId != 0xffff) {\r
-\r
-    //\r
-    // Read the entire config header for the device\r
-    //\r
-\r
-    Status = PciRootBridgeIo->Pci.Read (\r
-                                    PciRootBridgeIo,\r
-                                    EfiPciWidthUint32,\r
-                                    Address,\r
-                                    sizeof (PCI_TYPE00) / sizeof (UINT32),\r
-                                    Pci\r
-                                    );\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-PciPciDeviceInfoCollector (\r
-  IN PCI_IO_DEVICE                      *Bridge,\r
-  UINT8                                 StartBusNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS          Status;\r
-  PCI_TYPE00          Pci;\r
-  UINT8               Device;\r
-  UINT8               Func;\r
-  UINT8               SecBus;\r
-  PCI_IO_DEVICE       *PciIoDevice;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-\r
-  Status      = EFI_SUCCESS;\r
-  SecBus      = 0;\r
-  PciIoDevice = NULL;\r
-\r
-  for (Device = 0; Device <= PCI_MAX_DEVICE; Device++) {\r
-\r
-    for (Func = 0; Func <= PCI_MAX_FUNC; Func++) {\r
-\r
-      //\r
-      // Check to see whether PCI device is present\r
-      //\r
-\r
-      Status = PciDevicePresent (\r
-                Bridge->PciRootBridgeIo,\r
-                &Pci,\r
-                (UINT8) StartBusNumber,\r
-                (UINT8) Device,\r
-                (UINT8) Func\r
-                );\r
-\r
-      if (EFI_ERROR (Status) && Func == 0) {\r
-        //\r
-        // go to next device if there is no Function 0\r
-        //\r
-        break;\r
-      }\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-\r
-        //\r
-        // Collect all the information about the PCI device discovered\r
-        //\r
-        Status = PciSearchDevice (\r
-                  Bridge,\r
-                  &Pci,\r
-                  (UINT8) StartBusNumber,\r
-                  Device,\r
-                  Func,\r
-                  &PciIoDevice\r
-                  );\r
-\r
-        //\r
-        // Recursively scan PCI busses on the other side of PCI-PCI bridges\r
-        //\r
-        //\r
-\r
-        if (!EFI_ERROR (Status) && (IS_PCI_BRIDGE (&Pci) || IS_CARDBUS_BRIDGE (&Pci))) {\r
-\r
-          //\r
-          // If it is PPB, we need to get the secondary bus to continue the enumeration\r
-          //\r
-          PciIo   = &(PciIoDevice->PciIo);\r
-\r
-          Status  = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x19, 1, &SecBus);\r
-\r
-          if (EFI_ERROR (Status)) {\r
-            return Status;\r
-          }\r
-              \r
-          //\r
-          // If the PCI bridge is initialized then enumerate the next level bus\r
-          //\r
-          if (SecBus != 0) {\r
-            Status = PciPciDeviceInfoCollector (\r
-                      PciIoDevice,\r
-                      (UINT8) (SecBus)\r
-                      );\r
-          }\r
-        }\r
-\r
-        if (Func == 0 && !IS_PCI_MULTI_FUNC (&Pci)) {\r
-\r
-          //\r
-          // Skip sub functions, this is not a multi function device\r
-          //\r
-          Func = PCI_MAX_FUNC;\r
-        }\r
-      }\r
-\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PciSearchDevice (\r
-  IN  PCI_IO_DEVICE                         *Bridge,\r
-  IN  PCI_TYPE00                            *Pci,\r
-  IN  UINT8                                 Bus,\r
-  IN  UINT8                                 Device,\r
-  IN  UINT8                                 Func,\r
-  OUT PCI_IO_DEVICE                         **PciDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Search required device.\r
-\r
-Arguments:\r
-\r
-  Bridge     - A pointer to the PCI_IO_DEVICE.\r
-  Pci        - A pointer to the PCI_TYPE00.\r
-  Bus        - Bus number.\r
-  Device     - Device number.\r
-  Func       - Function number.\r
-  PciDevice  - The Required pci device.\r
-\r
-Returns:\r
-\r
-  Status code.\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = NULL;\r
-\r
-  if (!IS_PCI_BRIDGE (Pci)) {\r
-\r
-    if (IS_CARDBUS_BRIDGE (Pci)) {\r
-      PciIoDevice = GatherP2CInfo (\r
-                      Bridge->PciRootBridgeIo,\r
-                      Pci,\r
-                      Bus,\r
-                      Device,\r
-                      Func\r
-                      );\r
-      if ((PciIoDevice != NULL) && (gFullEnumeration == TRUE)) {\r
-        InitializeP2C (PciIoDevice);\r
-      }\r
-    } else {\r
-\r
-      //\r
-      // Create private data for Pci Device\r
-      //\r
-      PciIoDevice = GatherDeviceInfo (\r
-                      Bridge->PciRootBridgeIo,\r
-                      Pci,\r
-                      Bus,\r
-                      Device,\r
-                      Func\r
-                      );\r
-\r
-    }\r
-\r
-  } else {\r
-\r
-    //\r
-    // Create private data for PPB\r
-    //\r
-    PciIoDevice = GatherPPBInfo (\r
-                    Bridge->PciRootBridgeIo,\r
-                    Pci,\r
-                    Bus,\r
-                    Device,\r
-                    Func\r
-                    );\r
-\r
-    //\r
-    // Special initialization for PPB including making the PPB quiet\r
-    //\r
-    if ((PciIoDevice != NULL) && (gFullEnumeration == TRUE)) {\r
-      InitializePPB (PciIoDevice);\r
-    }\r
-  }\r
-\r
-  if (!PciIoDevice) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  \r
-  //\r
-  // Create a device path for this PCI device and store it into its private data\r
-  //\r
-  CreatePciDevicePath(\r
-    Bridge->DevicePath,\r
-    PciIoDevice \r
-    );\r
-  \r
-  //\r
-  // Detect this function has option rom\r
-  //\r
-  if (gFullEnumeration) {\r
-\r
-    if (!IS_CARDBUS_BRIDGE (Pci)) {\r
-\r
-      GetOpRomInfo (PciIoDevice);\r
-\r
-    }\r
-\r
-    ResetPowerManagementFeature (PciIoDevice);\r
-    \r
-  } \r
-  else {\r
-    PciRomGetRomResourceFromPciOptionRomTable (\r
-      &gPciBusDriverBinding,\r
-      PciIoDevice->PciRootBridgeIo,\r
-      PciIoDevice\r
-      );\r
-  }\r
-\r
\r
-  //\r
-  // Insert it into a global tree for future reference\r
-  //\r
-  InsertPciDevice (Bridge, PciIoDevice);\r
-\r
-  //\r
-  // Determine PCI device attributes\r
-  //\r
-  DetermineDeviceAttribute (PciIoDevice);\r
-\r
-  if (PciDevice != NULL) {\r
-    *PciDevice = PciIoDevice;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-GatherDeviceInfo (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINTN                           Offset;\r
-  UINTN                           BarIndex;\r
-  PCI_IO_DEVICE                   *PciIoDevice;\r
-\r
-  PciIoDevice = CreatePciIoDevice (\r
-                  PciRootBridgeIo,\r
-                  Pci,\r
-                  Bus,\r
-                  Device,\r
-                  Func\r
-                  );\r
-\r
-  if (!PciIoDevice) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // If it is a full enumeration, disconnect the device in advance\r
-  //\r
-  if (gFullEnumeration) {\r
-\r
-    PciDisableCommandRegister (PciIoDevice, EFI_PCI_COMMAND_BITS_OWNED);\r
-\r
-  }\r
-\r
-  //\r
-  // Start to parse the bars\r
-  //\r
-  for (Offset = 0x10, BarIndex = 0; Offset <= 0x24; BarIndex++) {\r
-    Offset = PciParseBar (PciIoDevice, Offset, BarIndex);\r
-  }\r
-\r
-  return PciIoDevice;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-GatherPPBInfo (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE                   *PciIoDevice;\r
-  EFI_STATUS                      Status;\r
-  UINT8                           Value;\r
-  EFI_PCI_IO_PROTOCOL             *PciIo;\r
-  UINT8                           Temp;\r
-\r
-  PciIoDevice = CreatePciIoDevice (\r
-                  PciRootBridgeIo,\r
-                  Pci,\r
-                  Bus,\r
-                  Device,\r
-                  Func\r
-                  );\r
-\r
-  if (!PciIoDevice) {\r
-    return NULL;\r
-  }\r
-  \r
-  if (gFullEnumeration) {\r
-    PciDisableCommandRegister (PciIoDevice, EFI_PCI_COMMAND_BITS_OWNED);\r
-\r
-    //\r
-    // Initalize the bridge control register\r
-    //\r
-    PciDisableBridgeControlRegister (PciIoDevice, EFI_PCI_BRIDGE_CONTROL_BITS_OWNED);\r
-  }\r
-\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  //\r
-  // Test whether it support 32 decode or not\r
-  //\r
-  PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x1C, 1, &Temp);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x1C, 1, &gAllOne);\r
-  PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x1C, 1, &Value);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x1C, 1, &Temp);\r
-\r
-  if (Value) {\r
-    if (Value & 0x01) {\r
-      PciIoDevice->Decodes |= EFI_BRIDGE_IO32_DECODE_SUPPORTED;\r
-    } else {\r
-      PciIoDevice->Decodes |= EFI_BRIDGE_IO16_DECODE_SUPPORTED;\r
-    }\r
-  }\r
-\r
-  Status = BarExisted (\r
-            PciIoDevice,\r
-            0x24,\r
-            NULL,\r
-            NULL\r
-            );\r
-\r
-  //\r
-  // test if it supports 64 memory or not\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    Status = BarExisted (\r
-              PciIoDevice,\r
-              0x28,\r
-              NULL,\r
-              NULL\r
-              );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      PciIoDevice->Decodes |= EFI_BRIDGE_PMEM32_DECODE_SUPPORTED;\r
-      PciIoDevice->Decodes |= EFI_BRIDGE_PMEM64_DECODE_SUPPORTED;\r
-    } else {\r
-      PciIoDevice->Decodes |= EFI_BRIDGE_PMEM32_DECODE_SUPPORTED;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Memory 32 code is required for ppb\r
-  //\r
-  PciIoDevice->Decodes |= EFI_BRIDGE_MEM32_DECODE_SUPPORTED;\r
-\r
-  return PciIoDevice;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-GatherP2CInfo (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE         *PciIoDevice;\r
-  \r
-  PciIoDevice = CreatePciIoDevice (\r
-                  PciRootBridgeIo,\r
-                  Pci,\r
-                  Bus,\r
-                  Device,\r
-                  Func\r
-                  );\r
-\r
-  if (!PciIoDevice) {\r
-    return NULL;\r
-  }\r
-\r
-  if (gFullEnumeration) {\r
-    PciDisableCommandRegister (PciIoDevice, EFI_PCI_COMMAND_BITS_OWNED);\r
-\r
-    //\r
-    // Initalize the bridge control register\r
-    //\r
-    PciDisableBridgeControlRegister (PciIoDevice, EFI_PCCARD_BRIDGE_CONTROL_BITS_OWNED);\r
-\r
-  }\r
-  //\r
-  // P2C only has one bar that is in 0x10\r
-  //\r
-  PciParseBar(PciIoDevice, 0x10, 0);\r
-  \r
-  PciIoDevice->Decodes = EFI_BRIDGE_MEM32_DECODE_SUPPORTED  |\r
-                         EFI_BRIDGE_PMEM32_DECODE_SUPPORTED |\r
-                         EFI_BRIDGE_IO32_DECODE_SUPPORTED;\r
-\r
-  return PciIoDevice;\r
-}\r
-\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-CreatePciDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
-  IN  PCI_IO_DEVICE            *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  PCI_DEVICE_PATH PciNode;\r
-\r
-  //\r
-  // Create PCI device path\r
-  //\r
-  PciNode.Header.Type     = HARDWARE_DEVICE_PATH;\r
-  PciNode.Header.SubType  = HW_PCI_DP;\r
-  SetDevicePathNodeLength (&PciNode.Header, sizeof (PciNode));\r
-\r
-  PciNode.Device          = PciIoDevice->DeviceNumber;\r
-  PciNode.Function        = PciIoDevice->FunctionNumber;\r
-  PciIoDevice->DevicePath = AppendDevicePathNode (ParentDevicePath, &PciNode.Header);\r
-\r
-  return PciIoDevice->DevicePath;\r
-}\r
-\r
-EFI_STATUS\r
-BarExisted (\r
-  IN PCI_IO_DEVICE *PciIoDevice,\r
-  IN UINTN         Offset,\r
-  OUT UINT32       *BarLengthValue,\r
-  OUT UINT32       *OriginalBarValue\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check the bar is existed or not.\r
-\r
-Arguments:\r
-\r
-  PciIoDevice       - A pointer to the PCI_IO_DEVICE.\r
-  Offset            - The offset.\r
-  BarLengthValue    - The bar length value.\r
-  OriginalBarValue  - The original bar value.\r
-\r
-Returns:\r
-\r
-  EFI_NOT_FOUND     - The bar don't exist.\r
-  EFI_SUCCESS       - The bar exist.\r
-\r
---*/\r
-{\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-  UINT32              OriginalValue;\r
-  UINT32              Value;\r
-  EFI_TPL             OldTpl;\r
-\r
-  PciIo = &PciIoDevice->PciIo;\r
-\r
-  //\r
-  // Preserve the original value\r
-  //\r
-\r
-  PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, (UINT8) Offset, 1, &OriginalValue);\r
-\r
-  //\r
-  // Raise TPL to high level to disable timer interrupt while the BAR is probed\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, (UINT8) Offset, 1, &gAllOne);\r
-  PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, (UINT8) Offset, 1, &Value);\r
-\r
-  //\r
-  // Write back the original value\r
-  //\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, (UINT8) Offset, 1, &OriginalValue);\r
-\r
-  //\r
-  // Restore TPL to its original level\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  if (BarLengthValue != NULL) {\r
-    *BarLengthValue = Value;\r
-  }\r
-\r
-  if (OriginalBarValue != NULL) {\r
-    *OriginalBarValue = OriginalValue;\r
-  }\r
-\r
-  if (Value == 0) {\r
-    return EFI_NOT_FOUND;\r
-  } else {\r
-    return EFI_SUCCESS;\r
-  }\r
-}\r
-\r
-\r
-EFI_STATUS\r
-DetermineDeviceAttribute (\r
-  IN PCI_IO_DEVICE                      *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
\r
-  Determine the related attributes of all devices under a Root Bridge\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT16          Command;\r
-  UINT16          BridgeControl;\r
-\r
-  Command = 0;\r
-\r
-  PciIoDevice->Supports |= EFI_PCI_DEVICE_ENABLE;\r
-  PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE;\r
-\r
-  if (IS_PCI_VGA (&(PciIoDevice->Pci))){\r
-\r
-    //\r
-    // If the device is VGA, VGA related Attributes are supported\r
-    //\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO ;\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY   ;\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_VGA_IO    ;\r
-  }\r
-\r
-  if(IS_ISA_BRIDGE(&(PciIoDevice->Pci)) || IS_INTEL_ISA_BRIDGE(&(PciIoDevice->Pci))) {\r
-    //\r
-    // If the devie is a ISA Bridge, set the two attributes\r
-    //\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO;\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_ISA_IO;\r
-  }\r
-\r
-  if (IS_PCI_GFX (&(PciIoDevice->Pci))) {\r
-\r
-    //\r
-    // If the device is GFX, then only set the EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO\r
-    // attribute\r
-    //\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO    ;\r
-  }\r
-\r
-\r
-  //\r
-  // If the device is IDE, IDE related attributes are supported\r
-  //\r
-  if (IS_PCI_IDE (&(PciIoDevice->Pci))) {\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO  ;\r
-    PciIoDevice->Supports |= EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO  ;\r
-  }\r
-\r
-  PciReadCommandRegister(PciIoDevice, &Command);\r
-\r
-  \r
-  if (Command & EFI_PCI_COMMAND_IO_SPACE) {\r
-    PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_IO;\r
-  }\r
-\r
-  if (Command & EFI_PCI_COMMAND_MEMORY_SPACE) {\r
-    PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_MEMORY;\r
-  }\r
-\r
-  if (Command & EFI_PCI_COMMAND_BUS_MASTER) {\r
-    PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_BUS_MASTER;\r
-  }\r
-\r
-  if (IS_PCI_BRIDGE (&(PciIoDevice->Pci)) || \r
-      IS_CARDBUS_BRIDGE (&(PciIoDevice->Pci))){\r
-\r
-    //\r
-    // If it is a PPB, read the Bridge Control Register to determine\r
-    // the relevant attributes\r
-    //\r
-    BridgeControl = 0;\r
-    PciReadBridgeControlRegister(PciIoDevice, &BridgeControl);\r
-\r
-    //\r
-    // Determine whether the ISA bit is set\r
-    // If ISA Enable on Bridge is set, the PPB\r
-    // will block forwarding 0x100-0x3ff for each 1KB in the \r
-    // first 64KB I/O range.\r
-    //\r
-    if ((BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA) != 0) {\r
-      PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_ISA_IO;\r
-    } \r
-\r
-    //\r
-    // Determine whether the VGA bit is set\r
-    // If it is set, the bridge is set to decode VGA memory range\r
-    // and palette register range\r
-    //\r
-    if (IS_PCI_VGA (&(PciIoDevice->Pci)) &&BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA) {\r
-      PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_IO;\r
-      PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY;\r
-      PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO;\r
-    }\r
-\r
-    //\r
-    // if the palette snoop bit is set, then the brige is set to \r
-    // decode palette IO write\r
-    //\r
-    if (Command & EFI_PCI_COMMAND_VGA_PALETTE_SNOOP) {\r
-      PciIoDevice->Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO;\r
-    }\r
-  } \r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINTN\r
-PciParseBar (\r
-  IN PCI_IO_DEVICE  *PciIoDevice,\r
-  IN UINTN          Offset,\r
-  IN UINTN          BarIndex\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT32      Value;\r
-  UINT32      OriginalValue;\r
-  UINT32      Mask;\r
-  EFI_STATUS  Status;\r
-\r
-  OriginalValue = 0;\r
-  Value         = 0;\r
-\r
-  Status = BarExisted (\r
-            PciIoDevice,\r
-            Offset,\r
-            &Value,\r
-            &OriginalValue\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    PciIoDevice->PciBar[BarIndex].BaseAddress = 0;\r
-    PciIoDevice->PciBar[BarIndex].Length      = 0;\r
-    PciIoDevice->PciBar[BarIndex].Alignment   = 0;\r
-\r
-    //\r
-    // Some devices don't fully comply to PCI spec 2.2. So be to scan all the BARs anyway\r
-    //\r
-    PciIoDevice->PciBar[BarIndex].Offset = (UINT8) Offset;\r
-    return Offset + 4;\r
-  }\r
-\r
-  PciIoDevice->PciBar[BarIndex].Offset = (UINT8) Offset;\r
-  if (Value & 0x01) {\r
-    //\r
-    // Device I/Os\r
-    //\r
-    Mask = 0xfffffffc;\r
-\r
-    if (Value & 0xFFFF0000) {\r
-      //\r
-      // It is a IO32 bar\r
-      //\r
-      PciIoDevice->PciBar[BarIndex].BarType   = PciBarTypeIo32;\r
-      PciIoDevice->PciBar[BarIndex].Length    = ((~(Value & Mask)) + 1);\r
-      PciIoDevice->PciBar[BarIndex].Alignment = PciIoDevice->PciBar[BarIndex].Length - 1;\r
-\r
-    } else {\r
-      //\r
-      // It is a IO16 bar\r
-      //\r
-      PciIoDevice->PciBar[BarIndex].BarType   = PciBarTypeIo16;\r
-      PciIoDevice->PciBar[BarIndex].Length    = 0x0000FFFF & ((~(Value & Mask)) + 1);\r
-      PciIoDevice->PciBar[BarIndex].Alignment = PciIoDevice->PciBar[BarIndex].Length - 1;\r
-\r
-    }\r
-    //\r
-    // Workaround. Some platforms inplement IO bar with 0 length\r
-    // Need to treat it as no-bar\r
-    //\r
-    if (PciIoDevice->PciBar[BarIndex].Length == 0) {\r
-      PciIoDevice->PciBar[BarIndex].BarType = PciBarTypeUnknown;\r
-    }\r
-\r
-    PciIoDevice->PciBar[BarIndex].Prefetchable  = FALSE;\r
-    PciIoDevice->PciBar[BarIndex].BaseAddress   = OriginalValue & Mask;\r
-\r
-  } else {\r
-\r
-    Mask  = 0xfffffff0;\r
-\r
-    PciIoDevice->PciBar[BarIndex].BaseAddress = OriginalValue & Mask;\r
-\r
-    switch (Value & 0x07) {\r
-\r
-    //\r
-    //memory space; anywhere in 32 bit address space\r
-    //\r
-    case 0x00:\r
-      if (Value & 0x08) {\r
-        PciIoDevice->PciBar[BarIndex].BarType = PciBarTypePMem32;\r
-      } else {\r
-        PciIoDevice->PciBar[BarIndex].BarType = PciBarTypeMem32;\r
-      }\r
-\r
-      PciIoDevice->PciBar[BarIndex].Length    = (~(Value & Mask)) + 1;\r
-      PciIoDevice->PciBar[BarIndex].Alignment = PciIoDevice->PciBar[BarIndex].Length - 1;\r
-\r
-      break;\r
-\r
-    //\r
-    // memory space; anywhere in 64 bit address space\r
-    //\r
-    case 0x04:\r
-      if (Value & 0x08) {\r
-        PciIoDevice->PciBar[BarIndex].BarType = PciBarTypePMem64;\r
-      } else {\r
-        PciIoDevice->PciBar[BarIndex].BarType = PciBarTypeMem64;\r
-      }\r
-\r
-      //\r
-      // According to PCI 2.2,if the bar indicates a memory 64 decoding, next bar\r
-      // is regarded as an extension for the first bar. As a result\r
-      // the sizing will be conducted on combined 64 bit value\r
-      // Here just store the masked first 32bit value for future size\r
-      // calculation\r
-      //\r
-      PciIoDevice->PciBar[BarIndex].Length    = Value & Mask;\r
-      PciIoDevice->PciBar[BarIndex].Alignment = PciIoDevice->PciBar[BarIndex].Length - 1;\r
-\r
-      //\r
-      // Increment the offset to point to next DWORD\r
-      //\r
-      Offset += 4;\r
-\r
-      Status = BarExisted (\r
-                PciIoDevice,\r
-                Offset,\r
-                &Value,\r
-                &OriginalValue\r
-                );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        return Offset + 4;\r
-      }\r
-\r
-      //\r
-      // Fix the length to support some spefic 64 bit BAR\r
-      //\r
-      Value |= ((UINT32)(-1) << HighBitSet32 (Value)); \r
-\r
-      //\r
-      // Calculate the size of 64bit bar\r
-      //\r
-      PciIoDevice->PciBar[BarIndex].BaseAddress |= LShiftU64 ((UINT64) OriginalValue, 32);\r
-\r
-      PciIoDevice->PciBar[BarIndex].Length    = PciIoDevice->PciBar[BarIndex].Length | LShiftU64 ((UINT64) Value, 32);\r
-      PciIoDevice->PciBar[BarIndex].Length    = (~(PciIoDevice->PciBar[BarIndex].Length)) + 1;\r
-      PciIoDevice->PciBar[BarIndex].Alignment = PciIoDevice->PciBar[BarIndex].Length - 1;\r
-\r
-      break;\r
-\r
-    //\r
-    // reserved\r
-    //\r
-    default:\r
-      PciIoDevice->PciBar[BarIndex].BarType   = PciBarTypeUnknown;\r
-      PciIoDevice->PciBar[BarIndex].Length    = (~(Value & Mask)) + 1;\r
-      PciIoDevice->PciBar[BarIndex].Alignment = PciIoDevice->PciBar[BarIndex].Length - 1;\r
-\r
-      break;\r
-    }\r
-  }\r
-  \r
-  //\r
-  // Check the length again so as to keep compatible with some special bars\r
-  //\r
-  if (PciIoDevice->PciBar[BarIndex].Length == 0) {\r
-    PciIoDevice->PciBar[BarIndex].BarType     = PciBarTypeUnknown;\r
-    PciIoDevice->PciBar[BarIndex].BaseAddress = 0;\r
-    PciIoDevice->PciBar[BarIndex].Alignment   = 0;\r
-  }\r
-  \r
-  //\r
-  // Increment number of bar\r
-  //\r
-  return Offset + 4;\r
-}\r
-\r
-EFI_STATUS\r
-InitializePPB (\r
-  IN PCI_IO_DEVICE *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-\r
-  PciIo = &(PciIoDevice->PciIo);\r
-\r
-  //\r
-  // Put all the resource apertures including IO16\r
-  // Io32, pMem32, pMem64 to quiescent state\r
-  // Resource base all ones, Resource limit all zeros\r
-  //\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x1C, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x1D, 1, &gAllZero);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x20, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x22, 1, &gAllZero);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x24, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x26, 1, &gAllZero);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x28, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x2C, 1, &gAllZero);\r
-\r
-  //\r
-  // don't support use io32 as for now\r
-  //\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x30, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x32, 1, &gAllZero);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-InitializeP2C (\r
-  IN PCI_IO_DEVICE *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-\r
-  PciIo = &(PciIoDevice->PciIo);\r
-\r
-  //\r
-  // Put all the resource apertures including IO16\r
-  // Io32, pMem32, pMem64 to quiescent state(\r
-  // Resource base all ones, Resource limit all zeros\r
-  //\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1c, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x20, 1, &gAllZero);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x24, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x28, 1, &gAllZero);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x2c, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x30, 1, &gAllZero);\r
-\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x34, 1, &gAllOne);\r
-  PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x38, 1, &gAllZero);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-PCI_IO_DEVICE *\r
-CreatePciIoDevice (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  IN PCI_TYPE00                       *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = NULL;\r
-\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (PCI_IO_DEVICE),\r
-                  (VOID **) &PciIoDevice\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return NULL;\r
-  }\r
-\r
-  ZeroMem (PciIoDevice, sizeof (PCI_IO_DEVICE));\r
-\r
-  PciIoDevice->Signature        = PCI_IO_DEVICE_SIGNATURE;\r
-  PciIoDevice->Handle           = NULL;\r
-  PciIoDevice->PciRootBridgeIo  = PciRootBridgeIo;\r
-  PciIoDevice->DevicePath       = NULL;\r
-  PciIoDevice->BusNumber        = Bus;\r
-  PciIoDevice->DeviceNumber     = Device;\r
-  PciIoDevice->FunctionNumber   = Func;\r
-  PciIoDevice->Decodes          = 0;\r
-  if (gFullEnumeration) {\r
-    PciIoDevice->Allocated = FALSE;\r
-  } else {\r
-    PciIoDevice->Allocated = TRUE;\r
-  }\r
-\r
-  PciIoDevice->Attributes         = 0;\r
-  PciIoDevice->Supports           = 0;\r
-  PciIoDevice->BusOverride        = FALSE;\r
-  PciIoDevice->IsPciExp           = FALSE;\r
-\r
-  CopyMem (&(PciIoDevice->Pci), Pci, sizeof (PCI_TYPE01));\r
-\r
-  //\r
-  // Initialize the PCI I/O instance structure\r
-  //\r
-\r
-  Status  = InitializePciIoInstance (PciIoDevice);\r
-  Status  = InitializePciDriverOverrideInstance (PciIoDevice);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (PciIoDevice);\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Initialize the reserved resource list\r
-  //\r
-  InitializeListHead (&PciIoDevice->ReservedResourceList);\r
-\r
-  //\r
-  // Initialize the driver list\r
-  //\r
-  InitializeListHead (&PciIoDevice->OptionRomDriverList);\r
-\r
-  //\r
-  // Initialize the child list\r
-  //\r
-  InitializeListHead (&PciIoDevice->ChildList);\r
-\r
-  return PciIoDevice;\r
-}\r
-\r
-EFI_STATUS\r
-PciEnumeratorLight (\r
-  IN EFI_HANDLE                    Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine is used to enumerate entire pci bus system \r
-  in a given platform\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-\r
-  EFI_STATUS                        Status;\r
-  EFI_DEVICE_PATH_PROTOCOL          *ParentDevicePath;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL   *PciRootBridgeIo;\r
-  PCI_IO_DEVICE                     *RootBridgeDev;\r
-  UINT16                            MinBus;\r
-  UINT16                            MaxBus;\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;\r
-\r
-  MinBus      = 0;\r
-  MaxBus      = PCI_MAX_BUS;\r
-  Descriptors = NULL;\r
-\r
-  //\r
-  // If this host bridge has been already enumerated, then return successfully\r
-  //\r
-  if (RootBridgeExisted (Controller)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller      ,   \r
-                  &gEfiDevicePathProtocolGuid,  \r
-                  (VOID **)&ParentDevicePath,\r
-                  gPciBusDriverBinding.DriverBindingHandle,     \r
-                  Controller,   \r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Open pci root bridge io protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciRootBridgeIoProtocolGuid,\r
-                  (VOID **) &PciRootBridgeIo,\r
-                  gPciBusDriverBinding.DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Load all EFI Drivers from all PCI Option ROMs behind the PCI Root Bridge \r
-  //\r
-  Status = PciRomLoadEfiDriversFromOptionRomTable (&gPciBusDriverBinding, PciRootBridgeIo);\r
-\r
-  Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Descriptors);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  while (PciGetBusRange (&Descriptors, &MinBus, &MaxBus, NULL) == EFI_SUCCESS) {\r
-\r
-    //\r
-    // Create a device node for root bridge device with a NULL host bridge controller handle\r
-    //\r
-    RootBridgeDev = CreateRootBridge (Controller);\r
-\r
-    //\r
-    // Record the root bridge device path\r
-    //\r
-    RootBridgeDev->DevicePath = ParentDevicePath;\r
-\r
-    //\r
-    // Record the root bridge io protocol\r
-    //\r
-    RootBridgeDev->PciRootBridgeIo = PciRootBridgeIo;\r
-\r
-    Status = PciPciDeviceInfoCollector (\r
-              RootBridgeDev,\r
-              (UINT8) MinBus\r
-              );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-\r
-      //\r
-      // If successfully, insert the node into device pool\r
-      //\r
-      InsertRootBridge (RootBridgeDev);\r
-    } else {\r
-\r
-      //\r
-      // If unsuccessly, destroy the entire node\r
-      //\r
-      DestroyRootBridge (RootBridgeDev);\r
-    }\r
-\r
-    Descriptors++;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PciGetBusRange (\r
-  IN     EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  **Descriptors,\r
-  OUT    UINT16                             *MinBus,\r
-  OUT    UINT16                             *MaxBus,\r
-  OUT    UINT16                             *BusRange\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the bus range.\r
-\r
-Arguments:\r
-\r
-  Descriptors     - A pointer to the address space descriptor.\r
-  MinBus          - The min bus.\r
-  MaxBus          - The max bus.\r
-  BusRange        - The bus range.\r
-  \r
-Returns:\r
-  \r
-  Status Code.\r
-\r
---*/\r
-{\r
-\r
-  while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) {\r
-    if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {\r
-      if (MinBus != NULL) {\r
-        *MinBus = (UINT16)(*Descriptors)->AddrRangeMin;\r
-      }\r
-\r
-      if (MaxBus != NULL) {\r
-        *MaxBus = (UINT16)(*Descriptors)->AddrRangeMax;\r
-      }\r
-\r
-      if (BusRange != NULL) {\r
-        *BusRange = (UINT16)(*Descriptors)->AddrLen;\r
-      }\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    (*Descriptors)++;\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.h b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.h
deleted file mode 100644 (file)
index d30c75c..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciEnumeratorSupport.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_ENUMERATOR_SUPPORT_H\r
-#define _EFI_PCI_ENUMERATOR_SUPPORT_H\r
-\r
-#include "PciBus.h"\r
-\r
-EFI_STATUS\r
-PciPciDeviceInfoCollector (\r
-  IN PCI_IO_DEVICE                      *Bridge,\r
-  UINT8                                 StartBusNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Bridge          - TODO: add argument description\r
-  StartBusNumber  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-PciDevicePresent(\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  PCI_TYPE00                          *Pci,\r
-  UINT8                               Bus,\r
-  UINT8                               Device,\r
-  UINT8                               Func\r
-);\r
-\r
-EFI_STATUS\r
-PciEnumeratorLight (\r
-  IN EFI_HANDLE                    Controller\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Controller  - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-PciGetBusRange (\r
-  IN     EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  **Descriptors,\r
-  OUT    UINT16                             *MinBus,\r
-  OUT    UINT16                             *MaxBus,\r
-  OUT    UINT16                             *BusRange\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  Descriptors - TODO: add argument description\r
-  MinBus      - TODO: add argument description\r
-  MaxBus      - TODO: add argument description\r
-  BusRange    - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciIo.c b/DuetPkg/PciBusNoEnumerationDxe/PciIo.c
deleted file mode 100644 (file)
index 9f47373..0000000
+++ /dev/null
@@ -1,1852 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciIo.c\r
-  \r
-Abstract:\r
-\r
-  PCI I/O Abstraction Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-//\r
-// PCI I/O Support Function Prototypes\r
-//\r
-//\r
-\r
-BOOLEAN \r
-PciDevicesOnTheSamePath (\r
-  IN PCI_IO_DEVICE       *PciDevice1,\r
-  IN PCI_IO_DEVICE       *PciDevice2\r
-);\r
-\r
-\r
-EFI_STATUS \r
-UpStreamBridgesAttributes (\r
-  IN  PCI_IO_DEVICE                            *PciIoDevice,\r
-  IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,\r
-  IN  UINT64                                   Attributes\r
-);\r
-\r
-\r
-BOOLEAN \r
-CheckBarType ( \r
-  IN PCI_IO_DEVICE  *PciIoDevice,\r
-  UINT8             BarIndex,\r
-  PCI_BAR_TYPE      BarType\r
-);\r
-\r
-\r
-EFI_STATUS \r
-SetBootVGA ( \r
-  IN  PCI_IO_DEVICE                  *PciIoDevice\r
-);\r
-\r
-EFI_STATUS \r
-DisableBootVGA ( \r
-  IN  PCI_IO_DEVICE                  *PciIoDevice\r
-);\r
-\r
-\r
-EFI_STATUS\r
-PciIoVerifyBarAccess (\r
-  PCI_IO_DEVICE                 *PciIoDevice,\r
-  UINT8                         BarIndex,\r
-  PCI_BAR_TYPE                  Type,\r
-  IN EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  UINT64                        *Offset\r
-);\r
-\r
-EFI_STATUS\r
-PciIoVerifyConfigAccess (\r
-  PCI_IO_DEVICE                 *PciIoDevice,\r
-  IN EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  IN UINT64                     *Offset\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoPollMem (\r
-  IN  EFI_PCI_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT8                      BarIndex,\r
-  IN  UINT64                     Offset,\r
-  IN  UINT64                     Mask,\r
-  IN  UINT64                     Value,\r
-  IN  UINT64                     Delay,\r
-  OUT UINT64                     *Result\r
-);\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-PciIoPollIo (\r
-  IN  EFI_PCI_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT8                      BarIndex,\r
-  IN  UINT64                     Offset,\r
-  IN  UINT64                     Mask,\r
-  IN  UINT64                     Value,\r
-  IN  UINT64                     Delay,\r
-  OUT UINT64                     *Result\r
-);    \r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoMemRead (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoMemWrite (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoIoRead (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoIoWrite (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoConfigRead (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT32                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoConfigWrite (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT32                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoCopyMem (\r
-  IN     EFI_PCI_IO_PROTOCOL  *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
-  IN     UINT8                        DestBarIndex,\r
-  IN     UINT64                       DestOffset,\r
-  IN     UINT8                        SrcBarIndex,\r
-  IN     UINT64                       SrcOffset,\r
-  IN     UINTN                        Count\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoMap (\r
-  IN     EFI_PCI_IO_PROTOCOL            *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoUnmap (\r
-  IN  EFI_PCI_IO_PROTOCOL  *This,\r
-  IN  VOID                 *Mapping\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoAllocateBuffer (\r
-  IN  EFI_PCI_IO_PROTOCOL    *This,\r
-  IN  EFI_ALLOCATE_TYPE      Type,\r
-  IN  EFI_MEMORY_TYPE        MemoryType,\r
-  IN  UINTN                  Pages,\r
-  OUT VOID                   **HostAddress,\r
-  IN  UINT64                 Attributes\r
-);\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoFreeBuffer (\r
-  IN  EFI_PCI_IO_PROTOCOL   *This,\r
-  IN  UINTN                 Pages,\r
-  IN  VOID                  *HostAddress\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoFlush (\r
-  IN  EFI_PCI_IO_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoGetLocation (\r
-  IN  EFI_PCI_IO_PROTOCOL  *This,\r
-  OUT UINTN                *Segment,\r
-  OUT UINTN                *Bus,\r
-  OUT UINTN                *Device,\r
-  OUT UINTN                *Function\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoAttributes (\r
-  IN  EFI_PCI_IO_PROTOCOL              *This,\r
-  IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,\r
-  IN  UINT64                                   Attributes,\r
-  OUT UINT64                                   *Result   OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoGetBarAttributes(\r
-  IN  EFI_PCI_IO_PROTOCOL    *This,\r
-  IN  UINT8                          BarIndex,\r
-  OUT UINT64                         *Supports,   OPTIONAL\r
-  OUT VOID                           **Resources  OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoSetBarAttributes(\r
-  IN     EFI_PCI_IO_PROTOCOL  *This,\r
-  IN     UINT64                       Attributes,\r
-  IN     UINT8                        BarIndex,\r
-  IN OUT UINT64                       *Offset,\r
-  IN OUT UINT64                       *Length\r
-  );\r
-\r
-\r
-//\r
-// Pci Io Protocol Interface\r
-//\r
-EFI_PCI_IO_PROTOCOL  PciIoInterface = {\r
-  PciIoPollMem,\r
-  PciIoPollIo,\r
-  {\r
-    PciIoMemRead,\r
-    PciIoMemWrite\r
-  },\r
-  {\r
-    PciIoIoRead,\r
-    PciIoIoWrite\r
-  },\r
-  {\r
-    PciIoConfigRead,\r
-    PciIoConfigWrite\r
-  },\r
-  PciIoCopyMem,\r
-  PciIoMap,\r
-  PciIoUnmap,\r
-  PciIoAllocateBuffer,\r
-  PciIoFreeBuffer,\r
-  PciIoFlush,\r
-  PciIoGetLocation,\r
-  PciIoAttributes,\r
-  PciIoGetBarAttributes,\r
-  PciIoSetBarAttributes,\r
-  0,\r
-  NULL\r
-};\r
-\r
-\r
-EFI_STATUS\r
-InitializePciIoInstance (\r
-  PCI_IO_DEVICE  *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initializes a PCI I/O Instance\r
-\r
-Arguments:\r
-  \r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-{\r
-  CopyMem (&PciIoDevice->PciIo, &PciIoInterface, sizeof (EFI_PCI_IO_PROTOCOL));\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PciIoVerifyBarAccess (\r
-  PCI_IO_DEVICE                   *PciIoDevice,\r
-  UINT8                           BarIndex,\r
-  PCI_BAR_TYPE                    Type,\r
-  IN EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
-  IN UINTN                        Count,\r
-  UINT64                          *Offset\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Verifies access to a PCI Base Address Register (BAR)\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BarIndex == EFI_PCI_IO_PASS_THROUGH_BAR) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // BarIndex 0-5 is legal\r
-  //\r
-  if (BarIndex >= PCI_MAX_BAR) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (!CheckBarType (PciIoDevice, BarIndex, Type)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If Width is EfiPciIoWidthFifoUintX then convert to EfiPciIoWidthUintX\r
-  // If Width is EfiPciIoWidthFillUintX then convert to EfiPciIoWidthUintX\r
-  //\r
-  if (Width >= EfiPciIoWidthFifoUint8 && Width <= EfiPciIoWidthFifoUint64) {\r
-    Count = 1;\r
-  }\r
-\r
-  Width = (EFI_PCI_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-\r
-  if ((*Offset + Count * ((UINTN)1 << Width)) - 1 >= PciIoDevice->PciBar[BarIndex].Length) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Offset = *Offset + PciIoDevice->PciBar[BarIndex].BaseAddress;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PciIoVerifyConfigAccess (\r
-  PCI_IO_DEVICE                 *PciIoDevice,\r
-  IN EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINTN                      Count,\r
-  IN UINT64                     *Offset\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Verifies access to a PCI Config Header\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT64  ExtendOffset;\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If Width is EfiPciIoWidthFifoUintX then convert to EfiPciIoWidthUintX\r
-  // If Width is EfiPciIoWidthFillUintX then convert to EfiPciIoWidthUintX\r
-  //\r
-  Width = (EFI_PCI_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-\r
-  if (PciIoDevice->IsPciExp) {\r
-    if ((*Offset + Count * ((UINTN)1 << Width)) - 1 >= PCI_EXP_MAX_CONFIG_OFFSET) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    ExtendOffset  = LShiftU64 (*Offset, 32);\r
-    *Offset       = EFI_PCI_ADDRESS (PciIoDevice->BusNumber, PciIoDevice->DeviceNumber, PciIoDevice->FunctionNumber, 0);\r
-    *Offset       = (*Offset) | ExtendOffset;\r
-\r
-  } else {\r
-    if ((*Offset + Count * ((UINTN)1 << Width)) - 1 >= PCI_MAX_CONFIG_OFFSET) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    *Offset = EFI_PCI_ADDRESS (PciIoDevice->BusNumber, PciIoDevice->DeviceNumber, PciIoDevice->FunctionNumber, *Offset);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoPollMem (\r
-  IN  EFI_PCI_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT8                      BarIndex,\r
-  IN  UINT64                     Offset,\r
-  IN  UINT64                     Mask,\r
-  IN  UINT64                     Value,\r
-  IN  UINT64                     Delay,\r
-  OUT UINT64                     *Result\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Poll PCI Memmory\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, BarIndex, PciBarTypeMem, Width, 1, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Width > EfiPciIoWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->PollMem (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                          Offset,\r
-                                          Mask,\r
-                                          Value,\r
-                                          Delay,\r
-                                          Result\r
-                                          );\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoPollIo (\r
-  IN  EFI_PCI_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT8                      BarIndex,\r
-  IN  UINT64                     Offset,\r
-  IN  UINT64                     Mask,\r
-  IN  UINT64                     Value,\r
-  IN  UINT64                     Delay,\r
-  OUT UINT64                     *Result\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Poll PCI IO\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width > EfiPciIoWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, BarIndex, PciBarTypeIo, Width, 1, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->PollIo (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                          Offset,\r
-                                          Mask,\r
-                                          Value,\r
-                                          Delay,\r
-                                          Result\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoMemRead (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs a PCI Memory Read Cycle\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  if (Buffer == NULL){\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, BarIndex, PciBarTypeMem, Width, Count, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Mem.Read (\r
-                                              PciIoDevice->PciRootBridgeIo,\r
-                                              (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                              Offset,\r
-                                              Count,\r
-                                              Buffer\r
-                                              );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoMemWrite (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs a PCI Memory Write Cycle\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  if (Buffer == NULL){\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, BarIndex, PciBarTypeMem, Width, Count, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Mem.Write (\r
-                                              PciIoDevice->PciRootBridgeIo,\r
-                                              (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                              Offset,\r
-                                              Count,\r
-                                              Buffer\r
-                                              );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoIoRead (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs a PCI I/O Read Cycle\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  if (Buffer == NULL){\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, BarIndex, PciBarTypeIo, Width, Count, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Io.Read (\r
-                                              PciIoDevice->PciRootBridgeIo,\r
-                                              (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                              Offset,\r
-                                              Count,\r
-                                              Buffer\r
-                                              );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoIoWrite (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT8                      BarIndex,\r
-  IN     UINT64                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs a PCI I/O Write Cycle\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  if (Buffer == NULL){\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, BarIndex, PciBarTypeIo, Width, Count, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Io.Write (\r
-                                              PciIoDevice->PciRootBridgeIo,\r
-                                              (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                              Offset,\r
-                                              Count,\r
-                                              Buffer\r
-                                              );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoConfigRead (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT32                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs a PCI Configuration Read Cycle\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-  UINT64        Address;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  Address     = Offset;\r
-  Status      = PciIoVerifyConfigAccess (PciIoDevice, Width, Count, &Address);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Pci.Read (\r
-                                              PciIoDevice->PciRootBridgeIo,\r
-                                              (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                              Address,\r
-                                              Count,\r
-                                              Buffer\r
-                                              );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoConfigWrite (\r
-  IN     EFI_PCI_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT32                     Offset,\r
-  IN     UINTN                      Count,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Performs a PCI Configuration Write Cycle\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-  UINT64        Address;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  Address     = Offset;\r
-  Status      = PciIoVerifyConfigAccess (PciIoDevice, Width, Count, &Address);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Pci.Write (\r
-                                              PciIoDevice->PciRootBridgeIo,\r
-                                              (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                              Address,\r
-                                              Count,\r
-                                              Buffer\r
-                                              );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoCopyMem (\r
-  IN EFI_PCI_IO_PROTOCOL              *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_WIDTH    Width,\r
-  IN     UINT8                        DestBarIndex,\r
-  IN     UINT64                       DestOffset,\r
-  IN     UINT8                        SrcBarIndex,\r
-  IN     UINT64                       SrcOffset,\r
-  IN     UINTN                        Count\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Copy PCI Memory\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Width >= EfiPciIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Width == EfiPciIoWidthFifoUint8  ||\r
-      Width == EfiPciIoWidthFifoUint16 ||\r
-      Width == EfiPciIoWidthFifoUint32 ||\r
-      Width == EfiPciIoWidthFifoUint64 ||\r
-      Width == EfiPciIoWidthFillUint8  ||\r
-      Width == EfiPciIoWidthFillUint16 ||\r
-      Width == EfiPciIoWidthFillUint32 ||\r
-      Width == EfiPciIoWidthFillUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, DestBarIndex, PciBarTypeMem, Width, Count, &DestOffset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoVerifyBarAccess (PciIoDevice, SrcBarIndex, PciBarTypeMem, Width, Count, &SrcOffset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->CopyMem (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                          DestOffset,\r
-                                          SrcOffset,\r
-                                          Count\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoMap (\r
-  IN     EFI_PCI_IO_PROTOCOL            *This,\r
-  IN     EFI_PCI_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     VOID                           *HostAddress,\r
-  IN OUT UINTN                          *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS           *DeviceAddress,\r
-  OUT    VOID                           **Mapping\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Maps a memory region for DMA\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if ((UINT32)Operation >= EfiPciIoOperationMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (HostAddress == NULL || NumberOfBytes == NULL || DeviceAddress == NULL || Mapping == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE) {\r
-    Operation = (EFI_PCI_IO_PROTOCOL_OPERATION) (Operation + EfiPciOperationBusMasterRead64);\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Map (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION) Operation,\r
-                                          HostAddress,\r
-                                          NumberOfBytes,\r
-                                          DeviceAddress,\r
-                                          Mapping\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoUnmap (\r
-  IN  EFI_PCI_IO_PROTOCOL  *This,\r
-  IN  VOID                 *Mapping\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Unmaps a memory region for DMA\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->Unmap (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          Mapping\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoAllocateBuffer (\r
-  IN  EFI_PCI_IO_PROTOCOL   *This,\r
-  IN  EFI_ALLOCATE_TYPE     Type,\r
-  IN  EFI_MEMORY_TYPE       MemoryType,\r
-  IN  UINTN                 Pages,\r
-  OUT VOID                  **HostAddress,\r
-  IN  UINT64                Attributes\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Allocates a common buffer for DMA\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  if (Attributes &\r
-      (~(EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED))) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE) {\r
-    Attributes |= EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE;\r
-  }\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->AllocateBuffer (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          Type,\r
-                                          MemoryType,\r
-                                          Pages,\r
-                                          HostAddress,\r
-                                          Attributes\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoFreeBuffer (\r
-  IN  EFI_PCI_IO_PROTOCOL   *This,\r
-  IN  UINTN                 Pages,\r
-  IN  VOID                  *HostAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Frees a common buffer \r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-  \r
-  if( HostAddress == NULL ){\r
-     return EFI_INVALID_PARAMETER;\r
-  } \r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  Status = PciIoDevice->PciRootBridgeIo->FreeBuffer (\r
-                                          PciIoDevice->PciRootBridgeIo,\r
-                                          Pages,\r
-                                          HostAddress\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoFlush (\r
-  IN  EFI_PCI_IO_PROTOCOL  *This\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Flushes a DMA buffer\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-\r
-{\r
-  EFI_STATUS    Status;\r
-  UINT32         Register;\r
-  PCI_IO_DEVICE  *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  //\r
-  // If the device is behind a PCI-PCI Bridge, then perform a read cycles to the device to \r
-  // flush the posted write cycles through the PCI-PCI bridges\r
-  //\r
-  if (PciIoDevice->Parent != NULL) {\r
-    Status = This->Pci.Read (This, EfiPciIoWidthUint32, 0, 1, &Register);\r
-  }\r
-\r
-  //\r
-  // Call the PCI Root Bridge I/O Protocol to flush the posted write cycles through the chipset\r
-  //\r
-  Status = PciIoDevice->PciRootBridgeIo->Flush (\r
-                                           PciIoDevice->PciRootBridgeIo\r
-                                           );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoGetLocation (\r
-  IN  EFI_PCI_IO_PROTOCOL  *This,\r
-  OUT UINTN                *Segment,\r
-  OUT UINTN                *Bus,\r
-  OUT UINTN                *Device,\r
-  OUT UINTN                *Function\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Gets a PCI device's current bus number, device number, and function number.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if (Segment == NULL || Bus == NULL || Device == NULL || Function == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Segment  = PciIoDevice->PciRootBridgeIo->SegmentNumber;\r
-  *Bus      = PciIoDevice->BusNumber;\r
-  *Device   = PciIoDevice->DeviceNumber;\r
-  *Function = PciIoDevice->FunctionNumber;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-BOOLEAN\r
-CheckBarType (\r
-  IN PCI_IO_DEVICE       *PciIoDevice,\r
-  UINT8                  BarIndex,\r
-  PCI_BAR_TYPE           BarType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Sets a PCI controllers attributes on a resource range\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  switch (BarType) {\r
-\r
-  case PciBarTypeMem:\r
-\r
-    if (PciIoDevice->PciBar[BarIndex].BarType != PciBarTypeMem32  &&\r
-        PciIoDevice->PciBar[BarIndex].BarType != PciBarTypePMem32 &&\r
-        PciIoDevice->PciBar[BarIndex].BarType != PciBarTypePMem64 &&\r
-        PciIoDevice->PciBar[BarIndex].BarType != PciBarTypeMem64    ) {\r
-      return FALSE;\r
-    }\r
-\r
-    return TRUE;\r
-\r
-  case PciBarTypeIo:\r
-    if (PciIoDevice->PciBar[BarIndex].BarType != PciBarTypeIo32 &&\r
-        PciIoDevice->PciBar[BarIndex].BarType != PciBarTypeIo16){\r
-      return FALSE;\r
-    }\r
-\r
-    return TRUE;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoAttributes (\r
-  IN EFI_PCI_IO_PROTOCOL                       * This,\r
-  IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,\r
-  IN  UINT64                                   Attributes,\r
-  OUT UINT64                                   *Result OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-  PCI_IO_DEVICE *Temp;\r
-  UINT64         NewAttributes;\r
-  UINT64         PciRootBridgeSupports;\r
-  UINT64         PciRootBridgeAttributes;\r
-  UINT64         NewPciRootBridgeAttributes;\r
-  UINT64         NewUpStreamBridgeAttributes;\r
-  UINT64         ModifiedPciRootBridgeAttributes;\r
-  UINT16         EnableCommand;\r
-  UINT16         DisableCommand;\r
-  UINT16         EnableBridge;\r
-  UINT16         DisableBridge;\r
-  UINT16         Command;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-  NewUpStreamBridgeAttributes = 0;\r
-\r
-  EnableCommand   = 0;\r
-  DisableCommand  = 0;\r
-  EnableBridge    = 0;\r
-  DisableBridge   = 0;\r
-\r
-  switch (Operation) {\r
-  case EfiPciIoAttributeOperationGet:\r
-    if (Result == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    *Result = PciIoDevice->Attributes;\r
-    return EFI_SUCCESS;\r
-\r
-  case EfiPciIoAttributeOperationSupported:\r
-    if (Result == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    *Result = PciIoDevice->Supports;\r
-    return EFI_SUCCESS;\r
-\r
-  case EfiPciIoAttributeOperationEnable:\r
-    if(Attributes & ~(PciIoDevice->Supports)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    NewAttributes = PciIoDevice->Attributes | Attributes;\r
-    break;\r
-  case EfiPciIoAttributeOperationDisable:\r
-    if(Attributes & ~(PciIoDevice->Supports)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    NewAttributes = PciIoDevice->Attributes & (~Attributes);\r
-    break;\r
-  case EfiPciIoAttributeOperationSet:\r
-    if(Attributes & ~(PciIoDevice->Supports)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    NewAttributes = Attributes;\r
-    break;\r
-  default:\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If VGA_IO is set, then set VGA_MEMORY too.  This driver can not enable them seperately.\r
-  //\r
-  if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) {\r
-    NewAttributes |= EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY;\r
-  }\r
-\r
-  //\r
-  // If VGA_MEMORY is set, then set VGA_IO too.  This driver can not enable them seperately.\r
-  //\r
-  if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY) {\r
-    NewAttributes |= EFI_PCI_IO_ATTRIBUTE_VGA_IO;\r
-  }\r
-\r
-  //\r
-  // If the attributes are already set correctly, then just return EFI_SUCCESS;\r
-  //\r
-  if ((NewAttributes ^ PciIoDevice->Attributes) == 0) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // This driver takes care of EFI_PCI_IO_ATTRIBUTE_IO, EFI_PCI_IO_ATTRIBUTE_MEMORY, and\r
-  // EFI_PCI_IO_ATTRIBUTE_BUS_MASTER.  Strip these 3 bits off the new attribute mask so\r
-  // a call to the PCI Root Bridge I/O Protocol can be made\r
-  //\r
-\r
-  if (!IS_PCI_BRIDGE(&PciIoDevice->Pci)) {\r
-    NewPciRootBridgeAttributes = NewAttributes & (~(EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE));\r
-\r
-    //  \r
-    // Get the current attributes of this PCI device's PCI Root Bridge\r
-    //\r
-    Status = PciIoDevice->PciRootBridgeIo->GetAttributes (\r
-                                            PciIoDevice->PciRootBridgeIo,\r
-                                            &PciRootBridgeSupports,\r
-                                            &PciRootBridgeAttributes\r
-                                            );\r
-\r
-    //\r
-    // Check to see if any of the PCI Root Bridge attributes are being modified\r
-    //\r
-    ModifiedPciRootBridgeAttributes = NewPciRootBridgeAttributes ^ PciRootBridgeAttributes;\r
-    if (ModifiedPciRootBridgeAttributes) {\r
-\r
-      //\r
-      // Check to see if the PCI Root Bridge supports modifiying the attributes that are changing\r
-      //\r
-      if ((ModifiedPciRootBridgeAttributes & PciRootBridgeSupports) != ModifiedPciRootBridgeAttributes) {\r
-  //     return EFI_UNSUPPORTED;\r
-      }\r
-      //\r
-      // Call the PCI Root Bridge to attempt to modify the attributes\r
-      //\r
-      Status = PciIoDevice->PciRootBridgeIo->SetAttributes (\r
-                                             PciIoDevice->PciRootBridgeIo,\r
-                                             NewPciRootBridgeAttributes,\r
-                                             NULL,\r
-                                             NULL\r
-                                             );\r
-      if (EFI_ERROR (Status)) {\r
-      //\r
-      // The PCI Root Bridge could not modify the attributes, so return the error.\r
-      //\r
-        return Status;\r
-      }\r
-    }\r
-  }\r
-\r
-\r
-  if (IS_PCI_BRIDGE(&PciIoDevice->Pci)) {\r
-\r
-\r
-    //\r
-    // Check to see if an VGA related attributes are being set.\r
-    //\r
-    if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO)) {\r
-\r
-      if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) {\r
-        EnableBridge  |= EFI_PCI_BRIDGE_CONTROL_VGA;\r
-      } else {\r
-        DisableBridge  |= EFI_PCI_BRIDGE_CONTROL_VGA;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Check to see if an VGA related attributes are being set.\r
-    // If ISA Enable on the PPB is set, the PPB will block the\r
-    // 0x100-0x3FF for each 1KB block in the first 64K I/O block\r
-    //\r
-    if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_ISA_IO) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_ISA_IO)) {\r
-\r
-      if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_ISA_IO) {\r
-        DisableBridge  |= EFI_PCI_BRIDGE_CONTROL_ISA;\r
-      } else {\r
-        EnableBridge  |= EFI_PCI_BRIDGE_CONTROL_ISA;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Check to see if an VGA related attributes are being set.\r
-    //\r
-    if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO)) {\r
-\r
-      if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) {\r
-        EnableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-      } else {\r
-        DisableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-      }\r
-    }\r
-\r
-  } else {\r
-\r
-    if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO)) {\r
-\r
-      if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) {\r
-\r
-        //\r
-        //Check if there have been an active VGA device on the same segment\r
-        //\r
-        Temp = ActiveVGADeviceOnTheSameSegment (PciIoDevice);\r
-\r
-        if (Temp && Temp != PciIoDevice) {\r
-          return EFI_UNSUPPORTED;\r
-        }\r
-      }\r
-    }\r
-\r
-    if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO)) {\r
-      if (IS_PCI_GFX(&PciIoDevice->Pci)) {\r
-\r
-        //\r
-        //Get the boot VGA on the same segement\r
-        //\r
-        Temp = ActiveVGADeviceOnTheSameSegment (PciIoDevice);\r
-\r
-        if (!Temp) {\r
-\r
-          //\r
-          // If there is no VGA device on the segement, set\r
-          // this graphics card to decode the palette range\r
-          //\r
-          DisableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-        } else {\r
-\r
-          //\r
-          // Check these two agents are on the same path\r
-          //\r
-          if (PciDevicesOnTheSamePath(Temp, PciIoDevice)) {\r
-\r
-            //\r
-            // Check if they are on the same bus\r
-            //\r
-            if (Temp->Parent == PciIoDevice->Parent) {\r
-\r
-              PciReadCommandRegister (Temp, &Command);\r
-\r
-              //\r
-              // If they are on the same bus, either one can\r
-              // be set to snoop, the other set to decode\r
-              //\r
-              if (Command & EFI_PCI_COMMAND_VGA_PALETTE_SNOOP) {\r
-                DisableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-              } else {\r
-                EnableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-              }\r
-            } else {\r
-\r
-              //\r
-              // If they are on  the same path but on the different bus\r
-              // The first agent is set to snoop, the second one set to\r
-              // decode\r
-              //\r
-              if (Temp->BusNumber > PciIoDevice->BusNumber) {\r
-                PciEnableCommandRegister(Temp,EFI_PCI_COMMAND_VGA_PALETTE_SNOOP);\r
-                DisableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-              } else {\r
-                PciDisableCommandRegister(Temp,EFI_PCI_COMMAND_VGA_PALETTE_SNOOP);\r
-                EnableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-              }\r
-            }\r
-          } else {\r
-\r
-            EnableCommand  |= EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Check to see of the I/O enable is being modified\r
-  //\r
-  if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_IO) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_IO)) {\r
-    if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_IO) {\r
-      EnableCommand |= EFI_PCI_COMMAND_IO_SPACE;\r
-    } else {\r
-      DisableCommand |= EFI_PCI_COMMAND_IO_SPACE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Check to see of the Memory enable is being modified\r
-  //\r
-  if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_MEMORY) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_MEMORY)) {\r
-    if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_MEMORY) {\r
-      EnableCommand |= EFI_PCI_COMMAND_MEMORY_SPACE;\r
-    } else {\r
-      DisableCommand |= EFI_PCI_COMMAND_MEMORY_SPACE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Check to see of the Bus Master enable is being modified\r
-  //\r
-  if ((NewAttributes & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) ^ (PciIoDevice->Attributes & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER)) {\r
-    if (NewAttributes & EFI_PCI_IO_ATTRIBUTE_BUS_MASTER) {\r
-      EnableCommand  |= EFI_PCI_COMMAND_BUS_MASTER;\r
-    } else {\r
-      DisableCommand |= EFI_PCI_COMMAND_BUS_MASTER;\r
-    }\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (EnableCommand) {\r
-    Status = PciEnableCommandRegister(PciIoDevice, EnableCommand);\r
-  } \r
-\r
-  if (DisableCommand) {\r
-    Status = PciDisableCommandRegister(PciIoDevice, DisableCommand);\r
-  }\r
-\r
-  if (EFI_ERROR(Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (EnableBridge) {\r
-    Status = PciEnableBridgeControlRegister(PciIoDevice, EnableBridge);\r
-  }\r
-\r
-  if (DisableBridge) {\r
-    Status = PciDisableBridgeControlRegister(PciIoDevice, DisableBridge);\r
-  }\r
-   \r
-  if (EFI_ERROR(Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Set the upstream bridge attributes\r
-  //\r
-  if (Operation != EfiPciIoAttributeOperationGet && Operation != EfiPciIoAttributeOperationSupported) {\r
-\r
-    //\r
-    // EFI_PCI_IO_ATTRIBUTE_MEMORY, EFI_PCI_IO_ATTRIBUTE_IO, EFI_PCI_IO_ATTRIBUTE_BUS_MASTER\r
-    // EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE, EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED\r
-    // EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE will not effect to upstream bridge\r
-    // \r
-    NewUpStreamBridgeAttributes = Attributes & \\r
-                                (~(EFI_PCI_IO_ATTRIBUTE_IO | \\r
-                                EFI_PCI_IO_ATTRIBUTE_MEMORY | \\r
-                                EFI_PCI_IO_ATTRIBUTE_BUS_MASTER | \\r
-                                EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | \\r
-                                EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED | \\r
-                                EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE));\r
-\r
-    if (NewUpStreamBridgeAttributes){\r
-      UpStreamBridgesAttributes(PciIoDevice, Operation, NewUpStreamBridgeAttributes);\r
-    }\r
-  }\r
-  \r
-  PciIoDevice->Attributes = NewAttributes;\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoGetBarAttributes (\r
-  IN EFI_PCI_IO_PROTOCOL             * This,\r
-  IN  UINT8                          BarIndex,\r
-  OUT UINT64                         *Supports, OPTIONAL\r
-  OUT VOID                           **Resources OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT8                             *Configuration;\r
-  PCI_IO_DEVICE                     *PciIoDevice;\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *AddressSpace;\r
-  EFI_ACPI_END_TAG_DESCRIPTOR       *End;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  if (Supports == NULL && Resources == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((BarIndex >= PCI_MAX_BAR) || (PciIoDevice->PciBar[BarIndex].BarType == PciBarTypeUnknown)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // This driver does not support modifications to the WRITE_COMBINE or\r
-  // CACHED attributes for BAR ranges.\r
-  //\r
-  if (Supports != NULL) {\r
-    *Supports = PciIoDevice->Supports & EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED & EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE;\r
-  }\r
-\r
-  if (Resources != NULL) {\r
-    Configuration = AllocateZeroPool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));\r
-    if (Configuration == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    AddressSpace = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;\r
-\r
-    AddressSpace->Desc         = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    AddressSpace->Len          = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3);\r
-\r
-    AddressSpace->AddrRangeMin = PciIoDevice->PciBar[BarIndex].BaseAddress;\r
-    AddressSpace->AddrLen      = PciIoDevice->PciBar[BarIndex].Length;\r
-    AddressSpace->AddrRangeMax = PciIoDevice->PciBar[BarIndex].Alignment;\r
-\r
-    switch (PciIoDevice->PciBar[BarIndex].BarType) {\r
-    case PciBarTypeIo16:\r
-    case PciBarTypeIo32:\r
-      //\r
-      // Io\r
-      //\r
-      AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_IO;\r
-      break;\r
-\r
-    case PciBarTypeMem32:\r
-      //\r
-      // Mem\r
-      //\r
-      AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-      //\r
-      // 32 bit\r
-      //\r
-      AddressSpace->AddrSpaceGranularity = 32;\r
-      break;\r
-\r
-    case PciBarTypePMem32:\r
-      //\r
-      // Mem\r
-      //\r
-      AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-      //\r
-      // prefechable\r
-      //\r
-      AddressSpace->SpecificFlag = 0x6;\r
-      //\r
-      // 32 bit\r
-      //\r
-      AddressSpace->AddrSpaceGranularity = 32;\r
-      break;\r
-\r
-    case PciBarTypeMem64:\r
-      //\r
-      // Mem\r
-      //\r
-      AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-      //\r
-      // 64 bit\r
-      //\r
-      AddressSpace->AddrSpaceGranularity = 64;\r
-      break;\r
-\r
-    case PciBarTypePMem64:\r
-      //\r
-      // Mem\r
-      //\r
-      AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-      //\r
-      // prefechable\r
-      //\r
-      AddressSpace->SpecificFlag = 0x6;\r
-      //\r
-      // 64 bit\r
-      //\r
-      AddressSpace->AddrSpaceGranularity = 64;\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-\r
-    //\r
-    // put the checksum\r
-    //\r
-    End           = (EFI_ACPI_END_TAG_DESCRIPTOR *) (AddressSpace + 1);\r
-    End->Desc     = ACPI_END_TAG_DESCRIPTOR;\r
-    End->Checksum = 0;\r
-\r
-    *Resources    = Configuration;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PciIoSetBarAttributes (\r
-  IN EFI_PCI_IO_PROTOCOL              *This,\r
-  IN     UINT64                       Attributes,\r
-  IN     UINT8                        BarIndex,\r
-  IN OUT UINT64                       *Offset,\r
-  IN OUT UINT64                       *Length\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS    Status;\r
-  PCI_IO_DEVICE *PciIoDevice;\r
-  UINT64        NonRelativeOffset;\r
-  UINT64        Supports;\r
-\r
-  PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);\r
-\r
-  //\r
-  // Make sure Offset and Length are not NULL\r
-  //\r
-  if (Offset == NULL || Length == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (PciIoDevice->PciBar[BarIndex].BarType == PciBarTypeUnknown) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // This driver does not support setting the WRITE_COMBINE or the CACHED attributes.\r
-  // If Attributes is not 0, then return EFI_UNSUPPORTED.\r
-  //\r
-  Supports = PciIoDevice->Supports & EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED & EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE;\r
-\r
-  if (Attributes != (Attributes & Supports)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Attributes must be supported.  Make sure the BAR range describd by BarIndex, Offset, and\r
-  // Length are valid for this PCI device.\r
-  //\r
-  NonRelativeOffset = *Offset;\r
-  Status = PciIoVerifyBarAccess (\r
-            PciIoDevice,\r
-            BarIndex,\r
-            PciBarTypeMem,\r
-            EfiPciIoWidthUint8,\r
-            (UINT32) *Length,\r
-            &NonRelativeOffset\r
-            );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-UpStreamBridgesAttributes (\r
-  IN  PCI_IO_DEVICE                            *PciIoDevice,\r
-  IN  EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,\r
-  IN  UINT64                                   Attributes\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  PCI_IO_DEVICE       *Parent;\r
-  EFI_PCI_IO_PROTOCOL *PciIo;\r
-\r
-  Parent = PciIoDevice->Parent;\r
-\r
-  while (Parent && IS_PCI_BRIDGE (&Parent->Pci)) {\r
-\r
-    //\r
-    // Get the PciIo Protocol\r
-    //\r
-    PciIo = &Parent->PciIo;\r
-\r
-    PciIo->Attributes (PciIo, Operation, Attributes, NULL);\r
-\r
-    Parent = Parent->Parent;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-BOOLEAN\r
-PciDevicesOnTheSamePath (\r
-  IN PCI_IO_DEVICE        *PciDevice1,\r
-  IN PCI_IO_DEVICE        *PciDevice2\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-  PciDevice1  -  The pointer to the first PCI_IO_DEVICE.\r
-  PciDevice2  -  The pointer to the second PCI_IO_DEVICE.\r
-\r
-Returns:\r
-\r
-  TRUE   -  The two Pci devices are on the same path.\r
-  FALSE  -  The two Pci devices are not on the same path.\r
-\r
---*/\r
-{\r
-\r
-  if (PciDevice1->Parent == PciDevice2->Parent) {\r
-    return TRUE;\r
-  }\r
-\r
-  return (BOOLEAN) ((PciDeviceExisted (PciDevice1->Parent, PciDevice2)|| PciDeviceExisted (PciDevice2->Parent, PciDevice1)));\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciIo.h b/DuetPkg/PciBusNoEnumerationDxe/PciIo.h
deleted file mode 100644 (file)
index 0810ae3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciIo.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_IO_PROTOCOL_H\r
-#define _EFI_PCI_IO_PROTOCOL_H\r
-\r
-EFI_STATUS\r
-InitializePciIoInstance (\r
-  PCI_IO_DEVICE  *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciIoDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciOptionRomSupport.c b/DuetPkg/PciBusNoEnumerationDxe/PciOptionRomSupport.c
deleted file mode 100644 (file)
index 28adb2b..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciOptionRomSupport.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-\r
-EFI_STATUS\r
-RomDecode (\r
-  IN PCI_IO_DEVICE   *PciDevice,\r
-  IN UINT8           RomBarIndex,\r
-  IN UINT32          RomBar,\r
-  IN BOOLEAN         Enable\r
-);\r
-\r
-EFI_STATUS\r
-GetOpRomInfo (\r
-  IN PCI_IO_DEVICE    *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  UINT8                           RomBarIndex;\r
-  UINT32                          AllOnes;\r
-  UINT64                          Address;\r
-  EFI_STATUS                      Status;\r
-  UINT8                           Bus;\r
-  UINT8                           Device;\r
-  UINT8                           Function;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
-\r
-  Bus             = PciIoDevice->BusNumber;\r
-  Device          = PciIoDevice->DeviceNumber;\r
-  Function        = PciIoDevice->FunctionNumber;\r
-\r
-  PciRootBridgeIo = PciIoDevice->PciRootBridgeIo;\r
-\r
-  //\r
-  // offset is 0x30 if is not ppb\r
-  //\r
-\r
-  //\r
-  // 0x30\r
-  //\r
-  RomBarIndex = PCI_EXPANSION_ROM_BASE;\r
-\r
-  if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {\r
-    //\r
-    // if is ppb\r
-    //\r
-\r
-    //\r
-    // 0x38\r
-    //\r
-    RomBarIndex = PCI_BRIDGE_ROMBAR;\r
-  }\r
-  //\r
-  // the bit0 is 0 to prevent the enabling of the Rom address decoder\r
-  //\r
-  AllOnes = 0xfffffffe;\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Function, RomBarIndex);\r
-\r
-  Status = PciRootBridgeIo->Pci.Write (\r
-                                  PciRootBridgeIo,\r
-                                  EfiPciWidthUint32,\r
-                                  Address,\r
-                                  1,\r
-                                  &AllOnes\r
-                                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // read back\r
-  //\r
-  Status = PciRootBridgeIo->Pci.Read (\r
-                                  PciRootBridgeIo,\r
-                                  EfiPciWidthUint32,\r
-                                  Address,\r
-                                  1,\r
-                                  &AllOnes\r
-                                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Bits [1, 10] are reserved\r
-  //\r
-  AllOnes &= 0xFFFFF800;\r
-  if ((AllOnes == 0) || (AllOnes == 0xFFFFF800)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  DEBUG ((EFI_D_ERROR, "PCIBUS: GetOpRomInfo: OPROM detected!\n"));\r
-  DEBUG ((EFI_D_ERROR, "PCIBUS: GetOpRomInfo: B-%x, D-%x, F-%x\n", (UINTN)Bus, (UINTN)Device, (UINTN)Function));\r
-\r
-  PciIoDevice->RomSize = (UINT64) ((~AllOnes) + 1);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-LoadOpRomImage (\r
-  IN PCI_IO_DEVICE   *PciDevice,\r
-  IN UINT64          ReservedMemoryBase\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
\r
-    Load option rom image for specified PCI device\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  UINT8                     RomBarIndex;\r
-  UINT8                     Indicator;\r
-  UINT16                    OffsetPcir;\r
-  UINT32                    RomBarOffset;\r
-  UINT32                    RomBar;\r
-  EFI_STATUS                retStatus;\r
-  BOOLEAN                   FirstCheck;\r
-  UINT8                     *Image;\r
-  PCI_EXPANSION_ROM_HEADER  *RomHeader;\r
-  PCI_DATA_STRUCTURE        *RomPcir;\r
-  UINT64                    RomSize;\r
-  UINT64                    RomImageSize;\r
-  UINT32                    LegacyImageLength;\r
-  UINT8                     *RomInMemory;\r
-  UINT8                     CodeType;\r
-\r
-  RomSize       = PciDevice->RomSize;\r
-\r
-  Indicator     = 0;\r
-  RomImageSize  = 0;\r
-  RomInMemory   = NULL;\r
-  CodeType      = 0xFF;\r
-\r
-  //\r
-  // Get the RomBarIndex\r
-  //\r
-\r
-  //\r
-  // 0x30\r
-  //\r
-  RomBarIndex = PCI_EXPANSION_ROM_BASE;\r
-  if (IS_PCI_BRIDGE (&(PciDevice->Pci))) {\r
-    //\r
-    // if is ppb\r
-    //\r
-\r
-    //\r
-    // 0x38\r
-    //\r
-    RomBarIndex = PCI_BRIDGE_ROMBAR;\r
-  }\r
-  //\r
-  // Allocate memory for Rom header and PCIR\r
-  //\r
-  RomHeader = AllocatePool (sizeof (PCI_EXPANSION_ROM_HEADER));\r
-  if (RomHeader == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  RomPcir = AllocatePool (sizeof (PCI_DATA_STRUCTURE));\r
-  if (RomPcir == NULL) {\r
-    gBS->FreePool (RomHeader);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  RomBar = (UINT32)ReservedMemoryBase;  \r
-\r
-  //\r
-  // Enable RomBar\r
-  //\r
-  RomDecode (PciDevice, RomBarIndex, RomBar, TRUE);\r
-\r
-  RomBarOffset  = RomBar;\r
-  retStatus     = EFI_NOT_FOUND;\r
-  FirstCheck    = TRUE;\r
-  LegacyImageLength = 0;\r
-\r
-  do {\r
-    PciDevice->PciRootBridgeIo->Mem.Read (\r
-                                      PciDevice->PciRootBridgeIo,\r
-                                      EfiPciWidthUint8,\r
-                                      RomBarOffset,\r
-                                      sizeof (PCI_EXPANSION_ROM_HEADER),\r
-                                      (UINT8 *) RomHeader\r
-                                      );\r
-\r
-    if (RomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-      RomBarOffset = RomBarOffset + 512;\r
-      if (FirstCheck) {\r
-        break;\r
-      } else {\r
-        RomImageSize = RomImageSize + 512;\r
-        continue;\r
-      }\r
-    }\r
-\r
-    FirstCheck  = FALSE;\r
-    OffsetPcir  = RomHeader->PcirOffset;\r
-    //\r
-    // If the pointer to the PCI Data Structure is invalid, no further images can be located. \r
-    // The PCI Data Structure must be DWORD aligned. \r
-    //\r
-    if (OffsetPcir == 0 ||\r
-       (OffsetPcir & 3) != 0 ||\r
-       RomImageSize + OffsetPcir + sizeof (PCI_DATA_STRUCTURE) > RomSize) {\r
-      break;\r
-    }\r
-    PciDevice->PciRootBridgeIo->Mem.Read (\r
-                                      PciDevice->PciRootBridgeIo,\r
-                                      EfiPciWidthUint8,\r
-                                      RomBarOffset + OffsetPcir,\r
-                                      sizeof (PCI_DATA_STRUCTURE),\r
-                                      (UINT8 *) RomPcir\r
-                                      );\r
-    //\r
-    // If a valid signature is not present in the PCI Data Structure, no further images can be located.\r
-    //\r
-    if (RomPcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-      break;\r
-    }\r
-    if (RomImageSize + RomPcir->ImageLength * 512 > RomSize) {\r
-      break;\r
-    }\r
-    if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {\r
-      CodeType = PCI_CODE_TYPE_PCAT_IMAGE;\r
-      LegacyImageLength = ((UINT32)((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512) * 512;\r
-    }\r
-    Indicator     = RomPcir->Indicator;\r
-    RomImageSize  = RomImageSize + RomPcir->ImageLength * 512;\r
-    RomBarOffset  = RomBarOffset + RomPcir->ImageLength * 512;\r
-  } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize));\r
-\r
-  //\r
-  // Some Legacy Cards do not report the correct ImageLength so used the maximum\r
-  // of the legacy length and the PCIR Image Length\r
-  //\r
-  if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {\r
-    RomImageSize = MAX (RomImageSize, LegacyImageLength);\r
-  }\r
-\r
-  if (RomImageSize > 0) {\r
-    retStatus = EFI_SUCCESS;\r
-    Image     = AllocatePool ((UINT32) RomImageSize);\r
-    if (Image == NULL) {\r
-      RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);\r
-      gBS->FreePool (RomHeader);\r
-      gBS->FreePool (RomPcir);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    \r
-    //\r
-    // Copy Rom image into memory\r
-    //\r
-    PciDevice->PciRootBridgeIo->Mem.Read (\r
-                                      PciDevice->PciRootBridgeIo,\r
-                                      EfiPciWidthUint8,\r
-                                      RomBar,\r
-                                      (UINT32) RomImageSize,\r
-                                      Image\r
-                                      );\r
-    RomInMemory = Image;\r
-  }\r
-\r
-  RomDecode (PciDevice, RomBarIndex, RomBar, FALSE);\r
-\r
-  PciDevice->PciIo.RomSize  = RomImageSize;\r
-  PciDevice->PciIo.RomImage = RomInMemory;\r
-\r
-  //\r
-  // Free allocated memory\r
-  //\r
-  gBS->FreePool (RomHeader);\r
-  gBS->FreePool (RomPcir);\r
-\r
-  return retStatus;\r
-}\r
-\r
-EFI_STATUS\r
-RomDecode (\r
-  IN PCI_IO_DEVICE   *PciDevice,\r
-  IN UINT8           RomBarIndex,\r
-  IN UINT32          RomBar,\r
-  IN BOOLEAN         Enable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  UINT16                          CommandValue;\r
-  UINT32                          Value32;\r
-  UINT64                          Address;\r
-  //EFI_STATUS                      Status;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
-  \r
-  PciRootBridgeIo = PciDevice->PciRootBridgeIo;\r
-  if (Enable) {\r
-    Address = EFI_PCI_ADDRESS (PciDevice->BusNumber, PciDevice->DeviceNumber, PciDevice->FunctionNumber, RomBarIndex);\r
-    //\r
-    // set the Rom base address: now is hardcode\r
-    //\r
-    PciRootBridgeIo->Pci.Write(\r
-                               PciRootBridgeIo, \r
-                               EfiPciWidthUint32, \r
-                               Address, \r
-                               1, \r
-                               &RomBar);\r
-  \r
-    //\r
-    // enable its decoder\r
-    //\r
-    Value32 = RomBar | 0x1;\r
-    PciRootBridgeIo->Pci.Write(\r
-                               PciRootBridgeIo, \r
-                               EfiPciWidthUint32, \r
-                               Address, \r
-                               1, \r
-                               &Value32);\r
-    \r
-    //\r
-    //setting the memory space bit in the function's command register\r
-    //\r
-    Address = EFI_PCI_ADDRESS (PciDevice->BusNumber, PciDevice->DeviceNumber, PciDevice->FunctionNumber, 0x04);\r
-    PciRootBridgeIo->Pci.Read(\r
-                              PciRootBridgeIo, \r
-                              EfiPciWidthUint16, \r
-                              Address, \r
-                              1, \r
-                              &CommandValue);\r
-    \r
-    CommandValue = (UINT16)(CommandValue | 0x0002); //0x0003\r
-    PciRootBridgeIo->Pci.Write(\r
-                               PciRootBridgeIo, \r
-                               EfiPciWidthUint16, \r
-                               Address, \r
-                               1, \r
-                               &CommandValue);\r
-  } else {\r
-    //\r
-    // disable rom decode\r
-    //  \r
-    Address = EFI_PCI_ADDRESS (PciDevice->BusNumber, PciDevice->DeviceNumber, PciDevice->FunctionNumber, RomBarIndex);\r
-    Value32 = 0xfffffffe;\r
-    PciRootBridgeIo->Pci.Write(\r
-                               PciRootBridgeIo, \r
-                               EfiPciWidthUint32, \r
-                               Address, \r
-                               1, \r
-                               &Value32);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-EFI_STATUS\r
-ProcessOpRomImage (\r
-  PCI_IO_DEVICE   *PciDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Process the oprom image.\r
-  \r
-Arguments:\r
-  PciDevice       A pointer to a pci device.\r
-\r
-Returns:\r
-\r
-  EFI Status.\r
-  \r
---*/\r
-{\r
-  UINT8                         Indicator;\r
-  UINT32                        ImageSize;\r
-  UINT16                        ImageOffset;\r
-  VOID                          *RomBar;\r
-  UINT8                         *RomBarOffset;\r
-  EFI_HANDLE                    ImageHandle;\r
-  EFI_STATUS                    Status;\r
-  EFI_STATUS                    retStatus;\r
-  BOOLEAN                       SkipImage;\r
-  UINT32                        DestinationSize;\r
-  UINT32                        ScratchSize;\r
-  UINT8                         *Scratch;\r
-  VOID                          *ImageBuffer;\r
-  VOID                          *DecompressedImageBuffer;\r
-  UINT32                        ImageLength;\r
-  EFI_DECOMPRESS_PROTOCOL       *Decompress;\r
-  EFI_PCI_EXPANSION_ROM_HEADER  *EfiRomHeader;\r
-  PCI_DATA_STRUCTURE            *Pcir;\r
-  UINT32                        InitializationSize;\r
-\r
-  Indicator = 0;\r
-\r
-  //\r
-  // Get the Address of the Rom image\r
-  //\r
-  RomBar        = PciDevice->PciIo.RomImage;\r
-  RomBarOffset  = (UINT8 *) RomBar;\r
-  retStatus     = EFI_NOT_FOUND;\r
-\r
-  if (RomBarOffset == NULL) {\r
-    return retStatus;\r
-  }\r
-  ASSERT (((EFI_PCI_EXPANSION_ROM_HEADER *) RomBarOffset)->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE);\r
-\r
-  do {\r
-    EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) RomBarOffset;\r
-    if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-      RomBarOffset = RomBarOffset + 512;\r
-      continue;\r
-    }\r
-\r
-    Pcir        = (PCI_DATA_STRUCTURE *) (RomBarOffset + EfiRomHeader->PcirOffset);\r
-    ASSERT (Pcir->Signature == PCI_DATA_STRUCTURE_SIGNATURE);\r
-    ImageSize   = (UINT32) (Pcir->ImageLength * 512);\r
-    Indicator   = Pcir->Indicator;\r
-\r
-    if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&\r
-        (EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&\r
-        ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||\r
-         (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {\r
-\r
-      ImageOffset             = EfiRomHeader->EfiImageHeaderOffset;\r
-      InitializationSize      = EfiRomHeader->InitializationSize * 512;\r
-\r
-      if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {\r
-\r
-        ImageBuffer             = (VOID *) (RomBarOffset + ImageOffset);\r
-        ImageLength             =  InitializationSize - (UINT32)ImageOffset;\r
-        DecompressedImageBuffer = NULL;\r
-\r
-        //\r
-        // decompress here if needed\r
-        //\r
-        SkipImage = FALSE;\r
-        if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
-          SkipImage = TRUE;\r
-        }\r
-\r
-        if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
-          Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **) &Decompress);\r
-          if (EFI_ERROR (Status)) {\r
-            SkipImage = TRUE;\r
-          } else {\r
-            SkipImage = TRUE;\r
-            Status = Decompress->GetInfo (\r
-                                  Decompress,\r
-                                  ImageBuffer,\r
-                                  ImageLength,\r
-                                  &DestinationSize,\r
-                                  &ScratchSize\r
-                                  );\r
-            if (!EFI_ERROR (Status)) {\r
-              DecompressedImageBuffer = NULL;\r
-              DecompressedImageBuffer = AllocatePool (DestinationSize);\r
-              if (DecompressedImageBuffer != NULL) {\r
-                Scratch = AllocatePool (ScratchSize);\r
-                if (Scratch != NULL) {\r
-                  Status = Decompress->Decompress (\r
-                                        Decompress,\r
-                                        ImageBuffer,\r
-                                        ImageLength,\r
-                                        DecompressedImageBuffer,\r
-                                        DestinationSize,\r
-                                        Scratch,\r
-                                        ScratchSize\r
-                                        );\r
-                  if (!EFI_ERROR (Status)) {\r
-                    ImageBuffer = DecompressedImageBuffer;\r
-                    ImageLength = DestinationSize;\r
-                    SkipImage   = FALSE;\r
-                  }\r
-\r
-                  gBS->FreePool (Scratch);\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-\r
-        if (!SkipImage) {\r
-          //\r
-          // load image and start image\r
-          //\r
-          Status = gBS->LoadImage (\r
-                          FALSE,\r
-                          gPciBusDriverBinding.DriverBindingHandle,\r
-                          NULL,\r
-                          ImageBuffer,\r
-                          ImageLength,\r
-                          &ImageHandle\r
-                          );\r
-          if (!EFI_ERROR (Status)) {\r
-            Status = gBS->StartImage (ImageHandle, NULL, NULL);\r
-            if (!EFI_ERROR (Status)) {\r
-              AddDriver (PciDevice, ImageHandle);\r
-              retStatus = EFI_SUCCESS;\r
-            }\r
-          }\r
-        }\r
-\r
-        RomBarOffset = RomBarOffset + ImageSize;\r
-      } else {\r
-        RomBarOffset = RomBarOffset + ImageSize;\r
-      }\r
-    } else {\r
-      RomBarOffset = RomBarOffset + ImageSize;\r
-    }\r
-\r
-  } while (((Indicator & 0x80) == 0x00) && ((UINTN) (RomBarOffset - (UINT8 *) RomBar) < PciDevice->RomSize));\r
-\r
-  return retStatus;\r
-\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciOptionRomSupport.h b/DuetPkg/PciBusNoEnumerationDxe/PciOptionRomSupport.h
deleted file mode 100644 (file)
index 7128ec4..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciOptionRomSupport.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_OP_ROM_SUPPORT_H\r
-#define _EFI_PCI_OP_ROM_SUPPORT_H\r
-\r
-EFI_STATUS\r
-GetOpRomInfo (\r
-  IN PCI_IO_DEVICE    *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciIoDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-LoadOpRomImage (\r
-  IN PCI_IO_DEVICE   *PciDevice,\r
-  IN UINT64          ReservedMemoryBase\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciDevice - TODO: add argument description\r
-  RomBase   - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-ProcessOpRomImage (\r
-  PCI_IO_DEVICE   *PciDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.c b/DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.c
deleted file mode 100644 (file)
index eaeaeb7..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciPowerManagement.c\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-ResetPowerManagementFeature (\r
-  IN PCI_IO_DEVICE *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function is intended to turn off PWE assertion and\r
-  put the device to D0 state if the device supports\r
-  PCI Power Management.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-  \r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT8       PowerManagementRegBlock;\r
-  UINT16      PowerManagementCSR;\r
-\r
-  PowerManagementRegBlock = 0;\r
-\r
-  Status = LocateCapabilityRegBlock (\r
-            PciIoDevice,\r
-            EFI_PCI_CAPABILITY_ID_PMI,\r
-            &PowerManagementRegBlock,\r
-            NULL\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Turn off the PWE assertion and put the device into D0 State\r
-  //\r
-\r
-  //\r
-  // Read PMCSR\r
-  //\r
-  Status = PciIoDevice->PciIo.Pci.Read (\r
-                                    &PciIoDevice->PciIo,\r
-                                    EfiPciIoWidthUint16,\r
-                                    PowerManagementRegBlock + 4,\r
-                                    1,\r
-                                    &PowerManagementCSR\r
-                                    );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Clear PME_Status bit\r
-    //\r
-    PowerManagementCSR |= BIT15;\r
-    //\r
-    // Clear PME_En bit. PowerState = D0.\r
-    //\r
-    PowerManagementCSR &= ~(BIT8 | BIT1 | BIT0);\r
-\r
-    //\r
-    // Write PMCSR\r
-    //\r
-    Status = PciIoDevice->PciIo.Pci.Write (\r
-                                      &PciIoDevice->PciIo,\r
-                                      EfiPciIoWidthUint16,\r
-                                      PowerManagementRegBlock + 4,\r
-                                      1,\r
-                                      &PowerManagementCSR\r
-                                      );\r
-  }\r
-  return Status;\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.h b/DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.h
deleted file mode 100644 (file)
index e53303b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciPowerManagement.h\r
-  \r
-Abstract:\r
-\r
-  PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_POWER_MANAGEMENT_H\r
-#define _EFI_PCI_POWER_MANAGEMENT_H\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-ResetPowerManagementFeature (\r
-  IN PCI_IO_DEVICE *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  PciIoDevice - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-#endif\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciRomTable.c b/DuetPkg/PciBusNoEnumerationDxe/PciRomTable.c
deleted file mode 100644 (file)
index 5085431..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciRomTable.c\r
-  \r
-Abstract:\r
-\r
-  Option Rom Support for PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PciBus.h"\r
-\r
-typedef struct {\r
-  EFI_HANDLE  ImageHandle;\r
-  UINTN       Seg;\r
-  UINT8       Bus;\r
-  UINT8       Dev;\r
-  UINT8       Func;\r
-} EFI_PCI_ROM_IMAGE_MAPPING;\r
-\r
-UINTN                      mNumberOfPciRomImages     = 0;\r
-UINTN                      mMaxNumberOfPciRomImages  = 0;\r
-EFI_PCI_ROM_IMAGE_MAPPING  *mRomImageTable           = NULL;\r
-\r
-CHAR16 mHexDigit[17] = L"0123456789ABCDEF";\r
-\r
-VOID\r
-PciRomAddImageMapping (\r
-  IN EFI_HANDLE  ImageHandle,\r
-  IN UINTN       Seg,\r
-  IN UINT8       Bus,\r
-  IN UINT8       Dev,\r
-  IN UINT8       Func\r
-  )\r
-\r
-{\r
-  EFI_PCI_ROM_IMAGE_MAPPING *TempMapping;\r
-\r
-  if (mNumberOfPciRomImages >= mMaxNumberOfPciRomImages) {\r
-\r
-    mMaxNumberOfPciRomImages += 0x20;\r
-\r
-    TempMapping = NULL;\r
-    TempMapping = AllocatePool (mMaxNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));\r
-    if (TempMapping == NULL) {\r
-      return ;\r
-    }\r
-\r
-    CopyMem (TempMapping, mRomImageTable, mNumberOfPciRomImages * sizeof (EFI_PCI_ROM_IMAGE_MAPPING));\r
-\r
-    if (mRomImageTable != NULL) {\r
-      gBS->FreePool (mRomImageTable);\r
-    }\r
-\r
-    mRomImageTable = TempMapping;\r
-  }\r
-\r
-  mRomImageTable[mNumberOfPciRomImages].ImageHandle = ImageHandle;\r
-  mRomImageTable[mNumberOfPciRomImages].Seg         = Seg;\r
-  mRomImageTable[mNumberOfPciRomImages].Bus         = Bus;\r
-  mRomImageTable[mNumberOfPciRomImages].Dev         = Dev;\r
-  mRomImageTable[mNumberOfPciRomImages].Func        = Func;\r
-  mNumberOfPciRomImages++;\r
-}\r
-\r
-VOID\r
-HexToString (\r
-  CHAR16  *String,\r
-  UINTN   Value,\r
-  UINTN   Digits\r
-  )\r
-\r
-{\r
-  for (; Digits > 0; Digits--, String++) {\r
-    *String = mHexDigit[((Value >> (4*(Digits-1))) & 0x0f)];\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-PciRomLoadEfiDriversFromRomImage (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_PCI_OPTION_ROM_DESCRIPTOR  *PciOptionRomDescriptor\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Command entry point. \r
-\r
-Arguments:\r
-  ImageHandle     The image handle. \r
-  SystemTable     The system table.\r
-\r
-Returns:\r
-  EFI_SUCCESS             - The command completed successfully\r
-  EFI_INVALID_PARAMETER   - Command usage error\r
-  EFI_UNSUPPORTED         - Protocols unsupported\r
-  EFI_OUT_OF_RESOURCES    - Out of memory\r
-  Other value             - Unknown error\r
-\r
---*/\r
-{\r
-  VOID                          *RomBar;\r
-  UINTN                         RomSize;\r
-  CHAR16                        *FileName;\r
-  EFI_PCI_EXPANSION_ROM_HEADER  *EfiRomHeader;\r
-  PCI_DATA_STRUCTURE            *Pcir;\r
-  UINTN                         ImageIndex;\r
-  UINTN                         RomBarOffset;\r
-  UINT32                        ImageSize;\r
-  UINT16                        ImageOffset;\r
-  EFI_HANDLE                    ImageHandle;\r
-  EFI_STATUS                    Status;\r
-  EFI_STATUS                    retStatus;\r
-  EFI_DEVICE_PATH_PROTOCOL      *FilePath;\r
-  BOOLEAN                       SkipImage;\r
-  UINT32                        DestinationSize;\r
-  UINT32                        ScratchSize;\r
-  UINT8                         *Scratch;\r
-  VOID                          *ImageBuffer;\r
-  VOID                          *DecompressedImageBuffer;\r
-  UINT32                        ImageLength;\r
-  EFI_DECOMPRESS_PROTOCOL       *Decompress;\r
-  UINT32                        InitializationSize;\r
-\r
-  RomBar = (VOID *) (UINTN) PciOptionRomDescriptor->RomAddress;\r
-  RomSize = (UINTN) PciOptionRomDescriptor->RomLength;\r
-  FileName = L"PciRom Seg=00000000 Bus=00 Dev=00 Func=00 Image=0000";\r
-\r
-  HexToString (&FileName[11], PciOptionRomDescriptor->Seg, 8);\r
-  HexToString (&FileName[24], PciOptionRomDescriptor->Bus, 2);\r
-  HexToString (&FileName[31], PciOptionRomDescriptor->Dev, 2);\r
-  HexToString (&FileName[39], PciOptionRomDescriptor->Func, 2);\r
-\r
-  ImageIndex    = 0;\r
-  retStatus     = EFI_NOT_FOUND;\r
-  RomBarOffset  = (UINTN) RomBar;\r
-\r
-  do {\r
-\r
-    EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset;\r
-\r
-\r
-    if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r
-      return retStatus;\r
-    }\r
-\r
-    //\r
-    // If the pointer to the PCI Data Structure is invalid, no further images can be located. \r
-    // The PCI Data Structure must be DWORD aligned. \r
-    //\r
-    if (EfiRomHeader->PcirOffset == 0 ||\r
-        (EfiRomHeader->PcirOffset & 3) != 0 ||\r
-        RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {\r
-      break;\r
-    }\r
-    Pcir      = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset);\r
-    //\r
-    // If a valid signature is not present in the PCI Data Structure, no further images can be located.\r
-    //\r
-    if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-      break;\r
-    }\r
-    ImageSize = Pcir->ImageLength * 512;\r
-    if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {\r
-      break;\r
-    }\r
-\r
-    if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&\r
-        (EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&\r
-        ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||\r
-         (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {\r
-\r
-      ImageOffset             = EfiRomHeader->EfiImageHeaderOffset;\r
-      InitializationSize      = EfiRomHeader->InitializationSize * 512;\r
-\r
-      if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {\r
-\r
-        ImageBuffer             = (VOID *) (UINTN) (RomBarOffset + ImageOffset);\r
-        ImageLength             = InitializationSize - ImageOffset;\r
-        DecompressedImageBuffer = NULL;\r
-\r
-        //\r
-        // decompress here if needed\r
-        //\r
-        SkipImage = FALSE;\r
-        if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
-          SkipImage = TRUE;\r
-        }\r
-\r
-        if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r
-          Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **) &Decompress);\r
-          if (EFI_ERROR (Status)) {\r
-            SkipImage = TRUE;\r
-          } else {\r
-            SkipImage = TRUE;\r
-            Status = Decompress->GetInfo (\r
-                                  Decompress,\r
-                                  ImageBuffer,\r
-                                  ImageLength,\r
-                                  &DestinationSize,\r
-                                  &ScratchSize\r
-                                  );\r
-            if (!EFI_ERROR (Status)) {\r
-              DecompressedImageBuffer = NULL;\r
-              DecompressedImageBuffer = AllocatePool (DestinationSize);\r
-              if (DecompressedImageBuffer != NULL) {\r
-                Scratch = AllocatePool (ScratchSize);\r
-                if (Scratch != NULL) {\r
-                  Status = Decompress->Decompress (\r
-                                        Decompress,\r
-                                        ImageBuffer,\r
-                                        ImageLength,\r
-                                        DecompressedImageBuffer,\r
-                                        DestinationSize,\r
-                                        Scratch,\r
-                                        ScratchSize\r
-                                        );\r
-                  if (!EFI_ERROR (Status)) {\r
-                    ImageBuffer = DecompressedImageBuffer;\r
-                    ImageLength = DestinationSize;\r
-                    SkipImage   = FALSE;\r
-                  }\r
-\r
-                  gBS->FreePool (Scratch);\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-\r
-        if (!SkipImage) {\r
-\r
-          //\r
-          // load image and start image\r
-          //\r
-\r
-          HexToString (&FileName[48], ImageIndex, 4);\r
-          FilePath = FileDevicePath (NULL, FileName);\r
-\r
-          Status = gBS->LoadImage (\r
-                          FALSE,\r
-                          This->ImageHandle,\r
-                          FilePath,\r
-                          ImageBuffer,\r
-                          ImageLength,\r
-                          &ImageHandle\r
-                          );\r
-          if (!EFI_ERROR (Status)) {\r
-            Status = gBS->StartImage (ImageHandle, NULL, NULL);\r
-            if (!EFI_ERROR (Status)) {\r
-              PciRomAddImageMapping (\r
-                ImageHandle,\r
-                PciOptionRomDescriptor->Seg,\r
-                PciOptionRomDescriptor->Bus,\r
-                PciOptionRomDescriptor->Dev,\r
-                PciOptionRomDescriptor->Func\r
-                );\r
-              retStatus = Status;\r
-            }\r
-          }\r
-          if (FilePath != NULL) {\r
-            gBS->FreePool (FilePath);\r
-          }\r
-        }\r
-\r
-        if (DecompressedImageBuffer != NULL) {\r
-          gBS->FreePool (DecompressedImageBuffer);\r
-        }\r
-\r
-      }\r
-    }\r
-\r
-    RomBarOffset = RomBarOffset + ImageSize;\r
-    ImageIndex++;\r
-  } while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize));\r
-\r
-  return retStatus;\r
-}\r
-\r
-EFI_STATUS\r
-PciRomLoadEfiDriversFromOptionRomTable (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL      *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_PCI_OPTION_ROM_TABLE          *PciOptionRomTable;\r
-  EFI_PCI_OPTION_ROM_DESCRIPTOR     *PciOptionRomDescriptor;\r
-  UINTN                             Index;\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;\r
-  UINT16                            MinBus;\r
-  UINT16                            MaxBus;\r
-\r
-  Status = EfiGetSystemConfigurationTable (&gEfiPciOptionRomTableGuid, (VOID **) &PciOptionRomTable);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Status = EFI_NOT_FOUND;\r
-\r
-  for (Index = 0; Index < PciOptionRomTable->PciOptionRomCount; Index++) {\r
-    PciOptionRomDescriptor = &PciOptionRomTable->PciOptionRomDescriptors[Index];\r
-    if (!PciOptionRomDescriptor->DontLoadEfiRom) {\r
-      if (PciOptionRomDescriptor->Seg == PciRootBridgeIo->SegmentNumber) {\r
-        Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Descriptors);\r
-        if (EFI_ERROR (Status)) {\r
-          return Status;\r
-        }\r
-\r
-        PciGetBusRange (&Descriptors, &MinBus, &MaxBus, NULL);\r
-        if ((MinBus <= PciOptionRomDescriptor->Bus) && (PciOptionRomDescriptor->Bus <= MaxBus)) {\r
-          Status = PciRomLoadEfiDriversFromRomImage (This, PciOptionRomDescriptor);\r
-          PciOptionRomDescriptor->DontLoadEfiRom |= 2;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-PciRomGetRomResourceFromPciOptionRomTable (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL      *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  PCI_IO_DEVICE                       *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_PCI_OPTION_ROM_TABLE      *PciOptionRomTable;\r
-  EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptor;\r
-  UINTN                         Index;\r
-\r
-  Status = EfiGetSystemConfigurationTable (&gEfiPciOptionRomTableGuid, (VOID **) &PciOptionRomTable);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  for (Index = 0; Index < PciOptionRomTable->PciOptionRomCount; Index++) {\r
-    PciOptionRomDescriptor = &PciOptionRomTable->PciOptionRomDescriptors[Index];\r
-    if (PciOptionRomDescriptor->Seg == PciRootBridgeIo->SegmentNumber &&\r
-        PciOptionRomDescriptor->Bus == PciIoDevice->BusNumber         &&\r
-        PciOptionRomDescriptor->Dev == PciIoDevice->DeviceNumber      &&\r
-        PciOptionRomDescriptor->Func == PciIoDevice->FunctionNumber ) {\r
-\r
-      PciIoDevice->PciIo.RomImage = (VOID *) (UINTN) PciOptionRomDescriptor->RomAddress;\r
-      PciIoDevice->PciIo.RomSize  = (UINTN) PciOptionRomDescriptor->RomLength;\r
-    }\r
-  }\r
-\r
-  for (Index = 0; Index < mNumberOfPciRomImages; Index++) {\r
-    if (mRomImageTable[Index].Seg  == PciRootBridgeIo->SegmentNumber &&\r
-        mRomImageTable[Index].Bus  == PciIoDevice->BusNumber         &&\r
-        mRomImageTable[Index].Dev  == PciIoDevice->DeviceNumber      &&\r
-        mRomImageTable[Index].Func == PciIoDevice->FunctionNumber    ) {\r
-\r
-      AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle);\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciRomTable.h b/DuetPkg/PciBusNoEnumerationDxe/PciRomTable.h
deleted file mode 100644 (file)
index 159a7f3..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PciRomTable.h\r
-  \r
-Abstract:\r
-\r
-  Option Rom Support for PCI Bus Driver\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#ifndef _EFI_PCI_ROM_TABLE_H\r
-#define _EFI_PCI_ROM_TABLE_H\r
-\r
-\r
-EFI_STATUS\r
-PciRomLoadEfiDriversFromOptionRomTable (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL      *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo\r
-  );\r
-\r
-EFI_STATUS\r
-PciRomGetRomResourceFromPciOptionRomTable (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL      *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *PciRootBridgeIo,\r
-  PCI_IO_DEVICE                       *PciIoDevice\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  TODO: Add function description\r
-\r
-Arguments:\r
-\r
-  This            - TODO: add argument description\r
-  PciRootBridgeIo - TODO: add argument description\r
-  PciIoDevice     - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  TODO: add return values\r
-\r
---*/\r
-;\r
-#endif\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/DeviceIo.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/DeviceIo.c
deleted file mode 100644 (file)
index b9cae2b..0000000
+++ /dev/null
@@ -1,845 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-    DeviceIo.c\r
-    \r
-Abstract:\r
-\r
-    EFI PC-AT PCI Device IO driver\r
-\r
---*/\r
-#include "PcatPciRootBridge.h"\r
-#include "DeviceIo.h"\r
-\r
-EFI_STATUS\r
-DeviceIoConstructor (\r
-  IN EFI_HANDLE                      Handle,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,\r
-  IN EFI_DEVICE_PATH_PROTOCOL        *DevicePath,\r
-  IN UINT16                          PrimaryBus,\r
-  IN UINT16                          SubordinateBus\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Initialize and install a Device IO protocol on a empty device path handle.\r
-\r
-Arguments:\r
-  \r
-  Handle               - Handle of PCI RootBridge IO instance\r
-  PciRootBridgeIo      - PCI RootBridge IO instance\r
-  DevicePath           - Device Path of PCI RootBridge IO instance\r
-  PrimaryBus           - Primary Bus\r
-  SubordinateBus       - Subordinate Bus\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS          -  This driver is added to ControllerHandle.  \r
-  EFI_ALREADY_STARTED  -  This driver is already running on ControllerHandle.   \r
-  Others               -  This driver does not support this device.\r
-\r
---*/\r
-{\r
-  EFI_STATUS                      Status;\r
-  DEVICE_IO_PRIVATE_DATA          *Private;\r
-\r
-  //\r
-  // Initialize the Device IO device instance.\r
-  //\r
-  Private = AllocateZeroPool (sizeof (DEVICE_IO_PRIVATE_DATA));\r
-  if (Private == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Private->Signature                = DEVICE_IO_PRIVATE_DATA_SIGNATURE;\r
-  Private->Handle                   = Handle;\r
-  Private->PciRootBridgeIo          = PciRootBridgeIo;\r
-  Private->DevicePath               = DevicePath;\r
-  Private->PrimaryBus               = PrimaryBus;\r
-  Private->SubordinateBus           = SubordinateBus;\r
-\r
-  Private->DeviceIo.Mem.Read        = DeviceIoMemRead;\r
-  Private->DeviceIo.Mem.Write       = DeviceIoMemWrite;\r
-  Private->DeviceIo.Io.Read         = DeviceIoIoRead;\r
-  Private->DeviceIo.Io.Write        = DeviceIoIoWrite;\r
-  Private->DeviceIo.Pci.Read        = DeviceIoPciRead;\r
-  Private->DeviceIo.Pci.Write       = DeviceIoPciWrite;\r
-  Private->DeviceIo.PciDevicePath   = DeviceIoPciDevicePath;\r
-  Private->DeviceIo.Map             = DeviceIoMap;\r
-  Private->DeviceIo.Unmap           = DeviceIoUnmap;\r
-  Private->DeviceIo.AllocateBuffer  = DeviceIoAllocateBuffer;\r
-  Private->DeviceIo.Flush           = DeviceIoFlush;\r
-  Private->DeviceIo.FreeBuffer      = DeviceIoFreeBuffer;\r
-\r
-  //\r
-  // Install protocol interfaces for the Device IO device.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Private->Handle,\r
-                  &gEfiDeviceIoProtocolGuid,\r
-                  &Private->DeviceIo,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMemRead (\r
-  IN     EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN     EFI_IO_WIDTH             Width,\r
-  IN     UINT64                   Address,\r
-  IN     UINTN                    Count,\r
-  IN OUT VOID                     *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform reading memory mapped I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.\r
-  Address  -  The base address of I/O operations.  \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.           \r
-  Buffer   -  The destination buffer to store results.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was read from the device.  \r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Width > MMIO_COPY_UINT64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  if (Width >= MMIO_COPY_UINT8) {\r
-    Width = (EFI_IO_WIDTH) (Width - MMIO_COPY_UINT8);\r
-    Status = Private->PciRootBridgeIo->CopyMem (\r
-                                         Private->PciRootBridgeIo,\r
-                                         (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                         (UINT64)(UINTN) Buffer,\r
-                                         Address,\r
-                                         Count\r
-                                         );\r
-  } else {\r
-    Status = Private->PciRootBridgeIo->Mem.Read (\r
-                                             Private->PciRootBridgeIo,\r
-                                             (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                             Address,\r
-                                             Count,\r
-                                             Buffer\r
-                                             );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMemWrite (\r
-  IN     EFI_DEVICE_IO_PROTOCOL    *This,\r
-  IN     EFI_IO_WIDTH              Width,\r
-  IN     UINT64                    Address,\r
-  IN     UINTN                     Count,\r
-  IN OUT VOID                      *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform writing memory mapped I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.  \r
-  Address  -  The base address of I/O operations.   \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.            \r
-  Buffer   -  The source buffer of data to be written.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was written to the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Width > MMIO_COPY_UINT64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  if (Width >= MMIO_COPY_UINT8) {\r
-    Width = (EFI_IO_WIDTH) (Width - MMIO_COPY_UINT8);\r
-    Status = Private->PciRootBridgeIo->CopyMem (\r
-                                         Private->PciRootBridgeIo,\r
-                                         (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                         Address,\r
-                                         (UINT64)(UINTN) Buffer,\r
-                                         Count\r
-                                         );\r
-  } else {\r
-    Status = Private->PciRootBridgeIo->Mem.Write (\r
-                                             Private->PciRootBridgeIo,\r
-                                             (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                             Address,\r
-                                             Count,\r
-                                             Buffer\r
-                                             );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoIoRead (\r
-  IN     EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN     EFI_IO_WIDTH             Width,\r
-  IN     UINT64                   Address,\r
-  IN     UINTN                    Count,\r
-  IN OUT VOID                     *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform reading I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.\r
-  Address  -  The base address of I/O operations. \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.          \r
-  Buffer   -  The destination buffer to store results.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was read from the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Width >= MMIO_COPY_UINT8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = Private->PciRootBridgeIo->Io.Read (\r
-                                          Private->PciRootBridgeIo,\r
-                                          (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                          Address,\r
-                                          Count,\r
-                                          Buffer\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoIoWrite (\r
-  IN     EFI_DEVICE_IO_PROTOCOL    *This,\r
-  IN     EFI_IO_WIDTH              Width,\r
-  IN     UINT64                    Address,\r
-  IN     UINTN                     Count,\r
-  IN OUT VOID                      *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform writing I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.\r
-  Address  -  The base address of I/O operations.\r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.        \r
-  Buffer   -  The source buffer of data to be written.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was written to the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Width >= MMIO_COPY_UINT8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = Private->PciRootBridgeIo->Io.Write (\r
-                                          Private->PciRootBridgeIo,\r
-                                          (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                          Address,\r
-                                          Count,\r
-                                          Buffer\r
-                                          );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoPciRead (\r
-  IN     EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN     EFI_IO_WIDTH             Width,\r
-  IN     UINT64                   Address,\r
-  IN     UINTN                    Count,\r
-  IN OUT VOID                     *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform reading PCI configuration space of device\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations. \r
-  Address  -  The base address of I/O operations. \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.           \r
-  Buffer   -  The destination buffer to store results.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was read from the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if ((UINT32)Width >= MMIO_COPY_UINT8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = Private->PciRootBridgeIo->Pci.Read (\r
-                                           Private->PciRootBridgeIo,\r
-                                           (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                           Address,\r
-                                           Count,\r
-                                           Buffer\r
-                                           );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoPciWrite (\r
-  IN     EFI_DEVICE_IO_PROTOCOL    *This,\r
-  IN     EFI_IO_WIDTH              Width,\r
-  IN     UINT64                    Address,\r
-  IN     UINTN                     Count,\r
-  IN OUT VOID                      *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform writing PCI configuration space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.   \r
-  Width    -  Width of I/O operations. \r
-  Address  -  The base address of I/O operations. \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.         \r
-  Buffer   -  The source buffer of data to be written.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was written to the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if ((UINT32)Width >= MMIO_COPY_UINT8) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = Private->PciRootBridgeIo->Pci.Write (\r
-                                           Private->PciRootBridgeIo,\r
-                                           (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) Width,\r
-                                           Address,\r
-                                           Count,\r
-                                           Buffer\r
-                                           );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-AppendPciDevicePath (\r
-  IN     DEVICE_IO_PRIVATE_DATA    *Private,\r
-  IN     UINT8                     Bus,\r
-  IN     UINT8                     Device,\r
-  IN     UINT8                     Function,\r
-  IN     EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
-  IN OUT UINT16                    *BridgePrimaryBus,\r
-  IN OUT UINT16                    *BridgeSubordinateBus\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Append a PCI device path node to another device path.\r
-\r
-Arguments:\r
-  \r
-  Private               -  A pointer to DEVICE_IO_PRIVATE_DATA instance.  \r
-  Bus                   -  PCI bus number of the device.\r
-  Device                -  PCI device number of the device.\r
-  Function              -  PCI function number of the device.\r
-  DevicePath            -  Original device path which will be appended a PCI device path node.\r
-  BridgePrimaryBus      -  Primary bus number of the bridge.\r
-  BridgeSubordinateBus  -  Subordinate bus number of the bridge.\r
-\r
-Returns:\r
-  \r
-  Pointer to the appended PCI device path.\r
-\r
---*/\r
-{\r
-  UINT16                    ThisBus;\r
-  UINT8                     ThisDevice;\r
-  UINT8                     ThisFunc;\r
-  UINT64                    Address;\r
-  PCI_TYPE01                PciBridge;\r
-  PCI_TYPE01                *PciPtr;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ReturnDevicePath;\r
-  PCI_DEVICE_PATH           PciNode;\r
-\r
-  PciPtr = &PciBridge;\r
-  for (ThisBus = *BridgePrimaryBus; ThisBus <= *BridgeSubordinateBus; ThisBus++) {\r
-    for (ThisDevice = 0; ThisDevice <= PCI_MAX_DEVICE; ThisDevice++) {\r
-      for (ThisFunc = 0; ThisFunc <= PCI_MAX_FUNC; ThisFunc++) {\r
-        Address = EFI_PCI_ADDRESS (ThisBus, ThisDevice, ThisFunc, 0);\r
-        ZeroMem (PciPtr, sizeof (PCI_TYPE01));\r
-        Private->DeviceIo.Pci.Read (\r
-                                &Private->DeviceIo,\r
-                                IO_UINT32,\r
-                                Address,\r
-                                1,\r
-                                &(PciPtr->Hdr.VendorId)\r
-                                );\r
-        if ((PciPtr->Hdr.VendorId == 0xffff) && (ThisFunc == 0)) {\r
-          break;\r
-        }\r
-        if (PciPtr->Hdr.VendorId == 0xffff) {\r
-          continue;\r
-        }\r
-\r
-        Private->DeviceIo.Pci.Read (\r
-                                &Private->DeviceIo,\r
-                                IO_UINT32,\r
-                                Address,\r
-                                sizeof (PCI_TYPE01) / sizeof (UINT32),\r
-                                PciPtr\r
-                                );\r
-        if (IS_PCI_BRIDGE (PciPtr)) {\r
-          if (Bus >= PciPtr->Bridge.SecondaryBus && Bus <= PciPtr->Bridge.SubordinateBus) {\r
-\r
-            PciNode.Header.Type     = HARDWARE_DEVICE_PATH;\r
-            PciNode.Header.SubType  = HW_PCI_DP;\r
-            SetDevicePathNodeLength (&PciNode.Header, sizeof (PciNode));\r
-\r
-            PciNode.Device        = ThisDevice;\r
-            PciNode.Function      = ThisFunc;\r
-            ReturnDevicePath      = AppendDevicePathNode (DevicePath, &PciNode.Header);\r
-\r
-            *BridgePrimaryBus     = PciPtr->Bridge.SecondaryBus;\r
-            *BridgeSubordinateBus = PciPtr->Bridge.SubordinateBus;\r
-            return ReturnDevicePath;\r
-          }\r
-        }\r
-\r
-        if ((ThisFunc == 0) && ((PciPtr->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x0)) {\r
-          //\r
-          // Skip sub functions, this is not a multi function device\r
-          //\r
-          break;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  ZeroMem (&PciNode, sizeof (PciNode));\r
-  PciNode.Header.Type     = HARDWARE_DEVICE_PATH;\r
-  PciNode.Header.SubType  = HW_PCI_DP;\r
-  SetDevicePathNodeLength (&PciNode.Header, sizeof (PciNode));\r
-  PciNode.Device        = Device;\r
-  PciNode.Function      = Function;\r
-\r
-  ReturnDevicePath      = AppendDevicePathNode (DevicePath, &PciNode.Header);\r
-\r
-  *BridgePrimaryBus     = 0xffff;\r
-  *BridgeSubordinateBus = 0xffff;\r
-  return ReturnDevicePath;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoPciDevicePath (\r
-  IN     EFI_DEVICE_IO_PROTOCOL        *This,\r
-  IN     UINT64                        Address,\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL      **PciDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Provides an EFI Device Path for a PCI device with the given PCI configuration space address.\r
-\r
-Arguments:\r
-  \r
-  This           -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.  \r
-  Address        -  The PCI configuration space address of the device whose Device Path\r
-                    is going to be returned.           \r
-  PciDevicePath  -  A pointer to the pointer for the EFI Device Path for PciAddress.\r
-                    Memory for the Device Path is allocated from the pool.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS           -  The PciDevicePath returns a pointer to a valid EFI Device Path.\r
-  EFI_UNSUPPORTED       -  The PciAddress does not map to a valid EFI Device Path. \r
-  EFI_OUT_OF_RESOURCES  -  The request could not be completed due to a lack of resources.\r
-\r
---*/\r
-{\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-  UINT16                  PrimaryBus;\r
-  UINT16                  SubordinateBus;\r
-  UINT8                   Bus;\r
-  UINT8                   Device;\r
-  UINT8                   Func;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Bus     = (UINT8) (((UINT32) Address >> 24) & 0xff);\r
-  Device  = (UINT8) (((UINT32) Address >> 16) & 0xff);\r
-  Func    = (UINT8) (((UINT32) Address >> 8) & 0xff);\r
-\r
-  if (Bus < Private->PrimaryBus || Bus > Private->SubordinateBus) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  *PciDevicePath  = Private->DevicePath;\r
-  PrimaryBus      = Private->PrimaryBus;\r
-  SubordinateBus  = Private->SubordinateBus;\r
-  do {\r
-    *PciDevicePath = AppendPciDevicePath (\r
-                       Private,\r
-                       Bus,\r
-                       Device,\r
-                       Func,\r
-                       *PciDevicePath,\r
-                       &PrimaryBus,\r
-                       &SubordinateBus\r
-                       );\r
-    if (*PciDevicePath == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-  } while (PrimaryBus != 0xffff);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMap (\r
-  IN     EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN     EFI_IO_OPERATION_TYPE    Operation,\r
-  IN     EFI_PHYSICAL_ADDRESS     *HostAddress,\r
-  IN OUT UINTN                    *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS     *DeviceAddress,\r
-  OUT    VOID                     **Mapping\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Provides the device-specific addresses needed to access system memory.\r
-\r
-Arguments:\r
-  \r
-  This           -  A pointer to the EFI_DEVICE_IO_INTERFACE instance. \r
-  Operation      -  Indicates if the bus master is going to read or write to system memory.  \r
-  HostAddress    -  The system memory address to map to the device.\r
-  NumberOfBytes  -  On input the number of bytes to map. On output the number of bytes\r
-                    that were mapped.\r
-  DeviceAddress  -  The resulting map address for the bus master device to use to access the\r
-                    hosts HostAddress.\r
-  Mapping        -  A resulting value to pass to Unmap().\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS            -  The range was mapped for the returned NumberOfBytes. \r
-  EFI_INVALID_PARAMETER  -  The Operation or HostAddress is undefined. \r
-  EFI_UNSUPPORTED        -  The HostAddress cannot be mapped as a common buffer.\r
-  EFI_DEVICE_ERROR       -  The system hardware could not map the requested address. \r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to a lack of resources.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if ((UINT32)Operation > EfiBusMasterCommonBuffer) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (((UINTN) (*HostAddress) != (*HostAddress)) && Operation == EfiBusMasterCommonBuffer) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = Private->PciRootBridgeIo->Map (\r
-                                       Private->PciRootBridgeIo,\r
-                                       (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION) Operation,\r
-                                       (VOID *) (UINTN) (*HostAddress),\r
-                                       NumberOfBytes,\r
-                                       DeviceAddress,\r
-                                       Mapping\r
-                                       );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoUnmap (\r
-  IN EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN VOID                     *Mapping\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Completes the Map() operation and releases any corresponding resources.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-  Mapping  -  The mapping value returned from Map().\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS       -  The range was unmapped.\r
-  EFI_DEVICE_ERROR  -  The data was not committed to the target system memory.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = Private->PciRootBridgeIo->Unmap (\r
-                                       Private->PciRootBridgeIo,\r
-                                       Mapping\r
-                                       );\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoAllocateBuffer (\r
-  IN     EFI_DEVICE_IO_PROTOCOL    *This,\r
-  IN     EFI_ALLOCATE_TYPE         Type,\r
-  IN     EFI_MEMORY_TYPE           MemoryType,\r
-  IN     UINTN                     Pages,\r
-  IN OUT EFI_PHYSICAL_ADDRESS      *PhysicalAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.\r
-\r
-Arguments:\r
-  \r
-  This             -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-  Type             -  The type allocation to perform.\r
-  MemoryType       -  The type of memory to allocate, EfiBootServicesData or\r
-                      EfiRuntimeServicesData.\r
-  Pages            -  The number of pages to allocate.\r
-  PhysicalAddress  -  A pointer to store the base address of the allocated range.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS            -  The requested memory pages were allocated.\r
-  EFI_OUT_OF_RESOURCES   -  The memory pages could not be allocated.\r
-  EFI_INVALID_PARAMETER  -  The requested memory type is invalid.\r
-  EFI_UNSUPPORTED        -  The requested PhysicalAddress is not supported on\r
-                            this platform.\r
-\r
---*/\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  HostAddress;\r
-\r
-  HostAddress = *PhysicalAddress;\r
-\r
-  if ((MemoryType != EfiBootServicesData) && (MemoryType != EfiRuntimeServicesData)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((UINT32)Type >= MaxAllocateType) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Type == AllocateAddress) && (HostAddress + EFI_PAGES_TO_SIZE (Pages) - 1 > MAX_COMMON_BUFFER)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if ((AllocateAnyPages == Type) || (AllocateMaxAddress == Type && HostAddress > MAX_COMMON_BUFFER)) {\r
-    Type        = AllocateMaxAddress;\r
-    HostAddress = MAX_COMMON_BUFFER;\r
-  }\r
-\r
-  Status = gBS->AllocatePages (\r
-                  Type,\r
-                  MemoryType,\r
-                  Pages,\r
-                  &HostAddress\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-\r
-  *PhysicalAddress = HostAddress;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoFlush (\r
-  IN EFI_DEVICE_IO_PROTOCOL  *This\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Flushes any posted write data to the device.\r
-\r
-Arguments:\r
-  \r
-  This  -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS       -  The buffers were flushed.\r
-  EFI_DEVICE_ERROR  -  The buffers were not flushed due to a hardware error.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-  DEVICE_IO_PRIVATE_DATA  *Private;\r
-\r
-  Private = DEVICE_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status  = Private->PciRootBridgeIo->Flush (Private->PciRootBridgeIo);\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoFreeBuffer (\r
-  IN EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN UINTN                    Pages,\r
-  IN EFI_PHYSICAL_ADDRESS     HostAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Frees pages that were allocated with AllocateBuffer().\r
-\r
-Arguments:\r
-  \r
-  This         -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-  Pages        -  The number of pages to free.\r
-  HostAddress  -  The base address of the range to free.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS            -  The requested memory pages were freed.\r
-  EFI_NOT_FOUND          -  The requested memory pages were not allocated with\r
-                            AllocateBuffer().               \r
-  EFI_INVALID_PARAMETER  -  HostAddress is not page aligned or Pages is invalid.\r
-\r
---*/\r
-{\r
-  if (((HostAddress & EFI_PAGE_MASK) != 0) || (Pages <= 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return gBS->FreePages (HostAddress, Pages);\r
-}\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/DeviceIo.h b/DuetPkg/PciRootBridgeNoEnumerationDxe/DeviceIo.h
deleted file mode 100644 (file)
index 6c40f9d..0000000
+++ /dev/null
@@ -1,449 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-    DeviceIo.h\r
-    \r
-Abstract:\r
-\r
-    Private Data definition for Device IO driver\r
-\r
---*/\r
-\r
-#ifndef _DEVICE_IO_H\r
-#define _DEVICE_IO_H\r
-\r
-\r
-\r
-#define DEVICE_IO_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('d', 'e', 'v', 'I')\r
-\r
-#define MAX_COMMON_BUFFER                 0x00000000FFFFFFFF\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-  EFI_HANDLE                      Handle;\r
-  EFI_DEVICE_IO_PROTOCOL          DeviceIo;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
-  EFI_DEVICE_PATH_PROTOCOL        *DevicePath;\r
-  UINT16                          PrimaryBus;\r
-  UINT16                          SubordinateBus;\r
-} DEVICE_IO_PRIVATE_DATA;\r
-\r
-#define DEVICE_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DEVICE_IO_PRIVATE_DATA, DeviceIo, DEVICE_IO_PRIVATE_DATA_SIGNATURE)\r
-\r
-EFI_STATUS\r
-DeviceIoConstructor (\r
-  IN EFI_HANDLE                      Handle,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,\r
-  IN EFI_DEVICE_PATH_PROTOCOL        *DevicePath,\r
-  IN UINT16                          PrimaryBus,\r
-  IN UINT16                          SubordinateBus\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize and install a Device IO protocol on a empty device path handle.\r
-\r
-Arguments:\r
-\r
-  Handle               - Handle of PCI RootBridge IO instance\r
-  PciRootBridgeIo      - PCI RootBridge IO instance\r
-  DevicePath           - Device Path of PCI RootBridge IO instance\r
-  PrimaryBus           - Primary Bus\r
-  SubordinateBus       - Subordinate Bus\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS          -  This driver is added to ControllerHandle.  \r
-  EFI_ALREADY_STARTED  -  This driver is already running on ControllerHandle.   \r
-  Others               -  This driver does not support this device.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMemRead (\r
-  IN     EFI_DEVICE_IO_PROTOCOL *This,\r
-  IN     EFI_IO_WIDTH           Width,\r
-  IN     UINT64                 Address,\r
-  IN     UINTN                  Count,\r
-  IN OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform reading memory mapped I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.\r
-  Address  -  The base address of I/O operations.  \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.           \r
-  Buffer   -  The destination buffer to store results.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was read from the device.  \r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\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
-DeviceIoMemWrite (\r
-  IN     EFI_DEVICE_IO_PROTOCOL *This,\r
-  IN     EFI_IO_WIDTH           Width,\r
-  IN     UINT64                 Address,\r
-  IN     UINTN                  Count,\r
-  IN OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform writing memory mapped I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.  \r
-  Address  -  The base address of I/O operations.   \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.            \r
-  Buffer   -  The source buffer of data to be written.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was written to the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\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
-DeviceIoIoRead (\r
-  IN     EFI_DEVICE_IO_PROTOCOL *This,\r
-  IN     EFI_IO_WIDTH           Width,\r
-  IN     UINT64                 Address,\r
-  IN     UINTN                  Count,\r
-  IN OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform reading I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.\r
-  Address  -  The base address of I/O operations. \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.          \r
-  Buffer   -  The destination buffer to store results.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was read from the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\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
-DeviceIoIoWrite (\r
-  IN     EFI_DEVICE_IO_PROTOCOL *This,\r
-  IN     EFI_IO_WIDTH           Width,\r
-  IN     UINT64                 Address,\r
-  IN     UINTN                  Count,\r
-  IN OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform writing I/O space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations.\r
-  Address  -  The base address of I/O operations.\r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.        \r
-  Buffer   -  The source buffer of data to be written.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was written to the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\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
-DeviceIoPciRead (\r
-  IN     EFI_DEVICE_IO_PROTOCOL *This,\r
-  IN     EFI_IO_WIDTH           Width,\r
-  IN     UINT64                 Address,\r
-  IN     UINTN                  Count,\r
-  IN OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform reading PCI configuration space of device\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.  \r
-  Width    -  Width of I/O operations. \r
-  Address  -  The base address of I/O operations. \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.           \r
-  Buffer   -  The destination buffer to store results.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was read from the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\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
-DeviceIoPciWrite (\r
-  IN     EFI_DEVICE_IO_PROTOCOL *This,\r
-  IN     EFI_IO_WIDTH           Width,\r
-  IN     UINT64                 Address,\r
-  IN     UINTN                  Count,\r
-  IN OUT VOID                   *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Perform writing PCI configuration space of device.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to EFI_DEVICE_IO protocol instance.   \r
-  Width    -  Width of I/O operations. \r
-  Address  -  The base address of I/O operations. \r
-  Count    -  The number of I/O operations to perform. \r
-              Bytes moves is Width size * Count, starting at Address.         \r
-  Buffer   -  The source buffer of data to be written.\r
-\r
-Returns:\r
-    \r
-  EFI_SUCCESS            -  The data was written to the device.\r
-  EFI_INVALID_PARAMETER  -  Width is invalid.\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
-DeviceIoPciDevicePath (\r
-  IN     EFI_DEVICE_IO_PROTOCOL        *This,\r
-  IN     UINT64                        Address,\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL      **PciDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Append a PCI device path node to another device path.\r
-\r
-Arguments:\r
-  \r
-  This                  -  A pointer to EFI_DEVICE_IO_PROTOCOL.  \r
-  Address               -  PCI bus,device, function.\r
-  PciDevicePath         -  PCI device path.\r
-\r
-Returns:\r
-  \r
-  Pointer to the appended PCI device path.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMap (\r
-  IN     EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN     EFI_IO_OPERATION_TYPE    Operation,\r
-  IN     EFI_PHYSICAL_ADDRESS     *HostAddress,\r
-  IN OUT UINTN                    *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS     *DeviceAddress,\r
-  OUT    VOID                     **Mapping\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Provides the device-specific addresses needed to access system memory.\r
-\r
-Arguments:\r
-  \r
-  This           -  A pointer to the EFI_DEVICE_IO_INTERFACE instance. \r
-  Operation      -  Indicates if the bus master is going to read or write to system memory.  \r
-  HostAddress    -  The system memory address to map to the device.\r
-  NumberOfBytes  -  On input the number of bytes to map. On output the number of bytes\r
-                    that were mapped.\r
-  DeviceAddress  -  The resulting map address for the bus master device to use to access the\r
-                    hosts HostAddress.\r
-  Mapping        -  A resulting value to pass to Unmap().\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS            -  The range was mapped for the returned NumberOfBytes. \r
-  EFI_INVALID_PARAMETER  -  The Operation or HostAddress is undefined. \r
-  EFI_UNSUPPORTED        -  The HostAddress cannot be mapped as a common buffer.\r
-  EFI_DEVICE_ERROR       -  The system hardware could not map the requested address. \r
-  EFI_OUT_OF_RESOURCES   -  The request could not be completed due to a lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoUnmap (\r
-  IN EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN VOID                     *Mapping\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Completes the Map() operation and releases any corresponding resources.\r
-\r
-Arguments:\r
-  \r
-  This     -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-  Mapping  -  The mapping value returned from Map().\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS       -  The range was unmapped.\r
-  EFI_DEVICE_ERROR  -  The data was not committed to the target system memory.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoAllocateBuffer (\r
-  IN     EFI_DEVICE_IO_PROTOCOL    *This,\r
-  IN     EFI_ALLOCATE_TYPE         Type,\r
-  IN     EFI_MEMORY_TYPE           MemoryType,\r
-  IN     UINTN                     Pages,\r
-  IN OUT EFI_PHYSICAL_ADDRESS      *HostAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.\r
-\r
-Arguments:\r
-  \r
-  This             -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-  Type             -  The type allocation to perform.\r
-  MemoryType       -  The type of memory to allocate, EfiBootServicesData or\r
-                      EfiRuntimeServicesData.\r
-  Pages            -  The number of pages to allocate.\r
-  HostAddress      -  A pointer to store the base address of the allocated range.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS            -  The requested memory pages were allocated.\r
-  EFI_OUT_OF_RESOURCES   -  The memory pages could not be allocated.\r
-  EFI_INVALID_PARAMETER  -  The requested memory type is invalid.\r
-  EFI_UNSUPPORTED        -  The requested PhysicalAddress is not supported on\r
-                            this platform.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoFlush (\r
-  IN EFI_DEVICE_IO_PROTOCOL  *This\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Flushes any posted write data to the device.\r
-\r
-Arguments:\r
-  \r
-  This  -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS       -  The buffers were flushed.\r
-  EFI_DEVICE_ERROR  -  The buffers were not flushed due to a hardware error.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoFreeBuffer (\r
-  IN EFI_DEVICE_IO_PROTOCOL   *This,\r
-  IN UINTN                    Pages,\r
-  IN EFI_PHYSICAL_ADDRESS     HostAddress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Frees pages that were allocated with AllocateBuffer().\r
-\r
-Arguments:\r
-  \r
-  This         -  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-  Pages        -  The number of pages to free.\r
-  HostAddress  -  The base address of the range to free.\r
-\r
-Returns:\r
-  \r
-  EFI_SUCCESS            -  The requested memory pages were freed.\r
-  EFI_NOT_FOUND          -  The requested memory pages were not allocated with\r
-                            AllocateBuffer().               \r
-  EFI_INVALID_PARAMETER  -  HostAddress is not page aligned or Pages is invalid.\r
-\r
---*/\r
-;\r
-\r
-#endif\r
-\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/Ia32/PcatIo.c
deleted file mode 100644 (file)
index d479e7f..0000000
+++ /dev/null
@@ -1,738 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-    PcatPciRootBridgeIo.c\r
-    \r
-Abstract:\r
-\r
-    EFI PC AT PCI Root Bridge Io Protocol\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PcatPciRootBridge.h"\r
-\r
-BOOLEAN                  mPciOptionRomTableInstalled = FALSE;\r
-EFI_PCI_OPTION_ROM_TABLE mPciOptionRomTable          = {0, NULL};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 UserAddress,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *UserBuffer\r
-  )\r
-{\r
-  return gCpuIo->Io.Read (\r
-                      gCpuIo,\r
-                      (EFI_CPU_IO_PROTOCOL_WIDTH) Width,\r
-                      UserAddress,\r
-                      Count,\r
-                      UserBuffer\r
-                      );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoWrite (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 UserAddress,\r
-  IN UINTN                                  Count,\r
-  IN OUT VOID                               *UserBuffer\r
-  )\r
-{\r
-  return gCpuIo->Io.Write (\r
-                      gCpuIo,\r
-                      (EFI_CPU_IO_PROTOCOL_WIDTH) Width,\r
-                      UserAddress,\r
-                      Count,\r
-                      UserBuffer\r
-                      );\r
-\r
-}\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoGetIoPortMapping (\r
-  OUT EFI_PHYSICAL_ADDRESS  *IoPortMapping,\r
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryPortMapping\r
-  )\r
-/*++\r
-\r
-  Get the IO Port Mapping.  For IA-32 it is always 0.\r
-  \r
---*/\r
-{\r
-  *IoPortMapping = 0;\r
-  *MemoryPortMapping = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoPciRW (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN BOOLEAN                                Write,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 UserAddress,\r
-  IN UINTN                                  Count,\r
-  IN OUT VOID                               *UserBuffer\r
-  )\r
-{\r
-  PCI_CONFIG_ACCESS_CF8             Pci;\r
-  PCI_CONFIG_ACCESS_CF8             PciAligned;\r
-  UINT32                            InStride;\r
-  UINT32                            OutStride;\r
-  UINTN                             PciData;\r
-  UINTN                             PciDataStride;\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE     *PrivateData;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS  PciAddress;\r
-  UINT64                            PciExpressRegAddr;\r
-  BOOLEAN                           UsePciExpressAccess;\r
-\r
-  if ((UINT32)Width >= EfiPciWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if ((Width & 0x03) >= EfiPciWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  InStride    = 1 << (Width & 0x03);\r
-  OutStride   = InStride;\r
-  if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {\r
-    InStride = 0;\r
-  }\r
-\r
-  if (Width >= EfiPciWidthFillUint8 && Width <= EfiPciWidthFillUint64) {\r
-    OutStride = 0;\r
-  }\r
-\r
-  UsePciExpressAccess = FALSE;\r
-\r
-  CopyMem (&PciAddress, &UserAddress, sizeof(UINT64));\r
-\r
-  if (PciAddress.ExtendedRegister > 0xFF) {\r
-    //\r
-    // Check PciExpressBaseAddress\r
-    //\r
-    if ((PrivateData->PciExpressBaseAddress == 0) ||\r
-        (PrivateData->PciExpressBaseAddress >= MAX_ADDRESS)) {\r
-      return EFI_UNSUPPORTED;\r
-    } else {\r
-      UsePciExpressAccess = TRUE;\r
-    }\r
-  } else {\r
-    if (PciAddress.ExtendedRegister != 0) {\r
-      Pci.Bits.Reg = PciAddress.ExtendedRegister & 0xFF;\r
-    } else {\r
-      Pci.Bits.Reg = PciAddress.Register;\r
-    }\r
-    //\r
-    // Note: We can also use PciExpress access here, if wanted.\r
-    //\r
-  }\r
-\r
-  if (!UsePciExpressAccess) {\r
-    Pci.Bits.Func     = PciAddress.Function;\r
-    Pci.Bits.Dev      = PciAddress.Device;\r
-    Pci.Bits.Bus      = PciAddress.Bus;\r
-    Pci.Bits.Reserved = 0;\r
-    Pci.Bits.Enable   = 1;\r
-\r
-    //\r
-    // PCI Config access are all 32-bit alligned, but by accessing the\r
-    //  CONFIG_DATA_REGISTER (0xcfc) with different widths more cycle types\r
-    //  are possible on PCI.\r
-    //\r
-    // To read a byte of PCI config space you load 0xcf8 and \r
-    //  read 0xcfc, 0xcfd, 0xcfe, 0xcff\r
-    //\r
-    PciDataStride = Pci.Bits.Reg & 0x03;\r
-\r
-    while (Count) {\r
-      PciAligned = Pci;\r
-      PciAligned.Bits.Reg &= 0xfc;\r
-      PciData = (UINTN)PrivateData->PciData + PciDataStride;\r
-      EfiAcquireLock(&PrivateData->PciLock);\r
-      This->Io.Write (This, EfiPciWidthUint32, PrivateData->PciAddress, 1, &PciAligned);\r
-      if (Write) {\r
-        This->Io.Write (This, Width, PciData, 1, UserBuffer);\r
-      } else {\r
-        This->Io.Read (This, Width, PciData, 1, UserBuffer);\r
-      }\r
-      EfiReleaseLock(&PrivateData->PciLock);\r
-      UserBuffer = ((UINT8 *)UserBuffer) + OutStride;\r
-      PciDataStride = (PciDataStride + InStride) % 4;\r
-      Pci.Bits.Reg += InStride;\r
-      Count -= 1;\r
-    }\r
-  } else {\r
-    //\r
-    // Access PCI-Express space by using memory mapped method.\r
-    //\r
-    PciExpressRegAddr = (PrivateData->PciExpressBaseAddress) |\r
-                        (PciAddress.Bus      << 20) |\r
-                        (PciAddress.Device   << 15) |\r
-                        (PciAddress.Function << 12);\r
-    if (PciAddress.ExtendedRegister != 0) {\r
-      PciExpressRegAddr += PciAddress.ExtendedRegister;\r
-    } else {\r
-      PciExpressRegAddr += PciAddress.Register;\r
-    }\r
-    while (Count) {\r
-      if (Write) {\r
-        This->Mem.Write (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);\r
-      } else {\r
-        This->Mem.Read (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);\r
-      }\r
-\r
-      UserBuffer = ((UINT8 *) UserBuffer) + OutStride;\r
-      PciExpressRegAddr += InStride;\r
-      Count -= 1;\r
-    }\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-ScanPciBus(\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  EFI_PCI_BUS_SCAN_CALLBACK        Callback,\r
-  VOID                             *Context\r
-  )\r
-  \r
-{\r
-  UINT16      Bus;\r
-  UINT16      Device;\r
-  UINT16      Func;\r
-  UINT64      Address;\r
-  PCI_TYPE00  PciHeader;\r
-\r
-  //\r
-  // Loop through all busses\r
-  //\r
-  for (Bus = MinBus; Bus <= MaxBus; Bus++) {\r
-    //  \r
-    // Loop 32 devices per bus\r
-    //\r
-    for (Device = MinDevice; Device <= MaxDevice; Device++) {\r
-      //\r
-      // Loop through 8 functions per device\r
-      //\r
-      for (Func = MinFunc; Func <= MaxFunc; Func++) {\r
-\r
-        //\r
-        // Compute the EFI Address required to access the PCI Configuration Header of this PCI Device\r
-        //\r
-        Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);\r
-\r
-        //\r
-        // Read the VendorID from this PCI Device's Confioguration Header\r
-        //\r
-        IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &PciHeader.Hdr.VendorId);\r
-    \r
-        //\r
-        // If VendorId = 0xffff, there does not exist a device at this \r
-        // location. For each device, if there is any function on it, \r
-        // there must be 1 function at Function 0. So if Func = 0, there\r
-        // will be no more functions in the same device, so we can break\r
-        // loop to deal with the next device.\r
-        //  \r
-        if (PciHeader.Hdr.VendorId == 0xffff && Func == 0) {\r
-          break;\r
-        }\r
-        \r
-        if (PciHeader.Hdr.VendorId != 0xffff) {\r
-\r
-          //\r
-          // Read the HeaderType to determine if this is a multi-function device\r
-          //\r
-          IoDev->Pci.Read (IoDev, EfiPciWidthUint8, Address + 0x0e, 1, &PciHeader.Hdr.HeaderType);\r
-\r
-          //\r
-          // Call the callback function for the device that was found\r
-          //\r
-          Callback(\r
-            IoDev, \r
-            MinBus, MaxBus,\r
-            MinDevice, MaxDevice,\r
-            MinFunc, MaxFunc,\r
-            Bus,\r
-            Device,\r
-            Func,\r
-            Context\r
-            );\r
-\r
-          //\r
-          // If this is not a multi-function device, we can leave the loop \r
-          // to deal with the next device.\r
-          //\r
-          if ((PciHeader.Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00 && Func == 0) {\r
-            break;\r
-          }\r
-        }  \r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-VOID\r
-CheckForRom (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *VoidContext\r
-  )\r
-{\r
-  EFI_STATUS                                 Status;\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  *Context;\r
-  UINT64                                     Address;\r
-  PCI_TYPE00                                 PciHeader;\r
-  PCI_TYPE01                                 *PciBridgeHeader;\r
-  UINT32                                     Register;\r
-  UINT32                                     RomBar;\r
-  UINT32                                     RomBarSize;\r
-  EFI_PHYSICAL_ADDRESS                       RomBuffer;\r
-  UINT32                                     MaxRomSize;\r
-  EFI_PCI_EXPANSION_ROM_HEADER               EfiRomHeader;\r
-  PCI_DATA_STRUCTURE                         Pcir;\r
-  EFI_PCI_OPTION_ROM_DESCRIPTOR              *TempPciOptionRomDescriptors;\r
-  BOOLEAN                                    LastImage;\r
-\r
-  Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;\r
-\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);\r
-\r
-  //\r
-  // Save the contents of the PCI Configuration Header\r
-  //\r
-  IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);\r
-\r
-  if (IS_PCI_BRIDGE(&PciHeader)) {\r
-\r
-    PciBridgeHeader = (PCI_TYPE01 *)(&PciHeader);\r
-\r
-    //\r
-    // See if the PCI-PCI Bridge has its secondary interface enabled.\r
-    //\r
-    if (PciBridgeHeader->Bridge.SubordinateBus >= PciBridgeHeader->Bridge.SecondaryBus) {\r
-\r
-      //\r
-      // Disable the Prefetchable Memory Window\r
-      //\r
-      Register = 0x00000000;\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x26, 1, &Register);\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x2c, 1, &Register);\r
-      Register = 0xffffffff;\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x24, 1, &Register);\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x28, 1, &Register);\r
-\r
-      //\r
-      // Program Memory Window to the PCI Root Bridge Memory Window\r
-      //\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x20, 4, &Context->PpbMemoryWindow);\r
-\r
-      //\r
-      // Enable the Memory decode for the PCI-PCI Bridge\r
-      //\r
-      IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-      Register |= 0x02;\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-\r
-      //\r
-      // Recurse on the Secondary Bus Number\r
-      //\r
-      ScanPciBus(\r
-        IoDev,\r
-        PciBridgeHeader->Bridge.SecondaryBus, PciBridgeHeader->Bridge.SecondaryBus, \r
-        0, PCI_MAX_DEVICE, \r
-        0, PCI_MAX_FUNC, \r
-        CheckForRom, Context\r
-        );\r
-    }\r
-  } else {\r
-\r
-    //\r
-    // Check if an Option ROM Register is present and save the Option ROM Window Register\r
-    //\r
-    RomBar = 0xffffffff;\r
-    IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-    IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-\r
-    RomBarSize = (~(RomBar & 0xfffff800)) + 1;\r
-\r
-    //\r
-    // Make sure the size of the ROM is between 0 and 16 MB\r
-    //\r
-    if (RomBarSize > 0 && RomBarSize <= 0x01000000) {\r
-\r
-      //\r
-      // Program Option ROM Window Register to the PCI Root Bridge Window and Enable the Option ROM Window\r
-      //\r
-      RomBar = (Context->PpbMemoryWindow & 0xffff) << 16;\r
-      RomBar = ((RomBar - 1) & (~(RomBarSize - 1))) + RomBarSize;\r
-      if (RomBar < (Context->PpbMemoryWindow & 0xffff0000)) {\r
-        MaxRomSize = (Context->PpbMemoryWindow & 0xffff0000) - RomBar;\r
-        RomBar = RomBar + 1;\r
-        IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-        IoDev->Pci.Read  (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-        RomBar = RomBar - 1;\r
-\r
-        //\r
-        // Enable the Memory decode for the PCI Device\r
-        //\r
-        IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-        Register |= 0x02;\r
-        IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-\r
-        //\r
-        // Follow the chain of images to determine the size of the Option ROM present\r
-        // Keep going until the last image is found by looking at the Indicator field\r
-        // or the size of an image is 0, or the size of all the images is bigger than the\r
-        // size of the window programmed into the PPB.\r
-        //\r
-        RomBarSize = 0;\r
-        do {\r
-\r
-          LastImage = TRUE;\r
-\r
-          ZeroMem (&EfiRomHeader, sizeof(EfiRomHeader));\r
-          IoDev->Mem.Read (\r
-            IoDev, \r
-            EfiPciWidthUint8, \r
-            RomBar + RomBarSize, \r
-            sizeof(EfiRomHeader),\r
-            &EfiRomHeader\r
-            );\r
-\r
-          Pcir.ImageLength = 0;\r
-\r
-          if (EfiRomHeader.Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE &&\r
-              EfiRomHeader.PcirOffset != 0 &&\r
-              (EfiRomHeader.PcirOffset & 3) == 0 &&\r
-              RomBarSize + EfiRomHeader.PcirOffset + sizeof (PCI_DATA_STRUCTURE) <= MaxRomSize) {\r
-            ZeroMem (&Pcir, sizeof(Pcir));\r
-            IoDev->Mem.Read (\r
-              IoDev, \r
-              EfiPciWidthUint8, \r
-              RomBar + RomBarSize + EfiRomHeader.PcirOffset, \r
-              sizeof(Pcir),\r
-              &Pcir\r
-              );\r
-\r
-            if (Pcir.Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-              break;\r
-            }\r
-            if (RomBarSize + Pcir.ImageLength * 512 > MaxRomSize) {\r
-              break;\r
-            }\r
-            if ((Pcir.Indicator & 0x80) == 0x00) {\r
-              LastImage = FALSE;\r
-            }\r
-\r
-            RomBarSize += Pcir.ImageLength * 512;\r
-          }\r
-        } while (!LastImage && RomBarSize < MaxRomSize && Pcir.ImageLength !=0);\r
-\r
-        if (RomBarSize > 0) {\r
-\r
-          //\r
-          // Allocate a memory buffer for the Option ROM contents.\r
-          //\r
-          Status = gBS->AllocatePages(\r
-                          AllocateAnyPages,\r
-                          EfiBootServicesData,\r
-                          EFI_SIZE_TO_PAGES(RomBarSize),\r
-                          &RomBuffer\r
-                          );\r
-\r
-          if (!EFI_ERROR (Status)) {\r
-\r
-            //\r
-            // Copy the contents of the Option ROM to the memory buffer\r
-            //\r
-            IoDev->Mem.Read (IoDev, EfiPciWidthUint32, RomBar, RomBarSize / sizeof(UINT32), (VOID *)(UINTN)RomBuffer);\r
-\r
-            Status = gBS->AllocatePool(\r
-                            EfiBootServicesData,\r
-                            ((UINT32)mPciOptionRomTable.PciOptionRomCount + 1) * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR),\r
-                            (VOID*)&TempPciOptionRomDescriptors\r
-                            );\r
-            if (mPciOptionRomTable.PciOptionRomCount > 0) {\r
-              CopyMem(\r
-                TempPciOptionRomDescriptors, \r
-                mPciOptionRomTable.PciOptionRomDescriptors, \r
-                (UINT32)mPciOptionRomTable.PciOptionRomCount * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR)\r
-                );\r
-\r
-              gBS->FreePool(mPciOptionRomTable.PciOptionRomDescriptors);\r
-            }\r
-\r
-            mPciOptionRomTable.PciOptionRomDescriptors = TempPciOptionRomDescriptors; \r
-\r
-            TempPciOptionRomDescriptors = &(mPciOptionRomTable.PciOptionRomDescriptors[(UINT32)mPciOptionRomTable.PciOptionRomCount]);\r
-\r
-            TempPciOptionRomDescriptors->RomAddress              = RomBuffer;\r
-            TempPciOptionRomDescriptors->MemoryType              = EfiBootServicesData;\r
-            TempPciOptionRomDescriptors->RomLength               = RomBarSize;\r
-            TempPciOptionRomDescriptors->Seg                     = (UINT32)IoDev->SegmentNumber;\r
-            TempPciOptionRomDescriptors->Bus                     = (UINT8)Bus;\r
-            TempPciOptionRomDescriptors->Dev                     = (UINT8)Device;\r
-            TempPciOptionRomDescriptors->Func                    = (UINT8)Func;\r
-            TempPciOptionRomDescriptors->ExecutedLegacyBiosImage = TRUE;\r
-            TempPciOptionRomDescriptors->DontLoadEfiRom          = FALSE;\r
-\r
-            mPciOptionRomTable.PciOptionRomCount++;\r
-          }\r
-        }\r
-\r
-        //\r
-        // Disable the Memory decode for the PCI-PCI Bridge\r
-        //\r
-        IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-        Register &= (~0x02);\r
-        IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Restore the PCI Configuration Header \r
-  //\r
-  IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);\r
-}\r
-\r
-VOID\r
-SaveCommandRegister (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *VoidContext\r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  *Context;\r
-  UINT64  Address;\r
-  UINTN   Index;\r
-  UINT16  Command;\r
-\r
-  Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;\r
-\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);\r
-\r
-  Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;\r
-\r
-  IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);\r
-\r
-  //\r
-  // Clear the memory enable bit\r
-  //\r
-  Command = (UINT16) (Context->CommandRegisterBuffer[Index] & (~0x02));\r
-\r
-  IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Command);\r
-}\r
-\r
-VOID\r
-RestoreCommandRegister (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *VoidContext\r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  *Context;\r
-  UINT64                                     Address;\r
-  UINTN                                      Index;\r
-\r
-  Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;\r
-\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);\r
-\r
-  Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;\r
-\r
-  IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);\r
-}\r
-\r
-EFI_STATUS\r
-ScanPciRootBridgeForRoms(\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev\r
-  )\r
-  \r
-{\r
-  EFI_STATUS                                 Status;\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR          *Descriptors; \r
-  UINT16                                     MinBus;\r
-  UINT16                                     MaxBus;\r
-  UINT64                                     RootWindowBase;\r
-  UINT64                                     RootWindowLimit;\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  Context;\r
-\r
-  if (mPciOptionRomTableInstalled == FALSE) {\r
-    gBS->InstallConfigurationTable(&gEfiPciOptionRomTableGuid, &mPciOptionRomTable);\r
-    mPciOptionRomTableInstalled = TRUE;\r
-  }\r
-\r
-  Status = IoDev->Configuration(IoDev, (VOID **)&Descriptors);\r
-  if (EFI_ERROR (Status) || Descriptors == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  MinBus = 0xffff;\r
-  MaxBus = 0xffff;\r
-  RootWindowBase  = 0;\r
-  RootWindowLimit = 0;\r
-  while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {\r
-    //\r
-    // Find bus range\r
-    //\r
-    if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {\r
-      MinBus = (UINT16)Descriptors->AddrRangeMin;\r
-      MaxBus = (UINT16)Descriptors->AddrRangeMax;\r
-    }\r
-    //\r
-    // Find memory descriptors that are not prefetchable\r
-    //\r
-    if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM && Descriptors->SpecificFlag == 0) {\r
-      //\r
-      // Find Memory Descriptors that are less than 4GB, so the PPB Memory Window can be used for downstream devices\r
-      //\r
-      if (Descriptors->AddrRangeMax < 0x100000000ULL) {\r
-        //\r
-        // Find the largest Non-Prefetchable Memory Descriptor that is less than 4GB\r
-        //\r
-        if ((Descriptors->AddrRangeMax - Descriptors->AddrRangeMin) > (RootWindowLimit - RootWindowBase)) {\r
-          RootWindowBase  = Descriptors->AddrRangeMin;\r
-          RootWindowLimit = Descriptors->AddrRangeMax;\r
-        }\r
-      }\r
-    }\r
-    Descriptors ++;\r
-  }\r
-\r
-  //\r
-  // Make sure a bus range was found\r
-  //\r
-  if (MinBus == 0xffff || MaxBus == 0xffff) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Make sure a non-prefetchable memory region was found\r
-  //\r
-  if (RootWindowBase == 0 && RootWindowLimit == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Round the Base and Limit values to 1 MB boudaries\r
-  //\r
-  RootWindowBase  = ((RootWindowBase - 1) & 0xfff00000) + 0x00100000;\r
-  RootWindowLimit = ((RootWindowLimit + 1) & 0xfff00000) - 1;\r
-\r
-  //\r
-  // Make sure that the size of the rounded window is greater than zero\r
-  //\r
-  if (RootWindowLimit <= RootWindowBase) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Allocate buffer to save the Command register from all the PCI devices\r
-  //\r
-  Context.CommandRegisterBuffer = NULL;\r
-  Status = gBS->AllocatePool(\r
-                  EfiBootServicesData,\r
-                  sizeof(UINT16) * (MaxBus - MinBus + 1) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1),\r
-                  (VOID **)&Context.CommandRegisterBuffer\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Context.PpbMemoryWindow   = (((UINT32)RootWindowBase) >> 16) | ((UINT32)RootWindowLimit & 0xffff0000);\r
-\r
-  //\r
-  // Save the Command register from all the PCI devices, and disable the I/O, Mem, and BusMaster bits\r
-  //\r
-  ScanPciBus(\r
-    IoDev,\r
-    MinBus, MaxBus, \r
-    0, PCI_MAX_DEVICE, \r
-    0, PCI_MAX_FUNC, \r
-    SaveCommandRegister, &Context\r
-    );\r
-\r
-  //\r
-  // Recursively scan all the busses for PCI Option ROMs\r
-  //\r
-  ScanPciBus(\r
-    IoDev,\r
-    MinBus, MinBus, \r
-    0, PCI_MAX_DEVICE, \r
-    0, PCI_MAX_FUNC, \r
-    CheckForRom, &Context\r
-    );\r
-\r
-  //\r
-  // Restore the Command register in all the PCI devices\r
-  //\r
-  ScanPciBus(\r
-    IoDev,\r
-    MinBus, MaxBus, \r
-    0, PCI_MAX_DEVICE, \r
-    0, PCI_MAX_FUNC, \r
-    RestoreCommandRegister, &Context\r
-    );\r
-\r
-  //\r
-  // Free the buffer used to save all the Command register values\r
-  //\r
-  gBS->FreePool(Context.CommandRegisterBuffer);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridge.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridge.c
deleted file mode 100644 (file)
index f633533..0000000
+++ /dev/null
@@ -1,1009 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
-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
-  PcatPciRootBridge.c\r
-    \r
-Abstract:\r
-\r
-    EFI PC-AT PCI Root Bridge Controller\r
-\r
---*/\r
-\r
-#include "PcatPciRootBridge.h"\r
-#include "DeviceIo.h"\r
-\r
-EFI_CPU_IO2_PROTOCOL *gCpuIo;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializePcatPciRootBridge (\r
-  IN EFI_HANDLE       ImageHandle,\r
-  IN EFI_SYSTEM_TABLE *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Initializes the PCI Root Bridge Controller\r
-\r
-Arguments:\r
-  ImageHandle -\r
-  SystemTable -\r
-    \r
-Returns:\r
-    None\r
-\r
---*/\r
-{\r
-  EFI_STATUS                     Status;\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData;\r
-  UINTN                          PciSegmentIndex;\r
-  UINTN                          PciRootBridgeIndex;\r
-  UINTN                          PrimaryBusIndex;\r
-  UINTN                          NumberOfPciRootBridges;\r
-  UINTN                          NumberOfPciDevices;\r
-  UINTN                          Device;\r
-  UINTN                          Function;\r
-  UINT16                         VendorId;\r
-  PCI_TYPE01                     PciConfigurationHeader;\r
-  UINT64                         Address;\r
-  UINT64                         Value;\r
-  UINT64                         Base;\r
-  UINT64                         Limit;\r
-\r
-  //\r
-  // Initialize gCpuIo now since the chipset init code requires it.\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiCpuIo2ProtocolGuid, NULL, (VOID **)&gCpuIo);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Initialize variables required to search all PCI segments for PCI devices\r
-  //\r
-  PciSegmentIndex        = 0;\r
-  PciRootBridgeIndex     = 0;\r
-  NumberOfPciRootBridges = 0;\r
-  PrimaryBusIndex        = 0;\r
-\r
-  while (PciSegmentIndex <= PCI_MAX_SEGMENT) {\r
-\r
-    PrivateData = NULL;\r
-    Status = gBS->AllocatePool(\r
-                    EfiBootServicesData,\r
-                    sizeof (PCAT_PCI_ROOT_BRIDGE_INSTANCE),\r
-                    (VOID **)&PrivateData\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    ZeroMem (PrivateData, sizeof (PCAT_PCI_ROOT_BRIDGE_INSTANCE));\r
-\r
-    //\r
-    // Initialize the signature of the private data structure\r
-    //\r
-    PrivateData->Signature  = PCAT_PCI_ROOT_BRIDGE_SIGNATURE;\r
-    PrivateData->Handle     = NULL;\r
-    PrivateData->DevicePath = NULL;\r
-    InitializeListHead (&PrivateData->MapInfo);\r
-\r
-    //\r
-    // Initialize the PCI root bridge number and the bus range for that root bridge\r
-    //\r
-    PrivateData->RootBridgeNumber = (UINT32)PciRootBridgeIndex;\r
-    PrivateData->PrimaryBus       = (UINT32)PrimaryBusIndex;\r
-    PrivateData->SubordinateBus   = (UINT32)PrimaryBusIndex;\r
-\r
-    PrivateData->IoBase      = 0xffffffff;\r
-    PrivateData->MemBase     = 0xffffffff;\r
-    PrivateData->Mem32Base   = 0xffffffffffffffffULL;\r
-    PrivateData->Pmem32Base  = 0xffffffffffffffffULL;\r
-    PrivateData->Mem64Base   = 0xffffffffffffffffULL;\r
-    PrivateData->Pmem64Base  = 0xffffffffffffffffULL;\r
-\r
-    //\r
-    // The default mechanism for performing PCI Configuration cycles is to \r
-    // use the I/O ports at 0xCF8 and 0xCFC.  This is only used for IA-32.\r
-    // IPF uses SAL calls to perform PCI COnfiguration cycles\r
-    //\r
-    PrivateData->PciAddress  = 0xCF8;\r
-    PrivateData->PciData     = 0xCFC;\r
-\r
-    //\r
-    // Get the physical I/O base for performing PCI I/O cycles\r
-    // For IA-32, this is always 0, because IA-32 has IN and OUT instructions\r
-    // For IPF, a SAL call is made to retrieve the base address for PCI I/O cycles\r
-    //\r
-    Status = PcatRootBridgeIoGetIoPortMapping (\r
-               &PrivateData->PhysicalIoBase, \r
-               &PrivateData->PhysicalMemoryBase\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    //\r
-    // Get PCI Express Base Address\r
-    //\r
-    PrivateData->PciExpressBaseAddress = GetPciExpressBaseAddressForRootBridge (PciSegmentIndex, PciRootBridgeIndex);\r
-    if (PrivateData->PciExpressBaseAddress != 0) {\r
-      DEBUG ((EFI_D_ERROR, "PCIE Base - 0x%lx\n", PrivateData->PciExpressBaseAddress));\r
-    }\r
-\r
-    //\r
-    // Create a lock for performing PCI Configuration cycles\r
-    //\r
-    EfiInitializeLock (&PrivateData->PciLock, TPL_HIGH_LEVEL);\r
-\r
-    //\r
-    // Initialize the attributes for this PCI root bridge\r
-    //\r
-    PrivateData->Attributes  = 0;\r
-\r
-    //\r
-    // Build the EFI Device Path Protocol instance for this PCI Root Bridge\r
-    //\r
-    Status = PcatRootBridgeDevicePathConstructor (&PrivateData->DevicePath, PciRootBridgeIndex, (BOOLEAN)((PrivateData->PciExpressBaseAddress != 0) ? TRUE : FALSE));\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    //\r
-    // Build the PCI Root Bridge I/O Protocol instance for this PCI Root Bridge\r
-    //\r
-    Status = PcatRootBridgeIoConstructor (&PrivateData->Io, PciSegmentIndex);\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-    \r
-    //\r
-    // Scan all the PCI devices on the primary bus of the PCI root bridge\r
-    //\r
-    for (Device = 0, NumberOfPciDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {\r
-    \r
-      for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {\r
-\r
-        //\r
-        // Compute the PCI configuration address of the PCI device to probe\r
-        //\r
-        Address = EFI_PCI_ADDRESS (PrimaryBusIndex, Device, Function, 0);\r
-\r
-        //\r
-        // Read the Vendor ID from the PCI Configuration Header\r
-        //\r
-        Status = PrivateData->Io.Pci.Read (\r
-                                       &PrivateData->Io, \r
-                                       EfiPciWidthUint16, \r
-                                       Address, \r
-                                       sizeof (VendorId) / sizeof (UINT16), \r
-                                       &VendorId\r
-                                       );\r
-        if ((EFI_ERROR (Status)) || ((VendorId == 0xffff) && (Function == 0))) {\r
-          //\r
-          // If the PCI Configuration Read fails, or a PCI device does not exist, then \r
-          // skip this entire PCI device\r
-          //\r
-          break;\r
-        }\r
-        if (VendorId == 0xffff) {\r
-          //\r
-          // If PCI function != 0, VendorId == 0xFFFF, we continue to search PCI function.\r
-          //\r
-          continue;\r
-        }\r
-\r
-        //\r
-        // Read the entire PCI Configuration Header\r
-        //\r
-        Status = PrivateData->Io.Pci.Read (\r
-                                       &PrivateData->Io, \r
-                                       EfiPciWidthUint16, \r
-                                       Address, \r
-                                       sizeof (PciConfigurationHeader) / sizeof (UINT16), \r
-                                       &PciConfigurationHeader\r
-                                       );\r
-        if (EFI_ERROR (Status)) {\r
-          //\r
-          // If the entire PCI Configuration Header can not be read, then skip this entire PCI device\r
-          //\r
-          break;\r
-        }\r
-\r
-\r
-        //\r
-        // Increment the number of PCI device found on the primary bus of the PCI root bridge\r
-        //\r
-        NumberOfPciDevices++;\r
-\r
-        //\r
-        // Look for devices with the VGA Palette Snoop enabled in the COMMAND register of the PCI Config Header\r
-        //\r
-        if (PciConfigurationHeader.Hdr.Command & 0x20) {\r
-          PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
-        }\r
-\r
-        //\r
-        // If the device is a PCI-PCI Bridge, then look at the Subordinate Bus Number\r
-        //\r
-        if (IS_PCI_BRIDGE(&PciConfigurationHeader)) {\r
-          //\r
-          // Get the Bus range that the PPB is decoding\r
-          //\r
-          if (PciConfigurationHeader.Bridge.SubordinateBus > PrivateData->SubordinateBus) {\r
-            //\r
-            // If the suborinate bus number of the PCI-PCI bridge is greater than the PCI root bridge's\r
-            // current subordinate bus number, then update the PCI root bridge's subordinate bus number \r
-            //\r
-            PrivateData->SubordinateBus = PciConfigurationHeader.Bridge.SubordinateBus;\r
-          }\r
-\r
-          //\r
-          // Get the I/O range that the PPB is decoding\r
-          //\r
-          Value = PciConfigurationHeader.Bridge.IoBase & 0x0f;\r
-          Base  = ((UINT32)PciConfigurationHeader.Bridge.IoBase & 0xf0) << 8;\r
-          Limit = (((UINT32)PciConfigurationHeader.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;\r
-          if (Value == 0x01) {\r
-            Base  |= ((UINT32)PciConfigurationHeader.Bridge.IoBaseUpper16 << 16);\r
-            Limit |= ((UINT32)PciConfigurationHeader.Bridge.IoLimitUpper16 << 16);\r
-          }\r
-          if (Base < Limit) {\r
-            if (PrivateData->IoBase > Base) {\r
-              PrivateData->IoBase = Base;\r
-            }\r
-            if (PrivateData->IoLimit < Limit) {\r
-              PrivateData->IoLimit = Limit;\r
-            }\r
-          }\r
-\r
-          //\r
-          // Get the Memory range that the PPB is decoding\r
-          //\r
-          Base  = ((UINT32)PciConfigurationHeader.Bridge.MemoryBase & 0xfff0) << 16;\r
-          Limit = (((UINT32)PciConfigurationHeader.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;\r
-          if (Base < Limit) {\r
-            if (PrivateData->MemBase > Base) {\r
-              PrivateData->MemBase = Base;\r
-            }\r
-            if (PrivateData->MemLimit < Limit) {\r
-              PrivateData->MemLimit = Limit;\r
-            }\r
-            if (PrivateData->Mem32Base > Base) {\r
-              PrivateData->Mem32Base = Base;\r
-            }\r
-            if (PrivateData->Mem32Limit < Limit) {\r
-              PrivateData->Mem32Limit = Limit;\r
-            }\r
-          }\r
-\r
-          //\r
-          // Get the Prefetchable Memory range that the PPB is decoding\r
-          //\r
-          Value = PciConfigurationHeader.Bridge.PrefetchableMemoryBase & 0x0f;\r
-          Base  = ((UINT32)PciConfigurationHeader.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;\r
-          Limit = (((UINT32)PciConfigurationHeader.Bridge.PrefetchableMemoryLimit & 0xfff0) << 16) | 0xffffff;\r
-          if (Value == 0x01) {\r
-            Base  |= LShiftU64((UINT64)PciConfigurationHeader.Bridge.PrefetchableBaseUpper32,32);\r
-            Limit |= LShiftU64((UINT64)PciConfigurationHeader.Bridge.PrefetchableLimitUpper32,32);\r
-          }\r
-          if (Base < Limit) {\r
-            if (PrivateData->MemBase > Base) {\r
-              PrivateData->MemBase = Base;\r
-            }\r
-            if (PrivateData->MemLimit < Limit) {\r
-              PrivateData->MemLimit = Limit;\r
-            }\r
-            if (Value == 0x00) {\r
-              if (PrivateData->Pmem32Base > Base) {\r
-                PrivateData->Pmem32Base = Base;\r
-              }\r
-              if (PrivateData->Pmem32Limit < Limit) {\r
-                PrivateData->Pmem32Limit = Limit;\r
-              }\r
-            }\r
-            if (Value == 0x01) {\r
-              if (PrivateData->Pmem64Base > Base) {\r
-                PrivateData->Pmem64Base = Base;\r
-              }\r
-              if (PrivateData->Pmem64Limit < Limit) {\r
-                PrivateData->Pmem64Limit = Limit;\r
-              }\r
-            }\r
-          }\r
-\r
-          //\r
-          // Look at the PPB Configuration for legacy decoding attributes\r
-          //\r
-          if (PciConfigurationHeader.Bridge.BridgeControl & 0x04) {\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;\r
-          }\r
-          if (PciConfigurationHeader.Bridge.BridgeControl & 0x08) {\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;\r
-          }\r
-\r
-        } else {\r
-          //\r
-          // Parse the BARs of the PCI device to determine what I/O Ranges,\r
-          // Memory Ranges, and Prefetchable Memory Ranges the device is decoding\r
-          //\r
-          if ((PciConfigurationHeader.Hdr.HeaderType & HEADER_LAYOUT_CODE) == HEADER_TYPE_DEVICE) {\r
-            Status = PcatPciRootBridgeParseBars (\r
-                       PrivateData, \r
-                       PciConfigurationHeader.Hdr.Command,\r
-                       PrimaryBusIndex, \r
-                       Device, \r
-                       Function\r
-                       );\r
-          }\r
-\r
-          //\r
-          // See if the PCI device is an IDE controller\r
-          //\r
-          if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x01 &&\r
-              PciConfigurationHeader.Hdr.ClassCode[1] == 0x01    ) {\r
-            if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x80) {\r
-              PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;\r
-              PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;\r
-            }\r
-            if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x01) {\r
-              PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;\r
-            }\r
-            if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x04) {\r
-              PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;\r
-            }\r
-          }\r
-\r
-          //\r
-          // See if the PCI device is a legacy VGA controller\r
-          //\r
-          if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x00 &&\r
-              PciConfigurationHeader.Hdr.ClassCode[1] == 0x01    ) {\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;\r
-          }\r
-\r
-          //\r
-          // See if the PCI device is a standard VGA controller\r
-          //\r
-          if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x03 &&\r
-              PciConfigurationHeader.Hdr.ClassCode[1] == 0x00    ) {\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;\r
-            PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;\r
-          }\r
-\r
-          //\r
-          // See if the PCI Device is a PCI - ISA or PCI - EISA \r
-          // or ISA_POSITIVIE_DECODE Bridge device\r
-          //\r
-          if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x06) {\r
-            if (PciConfigurationHeader.Hdr.ClassCode[1] == 0x01 ||\r
-                PciConfigurationHeader.Hdr.ClassCode[1] == 0x02 || \r
-                PciConfigurationHeader.Hdr.ClassCode[1] == 0x80 ) {\r
-              PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;\r
-              PrivateData->Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;\r
-\r
-              if (PrivateData->MemBase > 0xa0000) {\r
-                PrivateData->MemBase = 0xa0000;\r
-              }\r
-              if (PrivateData->MemLimit < 0xbffff) {\r
-               PrivateData->MemLimit = 0xbffff;\r
-             }\r
-            }\r
-          }\r
-        }\r
-\r
-        //\r
-        // If this device is not a multi function device, then skip the rest of this PCI device\r
-        //\r
-        if (Function == 0 && !(PciConfigurationHeader.Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION)) {\r
-          break;\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // After scanning all the PCI devices on the PCI root bridge's primary bus, update the \r
-    // Primary Bus Number for the next PCI root bridge to be this PCI root bridge's subordinate\r
-    // bus number + 1.\r
-    //\r
-    PrimaryBusIndex = PrivateData->SubordinateBus + 1;\r
-\r
-    //\r
-    // If at least one PCI device was found on the primary bus of this PCI root bridge, then the PCI root bridge\r
-    // exists.\r
-    //\r
-    if (NumberOfPciDevices > 0) {\r
-\r
-      //\r
-      // Adjust the I/O range used for bounds checking for the legacy decoding attributed\r
-      //\r
-      if (PrivateData->Attributes & 0x7f) {\r
-        PrivateData->IoBase = 0;\r
-        if (PrivateData->IoLimit < 0xffff) {\r
-          PrivateData->IoLimit = 0xffff;\r
-        }\r
-      }\r
-\r
-      //\r
-      // Adjust the Memory range used for bounds checking for the legacy decoding attributed\r
-      //\r
-      if (PrivateData->Attributes & EFI_PCI_ATTRIBUTE_VGA_MEMORY) {\r
-        if (PrivateData->MemBase > 0xa0000) {\r
-          PrivateData->MemBase = 0xa0000;\r
-        }\r
-        if (PrivateData->MemLimit < 0xbffff) {\r
-          PrivateData->MemLimit = 0xbffff;\r
-        }\r
-      }\r
-\r
-      //\r
-      // Build ACPI descriptors for the resources on the PCI Root Bridge\r
-      //\r
-      Status = ConstructConfiguration(PrivateData);\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      //\r
-      // Create the handle for this PCI Root Bridge \r
-      //\r
-      Status = gBS->InstallMultipleProtocolInterfaces (\r
-                     &PrivateData->Handle,              \r
-                     &gEfiDevicePathProtocolGuid,\r
-                     PrivateData->DevicePath,\r
-                     &gEfiPciRootBridgeIoProtocolGuid,\r
-                     &PrivateData->Io,\r
-                     NULL\r
-                     );\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      //\r
-      // Contruct DeviceIoProtocol\r
-      //\r
-      Status = DeviceIoConstructor (\r
-                 PrivateData->Handle,\r
-                 &PrivateData->Io,\r
-                 PrivateData->DevicePath,\r
-                 (UINT16)PrivateData->PrimaryBus,\r
-                 (UINT16)PrivateData->SubordinateBus\r
-                 );\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      //\r
-      // Scan this PCI Root Bridge for PCI Option ROMs and add them to the PCI Option ROM Table\r
-      //\r
-      Status = ScanPciRootBridgeForRoms(&PrivateData->Io);\r
-\r
-      //\r
-      // Increment the index for the next PCI Root Bridge\r
-      //\r
-      PciRootBridgeIndex++;\r
-\r
-    } else {\r
-\r
-      //\r
-      // If no PCI Root Bridges were found on the current PCI segment, then exit\r
-      //\r
-      if (NumberOfPciRootBridges == 0) {\r
-        Status = EFI_SUCCESS;\r
-        goto Done;\r
-      }\r
-\r
-    }\r
-\r
-    //\r
-    // If the PrimaryBusIndex is greater than the maximum allowable PCI bus number, then\r
-    // the PCI Segment Number is incremented, and the next segment is searched starting at Bus #0\r
-    // Otherwise, the search is continued on the next PCI Root Bridge\r
-    //\r
-    if (PrimaryBusIndex > PCI_MAX_BUS) {\r
-      PciSegmentIndex++;\r
-      NumberOfPciRootBridges = 0;\r
-      PrimaryBusIndex = 0;\r
-    } else {\r
-      NumberOfPciRootBridges++;\r
-    }\r
-\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-Done:\r
-  //\r
-  // Clean up memory allocated for the PCI Root Bridge that was searched but not created.\r
-  //\r
-  if (PrivateData) {\r
-    if (PrivateData->DevicePath) {\r
-      gBS->FreePool(PrivateData->DevicePath);\r
-    }\r
-    gBS->FreePool (PrivateData);\r
-  }\r
-\r
-  //\r
-  // If no PCI Root Bridges were discovered, then return the error condition from scanning the\r
-  // first PCI Root Bridge\r
-  //\r
-  if (PciRootBridgeIndex == 0) {\r
-    return Status;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS \r
-ConstructConfiguration(\r
-  IN OUT PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
\r
-{\r
-  EFI_STATUS                         Status;\r
-  UINT8                              NumConfig;\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *Configuration;\r
-  EFI_ACPI_END_TAG_DESCRIPTOR        *ConfigurationEnd;\r
-\r
-  NumConfig = 0;\r
-  PrivateData->Configuration = NULL;\r
-\r
-  if (PrivateData->SubordinateBus >= PrivateData->PrimaryBus) {\r
-    NumConfig++;\r
-  }\r
-  if (PrivateData->IoLimit >= PrivateData->IoBase) {\r
-    NumConfig++;\r
-  }\r
-  if (PrivateData->Mem32Limit >= PrivateData->Mem32Base) {\r
-    NumConfig++;\r
-  }\r
-  if (PrivateData->Pmem32Limit >= PrivateData->Pmem32Base) {\r
-    NumConfig++;\r
-  }\r
-  if (PrivateData->Mem64Limit >= PrivateData->Mem64Base) {\r
-    NumConfig++;\r
-  }\r
-  if (PrivateData->Pmem64Limit >= PrivateData->Pmem64Base) {\r
-    NumConfig++;\r
-  }\r
-\r
-  if ( NumConfig == 0 ) {\r
-\r
-    //\r
-    // If there is no resource request\r
-    //\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData, \r
-                    sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR),\r
-                    (VOID **)&PrivateData->Configuration\r
-                    );\r
-    if (EFI_ERROR (Status )) {\r
-      return Status;\r
-    }\r
-\r
-    Configuration = PrivateData->Configuration;\r
-    \r
-    ZeroMem (\r
-      Configuration, \r
-      sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR) \r
-      );\r
-    \r
-    Configuration->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len  = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration++;\r
-\r
-    ConfigurationEnd       = (EFI_ACPI_END_TAG_DESCRIPTOR *)(Configuration);\r
-    ConfigurationEnd->Desc = ACPI_END_TAG_DESCRIPTOR;\r
-    ConfigurationEnd->Checksum = 0;\r
-  }\r
-\r
-  //\r
-  // If there is at least one type of resource request,\r
-  // allocate a acpi resource node \r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData, \r
-                  sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * NumConfig + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR),\r
-                  (VOID **)&PrivateData->Configuration\r
-                  );\r
-  if (EFI_ERROR (Status )) {\r
-    return Status;\r
-  }\r
-  \r
-  Configuration = PrivateData->Configuration;\r
-\r
-  ZeroMem (\r
-    Configuration, \r
-    sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * NumConfig + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)\r
-    );\r
-\r
-  if (PrivateData->SubordinateBus >= PrivateData->PrimaryBus) {\r
-    Configuration->Desc         = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len          = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration->ResType      = ACPI_ADDRESS_SPACE_TYPE_BUS;\r
-    Configuration->SpecificFlag = 0; \r
-    Configuration->AddrRangeMin = PrivateData->PrimaryBus;\r
-    Configuration->AddrRangeMax = PrivateData->SubordinateBus;\r
-    Configuration->AddrLen      = Configuration->AddrRangeMax - Configuration->AddrRangeMin + 1;\r
-    Configuration++;\r
-  }\r
-  //\r
-  // Deal with io aperture\r
-  //\r
-  if (PrivateData->IoLimit >= PrivateData->IoBase) {\r
-    Configuration->Desc         = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len          = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration->ResType      = ACPI_ADDRESS_SPACE_TYPE_IO;\r
-    Configuration->SpecificFlag = 1; //non ISA range\r
-    Configuration->AddrRangeMin = PrivateData->IoBase;\r
-    Configuration->AddrRangeMax = PrivateData->IoLimit;\r
-    Configuration->AddrLen      = Configuration->AddrRangeMax - Configuration->AddrRangeMin + 1;\r
-    Configuration++;\r
-  }\r
-\r
-  //\r
-  // Deal with mem32 aperture\r
-  //\r
-  if (PrivateData->Mem32Limit >= PrivateData->Mem32Base) {\r
-    Configuration->Desc                 = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len                  = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration->ResType              = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-    Configuration->SpecificFlag         = 0; //Nonprefechable\r
-    Configuration->AddrSpaceGranularity = 32; //32 bit\r
-    Configuration->AddrRangeMin         = PrivateData->Mem32Base;\r
-    Configuration->AddrRangeMax         = PrivateData->Mem32Limit;\r
-    Configuration->AddrLen              = Configuration->AddrRangeMax - Configuration->AddrRangeMin + 1;\r
-    Configuration++;\r
-  } \r
-\r
-  //\r
-  // Deal with Pmem32 aperture\r
-  //\r
-  if (PrivateData->Pmem32Limit >= PrivateData->Pmem32Base) {\r
-    Configuration->Desc                 = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len                  = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration->ResType              = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-    Configuration->SpecificFlag         = 0x6; //prefechable\r
-    Configuration->AddrSpaceGranularity = 32; //32 bit\r
-    Configuration->AddrRangeMin         = PrivateData->Pmem32Base;\r
-    Configuration->AddrRangeMax         = PrivateData->Pmem32Limit;\r
-    Configuration->AddrLen              = Configuration->AddrRangeMax - Configuration->AddrRangeMin + 1;\r
-    Configuration++;\r
-  }\r
-\r
-  //\r
-  // Deal with mem64 aperture\r
-  //\r
-  if (PrivateData->Mem64Limit >= PrivateData->Mem64Base) {\r
-    Configuration->Desc                 = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len                  = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration->ResType              = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-    Configuration->SpecificFlag         = 0; //nonprefechable\r
-    Configuration->AddrSpaceGranularity = 64; //32 bit\r
-    Configuration->AddrRangeMin         = PrivateData->Mem64Base;\r
-    Configuration->AddrRangeMax         = PrivateData->Mem64Limit;\r
-    Configuration->AddrLen              = Configuration->AddrRangeMax - Configuration->AddrRangeMin + 1;\r
-    Configuration++;\r
-  }\r
-\r
-  //\r
-  // Deal with Pmem64 aperture\r
-  //\r
-  if (PrivateData->Pmem64Limit >= PrivateData->Pmem64Base) {\r
-    Configuration->Desc                 = ACPI_ADDRESS_SPACE_DESCRIPTOR;\r
-    Configuration->Len                  = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);\r
-    Configuration->ResType              = ACPI_ADDRESS_SPACE_TYPE_MEM;\r
-    Configuration->SpecificFlag         = 0x06; //prefechable\r
-    Configuration->AddrSpaceGranularity = 64; //32 bit\r
-    Configuration->AddrRangeMin         = PrivateData->Pmem64Base;\r
-    Configuration->AddrRangeMax         = PrivateData->Pmem64Limit;\r
-    Configuration->AddrLen              = Configuration->AddrRangeMax - Configuration->AddrRangeMin + 1;\r
-    Configuration++;\r
-  }\r
-\r
-  //\r
-  // put the checksum\r
-  //\r
-  ConfigurationEnd           = (EFI_ACPI_END_TAG_DESCRIPTOR *)(Configuration);\r
-  ConfigurationEnd->Desc     = ACPI_END_TAG_DESCRIPTOR;\r
-  ConfigurationEnd->Checksum = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS \r
-PcatPciRootBridgeBarExisted (\r
-  IN  PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData,\r
-  IN  UINT64                         Address,\r
-  OUT UINT32                         *OriginalValue,\r
-  OUT UINT32                         *Value\r
-  ) \r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT32      AllOnes;\r
-  EFI_TPL     OldTpl;\r
-\r
-  //\r
-  // Preserve the original value\r
-  //\r
-  Status = PrivateData->Io.Pci.Read (\r
-                                 &PrivateData->Io, \r
-                                 EfiPciWidthUint32, \r
-                                 Address, \r
-                                 1, \r
-                                 OriginalValue\r
-                                 );\r
-\r
-  //\r
-  // Raise TPL to high level to disable timer interrupt while the BAR is probed\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  AllOnes = 0xffffffff;\r
-\r
-  Status = PrivateData->Io.Pci.Write (\r
-                                 &PrivateData->Io, \r
-                                 EfiPciWidthUint32, \r
-                                 Address, \r
-                                 1, \r
-                                 &AllOnes\r
-                                 );\r
-  Status = PrivateData->Io.Pci.Read (\r
-                                 &PrivateData->Io, \r
-                                 EfiPciWidthUint32, \r
-                                 Address, \r
-                                 1, \r
-                                 Value\r
-                                 );\r
-\r
-  //\r
-  //Write back the original value\r
-  //\r
-  Status = PrivateData->Io.Pci.Write (\r
-                                 &PrivateData->Io, \r
-                                 EfiPciWidthUint32, \r
-                                 Address, \r
-                                 1, \r
-                                 OriginalValue\r
-                                 );\r
-\r
-  //\r
-  // Restore TPL to its original level\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  if ( *Value == 0 ) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-PcatPciRootBridgeParseBars (\r
-  IN PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData,\r
-  IN UINT16                         Command,\r
-  IN UINTN                          Bus,\r
-  IN UINTN                          Device,\r
-  IN UINTN                          Function\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT64      Address;\r
-  UINT32      OriginalValue;\r
-  UINT32      Value;\r
-  UINT32      OriginalUpperValue;\r
-  UINT32      UpperValue;\r
-  UINT64      Mask;\r
-  UINTN       Offset;\r
-  UINT64      Base;\r
-  UINT64      Length;\r
-  UINT64      Limit;\r
-\r
-  for (Offset = 0x10; Offset < 0x28; Offset += 4) {\r
-    Address = EFI_PCI_ADDRESS (Bus, Device, Function, Offset);\r
-    Status = PcatPciRootBridgeBarExisted (\r
-               PrivateData,\r
-               Address,\r
-               &OriginalValue,\r
-               &Value\r
-               );\r
-\r
-    if (!EFI_ERROR (Status )) {\r
-      if ( Value & 0x01 ) { \r
-        if (Command & 0x0001) {\r
-          //\r
-          //Device I/Os\r
-          //\r
-          Mask = 0xfffffffc;\r
-          Base = OriginalValue & Mask;\r
-          Length = ((~(Value & Mask)) & Mask) + 0x04;\r
-          if (!(Value & 0xFFFF0000)){\r
-            Length &= 0x0000FFFF;\r
-          }\r
-          Limit = Base + Length - 1;\r
-\r
-          if (Base < Limit) {\r
-            if (PrivateData->IoBase > Base) {\r
-              PrivateData->IoBase = (UINT32)Base;\r
-            }\r
-            if (PrivateData->IoLimit < Limit) {\r
-              PrivateData->IoLimit = (UINT32)Limit;\r
-            }\r
-          }\r
-        }\r
-   \r
-      } else {\r
-\r
-        if (Command & 0x0002) {\r
-\r
-          Mask = 0xfffffff0;\r
-          Base = OriginalValue & Mask;\r
-          Length = Value & Mask;\r
\r
-          if ((Value & 0x07) != 0x04) {\r
-            Length = ((~Length) + 1) & 0xffffffff;\r
-          } else {\r
-            Offset += 4; \r
-            Address = EFI_PCI_ADDRESS (Bus, Device, Function, Offset);\r
-\r
-            Status = PcatPciRootBridgeBarExisted (\r
-                       PrivateData,\r
-                       Address,\r
-                       &OriginalUpperValue,\r
-                       &UpperValue\r
-                       );\r
-\r
-            Base   = Base | LShiftU64((UINT64)OriginalUpperValue,32);\r
-            Length = Length | LShiftU64((UINT64)UpperValue,32);\r
-            Length = (~Length) + 1;\r
-          }\r
-\r
-          Limit = Base + Length - 1;\r
-\r
-          if (Base < Limit) {\r
-            if (PrivateData->MemBase > Base) {\r
-              PrivateData->MemBase = Base;\r
-            }\r
-            if (PrivateData->MemLimit < Limit) {\r
-              PrivateData->MemLimit = Limit;\r
-            }\r
-\r
-            switch (Value &0x07) {\r
-            case 0x00: ////memory space; anywhere in 32 bit address space\r
-              if (Value & 0x08) {\r
-                if (PrivateData->Pmem32Base > Base) {\r
-                  PrivateData->Pmem32Base = Base;\r
-                }\r
-                if (PrivateData->Pmem32Limit < Limit) {\r
-                  PrivateData->Pmem32Limit = Limit;\r
-                }\r
-              } else {\r
-                if (PrivateData->Mem32Base > Base) {\r
-                  PrivateData->Mem32Base = Base;\r
-                }\r
-                if (PrivateData->Mem32Limit < Limit) {\r
-                  PrivateData->Mem32Limit = Limit;\r
-                }\r
-              }\r
-              break;\r
-            case 0x04: //memory space; anywhere in 64 bit address space\r
-              if (Value & 0x08) {\r
-                if (PrivateData->Pmem64Base > Base) {\r
-                  PrivateData->Pmem64Base = Base;\r
-                }\r
-                if (PrivateData->Pmem64Limit < Limit) {\r
-                  PrivateData->Pmem64Limit = Limit;\r
-                }\r
-              } else {\r
-                if (PrivateData->Mem64Base > Base) {\r
-                  PrivateData->Mem64Base = Base;\r
-                }\r
-                if (PrivateData->Mem64Limit < Limit) {\r
-                  PrivateData->Mem64Limit = Limit;\r
-                }\r
-              }\r
-              break;\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINT64\r
-GetPciExpressBaseAddressForRootBridge (\r
-  IN UINTN    HostBridgeNumber,\r
-  IN UINTN    RootBridgeNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This routine is to get PciExpress Base Address for this RootBridge\r
-\r
-Arguments:\r
-  HostBridgeNumber - The number of HostBridge\r
-  RootBridgeNumber - The number of RootBridge\r
-    \r
-Returns:\r
-  UINT64 - PciExpressBaseAddress for this HostBridge and RootBridge\r
-\r
---*/\r
-{\r
-  EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION *PciExpressBaseAddressInfo;\r
-  UINTN                                    BufferSize;\r
-  UINT32                                   Index;\r
-  UINT32                                   Number;\r
-  EFI_PEI_HOB_POINTERS                     GuidHob;\r
-\r
-  //\r
-  // Get PciExpressAddressInfo Hob\r
-  //\r
-  PciExpressBaseAddressInfo = NULL;\r
-  BufferSize                = 0;\r
-  GuidHob.Raw = GetFirstGuidHob (&gEfiPciExpressBaseAddressGuid);\r
-  if (GuidHob.Raw != NULL) {\r
-    PciExpressBaseAddressInfo = GET_GUID_HOB_DATA (GuidHob.Guid);\r
-    BufferSize                = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);\r
-  } else {\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Search the PciExpress Base Address in the Hob for current RootBridge\r
-  //\r
-  Number = (UINT32)(BufferSize / sizeof(EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION));\r
-  for (Index = 0; Index < Number; Index++) {\r
-    if ((PciExpressBaseAddressInfo[Index].HostBridgeNumber == HostBridgeNumber) &&\r
-        (PciExpressBaseAddressInfo[Index].RootBridgeNumber == RootBridgeNumber)) {\r
-      return PciExpressBaseAddressInfo[Index].PciExpressBaseAddress;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Do not find the PciExpress Base Address in the Hob\r
-  //\r
-  return 0;\r
-}\r
-\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridge.h b/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridge.h
deleted file mode 100644 (file)
index 0450fcf..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-  PcatPciRootBridge.h\r
-\r
-Abstract:\r
-\r
-  The driver for the host to pci bridge (root bridge).\r
-\r
---*/\r
-\r
-#ifndef _PCAT_PCI_ROOT_BRIDGE_H_\r
-#define _PCAT_PCI_ROOT_BRIDGE_H_\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/PciRootBridgeIo.h>\r
-#include <Protocol/DeviceIo.h>\r
-#include <Protocol/CpuIo2.h>\r
-\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/HobLib.h>\r
-\r
-#include <Guid/PciOptionRomTable.h>\r
-#include <Guid/HobList.h>\r
-#include <Guid/PciExpressBaseAddress.h>\r
-\r
-#include <IndustryStandard/Acpi.h>\r
-#include <IndustryStandard/Pci.h>\r
-\r
-#define PCI_MAX_SEGMENT   0\r
-//\r
-// Driver Instance Data Prototypes\r
-//\r
-#define PCAT_PCI_ROOT_BRIDGE_SIGNATURE  SIGNATURE_32('p', 'c', 'r', 'b')\r
-\r
-typedef struct {\r
-  UINT32                            Signature;\r
-  EFI_HANDLE                        Handle;\r
-                                    \r
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL   Io;\r
-  EFI_CPU_IO2_PROTOCOL              *CpuIo;\r
-\r
-  UINT32                            RootBridgeNumber;\r
-  UINT32                            PrimaryBus;\r
-  UINT32                            SubordinateBus;\r
-                                     \r
-  UINT64                            MemBase;     // Offsets host to bus memory addr.\r
-  UINT64                            MemLimit;    // Max allowable memory access\r
-                                    \r
-  UINT64                            IoBase;      // Offsets host to bus io addr.\r
-  UINT64                            IoLimit;     // Max allowable io access\r
-                                    \r
-  UINT64                            PciAddress;\r
-  UINT64                            PciData;\r
-                                    \r
-  UINT64                            PhysicalMemoryBase;\r
-  UINT64                            PhysicalIoBase;\r
-                                     \r
-  EFI_LOCK                          PciLock;\r
-                                    \r
-  UINT64                            Attributes;\r
-                                    \r
-  UINT64                            Mem32Base;\r
-  UINT64                            Mem32Limit;\r
-  UINT64                            Pmem32Base;\r
-  UINT64                            Pmem32Limit;\r
-  UINT64                            Mem64Base;\r
-  UINT64                            Mem64Limit;\r
-  UINT64                            Pmem64Base;\r
-  UINT64                            Pmem64Limit;\r
-\r
-  UINT64                            PciExpressBaseAddress;\r
-\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Configuration;\r
-\r
-  LIST_ENTRY                    MapInfo;\r
-} PCAT_PCI_ROOT_BRIDGE_INSTANCE;\r
-\r
-//\r
-// Driver Instance Data Macros\r
-//\r
-#define DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) \\r
-  CR(a, PCAT_PCI_ROOT_BRIDGE_INSTANCE, Io, PCAT_PCI_ROOT_BRIDGE_SIGNATURE)\r
-\r
-//\r
-// Private data types\r
-//\r
-typedef union {\r
-  UINT8   volatile  *buf;\r
-  UINT8   volatile  *ui8;\r
-  UINT16  volatile  *ui16;\r
-  UINT32  volatile  *ui32;\r
-  UINT64  volatile  *ui64;\r
-  UINTN   volatile  ui;\r
-} PTR;\r
-\r
-typedef struct {\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION  Operation;\r
-  UINTN                                      NumberOfBytes;\r
-  UINTN                                      NumberOfPages;\r
-  EFI_PHYSICAL_ADDRESS                       HostAddress;\r
-  EFI_PHYSICAL_ADDRESS                       MappedHostAddress;\r
-} MAP_INFO;\r
-\r
-typedef struct {\r
-  LIST_ENTRY Link;\r
-  MAP_INFO * Map;  \r
-} MAP_INFO_INSTANCE;\r
-\r
-typedef\r
-VOID\r
-(*EFI_PCI_BUS_SCAN_CALLBACK) (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *Context\r
-  );\r
-\r
-typedef struct {\r
-  UINT16                    *CommandRegisterBuffer;\r
-  UINT32                    PpbMemoryWindow;     \r
-} PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT;\r
-\r
-typedef struct {\r
-  UINT8 Register;\r
-  UINT8 Function;\r
-  UINT8 Device;\r
-  UINT8 Bus;\r
-  UINT8 Reserved[4];\r
-} DEFIO_PCI_ADDR;\r
-\r
-//\r
-// Driver Protocol Constructor Prototypes\r
-//\r
-EFI_STATUS \r
-ConstructConfiguration(\r
-  IN OUT PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData\r
-  );\r
-\r
-EFI_STATUS\r
-PcatPciRootBridgeParseBars (\r
-  IN PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData,\r
-  IN UINT16                         Command,\r
-  IN UINTN                          Bus,\r
-  IN UINTN                          Device,\r
-  IN UINTN                          Function\r
-  );\r
-\r
-EFI_STATUS\r
-ScanPciRootBridgeForRoms(\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev\r
-  );\r
-\r
-EFI_STATUS\r
-PcatRootBridgeDevicePathConstructor (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  **Protocol,\r
-  IN UINTN                     RootBridgeNumber,\r
-  IN BOOLEAN                   IsPciExpress\r
-  );\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoConstructor (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *Protocol,\r
-  IN UINTN                            SegmentNumber\r
-  );\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoGetIoPortMapping (\r
-  OUT EFI_PHYSICAL_ADDRESS  *IoPortMapping,\r
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryPortMapping\r
-  );\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoPciRW (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN BOOLEAN                                Write,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 UserAddress,\r
-  IN UINTN                                  Count,\r
-  IN OUT VOID                               *UserBuffer\r
-  );\r
-\r
-UINT64\r
-GetPciExpressBaseAddressForRootBridge (\r
-  IN UINTN    HostBridgeNumber,\r
-  IN UINTN    RootBridgeNumber\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_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
-PcatRootBridgeIoIoWrite (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 UserAddress,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *UserBuffer\r
-  );\r
-\r
-//\r
-// Driver entry point prototype\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-InitializePcatPciRootBridge (\r
-  IN EFI_HANDLE       ImageHandle,\r
-  IN EFI_SYSTEM_TABLE *SystemTable\r
-  );\r
-\r
-extern EFI_CPU_IO2_PROTOCOL  *gCpuIo;\r
-\r
-#endif\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeDevicePath.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeDevicePath.c
deleted file mode 100644 (file)
index 05891ea..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-    PcatPciRootBridgeDevicePath.c\r
-    \r
-Abstract:\r
-\r
-    EFI PCAT PCI Root Bridge Device Path Protocol\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PcatPciRootBridge.h"\r
-\r
-//\r
-// Static device path declarations for this driver.\r
-//\r
-\r
-typedef struct {\r
-  ACPI_HID_DEVICE_PATH              AcpiDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL          EndDevicePath;\r
-} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;\r
-\r
-EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {\r
-  {\r
-    {\r
-      ACPI_DEVICE_PATH,\r
-      ACPI_DP,\r
-      {\r
-        (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),\r
-        (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8),\r
-      }\r
-    },\r
-    EISA_PNP_ID(0x0A03),\r
-    0\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      END_DEVICE_PATH_LENGTH,\r
-      0\r
-    }\r
-  }\r
-};\r
-\r
-EFI_STATUS\r
-PcatRootBridgeDevicePathConstructor (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  **Protocol,\r
-  IN UINTN                     RootBridgeNumber,\r
-  IN BOOLEAN                   IsPciExpress\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Construct the device path protocol\r
-\r
-Arguments:\r
-\r
-    Protocol - protocol to initialize\r
-    \r
-Returns:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-  ACPI_HID_DEVICE_PATH  *AcpiDevicePath;\r
\r
-  *Protocol = DuplicateDevicePath((EFI_DEVICE_PATH_PROTOCOL *)(&mEfiPciRootBridgeDevicePath));\r
-\r
-  AcpiDevicePath = (ACPI_HID_DEVICE_PATH *)(*Protocol);\r
\r
-  AcpiDevicePath->UID = (UINT32)RootBridgeNumber;\r
-\r
-  if (IsPciExpress) {\r
-    AcpiDevicePath->HID = EISA_PNP_ID(0x0A08);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeIo.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeIo.c
deleted file mode 100644 (file)
index d5d79ae..0000000
+++ /dev/null
@@ -1,1036 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-    PcatPciRootBridgeIo.c\r
-    \r
-Abstract:\r
-\r
-    EFI PC AT PCI Root Bridge Io Protocol\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PcatPciRootBridge.h"\r
-\r
-//\r
-// Protocol Member Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPollMem ( \r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                                 Address,\r
-  IN  UINT64                                 Mask,\r
-  IN  UINT64                                 Value,\r
-  IN  UINT64                                 Delay,\r
-  OUT UINT64                                 *Result\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPollIo ( \r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                                 Address,\r
-  IN  UINT64                                 Mask,\r
-  IN  UINT64                                 Value,\r
-  IN  UINT64                                 Delay,\r
-  OUT UINT64                                 *Result\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoMemRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_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
-PcatRootBridgeIoMemWrite (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_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
-PcatRootBridgeIoCopyMem (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 DestAddress,\r
-  IN UINT64                                 SrcAddress,\r
-  IN UINTN                                  Count\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPciRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_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
-PcatRootBridgeIoPciWrite (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_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
-PcatRootBridgeIoMap (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL            *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     VOID                                       *HostAddress,\r
-  IN OUT UINTN                                      *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS                       *DeviceAddress,\r
-  OUT    VOID                                       **Mapping\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoUnmap (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN VOID                             *Mapping\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoAllocateBuffer (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE                Type,\r
-  IN  EFI_MEMORY_TYPE                  MemoryType,\r
-  IN  UINTN                            Pages,\r
-  OUT VOID                             **HostAddress,\r
-  IN  UINT64                           Attributes\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoFreeBuffer (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN  UINTN                            Pages,\r
-  OUT VOID                             *HostAddress\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoFlush (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoGetAttributes (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  OUT UINT64                           *Supported,\r
-  OUT UINT64                           *Attributes\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoSetAttributes (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN     UINT64                           Attributes,\r
-  IN OUT UINT64                           *ResourceBase,\r
-  IN OUT UINT64                           *ResourceLength \r
-  ); \r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoConfiguration (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  OUT VOID                             **Resources\r
-  );\r
-\r
-//\r
-// Private Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoMemRW (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINTN                                  Count,\r
-  IN  BOOLEAN                                InStrideFlag,\r
-  IN  PTR                                    In,\r
-  IN  BOOLEAN                                OutStrideFlag,\r
-  OUT PTR                                    Out\r
-  );\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoConstructor (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *Protocol,\r
-  IN UINTN                            SegmentNumber\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Contruct the Pci Root Bridge Io protocol\r
-\r
-Arguments:\r
-\r
-    Protocol - protocol to initialize\r
-    \r
-Returns:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-  Protocol->ParentHandle   = NULL;\r
-\r
-  Protocol->PollMem        = PcatRootBridgeIoPollMem;\r
-  Protocol->PollIo         = PcatRootBridgeIoPollIo;\r
-\r
-  Protocol->Mem.Read       = PcatRootBridgeIoMemRead;\r
-  Protocol->Mem.Write      = PcatRootBridgeIoMemWrite;\r
-\r
-  Protocol->Io.Read        = PcatRootBridgeIoIoRead;\r
-  Protocol->Io.Write       = PcatRootBridgeIoIoWrite;\r
-\r
-  Protocol->CopyMem        = PcatRootBridgeIoCopyMem;\r
-\r
-  Protocol->Pci.Read       = PcatRootBridgeIoPciRead;\r
-  Protocol->Pci.Write      = PcatRootBridgeIoPciWrite;\r
-\r
-  Protocol->Map            = PcatRootBridgeIoMap;\r
-  Protocol->Unmap          = PcatRootBridgeIoUnmap;\r
-\r
-  Protocol->AllocateBuffer = PcatRootBridgeIoAllocateBuffer;\r
-  Protocol->FreeBuffer     = PcatRootBridgeIoFreeBuffer;\r
-\r
-  Protocol->Flush          = PcatRootBridgeIoFlush;\r
-\r
-  Protocol->GetAttributes  = PcatRootBridgeIoGetAttributes;\r
-  Protocol->SetAttributes  = PcatRootBridgeIoSetAttributes;\r
-\r
-  Protocol->Configuration  = PcatRootBridgeIoConfiguration;\r
-\r
-  Protocol->SegmentNumber  = (UINT32)SegmentNumber;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPollMem ( \r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                                 Address,\r
-  IN  UINT64                                 Mask,\r
-  IN  UINT64                                 Value,\r
-  IN  UINT64                                 Delay,\r
-  OUT UINT64                                 *Result\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT64      NumberOfTicks;\r
-  UINT32      Remainder;\r
-\r
-  if (Result == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-\r
-  if ((UINT32)Width > EfiPciWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // No matter what, always do a single poll.\r
-  //\r
-  Status = This->Mem.Read (This, Width, Address, 1, Result);\r
-  if ( EFI_ERROR(Status) ) {\r
-    return Status;\r
-  }    \r
-  if ( (*Result & Mask) == Value ) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Delay == 0) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-\r
-    NumberOfTicks = DivU64x32Remainder (Delay, 100, &Remainder);\r
-    if ( Remainder !=0 ) {\r
-      NumberOfTicks += 1;\r
-    }\r
-    NumberOfTicks += 1;\r
-  \r
-    while ( NumberOfTicks ) {\r
-\r
-      gBS->Stall (10);\r
-\r
-      Status = This->Mem.Read (This, Width, Address, 1, Result);\r
-      if ( EFI_ERROR(Status) ) {\r
-        return Status;\r
-      }\r
-    \r
-      if ( (*Result & Mask) == Value ) {\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      NumberOfTicks -= 1;\r
-    }\r
-  }\r
-  return EFI_TIMEOUT;\r
-}\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPollIo ( \r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                                 Address,\r
-  IN  UINT64                                 Mask,\r
-  IN  UINT64                                 Value,\r
-  IN  UINT64                                 Delay,\r
-  OUT UINT64                                 *Result\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT64      NumberOfTicks;\r
-  UINT32       Remainder;\r
-\r
-  if (Result == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((UINT32)Width > EfiPciWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // No matter what, always do a single poll.\r
-  //\r
-  Status = This->Io.Read (This, Width, Address, 1, Result);\r
-  if ( EFI_ERROR(Status) ) {\r
-    return Status;\r
-  }    \r
-  if ( (*Result & Mask) == Value ) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Delay == 0) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-\r
-    NumberOfTicks = DivU64x32Remainder (Delay, 100, &Remainder);\r
-    if ( Remainder !=0 ) {\r
-      NumberOfTicks += 1;\r
-    }\r
-    NumberOfTicks += 1;\r
-  \r
-    while ( NumberOfTicks ) {\r
-\r
-      gBS->Stall(10);\r
-    \r
-      Status = This->Io.Read (This, Width, Address, 1, Result);\r
-      if ( EFI_ERROR(Status) ) {\r
-        return Status;\r
-      }\r
-    \r
-      if ( (*Result & Mask) == Value ) {\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      NumberOfTicks -= 1;\r
-    }\r
-  }\r
-  return EFI_TIMEOUT;\r
-}\r
-\r
-BOOLEAN\r
-PcatRootBridgeMemAddressValid (\r
-  IN PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData,\r
-  IN UINT64                         Address\r
-  )\r
-{\r
-  if ((Address >= PrivateData->PciExpressBaseAddress) && (Address < PrivateData->PciExpressBaseAddress + 0x10000000)) {\r
-    return TRUE;\r
-  }\r
-  if ((Address >= PrivateData->MemBase) && (Address < PrivateData->MemLimit)) {\r
-    return TRUE;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoMemRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 Address,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *Buffer\r
-  )\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE  *PrivateData;\r
-  UINTN                          AlignMask;\r
-  PTR                            In;\r
-  PTR                            Out;\r
-\r
-  if ( Buffer == NULL ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  if (!PcatRootBridgeMemAddressValid (PrivateData, Address)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  AlignMask = (1 << (Width & 0x03)) - 1;\r
-  if (Address & AlignMask) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Address += PrivateData->PhysicalMemoryBase;\r
-\r
-  In.buf  = Buffer;\r
-  Out.buf = (VOID *)(UINTN) Address;\r
-  if ((UINT32)Width <= EfiPciWidthUint64) {\r
-    return PcatRootBridgeIoMemRW (Width, Count, TRUE, In, TRUE, Out);\r
-  }\r
-  if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {\r
-    return PcatRootBridgeIoMemRW (Width, Count, TRUE, In, FALSE, Out);\r
-  }\r
-  if (Width >= EfiPciWidthFillUint8 && Width <= EfiPciWidthFillUint64) {\r
-    return PcatRootBridgeIoMemRW (Width, Count, FALSE, In, TRUE, Out);\r
-  }\r
-\r
-  return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoMemWrite (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 Address,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *Buffer\r
-  )\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData;\r
-  UINTN  AlignMask;\r
-  PTR    In;\r
-  PTR    Out;\r
-\r
-  if ( Buffer == NULL ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  if (!PcatRootBridgeMemAddressValid (PrivateData, Address)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  AlignMask = (1 << (Width & 0x03)) - 1;\r
-  if (Address & AlignMask) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Address += PrivateData->PhysicalMemoryBase;\r
-\r
-  In.buf  = (VOID *)(UINTN) Address;\r
-  Out.buf = Buffer;\r
-  if ((UINT32)Width <= EfiPciWidthUint64) {\r
-    return PcatRootBridgeIoMemRW (Width, Count, TRUE, In, TRUE, Out);\r
-  }\r
-  if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {\r
-    return PcatRootBridgeIoMemRW (Width, Count, FALSE, In, TRUE, Out);\r
-  }\r
-  if (Width >= EfiPciWidthFillUint8 && Width <= EfiPciWidthFillUint64) {\r
-    return PcatRootBridgeIoMemRW (Width, Count, TRUE, In, FALSE, Out);\r
-  }\r
-\r
-  return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoCopyMem (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 DestAddress,\r
-  IN UINT64                                 SrcAddress,\r
-  IN UINTN                                  Count\r
-  )\r
-\r
-{\r
-  EFI_STATUS  Status;\r
-  BOOLEAN     Direction;\r
-  UINTN       Stride;\r
-  UINTN       Index;\r
-  UINT64      Result;\r
-\r
-  if ((UINT32)Width > EfiPciWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }       \r
-\r
-  if (DestAddress == SrcAddress) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Stride = (UINTN)1 << Width;\r
-\r
-  Direction = TRUE;\r
-  if ((DestAddress > SrcAddress) && (DestAddress < (SrcAddress + Count * Stride))) {\r
-    Direction   = FALSE;\r
-    SrcAddress  = SrcAddress  + (Count-1) * Stride;\r
-    DestAddress = DestAddress + (Count-1) * Stride;\r
-  }\r
-\r
-  for (Index = 0;Index < Count;Index++) {\r
-    Status = PcatRootBridgeIoMemRead (\r
-               This,\r
-               Width,\r
-               SrcAddress,\r
-               1,\r
-               &Result\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    Status = PcatRootBridgeIoMemWrite (\r
-               This,\r
-               Width,\r
-               DestAddress,\r
-               1,\r
-               &Result\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    if (Direction) {\r
-      SrcAddress  += Stride;\r
-      DestAddress += Stride;\r
-    } else {\r
-      SrcAddress  -= Stride;\r
-      DestAddress -= Stride;\r
-    }\r
-  }\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPciRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 Address,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *Buffer\r
-  )\r
-{\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return PcatRootBridgeIoPciRW (This, FALSE, Width, Address, Count, Buffer);\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoPciWrite (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 Address,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *Buffer\r
-  )\r
-{\r
-  if (Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  return PcatRootBridgeIoPciRW (This, TRUE, Width, Address, Count, Buffer);\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoMap (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL            *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION  Operation,\r
-  IN     VOID                                       *HostAddress,\r
-  IN OUT UINTN                                      *NumberOfBytes,\r
-  OUT    EFI_PHYSICAL_ADDRESS                       *DeviceAddress,\r
-  OUT    VOID                                       **Mapping\r
-  )\r
-\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  MAP_INFO              *MapInfo;\r
-  MAP_INFO_INSTANCE    *MapInstance;\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData;\r
-\r
-  if ( HostAddress == NULL || NumberOfBytes == NULL || \r
-       DeviceAddress == NULL || Mapping == NULL ) {\r
-    \r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Perform a fence operation to make sure all memory operations are flushed\r
-  //\r
-  MemoryFence();\r
-\r
-  //\r
-  // Initialize the return values to their defaults\r
-  //\r
-  *Mapping = NULL;\r
-\r
-  //\r
-  // Make sure that Operation is valid\r
-  //\r
-  if ((UINT32)Operation >= EfiPciOperationMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Most PCAT like chipsets can not handle performing DMA above 4GB.\r
-  // If any part of the DMA transfer being mapped is above 4GB, then\r
-  // map the DMA transfer to a buffer below 4GB.\r
-  //\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;\r
-  if ((PhysicalAddress + *NumberOfBytes) > 0x100000000ULL) {\r
-\r
-    //\r
-    // Common Buffer operations can not be remapped.  If the common buffer\r
-    // if above 4GB, then it is not possible to generate a mapping, so return \r
-    // an error.\r
-    //\r
-    if (Operation == EfiPciOperationBusMasterCommonBuffer || Operation == EfiPciOperationBusMasterCommonBuffer64) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    //\r
-    // Allocate a MAP_INFO structure to remember the mapping when Unmap() is\r
-    // called later.\r
-    //\r
-    Status = gBS->AllocatePool (\r
-                    EfiBootServicesData, \r
-                    sizeof(MAP_INFO), \r
-                    (VOID **)&MapInfo\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      *NumberOfBytes = 0;\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // Return a pointer to the MAP_INFO structure in Mapping\r
-    //\r
-    *Mapping = MapInfo;\r
-\r
-    //\r
-    // Initialize the MAP_INFO structure\r
-    //\r
-    MapInfo->Operation         = Operation;\r
-    MapInfo->NumberOfBytes     = *NumberOfBytes;\r
-    MapInfo->NumberOfPages     = EFI_SIZE_TO_PAGES(*NumberOfBytes);\r
-    MapInfo->HostAddress       = PhysicalAddress;\r
-    MapInfo->MappedHostAddress = 0x00000000ffffffff;\r
-\r
-    //\r
-    // Allocate a buffer below 4GB to map the transfer to.\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress, \r
-                    EfiBootServicesData, \r
-                    MapInfo->NumberOfPages,\r
-                    &MapInfo->MappedHostAddress\r
-                    );\r
-    if (EFI_ERROR(Status)) {\r
-      gBS->FreePool (MapInfo);\r
-      *NumberOfBytes = 0;\r
-      return Status;\r
-    }\r
-\r
-    //\r
-    // If this is a read operation from the Bus Master's point of view,\r
-    // then copy the contents of the real buffer into the mapped buffer\r
-    // so the Bus Master can read the contents of the real buffer.\r
-    //\r
-    if (Operation == EfiPciOperationBusMasterRead || Operation == EfiPciOperationBusMasterRead64) {\r
-      CopyMem (\r
-        (VOID *)(UINTN)MapInfo->MappedHostAddress, \r
-        (VOID *)(UINTN)MapInfo->HostAddress,\r
-        MapInfo->NumberOfBytes\r
-        );\r
-    }\r
-\r
-\r
-  Status =gBS->AllocatePool (\r
-                    EfiBootServicesData, \r
-                    sizeof(MAP_INFO_INSTANCE), \r
-                    (VOID **)&MapInstance\r
-                    );                    \r
-    if (EFI_ERROR(Status)) {\r
-      gBS->FreePages (MapInfo->MappedHostAddress,MapInfo->NumberOfPages);\r
-      gBS->FreePool (MapInfo);\r
-      *NumberOfBytes = 0;\r
-      return Status;\r
-    }\r
-\r
-    MapInstance->Map=MapInfo;\r
-    PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-    InsertTailList(&PrivateData->MapInfo,&MapInstance->Link);\r
-    \r
-  //\r
-    // The DeviceAddress is the address of the maped buffer below 4GB\r
-    //\r
-    *DeviceAddress = MapInfo->MappedHostAddress;\r
-  } else {\r
-    //\r
-    // The transfer is below 4GB, so the DeviceAddress is simply the HostAddress\r
-    //\r
-    *DeviceAddress = PhysicalAddress;\r
-  }\r
-\r
-  //\r
-  // Perform a fence operation to make sure all memory operations are flushed\r
-  //\r
-  MemoryFence();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoUnmap (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN VOID                             *Mapping\r
-  )\r
-\r
-{\r
-  MAP_INFO    *MapInfo;\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData;\r
-  LIST_ENTRY *Link;\r
-\r
-  //\r
-  // Perform a fence operation to make sure all memory operations are flushed\r
-  //\r
-  MemoryFence();\r
-\r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-  //\r
-  // See if the Map() operation associated with this Unmap() required a mapping buffer.\r
-  // If a mapping buffer was not required, then this function simply returns EFI_SUCCESS.\r
-  //\r
-  if (Mapping != NULL) {\r
-    //\r
-    // Get the MAP_INFO structure from Mapping\r
-    //\r
-    MapInfo = (MAP_INFO *)Mapping;\r
-\r
-  for (Link = PrivateData->MapInfo.ForwardLink; Link != &PrivateData->MapInfo; Link = Link->ForwardLink) {\r
-      if (((MAP_INFO_INSTANCE*)Link)->Map == MapInfo)\r
-        break;\r
-    }\r
-\r
-    if (Link == &PrivateData->MapInfo) {\r
-      return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-    RemoveEntryList(Link);\r
-    ((MAP_INFO_INSTANCE*)Link)->Map = NULL;\r
-    gBS->FreePool((MAP_INFO_INSTANCE*)Link);\r
-\r
-    //\r
-    // If this is a write operation from the Bus Master's point of view,\r
-    // then copy the contents of the mapped buffer into the real buffer\r
-    // so the processor can read the contents of the real buffer.\r
-    //\r
-    if (MapInfo->Operation == EfiPciOperationBusMasterWrite || MapInfo->Operation == EfiPciOperationBusMasterWrite64) {\r
-      CopyMem (\r
-        (VOID *)(UINTN)MapInfo->HostAddress, \r
-        (VOID *)(UINTN)MapInfo->MappedHostAddress,\r
-        MapInfo->NumberOfBytes\r
-        );\r
-    }\r
-\r
-    //\r
-    // Free the mapped buffer and the MAP_INFO structure.\r
-    //\r
-    gBS->FreePages (MapInfo->MappedHostAddress, MapInfo->NumberOfPages);\r
-    gBS->FreePool (Mapping);\r
-  }\r
-\r
-  //\r
-  // Perform a fence operation to make sure all memory operations are flushed\r
-  //\r
-  MemoryFence();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoAllocateBuffer (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN  EFI_ALLOCATE_TYPE                Type,\r
-  IN  EFI_MEMORY_TYPE                  MemoryType,\r
-  IN  UINTN                            Pages,\r
-  OUT VOID                             **HostAddress,\r
-  IN  UINT64                           Attributes\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-\r
-  //\r
-  // Validate Attributes\r
-  //\r
-  if (Attributes & EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Check for invalid inputs\r
-  //\r
-  if (HostAddress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData\r
-  //\r
-  if (MemoryType != EfiBootServicesData && MemoryType != EfiRuntimeServicesData) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Limit allocations to memory below 4GB\r
-  //\r
-  PhysicalAddress = (EFI_PHYSICAL_ADDRESS)(0xffffffff);\r
-\r
-  Status = gBS->AllocatePages (AllocateMaxAddress, MemoryType, Pages, &PhysicalAddress);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  *HostAddress = (VOID *)(UINTN)PhysicalAddress;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoFreeBuffer (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN  UINTN                            Pages,\r
-  OUT VOID                             *HostAddress\r
-  )\r
-\r
-{\r
-\r
-  if( HostAddress == NULL ){\r
-     return EFI_INVALID_PARAMETER;\r
-  } \r
-  return gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress, Pages);\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoFlush (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This\r
-  )\r
-\r
-{\r
-  //\r
-  // Perform a fence operation to make sure all memory operations are flushed\r
-  //\r
-  MemoryFence();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoGetAttributes (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  OUT UINT64                           *Supported,  OPTIONAL\r
-  OUT UINT64                           *Attributes\r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE *PrivateData;\r
-\r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  if (Attributes == NULL && Supported == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Supported is an OPTIONAL parameter.  See if it is NULL\r
-  //\r
-  if (Supported) {\r
-    //\r
-    // This is a generic driver for a PC-AT class system.  It does not have any\r
-    // chipset specific knowlegde, so none of the attributes can be set or \r
-    // cleared.  Any attempt to set attribute that are already set will succeed, \r
-    // and any attempt to set an attribute that is not supported will fail.\r
-    //\r
-    *Supported = PrivateData->Attributes;\r
-  }\r
-\r
-  //\r
-  // Set Attrbutes to the attributes detected when the PCI Root Bridge was initialized\r
-  //\r
-  \r
-  if (Attributes) {\r
-    *Attributes = PrivateData->Attributes;\r
-  }\r
-  \r
-   \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoSetAttributes (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  IN     UINT64                           Attributes,\r
-  IN OUT UINT64                           *ResourceBase,\r
-  IN OUT UINT64                           *ResourceLength \r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE   *PrivateData;\r
-  \r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  //\r
-  // This is a generic driver for a PC-AT class system.  It does not have any\r
-  // chipset specific knowlegde, so none of the attributes can be set or \r
-  // cleared.  Any attempt to set attribute that are already set will succeed, \r
-  // and any attempt to set an attribute that is not supported will fail.\r
-  //\r
-  if (Attributes & (~PrivateData->Attributes)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoConfiguration (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
-  OUT VOID                             **Resources\r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE   *PrivateData;\r
-  \r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  *Resources = PrivateData->Configuration;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Internal function\r
-//\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoMemRW (\r
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINTN                                  Count,\r
-  IN  BOOLEAN                                InStrideFlag,\r
-  IN  PTR                                    In,\r
-  IN  BOOLEAN                                OutStrideFlag,\r
-  OUT PTR                                    Out\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Private service to provide the memory read/write\r
-\r
-Arguments:\r
-\r
-  Width of the Memory Access\r
-  Count of the number of accesses to perform\r
-\r
-Returns:\r
-\r
-  Status\r
-\r
-  EFI_SUCCESS           - Successful transaction\r
-  EFI_INVALID_PARAMETER - Unsupported width and address combination\r
-\r
---*/\r
-{\r
-  UINTN  Stride;\r
-  UINTN  InStride;\r
-  UINTN  OutStride;\r
-\r
-\r
-  Width     = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
-  Stride    = (UINTN)1 << Width;\r
-  InStride  = InStrideFlag  ? Stride : 0;\r
-  OutStride = OutStrideFlag ? Stride : 0;\r
-\r
-  //\r
-  // Loop for each iteration and move the data\r
-  //\r
-  switch (Width) {\r
-  case EfiPciWidthUint8:\r
-    for (;Count > 0; Count--, In.buf += InStride, Out.buf += OutStride) {\r
-      MemoryFence();\r
-      *In.ui8 = *Out.ui8;\r
-      MemoryFence();\r
-    }\r
-    break;\r
-  case EfiPciWidthUint16:\r
-    for (;Count > 0; Count--, In.buf += InStride, Out.buf += OutStride) {\r
-      MemoryFence();\r
-      *In.ui16 = *Out.ui16;\r
-      MemoryFence();\r
-    }\r
-    break;\r
-  case EfiPciWidthUint32:\r
-    for (;Count > 0; Count--, In.buf += InStride, Out.buf += OutStride) {\r
-      MemoryFence();\r
-      *In.ui32 = *Out.ui32;\r
-      MemoryFence();\r
-    }\r
-    break;\r
-  default:\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf b/DuetPkg/PciRootBridgeNoEnumerationDxe/PciRootBridgeNoEnumeration.inf
deleted file mode 100644 (file)
index d8b2e6e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-## @file\r
-# \r
-# Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#  Abstract:\r
-#\r
-##\r
-\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PcatPciRootBridge\r
-  FILE_GUID                      = 0F7EC77A-1EE1-400f-A99D-7CBD1FEB181E\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializePcatPciRootBridge\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  DuetPkg/DuetPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  DebugLib\r
-  BaseMemoryLib\r
-  DevicePathLib\r
-  HobLib\r
-\r
-[Sources]\r
-  PcatPciRootBridge.h\r
-  PcatPciRootBridge.c\r
-  PcatPciRootBridgeDevicePath.c\r
-  PcatPciRootBridgeIo.c\r
-  DeviceIo.h\r
-  DeviceIo.c\r
-\r
-[Sources.ia32]\r
-  Ia32/PcatIo.c\r
-  \r
-[Sources.x64]\r
-  X64/PcatIo.c\r
-\r
-[Protocols]\r
-  gEfiPciRootBridgeIoProtocolGuid\r
-  gEfiDeviceIoProtocolGuid\r
-  gEfiCpuIo2ProtocolGuid\r
-\r
-[Guids]\r
-  gEfiPciOptionRomTableGuid\r
-  gEfiPciExpressBaseAddressGuid\r
-\r
-[Depex]\r
-  gEfiCpuIo2ProtocolGuid\r
diff --git a/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c b/DuetPkg/PciRootBridgeNoEnumerationDxe/X64/PcatIo.c
deleted file mode 100644 (file)
index 179df3d..0000000
+++ /dev/null
@@ -1,738 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
-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
-    PcatPciRootBridgeIo.c\r
-    \r
-Abstract:\r
-\r
-    EFI PC AT PCI Root Bridge Io Protocol\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-#include "PcatPciRootBridge.h"\r
-\r
-BOOLEAN                  mPciOptionRomTableInstalled = FALSE;\r
-EFI_PCI_OPTION_ROM_TABLE mPciOptionRomTable          = {0, NULL};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 UserAddress,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *UserBuffer\r
-  )\r
-{\r
-  return gCpuIo->Io.Read (\r
-                      gCpuIo,\r
-                      (EFI_CPU_IO_PROTOCOL_WIDTH) Width,\r
-                      UserAddress,\r
-                      Count,\r
-                      UserBuffer\r
-                      );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoWrite (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 UserAddress,\r
-  IN UINTN                                  Count,\r
-  IN OUT VOID                               *UserBuffer\r
-  )\r
-{\r
-  return gCpuIo->Io.Write (\r
-                      gCpuIo,\r
-                      (EFI_CPU_IO_PROTOCOL_WIDTH) Width,\r
-                      UserAddress,\r
-                      Count,\r
-                      UserBuffer\r
-                      );\r
-\r
-}\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoGetIoPortMapping (\r
-  OUT EFI_PHYSICAL_ADDRESS  *IoPortMapping,\r
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryPortMapping\r
-  )\r
-/*++\r
-\r
-  Get the IO Port Mapping.  For IA-32 it is always 0.\r
-  \r
---*/\r
-{\r
-  *IoPortMapping = 0;\r
-  *MemoryPortMapping = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-PcatRootBridgeIoPciRW (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN BOOLEAN                                Write,\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                                 UserAddress,\r
-  IN UINTN                                  Count,\r
-  IN OUT VOID                               *UserBuffer\r
-  )\r
-{\r
-  PCI_CONFIG_ACCESS_CF8             Pci;\r
-  PCI_CONFIG_ACCESS_CF8             PciAligned;\r
-  UINT32                            InStride;\r
-  UINT32                            OutStride;\r
-  UINTN                             PciData;\r
-  UINTN                             PciDataStride;\r
-  PCAT_PCI_ROOT_BRIDGE_INSTANCE     *PrivateData;\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS  PciAddress;\r
-  UINT64                            PciExpressRegAddr;\r
-  BOOLEAN                           UsePciExpressAccess;\r
-\r
-  if ((UINT32)Width >= EfiPciWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if ((Width & 0x03) >= EfiPciWidthUint64) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
-\r
-  InStride    = 1 << (Width & 0x03);\r
-  OutStride   = InStride;\r
-  if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {\r
-    InStride = 0;\r
-  }\r
-\r
-  if (Width >= EfiPciWidthFillUint8 && Width <= EfiPciWidthFillUint64) {\r
-    OutStride = 0;\r
-  }\r
-\r
-  UsePciExpressAccess = FALSE;\r
-\r
-  CopyMem (&PciAddress, &UserAddress, sizeof(UINT64));\r
-\r
-  if (PciAddress.ExtendedRegister > 0xFF) {\r
-    //\r
-    // Check PciExpressBaseAddress\r
-    //\r
-    if ((PrivateData->PciExpressBaseAddress == 0) ||\r
-        (PrivateData->PciExpressBaseAddress >= MAX_ADDRESS)) {\r
-      return EFI_UNSUPPORTED;\r
-    } else {\r
-      UsePciExpressAccess = TRUE;\r
-    }\r
-  } else {\r
-    if (PciAddress.ExtendedRegister != 0) {\r
-      Pci.Bits.Reg = PciAddress.ExtendedRegister & 0xFF;\r
-    } else {\r
-      Pci.Bits.Reg = PciAddress.Register;\r
-    }\r
-    //\r
-    // Note: We can also use PciExpress access here, if wanted.\r
-    //\r
-  }\r
-\r
-  if (!UsePciExpressAccess) {\r
-    Pci.Bits.Func     = PciAddress.Function;\r
-    Pci.Bits.Dev      = PciAddress.Device;\r
-    Pci.Bits.Bus      = PciAddress.Bus;\r
-    Pci.Bits.Reserved = 0;\r
-    Pci.Bits.Enable   = 1;\r
-\r
-    //\r
-    // PCI Config access are all 32-bit alligned, but by accessing the\r
-    //  CONFIG_DATA_REGISTER (0xcfc) with different widths more cycle types\r
-    //  are possible on PCI.\r
-    //\r
-    // To read a byte of PCI config space you load 0xcf8 and \r
-    //  read 0xcfc, 0xcfd, 0xcfe, 0xcff\r
-    //\r
-    PciDataStride = Pci.Bits.Reg & 0x03;\r
-\r
-    while (Count) {\r
-      PciAligned = Pci;\r
-      PciAligned.Bits.Reg &= 0xfc;\r
-      PciData = (UINTN)PrivateData->PciData + PciDataStride;\r
-      EfiAcquireLock(&PrivateData->PciLock);\r
-      This->Io.Write (This, EfiPciWidthUint32, PrivateData->PciAddress, 1, &PciAligned);\r
-      if (Write) {\r
-        This->Io.Write (This, Width, PciData, 1, UserBuffer);\r
-      } else {\r
-        This->Io.Read (This, Width, PciData, 1, UserBuffer);\r
-      }\r
-      EfiReleaseLock(&PrivateData->PciLock);\r
-      UserBuffer = ((UINT8 *)UserBuffer) + OutStride;\r
-      PciDataStride = (PciDataStride + InStride) % 4;\r
-      Pci.Bits.Reg += InStride;\r
-      Count -= 1;\r
-    }\r
-  } else {\r
-    //\r
-    // Access PCI-Express space by using memory mapped method.\r
-    //\r
-    PciExpressRegAddr = (PrivateData->PciExpressBaseAddress) |\r
-                        (PciAddress.Bus      << 20) |\r
-                        (PciAddress.Device   << 15) |\r
-                        (PciAddress.Function << 12);\r
-    if (PciAddress.ExtendedRegister != 0) {\r
-      PciExpressRegAddr += PciAddress.ExtendedRegister;\r
-    } else {\r
-      PciExpressRegAddr += PciAddress.Register;\r
-    }\r
-    while (Count) {\r
-      if (Write) {\r
-        This->Mem.Write (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);\r
-      } else {\r
-        This->Mem.Read (This, Width, (UINTN) PciExpressRegAddr, 1, UserBuffer);\r
-      }\r
-\r
-      UserBuffer = ((UINT8 *) UserBuffer) + OutStride;\r
-      PciExpressRegAddr += InStride;\r
-      Count -= 1;\r
-    }\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-ScanPciBus(\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  EFI_PCI_BUS_SCAN_CALLBACK        Callback,\r
-  VOID                             *Context\r
-  )\r
-  \r
-{\r
-  UINT16      Bus;\r
-  UINT16      Device;\r
-  UINT16      Func;\r
-  UINT64      Address;\r
-  PCI_TYPE00  PciHeader;\r
-\r
-  //\r
-  // Loop through all busses\r
-  //\r
-  for (Bus = MinBus; Bus <= MaxBus; Bus++) {\r
-    //  \r
-    // Loop 32 devices per bus\r
-    //\r
-    for (Device = MinDevice; Device <= MaxDevice; Device++) {\r
-      //\r
-      // Loop through 8 functions per device\r
-      //\r
-      for (Func = MinFunc; Func <= MaxFunc; Func++) {\r
-\r
-        //\r
-        // Compute the EFI Address required to access the PCI Configuration Header of this PCI Device\r
-        //\r
-        Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);\r
-\r
-        //\r
-        // Read the VendorID from this PCI Device's Confioguration Header\r
-        //\r
-        IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &PciHeader.Hdr.VendorId);\r
-    \r
-        //\r
-        // If VendorId = 0xffff, there does not exist a device at this \r
-        // location. For each device, if there is any function on it, \r
-        // there must be 1 function at Function 0. So if Func = 0, there\r
-        // will be no more functions in the same device, so we can break\r
-        // loop to deal with the next device.\r
-        //  \r
-        if (PciHeader.Hdr.VendorId == 0xffff && Func == 0) {\r
-          break;\r
-        }\r
-        \r
-        if (PciHeader.Hdr.VendorId != 0xffff) {\r
-\r
-          //\r
-          // Read the HeaderType to determine if this is a multi-function device\r
-          //\r
-          IoDev->Pci.Read (IoDev, EfiPciWidthUint8, Address + 0x0e, 1, &PciHeader.Hdr.HeaderType);\r
-\r
-          //\r
-          // Call the callback function for the device that was found\r
-          //\r
-          Callback(\r
-            IoDev, \r
-            MinBus, MaxBus,\r
-            MinDevice, MaxDevice,\r
-            MinFunc, MaxFunc,\r
-            Bus,\r
-            Device,\r
-            Func,\r
-            Context\r
-            );\r
-\r
-          //\r
-          // If this is not a multi-function device, we can leave the loop \r
-          // to deal with the next device.\r
-          //\r
-          if ((PciHeader.Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00 && Func == 0) {\r
-            break;\r
-          }\r
-        }  \r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-VOID\r
-CheckForRom (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *VoidContext\r
-  )\r
-{\r
-  EFI_STATUS                                 Status;\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  *Context;\r
-  UINT64                                     Address;\r
-  PCI_TYPE00                                 PciHeader;\r
-  PCI_TYPE01                                 *PciBridgeHeader;\r
-  UINT32                                     Register;\r
-  UINT32                                     RomBar;\r
-  UINT32                                     RomBarSize;\r
-  EFI_PHYSICAL_ADDRESS                       RomBuffer;\r
-  UINT32                                     MaxRomSize;\r
-  EFI_PCI_EXPANSION_ROM_HEADER               EfiRomHeader;\r
-  PCI_DATA_STRUCTURE                         Pcir;\r
-  EFI_PCI_OPTION_ROM_DESCRIPTOR              *TempPciOptionRomDescriptors;\r
-  BOOLEAN                                    LastImage;\r
-\r
-  Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;\r
-\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 0);\r
-\r
-  //\r
-  // Save the contents of the PCI Configuration Header\r
-  //\r
-  IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);\r
-\r
-  if (IS_PCI_BRIDGE(&PciHeader)) {\r
-\r
-    PciBridgeHeader = (PCI_TYPE01 *)(&PciHeader);\r
-\r
-    //\r
-    // See if the PCI-PCI Bridge has its secondary interface enabled.\r
-    //\r
-    if (PciBridgeHeader->Bridge.SubordinateBus >= PciBridgeHeader->Bridge.SecondaryBus) {\r
-\r
-      //\r
-      // Disable the Prefetchable Memory Window\r
-      //\r
-      Register = 0x00000000;\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x26, 1, &Register);\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x2c, 1, &Register);\r
-      Register = 0xffffffff;\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x24, 1, &Register);\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x28, 1, &Register);\r
-\r
-      //\r
-      // Program Memory Window to the PCI Root Bridge Memory Window\r
-      //\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 0x20, 4, &Context->PpbMemoryWindow);\r
-\r
-      //\r
-      // Enable the Memory decode for the PCI-PCI Bridge\r
-      //\r
-      IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-      Register |= 0x02;\r
-      IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-\r
-      //\r
-      // Recurse on the Secondary Bus Number\r
-      //\r
-      ScanPciBus(\r
-        IoDev,\r
-        PciBridgeHeader->Bridge.SecondaryBus, PciBridgeHeader->Bridge.SecondaryBus, \r
-        0, PCI_MAX_DEVICE, \r
-        0, PCI_MAX_FUNC, \r
-        CheckForRom, Context\r
-        );\r
-    }\r
-  } else {\r
-\r
-    //\r
-    // Check if an Option ROM Register is present and save the Option ROM Window Register\r
-    //\r
-    RomBar = 0xffffffff;\r
-    IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-    IoDev->Pci.Read (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-\r
-    RomBarSize = (~(RomBar & 0xfffff800)) + 1;\r
-\r
-    //\r
-    // Make sure the size of the ROM is between 0 and 16 MB\r
-    //\r
-    if (RomBarSize > 0 && RomBarSize <= 0x01000000) {\r
-\r
-      //\r
-      // Program Option ROM Window Register to the PCI Root Bridge Window and Enable the Option ROM Window\r
-      //\r
-      RomBar = (Context->PpbMemoryWindow & 0xffff) << 16;\r
-      RomBar = ((RomBar - 1) & (~(RomBarSize - 1))) + RomBarSize;\r
-      if (RomBar < (Context->PpbMemoryWindow & 0xffff0000)) {\r
-        MaxRomSize = (Context->PpbMemoryWindow & 0xffff0000) - RomBar;\r
-        RomBar = RomBar + 1;\r
-        IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-        IoDev->Pci.Read  (IoDev, EfiPciWidthUint32, Address + 0x30, 1, &RomBar);\r
-        RomBar = RomBar - 1;\r
-\r
-        //\r
-        // Enable the Memory decode for the PCI Device\r
-        //\r
-        IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-        Register |= 0x02;\r
-        IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-\r
-        //\r
-        // Follow the chain of images to determine the size of the Option ROM present\r
-        // Keep going until the last image is found by looking at the Indicator field\r
-        // or the size of an image is 0, or the size of all the images is bigger than the\r
-        // size of the window programmed into the PPB.\r
-        //\r
-        RomBarSize = 0;\r
-        do {\r
-\r
-          LastImage = TRUE;\r
-\r
-          ZeroMem (&EfiRomHeader, sizeof(EfiRomHeader));\r
-          IoDev->Mem.Read (\r
-            IoDev, \r
-            EfiPciWidthUint8, \r
-            RomBar + RomBarSize, \r
-            sizeof(EfiRomHeader),\r
-            &EfiRomHeader\r
-            );\r
-\r
-          Pcir.ImageLength = 0;\r
-\r
-          if (EfiRomHeader.Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE &&\r
-              EfiRomHeader.PcirOffset != 0 &&\r
-              (EfiRomHeader.PcirOffset & 3) == 0 &&\r
-              RomBarSize + EfiRomHeader.PcirOffset + sizeof (PCI_DATA_STRUCTURE) <= MaxRomSize) {\r
-            ZeroMem (&Pcir, sizeof(Pcir));\r
-            IoDev->Mem.Read (\r
-              IoDev, \r
-              EfiPciWidthUint8, \r
-              RomBar + RomBarSize + EfiRomHeader.PcirOffset, \r
-              sizeof(Pcir),\r
-              &Pcir\r
-              );\r
-\r
-            if (Pcir.Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
-              break;\r
-            }\r
-            if (RomBarSize + Pcir.ImageLength * 512 > MaxRomSize) {\r
-              break;\r
-            }\r
-            if ((Pcir.Indicator & 0x80) == 0x00) {\r
-              LastImage = FALSE;\r
-            }\r
-\r
-            RomBarSize += Pcir.ImageLength * 512;\r
-          }\r
-        } while (!LastImage && RomBarSize < MaxRomSize && Pcir.ImageLength !=0);\r
-\r
-        if (RomBarSize > 0) {\r
-\r
-          //\r
-          // Allocate a memory buffer for the Option ROM contents.\r
-          //\r
-          Status = gBS->AllocatePages(\r
-                          AllocateAnyPages,\r
-                          EfiBootServicesData,\r
-                          EFI_SIZE_TO_PAGES(RomBarSize),\r
-                          &RomBuffer\r
-                          );\r
-\r
-          if (!EFI_ERROR (Status)) {\r
-\r
-            //\r
-            // Copy the contents of the Option ROM to the memory buffer\r
-            //\r
-            IoDev->Mem.Read (IoDev, EfiPciWidthUint32, RomBar, RomBarSize / sizeof(UINT32), (VOID *)(UINTN)RomBuffer);\r
-\r
-            Status = gBS->AllocatePool(\r
-                            EfiBootServicesData,\r
-                            ((UINT32)mPciOptionRomTable.PciOptionRomCount + 1) * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR),\r
-                            (VOID **) &TempPciOptionRomDescriptors\r
-                            );\r
-            if (mPciOptionRomTable.PciOptionRomCount > 0) {\r
-              CopyMem(\r
-                TempPciOptionRomDescriptors, \r
-                mPciOptionRomTable.PciOptionRomDescriptors, \r
-                (UINT32)mPciOptionRomTable.PciOptionRomCount * sizeof(EFI_PCI_OPTION_ROM_DESCRIPTOR)\r
-                );\r
-\r
-              gBS->FreePool(mPciOptionRomTable.PciOptionRomDescriptors);\r
-            }\r
-\r
-            mPciOptionRomTable.PciOptionRomDescriptors = TempPciOptionRomDescriptors; \r
-\r
-            TempPciOptionRomDescriptors = &(mPciOptionRomTable.PciOptionRomDescriptors[(UINT32)mPciOptionRomTable.PciOptionRomCount]);\r
-\r
-            TempPciOptionRomDescriptors->RomAddress              = RomBuffer;\r
-            TempPciOptionRomDescriptors->MemoryType              = EfiBootServicesData;\r
-            TempPciOptionRomDescriptors->RomLength               = RomBarSize;\r
-            TempPciOptionRomDescriptors->Seg                     = (UINT32)IoDev->SegmentNumber;\r
-            TempPciOptionRomDescriptors->Bus                     = (UINT8)Bus;\r
-            TempPciOptionRomDescriptors->Dev                     = (UINT8)Device;\r
-            TempPciOptionRomDescriptors->Func                    = (UINT8)Func;\r
-            TempPciOptionRomDescriptors->ExecutedLegacyBiosImage = TRUE;\r
-            TempPciOptionRomDescriptors->DontLoadEfiRom          = FALSE;\r
-\r
-            mPciOptionRomTable.PciOptionRomCount++;\r
-          }\r
-        }\r
-\r
-        //\r
-        // Disable the Memory decode for the PCI-PCI Bridge\r
-        //\r
-        IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-        Register &= (~0x02);\r
-        IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address + 4, 1, &Register);\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Restore the PCI Configuration Header \r
-  //\r
-  IoDev->Pci.Write (IoDev, EfiPciWidthUint32, Address, sizeof(PciHeader)/sizeof(UINT32), &PciHeader);\r
-}\r
-\r
-VOID\r
-SaveCommandRegister (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *VoidContext\r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  *Context;\r
-  UINT64  Address;\r
-  UINTN   Index;\r
-  UINT16  Command;\r
-\r
-  Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;\r
-\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);\r
-\r
-  Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;\r
-\r
-  IoDev->Pci.Read (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);\r
-\r
-  //\r
-  // Clear the memory enable bit\r
-  //\r
-  Command = (UINT16) (Context->CommandRegisterBuffer[Index] & (~0x02));\r
-\r
-  IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Command);\r
-}\r
-\r
-VOID\r
-RestoreCommandRegister (\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev,\r
-  UINT16                           MinBus,\r
-  UINT16                           MaxBus,\r
-  UINT16                           MinDevice,\r
-  UINT16                           MaxDevice,\r
-  UINT16                           MinFunc,\r
-  UINT16                           MaxFunc,\r
-  UINT16                           Bus,\r
-  UINT16                           Device,\r
-  UINT16                           Func,\r
-  IN VOID                          *VoidContext\r
-  )\r
-\r
-{\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  *Context;\r
-  UINT64                                     Address;\r
-  UINTN                                      Index;\r
-\r
-  Context = (PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT *)VoidContext;\r
-\r
-  Address = EFI_PCI_ADDRESS (Bus, Device, Func, 4);\r
-\r
-  Index = (Bus - MinBus) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1) + Device * (PCI_MAX_FUNC+1) + Func;\r
-\r
-  IoDev->Pci.Write (IoDev, EfiPciWidthUint16, Address, 1, &Context->CommandRegisterBuffer[Index]);\r
-}\r
-\r
-EFI_STATUS\r
-ScanPciRootBridgeForRoms(\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *IoDev\r
-  )\r
-  \r
-{\r
-  EFI_STATUS                                 Status;\r
-  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR          *Descriptors; \r
-  UINT16                                     MinBus;\r
-  UINT16                                     MaxBus;\r
-  UINT64                                     RootWindowBase;\r
-  UINT64                                     RootWindowLimit;\r
-  PCAT_PCI_ROOT_BRIDGE_SCAN_FOR_ROM_CONTEXT  Context;\r
-\r
-  if (mPciOptionRomTableInstalled == FALSE) {\r
-    gBS->InstallConfigurationTable(&gEfiPciOptionRomTableGuid, &mPciOptionRomTable);\r
-    mPciOptionRomTableInstalled = TRUE;\r
-  }\r
-\r
-  Status = IoDev->Configuration(IoDev, (VOID **) &Descriptors);\r
-  if (EFI_ERROR (Status) || Descriptors == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  MinBus = 0xffff;\r
-  MaxBus = 0xffff;\r
-  RootWindowBase  = 0;\r
-  RootWindowLimit = 0;\r
-  while (Descriptors->Desc != ACPI_END_TAG_DESCRIPTOR) {\r
-    //\r
-    // Find bus range\r
-    //\r
-    if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {\r
-      MinBus = (UINT16)Descriptors->AddrRangeMin;\r
-      MaxBus = (UINT16)Descriptors->AddrRangeMax;\r
-    }\r
-    //\r
-    // Find memory descriptors that are not prefetchable\r
-    //\r
-    if (Descriptors->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM && Descriptors->SpecificFlag == 0) {\r
-      //\r
-      // Find Memory Descriptors that are less than 4GB, so the PPB Memory Window can be used for downstream devices\r
-      //\r
-      if (Descriptors->AddrRangeMax < 0x100000000ULL) {\r
-        //\r
-        // Find the largest Non-Prefetchable Memory Descriptor that is less than 4GB\r
-        //\r
-        if ((Descriptors->AddrRangeMax - Descriptors->AddrRangeMin) > (RootWindowLimit - RootWindowBase)) {\r
-          RootWindowBase  = Descriptors->AddrRangeMin;\r
-          RootWindowLimit = Descriptors->AddrRangeMax;\r
-        }\r
-      }\r
-    }\r
-    Descriptors ++;\r
-  }\r
-\r
-  //\r
-  // Make sure a bus range was found\r
-  //\r
-  if (MinBus == 0xffff || MaxBus == 0xffff) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Make sure a non-prefetchable memory region was found\r
-  //\r
-  if (RootWindowBase == 0 && RootWindowLimit == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Round the Base and Limit values to 1 MB boudaries\r
-  //\r
-  RootWindowBase  = ((RootWindowBase - 1) & 0xfff00000) + 0x00100000;\r
-  RootWindowLimit = ((RootWindowLimit + 1) & 0xfff00000) - 1;\r
-\r
-  //\r
-  // Make sure that the size of the rounded window is greater than zero\r
-  //\r
-  if (RootWindowLimit <= RootWindowBase) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Allocate buffer to save the Command register from all the PCI devices\r
-  //\r
-  Context.CommandRegisterBuffer = NULL;\r
-  Status = gBS->AllocatePool(\r
-                  EfiBootServicesData,\r
-                  sizeof(UINT16) * (MaxBus - MinBus + 1) * (PCI_MAX_DEVICE+1) * (PCI_MAX_FUNC+1),\r
-                  (VOID **) &Context.CommandRegisterBuffer\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Context.PpbMemoryWindow   = (((UINT32)RootWindowBase) >> 16) | ((UINT32)RootWindowLimit & 0xffff0000);\r
-\r
-  //\r
-  // Save the Command register from all the PCI devices, and disable the I/O, Mem, and BusMaster bits\r
-  //\r
-  ScanPciBus(\r
-    IoDev,\r
-    MinBus, MaxBus, \r
-    0, PCI_MAX_DEVICE, \r
-    0, PCI_MAX_FUNC, \r
-    SaveCommandRegister, &Context\r
-    );\r
-\r
-  //\r
-  // Recursively scan all the busses for PCI Option ROMs\r
-  //\r
-  ScanPciBus(\r
-    IoDev,\r
-    MinBus, MinBus, \r
-    0, PCI_MAX_DEVICE, \r
-    0, PCI_MAX_FUNC, \r
-    CheckForRom, &Context\r
-    );\r
-\r
-  //\r
-  // Restore the Command register in all the PCI devices\r
-  //\r
-  ScanPciBus(\r
-    IoDev,\r
-    MinBus, MaxBus, \r
-    0, PCI_MAX_DEVICE, \r
-    0, PCI_MAX_FUNC, \r
-    RestoreCommandRegister, &Context\r
-    );\r
-\r
-  //\r
-  // Free the buffer used to save all the Command register values\r
-  //\r
-  gBS->FreePool(Context.CommandRegisterBuffer);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/PostBuild.bat b/DuetPkg/PostBuild.bat
deleted file mode 100644 (file)
index e7f2778..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-@echo off\r
-@REM ## @file\r
-@REM #\r
-@REM #  Post build script that will be automatically run after build.\r
-@REM #\r
-@REM #  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
-@REM #\r
-@REM #  This program and the accompanying materials\r
-@REM #  are licensed and made available under the terms and conditions of the BSD License\r
-@REM #  which accompanies this distribution. The full text of the license may be found at\r
-@REM #  http://opensource.org/licenses/bsd-license.php\r
-@REM #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-@REM #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-@REM #\r
-@REM #\r
-@REM ##\r
-\r
-set BASETOOLS_DIR=%EDK_TOOLS_BIN%\r
-set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin\r
-\r
-:SetDefault\r
-set TARGET_ARCH=\r
-set TARGET=\r
-set TOOL_CHAIN_TAG=\r
-\r
-:ParseParamsLoop\r
-if "%1"=="" goto EndPParseParamsLoop\r
-if /I "%1"=="-p" goto ParseParamsLoopNext\r
-if /I "%1"=="-a" set TARGET_ARCH=%2& goto ParseParamsLoopNext\r
-if /I "%1"=="-b" set TARGET=%2& goto ParseParamsLoopNext\r
-if /I "%1"=="-t" set TOOL_CHAIN_TAG=%2& goto ParseParamsLoopNext\r
-if /I "%1"=="-h" goto Help\r
-\r
-:ParseParamsLoopNext\r
-shift\r
-shift\r
-goto ParseParamsLoop\r
-\r
-:EndPParseParamsLoop\r
-if "%TARGET_ARCH%"=="" goto Help\r
-if "%TARGET%"=="" goto Help\r
-if "%TOOL_CHAIN_TAG%"=="" goto Help\r
-\r
-set PROCESSOR=%TARGET_ARCH%\r
-set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%\r
-\r
-@REM Store environment variables used by CreateBootDisk.bat\r
-echo set TARGET=%TARGET%> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
-echo set TOOL_CHAIN_TAG=%TOOL_CHAIN_TAG%>> %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
-\r
-echo Compressing DUETEFIMainFv.FV ...\r
-%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DUETEFIMAINFV.z %BUILD_DIR%\FV\DUETEFIMAINFV.Fv\r
-\r
-echo Compressing DxeMain.efi ...\r
-%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\%PROCESSOR%\DxeCore.efi\r
-\r
-echo Compressing DxeIpl.efi ...\r
-%BASETOOLS_DIR%\LzmaCompress -e -o %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\%PROCESSOR%\DxeIpl.efi\r
-\r
-echo Generate Loader Image ...\r
-if "%PROCESSOR%"=="IA32" goto GENERATE_IMAGE_IA32\r
-if "%PROCESSOR%"=="X64" goto GENERATE_IMAGE_X64\r
-\r
-:GENERATE_IMAGE_IA32\r
-%BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z\r
-copy /b %BOOTSECTOR_BIN_DIR%\Start.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr\r
-copy /b %BOOTSECTOR_BIN_DIR%\Start16.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr16\r
-copy /b %BOOTSECTOR_BIN_DIR%\Start32.com+%BOOTSECTOR_BIN_DIR%\Efi32.com2+%BUILD_DIR%\FV\Efildr32 %BUILD_DIR%\FV\Efildr20\r
-goto end\r
-\r
-:GENERATE_IMAGE_X64\r
-%BASETOOLS_DIR%\EfiLdrImage.exe -o %BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\%PROCESSOR%\EfiLoader.efi %BUILD_DIR%\FV\DxeIpl.z %BUILD_DIR%\FV\DxeMain.z %BUILD_DIR%\FV\DUETEFIMAINFV.z\r
-copy /b %BOOTSECTOR_BIN_DIR%\Start64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\EfildrPure\r
-%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\EfildrPure -o %BUILD_DIR%\FV\Efildr\r
-copy /b %BOOTSECTOR_BIN_DIR%\St16_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr16Pure\r
-%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr16Pure -o %BUILD_DIR%\FV\Efildr16\r
-copy /b %BOOTSECTOR_BIN_DIR%\St32_64.com+%BOOTSECTOR_BIN_DIR%\Efi64.com2+%BUILD_DIR%\FV\Efildr64 %BUILD_DIR%\FV\Efildr20Pure\r
-%BASETOOLS_DIR%\GenPage.exe %BUILD_DIR%\FV\Efildr20Pure -o %BUILD_DIR%\FV\Efildr20\r
-goto end\r
-\r
-:Help\r
-echo Usage: This script will be run automatically after build.\r
-:end\r
diff --git a/DuetPkg/PostBuild.sh b/DuetPkg/PostBuild.sh
deleted file mode 100755 (executable)
index 524c9d7..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-
-## @file
-#
-#  Post build script that will be automatically run after build.
-#
-#  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-#  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.
-#
-##
-
-if [ -z "$EDK_TOOLS_PATH" ]
-then
-export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
-else
-export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin
-fi
-
-export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
-export PROCESSOR=""
-export TOOLTAG=""
-
-while [ $# -gt 0 ]; do
-    if [ "$1" = "-a" ]; then
-        export PROCESSOR=$2
-    elif [ "$1" = "-t" ]; then
-        export TOOLTAG=$2
-    elif [ "$1" = "-h" ]; then
-        echo Usage: This script will be run automatically after build.
-        return 1
-    fi
-    shift
-    shift
-done
-
-if [ "$PROCESSOR" = "" -o "$TOOLTAG" = "" ]; then
-    echo Usage: This script will be run automatically after build.
-    return 1
-fi
-
-export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLTAG
-
-#
-# Store environment variables used by CreateBootDisk.sh
-#
-echo export TOOLCHAIN=$TOOLTAG> $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh
-chmod +x $WORKSPACE/DuetPkg/SetEnv_$PROCESSOR.sh
-
-#
-# Boot sector module could only be built under IA32 tool chain
-#
-
-echo Compressing DUETEFIMainFv.FV ...
-$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DUETEFIMAINFV.z $BUILD_DIR/FV/DUETEFIMAINFV.Fv
-
-echo Compressing DxeMain.efi ...
-$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/$PROCESSOR/DxeCore.efi
-
-echo Compressing DxeIpl.efi ...
-$BASETOOLS_DIR/LzmaCompress -e -o $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/$PROCESSOR/DxeIpl.efi
-
-echo Generate Loader Image ...
-
-if [ $PROCESSOR = IA32 ]
-then
-    $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
-    $BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr32 $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
-    cat $BOOTSECTOR_BIN_DIR/Start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32   > $BUILD_DIR/FV/Efildr
-    #
-    # It is safe to use "bcat" to cat following binary file, if bcat command is avaiable for your system
-    #
-    #bcat -o $BUILD_DIR/FV/Efildr.bcat $BOOTSECTOR_BIN_DIR/start.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
-    cat $BOOTSECTOR_BIN_DIR/Start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr16
-    #bcat -o $BUILD_DIR/FV/Efildr16.bcat $BOOTSECTOR_BIN_DIR/start16.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
-    cat $BOOTSECTOR_BIN_DIR/Start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32 > $BUILD_DIR/FV/Efildr20
-    #bcat -o $BUILD_DIR/FV/Efildr20.bcat $BOOTSECTOR_BIN_DIR/start32.com $BOOTSECTOR_BIN_DIR/efi32.com2 $BUILD_DIR/FV/Efildr32
-    echo Done!
-fi
-
-if [ $PROCESSOR = X64 ]
-then
-    $BASETOOLS_DIR/GenFw --rebase 0x10000 -o $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/$PROCESSOR/EfiLoader.efi
-    $BASETOOLS_DIR/EfiLdrImage -o $BUILD_DIR/FV/Efildr64 $BUILD_DIR/$PROCESSOR/EfiLoader.efi $BUILD_DIR/FV/DxeIpl.z $BUILD_DIR/FV/DxeMain.z $BUILD_DIR/FV/DUETEFIMAINFV.z
-    cat $BOOTSECTOR_BIN_DIR/Start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/EfildrPure
-    #bcat -o $BUILD_DIR/FV/EfildrPure $BOOTSECTOR_BIN_DIR/start64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
-    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/EfildrPure -o $BUILD_DIR/FV/Efildr
-    cat $BOOTSECTOR_BIN_DIR/St16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr16Pure
-    #bcat -o $BUILD_DIR/FV/Efildr16Pure $BOOTSECTOR_BIN_DIR/st16_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
-    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr16Pure -o $BUILD_DIR/FV/Efildr16
-    cat $BOOTSECTOR_BIN_DIR/St32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64 > $BUILD_DIR/FV/Efildr20Pure
-    #bcat -o $BUILD_DIR/FV/Efildr20Pure $BOOTSECTOR_BIN_DIR/st32_64.com $BOOTSECTOR_BIN_DIR/efi64.com2 $BUILD_DIR/FV/Efildr64
-    $BASETOOLS_DIR/GenPage $BUILD_DIR/FV/Efildr20Pure -o $BUILD_DIR/FV/Efildr20
-
-    echo Done!
-fi
-
-
diff --git a/DuetPkg/ReadMe.txt b/DuetPkg/ReadMe.txt
deleted file mode 100644 (file)
index f894d94..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-Developer's UEFI Emulation (DUET) on Edk2\r
-\r
-A. Build DUET image on Windows Platform\r
-========================================\r
-1. Tools preparation\r
-\r
-  To build DUET image, Visual Studio is required:\r
-  1). Base on below link to create Visual Studio build environment.\r
-      https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems\r
-\r
-2. Build Duet Platform module\r
-\r
-  1). run cmd.exe to open command line window.\r
-  2). enter workspace root directory such as c:\edk2_tree\r
-  3). set the environment variable EDK_TOOLS_BIN to point at the BaseTools binaries directory\r
-      i.e., "set EDK_TOOLS_BIN=c:\edk2-BaseTools-win32"\r
-  4). run "edksetup.bat"\r
-  5). run "build -p DuetPkg\DuetPkgIa32.dsc -a IA32 -t VS2015x86" for IA32 architecture platform (using 64-bit VS2015 for example) or\r
-          "build -p DuetPkg\DuetPkgX64.dsc -a X64 -t VS2015x86" for X64 architecture platform.\r
-\r
-  NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command.\r
-\r
-\r
-Create bootable disk\r
-======================\r
-\r
-3. Create boot disk\r
-  The following steps are same for IA32 architecture platform or X64 architecture platform.\r
-\r
-3.1 Create floppy boot disk\r
-  1). enter <Workspace>\DuetPkg directory.\r
-  2). Insert a floppy disk to drive\r
-  3). run "CreateBootDisk.bat floppy a: FAT12 IA32" if floppy drive is a: disk and Arch to boot is IA32.\r
-      or\r
-      run "CreateBootDisk.bat floppy a: FAT12 X64" if floppy drive is a: disk and Arch to boot is X64.\r
-3.2 Create usb boot disk\r
-  1). enter <Workspace>\DuetPkg directory.\r
-  2). Plugin usb disk\r
-  3). run "CreateBootDisk.bat usb e: FAT16 IA32" if usb drive is e: and FAT format is FAT16 and Arch to boot is IA32.\r
-      or "CreateBootDisk.bat usb e: FAT16 X64" if usb drive is e: and FAT format is FAT16 and Arch to boot is X64.\r
-      or "CreateBootDisk.bat usb e: FAT32 IA32" if usb drive is e: and FAT format is FAT32 and Arch to boot is IA32.\r
-      or "CreateBootDisk.bat usb e: FAT32 X64" if usb drive is e: and FAT format is FAT32 and Arch to boot is X64.\r
-  4). UnPlug usb disk and plugin it again.\r
-  5). run "CreateBootDisk.bat usb e: FAT16 IA32 step2" if usb drive is e: and FAT format is FAT16 and Arch to boot is IA32.\r
-      or "CreateBootDisk.bat usb e: FAT16 X64 step2" if usb drive is e: and FAT format is FAT16 and Arch to boot is X64.\r
-      or "CreateBootDisk.bat usb e: FAT32 IA32 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is IA32.\r
-      or "CreateBootDisk.bat usb e: FAT32 X64 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is X64.\r
-\r
-B. Build DUET image on Linux Platform\r
-======================================\r
-1. Tools preparation\r
-\r
-  To build DUET image, GCC installation (4.4+) is required:\r
-  1). Base on below link to create GCC build environment.\r
-      https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC\r
-\r
-2. Build Duet Platform module\r
-\r
-  1). Open the terminal.\r
-  2). enter workspace root directory such as /edk2_tree\r
-  3). run ". edksetup.sh BaseTools"\r
-  4). run "build -p DuetPkg/DuetPkgIa32.dsc -a IA32 -t GCC49" for IA32 architecture platform (using GCC 4.9 for example) or\r
-          "build -p DuetPkg/DuetPkgX64.dsc -a X64 -t GCC49" for X64 architecture platform.\r
-\r
-  NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command.\r
-        After post build action, you should check the size of EfiLdr at $WORKSPACE/Build/DuetPkgIA32(DuetPkgX64)/DEBUG_GCC49 directory, it must less than 470k.\r
-        If not, you should manually remove some unnecessary drivers at DuetPkg.fdf file.\r
-\r
-3. Create bootable disk\r
-   The following steps are same for IA32 architecture platform or X64 architecture platform.\r
-\r
-3.1 Create floppy boot disk\r
-  1). enter /edk2_tree/DuetPkg directory.\r
-  2). Insert a floppy disk to drive\r
-  3). run "CreateBootDisk.sh" to build floppy drive\r
-      such as "./CreateBootDisk.sh floppy /media/floppy0 /dev/fd0 FAT12 IA32"\r
-\r
-3.2 Create usb boot disk\r
-  1). enter /edk2_tree/DuetPkg directory.\r
-  2). Plugin usb disk\r
-  3). run "CreateBootDisk.sh" to build usb drive\r
-      such as "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32"\r
-  4). UnPlug usb disk and plugin it again.\r
-  5). run "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32 step2"\r
diff --git a/DuetPkg/SataControllerDxe/ComponentName.c b/DuetPkg/SataControllerDxe/ComponentName.c
deleted file mode 100644 (file)
index 57cd3c8..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/** @file\r
-  UEFI Component Name(2) protocol implementation for Sata Controller driver.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#include "SataController.h"\r
-\r
-//\r
-/// EFI Component Name Protocol\r
-///\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gSataControllerComponentName = {\r
-  SataControllerComponentNameGetDriverName,\r
-  SataControllerComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-/// EFI Component Name 2 Protocol\r
-///\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataControllerComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataControllerComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-//\r
-/// Driver Name Strings\r
-///\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    (CHAR16 *)L"Sata Controller Init Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-///\r
-/// Controller Name Strings\r
-///\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerControllerNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    (CHAR16 *)L"Sata Controller"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the UEFI Driver.\r
-\r
-  @param This           A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param 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
-  @param 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
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by This\r
-                                and the language specified by Language was returned\r
-                                in DriverName.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support the\r
-                                language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerComponentNameGetDriverName (\r
-  IN EFI_COMPONENT_NAME_PROTOCOL    *This,\r
-  IN CHAR8                          *Language,\r
-  OUT CHAR16                        **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mSataControllerDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gSataControllerComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by an UEFI Driver.  \r
-\r
-  @param This                   A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param 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
-  @param ChildHandle OPTIONAL   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
-  @param 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
-  @param 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\r
-                                specified by Language from the point of view of the\r
-                                driver specified by This.\r
-  \r
-  @retval 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
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support the\r
-                                language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerComponentNameGetControllerName (\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
-  EFI_STATUS    Status;\r
-\r
-  //\r
-  // Make sure this driver is currently managing ControllHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gSataControllerDriverBinding.DriverBindingHandle,\r
-             &gEfiPciIoProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return LookupUnicodeString2 (\r
-          Language,\r
-          This->SupportedLanguages,\r
-          mSataControllerControllerNameTable,\r
-          ControllerName,\r
-          (BOOLEAN)(This == &gSataControllerComponentName)\r
-          );\r
-}\r
diff --git a/DuetPkg/SataControllerDxe/SataController.c b/DuetPkg/SataControllerDxe/SataController.c
deleted file mode 100644 (file)
index e5d10e2..0000000
+++ /dev/null
@@ -1,1049 +0,0 @@
-/** @file\r
-  This driver module produces IDE_CONTROLLER_INIT protocol for Sata Controllers.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#include "SataController.h"\r
-\r
-///\r
-/// EFI_DRIVER_BINDING_PROTOCOL instance\r
-///\r
-EFI_DRIVER_BINDING_PROTOCOL gSataControllerDriverBinding = {\r
-  SataControllerSupported,\r
-  SataControllerStart,\r
-  SataControllerStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-/**\r
-  Read AHCI Operation register.\r
-\r
-  @param PciIo      The PCI IO protocol instance.\r
-  @param Offset     The operation register offset.\r
-\r
-  @return The register content read.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-AhciReadReg (\r
-  IN EFI_PCI_IO_PROTOCOL    *PciIo,\r
-  IN UINT32                 Offset\r
-  )\r
-{\r
-  UINT32    Data;\r
-\r
-  ASSERT (PciIo != NULL);\r
-  \r
-  Data = 0;\r
-\r
-  PciIo->Mem.Read (\r
-               PciIo,\r
-               EfiPciIoWidthUint32,\r
-               AHCI_BAR_INDEX,\r
-               (UINT64) Offset,\r
-               1,\r
-               &Data\r
-               );\r
-\r
-  return Data;\r
-}\r
-\r
-/**\r
-  Write AHCI Operation register.\r
-\r
-  @param PciIo      The PCI IO protocol instance.\r
-  @param Offset     The operation register offset.\r
-  @param Data       The data used to write down.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-AhciWriteReg (\r
-  IN EFI_PCI_IO_PROTOCOL    *PciIo,\r
-  IN UINT32                 Offset,\r
-  IN UINT32                 Data\r
-  )\r
-{\r
-  ASSERT (PciIo != NULL);\r
-\r
-  PciIo->Mem.Write (\r
-               PciIo,\r
-               EfiPciIoWidthUint32,\r
-               AHCI_BAR_INDEX,\r
-               (UINT64) Offset,\r
-               1,\r
-               &Data\r
-               );\r
-\r
-  return;\r
-}\r
-\r
-/**\r
-  This function is used to calculate the best PIO mode supported by specific IDE device\r
-\r
-  @param IdentifyData   The identify data of specific IDE device.\r
-  @param DisPioMode     Disqualified PIO modes collection.\r
-  @param SelectedMode   Available PIO modes collection.\r
-\r
-  @retval EFI_SUCCESS       Best PIO modes are returned.\r
-  @retval EFI_UNSUPPORTED   The device doesn't support PIO mode,\r
-                            or all supported modes have been disqualified.\r
-**/\r
-EFI_STATUS\r
-CalculateBestPioMode (\r
-  IN EFI_IDENTIFY_DATA  *IdentifyData,\r
-  IN UINT16             *DisPioMode OPTIONAL,\r
-  OUT UINT16            *SelectedMode\r
-  )\r
-{\r
-  UINT16    PioMode;\r
-  UINT16    AdvancedPioMode;\r
-  UINT16    Temp;\r
-  UINT16    Index;\r
-  UINT16    MinimumPioCycleTime;\r
-\r
-  Temp = 0xff;\r
-\r
-  PioMode = (UINT8) (((ATA5_IDENTIFY_DATA *) (&(IdentifyData->AtaData)))->pio_cycle_timing >> 8);\r
-\r
-  //\r
-  // See whether Identify Data word 64 - 70 are valid\r
-  //\r
-  if ((IdentifyData->AtaData.field_validity & 0x02) == 0x02) {\r
-\r
-    AdvancedPioMode = IdentifyData->AtaData.advanced_pio_modes;\r
-    DEBUG ((EFI_D_INFO, "CalculateBestPioMode: AdvancedPioMode = %x\n", AdvancedPioMode));\r
-\r
-    for (Index = 0; Index < 8; Index++) {\r
-      if ((AdvancedPioMode & 0x01) != 0) {\r
-        Temp = Index;\r
-      }\r
-\r
-      AdvancedPioMode >>= 1;\r
-    }\r
-\r
-    //\r
-    // If Temp is modified, mean the advanced_pio_modes is not zero;\r
-    // if Temp is not modified, mean there is no advanced PIO mode supported,\r
-    // the best PIO Mode is the value in pio_cycle_timing.\r
-    //\r
-    if (Temp != 0xff) {\r
-      AdvancedPioMode = (UINT16) (Temp + 3);\r
-    } else {\r
-      AdvancedPioMode = PioMode;\r
-    }\r
-\r
-    //\r
-    // Limit the PIO mode to at most PIO4.\r
-    //\r
-    PioMode = (UINT16) MIN (AdvancedPioMode, 4);\r
-\r
-    MinimumPioCycleTime = IdentifyData->AtaData.min_pio_cycle_time_with_flow_control;\r
-\r
-    if (MinimumPioCycleTime <= 120) {\r
-      PioMode = (UINT16) MIN (4, PioMode);\r
-    } else if (MinimumPioCycleTime <= 180) {\r
-      PioMode = (UINT16) MIN (3, PioMode);\r
-    } else if (MinimumPioCycleTime <= 240) {\r
-      PioMode = (UINT16) MIN (2, PioMode);\r
-    } else {\r
-      PioMode = 0;\r
-    }\r
-\r
-    //\r
-    // Degrade the PIO mode if the mode has been disqualified\r
-    //\r
-    if (DisPioMode != NULL) {\r
-      if (*DisPioMode < 2) {\r
-        return EFI_UNSUPPORTED; // no mode below ATA_PIO_MODE_BELOW_2\r
-      }\r
-\r
-      if (PioMode >= *DisPioMode) {\r
-        PioMode = (UINT16) (*DisPioMode - 1);\r
-      }\r
-    }\r
-\r
-    if (PioMode < 2) {\r
-      *SelectedMode = 1;        // ATA_PIO_MODE_BELOW_2;\r
-    } else {\r
-      *SelectedMode = PioMode;  // ATA_PIO_MODE_2 to ATA_PIO_MODE_4;\r
-    }\r
-\r
-  } else {\r
-    //\r
-    // Identify Data word 64 - 70 are not valid\r
-    // Degrade the PIO mode if the mode has been disqualified\r
-    //\r
-    if (DisPioMode != NULL) {\r
-      if (*DisPioMode < 2) {\r
-        return EFI_UNSUPPORTED; // no mode below ATA_PIO_MODE_BELOW_2\r
-      }\r
-\r
-      if (PioMode == *DisPioMode) {\r
-        PioMode--;\r
-      }\r
-    }\r
-\r
-    if (PioMode < 2) {\r
-      *SelectedMode = 1;        // ATA_PIO_MODE_BELOW_2;\r
-    } else {\r
-      *SelectedMode = 2;        // ATA_PIO_MODE_2;\r
-    }\r
-\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This function is used to calculate the best UDMA mode supported by specific IDE device\r
-\r
-  @param IdentifyData   The identify data of specific IDE device.\r
-  @param DisUDmaMode     Disqualified UDMA modes collection.\r
-  @param SelectedMode   Available UDMA modes collection.\r
-\r
-  @retval EFI_SUCCESS       Best UDMA modes are returned.\r
-  @retval EFI_UNSUPPORTED   The device doesn't support UDMA mode,\r
-                            or all supported modes have been disqualified.\r
-**/\r
-EFI_STATUS\r
-CalculateBestUdmaMode (\r
-  IN EFI_IDENTIFY_DATA  *IdentifyData,\r
-  IN UINT16             *DisUDmaMode OPTIONAL,\r
-  OUT UINT16            *SelectedMode\r
-  )\r
-{\r
-  UINT16    TempMode;\r
-  UINT16    DeviceUDmaMode;\r
-\r
-  DeviceUDmaMode = 0;\r
-\r
-  //\r
-  // Check whether the WORD 88 (supported UltraDMA by drive) is valid\r
-  //\r
-  if ((IdentifyData->AtaData.field_validity & 0x04) == 0x00) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  DeviceUDmaMode = IdentifyData->AtaData.ultra_dma_mode;\r
-  DEBUG ((EFI_D_INFO, "CalculateBestUdmaMode: DeviceUDmaMode = %x\n", DeviceUDmaMode));\r
-  DeviceUDmaMode &= 0x3f;\r
-  TempMode = 0;                 // initialize it to UDMA-0\r
-\r
-  while ((DeviceUDmaMode >>= 1) != 0) {\r
-    TempMode++;\r
-  }\r
-\r
-  //\r
-  // Degrade the UDMA mode if the mode has been disqualified\r
-  //\r
-  if (DisUDmaMode != NULL) {\r
-    if (*DisUDmaMode == 0) {\r
-      *SelectedMode = 0;\r
-      return EFI_UNSUPPORTED;   // no mode below ATA_UDMA_MODE_0\r
-    }\r
-\r
-    if (TempMode >= *DisUDmaMode) {\r
-      TempMode = (UINT16) (*DisUDmaMode - 1);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Possible returned mode is between ATA_UDMA_MODE_0 and ATA_UDMA_MODE_5\r
-  //\r
-  *SelectedMode = TempMode;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  The Entry Point of module. It follows the standard UEFI driver model.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS   The entry point is executed successfully.\r
-  @retval other         Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeSataControllerDriver (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-\r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gSataControllerDriverBinding,\r
-             ImageHandle,\r
-             &gSataControllerComponentName,\r
-             &gSataControllerComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Supported function of Driver Binding protocol for this driver.\r
-  Test to see if this driver supports ControllerHandle.\r
-\r
-  @param This                   Protocol instance pointer.\r
-  @param Controller             Handle of device to test.\r
-  @param RemainingDevicePath    A pointer to the device path.\r
-                                it should be ignored by device driver.\r
-\r
-  @retval EFI_SUCCESS           This driver supports this device.\r
-  @retval EFI_ALREADY_STARTED   This driver is already running on this device.\r
-  @retval other                 This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PCI_IO_PROTOCOL   *PciIo;\r
-  PCI_TYPE00            PciData;\r
-\r
-  //\r
-  // Attempt to open PCI I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Now further check the PCI header: Base Class (offset 0x0B) and\r
-  // Sub Class (offset 0x0A). This controller should be an SATA controller\r
-  //\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        PCI_CLASSCODE_OFFSET,\r
-                        sizeof (PciData.Hdr.ClassCode),\r
-                        PciData.Hdr.ClassCode\r
-                        );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (IS_PCI_IDE (&PciData) || IS_PCI_SATADPA (&PciData)) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  This routine is called right after the .Supported() called and \r
-  Start this driver on ControllerHandle.\r
-\r
-  @param This                   Protocol instance pointer.\r
-  @param Controller             Handle of device to bind driver to.\r
-  @param RemainingDevicePath    A pointer to the device path.\r
-                                it should be ignored by device driver.\r
-\r
-  @retval EFI_SUCCESS           This driver is added to this device.\r
-  @retval EFI_ALREADY_STARTED   This driver is already running on this device.\r
-  @retval other                 Some error occurs when binding this driver to this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  PCI_TYPE00                        PciData;\r
-  EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData;\r
-  UINT32                            Data32;\r
-  UINTN                             ChannelDeviceCount;\r
-\r
-  DEBUG ((EFI_D_INFO, "SataControllerStart START\n"));\r
-\r
-  SataPrivateData = NULL;\r
-\r
-  //\r
-  // Now test and open PCI I/O Protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &PciIo,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "SataControllerStart error return status = %r\n", Status));\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Allocate Sata Private Data structure\r
-  //\r
-  SataPrivateData = AllocateZeroPool (sizeof (EFI_SATA_CONTROLLER_PRIVATE_DATA));\r
-  if (SataPrivateData == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Initialize Sata Private Data\r
-  //\r
-  SataPrivateData->Signature = SATA_CONTROLLER_SIGNATURE;\r
-  SataPrivateData->PciIo = PciIo;\r
-  SataPrivateData->IdeInit.GetChannelInfo = IdeInitGetChannelInfo;\r
-  SataPrivateData->IdeInit.NotifyPhase = IdeInitNotifyPhase;\r
-  SataPrivateData->IdeInit.SubmitData = IdeInitSubmitData;\r
-  SataPrivateData->IdeInit.DisqualifyMode = IdeInitDisqualifyMode;\r
-  SataPrivateData->IdeInit.CalculateMode = IdeInitCalculateMode;\r
-  SataPrivateData->IdeInit.SetTiming = IdeInitSetTiming;\r
-  SataPrivateData->IdeInit.EnumAll = SATA_ENUMER_ALL;\r
-\r
-  Status = PciIo->Pci.Read (\r
-                        PciIo,\r
-                        EfiPciIoWidthUint8,\r
-                        PCI_CLASSCODE_OFFSET,\r
-                        sizeof (PciData.Hdr.ClassCode),\r
-                        PciData.Hdr.ClassCode\r
-                        );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  if (IS_PCI_IDE (&PciData)) {\r
-    SataPrivateData->IdeInit.ChannelCount = IDE_MAX_CHANNEL;\r
-    SataPrivateData->DeviceCount = IDE_MAX_DEVICES;\r
-  } else if (IS_PCI_SATADPA (&PciData)) {\r
-    //\r
-    // Read Host Capability Register(CAP) to get Number of Ports(NPS) and Supports Port Multiplier(SPM)\r
-    //   NPS is 0's based value indicating the maximum number of ports supported by the HBA silicon.\r
-    //   A maximum of 32 ports can be supported. A value of '0h', indicating one port, is the minimum requirement.\r
-    //\r
-    Data32 = AhciReadReg (PciIo, R_AHCI_CAP);\r
-    SataPrivateData->IdeInit.ChannelCount = (UINT8) ((Data32 & B_AHCI_CAP_NPS) + 1);\r
-    SataPrivateData->DeviceCount = AHCI_MAX_DEVICES;\r
-    if ((Data32 & B_AHCI_CAP_SPM) == B_AHCI_CAP_SPM) {\r
-      SataPrivateData->DeviceCount = AHCI_MULTI_MAX_DEVICES;\r
-    }\r
-  }\r
-\r
-  ChannelDeviceCount = (UINTN) (SataPrivateData->IdeInit.ChannelCount) * (UINTN) (SataPrivateData->DeviceCount);\r
-  SataPrivateData->DisqualifiedModes = AllocateZeroPool ((sizeof (EFI_ATA_COLLECTIVE_MODE)) * ChannelDeviceCount);\r
-  if (SataPrivateData->DisqualifiedModes == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  SataPrivateData->IdentifyData = AllocateZeroPool ((sizeof (EFI_IDENTIFY_DATA)) * ChannelDeviceCount);\r
-  if (SataPrivateData->IdentifyData == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  SataPrivateData->IdentifyValid = AllocateZeroPool ((sizeof (BOOLEAN)) * ChannelDeviceCount);\r
-  if (SataPrivateData->IdentifyValid == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Install IDE Controller Init Protocol to this instance\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Controller,\r
-                  &gEfiIdeControllerInitProtocolGuid,\r
-                  &(SataPrivateData->IdeInit),\r
-                  NULL\r
-                  );\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    gBS->CloseProtocol (\r
-          Controller,\r
-          &gEfiPciIoProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Controller\r
-          );\r
-    if (SataPrivateData != NULL) {\r
-      if (SataPrivateData->DisqualifiedModes != NULL) {\r
-        FreePool (SataPrivateData->DisqualifiedModes);\r
-      }\r
-      if (SataPrivateData->IdentifyData != NULL) {\r
-        FreePool (SataPrivateData->IdentifyData);\r
-      }\r
-      if (SataPrivateData->IdentifyValid != NULL) {\r
-        FreePool (SataPrivateData->IdentifyValid);\r
-      }\r
-      FreePool (SataPrivateData);\r
-    }\r
-  }\r
-\r
-  DEBUG ((EFI_D_INFO, "SataControllerStart END status = %r\n", Status));\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  @param This               Protocol instance pointer.\r
-  @param Controller         Handle of device to stop driver on.\r
-  @param NumberOfChildren   Not used.\r
-  @param ChildHandleBuffer  Not used.\r
-\r
-  @retval EFI_SUCCESS   This driver is removed from this device.\r
-  @retval other         Some error occurs when removing this driver from this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN UINTN                          NumberOfChildren,\r
-  IN EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL  *IdeInit;\r
-  EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData;\r
-\r
-  //\r
-  // Open the produced protocol\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Controller,\r
-                  &gEfiIdeControllerInitProtocolGuid,\r
-                  (VOID **) &IdeInit,\r
-                  This->DriverBindingHandle,\r
-                  Controller,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (IdeInit);\r
-  ASSERT (SataPrivateData != NULL);\r
-\r
-  //\r
-  // Uninstall the IDE Controller Init Protocol from this instance\r
-  //\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Controller,\r
-                  &gEfiIdeControllerInitProtocolGuid,\r
-                  &(SataPrivateData->IdeInit),\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (SataPrivateData != NULL) {\r
-    if (SataPrivateData->DisqualifiedModes != NULL) {\r
-      FreePool (SataPrivateData->DisqualifiedModes);\r
-    }\r
-    if (SataPrivateData->IdentifyData != NULL) {\r
-      FreePool (SataPrivateData->IdentifyData);\r
-    }\r
-    if (SataPrivateData->IdentifyValid != NULL) {\r
-      FreePool (SataPrivateData->IdentifyValid);\r
-    }\r
-    FreePool (SataPrivateData);\r
-  }\r
-\r
-  //\r
-  // Close protocols opened by Sata Controller driver\r
-  //\r
-  return gBS->CloseProtocol (\r
-                Controller,\r
-                &gEfiPciIoProtocolGuid,\r
-                This->DriverBindingHandle,\r
-                Controller\r
-                );\r
-}\r
-\r
-/**\r
-  Calculate the flat array subscript of a (Channel, Device) pair.\r
-\r
-  @param[in] SataPrivateData  The private data structure corresponding to the\r
-                              SATA controller that attaches the device for\r
-                              which the flat array subscript is being\r
-                              calculated.\r
-\r
-  @param[in] Channel          The channel (ie. port) number on the SATA\r
-                              controller that the device is attached to.\r
-\r
-  @param[in] Device           The device number on the channel.\r
-\r
-  @return  The flat array subscript suitable for indexing DisqualifiedModes,\r
-           IdentifyData, and IdentifyValid.\r
-**/\r
-STATIC\r
-UINTN\r
-FlatDeviceIndex (\r
-  IN CONST EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData,\r
-  IN UINTN                                   Channel,\r
-  IN UINTN                                   Device\r
-  )\r
-{\r
-  ASSERT (SataPrivateData != NULL);\r
-  ASSERT (Channel < SataPrivateData->IdeInit.ChannelCount);\r
-  ASSERT (Device < SataPrivateData->DeviceCount);\r
-\r
-  return Channel * SataPrivateData->DeviceCount + Device;\r
-}\r
-\r
-//\r
-// Interface functions of IDE_CONTROLLER_INIT protocol\r
-//\r
-/**\r
-  Returns the information about the specified IDE channel.\r
-  \r
-  This function can be used to obtain information about a particular IDE channel.\r
-  The driver entity uses this information during the enumeration process. \r
-  \r
-  If Enabled is set to FALSE, the driver entity will not scan the channel. Note \r
-  that it will not prevent an operating system driver from scanning the channel.\r
-  \r
-  For most of today's controllers, MaxDevices will either be 1 or 2. For SATA \r
-  controllers, this value will always be 1. SATA configurations can contain SATA \r
-  port multipliers. SATA port multipliers behave like SATA bridges and can support\r
-  up to 16 devices on the other side. If a SATA port out of the IDE controller \r
-  is connected to a port multiplier, MaxDevices will be set to the number of SATA \r
-  devices that the port multiplier supports. Because today's port multipliers \r
-  support up to fifteen SATA devices, this number can be as large as fifteen. The IDE  \r
-  bus driver is required to scan for the presence of port multipliers behind an SATA \r
-  controller and enumerate up to MaxDevices number of devices behind the port \r
-  multiplier.    \r
-  \r
-  In this context, the devices behind a port multiplier constitute a channel.  \r
-  \r
-  @param[in]  This         The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in]  Channel      Zero-based channel number.\r
-  @param[out] Enabled      TRUE if this channel is enabled.  Disabled channels \r
-                           are not scanned to see if any devices are present.\r
-  @param[out] MaxDevices   The maximum number of IDE devices that the bus driver\r
-                           can expect on this channel.  For the ATA/ATAPI \r
-                           specification, version 6, this number will either be \r
-                           one or two. For Serial ATA (SATA) configurations with a \r
-                           port multiplier, this number can be as large as fifteen.\r
-\r
-  @retval EFI_SUCCESS             Information was returned without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitGetChannelInfo (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  OUT BOOLEAN                           *Enabled,\r
-  OUT UINT8                             *MaxDevices\r
-  )\r
-{\r
-  EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData;\r
-  SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);\r
-  ASSERT (SataPrivateData != NULL);\r
-\r
-  if (Channel < This->ChannelCount) {\r
-    *Enabled = TRUE;\r
-    *MaxDevices = SataPrivateData->DeviceCount;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  *Enabled = FALSE;\r
-  return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-/**\r
-  The notifications from the driver entity that it is about to enter a certain\r
-  phase of the IDE channel enumeration process.\r
-  \r
-  This function can be used to notify the IDE controller driver to perform \r
-  specific actions, including any chipset-specific initialization, so that the \r
-  chipset is ready to enter the next phase. Seven notification points are defined \r
-  at this time. \r
-  \r
-  More synchronization points may be added as required in the future.  \r
-\r
-  @param[in] This      The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Phase     The phase during enumeration.\r
-  @param[in] Channel   Zero-based channel number.\r
-\r
-  @retval EFI_SUCCESS             The notification was accepted without any errors.\r
-  @retval EFI_UNSUPPORTED         Phase is not supported.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_NOT_READY           This phase cannot be entered at this time; for \r
-                                  example, an attempt was made to enter a Phase \r
-                                  without having entered one or more previous \r
-                                  Phase.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitNotifyPhase (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN EFI_IDE_CONTROLLER_ENUM_PHASE      Phase,\r
-  IN UINT8                              Channel\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Submits the device information to the IDE controller driver.\r
-\r
-  This function is used by the driver entity to pass detailed information about \r
-  a particular device to the IDE controller driver. The driver entity obtains \r
-  this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData\r
-  is the pointer to the response data buffer. The IdentifyData buffer is owned \r
-  by the driver entity, and the IDE controller driver must make a local copy \r
-  of the entire buffer or parts of the buffer as needed. The original IdentifyData \r
-  buffer pointer may not be valid when\r
-  \r
-    - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or\r
-    - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.\r
-    \r
-  The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to \r
-  compute the optimum mode for the device. These fields are not limited to the \r
-  timing information. For example, an implementation of the IDE controller driver \r
-  may examine the vendor and type/mode field to match known bad drives.  \r
-  \r
-  The driver entity may submit drive information in any order, as long as it \r
-  submits information for all the devices belonging to the enumeration group \r
-  before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device\r
-  in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r
-  should be called with IdentifyData set to NULL.  The IDE controller driver may \r
-  not have any other mechanism to know whether a device is present or not. Therefore, \r
-  setting IdentifyData to NULL does not constitute an error condition. \r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a \r
-  given (Channel, Device) pair.  \r
-    \r
-  @param[in] This           A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Channel        Zero-based channel number.\r
-  @param[in] Device         Zero-based device number on the Channel.\r
-  @param[in] IdentifyData   The device's response to the ATA IDENTIFY_DEVICE command.\r
-\r
-  @retval EFI_SUCCESS             The information was accepted without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitSubmitData (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  IN EFI_IDENTIFY_DATA                  *IdentifyData\r
-  )\r
-{\r
-  EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData;\r
-  UINTN                             DeviceIndex;\r
-\r
-  SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);\r
-  ASSERT (SataPrivateData != NULL);\r
-\r
-  if ((Channel >= This->ChannelCount) || (Device >= SataPrivateData->DeviceCount)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device);\r
-\r
-  //\r
-  // Make a local copy of device's IdentifyData and mark the valid flag\r
-  //\r
-  if (IdentifyData != NULL) {\r
-    CopyMem (\r
-      &(SataPrivateData->IdentifyData[DeviceIndex]),\r
-      IdentifyData,\r
-      sizeof (EFI_IDENTIFY_DATA)\r
-      );\r
-\r
-    SataPrivateData->IdentifyValid[DeviceIndex] = TRUE;\r
-  } else {\r
-    SataPrivateData->IdentifyValid[DeviceIndex] = FALSE;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Disqualifies specific modes for an IDE device.\r
-\r
-  This function allows the driver entity or other drivers (such as platform \r
-  drivers) to reject certain timing modes and request the IDE controller driver\r
-  to recalculate modes. This function allows the driver entity and the IDE \r
-  controller driver to negotiate the timings on a per-device basis. This function \r
-  is useful in the case of drives that lie about their capabilities. An example \r
-  is when the IDE device fails to accept the timing modes that are calculated \r
-  by the IDE controller driver based on the response to the Identify Drive command.\r
-\r
-  If the driver entity does not want to limit the ATA timing modes and leave that \r
-  decision to the IDE controller driver, it can either not call this function for \r
-  the given device or call this function and set the Valid flag to FALSE for all \r
-  modes that are listed in EFI_ATA_COLLECTIVE_MODE.\r
-  \r
-  The driver entity may disqualify modes for a device in any order and any number \r
-  of times.\r
-  \r
-  This function can be called multiple times to invalidate multiple modes of the \r
-  same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI \r
-  specification for more information on PIO modes.  \r
-  \r
-  For Serial ATA (SATA) controllers, this member function can be used to disqualify\r
-  a higher transfer rate mode on a given channel. For example, a platform driver\r
-  may inform the IDE controller driver to not use second-generation (Gen2) speeds \r
-  for a certain SATA drive.\r
-  \r
-  @param[in] This       The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Channel    The zero-based channel number.\r
-  @param[in] Device     The zero-based device number on the Channel.\r
-  @param[in] BadModes   The modes that the device does not support and that\r
-                        should be disqualified.\r
-\r
-  @retval EFI_SUCCESS             The modes were accepted without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid.\r
-  @retval EFI_INVALID_PARAMETER   IdentifyData is NULL.\r
-                                \r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitDisqualifyMode (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  IN EFI_ATA_COLLECTIVE_MODE            *BadModes\r
-  )\r
-{\r
-  EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData;\r
-  UINTN                             DeviceIndex;\r
-\r
-  SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);\r
-  ASSERT (SataPrivateData != NULL);\r
-\r
-  if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >= SataPrivateData->DeviceCount)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device);\r
-\r
-  //\r
-  // Record the disqualified modes per channel per device. From ATA/ATAPI spec,\r
-  // if a mode is not supported, the modes higher than it is also not supported.\r
-  //\r
-  CopyMem (\r
-    &(SataPrivateData->DisqualifiedModes[DeviceIndex]),\r
-    BadModes,\r
-    sizeof (EFI_ATA_COLLECTIVE_MODE)\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Returns the information about the optimum modes for the specified IDE device.\r
-\r
-  This function is used by the driver entity to obtain the optimum ATA modes for\r
-  a specific device.  The IDE controller driver takes into account the following \r
-  while calculating the mode:\r
-    - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r
-    - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()\r
-\r
-  The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() \r
-  for all the devices that belong to an enumeration group before calling \r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.  \r
-  \r
-  The IDE controller driver will use controller- and possibly platform-specific \r
-  algorithms to arrive at SupportedModes.  The IDE controller may base its \r
-  decision on user preferences and other considerations as well. This function \r
-  may be called multiple times because the driver entity may renegotiate the mode \r
-  with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().\r
-    \r
-  The driver entity may collect timing information for various devices in any \r
-  order. The driver entity is responsible for making sure that all the dependencies\r
-  are satisfied. For example, the SupportedModes information for device A that \r
-  was previously returned may become stale after a call to \r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.\r
-  \r
-  The buffer SupportedModes is allocated by the callee because the caller does \r
-  not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE \r
-  is defined in a way that allows for future extensibility and can be of variable \r
-  length. This memory pool should be deallocated by the caller when it is no \r
-  longer necessary.  \r
-  \r
-  The IDE controller driver for a Serial ATA (SATA) controller can use this \r
-  member function to force a lower speed (first-generation [Gen1] speeds on a \r
-  second-generation [Gen2]-capable hardware).  The IDE controller driver can \r
-  also allow the driver entity to stay with the speed that has been negotiated \r
-  by the physical layer.\r
-  \r
-  @param[in]  This             The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in]  Channel          A zero-based channel number.\r
-  @param[in]  Device           A zero-based device number on the Channel.\r
-  @param[out] SupportedModes   The optimum modes for the device.\r
-\r
-  @retval EFI_SUCCESS             SupportedModes was returned.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid. \r
-  @retval EFI_INVALID_PARAMETER   SupportedModes is NULL.\r
-  @retval EFI_NOT_READY           Modes cannot be calculated due to a lack of \r
-                                  data.  This error may happen if \r
-                                  EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() \r
-                                  and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData() \r
-                                  were not called for at least one drive in the \r
-                                  same enumeration group.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitCalculateMode (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  OUT EFI_ATA_COLLECTIVE_MODE           **SupportedModes\r
-  )\r
-{\r
-  EFI_SATA_CONTROLLER_PRIVATE_DATA  *SataPrivateData;\r
-  EFI_IDENTIFY_DATA                 *IdentifyData;\r
-  BOOLEAN                           IdentifyValid;\r
-  EFI_ATA_COLLECTIVE_MODE           *DisqualifiedModes;\r
-  UINT16                            SelectedMode;\r
-  EFI_STATUS                        Status;\r
-  UINTN                             DeviceIndex;\r
-\r
-  SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);\r
-  ASSERT (SataPrivateData != NULL);\r
-\r
-  if ((Channel >= This->ChannelCount) || (SupportedModes == NULL) || (Device >= SataPrivateData->DeviceCount)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *SupportedModes = AllocateZeroPool (sizeof (EFI_ATA_COLLECTIVE_MODE));\r
-  if (*SupportedModes == NULL) {\r
-    ASSERT (*SupportedModes != NULL);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device);\r
-\r
-  IdentifyData = &(SataPrivateData->IdentifyData[DeviceIndex]);\r
-  IdentifyValid = SataPrivateData->IdentifyValid[DeviceIndex];\r
-  DisqualifiedModes = &(SataPrivateData->DisqualifiedModes[DeviceIndex]);\r
-\r
-  //\r
-  // Make sure we've got the valid identify data of the device from SubmitData()\r
-  //\r
-  if (!IdentifyValid) {\r
-    FreePool (*SupportedModes);\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  Status = CalculateBestPioMode (\r
-            IdentifyData,\r
-            (DisqualifiedModes->PioMode.Valid ? ((UINT16 *) &(DisqualifiedModes->PioMode.Mode)) : NULL),\r
-            &SelectedMode\r
-            );\r
-  if (!EFI_ERROR (Status)) {\r
-    (*SupportedModes)->PioMode.Valid = TRUE;\r
-    (*SupportedModes)->PioMode.Mode = SelectedMode;\r
-\r
-  } else {\r
-    (*SupportedModes)->PioMode.Valid = FALSE;\r
-  }\r
-  DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: PioMode = %x\n", (*SupportedModes)->PioMode.Mode));\r
-\r
-  Status = CalculateBestUdmaMode (\r
-            IdentifyData,\r
-            (DisqualifiedModes->UdmaMode.Valid ? ((UINT16 *) &(DisqualifiedModes->UdmaMode.Mode)) : NULL),\r
-            &SelectedMode\r
-            );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    (*SupportedModes)->UdmaMode.Valid = TRUE;\r
-    (*SupportedModes)->UdmaMode.Mode  = SelectedMode;\r
-\r
-  } else {\r
-    (*SupportedModes)->UdmaMode.Valid = FALSE;\r
-  }\r
-  DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: UdmaMode = %x\n", (*SupportedModes)->UdmaMode.Mode));\r
-\r
-  //\r
-  // The modes other than PIO and UDMA are not supported\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Commands the IDE controller driver to program the IDE controller hardware\r
-  so that the specified device can operate at the specified mode.\r
-\r
-  This function is used by the driver entity to instruct the IDE controller \r
-  driver to program the IDE controller hardware to the specified modes. This \r
-  function can be called only once for a particular device. For a Serial ATA \r
-  (SATA) Advanced Host Controller Interface (AHCI) controller, no controller-\r
-  specific programming may be required.\r
-\r
-  @param[in] This      Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Channel   Zero-based channel number.\r
-  @param[in] Device    Zero-based device number on the Channel.\r
-  @param[in] Modes     The modes to set.\r
-\r
-  @retval EFI_SUCCESS             The command was accepted without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid.\r
-  @retval EFI_NOT_READY           Modes cannot be set at this time due to lack of data.\r
-  @retval EFI_DEVICE_ERROR        Modes cannot be set due to hardware failure.\r
-                                  The driver entity should not use this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitSetTiming (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  IN EFI_ATA_COLLECTIVE_MODE            *Modes\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/DuetPkg/SataControllerDxe/SataController.h b/DuetPkg/SataControllerDxe/SataController.h
deleted file mode 100644 (file)
index a6c6c16..0000000
+++ /dev/null
@@ -1,542 +0,0 @@
-/** @file\r
-  Header file for Sata Controller driver.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  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
-\r
-#ifndef _SATA_CONTROLLER_H_\r
-#define _SATA_CONTROLLER_H_\r
-\r
-#include <Uefi.h>\r
-#include <Protocol/ComponentName.h>\r
-#include <Protocol/DriverBinding.h>\r
-#include <Protocol/PciIo.h>\r
-#include <Protocol/IdeControllerInit.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <IndustryStandard/Pci.h>\r
-\r
-//\r
-// Global Variables definitions\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gSataControllerDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gSataControllerComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2;\r
-\r
-#define AHCI_BAR_INDEX 0x05\r
-#define R_AHCI_CAP 0x0\r
-#define   B_AHCI_CAP_NPS (BIT4 | BIT3 | BIT2 | BIT1 | BIT0) // Number of Ports\r
-#define   B_AHCI_CAP_SPM BIT17 // Supports Port Multiplier\r
-\r
-///\r
-/// AHCI each channel can have up to 1 device\r
-///\r
-#define AHCI_MAX_DEVICES 0x01\r
-\r
-///\r
-/// AHCI each channel can have 15 devices in the presence of a multiplier\r
-///\r
-#define AHCI_MULTI_MAX_DEVICES 0x0F\r
-\r
-///\r
-/// IDE supports 2 channel max\r
-///\r
-#define IDE_MAX_CHANNEL 0x02\r
-\r
-///\r
-/// IDE supports 2 devices max\r
-///\r
-#define IDE_MAX_DEVICES 0x02\r
-\r
-#define SATA_ENUMER_ALL FALSE\r
-\r
-//\r
-// Sata Controller driver private data structure\r
-//\r
-\r
-#define SATA_CONTROLLER_SIGNATURE SIGNATURE_32('S','A','T','A')\r
-\r
-typedef struct _EFI_SATA_CONTROLLER_PRIVATE_DATA {\r
-  //\r
-  // Standard signature used to identify Sata Controller private data\r
-  //\r
-  UINT32                            Signature;\r
-\r
-  //\r
-  // Protocol instance of IDE_CONTROLLER_INIT produced by this driver\r
-  //\r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL  IdeInit;\r
-\r
-  //\r
-  // Copy of protocol pointers used by this driver\r
-  //\r
-  EFI_PCI_IO_PROTOCOL               *PciIo;\r
-\r
-  //\r
-  // The number of devices that are supported by this channel\r
-  //\r
-  UINT8                             DeviceCount;\r
-\r
-  //\r
-  // The highest disqulified mode for each attached device,\r
-  // From ATA/ATAPI spec, if a mode is not supported,\r
-  // the modes higher than it is also not supported\r
-  //\r
-  EFI_ATA_COLLECTIVE_MODE           *DisqualifiedModes;\r
-\r
-  //\r
-  // A copy of EFI_IDENTIFY_DATA data for each attached SATA device and its flag\r
-  //\r
-  EFI_IDENTIFY_DATA                 *IdentifyData;\r
-  BOOLEAN                           *IdentifyValid;\r
-} EFI_SATA_CONTROLLER_PRIVATE_DATA;\r
-\r
-#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE)\r
-\r
-//\r
-// Driver binding functions declaration\r
-//\r
-/**\r
-  Supported function of Driver Binding protocol for this driver.\r
-  Test to see if this driver supports ControllerHandle.\r
-\r
-  @param This                   Protocol instance pointer.\r
-  @param Controller             Handle of device to test.\r
-  @param RemainingDevicePath    A pointer to the device path. Should be ignored by\r
-                                device driver.\r
-\r
-  @retval EFI_SUCCESS           This driver supports this device.\r
-  @retval EFI_ALREADY_STARTED   This driver is already running on this device.\r
-  @retval other                 This driver does not support this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  This routine is called right after the .Supported() called and \r
-  Start this driver on ControllerHandle.\r
-\r
-  @param This                   Protocol instance pointer.\r
-  @param Controller             Handle of device to bind driver to.\r
-  @param RemainingDevicePath    A pointer to the device path. Should be ignored by\r
-                                device driver.\r
-\r
-  @retval EFI_SUCCESS           This driver is added to this device.\r
-  @retval EFI_ALREADY_STARTED   This driver is already running on this device.\r
-  @retval other                 Some error occurs when binding this driver to this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-;\r
-\r
-/**\r
-  Stop this driver on ControllerHandle.\r
-\r
-  @param This               Protocol instance pointer.\r
-  @param Controller         Handle of device to stop driver on.\r
-  @param NumberOfChildren   Not used.\r
-  @param ChildHandleBuffer  Not used.\r
-\r
-  @retval EFI_SUCCESS   This driver is removed from this device.\r
-  @retval other         Some error occurs when removing this driver from this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN UINTN                          NumberOfChildren,\r
-  IN EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-;\r
-\r
-//\r
-// IDE controller init functions declaration\r
-//\r
-/**\r
-  Returns the information about the specified IDE channel.\r
-  \r
-  This function can be used to obtain information about a particular IDE channel.\r
-  The driver entity uses this information during the enumeration process. \r
-  \r
-  If Enabled is set to FALSE, the driver entity will not scan the channel. Note \r
-  that it will not prevent an operating system driver from scanning the channel.\r
-  \r
-  For most of today's controllers, MaxDevices will either be 1 or 2. For SATA \r
-  controllers, this value will always be 1. SATA configurations can contain SATA \r
-  port multipliers. SATA port multipliers behave like SATA bridges and can support\r
-  up to 16 devices on the other side. If a SATA port out of the IDE controller \r
-  is connected to a port multiplier, MaxDevices will be set to the number of SATA \r
-  devices that the port multiplier supports. Because today's port multipliers \r
-  support up to fifteen SATA devices, this number can be as large as fifteen. The IDE  \r
-  bus driver is required to scan for the presence of port multipliers behind an SATA \r
-  controller and enumerate up to MaxDevices number of devices behind the port \r
-  multiplier.    \r
-  \r
-  In this context, the devices behind a port multiplier constitute a channel.  \r
-  \r
-  @param[in]  This         The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in]  Channel      Zero-based channel number.\r
-  @param[out] Enabled      TRUE if this channel is enabled.  Disabled channels \r
-                           are not scanned to see if any devices are present.\r
-  @param[out] MaxDevices   The maximum number of IDE devices that the bus driver\r
-                           can expect on this channel.  For the ATA/ATAPI \r
-                           specification, version 6, this number will either be \r
-                           one or two. For Serial ATA (SATA) configurations with a \r
-                           port multiplier, this number can be as large as fifteen.\r
-\r
-  @retval EFI_SUCCESS             Information was returned without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitGetChannelInfo (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  OUT BOOLEAN                           *Enabled,\r
-  OUT UINT8                             *MaxDevices\r
-  )\r
-;\r
-\r
-/**\r
-  The notifications from the driver entity that it is about to enter a certain\r
-  phase of the IDE channel enumeration process.\r
-  \r
-  This function can be used to notify the IDE controller driver to perform \r
-  specific actions, including any chipset-specific initialization, so that the \r
-  chipset is ready to enter the next phase. Seven notification points are defined \r
-  at this time. \r
-  \r
-  More synchronization points may be added as required in the future.  \r
-\r
-  @param[in] This      The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Phase     The phase during enumeration.\r
-  @param[in] Channel   Zero-based channel number.\r
-\r
-  @retval EFI_SUCCESS             The notification was accepted without any errors.\r
-  @retval EFI_UNSUPPORTED         Phase is not supported.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_NOT_READY           This phase cannot be entered at this time; for \r
-                                  example, an attempt was made to enter a Phase \r
-                                  without having entered one or more previous \r
-                                  Phase.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitNotifyPhase (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN EFI_IDE_CONTROLLER_ENUM_PHASE      Phase,\r
-  IN UINT8                              Channel\r
-  )\r
-;\r
-\r
-/**\r
-  Submits the device information to the IDE controller driver.\r
-\r
-  This function is used by the driver entity to pass detailed information about \r
-  a particular device to the IDE controller driver. The driver entity obtains \r
-  this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData\r
-  is the pointer to the response data buffer. The IdentifyData buffer is owned \r
-  by the driver entity, and the IDE controller driver must make a local copy \r
-  of the entire buffer or parts of the buffer as needed. The original IdentifyData \r
-  buffer pointer may not be valid when\r
-  \r
-    - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or\r
-    - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.\r
-    \r
-  The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to \r
-  compute the optimum mode for the device. These fields are not limited to the \r
-  timing information. For example, an implementation of the IDE controller driver \r
-  may examine the vendor and type/mode field to match known bad drives.  \r
-  \r
-  The driver entity may submit drive information in any order, as long as it \r
-  submits information for all the devices belonging to the enumeration group \r
-  before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device\r
-  in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r
-  should be called with IdentifyData set to NULL.  The IDE controller driver may \r
-  not have any other mechanism to know whether a device is present or not. Therefore, \r
-  setting IdentifyData to NULL does not constitute an error condition. \r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a \r
-  given (Channel, Device) pair.  \r
-    \r
-  @param[in] This           A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Channel        Zero-based channel number.\r
-  @param[in] Device         Zero-based device number on the Channel.\r
-  @param[in] IdentifyData   The device's response to the ATA IDENTIFY_DEVICE command.\r
-\r
-  @retval EFI_SUCCESS             The information was accepted without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitSubmitData (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  IN EFI_IDENTIFY_DATA                  *IdentifyData\r
-  )\r
-;\r
-\r
-/**\r
-  Disqualifies specific modes for an IDE device.\r
-\r
-  This function allows the driver entity or other drivers (such as platform \r
-  drivers) to reject certain timing modes and request the IDE controller driver\r
-  to recalculate modes. This function allows the driver entity and the IDE \r
-  controller driver to negotiate the timings on a per-device basis. This function \r
-  is useful in the case of drives that lie about their capabilities. An example \r
-  is when the IDE device fails to accept the timing modes that are calculated \r
-  by the IDE controller driver based on the response to the Identify Drive command.\r
-\r
-  If the driver entity does not want to limit the ATA timing modes and leave that \r
-  decision to the IDE controller driver, it can either not call this function for \r
-  the given device or call this function and set the Valid flag to FALSE for all \r
-  modes that are listed in EFI_ATA_COLLECTIVE_MODE.\r
-  \r
-  The driver entity may disqualify modes for a device in any order and any number \r
-  of times.\r
-  \r
-  This function can be called multiple times to invalidate multiple modes of the \r
-  same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI \r
-  specification for more information on PIO modes.  \r
-  \r
-  For Serial ATA (SATA) controllers, this member function can be used to disqualify\r
-  a higher transfer rate mode on a given channel. For example, a platform driver\r
-  may inform the IDE controller driver to not use second-generation (Gen2) speeds \r
-  for a certain SATA drive.\r
-  \r
-  @param[in] This       The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Channel    The zero-based channel number.\r
-  @param[in] Device     The zero-based device number on the Channel.\r
-  @param[in] BadModes   The modes that the device does not support and that\r
-                        should be disqualified.\r
-\r
-  @retval EFI_SUCCESS             The modes were accepted without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid.\r
-  @retval EFI_INVALID_PARAMETER   IdentifyData is NULL.\r
-                                \r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitDisqualifyMode (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  IN EFI_ATA_COLLECTIVE_MODE            *BadModes\r
-  )\r
-;\r
-\r
-/**\r
-  Returns the information about the optimum modes for the specified IDE device.\r
-\r
-  This function is used by the driver entity to obtain the optimum ATA modes for\r
-  a specific device.  The IDE controller driver takes into account the following \r
-  while calculating the mode:\r
-    - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r
-    - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()\r
-\r
-  The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() \r
-  for all the devices that belong to an enumeration group before calling \r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.  \r
-  \r
-  The IDE controller driver will use controller- and possibly platform-specific \r
-  algorithms to arrive at SupportedModes.  The IDE controller may base its \r
-  decision on user preferences and other considerations as well. This function \r
-  may be called multiple times because the driver entity may renegotiate the mode \r
-  with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().\r
-    \r
-  The driver entity may collect timing information for various devices in any \r
-  order. The driver entity is responsible for making sure that all the dependencies\r
-  are satisfied. For example, the SupportedModes information for device A that \r
-  was previously returned may become stale after a call to \r
-  EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.\r
-  \r
-  The buffer SupportedModes is allocated by the callee because the caller does \r
-  not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE \r
-  is defined in a way that allows for future extensibility and can be of variable \r
-  length. This memory pool should be deallocated by the caller when it is no \r
-  longer necessary.  \r
-  \r
-  The IDE controller driver for a Serial ATA (SATA) controller can use this \r
-  member function to force a lower speed (first-generation [Gen1] speeds on a \r
-  second-generation [Gen2]-capable hardware).  The IDE controller driver can \r
-  also allow the driver entity to stay with the speed that has been negotiated \r
-  by the physical layer.\r
-  \r
-  @param[in]  This             The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in]  Channel          A zero-based channel number.\r
-  @param[in]  Device           A zero-based device number on the Channel.\r
-  @param[out] SupportedModes   The optimum modes for the device.\r
-\r
-  @retval EFI_SUCCESS             SupportedModes was returned.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid. \r
-  @retval EFI_INVALID_PARAMETER   SupportedModes is NULL.\r
-  @retval EFI_NOT_READY           Modes cannot be calculated due to a lack of \r
-                                  data.  This error may happen if \r
-                                  EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() \r
-                                  and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData() \r
-                                  were not called for at least one drive in the \r
-                                  same enumeration group.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitCalculateMode (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  OUT EFI_ATA_COLLECTIVE_MODE           **SupportedModes\r
-  )\r
-;\r
-\r
-/**\r
-  Commands the IDE controller driver to program the IDE controller hardware\r
-  so that the specified device can operate at the specified mode.\r
-\r
-  This function is used by the driver entity to instruct the IDE controller \r
-  driver to program the IDE controller hardware to the specified modes. This \r
-  function can be called only once for a particular device. For a Serial ATA \r
-  (SATA) Advanced Host Controller Interface (AHCI) controller, no controller-\r
-  specific programming may be required.\r
-\r
-  @param[in] This      Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
-  @param[in] Channel   Zero-based channel number.\r
-  @param[in] Device    Zero-based device number on the Channel.\r
-  @param[in] Modes     The modes to set.\r
-\r
-  @retval EFI_SUCCESS             The command was accepted without any errors.\r
-  @retval EFI_INVALID_PARAMETER   Channel is invalid (Channel >= ChannelCount).\r
-  @retval EFI_INVALID_PARAMETER   Device is invalid.\r
-  @retval EFI_NOT_READY           Modes cannot be set at this time due to lack of data.\r
-  @retval EFI_DEVICE_ERROR        Modes cannot be set due to hardware failure.\r
-                                  The driver entity should not use this device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IdeInitSetTiming (\r
-  IN EFI_IDE_CONTROLLER_INIT_PROTOCOL   *This,\r
-  IN UINT8                              Channel,\r
-  IN UINT8                              Device,\r
-  IN EFI_ATA_COLLECTIVE_MODE            *Modes\r
-  )\r
-;\r
-\r
-//\r
-// Forward reference declaration\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the UEFI Driver.\r
-\r
-  @param This           A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param 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
-  @param 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
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by This\r
-                                and the language specified by Language was returned\r
-                                in DriverName.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support the\r
-                                language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerComponentNameGetDriverName (\r
-  IN EFI_COMPONENT_NAME_PROTOCOL    *This,\r
-  IN CHAR8                          *Language,\r
-  OUT CHAR16                        **DriverName\r
-  )\r
-;\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by an UEFI Driver.\r
-\r
-  @param This                   A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-  @param 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
-  @param OPTIONAL   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
-  @param 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
-  @param 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\r
-                                specified by Language from the point of view of the\r
-                                driver specified by This.\r
-\r
-  @retval 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
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support the\r
-                                language specified by Language.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SataControllerComponentNameGetControllerName (\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
-#endif\r
diff --git a/DuetPkg/SataControllerDxe/SataControllerDxe.inf b/DuetPkg/SataControllerDxe/SataControllerDxe.inf
deleted file mode 100644 (file)
index 2786404..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file\r
-#  \r
-#    Component description file for the Sata Controller driver.\r
-#\r
-#  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-#  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
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SataController\r
-  FILE_GUID                      = 8F4CD826-A5A0-4e93-9522-CFB0AB72926C\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = InitializeSataControllerDriver\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  SataController.c\r
-  SataController.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiDriverEntryPoint\r
-  DebugLib\r
-  UefiLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-\r
-[Protocols]\r
-  gEfiPciIoProtocolGuid  \r
-  gEfiIdeControllerInitProtocolGuid\r
diff --git a/DuetPkg/SmbiosGenDxe/SmbiosGen.c b/DuetPkg/SmbiosGenDxe/SmbiosGen.c
deleted file mode 100644 (file)
index 393bb4d..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-  SmbiosGen.c\r
-\r
-Abstract:\r
-\r
-**/\r
-\r
-#include "SmbiosGen.h"\r
-extern UINT8                SmbiosGenDxeStrings[];\r
-EFI_SMBIOS_PROTOCOL         *gSmbios;\r
-EFI_HII_HANDLE              gStringHandle;\r
-\r
-VOID *\r
-GetSmbiosTablesFromHob (\r
-  VOID\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS       *Table;\r
-  EFI_PEI_HOB_POINTERS        GuidHob;\r
-\r
-  GuidHob.Raw = GetFirstGuidHob (&gEfiSmbiosTableGuid);\r
-  if (GuidHob.Raw != NULL) {\r
-    Table = GET_GUID_HOB_DATA (GuidHob.Guid);\r
-    if (Table != NULL) {\r
-      return (VOID *)(UINTN)*Table;\r
-    }\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-\r
-VOID\r
-InstallProcessorSmbios (\r
-  IN VOID                  *Smbios\r
-  )\r
-{\r
-  SMBIOS_STRUCTURE_POINTER          SmbiosTable;\r
-  CHAR8                             *AString;\r
-  CHAR16                            *UString;\r
-  STRING_REF                        Token;\r
-\r
-  //\r
-  // Processor info (TYPE 4)\r
-  // \r
-  SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 4, 0);\r
-  if (SmbiosTable.Raw == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 4 (Processor Info) not found!\n"));\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Log Smbios Record Type4\r
-  //\r
-  LogSmbiosData(gSmbios,(UINT8*)SmbiosTable.Type4);\r
-\r
-  //\r
-  // Set ProcessorVersion string\r
-  //\r
-  AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type4->ProcessorVersion);\r
-  UString = AllocateZeroPool ((AsciiStrLen(AString) + 1) * sizeof(CHAR16));\r
-  ASSERT (UString != NULL);\r
-  AsciiStrToUnicodeStr (AString, UString);\r
-\r
-  Token = HiiSetString (gStringHandle, 0, UString, NULL);\r
-  if (Token == 0) {\r
-    gBS->FreePool (UString);\r
-    return ;\r
-  }\r
-  gBS->FreePool (UString);\r
-  return ;\r
-}\r
-\r
-VOID\r
-InstallCacheSmbios (\r
-  IN VOID                  *Smbios\r
-  )\r
-{\r
-  return ;\r
-}\r
-\r
-VOID\r
-InstallMemorySmbios (\r
-  IN VOID                  *Smbios\r
-  )\r
-{\r
-  SMBIOS_STRUCTURE_POINTER          SmbiosTable;\r
-\r
-  //\r
-  // Generate Memory Array Mapped Address info (TYPE 19)\r
-  //\r
-  SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 19, 0);\r
-  if (SmbiosTable.Raw == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 19 (Memory Array Mapped Address Info) not found!\n"));\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Record Smbios Type 19\r
-  //\r
-  LogSmbiosData(gSmbios, (UINT8*)SmbiosTable.Type19);\r
-  return ;\r
-}\r
-\r
-VOID\r
-InstallMiscSmbios (\r
-  IN VOID                  *Smbios\r
-  )\r
-{\r
-  SMBIOS_STRUCTURE_POINTER          SmbiosTable;\r
-  CHAR8                             *AString;\r
-  CHAR16                            *UString;\r
-  STRING_REF                        Token;\r
-\r
-  //\r
-  // BIOS information (TYPE 0)\r
-  // \r
-  SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 0, 0);\r
-  if (SmbiosTable.Raw == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 0 (BIOS Information) not found!\n"));\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Record Type 2\r
-  //\r
-  AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type0->BiosVersion);\r
-  UString = AllocateZeroPool ((AsciiStrLen(AString) + 1) * sizeof(CHAR16) + sizeof(FIRMWARE_BIOS_VERSIONE));\r
-  ASSERT (UString != NULL);\r
-  CopyMem (UString, FIRMWARE_BIOS_VERSIONE, sizeof(FIRMWARE_BIOS_VERSIONE));\r
-  AsciiStrToUnicodeStr (AString, UString + sizeof(FIRMWARE_BIOS_VERSIONE) / sizeof(CHAR16) - 1);\r
-\r
-  Token = HiiSetString (gStringHandle, 0, UString, NULL);\r
-  if (Token == 0) {\r
-    gBS->FreePool (UString);\r
-    return ;\r
-  }\r
-  gBS->FreePool (UString);\r
-\r
-  //\r
-  // Log Smios Type 0\r
-  //\r
-  LogSmbiosData(gSmbios, (UINT8*)SmbiosTable.Type0);\r
-  \r
-  //\r
-  // System information (TYPE 1)\r
-  // \r
-  SmbiosTable = GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT *)Smbios, 1, 0);\r
-  if (SmbiosTable.Raw == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "SmbiosTable: Type 1 (System Information) not found!\n"));\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Record Type 3\r
-  //\r
-  AString = GetSmbiosString (SmbiosTable, SmbiosTable.Type1->ProductName);\r
-  UString = AllocateZeroPool ((AsciiStrLen(AString) + 1) * sizeof(CHAR16) + sizeof(FIRMWARE_PRODUCT_NAME));\r
-  ASSERT (UString != NULL);\r
-  CopyMem (UString, FIRMWARE_PRODUCT_NAME, sizeof(FIRMWARE_PRODUCT_NAME));\r
-  AsciiStrToUnicodeStr (AString, UString + sizeof(FIRMWARE_PRODUCT_NAME) / sizeof(CHAR16) - 1);\r
-\r
-  Token = HiiSetString (gStringHandle, 0, UString, NULL);\r
-  if (Token == 0) {\r
-    gBS->FreePool (UString);\r
-    return ;\r
-  }\r
-  gBS->FreePool (UString);\r
-\r
-  //\r
-  // Log Smbios Type 1\r
-  //\r
-  LogSmbiosData(gSmbios, (UINT8*)SmbiosTable.Type1);\r
-  \r
-  return ;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SmbiosGenEntrypoint (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  VOID                    *Smbios;\r
-\r
-  Smbios = GetSmbiosTablesFromHob ();\r
-  if (Smbios == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiSmbiosProtocolGuid,\r
-                  NULL,\r
-                  (VOID**)&gSmbios\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  gStringHandle = HiiAddPackages (\r
-                    &gEfiCallerIdGuid,\r
-                    NULL,\r
-                    SmbiosGenDxeStrings,\r
-                    NULL\r
-                    );\r
-  ASSERT (gStringHandle != NULL);\r
-\r
-  InstallProcessorSmbios (Smbios);\r
-  InstallCacheSmbios     (Smbios);\r
-  InstallMemorySmbios    (Smbios);\r
-  InstallMiscSmbios      (Smbios);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-//\r
-// Internal function\r
-//\r
-\r
-UINTN\r
-SmbiosTableLength (\r
-  IN SMBIOS_STRUCTURE_POINTER SmbiosTable\r
-  )\r
-{\r
-  CHAR8  *AChar;\r
-  UINTN  Length;\r
-\r
-  AChar = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Hdr->Length);\r
-  while ((*AChar != 0) || (*(AChar + 1) != 0)) {\r
-    AChar ++;\r
-  }\r
-  Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2);\r
-  \r
-  return Length;\r
-}\r
-\r
-SMBIOS_STRUCTURE_POINTER\r
-GetSmbiosTableFromType (\r
-  IN SMBIOS_TABLE_ENTRY_POINT  *Smbios,\r
-  IN UINT8                     Type,\r
-  IN UINTN                     Index\r
-  )\r
-{\r
-  SMBIOS_STRUCTURE_POINTER SmbiosTable;\r
-  UINTN                    SmbiosTypeIndex;\r
-  \r
-  SmbiosTypeIndex = 0;\r
-  SmbiosTable.Raw = (UINT8 *)(UINTN)Smbios->TableAddress;\r
-  if (SmbiosTable.Raw == NULL) {\r
-    return SmbiosTable;\r
-  }\r
-  while ((SmbiosTypeIndex != Index) || (SmbiosTable.Hdr->Type != Type)) {\r
-    if (SmbiosTable.Hdr->Type == 127) {\r
-      SmbiosTable.Raw = NULL;\r
-      return SmbiosTable;\r
-    }\r
-    if (SmbiosTable.Hdr->Type == Type) {\r
-      SmbiosTypeIndex ++;\r
-    }\r
-    SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (SmbiosTable));\r
-  }\r
-\r
-  return SmbiosTable;\r
-}\r
-\r
-CHAR8 *\r
-GetSmbiosString (\r
-  IN SMBIOS_STRUCTURE_POINTER  SmbiosTable,\r
-  IN SMBIOS_TABLE_STRING       String\r
-  )\r
-{\r
-  CHAR8      *AString;\r
-  UINT8      Index;\r
-\r
-  Index = 1;\r
-  AString = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Hdr->Length);\r
-  while (Index != String) {\r
-    while (*AString != 0) {\r
-      AString ++;\r
-    }\r
-    AString ++;\r
-    if (*AString == 0) {\r
-      return AString;\r
-    }\r
-    Index ++;\r
-  }\r
-\r
-  return AString;\r
-}\r
-\r
-\r
-/**\r
-  Logs SMBIOS record.\r
-\r
-  @param  Smbios   Pointer to SMBIOS protocol instance.\r
-  @param  Buffer   Pointer to the data buffer.\r
-\r
-**/\r
-VOID\r
-LogSmbiosData (\r
-  IN   EFI_SMBIOS_PROTOCOL        *Smbios,\r
-  IN   UINT8                      *Buffer\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  EFI_SMBIOS_HANDLE  SmbiosHandle;\r
-  \r
-  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
-  Status = Smbios->Add (\r
-                     Smbios,\r
-                     NULL,\r
-                     &SmbiosHandle,\r
-                     (EFI_SMBIOS_TABLE_HEADER*)Buffer\r
-                     );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
diff --git a/DuetPkg/SmbiosGenDxe/SmbiosGen.h b/DuetPkg/SmbiosGenDxe/SmbiosGen.h
deleted file mode 100644 (file)
index 3a42e22..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-  DataHubGen.h\r
-\r
-Abstract:\r
-\r
-**/\r
-\r
-#ifndef _SMBIOS_GEN_H_\r
-#define _SMBIOS_GEN_H_\r
-\r
-#include <FrameworkDxe.h>\r
-#include <IndustryStandard/SmBios.h>\r
-\r
-#include <Guid/HobList.h>\r
-#include <Guid/SmBios.h>\r
-#include <Guid/DataHubRecords.h>\r
-\r
-#include <Protocol/Smbios.h>\r
-#include <Protocol/FrameworkHii.h>\r
-#include <Protocol/HiiDatabase.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiHiiServicesLib.h>\r
-\r
-#define   PRODUCT_NAME                  L"DUET"\r
-#define   PRODUCT_VERSION               L"Beta"\r
-\r
-#define   FIRMWARE_PRODUCT_NAME         (PRODUCT_NAME L": ")\r
-#ifdef EFI32\r
-#define   FIRMWARE_BIOS_VERSIONE        (PRODUCT_NAME L"(IA32.UEFI)" PRODUCT_VERSION L": ")\r
-#else  // EFIX64\r
-#define   FIRMWARE_BIOS_VERSIONE        (PRODUCT_NAME L"(X64.UEFI)"  PRODUCT_VERSION L": ")\r
-#endif\r
-\r
-SMBIOS_STRUCTURE_POINTER\r
-GetSmbiosTableFromType (\r
-  IN SMBIOS_TABLE_ENTRY_POINT  *Smbios,\r
-  IN UINT8                 Type,\r
-  IN UINTN                 Index\r
-  );\r
-\r
-CHAR8 *\r
-GetSmbiosString (\r
-  IN SMBIOS_STRUCTURE_POINTER  SmbiosTable,\r
-  IN SMBIOS_TABLE_STRING       String\r
-  );\r
-\r
-/**\r
-  Logs SMBIOS record.\r
-\r
-  @param  Smbios   Pointer to SMBIOS protocol instance.\r
-  @param  Buffer   Pointer to the data buffer.\r
-\r
-**/\r
-VOID\r
-LogSmbiosData (\r
-  IN   EFI_SMBIOS_PROTOCOL        *Smbios,\r
-  IN   UINT8                      *Buffer\r
-  );\r
-\r
-#endif\r
diff --git a/DuetPkg/SmbiosGenDxe/SmbiosGen.inf b/DuetPkg/SmbiosGenDxe/SmbiosGen.inf
deleted file mode 100644 (file)
index c8568da..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-## @file\r
-#\r
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# 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
-#    SmbiosGen.inf\r
-#\r
-#  Abstract:\r
-#\r
-#    Component description file for SmbiosGen module.\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SmbiosGenDxe\r
-  FILE_GUID                      = A17F4A89-5F19-444f-B7BE-48195E0575DB\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = SmbiosGenEntrypoint\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiLib\r
-  HobLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  MemoryAllocationLib\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  HiiLib\r
-  UefiHiiServicesLib\r
-  \r
-[Sources]\r
-  SmbiosGen.c\r
-  SmbiosGen.h\r
-  SmbiosGenStrings.uni\r
-\r
-[Guids]\r
-  gEfiSmbiosTableGuid\r
-\r
-[Protocols]\r
-  gEfiHiiDatabaseProtocolGuid\r
-  gEfiSmbiosProtocolGuid\r
-  gEfiHiiProtocolGuid\r
-  \r
-[Depex]\r
-  gEfiSmbiosProtocolGuid AND gEfiHiiDatabaseProtocolGuid\r
-\r
diff --git a/DuetPkg/SmbiosGenDxe/SmbiosGenStrings.uni b/DuetPkg/SmbiosGenDxe/SmbiosGenStrings.uni
deleted file mode 100644 (file)
index 5ef9e98..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// *++\r
-//\r
-// Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-// 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
-//   DataHubGenStrings.uni\r
-// \r
-// Abstract:\r
-// \r
-//   String definitions for DataHubGen file.\r
-// \r
-// Revision History:\r
-// \r
-// --*/\r
-\r
-/=#\r
-\r
-#langdef  en-US "English"\r
-\r
-#string STR_UNKNOWN                    #language en-US  "Unknown"\r
-\r
-\r
-\r
-\r
diff --git a/DuetPkg/build32.sh b/DuetPkg/build32.sh
deleted file mode 100755 (executable)
index 8aa2c3d..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-
-set -e
-shopt -s nocasematch
-
-
-#
-# Setup workspace if it is not set
-#
-if [ -z "$WORKSPACE" ]
-then
-  echo Initializing workspace
-  if [ ! -e `pwd`/edksetup.sh ]
-  then
-    cd ..
-  fi
-# This version is for the tools in the BaseTools project.
-# this assumes svn pulls have the same root dir
-#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
-# This version is for the tools source in edk2
-  export EDK_TOOLS_PATH=`pwd`/BaseTools
-  echo $EDK_TOOLS_PATH
-  source edksetup.sh BaseTools
-else
-  echo Building from: $WORKSPACE
-fi
-
-PROCESSOR=IA32
-Processor=Ia32
-
-#
-# Pick a default tool type for a given OS
-#
-TARGET_TOOLS=MYTOOLS
-case `uname` in
-  CYGWIN*) echo Cygwin not fully supported yet. ;;
-  Darwin*)
-      Major=$(uname -r | cut -f 1 -d '.')
-      if [[ $Major == 9 ]]
-      then
-        echo DuetPkg requires Snow Leopard or later OS
-        exit 1
-      else
-        TARGET_TOOLS=XCODE32
-      fi
-      ;;
-  Linux*)
-    gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
-    case $gcc_version in
-      4.5.*)
-        TARGET_TOOLS=GCC45
-        ;;
-      4.6.*)
-        TARGET_TOOLS=GCC46
-        ;;
-      4.7.*)
-        TARGET_TOOLS=GCC47
-        ;;
-      4.8.*)
-        TARGET_TOOLS=GCC48
-        ;;
-      4.9.*|4.1[0-9].*|5.*.*)
-        TARGET_TOOLS=GCC49
-        ;;
-      *)
-        TARGET_TOOLS=GCC44
-        ;;
-    esac
-    ;;
-
-esac
-
-BUILD_ROOT_ARCH=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR
-FLOPPY_IMAGE=$WORKSPACE/Build/DuetPkg$PROCESSOR/floppy.img
-
-if  [[ ! -f `which build` || ! -f `which GenFv` ]];
-then
-  # build the tools if they don't yet exist. Bin scheme
-  echo Building tools as they are not in the path
-  make -C $WORKSPACE/BaseTools
-elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
-then
-  # build the tools if they don't yet exist. BinWrapper scheme
-  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
-  make -C $WORKSPACE/BaseTools
-else
-  echo using prebuilt tools
-fi
-
-
-for arg in "$@"
-do
-  if [[ $arg == qemu ]]; then
-    shift
-    qemu -fda $FLOPPY_IMAGE -boot a $*
-    exit
-  fi
-
-  if [[ $arg == cleanall ]]; then
-    make -C $WORKSPACE/BaseTools clean
-    build -p $WORKSPACE/DuetPkg/DuetPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
-    exit $?
-  fi
-
-  if [[ $arg == clean ]]; then
-    build -p $WORKSPACE/DuetPkg/DuetPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
-    exit $?
-  fi
-done
-
-
-#
-# Build the edk2 DuetPkg
-#
-echo Running edk2 build for DuetPkg$Processor
-build -p $WORKSPACE/DuetPkg/DuetPkg$Processor.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 $*
-echo Running DuetPkg/CreateBootDisk.sh
-
-$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR
-exit $?
-
diff --git a/DuetPkg/build64.sh b/DuetPkg/build64.sh
deleted file mode 100755 (executable)
index 1e07234..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-
-set -e
-shopt -s nocasematch
-
-
-#
-# Setup workspace if it is not set
-#
-if [ -z "$WORKSPACE" ]
-then
-  echo Initializing workspace
-  if [ ! -e `pwd`/edksetup.sh ]
-  then
-    cd ..
-  fi
-# This version is for the tools in the BaseTools project.
-# this assumes svn pulls have the same root dir
-#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
-# This version is for the tools source in edk2
-  export EDK_TOOLS_PATH=`pwd`/BaseTools
-  echo $EDK_TOOLS_PATH
-  source edksetup.sh BaseTools
-else
-  echo Building from: $WORKSPACE
-fi
-
-PROCESSOR=X64
-
-#
-# Pick a default tool type for a given OS
-#
-TARGET_TOOLS=MYTOOLS
-case `uname` in
-  CYGWIN*) echo Cygwin not fully supported yet. ;;
-  Darwin*)
-      Major=$(uname -r | cut -f 1 -d '.')
-      if [[ $Major == 9 ]]
-      then
-        echo DuetPkg requires Snow Leopard or later OS
-        exit 1
-      else
-        TARGET_TOOLS=XCODE32
-      fi
-      ;;
-  Linux*)
-    gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
-    case $gcc_version in
-      4.5.*)
-        TARGET_TOOLS=GCC45
-        ;;
-      4.6.*)
-        TARGET_TOOLS=GCC46
-        ;;
-      4.7.*)
-        TARGET_TOOLS=GCC47
-        ;;
-      4.8.*)
-        TARGET_TOOLS=GCC48
-        ;;
-      4.9.*|4.1[0-9].*|5.*.*)
-        TARGET_TOOLS=GCC49
-        ;;
-      *)
-        TARGET_TOOLS=GCC44
-        ;;
-    esac
-    ;;
-
-esac
-
-BUILD_ROOT_ARCH=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR
-FLOPPY_IMAGE=$WORKSPACE/Build/DuetPkg$PROCESSOR/floppy.img
-
-if  [[ ! -f `which build` || ! -f `which GenFv` ]];
-then
-  # build the tools if they don't yet exist. Bin scheme
-  echo Building tools as they are not in the path
-  make -C $WORKSPACE/BaseTools
-elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
-then
-  # build the tools if they don't yet exist. BinWrapper scheme
-  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
-  make -C $WORKSPACE/BaseTools
-else
-  echo using prebuilt tools
-fi
-
-
-for arg in "$@"
-do
-  if [[ $arg == qemu ]]; then
-    shift
-    qemu-system-x86_64 -fda $FLOPPY_IMAGE -boot a $*
-    exit
-  fi
-
-  if [[ $arg == cleanall ]]; then
-    make -C $WORKSPACE/BaseTools clean
-    build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
-    exit $?
-  fi
-
-  if [[ $arg == clean ]]; then
-    build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 clean
-    exit $?
-  fi
-done
-
-
-#
-# Build the edk2 DuetPkg
-#
-echo Running edk2 build for DuetPkg$PROCESSOR
-build -p $WORKSPACE/DuetPkg/DuetPkg$PROCESSOR.dsc -a $PROCESSOR -t $TARGET_TOOLS -n 3 $*
-echo Running DuetPkg/CreateBootDisk.sh
-
-$WORKSPACE/DuetPkg/CreateBootDisk.sh file $FLOPPY_IMAGE /dev/null FAT12 $PROCESSOR
-exit $?
-