]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuVideoDxe: Int10h stub for Windows 7 & 2008 (stdvga, QXL)
authorLaszlo Ersek <lersek@redhat.com>
Tue, 20 May 2014 16:33:00 +0000 (16:33 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 20 May 2014 16:33:00 +0000 (16:33 +0000)
The Windows 2008 R2 SP1 (and Windows 7) UEFI guest's default video driver
dereferences the real mode Int10h vector, loads the pointed-to handler
code, and executes what it thinks to be VGA BIOS services in an internal
real-mode emulator. Consequently, video mode switching doesn't work in
Windows 2008 R2 SP1 when it runs on the pure UEFI build of OVMF, making
the guest uninstallable.

This patch adds a VGABIOS "shim" to QemuVideoDxe. For the first stdvga or
QXL card bound, an extremely stripped down VGABIOS imitation is installed
in the C segment. It provides a real implementation for the few services
that are in fact necessary for the win2k8r2sp1 UEFI guest, plus some fakes
that the guest invokes but whose effect is not important.

The C segment is not present in the UEFI memory map prepared by OVMF. We
never add memory space that would cover it (either in PEI, in the form of
memory resource descriptor HOBs, or in DXE, via gDS->AddMemorySpace()).
This way the handler body is invisible to all non-buggy UEFI guests, and
the rest of edk2.

The Int10h real-mode IVT entry is covered with a Boot Services Code page,
making that too unaccessible to the rest of edk2. (Thus UEFI guest OSes
different from the Windows 2008 family can reclaim the page. The Windows
2008 family accesses the page at zero regardless of the allocation type.)

The patch is the result of collaboration:

Initial proof of concept IVT entry installation and handler skeleton (in
NASM) by Jordan Justen.

Service tracing and implementation, data collection/analysis, and C coding
by yours truly.

Last minute changes by Gerd Hoffmann:
- Use OEM mode number (0xf1) instead of standard 800x600 mode (0x143). The
  resolution of the OEM mode (0xf1) is not standardized; the guest can't
  expect anything from it in advance.
- Use 1024x768 rather than 800x600 for more convenience in the Windows
  2008 R2 SP1 guest during OS installation, and after normal boot until
  the QXL XDDM guest driver is installed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15540 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/Driver.c
OvmfPkg/QemuVideoDxe/Qemu.h
OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
OvmfPkg/QemuVideoDxe/VbeShim.asm [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/VbeShim.c [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/VbeShim.h [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/VbeShim.sh [new file with mode: 0755]
OvmfPkg/README

diff --git a/OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h b/OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h
new file mode 100644 (file)
index 0000000..d55d128
--- /dev/null
@@ -0,0 +1,97 @@
+/** @file\r
+  Type definitions related to the VBE (VESA BIOS Extension, Int10h AH=4Fh)\r
+  services GET INFORMATION (AL=00h) and GET MODE INFORMATION (AL=01h).\r
+\r
+  For reference, see Ralf Brown's Interrupt List:\r
+  <http://www.cs.cmu.edu/~ralf/files.html>\r
+  <http://www.ctyme.com/rbrown.htm>\r
+\r
+  Copyright (C) 2014, Red Hat, Inc.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution. The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#ifndef __LEGACY_VGA_BIOS_H__\r
+#define __LEGACY_VGA_BIOS_H__\r
+\r
+#include <Base.h>\r
+\r
+#pragma pack (1)\r
+typedef struct {\r
+  UINT8  Signature[4];\r
+  UINT16 VesaVersion;\r
+  UINT32 OemNameAddress;\r
+  UINT32 Capabilities;\r
+  UINT32 ModeListAddress;\r
+  UINT16 VideoMem64K;\r
+  UINT16 OemSoftwareVersion;\r
+  UINT32 VendorNameAddress;\r
+  UINT32 ProductNameAddress;\r
+  UINT32 ProductRevAddress;\r
+} VBE_INFO_BASE;\r
+\r
+typedef struct {\r
+  VBE_INFO_BASE  Base;\r
+  UINT8          Buffer[256 - sizeof (VBE_INFO_BASE)];\r
+} VBE_INFO;\r
+\r
+typedef struct {\r
+  UINT16 ModeAttr;\r
+  UINT8  WindowAAttr;\r
+  UINT8  WindowBAttr;\r
+  UINT16 WindowGranularityKB;\r
+  UINT16 WindowSizeKB;\r
+  UINT16 WindowAStartSegment;\r
+  UINT16 WindowBStartSegment;\r
+  UINT32 WindowPositioningAddress;\r
+  UINT16 BytesPerScanLine;\r
+\r
+  UINT16 Width;\r
+  UINT16 Height;\r
+  UINT8  CharCellWidth;\r
+  UINT8  CharCellHeight;\r
+  UINT8  NumPlanes;\r
+  UINT8  BitsPerPixel;\r
+  UINT8  NumBanks;\r
+  UINT8  MemoryModel;\r
+  UINT8  BankSizeKB;\r
+  UINT8  NumImagePagesLessOne;\r
+  UINT8  Vbe3;\r
+\r
+  UINT8  RedMaskSize;\r
+  UINT8  RedMaskPos;\r
+  UINT8  GreenMaskSize;\r
+  UINT8  GreenMaskPos;\r
+  UINT8  BlueMaskSize;\r
+  UINT8  BlueMaskPos;\r
+  UINT8  ReservedMaskSize;\r
+  UINT8  ReservedMaskPos;\r
+  UINT8  DirectColorModeInfo;\r
+\r
+  UINT32 LfbAddress;\r
+  UINT32 OffScreenAddress;\r
+  UINT16 OffScreenSizeKB;\r
+\r
+  UINT16 BytesPerScanLineLinear;\r
+  UINT8  NumImagesLessOneBanked;\r
+  UINT8  NumImagesLessOneLinear;\r
+  UINT8  RedMaskSizeLinear;\r
+  UINT8  RedMaskPosLinear;\r
+  UINT8  GreenMaskSizeLinear;\r
+  UINT8  GreenMaskPosLinear;\r
+  UINT8  BlueMaskSizeLinear;\r
+  UINT8  BlueMaskPosLinear;\r
+  UINT8  ReservedMaskSizeLinear;\r
+  UINT8  ReservedMaskPosLinear;\r
+  UINT32 MaxPixelClockHz;\r
+  UINT8  Reserved[190];\r
+} VBE_MODE_INFO;\r
+#pragma pack ()\r
+\r
+#endif\r
index c44b8b2603008634be3c0f49699cccbaed8c4339..2194cbef44a47b517112c81692bdb1352bdecf60 100644 (file)
@@ -398,6 +398,11 @@ QemuVideoControllerDriverStart (
     goto UninstallGop;\r
   }\r
 \r
+  if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO ||\r
+      Private->Variant == QEMU_VIDEO_BOCHS) {\r
+    InstallVbeShim (Card->Name, Private->GraphicsOutput.Mode->FrameBufferBase);\r
+  }\r
+\r
   gBS->RestoreTPL (OldTpl);\r
   return EFI_SUCCESS;\r
 \r
index 098ee774e093f6a2a6c310ec127a49c0f543f18a..4bf51c715044ec345a3d13b220f340f1aeb4bf72 100644 (file)
@@ -502,4 +502,9 @@ QemuVideoBochsModeSetup (
   QEMU_VIDEO_PRIVATE_DATA  *Private\r
   );\r
 \r
+VOID\r
+InstallVbeShim (\r
+  IN CONST CHAR16         *CardName,\r
+  IN EFI_PHYSICAL_ADDRESS FrameBufferBase\r
+  );\r
 #endif\r
index 30284fcce0f12f9263644c54af4a13a5dc5bb5b3..5180b276001c56f5b508b5dc3ac60868204d76c7 100644 (file)
   DriverSupportedEfiVersion.c\r
   Gop.c\r
   Initialize.c\r
+  VbeShim.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   OptionRomPkg/OptionRomPkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
   BaseMemoryLib\r
@@ -49,6 +51,8 @@
   DebugLib\r
   DevicePathLib\r
   MemoryAllocationLib\r
+  PciLib\r
+  PrintLib\r
   TimerLib\r
   UefiBootServicesTableLib\r
   UefiDriverEntryPoint\r
diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.asm b/OvmfPkg/QemuVideoDxe/VbeShim.asm
new file mode 100644 (file)
index 0000000..18fa920
--- /dev/null
@@ -0,0 +1,287 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; A minimal Int10h stub that allows the Windows 2008 R2 SP1 UEFI guest's buggy,\r
+; default VGA driver to switch to 1024x768x32, on the stdvga and QXL video\r
+; cards of QEMU.\r
+;\r
+; Copyright (C) 2014, Red Hat, Inc.\r
+; Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+;\r
+; This program and the accompanying materials are licensed and made available\r
+; under the terms and conditions of the BSD License which accompanies this\r
+; distribution.  The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+; WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+; enable this macro for debug messages\r
+;%define DEBUG\r
+\r
+%macro DebugLog 1\r
+%ifdef DEBUG\r
+  push       si\r
+  mov        si, %1\r
+  call       PrintStringSi\r
+  pop        si\r
+%endif\r
+%endmacro\r
+\r
+\r
+BITS 16\r
+ORG 0\r
+\r
+VbeInfo:\r
+TIMES 256 nop\r
+\r
+VbeModeInfo:\r
+TIMES 256 nop\r
+\r
+\r
+Handler:\r
+  cmp        ax, 0x4f00\r
+  je         GetInfo\r
+  cmp        ax, 0x4f01\r
+  je         GetModeInfo\r
+  cmp        ax, 0x4f02\r
+  je         SetMode\r
+  cmp        ax, 0x4f03\r
+  je         GetMode\r
+  cmp        ax, 0x4f10\r
+  je         GetPmCapabilities\r
+  cmp        ax, 0x4f15\r
+  je         ReadEdid\r
+  cmp        ah, 0x00\r
+  je         SetModeLegacy\r
+  DebugLog   StrUnkownFunction\r
+Hang:\r
+  jmp        Hang\r
+\r
+\r
+GetInfo:\r
+  push       es\r
+  push       di\r
+  push       ds\r
+  push       si\r
+  push       cx\r
+\r
+  DebugLog   StrEnterGetInfo\r
+\r
+  ; target (es:di) set on input\r
+  push       cs\r
+  pop        ds\r
+  mov        si, VbeInfo\r
+  ; source (ds:si) set now\r
+\r
+  mov        cx, 256\r
+  cld\r
+  rep movsb\r
+\r
+  pop        cx\r
+  pop        si\r
+  pop        ds\r
+  pop        di\r
+  pop        es\r
+  jmp        Success\r
+\r
+\r
+GetModeInfo:\r
+  push       es\r
+  push       di\r
+  push       ds\r
+  push       si\r
+  push       cx\r
+\r
+  DebugLog   StrEnterGetModeInfo\r
+\r
+  and        cx, ~0x4000 ; clear potentially set LFB bit in mode number\r
+  cmp        cx, 0x00f1\r
+  je         KnownMode1\r
+  DebugLog   StrUnkownMode\r
+  jmp        Hang\r
+KnownMode1:\r
+  ; target (es:di) set on input\r
+  push       cs\r
+  pop        ds\r
+  mov        si, VbeModeInfo\r
+  ; source (ds:si) set now\r
+\r
+  mov        cx, 256\r
+  cld\r
+  rep movsb\r
+\r
+  pop        cx\r
+  pop        si\r
+  pop        ds\r
+  pop        di\r
+  pop        es\r
+  jmp        Success\r
+\r
+\r
+%define ATT_ADDRESS_REGISTER   0x03c0\r
+%define VBE_DISPI_IOPORT_INDEX 0x01ce\r
+%define VBE_DISPI_IOPORT_DATA  0x01d0\r
+\r
+%define VBE_DISPI_INDEX_XRES        0x1\r
+%define VBE_DISPI_INDEX_YRES        0x2\r
+%define VBE_DISPI_INDEX_BPP         0x3\r
+%define VBE_DISPI_INDEX_ENABLE      0x4\r
+%define VBE_DISPI_INDEX_BANK        0x5\r
+%define VBE_DISPI_INDEX_VIRT_WIDTH  0x6\r
+%define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7\r
+%define VBE_DISPI_INDEX_X_OFFSET    0x8\r
+%define VBE_DISPI_INDEX_Y_OFFSET    0x9\r
+\r
+%define VBE_DISPI_ENABLED     0x01\r
+%define VBE_DISPI_LFB_ENABLED 0x40\r
+\r
+%macro BochsWrite 2\r
+  push       dx\r
+  push       ax\r
+\r
+  mov        dx, VBE_DISPI_IOPORT_INDEX\r
+  mov        ax, %1\r
+  out        dx, ax\r
+\r
+  mov        dx, VBE_DISPI_IOPORT_DATA\r
+  mov        ax, %2\r
+  out        dx, ax\r
+\r
+  pop        ax\r
+  pop        dx\r
+%endmacro\r
+\r
+SetMode:\r
+  push       dx\r
+  push       ax\r
+\r
+  DebugLog   StrEnterSetMode\r
+\r
+  cmp        bx, 0x40f1\r
+  je         KnownMode2\r
+  DebugLog   StrUnkownMode\r
+  jmp        Hang\r
+KnownMode2:\r
+\r
+  ; unblank\r
+  mov        dx, ATT_ADDRESS_REGISTER\r
+  mov        al, 0x20\r
+  out        dx, al\r
+\r
+  BochsWrite VBE_DISPI_INDEX_ENABLE,        0\r
+  BochsWrite VBE_DISPI_INDEX_BANK,          0\r
+  BochsWrite VBE_DISPI_INDEX_X_OFFSET,      0\r
+  BochsWrite VBE_DISPI_INDEX_Y_OFFSET,      0\r
+  BochsWrite VBE_DISPI_INDEX_BPP,          32\r
+  BochsWrite VBE_DISPI_INDEX_XRES,       1024\r
+  BochsWrite VBE_DISPI_INDEX_VIRT_WIDTH, 1024\r
+  BochsWrite VBE_DISPI_INDEX_YRES,        768\r
+  BochsWrite VBE_DISPI_INDEX_VIRT_HEIGHT, 768\r
+  BochsWrite VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED\r
+\r
+  pop        ax\r
+  pop        dx\r
+  jmp        Success\r
+\r
+\r
+GetMode:\r
+  DebugLog   StrEnterGetMode\r
+  mov        bx, 0x40f1\r
+  jmp        Success\r
+\r
+\r
+GetPmCapabilities:\r
+  DebugLog   StrGetPmCapabilities\r
+  jmp        Unsupported\r
+\r
+\r
+ReadEdid:\r
+  DebugLog   StrReadEdid\r
+  jmp        Unsupported\r
+\r
+\r
+SetModeLegacy:\r
+  DebugLog   StrEnterSetModeLegacy\r
+\r
+  cmp        al, 0x03\r
+  je         KnownMode3\r
+  cmp        al, 0x12\r
+  je         KnownMode4\r
+  DebugLog   StrUnkownMode\r
+  jmp        Hang\r
+KnownMode3:\r
+  mov        al, 0x30\r
+  jmp        SetModeLegacyDone\r
+KnownMode4:\r
+  mov        al, 0x20\r
+SetModeLegacyDone:\r
+  DebugLog   StrExitSuccess\r
+  iret\r
+\r
+\r
+Success:\r
+  DebugLog   StrExitSuccess\r
+  mov        ax, 0x004f\r
+  iret\r
+\r
+\r
+Unsupported:\r
+  DebugLog   StrExitUnsupported\r
+  mov        ax, 0x014f\r
+  iret\r
+\r
+\r
+%ifdef DEBUG\r
+PrintStringSi:\r
+  pusha\r
+  push       ds ; save original\r
+  push       cs\r
+  pop        ds\r
+  mov        dx, 0x0402\r
+PrintStringSiLoop:\r
+  lodsb\r
+  cmp        al, 0\r
+  je         PrintStringSiDone\r
+  out        dx, al\r
+  jmp        PrintStringSiLoop\r
+PrintStringSiDone:\r
+  pop        ds ; restore original\r
+  popa\r
+  ret\r
+\r
+\r
+StrExitSuccess:\r
+  db 'Exit', 0x0a, 0\r
+\r
+StrExitUnsupported:\r
+  db 'Unsupported', 0x0a, 0\r
+\r
+StrUnkownFunction:\r
+  db 'Unknown Function', 0x0a, 0\r
+\r
+StrEnterGetInfo:\r
+  db 'GetInfo', 0x0a, 0\r
+\r
+StrEnterGetModeInfo:\r
+  db 'GetModeInfo', 0x0a, 0\r
+\r
+StrEnterGetMode:\r
+  db 'GetMode', 0x0a, 0\r
+\r
+StrEnterSetMode:\r
+  db 'SetMode', 0x0a, 0\r
+\r
+StrEnterSetModeLegacy:\r
+  db 'SetModeLegacy', 0x0a, 0\r
+\r
+StrUnkownMode:\r
+  db 'Unkown Mode', 0x0a, 0\r
+\r
+StrGetPmCapabilities:\r
+  db 'GetPmCapabilities', 0x0a, 0\r
+\r
+StrReadEdid:\r
+  db 'ReadEdid', 0x0a, 0\r
+%endif\r
diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.c b/OvmfPkg/QemuVideoDxe/VbeShim.c
new file mode 100644 (file)
index 0000000..ae25b64
--- /dev/null
@@ -0,0 +1,275 @@
+/** @file\r
+  Install a fake VGABIOS service handler (real mode Int10h) for the buggy\r
+  Windows 2008 R2 SP1 UEFI guest.\r
+\r
+  The handler is never meant to be directly executed by a VCPU; it's there for\r
+  the internal real mode emulator of Windows 2008 R2 SP1.\r
+\r
+  The code is based on Ralf Brown's Interrupt List:\r
+  <http://www.cs.cmu.edu/~ralf/files.html>\r
+  <http://www.ctyme.com/rbrown.htm>\r
+\r
+  Copyright (C) 2014, Red Hat, Inc.\r
+  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution. The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <IndustryStandard/LegacyVgaBios.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PciLib.h>\r
+#include <Library/PrintLib.h>\r
+\r
+#include "Qemu.h"\r
+#include "VbeShim.h"\r
+\r
+#pragma pack (1)\r
+typedef struct {\r
+  UINT16 Offset;\r
+  UINT16 Segment;\r
+} IVT_ENTRY;\r
+#pragma pack ()\r
+\r
+//\r
+// This string is displayed by Windows 2008 R2 SP1 in the Screen Resolution,\r
+// Advanced Settings dialog. It should be short.\r
+//\r
+STATIC CONST CHAR8 mProductRevision[] = "OVMF Int10h (fake)";\r
+\r
+/**\r
+  Install the VBE Info and VBE Mode Info structures, and the VBE service\r
+  handler routine in the C segment. Point the real-mode Int10h interrupt vector\r
+  to the handler. The only advertised mode is 1024x768x32.\r
+\r
+  @param[in] CardName         Name of the video card to be exposed in the\r
+                              Product Name field of the VBE Info structure. The\r
+                              parameter must originate from a\r
+                              QEMU_VIDEO_CARD.Name field.\r
+  @param[in] FrameBufferBase  Guest-physical base address of the video card's\r
+                              frame buffer.\r
+**/\r
+VOID\r
+InstallVbeShim (\r
+  IN CONST CHAR16         *CardName,\r
+  IN EFI_PHYSICAL_ADDRESS FrameBufferBase\r
+  )\r
+{\r
+  EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF;\r
+  UINTN                Segment0Pages;\r
+  IVT_ENTRY            *Int0x10;\r
+  EFI_STATUS           Status;\r
+  UINTN                Pam1Address;\r
+  UINT8                Pam1;\r
+  UINTN                SegmentCPages;\r
+  VBE_INFO             *VbeInfoFull;\r
+  VBE_INFO_BASE        *VbeInfo;\r
+  UINT8                *Ptr;\r
+  UINTN                Printed;\r
+  VBE_MODE_INFO        *VbeModeInfo;\r
+\r
+  Segment0 = 0x00000;\r
+  SegmentC = 0xC0000;\r
+  SegmentF = 0xF0000;\r
+\r
+  //\r
+  // Attempt to cover the real mode IVT with an allocation. This is a UEFI\r
+  // driver, hence the arch protocols have been installed previously. Among\r
+  // those, the CPU arch protocol has configured the IDT, so we can overwrite\r
+  // the IVT used in real mode.\r
+  //\r
+  // The allocation request may fail, eg. if LegacyBiosDxe has already run.\r
+  //\r
+  Segment0Pages = 1;\r
+  Int0x10       = (IVT_ENTRY *)(UINTN)Segment0 + 0x10;\r
+  Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode,\r
+                  Segment0Pages, &Segment0);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    EFI_PHYSICAL_ADDRESS Handler;\r
+\r
+    //\r
+    // Check if a video BIOS handler has been installed previously -- we\r
+    // shouldn't override a real video BIOS with our shim, nor our own shim if\r
+    // it's already present.\r
+    //\r
+    Handler = (Int0x10->Segment << 4) + Int0x10->Offset;\r
+    if (Handler >= SegmentC && Handler < SegmentF) {\r
+      DEBUG ((EFI_D_VERBOSE, "%a: Video BIOS handler found at %04x:%04x\n",\r
+        __FUNCTION__, Int0x10->Segment, Int0x10->Offset));\r
+      return;\r
+    }\r
+\r
+    //\r
+    // Otherwise we'll overwrite the Int10h vector, even though we may not own\r
+    // the page at zero.\r
+    //\r
+    DEBUG ((EFI_D_VERBOSE, "%a: failed to allocate page at zero: %r\n",\r
+      __FUNCTION__, Status));\r
+  } else {\r
+    //\r
+    // We managed to allocate the page at zero. SVN r14218 guarantees that it\r
+    // is NUL-filled.\r
+    //\r
+    ASSERT (Int0x10->Segment == 0x0000);\r
+    ASSERT (Int0x10->Offset  == 0x0000);\r
+  }\r
+\r
+  //\r
+  // Put the shim in place first.\r
+  //\r
+  Pam1Address = PCI_LIB_ADDRESS (0, 0, 0, 0x5A);\r
+  //\r
+  // low nibble covers 0xC0000 to 0xC3FFF\r
+  // high nibble covers 0xC4000 to 0xC7FFF\r
+  // bit1 in each nibble is Write Enable\r
+  // bit0 in each nibble is Read Enable\r
+  //\r
+  Pam1 = PciRead8 (Pam1Address);\r
+  PciWrite8 (Pam1Address, Pam1 | (BIT1 | BIT0));\r
+\r
+  //\r
+  // We never added memory space durig PEI or DXE for the C segment, so we\r
+  // don't need to (and can't) allocate from there. Also, guest operating\r
+  // systems will see a hole in the UEFI memory map there.\r
+  //\r
+  SegmentCPages = 4;\r
+\r
+  ASSERT (sizeof mVbeShim <= EFI_PAGES_TO_SIZE (SegmentCPages));\r
+  CopyMem ((VOID *)(UINTN)SegmentC, mVbeShim, sizeof mVbeShim);\r
+\r
+  //\r
+  // Fill in the VBE INFO structure.\r
+  //\r
+  VbeInfoFull = (VBE_INFO *)(UINTN)SegmentC;\r
+  VbeInfo     = &VbeInfoFull->Base;\r
+  Ptr         = VbeInfoFull->Buffer;\r
+\r
+  CopyMem (VbeInfo->Signature, "VESA", 4);\r
+  VbeInfo->VesaVersion = 0x0300;\r
+\r
+  VbeInfo->OemNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  CopyMem (Ptr, "QEMU", 5);\r
+  Ptr += 5;\r
+\r
+  VbeInfo->Capabilities = BIT0; // DAC can be switched into 8-bit mode\r
+\r
+  VbeInfo->ModeListAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  *(UINT16*)Ptr = 0x00f1; // mode number\r
+  Ptr += 2;\r
+  *(UINT16*)Ptr = 0xFFFF; // mode list terminator\r
+  Ptr += 2;\r
+\r
+  VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);\r
+  VbeInfo->OemSoftwareVersion = 0x0000;\r
+\r
+  VbeInfo->VendorNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  CopyMem (Ptr, "OVMF", 5);\r
+  Ptr += 5;\r
+\r
+  VbeInfo->ProductNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  Printed = AsciiSPrint ((CHAR8 *)Ptr,\r
+              sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s",\r
+              CardName);\r
+  Ptr += Printed + 1;\r
+\r
+  VbeInfo->ProductRevAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  CopyMem (Ptr, mProductRevision, sizeof mProductRevision);\r
+  Ptr += sizeof mProductRevision;\r
+\r
+  ASSERT (sizeof VbeInfoFull->Buffer >= Ptr - VbeInfoFull->Buffer);\r
+  ZeroMem (Ptr, sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer));\r
+\r
+  //\r
+  // Fil in the VBE MODE INFO structure.\r
+  //\r
+  VbeModeInfo = (VBE_MODE_INFO *)(VbeInfoFull + 1);\r
+\r
+  //\r
+  // bit0: mode supported by present hardware configuration\r
+  // bit1: optional information available (must be =1 for VBE v1.2+)\r
+  // bit3: set if color, clear if monochrome\r
+  // bit4: set if graphics mode, clear if text mode\r
+  // bit5: mode is not VGA-compatible\r
+  // bit7: linear framebuffer mode supported\r
+  //\r
+  VbeModeInfo->ModeAttr = BIT7 | BIT5 | BIT4 | BIT3 | BIT1 | BIT0;\r
+\r
+  //\r
+  // bit0: exists\r
+  // bit1: bit1: readable\r
+  // bit2: writeable\r
+  //\r
+  VbeModeInfo->WindowAAttr              = BIT2 | BIT1 | BIT0;\r
+\r
+  VbeModeInfo->WindowBAttr              = 0x00;\r
+  VbeModeInfo->WindowGranularityKB      = 0x0040;\r
+  VbeModeInfo->WindowSizeKB             = 0x0040;\r
+  VbeModeInfo->WindowAStartSegment      = 0xA000;\r
+  VbeModeInfo->WindowBStartSegment      = 0x0000;\r
+  VbeModeInfo->WindowPositioningAddress = 0x0000;\r
+  VbeModeInfo->BytesPerScanLine         = 1024 * 4;\r
+\r
+  VbeModeInfo->Width                = 1024;\r
+  VbeModeInfo->Height               = 768;\r
+  VbeModeInfo->CharCellWidth        = 8;\r
+  VbeModeInfo->CharCellHeight       = 16;\r
+  VbeModeInfo->NumPlanes            = 1;\r
+  VbeModeInfo->BitsPerPixel         = 32;\r
+  VbeModeInfo->NumBanks             = 1;\r
+  VbeModeInfo->MemoryModel          = 6; // direct color\r
+  VbeModeInfo->BankSizeKB           = 0;\r
+  VbeModeInfo->NumImagePagesLessOne = 0;\r
+  VbeModeInfo->Vbe3                 = 0x01;\r
+\r
+  VbeModeInfo->RedMaskSize      = 8;\r
+  VbeModeInfo->RedMaskPos       = 16;\r
+  VbeModeInfo->GreenMaskSize    = 8;\r
+  VbeModeInfo->GreenMaskPos     = 8;\r
+  VbeModeInfo->BlueMaskSize     = 8;\r
+  VbeModeInfo->BlueMaskPos      = 0;\r
+  VbeModeInfo->ReservedMaskSize = 8;\r
+  VbeModeInfo->ReservedMaskPos  = 24;\r
+\r
+  //\r
+  // bit1: Bytes in reserved field may be used by application\r
+  //\r
+  VbeModeInfo->DirectColorModeInfo = BIT1;\r
+\r
+  VbeModeInfo->LfbAddress       = (UINT32)FrameBufferBase;\r
+  VbeModeInfo->OffScreenAddress = 0;\r
+  VbeModeInfo->OffScreenSizeKB  = 0;\r
+\r
+  VbeModeInfo->BytesPerScanLineLinear = 1024 * 4;\r
+  VbeModeInfo->NumImagesLessOneBanked = 0;\r
+  VbeModeInfo->NumImagesLessOneLinear = 0;\r
+  VbeModeInfo->RedMaskSizeLinear      = 8;\r
+  VbeModeInfo->RedMaskPosLinear       = 16;\r
+  VbeModeInfo->GreenMaskSizeLinear    = 8;\r
+  VbeModeInfo->GreenMaskPosLinear     = 8;\r
+  VbeModeInfo->BlueMaskSizeLinear     = 8;\r
+  VbeModeInfo->BlueMaskPosLinear      = 0;\r
+  VbeModeInfo->ReservedMaskSizeLinear = 8;\r
+  VbeModeInfo->ReservedMaskPosLinear  = 24;\r
+  VbeModeInfo->MaxPixelClockHz        = 0;\r
+\r
+  ZeroMem (VbeModeInfo->Reserved, sizeof VbeModeInfo->Reserved);\r
+\r
+  //\r
+  // Clear Write Enable (bit1), keep Read Enable (bit0) set\r
+  //\r
+  PciWrite8 (Pam1Address, (Pam1 & ~BIT1) | BIT0);\r
+\r
+  //\r
+  // Second, point the Int10h vector at the shim.\r
+  //\r
+  Int0x10->Segment = SegmentC >> 4;\r
+  Int0x10->Offset  = (EFI_PHYSICAL_ADDRESS)(UINTN)(VbeModeInfo + 1) - SegmentC;\r
+\r
+  DEBUG ((EFI_D_INFO, "%a: VBE shim installed\n", __FUNCTION__));\r
+}\r
diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.h b/OvmfPkg/QemuVideoDxe/VbeShim.h
new file mode 100644 (file)
index 0000000..cc9b6e1
--- /dev/null
@@ -0,0 +1,701 @@
+//\r
+// THIS FILE WAS GENERATED BY "VbeShim.sh". DO NOT EDIT.\r
+//\r
+#ifndef _VBE_SHIM_H_\r
+#define _VBE_SHIM_H_\r
+STATIC CONST UINT8 mVbeShim[] = {\r
+  /* 00000000 nop                            */  0x90,\r
+  /* 00000001 nop                            */  0x90,\r
+  /* 00000002 nop                            */  0x90,\r
+  /* 00000003 nop                            */  0x90,\r
+  /* 00000004 nop                            */  0x90,\r
+  /* 00000005 nop                            */  0x90,\r
+  /* 00000006 nop                            */  0x90,\r
+  /* 00000007 nop                            */  0x90,\r
+  /* 00000008 nop                            */  0x90,\r
+  /* 00000009 nop                            */  0x90,\r
+  /* 0000000A nop                            */  0x90,\r
+  /* 0000000B nop                            */  0x90,\r
+  /* 0000000C nop                            */  0x90,\r
+  /* 0000000D nop                            */  0x90,\r
+  /* 0000000E nop                            */  0x90,\r
+  /* 0000000F nop                            */  0x90,\r
+  /* 00000010 nop                            */  0x90,\r
+  /* 00000011 nop                            */  0x90,\r
+  /* 00000012 nop                            */  0x90,\r
+  /* 00000013 nop                            */  0x90,\r
+  /* 00000014 nop                            */  0x90,\r
+  /* 00000015 nop                            */  0x90,\r
+  /* 00000016 nop                            */  0x90,\r
+  /* 00000017 nop                            */  0x90,\r
+  /* 00000018 nop                            */  0x90,\r
+  /* 00000019 nop                            */  0x90,\r
+  /* 0000001A nop                            */  0x90,\r
+  /* 0000001B nop                            */  0x90,\r
+  /* 0000001C nop                            */  0x90,\r
+  /* 0000001D nop                            */  0x90,\r
+  /* 0000001E nop                            */  0x90,\r
+  /* 0000001F nop                            */  0x90,\r
+  /* 00000020 nop                            */  0x90,\r
+  /* 00000021 nop                            */  0x90,\r
+  /* 00000022 nop                            */  0x90,\r
+  /* 00000023 nop                            */  0x90,\r
+  /* 00000024 nop                            */  0x90,\r
+  /* 00000025 nop                            */  0x90,\r
+  /* 00000026 nop                            */  0x90,\r
+  /* 00000027 nop                            */  0x90,\r
+  /* 00000028 nop                            */  0x90,\r
+  /* 00000029 nop                            */  0x90,\r
+  /* 0000002A nop                            */  0x90,\r
+  /* 0000002B nop                            */  0x90,\r
+  /* 0000002C nop                            */  0x90,\r
+  /* 0000002D nop                            */  0x90,\r
+  /* 0000002E nop                            */  0x90,\r
+  /* 0000002F nop                            */  0x90,\r
+  /* 00000030 nop                            */  0x90,\r
+  /* 00000031 nop                            */  0x90,\r
+  /* 00000032 nop                            */  0x90,\r
+  /* 00000033 nop                            */  0x90,\r
+  /* 00000034 nop                            */  0x90,\r
+  /* 00000035 nop                            */  0x90,\r
+  /* 00000036 nop                            */  0x90,\r
+  /* 00000037 nop                            */  0x90,\r
+  /* 00000038 nop                            */  0x90,\r
+  /* 00000039 nop                            */  0x90,\r
+  /* 0000003A nop                            */  0x90,\r
+  /* 0000003B nop                            */  0x90,\r
+  /* 0000003C nop                            */  0x90,\r
+  /* 0000003D nop                            */  0x90,\r
+  /* 0000003E nop                            */  0x90,\r
+  /* 0000003F nop                            */  0x90,\r
+  /* 00000040 nop                            */  0x90,\r
+  /* 00000041 nop                            */  0x90,\r
+  /* 00000042 nop                            */  0x90,\r
+  /* 00000043 nop                            */  0x90,\r
+  /* 00000044 nop                            */  0x90,\r
+  /* 00000045 nop                            */  0x90,\r
+  /* 00000046 nop                            */  0x90,\r
+  /* 00000047 nop                            */  0x90,\r
+  /* 00000048 nop                            */  0x90,\r
+  /* 00000049 nop                            */  0x90,\r
+  /* 0000004A nop                            */  0x90,\r
+  /* 0000004B nop                            */  0x90,\r
+  /* 0000004C nop                            */  0x90,\r
+  /* 0000004D nop                            */  0x90,\r
+  /* 0000004E nop                            */  0x90,\r
+  /* 0000004F nop                            */  0x90,\r
+  /* 00000050 nop                            */  0x90,\r
+  /* 00000051 nop                            */  0x90,\r
+  /* 00000052 nop                            */  0x90,\r
+  /* 00000053 nop                            */  0x90,\r
+  /* 00000054 nop                            */  0x90,\r
+  /* 00000055 nop                            */  0x90,\r
+  /* 00000056 nop                            */  0x90,\r
+  /* 00000057 nop                            */  0x90,\r
+  /* 00000058 nop                            */  0x90,\r
+  /* 00000059 nop                            */  0x90,\r
+  /* 0000005A nop                            */  0x90,\r
+  /* 0000005B nop                            */  0x90,\r
+  /* 0000005C nop                            */  0x90,\r
+  /* 0000005D nop                            */  0x90,\r
+  /* 0000005E nop                            */  0x90,\r
+  /* 0000005F nop                            */  0x90,\r
+  /* 00000060 nop                            */  0x90,\r
+  /* 00000061 nop                            */  0x90,\r
+  /* 00000062 nop                            */  0x90,\r
+  /* 00000063 nop                            */  0x90,\r
+  /* 00000064 nop                            */  0x90,\r
+  /* 00000065 nop                            */  0x90,\r
+  /* 00000066 nop                            */  0x90,\r
+  /* 00000067 nop                            */  0x90,\r
+  /* 00000068 nop                            */  0x90,\r
+  /* 00000069 nop                            */  0x90,\r
+  /* 0000006A nop                            */  0x90,\r
+  /* 0000006B nop                            */  0x90,\r
+  /* 0000006C nop                            */  0x90,\r
+  /* 0000006D nop                            */  0x90,\r
+  /* 0000006E nop                            */  0x90,\r
+  /* 0000006F nop                            */  0x90,\r
+  /* 00000070 nop                            */  0x90,\r
+  /* 00000071 nop                            */  0x90,\r
+  /* 00000072 nop                            */  0x90,\r
+  /* 00000073 nop                            */  0x90,\r
+  /* 00000074 nop                            */  0x90,\r
+  /* 00000075 nop                            */  0x90,\r
+  /* 00000076 nop                            */  0x90,\r
+  /* 00000077 nop                            */  0x90,\r
+  /* 00000078 nop                            */  0x90,\r
+  /* 00000079 nop                            */  0x90,\r
+  /* 0000007A nop                            */  0x90,\r
+  /* 0000007B nop                            */  0x90,\r
+  /* 0000007C nop                            */  0x90,\r
+  /* 0000007D nop                            */  0x90,\r
+  /* 0000007E nop                            */  0x90,\r
+  /* 0000007F nop                            */  0x90,\r
+  /* 00000080 nop                            */  0x90,\r
+  /* 00000081 nop                            */  0x90,\r
+  /* 00000082 nop                            */  0x90,\r
+  /* 00000083 nop                            */  0x90,\r
+  /* 00000084 nop                            */  0x90,\r
+  /* 00000085 nop                            */  0x90,\r
+  /* 00000086 nop                            */  0x90,\r
+  /* 00000087 nop                            */  0x90,\r
+  /* 00000088 nop                            */  0x90,\r
+  /* 00000089 nop                            */  0x90,\r
+  /* 0000008A nop                            */  0x90,\r
+  /* 0000008B nop                            */  0x90,\r
+  /* 0000008C nop                            */  0x90,\r
+  /* 0000008D nop                            */  0x90,\r
+  /* 0000008E nop                            */  0x90,\r
+  /* 0000008F nop                            */  0x90,\r
+  /* 00000090 nop                            */  0x90,\r
+  /* 00000091 nop                            */  0x90,\r
+  /* 00000092 nop                            */  0x90,\r
+  /* 00000093 nop                            */  0x90,\r
+  /* 00000094 nop                            */  0x90,\r
+  /* 00000095 nop                            */  0x90,\r
+  /* 00000096 nop                            */  0x90,\r
+  /* 00000097 nop                            */  0x90,\r
+  /* 00000098 nop                            */  0x90,\r
+  /* 00000099 nop                            */  0x90,\r
+  /* 0000009A nop                            */  0x90,\r
+  /* 0000009B nop                            */  0x90,\r
+  /* 0000009C nop                            */  0x90,\r
+  /* 0000009D nop                            */  0x90,\r
+  /* 0000009E nop                            */  0x90,\r
+  /* 0000009F nop                            */  0x90,\r
+  /* 000000A0 nop                            */  0x90,\r
+  /* 000000A1 nop                            */  0x90,\r
+  /* 000000A2 nop                            */  0x90,\r
+  /* 000000A3 nop                            */  0x90,\r
+  /* 000000A4 nop                            */  0x90,\r
+  /* 000000A5 nop                            */  0x90,\r
+  /* 000000A6 nop                            */  0x90,\r
+  /* 000000A7 nop                            */  0x90,\r
+  /* 000000A8 nop                            */  0x90,\r
+  /* 000000A9 nop                            */  0x90,\r
+  /* 000000AA nop                            */  0x90,\r
+  /* 000000AB nop                            */  0x90,\r
+  /* 000000AC nop                            */  0x90,\r
+  /* 000000AD nop                            */  0x90,\r
+  /* 000000AE nop                            */  0x90,\r
+  /* 000000AF nop                            */  0x90,\r
+  /* 000000B0 nop                            */  0x90,\r
+  /* 000000B1 nop                            */  0x90,\r
+  /* 000000B2 nop                            */  0x90,\r
+  /* 000000B3 nop                            */  0x90,\r
+  /* 000000B4 nop                            */  0x90,\r
+  /* 000000B5 nop                            */  0x90,\r
+  /* 000000B6 nop                            */  0x90,\r
+  /* 000000B7 nop                            */  0x90,\r
+  /* 000000B8 nop                            */  0x90,\r
+  /* 000000B9 nop                            */  0x90,\r
+  /* 000000BA nop                            */  0x90,\r
+  /* 000000BB nop                            */  0x90,\r
+  /* 000000BC nop                            */  0x90,\r
+  /* 000000BD nop                            */  0x90,\r
+  /* 000000BE nop                            */  0x90,\r
+  /* 000000BF nop                            */  0x90,\r
+  /* 000000C0 nop                            */  0x90,\r
+  /* 000000C1 nop                            */  0x90,\r
+  /* 000000C2 nop                            */  0x90,\r
+  /* 000000C3 nop                            */  0x90,\r
+  /* 000000C4 nop                            */  0x90,\r
+  /* 000000C5 nop                            */  0x90,\r
+  /* 000000C6 nop                            */  0x90,\r
+  /* 000000C7 nop                            */  0x90,\r
+  /* 000000C8 nop                            */  0x90,\r
+  /* 000000C9 nop                            */  0x90,\r
+  /* 000000CA nop                            */  0x90,\r
+  /* 000000CB nop                            */  0x90,\r
+  /* 000000CC nop                            */  0x90,\r
+  /* 000000CD nop                            */  0x90,\r
+  /* 000000CE nop                            */  0x90,\r
+  /* 000000CF nop                            */  0x90,\r
+  /* 000000D0 nop                            */  0x90,\r
+  /* 000000D1 nop                            */  0x90,\r
+  /* 000000D2 nop                            */  0x90,\r
+  /* 000000D3 nop                            */  0x90,\r
+  /* 000000D4 nop                            */  0x90,\r
+  /* 000000D5 nop                            */  0x90,\r
+  /* 000000D6 nop                            */  0x90,\r
+  /* 000000D7 nop                            */  0x90,\r
+  /* 000000D8 nop                            */  0x90,\r
+  /* 000000D9 nop                            */  0x90,\r
+  /* 000000DA nop                            */  0x90,\r
+  /* 000000DB nop                            */  0x90,\r
+  /* 000000DC nop                            */  0x90,\r
+  /* 000000DD nop                            */  0x90,\r
+  /* 000000DE nop                            */  0x90,\r
+  /* 000000DF nop                            */  0x90,\r
+  /* 000000E0 nop                            */  0x90,\r
+  /* 000000E1 nop                            */  0x90,\r
+  /* 000000E2 nop                            */  0x90,\r
+  /* 000000E3 nop                            */  0x90,\r
+  /* 000000E4 nop                            */  0x90,\r
+  /* 000000E5 nop                            */  0x90,\r
+  /* 000000E6 nop                            */  0x90,\r
+  /* 000000E7 nop                            */  0x90,\r
+  /* 000000E8 nop                            */  0x90,\r
+  /* 000000E9 nop                            */  0x90,\r
+  /* 000000EA nop                            */  0x90,\r
+  /* 000000EB nop                            */  0x90,\r
+  /* 000000EC nop                            */  0x90,\r
+  /* 000000ED nop                            */  0x90,\r
+  /* 000000EE nop                            */  0x90,\r
+  /* 000000EF nop                            */  0x90,\r
+  /* 000000F0 nop                            */  0x90,\r
+  /* 000000F1 nop                            */  0x90,\r
+  /* 000000F2 nop                            */  0x90,\r
+  /* 000000F3 nop                            */  0x90,\r
+  /* 000000F4 nop                            */  0x90,\r
+  /* 000000F5 nop                            */  0x90,\r
+  /* 000000F6 nop                            */  0x90,\r
+  /* 000000F7 nop                            */  0x90,\r
+  /* 000000F8 nop                            */  0x90,\r
+  /* 000000F9 nop                            */  0x90,\r
+  /* 000000FA nop                            */  0x90,\r
+  /* 000000FB nop                            */  0x90,\r
+  /* 000000FC nop                            */  0x90,\r
+  /* 000000FD nop                            */  0x90,\r
+  /* 000000FE nop                            */  0x90,\r
+  /* 000000FF nop                            */  0x90,\r
+  /* 00000100 nop                            */  0x90,\r
+  /* 00000101 nop                            */  0x90,\r
+  /* 00000102 nop                            */  0x90,\r
+  /* 00000103 nop                            */  0x90,\r
+  /* 00000104 nop                            */  0x90,\r
+  /* 00000105 nop                            */  0x90,\r
+  /* 00000106 nop                            */  0x90,\r
+  /* 00000107 nop                            */  0x90,\r
+  /* 00000108 nop                            */  0x90,\r
+  /* 00000109 nop                            */  0x90,\r
+  /* 0000010A nop                            */  0x90,\r
+  /* 0000010B nop                            */  0x90,\r
+  /* 0000010C nop                            */  0x90,\r
+  /* 0000010D nop                            */  0x90,\r
+  /* 0000010E nop                            */  0x90,\r
+  /* 0000010F nop                            */  0x90,\r
+  /* 00000110 nop                            */  0x90,\r
+  /* 00000111 nop                            */  0x90,\r
+  /* 00000112 nop                            */  0x90,\r
+  /* 00000113 nop                            */  0x90,\r
+  /* 00000114 nop                            */  0x90,\r
+  /* 00000115 nop                            */  0x90,\r
+  /* 00000116 nop                            */  0x90,\r
+  /* 00000117 nop                            */  0x90,\r
+  /* 00000118 nop                            */  0x90,\r
+  /* 00000119 nop                            */  0x90,\r
+  /* 0000011A nop                            */  0x90,\r
+  /* 0000011B nop                            */  0x90,\r
+  /* 0000011C nop                            */  0x90,\r
+  /* 0000011D nop                            */  0x90,\r
+  /* 0000011E nop                            */  0x90,\r
+  /* 0000011F nop                            */  0x90,\r
+  /* 00000120 nop                            */  0x90,\r
+  /* 00000121 nop                            */  0x90,\r
+  /* 00000122 nop                            */  0x90,\r
+  /* 00000123 nop                            */  0x90,\r
+  /* 00000124 nop                            */  0x90,\r
+  /* 00000125 nop                            */  0x90,\r
+  /* 00000126 nop                            */  0x90,\r
+  /* 00000127 nop                            */  0x90,\r
+  /* 00000128 nop                            */  0x90,\r
+  /* 00000129 nop                            */  0x90,\r
+  /* 0000012A nop                            */  0x90,\r
+  /* 0000012B nop                            */  0x90,\r
+  /* 0000012C nop                            */  0x90,\r
+  /* 0000012D nop                            */  0x90,\r
+  /* 0000012E nop                            */  0x90,\r
+  /* 0000012F nop                            */  0x90,\r
+  /* 00000130 nop                            */  0x90,\r
+  /* 00000131 nop                            */  0x90,\r
+  /* 00000132 nop                            */  0x90,\r
+  /* 00000133 nop                            */  0x90,\r
+  /* 00000134 nop                            */  0x90,\r
+  /* 00000135 nop                            */  0x90,\r
+  /* 00000136 nop                            */  0x90,\r
+  /* 00000137 nop                            */  0x90,\r
+  /* 00000138 nop                            */  0x90,\r
+  /* 00000139 nop                            */  0x90,\r
+  /* 0000013A nop                            */  0x90,\r
+  /* 0000013B nop                            */  0x90,\r
+  /* 0000013C nop                            */  0x90,\r
+  /* 0000013D nop                            */  0x90,\r
+  /* 0000013E nop                            */  0x90,\r
+  /* 0000013F nop                            */  0x90,\r
+  /* 00000140 nop                            */  0x90,\r
+  /* 00000141 nop                            */  0x90,\r
+  /* 00000142 nop                            */  0x90,\r
+  /* 00000143 nop                            */  0x90,\r
+  /* 00000144 nop                            */  0x90,\r
+  /* 00000145 nop                            */  0x90,\r
+  /* 00000146 nop                            */  0x90,\r
+  /* 00000147 nop                            */  0x90,\r
+  /* 00000148 nop                            */  0x90,\r
+  /* 00000149 nop                            */  0x90,\r
+  /* 0000014A nop                            */  0x90,\r
+  /* 0000014B nop                            */  0x90,\r
+  /* 0000014C nop                            */  0x90,\r
+  /* 0000014D nop                            */  0x90,\r
+  /* 0000014E nop                            */  0x90,\r
+  /* 0000014F nop                            */  0x90,\r
+  /* 00000150 nop                            */  0x90,\r
+  /* 00000151 nop                            */  0x90,\r
+  /* 00000152 nop                            */  0x90,\r
+  /* 00000153 nop                            */  0x90,\r
+  /* 00000154 nop                            */  0x90,\r
+  /* 00000155 nop                            */  0x90,\r
+  /* 00000156 nop                            */  0x90,\r
+  /* 00000157 nop                            */  0x90,\r
+  /* 00000158 nop                            */  0x90,\r
+  /* 00000159 nop                            */  0x90,\r
+  /* 0000015A nop                            */  0x90,\r
+  /* 0000015B nop                            */  0x90,\r
+  /* 0000015C nop                            */  0x90,\r
+  /* 0000015D nop                            */  0x90,\r
+  /* 0000015E nop                            */  0x90,\r
+  /* 0000015F nop                            */  0x90,\r
+  /* 00000160 nop                            */  0x90,\r
+  /* 00000161 nop                            */  0x90,\r
+  /* 00000162 nop                            */  0x90,\r
+  /* 00000163 nop                            */  0x90,\r
+  /* 00000164 nop                            */  0x90,\r
+  /* 00000165 nop                            */  0x90,\r
+  /* 00000166 nop                            */  0x90,\r
+  /* 00000167 nop                            */  0x90,\r
+  /* 00000168 nop                            */  0x90,\r
+  /* 00000169 nop                            */  0x90,\r
+  /* 0000016A nop                            */  0x90,\r
+  /* 0000016B nop                            */  0x90,\r
+  /* 0000016C nop                            */  0x90,\r
+  /* 0000016D nop                            */  0x90,\r
+  /* 0000016E nop                            */  0x90,\r
+  /* 0000016F nop                            */  0x90,\r
+  /* 00000170 nop                            */  0x90,\r
+  /* 00000171 nop                            */  0x90,\r
+  /* 00000172 nop                            */  0x90,\r
+  /* 00000173 nop                            */  0x90,\r
+  /* 00000174 nop                            */  0x90,\r
+  /* 00000175 nop                            */  0x90,\r
+  /* 00000176 nop                            */  0x90,\r
+  /* 00000177 nop                            */  0x90,\r
+  /* 00000178 nop                            */  0x90,\r
+  /* 00000179 nop                            */  0x90,\r
+  /* 0000017A nop                            */  0x90,\r
+  /* 0000017B nop                            */  0x90,\r
+  /* 0000017C nop                            */  0x90,\r
+  /* 0000017D nop                            */  0x90,\r
+  /* 0000017E nop                            */  0x90,\r
+  /* 0000017F nop                            */  0x90,\r
+  /* 00000180 nop                            */  0x90,\r
+  /* 00000181 nop                            */  0x90,\r
+  /* 00000182 nop                            */  0x90,\r
+  /* 00000183 nop                            */  0x90,\r
+  /* 00000184 nop                            */  0x90,\r
+  /* 00000185 nop                            */  0x90,\r
+  /* 00000186 nop                            */  0x90,\r
+  /* 00000187 nop                            */  0x90,\r
+  /* 00000188 nop                            */  0x90,\r
+  /* 00000189 nop                            */  0x90,\r
+  /* 0000018A nop                            */  0x90,\r
+  /* 0000018B nop                            */  0x90,\r
+  /* 0000018C nop                            */  0x90,\r
+  /* 0000018D nop                            */  0x90,\r
+  /* 0000018E nop                            */  0x90,\r
+  /* 0000018F nop                            */  0x90,\r
+  /* 00000190 nop                            */  0x90,\r
+  /* 00000191 nop                            */  0x90,\r
+  /* 00000192 nop                            */  0x90,\r
+  /* 00000193 nop                            */  0x90,\r
+  /* 00000194 nop                            */  0x90,\r
+  /* 00000195 nop                            */  0x90,\r
+  /* 00000196 nop                            */  0x90,\r
+  /* 00000197 nop                            */  0x90,\r
+  /* 00000198 nop                            */  0x90,\r
+  /* 00000199 nop                            */  0x90,\r
+  /* 0000019A nop                            */  0x90,\r
+  /* 0000019B nop                            */  0x90,\r
+  /* 0000019C nop                            */  0x90,\r
+  /* 0000019D nop                            */  0x90,\r
+  /* 0000019E nop                            */  0x90,\r
+  /* 0000019F nop                            */  0x90,\r
+  /* 000001A0 nop                            */  0x90,\r
+  /* 000001A1 nop                            */  0x90,\r
+  /* 000001A2 nop                            */  0x90,\r
+  /* 000001A3 nop                            */  0x90,\r
+  /* 000001A4 nop                            */  0x90,\r
+  /* 000001A5 nop                            */  0x90,\r
+  /* 000001A6 nop                            */  0x90,\r
+  /* 000001A7 nop                            */  0x90,\r
+  /* 000001A8 nop                            */  0x90,\r
+  /* 000001A9 nop                            */  0x90,\r
+  /* 000001AA nop                            */  0x90,\r
+  /* 000001AB nop                            */  0x90,\r
+  /* 000001AC nop                            */  0x90,\r
+  /* 000001AD nop                            */  0x90,\r
+  /* 000001AE nop                            */  0x90,\r
+  /* 000001AF nop                            */  0x90,\r
+  /* 000001B0 nop                            */  0x90,\r
+  /* 000001B1 nop                            */  0x90,\r
+  /* 000001B2 nop                            */  0x90,\r
+  /* 000001B3 nop                            */  0x90,\r
+  /* 000001B4 nop                            */  0x90,\r
+  /* 000001B5 nop                            */  0x90,\r
+  /* 000001B6 nop                            */  0x90,\r
+  /* 000001B7 nop                            */  0x90,\r
+  /* 000001B8 nop                            */  0x90,\r
+  /* 000001B9 nop                            */  0x90,\r
+  /* 000001BA nop                            */  0x90,\r
+  /* 000001BB nop                            */  0x90,\r
+  /* 000001BC nop                            */  0x90,\r
+  /* 000001BD nop                            */  0x90,\r
+  /* 000001BE nop                            */  0x90,\r
+  /* 000001BF nop                            */  0x90,\r
+  /* 000001C0 nop                            */  0x90,\r
+  /* 000001C1 nop                            */  0x90,\r
+  /* 000001C2 nop                            */  0x90,\r
+  /* 000001C3 nop                            */  0x90,\r
+  /* 000001C4 nop                            */  0x90,\r
+  /* 000001C5 nop                            */  0x90,\r
+  /* 000001C6 nop                            */  0x90,\r
+  /* 000001C7 nop                            */  0x90,\r
+  /* 000001C8 nop                            */  0x90,\r
+  /* 000001C9 nop                            */  0x90,\r
+  /* 000001CA nop                            */  0x90,\r
+  /* 000001CB nop                            */  0x90,\r
+  /* 000001CC nop                            */  0x90,\r
+  /* 000001CD nop                            */  0x90,\r
+  /* 000001CE nop                            */  0x90,\r
+  /* 000001CF nop                            */  0x90,\r
+  /* 000001D0 nop                            */  0x90,\r
+  /* 000001D1 nop                            */  0x90,\r
+  /* 000001D2 nop                            */  0x90,\r
+  /* 000001D3 nop                            */  0x90,\r
+  /* 000001D4 nop                            */  0x90,\r
+  /* 000001D5 nop                            */  0x90,\r
+  /* 000001D6 nop                            */  0x90,\r
+  /* 000001D7 nop                            */  0x90,\r
+  /* 000001D8 nop                            */  0x90,\r
+  /* 000001D9 nop                            */  0x90,\r
+  /* 000001DA nop                            */  0x90,\r
+  /* 000001DB nop                            */  0x90,\r
+  /* 000001DC nop                            */  0x90,\r
+  /* 000001DD nop                            */  0x90,\r
+  /* 000001DE nop                            */  0x90,\r
+  /* 000001DF nop                            */  0x90,\r
+  /* 000001E0 nop                            */  0x90,\r
+  /* 000001E1 nop                            */  0x90,\r
+  /* 000001E2 nop                            */  0x90,\r
+  /* 000001E3 nop                            */  0x90,\r
+  /* 000001E4 nop                            */  0x90,\r
+  /* 000001E5 nop                            */  0x90,\r
+  /* 000001E6 nop                            */  0x90,\r
+  /* 000001E7 nop                            */  0x90,\r
+  /* 000001E8 nop                            */  0x90,\r
+  /* 000001E9 nop                            */  0x90,\r
+  /* 000001EA nop                            */  0x90,\r
+  /* 000001EB nop                            */  0x90,\r
+  /* 000001EC nop                            */  0x90,\r
+  /* 000001ED nop                            */  0x90,\r
+  /* 000001EE nop                            */  0x90,\r
+  /* 000001EF nop                            */  0x90,\r
+  /* 000001F0 nop                            */  0x90,\r
+  /* 000001F1 nop                            */  0x90,\r
+  /* 000001F2 nop                            */  0x90,\r
+  /* 000001F3 nop                            */  0x90,\r
+  /* 000001F4 nop                            */  0x90,\r
+  /* 000001F5 nop                            */  0x90,\r
+  /* 000001F6 nop                            */  0x90,\r
+  /* 000001F7 nop                            */  0x90,\r
+  /* 000001F8 nop                            */  0x90,\r
+  /* 000001F9 nop                            */  0x90,\r
+  /* 000001FA nop                            */  0x90,\r
+  /* 000001FB nop                            */  0x90,\r
+  /* 000001FC nop                            */  0x90,\r
+  /* 000001FD nop                            */  0x90,\r
+  /* 000001FE nop                            */  0x90,\r
+  /* 000001FF nop                            */  0x90,\r
+  /* 00000200 cmp ax,0x4f00                  */  0x3D, 0x00, 0x4F,\r
+  /* 00000203 jz 0x22d                       */  0x74, 0x28,\r
+  /* 00000205 cmp ax,0x4f01                  */  0x3D, 0x01, 0x4F,\r
+  /* 00000208 jz 0x245                       */  0x74, 0x3B,\r
+  /* 0000020A cmp ax,0x4f02                  */  0x3D, 0x02, 0x4F,\r
+  /* 0000020D jz 0x269                       */  0x74, 0x5A,\r
+  /* 0000020F cmp ax,0x4f03                  */  0x3D, 0x03, 0x4F,\r
+  /* 00000212 jz word 0x331                  */  0x0F, 0x84, 0x1B, 0x01,\r
+  /* 00000216 cmp ax,0x4f10                  */  0x3D, 0x10, 0x4F,\r
+  /* 00000219 jz word 0x336                  */  0x0F, 0x84, 0x19, 0x01,\r
+  /* 0000021D cmp ax,0x4f15                  */  0x3D, 0x15, 0x4F,\r
+  /* 00000220 jz word 0x338                  */  0x0F, 0x84, 0x14, 0x01,\r
+  /* 00000224 cmp ah,0x0                     */  0x80, 0xFC, 0x00,\r
+  /* 00000227 jz word 0x33a                  */  0x0F, 0x84, 0x0F, 0x01,\r
+  /* 0000022B jmp short 0x22b                */  0xEB, 0xFE,\r
+  /* 0000022D push es                        */  0x06,\r
+  /* 0000022E push di                        */  0x57,\r
+  /* 0000022F push ds                        */  0x1E,\r
+  /* 00000230 push si                        */  0x56,\r
+  /* 00000231 push cx                        */  0x51,\r
+  /* 00000232 push cs                        */  0x0E,\r
+  /* 00000233 pop ds                         */  0x1F,\r
+  /* 00000234 mov si,0x0                     */  0xBE, 0x00, 0x00,\r
+  /* 00000237 mov cx,0x100                   */  0xB9, 0x00, 0x01,\r
+  /* 0000023A cld                            */  0xFC,\r
+  /* 0000023B rep movsb                      */  0xF3, 0xA4,\r
+  /* 0000023D pop cx                         */  0x59,\r
+  /* 0000023E pop si                         */  0x5E,\r
+  /* 0000023F pop ds                         */  0x1F,\r
+  /* 00000240 pop di                         */  0x5F,\r
+  /* 00000241 pop es                         */  0x07,\r
+  /* 00000242 jmp word 0x34c                 */  0xE9, 0x07, 0x01,\r
+  /* 00000245 push es                        */  0x06,\r
+  /* 00000246 push di                        */  0x57,\r
+  /* 00000247 push ds                        */  0x1E,\r
+  /* 00000248 push si                        */  0x56,\r
+  /* 00000249 push cx                        */  0x51,\r
+  /* 0000024A and cx,0xbfff                  */  0x81, 0xE1, 0xFF, 0xBF,\r
+  /* 0000024E cmp cx,0xf1                    */  0x81, 0xF9, 0xF1, 0x00,\r
+  /* 00000252 jz 0x256                       */  0x74, 0x02,\r
+  /* 00000254 jmp short 0x22b                */  0xEB, 0xD5,\r
+  /* 00000256 push cs                        */  0x0E,\r
+  /* 00000257 pop ds                         */  0x1F,\r
+  /* 00000258 mov si,0x100                   */  0xBE, 0x00, 0x01,\r
+  /* 0000025B mov cx,0x100                   */  0xB9, 0x00, 0x01,\r
+  /* 0000025E cld                            */  0xFC,\r
+  /* 0000025F rep movsb                      */  0xF3, 0xA4,\r
+  /* 00000261 pop cx                         */  0x59,\r
+  /* 00000262 pop si                         */  0x5E,\r
+  /* 00000263 pop ds                         */  0x1F,\r
+  /* 00000264 pop di                         */  0x5F,\r
+  /* 00000265 pop es                         */  0x07,\r
+  /* 00000266 jmp word 0x34c                 */  0xE9, 0xE3, 0x00,\r
+  /* 00000269 push dx                        */  0x52,\r
+  /* 0000026A push ax                        */  0x50,\r
+  /* 0000026B cmp bx,0x40f1                  */  0x81, 0xFB, 0xF1, 0x40,\r
+  /* 0000026F jz 0x273                       */  0x74, 0x02,\r
+  /* 00000271 jmp short 0x22b                */  0xEB, 0xB8,\r
+  /* 00000273 mov dx,0x3c0                   */  0xBA, 0xC0, 0x03,\r
+  /* 00000276 mov al,0x20                    */  0xB0, 0x20,\r
+  /* 00000278 out dx,al                      */  0xEE,\r
+  /* 00000279 push dx                        */  0x52,\r
+  /* 0000027A push ax                        */  0x50,\r
+  /* 0000027B mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 0000027E mov ax,0x4                     */  0xB8, 0x04, 0x00,\r
+  /* 00000281 out dx,ax                      */  0xEF,\r
+  /* 00000282 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 00000285 mov ax,0x0                     */  0xB8, 0x00, 0x00,\r
+  /* 00000288 out dx,ax                      */  0xEF,\r
+  /* 00000289 pop ax                         */  0x58,\r
+  /* 0000028A pop dx                         */  0x5A,\r
+  /* 0000028B push dx                        */  0x52,\r
+  /* 0000028C push ax                        */  0x50,\r
+  /* 0000028D mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 00000290 mov ax,0x5                     */  0xB8, 0x05, 0x00,\r
+  /* 00000293 out dx,ax                      */  0xEF,\r
+  /* 00000294 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 00000297 mov ax,0x0                     */  0xB8, 0x00, 0x00,\r
+  /* 0000029A out dx,ax                      */  0xEF,\r
+  /* 0000029B pop ax                         */  0x58,\r
+  /* 0000029C pop dx                         */  0x5A,\r
+  /* 0000029D push dx                        */  0x52,\r
+  /* 0000029E push ax                        */  0x50,\r
+  /* 0000029F mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 000002A2 mov ax,0x8                     */  0xB8, 0x08, 0x00,\r
+  /* 000002A5 out dx,ax                      */  0xEF,\r
+  /* 000002A6 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 000002A9 mov ax,0x0                     */  0xB8, 0x00, 0x00,\r
+  /* 000002AC out dx,ax                      */  0xEF,\r
+  /* 000002AD pop ax                         */  0x58,\r
+  /* 000002AE pop dx                         */  0x5A,\r
+  /* 000002AF push dx                        */  0x52,\r
+  /* 000002B0 push ax                        */  0x50,\r
+  /* 000002B1 mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 000002B4 mov ax,0x9                     */  0xB8, 0x09, 0x00,\r
+  /* 000002B7 out dx,ax                      */  0xEF,\r
+  /* 000002B8 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 000002BB mov ax,0x0                     */  0xB8, 0x00, 0x00,\r
+  /* 000002BE out dx,ax                      */  0xEF,\r
+  /* 000002BF pop ax                         */  0x58,\r
+  /* 000002C0 pop dx                         */  0x5A,\r
+  /* 000002C1 push dx                        */  0x52,\r
+  /* 000002C2 push ax                        */  0x50,\r
+  /* 000002C3 mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 000002C6 mov ax,0x3                     */  0xB8, 0x03, 0x00,\r
+  /* 000002C9 out dx,ax                      */  0xEF,\r
+  /* 000002CA mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 000002CD mov ax,0x20                    */  0xB8, 0x20, 0x00,\r
+  /* 000002D0 out dx,ax                      */  0xEF,\r
+  /* 000002D1 pop ax                         */  0x58,\r
+  /* 000002D2 pop dx                         */  0x5A,\r
+  /* 000002D3 push dx                        */  0x52,\r
+  /* 000002D4 push ax                        */  0x50,\r
+  /* 000002D5 mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 000002D8 mov ax,0x1                     */  0xB8, 0x01, 0x00,\r
+  /* 000002DB out dx,ax                      */  0xEF,\r
+  /* 000002DC mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 000002DF mov ax,0x400                   */  0xB8, 0x00, 0x04,\r
+  /* 000002E2 out dx,ax                      */  0xEF,\r
+  /* 000002E3 pop ax                         */  0x58,\r
+  /* 000002E4 pop dx                         */  0x5A,\r
+  /* 000002E5 push dx                        */  0x52,\r
+  /* 000002E6 push ax                        */  0x50,\r
+  /* 000002E7 mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 000002EA mov ax,0x6                     */  0xB8, 0x06, 0x00,\r
+  /* 000002ED out dx,ax                      */  0xEF,\r
+  /* 000002EE mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 000002F1 mov ax,0x400                   */  0xB8, 0x00, 0x04,\r
+  /* 000002F4 out dx,ax                      */  0xEF,\r
+  /* 000002F5 pop ax                         */  0x58,\r
+  /* 000002F6 pop dx                         */  0x5A,\r
+  /* 000002F7 push dx                        */  0x52,\r
+  /* 000002F8 push ax                        */  0x50,\r
+  /* 000002F9 mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 000002FC mov ax,0x2                     */  0xB8, 0x02, 0x00,\r
+  /* 000002FF out dx,ax                      */  0xEF,\r
+  /* 00000300 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 00000303 mov ax,0x300                   */  0xB8, 0x00, 0x03,\r
+  /* 00000306 out dx,ax                      */  0xEF,\r
+  /* 00000307 pop ax                         */  0x58,\r
+  /* 00000308 pop dx                         */  0x5A,\r
+  /* 00000309 push dx                        */  0x52,\r
+  /* 0000030A push ax                        */  0x50,\r
+  /* 0000030B mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 0000030E mov ax,0x7                     */  0xB8, 0x07, 0x00,\r
+  /* 00000311 out dx,ax                      */  0xEF,\r
+  /* 00000312 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 00000315 mov ax,0x300                   */  0xB8, 0x00, 0x03,\r
+  /* 00000318 out dx,ax                      */  0xEF,\r
+  /* 00000319 pop ax                         */  0x58,\r
+  /* 0000031A pop dx                         */  0x5A,\r
+  /* 0000031B push dx                        */  0x52,\r
+  /* 0000031C push ax                        */  0x50,\r
+  /* 0000031D mov dx,0x1ce                   */  0xBA, 0xCE, 0x01,\r
+  /* 00000320 mov ax,0x4                     */  0xB8, 0x04, 0x00,\r
+  /* 00000323 out dx,ax                      */  0xEF,\r
+  /* 00000324 mov dx,0x1d0                   */  0xBA, 0xD0, 0x01,\r
+  /* 00000327 mov ax,0x41                    */  0xB8, 0x41, 0x00,\r
+  /* 0000032A out dx,ax                      */  0xEF,\r
+  /* 0000032B pop ax                         */  0x58,\r
+  /* 0000032C pop dx                         */  0x5A,\r
+  /* 0000032D pop ax                         */  0x58,\r
+  /* 0000032E pop dx                         */  0x5A,\r
+  /* 0000032F jmp short 0x34c                */  0xEB, 0x1B,\r
+  /* 00000331 mov bx,0x40f1                  */  0xBB, 0xF1, 0x40,\r
+  /* 00000334 jmp short 0x34c                */  0xEB, 0x16,\r
+  /* 00000336 jmp short 0x350                */  0xEB, 0x18,\r
+  /* 00000338 jmp short 0x350                */  0xEB, 0x16,\r
+  /* 0000033A cmp al,0x3                     */  0x3C, 0x03,\r
+  /* 0000033C jz 0x345                       */  0x74, 0x07,\r
+  /* 0000033E cmp al,0x12                    */  0x3C, 0x12,\r
+  /* 00000340 jz 0x349                       */  0x74, 0x07,\r
+  /* 00000342 jmp word 0x22b                 */  0xE9, 0xE6, 0xFE,\r
+  /* 00000345 mov al,0x30                    */  0xB0, 0x30,\r
+  /* 00000347 jmp short 0x34b                */  0xEB, 0x02,\r
+  /* 00000349 mov al,0x20                    */  0xB0, 0x20,\r
+  /* 0000034B iretw                          */  0xCF,\r
+  /* 0000034C mov ax,0x4f                    */  0xB8, 0x4F, 0x00,\r
+  /* 0000034F iretw                          */  0xCF,\r
+  /* 00000350 mov ax,0x14f                   */  0xB8, 0x4F, 0x01,\r
+  /* 00000353 iretw                          */  0xCF,\r
+};\r
+#endif\r
diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.sh b/OvmfPkg/QemuVideoDxe/VbeShim.sh
new file mode 100755 (executable)
index 0000000..7a6eba6
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+###
+# @file
+# Shell script to assemble and dump the fake Int10h handler from NASM source to
+# a C array.
+#
+# Copyright (C) 2014, Red Hat, Inc.
+# Copyright (c) 2013 - 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 -e -u
+
+STEM=$(dirname -- "$0")/$(basename -- "$0" .sh)
+
+#
+# Install exit handler -- remove temporary files.
+#
+exit_handler()
+{
+  rm -f -- "$STEM".bin "$STEM".disasm "$STEM".offsets "$STEM".insns \
+      "$STEM".bytes
+}
+trap exit_handler EXIT
+
+#
+# Assemble the source file.
+#
+nasm -o "$STEM".bin -- "$STEM".asm
+
+#
+# Disassemble it, in order to get a binary dump associated with the source.
+# (ndisasm doesn't recognize the "--" end-of-options delimiter.)
+#
+ndisasm "$STEM".bin >"$STEM".disasm
+
+#
+# Create three files, each with one column of the disassembly.
+#
+# The first column contains the offsets, and it starts the comment.
+#
+cut -c 1-8 -- "$STEM".disasm \
+| sed -e 's,^,  /* ,' >"$STEM".offsets
+
+#
+# The second column contains the assembly-language instructions, and it closes
+# the comment. We first pad it to 30 characters.
+#
+cut -c 29- -- "$STEM".disasm \
+| sed -e 's,$,                              ,' \
+      -e 's,^\(.\{30\}\).*$,\1 */,' >"$STEM".insns
+
+#
+# The third column contains the bytes corresponding to the instruction,
+# represented as C integer constants. First strip trailing whitespace from the
+# middle column of the input disassembly, then process pairs of nibbles.
+#
+cut -c 11-28 -- "$STEM".disasm \
+| sed -e 's, \+$,,' -e 's/\(..\)/ 0x\1,/g' >"$STEM".bytes
+
+#
+# Write the output file, recombining the columns. The output should have CRLF
+# line endings.
+#
+{
+  printf '//\n'
+  printf '// THIS FILE WAS GENERATED BY "%s". DO NOT EDIT.\n' \
+      "$(basename -- "$0")"
+  printf '//\n'
+  printf '#ifndef _VBE_SHIM_H_\n'
+  printf '#define _VBE_SHIM_H_\n'
+  printf 'STATIC CONST UINT8 mVbeShim[] = {\n'
+  paste -d ' ' -- "$STEM".offsets "$STEM".insns "$STEM".bytes
+  printf '};\n'
+  printf '#endif\n'
+} \
+| unix2dos >"$STEM".h
index be798063a03edcd4777c2bb2332d3c6d8114a89d..3243dc685c67ac5214dfc5dafde70791a5d6b9ca 100644 (file)
@@ -17,6 +17,7 @@ Current capabilities:
   - Optional NIC support.  Requires QEMU (0.12.2 or later)\r
 * UEFI Linux boots\r
 * UEFI Windows 8 boots\r
+* UEFI Windows 7 & Windows 2008 Server boot (see important notes below!)\r
 \r
 === FUTURE PLANS ===\r
 \r
@@ -243,3 +244,13 @@ selectively. For example:
       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG\r
   }\r
 \r
+=== UEFI Windows 7 & Windows 2008 Server ===\r
+\r
+* One of the '-vga std' and '-vga qxl' QEMU options should be used.\r
+* Only one video mode, 1024x768x32, is supported at OS runtime.\r
+* The '-vga qxl' QEMU option is recommended. After booting the installed\r
+  guest OS, select the video card in Device Manager, and upgrade its driver\r
+  to the QXL XDDM one. Download location:\r
+  <http://www.spice-space.org/download.html>, Guest | Windows binaries.\r
+  This enables further resolutions at OS runtime, and provides S3\r
+  (suspend/resume) capability.\r