]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Add QemuVideoDxe driver
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 12 Apr 2011 15:08:51 +0000 (15:08 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 12 Apr 2011 15:08:51 +0000 (15:08 +0000)
This driver provides a UEFI Graphics Output Protocol (GOP) driver
for the QEMU Cirrus VGA hardware.  It enables 24-bit color,
and uses the standard 32-bit GOP pixel format whenever possible.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11524 6f19259b-4bc3-4df7-8a09-765794883524

14 files changed:
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32.fdf
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgIa32X64.fdf
OvmfPkg/OvmfPkgX64.dsc
OvmfPkg/OvmfPkgX64.fdf
OvmfPkg/QemuVideoDxe/ComponentName.c [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/Driver.c [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/Gop.c [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/Initialize.c [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/Qemu.h [new file with mode: 0644]
OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf [new file with mode: 0644]
OvmfPkg/build.sh

index 3cba44dff66709b65799cacc6f7e10c497f81a76..5020226b3db7cc571ce9e4aee029444825db2d41 100644 (file)
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
   MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
 \r
-  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
+  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {\r
+    <LibraryClasses>\r
+      BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf\r
+  }\r
 \r
   #\r
   # ISA Support\r
index 50181b2d55a574d5d11432cd63b5c276a5ed5260..317c183910d552899e6ff374c867ddc921b7f942 100644 (file)
@@ -201,7 +201,6 @@ INF  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf
 INF  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf\r
 INF  MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf\r
 INF  RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf\r
-INF  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
 \r
 INF  RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf\r
 INF  RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf\r
@@ -355,7 +354,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
     RAW RAW                |.raw\r
   }\r
 \r
-[OptionRom.CirrusLogic5446]\r
-INF  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf {\r
+[OptionRom.OvmfVideo]\r
+INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {\r
     PCI_DEVICE_ID  = 0x00B8\r
   }\r
index 62afa06041e58996923e2d047fc1d41dfa27e34f..083c340da63951a2f2264306456a705bf2c9160f 100644 (file)
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
   MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
 \r
-  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
+  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {\r
+    <LibraryClasses>\r
+      BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf\r
+  }\r
 \r
   #\r
   # ISA Support\r
index e27ea4be8374869ec5c0fc1b16d480335920f8ba..94583573a18ca613ea410953a03fb16667850453 100644 (file)
@@ -201,7 +201,6 @@ INF  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf
 INF  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf\r
 INF  MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf\r
 INF  RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf\r
-INF  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
 \r
 INF  RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf\r
 INF  RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf\r
@@ -262,11 +261,11 @@ READ_LOCK_CAP      = TRUE
 READ_LOCK_STATUS   = TRUE\r
 \r
 FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {\r
-       SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {\r
-          SECTION FV_IMAGE = MAINFV\r
-       }\r
    }\r
-  \r
+   SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {\r
+     SECTION FV_IMAGE = MAINFV\r
+   }\r
+ }\r
+\r
 ################################################################################\r
 \r
 [Rule.Common.SEC]\r
@@ -355,7 +354,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
     RAW RAW                |.raw\r
   }\r
 \r
-[OptionRom.CirrusLogic5446]\r
-INF  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf {\r
+[OptionRom.OvmfVideo]\r
+INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {\r
     PCI_DEVICE_ID  = 0x00B8\r
   }\r
index 4a2410ef76519b3082465d4e9a930b061bef8874..d6e070a04366216910caffbf2f4d841e73eca7b5 100644 (file)
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
   MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
 \r
-  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
+  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {\r
+    <LibraryClasses>\r
+      BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf\r
+  }\r
 \r
   #\r
   # ISA Support\r
index 7a2192615ee304c9dc005526c310cfed3643423e..64ed6874691e8067efce0847ae198f739cded922 100644 (file)
@@ -201,7 +201,6 @@ INF  IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf
 INF  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf\r
 INF  MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf\r
 INF  RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf\r
-INF  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf\r
 \r
 INF  RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf\r
 INF  RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf\r
@@ -214,7 +213,7 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
 # Network modules\r
 #\r
 !if $(NETWORK_ENABLE)\r
-  FILE DRIVER = A5C9C8B3-5ABB-4be2-8CA6-2FF06F405D04 {\r
+  FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 {\r
     SECTION PE32 = Intel3.5/EFIX64/E3507X2.EFI\r
   }\r
   INF  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf\r
@@ -355,7 +354,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
     RAW RAW                |.raw\r
   }\r
 \r
-[OptionRom.CirrusLogic5446]\r
-INF  OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf {\r
+[OptionRom.OvmfVideo]\r
+INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {\r
     PCI_DEVICE_ID  = 0x00B8\r
   }\r
diff --git a/OvmfPkg/QemuVideoDxe/ComponentName.c b/OvmfPkg/QemuVideoDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..de1fe76
--- /dev/null
@@ -0,0 +1,212 @@
+/** @file\r
+  Component name for the QEMU video controller.\r
+\r
+  Copyright (c) 2006 - 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
+\r
+  THE PROGRAM IS 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 "Qemu.h"\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gQemuVideoComponentName = {\r
+  QemuVideoComponentNameGetDriverName,\r
+  QemuVideoComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gQemuVideoComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) QemuVideoComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) QemuVideoComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mQemuVideoDriverNameTable[] = {\r
+  { "eng;en", L"QEMU Video Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mQemuVideoControllerNameTable[] = {\r
+  { "eng;en", L"QEMU Video PCI Adapter" },\r
+  { NULL , NULL }\r
+};\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoComponentNameGetDriverName (\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
+           mQemuVideoDriverNameTable,\r
+           DriverName,\r
+           (BOOLEAN)(This == &gQemuVideoComponentName)\r
+           );\r
+}\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoComponentNameGetControllerName (\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
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure this driver is currently managing ControllHandle\r
+  //\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gQemuVideoDriverBinding.DriverBindingHandle,\r
+             &gEfiPciIoProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get the QEMU Video's Device structure\r
+  //\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mQemuVideoControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gQemuVideoComponentName)\r
+           );\r
+}\r
diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c
new file mode 100644 (file)
index 0000000..cb3e349
--- /dev/null
@@ -0,0 +1,742 @@
+/** @file\r
+  This driver is a sample implementation of the Graphics Output Protocol for\r
+  the QEMU (Cirrus Logic 5446) video controller.\r
+\r
+  Copyright (c) 2006 - 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
+\r
+  THE PROGRAM IS 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 "Qemu.h"\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gQemuVideoDriverBinding = {\r
+  QemuVideoControllerDriverSupported,\r
+  QemuVideoControllerDriverStart,\r
+  QemuVideoControllerDriverStop,\r
+  0x10,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+/**\r
+  Check if this device is supported.\r
+\r
+  @param  This                   The driver binding protocol.\r
+  @param  Controller             The controller handle to check.\r
+  @param  RemainingDevicePath    The remaining device path.\r
+\r
+  @retval EFI_SUCCESS            The bus supports this controller.\r
+  @retval EFI_UNSUPPORTED        This device isn't supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoControllerDriverSupported (\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          Pci;\r
+  EFI_DEV_PATH        *Node;\r
+\r
+  //\r
+  // Open the 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
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Read the PCI Configuration Header from the 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
+    goto Done;\r
+  }\r
+\r
+  Status = EFI_UNSUPPORTED;\r
+  //\r
+  // See if the I/O enable is on.  Most systems only allow one VGA device to be turned on\r
+  // at a time, so see if this is one that is turned on.\r
+  //\r
+  //  if (((Pci.Hdr.Command & 0x01) == 0x01)) {\r
+  //\r
+  // See if this is a Cirrus Logic PCI controller\r
+  //\r
+  if (Pci.Hdr.VendorId == CIRRUS_LOGIC_VENDOR_ID) {\r
+    //\r
+    // See if this is a 5430 or a 5446 PCI controller\r
+    //\r
+    if (Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_DEVICE_ID || \r
+        Pci.Hdr.DeviceId == CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID ||\r
+        Pci.Hdr.DeviceId == CIRRUS_LOGIC_5446_DEVICE_ID) {\r
+        \r
+      Status = EFI_SUCCESS;\r
+      //\r
+      // If this is an Intel 945 graphics controller,\r
+      // go further check RemainingDevicePath validation\r
+      //\r
+      if (RemainingDevicePath != NULL) {\r
+        Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
+        //\r
+        // Check if RemainingDevicePath is the End of Device Path Node, \r
+        // if yes, return EFI_SUCCESS\r
+        //\r
+        if (!IsDevicePathEnd (Node)) {\r
+          //\r
+          // If RemainingDevicePath isn't the End of Device Path Node,\r
+          // check its validation\r
+          //\r
+          if (Node->DevPath.Type != ACPI_DEVICE_PATH ||\r
+              Node->DevPath.SubType != ACPI_ADR_DP ||\r
+              DevicePathNodeLength(&Node->DevPath) != sizeof(ACPI_ADR_DEVICE_PATH)) {\r
+            Status = EFI_UNSUPPORTED;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+Done:\r
+  //\r
+  // Close the PCI I/O Protocol\r
+  //\r
+  gBS->CloseProtocol (\r
+        Controller,\r
+        &gEfiPciIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Controller\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Start to process the controller.\r
+\r
+  @param  This                   The USB bus driver binding instance.\r
+  @param  Controller             The controller to check.\r
+  @param  RemainingDevicePath    The remaining device patch.\r
+\r
+  @retval EFI_SUCCESS            The controller is controlled by the usb bus.\r
+  @retval EFI_ALREADY_STARTED    The controller is already controlled by the usb\r
+                                 bus.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoControllerDriverStart (\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
+  QEMU_VIDEO_PRIVATE_DATA  *Private;\r
+  BOOLEAN                         PciAttributesSaved;\r
+  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
+  ACPI_ADR_DEVICE_PATH            AcpiDeviceNode;\r
+\r
+  PciAttributesSaved = FALSE;\r
+  //\r
+  // Allocate Private context data for GOP inteface.\r
+  //\r
+  Private = AllocateZeroPool (sizeof (QEMU_VIDEO_PRIVATE_DATA));\r
+  if (Private == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Set up context record\r
+  //\r
+  Private->Signature  = QEMU_VIDEO_PRIVATE_DATA_SIGNATURE;\r
+  Private->Handle     = NULL;\r
+\r
+  //\r
+  // Open PCI I/O Protocol\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiPciIoProtocolGuid,\r
+                  (VOID **) &Private->PciIo,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Save original PCI attributes\r
+  //\r
+  Status = Private->PciIo->Attributes (\r
+                    Private->PciIo,\r
+                    EfiPciIoAttributeOperationGet,\r
+                    0,\r
+                    &Private->OriginalPciAttributes\r
+                    );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+  PciAttributesSaved = TRUE;\r
+\r
+  Status = Private->PciIo->Attributes (\r
+                            Private->PciIo,\r
+                            EfiPciIoAttributeOperationEnable,\r
+                            EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO,\r
+                            NULL\r
+                            );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Get ParentDevicePath\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  Controller,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Set Gop Device Path\r
+  //\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
+    Private->GopDevicePath = AppendDevicePathNode (\r
+                                        ParentDevicePath,\r
+                                        (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode\r
+                                        );\r
+  } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+    //\r
+    // If RemainingDevicePath isn't the End of Device Path Node, \r
+    // only scan the specified device by RemainingDevicePath\r
+    //\r
+    Private->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);\r
+  } else {\r
+    //\r
+    // If RemainingDevicePath is the End of Device Path Node, \r
+    // don't create child device and return EFI_SUCCESS\r
+    //\r
+    Private->GopDevicePath = NULL;\r
+  }\r
+    \r
+  if (Private->GopDevicePath != NULL) {\r
+    //\r
+    // Creat child handle and device path protocol firstly\r
+    //\r
+    Private->Handle = NULL;\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &Private->Handle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    Private->GopDevicePath,\r
+                    NULL\r
+                    );\r
+  }\r
+\r
+  //\r
+  // Construct video mode buffer\r
+  //\r
+  Status = QemuVideoVideoModeSetup (Private);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  if (Private->GopDevicePath == NULL) {\r
+    //\r
+    // If RemainingDevicePath is the End of Device Path Node, \r
+    // don't create child device and return EFI_SUCCESS\r
+    //\r
+    Status = EFI_SUCCESS;\r
+  } else {\r
+\r
+    //\r
+    // Start the GOP software stack.\r
+    //\r
+    Status = QemuVideoGraphicsOutputConstructor (Private);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &Private->Handle,\r
+                    &gEfiGraphicsOutputProtocolGuid,\r
+                    &Private->GraphicsOutput,\r
+                    NULL\r
+                    );\r
+  }\r
+\r
+Error:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private) {\r
+      if (Private->PciIo) {\r
+        if (PciAttributesSaved == TRUE) {\r
+          //\r
+          // Restore original PCI attributes\r
+          //\r
+          Private->PciIo->Attributes (\r
+                          Private->PciIo,\r
+                          EfiPciIoAttributeOperationSet,\r
+                          Private->OriginalPciAttributes,\r
+                          NULL\r
+                          );\r
+        }\r
+        //\r
+        // Close the PCI I/O Protocol\r
+        //\r
+        gBS->CloseProtocol (\r
+              Private->Handle,\r
+              &gEfiPciIoProtocolGuid,\r
+              This->DriverBindingHandle,\r
+              Private->Handle\r
+              );\r
+      }\r
+\r
+      gBS->FreePool (Private);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Stop this device\r
+\r
+  @param  This                   The USB bus driver binding protocol.\r
+  @param  Controller             The controller to release.\r
+  @param  NumberOfChildren       The number of children of this device that\r
+                                 opened the controller BY_CHILD.\r
+  @param  ChildHandleBuffer      The array of child handle.\r
+\r
+  @retval EFI_SUCCESS            The controller or children are stopped.\r
+  @retval EFI_DEVICE_ERROR       Failed to stop the driver.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoControllerDriverStop (\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_GRAPHICS_OUTPUT_PROTOCOL    *GraphicsOutput;\r
+\r
+  EFI_STATUS                      Status;\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  (VOID **) &GraphicsOutput,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get our private context information\r
+  //\r
+  Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);\r
+\r
+  QemuVideoGraphicsOutputDestructor (Private);\r
+  //\r
+  // Remove the GOP protocol interface from the system\r
+  //\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  Private->Handle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  &Private->GraphicsOutput,\r
+                  NULL\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Restore original PCI attributes\r
+  //\r
+  Private->PciIo->Attributes (\r
+                  Private->PciIo,\r
+                  EfiPciIoAttributeOperationSet,\r
+                  Private->OriginalPciAttributes,\r
+                  NULL\r
+                  );\r
+\r
+  //\r
+  // Close the PCI I/O Protocol\r
+  //\r
+  gBS->CloseProtocol (\r
+        Controller,\r
+        &gEfiPciIoProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Controller\r
+        );\r
+\r
+  //\r
+  // Free our instance data\r
+  //\r
+  gBS->FreePool (Private);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+  @param  Address TODO: add argument description\r
+  @param  Data TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+outb (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address,\r
+  UINT8                           Data\r
+  )\r
+{\r
+  Private->PciIo->Io.Write (\r
+                      Private->PciIo,\r
+                      EfiPciIoWidthUint8,\r
+                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
+                      Address,\r
+                      1,\r
+                      &Data\r
+                      );\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+  @param  Address TODO: add argument description\r
+  @param  Data TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+outw (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address,\r
+  UINT16                          Data\r
+  )\r
+{\r
+  Private->PciIo->Io.Write (\r
+                      Private->PciIo,\r
+                      EfiPciIoWidthUint16,\r
+                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
+                      Address,\r
+                      1,\r
+                      &Data\r
+                      );\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+  @param  Address TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+UINT8\r
+inb (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address\r
+  )\r
+{\r
+  UINT8 Data;\r
+\r
+  Private->PciIo->Io.Read (\r
+                      Private->PciIo,\r
+                      EfiPciIoWidthUint8,\r
+                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
+                      Address,\r
+                      1,\r
+                      &Data\r
+                      );\r
+  return Data;\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+  @param  Address TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+UINT16\r
+inw (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address\r
+  )\r
+{\r
+  UINT16  Data;\r
+\r
+  Private->PciIo->Io.Read (\r
+                      Private->PciIo,\r
+                      EfiPciIoWidthUint16,\r
+                      EFI_PCI_IO_PASS_THROUGH_BAR,\r
+                      Address,\r
+                      1,\r
+                      &Data\r
+                      );\r
+  return Data;\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+  @param  Index TODO: add argument description\r
+  @param  Red TODO: add argument description\r
+  @param  Green TODO: add argument description\r
+  @param  Blue TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+SetPaletteColor (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Index,\r
+  UINT8                           Red,\r
+  UINT8                           Green,\r
+  UINT8                           Blue\r
+  )\r
+{\r
+  outb (Private, PALETTE_INDEX_REGISTER, (UINT8) Index);\r
+  outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Red >> 2));\r
+  outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Green >> 2));\r
+  outb (Private, PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2));\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+SetDefaultPalette (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  )\r
+{\r
+  UINTN Index;\r
+  UINTN RedIndex;\r
+  UINTN GreenIndex;\r
+  UINTN BlueIndex;\r
+\r
+  Index = 0;\r
+  for (RedIndex = 0; RedIndex < 8; RedIndex++) {\r
+    for (GreenIndex = 0; GreenIndex < 8; GreenIndex++) {\r
+      for (BlueIndex = 0; BlueIndex < 4; BlueIndex++) {\r
+        SetPaletteColor (Private, Index, (UINT8) (RedIndex << 5), (UINT8) (GreenIndex << 5), (UINT8) (BlueIndex << 6));\r
+        Index++;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+ClearScreen (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  )\r
+{\r
+  UINT32  Color;\r
+\r
+  Color = 0;\r
+  Private->PciIo->Mem.Write (\r
+                        Private->PciIo,\r
+                        EfiPciIoWidthFillUint32,\r
+                        0,\r
+                        0,\r
+                        0x400000 >> 2,\r
+                        &Color\r
+                        );\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+DrawLogo (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           ScreenWidth,\r
+  UINTN                           ScreenHeight\r
+  )\r
+{\r
+}\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  Private TODO: add argument description\r
+  @param  ModeData TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+VOID\r
+InitializeGraphicsMode (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  QEMU_VIDEO_VIDEO_MODES   *ModeData\r
+  )\r
+{\r
+  UINT8 Byte;\r
+  UINTN Index;\r
+  UINT16 DeviceId;\r
+  EFI_STATUS Status;\r
+\r
+  Status = Private->PciIo->Pci.Read (\r
+             Private->PciIo,\r
+             EfiPciIoWidthUint16,\r
+             PCI_DEVICE_ID_OFFSET,\r
+             1,\r
+             &DeviceId\r
+             );\r
+  //\r
+  // Read the PCI Configuration Header from the PCI Device\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  outw (Private, SEQ_ADDRESS_REGISTER, 0x1206);\r
+  outw (Private, SEQ_ADDRESS_REGISTER, 0x0012);\r
+\r
+  for (Index = 0; Index < 15; Index++) {\r
+    outw (Private, SEQ_ADDRESS_REGISTER, ModeData->SeqSettings[Index]);\r
+  }\r
+\r
+  if (DeviceId != CIRRUS_LOGIC_5446_DEVICE_ID) {\r
+    outb (Private, SEQ_ADDRESS_REGISTER, 0x0f);\r
+    Byte = (UINT8) ((inb (Private, SEQ_DATA_REGISTER) & 0xc7) ^ 0x30);\r
+    outb (Private, SEQ_DATA_REGISTER, Byte);\r
+  }\r
+\r
+  outb (Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting);\r
+  outw (Private, GRAPH_ADDRESS_REGISTER, 0x0506);\r
+  outw (Private, SEQ_ADDRESS_REGISTER, 0x0300);\r
+  outw (Private, CRTC_ADDRESS_REGISTER, 0x2011);\r
+\r
+  for (Index = 0; Index < 28; Index++) {\r
+    outw (Private, CRTC_ADDRESS_REGISTER, (UINT16) ((ModeData->CrtcSettings[Index] << 8) | Index));\r
+  }\r
+\r
+  for (Index = 0; Index < 9; Index++) {\r
+    outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((GraphicsController[Index] << 8) | Index));\r
+  }\r
+\r
+  inb (Private, INPUT_STATUS_1_REGISTER);\r
+\r
+  for (Index = 0; Index < 21; Index++) {\r
+    outb (Private, ATT_ADDRESS_REGISTER, (UINT8) Index);\r
+    outb (Private, ATT_ADDRESS_REGISTER, AttributeController[Index]);\r
+  }\r
+\r
+  outb (Private, ATT_ADDRESS_REGISTER, 0x20);\r
+\r
+  outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009);\r
+  outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a);\r
+  outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b);\r
+  outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff);\r
+\r
+  SetDefaultPalette (Private);\r
+  ClearScreen (Private);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeQemuVideo (\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
+             &gQemuVideoDriverBinding,\r
+             ImageHandle,\r
+             &gQemuVideoComponentName,\r
+             &gQemuVideoComponentName2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Install EFI Driver Supported EFI Version Protocol required for\r
+  // EFI drivers that are on PCI and other plug in cards.\r
+  //\r
+  gQemuVideoDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &ImageHandle,\r
+                  &gEfiDriverSupportedEfiVersionProtocolGuid,\r
+                  &gQemuVideoDriverSupportedEfiVersion,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c b/OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c
new file mode 100644 (file)
index 0000000..5691e41
--- /dev/null
@@ -0,0 +1,21 @@
+/** @file\r
+  Driver supported version protocol for the QEMU video driver.\r
+\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
+\r
+  THE PROGRAM IS 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
+#include "Qemu.h"\r
+\r
+EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gQemuVideoDriverSupportedEfiVersion = {\r
+  sizeof (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL), // Size of Protocol structure.\r
+  0                                                   // Version number to be filled at start up.\r
+};\r
+\r
diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
new file mode 100644 (file)
index 0000000..d364630
--- /dev/null
@@ -0,0 +1,361 @@
+/** @file\r
+  Graphics Output Protocol functions for the QEMU video controller.\r
+\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
+\r
+  THE PROGRAM IS 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 "Qemu.h"\r
+#include <IndustryStandard/Acpi.h>\r
+#include <Library/BltLib.h>\r
+\r
+STATIC\r
+VOID\r
+QemuVideoCompleteModeInfo (\r
+  IN  QEMU_VIDEO_MODE_DATA           *ModeData,\r
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info\r
+  )\r
+{\r
+  Info->Version = 0;\r
+  if (ModeData->ColorDepth == 8) {\r
+    Info->PixelFormat = PixelBitMask;\r
+    Info->PixelInformation.RedMask = PIXEL_RED_MASK;\r
+    Info->PixelInformation.GreenMask = PIXEL_GREEN_MASK;\r
+    Info->PixelInformation.BlueMask = PIXEL_BLUE_MASK;\r
+    Info->PixelInformation.ReservedMask = 0;\r
+  } else if (ModeData->ColorDepth == 24) {\r
+    Info->PixelFormat = PixelBitMask;\r
+    Info->PixelInformation.RedMask = PIXEL24_RED_MASK;\r
+    Info->PixelInformation.GreenMask = PIXEL24_GREEN_MASK;\r
+    Info->PixelInformation.BlueMask = PIXEL24_BLUE_MASK;\r
+    Info->PixelInformation.ReservedMask = 0;\r
+  } else if (ModeData->ColorDepth == 32) {\r
+    DEBUG ((EFI_D_INFO, "PixelBlueGreenRedReserved8BitPerColor\n"));\r
+    Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;\r
+  }\r
+  Info->PixelsPerScanLine = Info->HorizontalResolution;\r
+}\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+QemuVideoCompleteModeData (\r
+  IN  QEMU_VIDEO_PRIVATE_DATA           *Private,\r
+  OUT EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode\r
+  )\r
+{\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;\r
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR     *FrameBufDesc;\r
+  QEMU_VIDEO_MODE_DATA           *ModeData;\r
+\r
+  ModeData = &Private->ModeData[Mode->Mode];\r
+  Info = Mode->Info;\r
+  QemuVideoCompleteModeInfo (ModeData, Info);\r
+\r
+  Private->PciIo->GetBarAttributes (\r
+                        Private->PciIo,\r
+                        0,\r
+                        NULL,\r
+                        (VOID**) &FrameBufDesc\r
+                        );\r
+\r
+  Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin;\r
+  Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution;\r
+  Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) / 8);\r
+  DEBUG ((EFI_D_INFO, "FrameBufferBase: 0x%x, FrameBufferSize: 0x%x\n", Mode->FrameBufferBase, Mode->FrameBufferSize));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+//\r
+// Graphics Output Protocol Member Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoGraphicsOutputQueryMode (\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
+Routine Description:\r
+\r
+  Graphics Output protocol interface to query video mode\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    ModeNumber            - The mode number to return information on.\r
+    Info                  - Caller allocated buffer that returns information about ModeNumber.\r
+    SizeOfInfo            - A pointer to the size, in bytes, of the Info buffer.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - Mode information returned.\r
+    EFI_BUFFER_TOO_SMALL  - The Info buffer was too small.\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
+{\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private;\r
+  QEMU_VIDEO_MODE_DATA     *ModeData;\r
+\r
+  Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+  if (Private->HardwareNeedsStarting) {\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r
+  if (*Info == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+\r
+  ModeData = &Private->ModeData[ModeNumber];\r
+  (*Info)->HorizontalResolution = ModeData->HorizontalResolution;\r
+  (*Info)->VerticalResolution   = ModeData->VerticalResolution;\r
+  QemuVideoCompleteModeInfo (ModeData, *Info);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoGraphicsOutputSetMode (\r
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+  IN  UINT32                       ModeNumber\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Graphics Output protocol interface to set video mode\r
+\r
+  Arguments:\r
+    This             - Protocol instance pointer.\r
+    ModeNumber       - The mode number to be set.\r
+\r
+  Returns:\r
+    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
+{\r
+  QEMU_VIDEO_PRIVATE_DATA    *Private;\r
+  QEMU_VIDEO_MODE_DATA       *ModeData;\r
+//  UINTN                             Count;\r
+\r
+  Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+  if (ModeNumber >= This->Mode->MaxMode) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ModeData = &Private->ModeData[ModeNumber];\r
+\r
+  if (Private->LineBuffer) {\r
+    gBS->FreePool (Private->LineBuffer);\r
+  }\r
+\r
+  Private->LineBuffer = NULL;\r
+  Private->LineBuffer = AllocatePool (4 * ModeData->HorizontalResolution);\r
+  if (Private->LineBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  InitializeGraphicsMode (Private, &QemuVideoVideoModes[ModeData->ModeNumber]);\r
+\r
+  This->Mode->Mode = ModeNumber;\r
+  This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;\r
+  This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;\r
+  This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+\r
+  QemuVideoCompleteModeData (Private, This->Mode);\r
+\r
+  BltLibConfigure (\r
+    (VOID*)(UINTN) This->Mode->FrameBufferBase,\r
+    This->Mode->Info\r
+    );\r
+\r
+  Private->HardwareNeedsStarting  = FALSE;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoGraphicsOutputBlt (\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
+Routine Description:\r
+\r
+  Graphics Output protocol instance to block transfer for CirrusLogic device\r
+\r
+Arguments:\r
+\r
+  This          - Pointer to Graphics Output protocol instance\r
+  BltBuffer     - The data to transfer to screen\r
+  BltOperation  - The operation to perform\r
+  SourceX       - The X coordinate of the source for BltOperation\r
+  SourceY       - The Y coordinate of the source for BltOperation\r
+  DestinationX  - The X coordinate of the destination for BltOperation\r
+  DestinationY  - The Y coordinate of the destination for BltOperation\r
+  Width         - The width of a rectangle in the blt rectangle in pixels\r
+  Height        - The height of a rectangle in the blt rectangle in pixels\r
+  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
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER - Invalid parameter passed in\r
+  EFI_SUCCESS - Blt operation success\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_TPL                         OriginalTPL;\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
+  case EfiBltBufferToVideo:\r
+  case EfiBltVideoFill:\r
+  case EfiBltVideoToVideo:\r
+    Status = BltLibGopBlt (\r
+      BltBuffer,\r
+      BltOperation,\r
+      SourceX,\r
+      SourceY,\r
+      DestinationX,\r
+      DestinationY,\r
+      Width,\r
+      Height,\r
+      Delta\r
+      );\r
+    break;\r
+\r
+  default:\r
+    Status = EFI_INVALID_PARAMETER;\r
+    ASSERT (FALSE);\r
+  }\r
+\r
+  gBS->RestoreTPL (OriginalTPL);\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+QemuVideoGraphicsOutputConstructor (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+\r
+\r
+  GraphicsOutput            = &Private->GraphicsOutput;\r
+  GraphicsOutput->QueryMode = QemuVideoGraphicsOutputQueryMode;\r
+  GraphicsOutput->SetMode   = QemuVideoGraphicsOutputSetMode;\r
+  GraphicsOutput->Blt       = QemuVideoGraphicsOutputBlt;\r
+\r
+  //\r
+  // Initialize the private data\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE),\r
+                  (VOID **) &Private->GraphicsOutput.Mode\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
+                  (VOID **) &Private->GraphicsOutput.Mode->Info\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;\r
+  Private->GraphicsOutput.Mode->Mode    = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
+  Private->HardwareNeedsStarting        = TRUE;\r
+  Private->LineBuffer                   = NULL;\r
+\r
+  //\r
+  // Initialize the hardware\r
+  //\r
+  GraphicsOutput->SetMode (GraphicsOutput, 0);\r
+  DrawLogo (\r
+    Private,\r
+    Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,\r
+    Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution\r
+    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+QemuVideoGraphicsOutputDestructor (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+{\r
+  if (Private->GraphicsOutput.Mode != NULL) {\r
+    if (Private->GraphicsOutput.Mode->Info != NULL) {\r
+      gBS->FreePool (Private->GraphicsOutput.Mode->Info);\r
+    }\r
+    gBS->FreePool (Private->GraphicsOutput.Mode);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c b/OvmfPkg/QemuVideoDxe/Initialize.c
new file mode 100644 (file)
index 0000000..2491733
--- /dev/null
@@ -0,0 +1,203 @@
+/** @file\r
+  Graphics Output Protocol functions for the QEMU video controller.\r
+\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
+\r
+  THE PROGRAM IS 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 "Qemu.h"\r
+\r
+\r
+///\r
+/// Generic Attribute Controller Register Settings\r
+///\r
+UINT8  AttributeController[21] = {\r
+  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\r
+  0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,\r
+  0x41, 0x00, 0x0F, 0x00, 0x00\r
+};\r
+\r
+///\r
+/// Generic Graphics Controller Register Settings\r
+///\r
+UINT8 GraphicsController[9] = {\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF\r
+};\r
+\r
+//\r
+// 640 x 480 x 256 color @ 60 Hertz\r
+//\r
+UINT8 Crtc_640_480_256_60[28] = {\r
+  0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,\r
+  0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,\r
+  0xff, 0x00, 0x00, 0x22\r
+};\r
+\r
+UINT8 Crtc_640_480_32bpp_60[28] = {\r
+  0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,\r
+  0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0xe1, 0x83, 0xdf, 0x40, 0x00, 0xe7, 0x04, 0xe3,\r
+  0xff, 0x00, 0x00, 0x32\r
+};\r
+\r
+UINT16 Seq_640_480_256_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e\r
+};\r
+\r
+UINT16 Seq_640_480_32bpp_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e\r
+};\r
+\r
+//\r
+// 800 x 600 x 256 color @ 60 Hertz\r
+//\r
+UINT8 Crtc_800_600_256_60[28] = {\r
+  0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,\r
+  0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,\r
+  0xFF, 0x00, 0x00, 0x22\r
+};\r
+\r
+UINT8 Crtc_800_600_32bpp_60[28] = {\r
+  0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,\r
+  0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x58, 0x8C, 0x57, 0x90, 0x00, 0x5F, 0x91, 0xE3,\r
+  0xFF, 0x00, 0x00, 0x32\r
+};\r
+\r
+UINT16 Seq_800_600_256_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e\r
+};\r
+\r
+UINT16 Seq_800_600_32bpp_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e\r
+};\r
+\r
+UINT8 Crtc_960_720_32bpp_60[28] = {\r
+  0xA3, 0x77, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,\r
+  0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x02, 0x88, 0xCF, 0xe0, 0x00, 0x00, 0x64, 0xE3,\r
+  0xFF, 0x4A, 0x00, 0x32\r
+};\r
+\r
+UINT16 Seq_960_720_32bpp_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e\r
+};\r
+\r
+//\r
+// 1024 x 768 x 256 color @ 60 Hertz\r
+//\r
+UINT8 Crtc_1024_768_256_60[28] = {\r
+  0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,\r
+  0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,\r
+  0xFF, 0x4A, 0x00, 0x22\r
+};\r
+\r
+UINT16 Seq_1024_768_256_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e\r
+};\r
+\r
+//\r
+// 1024 x 768 x 24-bit color @ 60 Hertz\r
+//\r
+UINT8 Crtc_1024_768_24bpp_60[28] = {\r
+  0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,\r
+  0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,\r
+  0xFF, 0x4A, 0x00, 0x32\r
+};\r
+\r
+UINT16 Seq_1024_768_24bpp_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1507, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e\r
+};\r
+\r
+UINT8 Crtc_1024_768_32bpp_60[28] = {\r
+  0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,\r
+  0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x02, 0x88, 0xFF, 0xe0, 0x00, 0x00, 0x64, 0xE3,\r
+  0xFF, 0x4A, 0x00, 0x32\r
+};\r
+\r
+UINT16 Seq_1024_768_32bpp_60[15] = {\r
+  0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b,\r
+  0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e\r
+};\r
+\r
+///\r
+/// Table of supported video modes\r
+///\r
+QEMU_VIDEO_VIDEO_MODES  QemuVideoVideoModes[] = {\r
+//  {  640, 480, 8, 60, Crtc_640_480_256_60,  Seq_640_480_256_60,  0xe3 },\r
+//  {  800, 600, 8, 60, Crtc_800_600_256_60,  Seq_800_600_256_60,  0xef },\r
+  {  640, 480, 32, 60, Crtc_640_480_32bpp_60,  Seq_640_480_32bpp_60,  0xef },\r
+  {  800, 600, 32, 60, Crtc_800_600_32bpp_60,  Seq_800_600_32bpp_60,  0xef },\r
+//  { 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }\r
+  { 1024, 768, 24, 60, Crtc_1024_768_24bpp_60, Seq_1024_768_24bpp_60, 0xef }\r
+//  { 1024, 768, 32, 60, Crtc_1024_768_32bpp_60, Seq_1024_768_32bpp_60, 0xef }\r
+//  { 960, 720, 32, 60, Crtc_960_720_32bpp_60, Seq_1024_768_32bpp_60, 0xef }\r
+};\r
+\r
+#define QEMU_VIDEO_MODE_COUNT \\r
+  (sizeof (QemuVideoVideoModes) / sizeof (QemuVideoVideoModes[0]))\r
+\r
+/**\r
+  Construct the valid video modes for QemuVideo.\r
+\r
+**/\r
+EFI_STATUS\r
+QemuVideoVideoModeSetup (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  )\r
+{\r
+  UINT32                                 Index;\r
+  QEMU_VIDEO_MODE_DATA                   *ModeData;\r
+  QEMU_VIDEO_VIDEO_MODES                 *VideoMode;\r
+\r
+  //\r
+  // Setup Video Modes\r
+  //\r
+  Private->ModeData = AllocatePool (\r
+                        sizeof (Private->ModeData[0]) * QEMU_VIDEO_MODE_COUNT\r
+                        );\r
+  ModeData = Private->ModeData;\r
+  VideoMode = &QemuVideoVideoModes[0];\r
+  for (Index = 0; Index < QEMU_VIDEO_MODE_COUNT; Index ++) {\r
+    ModeData->ModeNumber = Index;\r
+    ModeData->HorizontalResolution          = VideoMode->Width;\r
+    ModeData->VerticalResolution            = VideoMode->Height;\r
+    ModeData->ColorDepth                    = VideoMode->ColorDepth;\r
+    ModeData->RefreshRate                   = VideoMode->RefreshRate;\r
+    DEBUG ((EFI_D_INFO,\r
+      "Adding Video Mode %d: %dx%d, %d-bit, %d Hz\n",\r
+      ModeData->ModeNumber,\r
+      ModeData->HorizontalResolution,\r
+      ModeData->VerticalResolution,\r
+      ModeData->ColorDepth,\r
+      ModeData->RefreshRate\r
+      ));\r
+\r
+    ModeData ++ ;\r
+    VideoMode ++;\r
+  }\r
+  Private->MaxMode = QEMU_VIDEO_MODE_COUNT;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
new file mode 100644 (file)
index 0000000..d3d5f6f
--- /dev/null
@@ -0,0 +1,418 @@
+/** @file\r
+  QEMU Video Controller Driver\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+//\r
+// QEMU Video Controller Driver\r
+//\r
+\r
+#ifndef _QEMU_H_\r
+#define _QEMU_H_\r
+\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/DriverSupportedEfiVersion.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/TimerLib.h>\r
+\r
+#include <IndustryStandard/Pci.h>\r
+\r
+//\r
+// QEMU Video PCI Configuration Header values\r
+//\r
+#define CIRRUS_LOGIC_VENDOR_ID                0x1013\r
+#define CIRRUS_LOGIC_5430_DEVICE_ID           0x00a8\r
+#define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0\r
+#define CIRRUS_LOGIC_5446_DEVICE_ID           0x00b8\r
+\r
+//\r
+// QEMU Vide Graphical Mode Data\r
+//\r
+typedef struct {\r
+  UINT32  ModeNumber;\r
+  UINT32  HorizontalResolution;\r
+  UINT32  VerticalResolution;\r
+  UINT32  ColorDepth;\r
+  UINT32  RefreshRate;\r
+} QEMU_VIDEO_MODE_DATA;\r
+\r
+#define PIXEL_RED_SHIFT   0\r
+#define PIXEL_GREEN_SHIFT 3\r
+#define PIXEL_BLUE_SHIFT  6\r
+\r
+#define PIXEL_RED_MASK    (BIT7 | BIT6 | BIT5)\r
+#define PIXEL_GREEN_MASK  (BIT4 | BIT3 | BIT2)\r
+#define PIXEL_BLUE_MASK   (BIT1 | BIT0)\r
+\r
+#define PIXEL_TO_COLOR_BYTE(pixel, mask, shift) ((UINT8) ((pixel & mask) << shift))\r
+#define PIXEL_TO_RED_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_RED_MASK, PIXEL_RED_SHIFT)\r
+#define PIXEL_TO_GREEN_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_GREEN_MASK, PIXEL_GREEN_SHIFT)\r
+#define PIXEL_TO_BLUE_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_BLUE_MASK, PIXEL_BLUE_SHIFT)\r
+\r
+#define RGB_BYTES_TO_PIXEL(Red, Green, Blue) \\r
+  (UINT8) ( (((Red) >> PIXEL_RED_SHIFT) & PIXEL_RED_MASK) | \\r
+            (((Green) >> PIXEL_GREEN_SHIFT) & PIXEL_GREEN_MASK) | \\r
+            (((Blue) >> PIXEL_BLUE_SHIFT) & PIXEL_BLUE_MASK) )\r
+\r
+#define PIXEL24_RED_MASK    0x00ff0000\r
+#define PIXEL24_GREEN_MASK  0x0000ff00\r
+#define PIXEL24_BLUE_MASK   0x000000ff\r
+\r
+#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER  0xffff\r
+\r
+//\r
+// QEMU Video Private Data Structure\r
+//\r
+#define QEMU_VIDEO_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('Q', 'V', 'I', 'D')\r
+\r
+typedef struct {\r
+  UINT64                                Signature;\r
+  EFI_HANDLE                            Handle;\r
+  EFI_PCI_IO_PROTOCOL                   *PciIo;\r
+  UINT64                                OriginalPciAttributes;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL          GraphicsOutput;\r
+  EFI_DEVICE_PATH_PROTOCOL              *GopDevicePath;\r
+  UINTN                                 CurrentMode;\r
+  UINTN                                 MaxMode;\r
+  QEMU_VIDEO_MODE_DATA                  *ModeData;\r
+  UINT8                                 *LineBuffer;\r
+  BOOLEAN                               HardwareNeedsStarting;\r
+} QEMU_VIDEO_PRIVATE_DATA;\r
+\r
+///\r
+/// Video Mode structure\r
+///\r
+typedef struct {\r
+  UINT32  Width;\r
+  UINT32  Height;\r
+  UINT32  ColorDepth;\r
+  UINT32  RefreshRate;\r
+  UINT8   *CrtcSettings;\r
+  UINT16  *SeqSettings;\r
+  UINT8   MiscSetting;\r
+} QEMU_VIDEO_VIDEO_MODES;\r
+\r
+#define QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \\r
+  CR(a, QEMU_VIDEO_PRIVATE_DATA, GraphicsOutput, QEMU_VIDEO_PRIVATE_DATA_SIGNATURE)\r
+\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern UINT8                                      AttributeController[];\r
+extern UINT8                                      GraphicsController[];\r
+extern UINT8                                      Crtc_640_480_256_60[];\r
+extern UINT16                                     Seq_640_480_256_60[];\r
+extern UINT8                                      Crtc_800_600_256_60[];\r
+extern UINT16                                     Seq_800_600_256_60[];\r
+extern UINT8                                      Crtc_1024_768_256_60[];\r
+extern UINT16                                     Seq_1024_768_256_60[];\r
+extern QEMU_VIDEO_VIDEO_MODES              QemuVideoVideoModes[];\r
+extern EFI_DRIVER_BINDING_PROTOCOL                gQemuVideoDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL                gQemuVideoComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL               gQemuVideoComponentName2;\r
+extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL  gQemuVideoDriverSupportedEfiVersion;\r
+\r
+//\r
+// Io Registers defined by VGA\r
+//\r
+#define CRTC_ADDRESS_REGISTER   0x3d4\r
+#define CRTC_DATA_REGISTER      0x3d5\r
+#define SEQ_ADDRESS_REGISTER    0x3c4\r
+#define SEQ_DATA_REGISTER       0x3c5\r
+#define GRAPH_ADDRESS_REGISTER  0x3ce\r
+#define GRAPH_DATA_REGISTER     0x3cf\r
+#define ATT_ADDRESS_REGISTER    0x3c0\r
+#define MISC_OUTPUT_REGISTER    0x3c2\r
+#define INPUT_STATUS_1_REGISTER 0x3da\r
+#define DAC_PIXEL_MASK_REGISTER 0x3c6\r
+#define PALETTE_INDEX_REGISTER  0x3c8\r
+#define PALETTE_DATA_REGISTER   0x3c9\r
+\r
+\r
+//\r
+// Graphics Output Hardware abstraction internal worker functions\r
+//\r
+EFI_STATUS\r
+QemuVideoGraphicsOutputConstructor (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  );\r
+\r
+EFI_STATUS\r
+QemuVideoGraphicsOutputDestructor (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  );\r
+\r
+\r
+//\r
+// EFI_DRIVER_BINDING_PROTOCOL Protocol Interface\r
+//\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  This TODO: add argument description\r
+  @param  Controller TODO: add argument description\r
+  @param  RemainingDevicePath TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoControllerDriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  This TODO: add argument description\r
+  @param  Controller TODO: add argument description\r
+  @param  RemainingDevicePath TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoControllerDriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  );\r
+\r
+/**\r
+  TODO: Add function description\r
+\r
+  @param  This TODO: add argument description\r
+  @param  Controller TODO: add argument description\r
+  @param  NumberOfChildren TODO: add argument description\r
+  @param  ChildHandleBuffer TODO: add argument description\r
+\r
+  TODO: add return values\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoControllerDriverStop (\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
+// EFI Component Name Functions\r
+//\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoComponentNameGetDriverName (\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 a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuVideoComponentNameGetControllerName (\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
+//\r
+// Local Function Prototypes\r
+//\r
+VOID\r
+InitializeGraphicsMode (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  QEMU_VIDEO_VIDEO_MODES   *ModeData\r
+  );\r
+\r
+VOID\r
+SetPaletteColor (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Index,\r
+  UINT8                           Red,\r
+  UINT8                           Green,\r
+  UINT8                           Blue\r
+  );\r
+\r
+VOID\r
+SetDefaultPalette (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  );\r
+\r
+VOID\r
+DrawLogo (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           ScreenWidth,\r
+  UINTN                           ScreenHeight\r
+  );\r
+\r
+VOID\r
+outb (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address,\r
+  UINT8                           Data\r
+  );\r
+\r
+VOID\r
+outw (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address,\r
+  UINT16                          Data\r
+  );\r
+\r
+UINT8\r
+inb (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address\r
+  );\r
+\r
+UINT16\r
+inw (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private,\r
+  UINTN                           Address\r
+  );\r
+\r
+EFI_STATUS\r
+QemuVideoVideoModeSetup (\r
+  QEMU_VIDEO_PRIVATE_DATA  *Private\r
+  );\r
+\r
+#endif\r
diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
new file mode 100644 (file)
index 0000000..6b19fb9
--- /dev/null
@@ -0,0 +1,71 @@
+#/** @file\r
+#  This driver is a sample implementation of the Graphics Output Protocol for\r
+#  the QEMU (Cirrus Logic 5446) video controller.\r
+#\r
+#  Copyright (c) 2006 - 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
+#\r
+#  THE PROGRAM IS 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                      = QemuVideoDxe\r
+  FILE_GUID                      = e3752948-b9a1-4770-90c4-df41c38986be\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeQemuVideo\r
+\r
+  PCI_VENDOR_ID  = 0x1013\r
+  PCI_DEVICE_ID  = 0x00A8\r
+  PCI_CLASS_CODE = 0x030000\r
+  PCI_REVISION   = 0x00\r
+  COMPRESS       = TRUE\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gQemuVideoDriverBinding\r
+#  COMPONENT_NAME                =  gQemuVideoComponentName\r
+#\r
+\r
+[Sources.common]\r
+  ComponentName.c\r
+  Driver.c\r
+  DriverSupportedEfiVersion.c\r
+  Gop.c\r
+  Initialize.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OptionRomPkg/OptionRomPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  BltLib\r
+  DebugLib\r
+  DevicePathLib\r
+  MemoryAllocationLib\r
+  TimerLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+\r
+[Protocols]\r
+  gEfiDriverSupportedEfiVersionProtocolGuid     # PROTOCOL ALWAYS_PRODUCED\r
+  gEfiGraphicsOutputProtocolGuid                # PROTOCOL BY_START\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL BY_START\r
+  gEfiPciIoProtocolGuid                         # PROTOCOL TO_START\r
+\r
+[Pcd]\r
+  gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion\r
+\r
index 0696999a65e5b66bbf19e21636e2306ea0268f3c..e107eeae860afa9a382d68a7e55ab0f3880c56ff 100755 (executable)
@@ -179,9 +179,9 @@ fi
 if [[ "$RUN_QEMU" == "yes" ]]; then
   if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
     mkdir $QEMU_FIRMWARE_DIR
-    ln -s $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin
-    ln -s $FV_DIR/CirrusLogic5446.rom $QEMU_FIRMWARE_DIR/vgabios-cirrus.bin
   fi
+  ln -sf $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin
+  ln -sf $FV_DIR/OvmfVideo.rom $QEMU_FIRMWARE_DIR/vgabios-cirrus.bin
   if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
     AUTO_QEMU_HDA="-hda fat:$BUILD_ROOT_ARCH"
   else