public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts
@ 2018-11-09 19:44 Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 1/4] Reapply "OvmfPkg: VMWare SVGA display device register definitions" Laszlo Ersek
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-11-09 19:44 UTC (permalink / raw)
  To: edk2-devel
  Cc: Anthony Perard, Ard Biesheuvel, Jordan Justen, Julien Grall,
	Philippe Mathieu-Daudé, yuchenlin

Repo:   https://github.com/lersek/edk2.git
Branch: revert_revert_bz_1319

Not much to say here, I've written it up in
<https://bugzilla.tianocore.org/show_bug.cgi?id=1319>.

One way to verify this series quickly is:

> $ git diff 62ea70e31285..revert_revert_bz_1319 -- OvmfPkg/
> [nothing]

Thanks, and sorry about the churn
Laszlo

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: yuchenlin <yuchenlin@synology.com>

Laszlo Ersek (4):
  Reapply "OvmfPkg: VMWare SVGA display device register definitions"
  Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port
    I/O."
  Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support"
  Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF
    file"

 OvmfPkg/Include/IndustryStandard/VmwareSvga.h | 104 +++++++++++++
 OvmfPkg/QemuVideoDxe/Driver.c                 | 135 ++++++++++++++++-
 OvmfPkg/QemuVideoDxe/Gop.c                    |  65 +++++++-
 OvmfPkg/QemuVideoDxe/Initialize.c             | 157 ++++++++++++++++++++
 OvmfPkg/QemuVideoDxe/Qemu.h                   |  29 ++++
 OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf         |   7 +
 OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c         |  70 +++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c         |  80 ++++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h    |  59 ++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c         |  78 ++++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c |  66 ++++++++
 11 files changed, 843 insertions(+), 7 deletions(-)
 create mode 100644 OvmfPkg/Include/IndustryStandard/VmwareSvga.h
 create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c
 create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c
 create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h
 create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c
 create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c

-- 
2.19.1.3.g30247aa5d201



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] Reapply "OvmfPkg: VMWare SVGA display device register definitions"
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
@ 2018-11-09 19:44 ` Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 2/4] Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port I/O." Laszlo Ersek
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-11-09 19:44 UTC (permalink / raw)
  To: edk2-devel
  Cc: Anthony Perard, Ard Biesheuvel, Jordan Justen, Julien Grall,
	Philippe Mathieu-Daudé, yuchenlin

This reverts commit 328409ce8de7f318ee9c929b64302bd361cd1dbd, reapplying
9bcca53fe466cdff397578328d9d87d257aba493.

Note that the commit now being reverted is technically correct; the only
reason we're reverting it is because it should not have been pushed past
the Soft Feature Freeze for the edk2-stable201811 tag.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: yuchenlin <yuchenlin@synology.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1319
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/Include/IndustryStandard/VmwareSvga.h | 104 ++++++++++++++++++++
 1 file changed, 104 insertions(+)

diff --git a/OvmfPkg/Include/IndustryStandard/VmwareSvga.h b/OvmfPkg/Include/IndustryStandard/VmwareSvga.h
new file mode 100644
index 000000000000..693d44bab6c3
--- /dev/null
+++ b/OvmfPkg/Include/IndustryStandard/VmwareSvga.h
@@ -0,0 +1,104 @@
+/** @file
+
+  Macro and enum definitions of a subset of port numbers, register identifiers
+  and values required for driving the VMWare SVGA virtual display adapter,
+  also implemented by Qemu.
+
+  This file's contents was extracted from file lib/vmware/svga_reg.h in commit
+  329dd537456f93a806841ec8a8213aed11395def of VMWare's vmware-svga repository:
+  git://git.code.sf.net/p/vmware-svga/git
+
+
+  Copyright 1998-2009 VMware, Inc.  All rights reserved.
+  Portions Copyright 2017 Phil Dennis-Jordan <phil@philjordan.eu>
+
+  Permission is hereby granted, free of charge, to any person
+  obtaining a copy of this software and associated documentation
+  files (the "Software"), to deal in the Software without
+  restriction, including without limitation the rights to use, copy,
+  modify, merge, publish, distribute, sublicense, and/or sell copies
+  of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+
+**/
+
+#ifndef _VMWARE_SVGA_H_
+#define _VMWARE_SVGA_H_
+
+#include <Base.h>
+
+//
+// IDs for recognising the device
+//
+#define VMWARE_PCI_VENDOR_ID_VMWARE            0x15AD
+#define VMWARE_PCI_DEVICE_ID_VMWARE_SVGA2      0x0405
+
+//
+// I/O port BAR offsets for register selection and read/write.
+//
+// The register index is written to the 32-bit index port, followed by a 32-bit
+// read or write on the value port to read or set that register's contents.
+//
+#define VMWARE_SVGA_INDEX_PORT         0x0
+#define VMWARE_SVGA_VALUE_PORT         0x1
+
+//
+// Some of the device's register indices for basic framebuffer functionality.
+//
+typedef enum {
+  VmwareSvgaRegId = 0,
+  VmwareSvgaRegEnable = 1,
+  VmwareSvgaRegWidth = 2,
+  VmwareSvgaRegHeight = 3,
+  VmwareSvgaRegMaxWidth = 4,
+  VmwareSvgaRegMaxHeight = 5,
+
+  VmwareSvgaRegBitsPerPixel = 7,
+
+  VmwareSvgaRegRedMask = 9,
+  VmwareSvgaRegGreenMask = 10,
+  VmwareSvgaRegBlueMask = 11,
+  VmwareSvgaRegBytesPerLine = 12,
+
+  VmwareSvgaRegFbOffset = 14,
+
+  VmwareSvgaRegFbSize = 16,
+  VmwareSvgaRegCapabilities = 17,
+
+  VmwareSvgaRegHostBitsPerPixel = 28,
+} VMWARE_SVGA_REGISTER;
+
+//
+// Values used with VmwareSvgaRegId for sanity-checking the device and getting
+// its version.
+//
+#define VMWARE_SVGA_MAGIC          0x900000U
+#define VMWARE_SVGA_MAKE_ID(ver)   (VMWARE_SVGA_MAGIC << 8 | (ver))
+
+#define VMWARE_SVGA_VERSION_2      2
+#define VMWARE_SVGA_ID_2           VMWARE_SVGA_MAKE_ID (VMWARE_SVGA_VERSION_2)
+
+#define VMWARE_SVGA_VERSION_1      1
+#define VMWARE_SVGA_ID_1           VMWARE_SVGA_MAKE_ID (VMWARE_SVGA_VERSION_1)
+
+#define VMWARE_SVGA_VERSION_0      0
+#define VMWARE_SVGA_ID_0           VMWARE_SVGA_MAKE_ID (VMWARE_SVGA_VERSION_0)
+
+//
+// One of the capability bits advertised by VmwareSvgaRegCapabilities.
+//
+#define VMWARE_SVGA_CAP_8BIT_EMULATION     BIT8
+
+#endif
-- 
2.19.1.3.g30247aa5d201




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port I/O."
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 1/4] Reapply "OvmfPkg: VMWare SVGA display device register definitions" Laszlo Ersek
@ 2018-11-09 19:44 ` Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 3/4] Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support" Laszlo Ersek
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-11-09 19:44 UTC (permalink / raw)
  To: edk2-devel
  Cc: Anthony Perard, Ard Biesheuvel, Jordan Justen, Julien Grall,
	Philippe Mathieu-Daudé, yuchenlin

This reverts commit 438ada5aa5a1174940795678c2dae07cde8f3869,
reapplying 05a5379458725234de8a05780fcb5da2c12680e4.

Note that the commit now being reverted is technically correct; the only
reason we're reverting it is because it should not have been pushed past
the Soft Feature Freeze for the edk2-stable201811 tag.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: yuchenlin <yuchenlin@synology.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1319
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf         |  6 ++
 OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h    | 59 +++++++++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c         | 70 +++++++++++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c         | 80 ++++++++++++++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c         | 78 +++++++++++++++++++
 OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c | 66 ++++++++++++++++
 6 files changed, 359 insertions(+)

diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
index e5575622dc61..895e6b8dbd4d 100644
--- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
@@ -41,9 +41,15 @@ [Sources.common]
   Qemu.h
 
 [Sources.Ia32, Sources.X64]
+  UnalignedIoGcc.c    | GCC
+  UnalignedIoIcc.c    | INTEL
+  UnalignedIoMsc.c    | MSFT
   VbeShim.c
   VbeShim.h
 
+[Sources.EBC]
+  UnalignedIoUnsupported.c
+
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
diff --git a/OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h b/OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h
new file mode 100644
index 000000000000..234de6c21bd1
--- /dev/null
+++ b/OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h
@@ -0,0 +1,59 @@
+/** @file
+  Unaligned port I/O, with implementations for various x86 compilers and a
+  dummy for platforms which do not support unaligned port I/O.
+
+  Copyright (c) 2017, Phil Dennis-Jordan.<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.
+
+**/
+
+#ifndef _UNALIGNED_IO_INTERNAL_H_
+#define _UNALIGNED_IO_INTERNAL_H_
+
+/**
+  Performs a 32-bit write to the specified, possibly unaligned I/O-type address.
+
+  Writes the 32-bit I/O port specified by Port with the value specified by Value
+  and returns Value. This function must guarantee that all I/O read and write
+  operations are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port   I/O port address
+  @param[in]  Value  32-bit word to write
+
+  @return The value written to the I/O port.
+
+**/
+UINT32
+UnalignedIoWrite32 (
+  IN      UINTN                     Port,
+  IN      UINT32                    Value
+  );
+
+/**
+  Reads a 32-bit word from the specified, possibly unaligned I/O-type address.
+
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is
+  returned. This function must guarantee that all I/O read and write operations
+  are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT32
+UnalignedIoRead32 (
+  IN      UINTN                     Port
+  );
+
+#endif
diff --git a/OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c b/OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c
new file mode 100644
index 000000000000..105d55d3b903
--- /dev/null
+++ b/OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c
@@ -0,0 +1,70 @@
+/** @file
+  Unaligned Port I/O. This file has compiler specifics for GCC as there is no
+  ANSI C standard for doing IO.
+
+  Based on IoLibGcc.c.
+
+  Copyright (c) 2006 - 2010, 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.
+
+**/
+
+
+#include "UnalignedIoInternal.h"
+
+/**
+  Performs a 32-bit write to the specified, possibly unaligned I/O-type
+  address.
+
+  Writes the 32-bit I/O port specified by Port with the value specified by
+  Value and returns Value. This function must guarantee that all I/O read and
+  write operations are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port   I/O port address
+  @param[in]  Value  32-bit word to write
+
+  @return The value written to the I/O port.
+
+**/
+UINT32
+UnalignedIoWrite32 (
+  IN      UINTN                     Port,
+  IN      UINT32                    Value
+  )
+{
+  __asm__ __volatile__ ( "outl %0, %1" : : "a" (Value), "d" ((UINT16)Port) );
+  return Value;
+}
+
+/**
+  Reads a 32-bit word from the specified, possibly unaligned I/O-type address.
+
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is
+  returned. This function must guarantee that all I/O read and write operations
+  are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT32
+UnalignedIoRead32 (
+  IN      UINTN                     Port
+  )
+{
+  UINT32 Data;
+  __asm__ __volatile__ ( "inl %1, %0" : "=a" (Data) : "d" ((UINT16)Port) );
+  return Data;
+}
+
diff --git a/OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c b/OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c
new file mode 100644
index 000000000000..79f3e446ddba
--- /dev/null
+++ b/OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c
@@ -0,0 +1,80 @@
+/** @file
+  Unaligned port I/O. This file has compiler specifics for ICC as there
+  is no ANSI C standard for doing IO.
+
+  Based on IoLibIcc.c.
+
+  Copyright (c) 2006 - 2008, 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.
+
+**/
+
+
+#include "UnalignedIoInternal.h"
+
+/**
+  Performs a 32-bit write to the specified, possibly unaligned I/O-type
+  address.
+
+  Writes the 32-bit I/O port specified by Port with the value specified by
+  Value and returns Value. This function must guarantee that all I/O read and
+  write operations are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port   I/O port address
+  @param[in]  Value  32-bit word to write
+
+  @return The value written to the I/O port.
+
+**/
+UINT32
+UnalignedIoWrite32 (
+  IN      UINTN                     Port,
+  IN      UINT32                    Value
+  )
+{
+  __asm {
+    mov eax, dword ptr [Value]
+    mov dx, word ptr [Port]
+    out dx, eax
+  }
+
+  return Value;
+}
+
+/**
+  Reads a 32-bit word from the specified, possibly unaligned I/O-type address.
+
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is
+  returned. This function must guarantee that all I/O read and write operations
+  are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT32
+UnalignedIoRead32 (
+  IN      UINTN                     Port
+  )
+{
+  UINT32 Data;
+
+  __asm {
+    mov dx, word ptr [Port]
+    in  eax, dx
+    mov dword ptr [Data], eax
+  }
+
+  return Data;
+}
diff --git a/OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c b/OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c
new file mode 100644
index 000000000000..a466baee8486
--- /dev/null
+++ b/OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c
@@ -0,0 +1,78 @@
+/** @file
+  Unaligned port I/O. This file has compiler specifics for Microsoft C as there
+  is no ANSI C standard for doing IO.
+
+  Based on IoLibMsc.c
+
+  Copyright (c) 2006 - 2010, 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.
+
+**/
+
+
+#include "UnalignedIoInternal.h"
+
+unsigned long  _inpd (unsigned short port);
+unsigned long  _outpd (unsigned short port, unsigned long dataword );
+void          _ReadWriteBarrier (void);
+
+/**
+  Performs a 32-bit write to the specified, possibly unaligned I/O-type
+  address.
+
+  Writes the 32-bit I/O port specified by Port with the value specified by
+  Value and returns Value. This function must guarantee that all I/O read and
+  write operations are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port   I/O port address
+  @param[in]  Value  32-bit word to write
+
+  @return The value written to the I/O port.
+
+**/
+UINT32
+UnalignedIoWrite32 (
+  IN      UINTN                     Port,
+  IN      UINT32                    Value
+  )
+{
+  _ReadWriteBarrier ();
+  _outpd ((UINT16)Port, Value);
+  _ReadWriteBarrier ();
+  return Value;
+}
+
+/**
+  Reads a 32-bit word from the specified, possibly unaligned I/O-type address.
+
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is
+  returned. This function must guarantee that all I/O read and write operations
+  are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT32
+UnalignedIoRead32 (
+  IN      UINTN                     Port
+  )
+{
+  UINT32                            Value;
+
+  _ReadWriteBarrier ();
+  Value = _inpd ((UINT16)Port);
+  _ReadWriteBarrier ();
+  return Value;
+}
diff --git a/OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c b/OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c
new file mode 100644
index 000000000000..57560ab38fcf
--- /dev/null
+++ b/OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c
@@ -0,0 +1,66 @@
+/** @file
+  Unaligned port I/O dummy implementation for platforms which do not support it.
+
+  Copyright (c) 2017, Phil Dennis-Jordan.<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.
+
+**/
+
+
+#include <Library/DebugLib.h>
+#include "UnalignedIoInternal.h"
+
+/**
+  Performs a 32-bit write to the specified, possibly unaligned I/O-type
+  address.
+
+  Writes the 32-bit I/O port specified by Port with the value specified by
+  Value and returns Value. This function must guarantee that all I/O read and
+  write operations are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port   I/O port address
+  @param[in]  Value  32-bit word to write
+
+  @return The value written to the I/O port.
+
+**/
+UINT32
+UnalignedIoWrite32 (
+  IN      UINTN                     Port,
+  IN      UINT32                    Value
+  )
+{
+  ASSERT (FALSE);
+  return Value;
+}
+
+/**
+  Reads a 32-bit word from the specified, possibly unaligned I/O-type address.
+
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is
+  returned. This function must guarantee that all I/O read and write operations
+  are serialized.
+
+  If 32-bit unaligned I/O port operations are not supported, then ASSERT().
+
+  @param[in]  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT32
+UnalignedIoRead32 (
+  IN      UINTN                     Port
+  )
+{
+  ASSERT (FALSE);
+  return 0;
+}
-- 
2.19.1.3.g30247aa5d201




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support"
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 1/4] Reapply "OvmfPkg: VMWare SVGA display device register definitions" Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 2/4] Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port I/O." Laszlo Ersek
@ 2018-11-09 19:44 ` Laszlo Ersek
  2018-11-09 19:44 ` [PATCH 4/4] Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF file" Laszlo Ersek
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-11-09 19:44 UTC (permalink / raw)
  To: edk2-devel
  Cc: Anthony Perard, Ard Biesheuvel, Jordan Justen, Julien Grall,
	Philippe Mathieu-Daudé, yuchenlin

This reverts commit 98856a724c2acdc0094220d4de615a557dad0f88, reapplying
c137d95081690d4877fbeb5f1856972e84ac32f2.

Note that the commit now being reverted is technically correct; the only
reason we're reverting it is because it should not have been pushed past
the Soft Feature Freeze for the edk2-stable201811 tag.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: yuchenlin <yuchenlin@synology.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1319
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/QemuVideoDxe/Qemu.h       |  29 ++++
 OvmfPkg/QemuVideoDxe/Driver.c     | 135 ++++++++++++++++-
 OvmfPkg/QemuVideoDxe/Gop.c        |  65 +++++++-
 OvmfPkg/QemuVideoDxe/Initialize.c | 157 ++++++++++++++++++++
 4 files changed, 379 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index d7da761705a1..bc49f867a4ff 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -92,6 +92,7 @@ typedef enum {
   QEMU_VIDEO_CIRRUS_5446,
   QEMU_VIDEO_BOCHS,
   QEMU_VIDEO_BOCHS_MMIO,
+  QEMU_VIDEO_VMWARE_SVGA,
 } QEMU_VIDEO_VARIANT;
 
 typedef struct {
@@ -116,10 +117,13 @@ typedef struct {
   //
   UINTN                                 MaxMode;
   QEMU_VIDEO_MODE_DATA                  *ModeData;
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *VmwareSvgaModeInfo;
 
   QEMU_VIDEO_VARIANT                    Variant;
   FRAME_BUFFER_CONFIGURE                *FrameBufferBltConfigure;
   UINTN                                 FrameBufferBltConfigureSize;
+  UINT8                                 FrameBufferVramBarIndex;
+  UINT16                                VmwareSvgaBasePort;
 } QEMU_VIDEO_PRIVATE_DATA;
 
 ///
@@ -503,9 +507,34 @@ QemuVideoBochsModeSetup (
   BOOLEAN                  IsQxl
   );
 
+EFI_STATUS
+QemuVideoVmwareSvgaModeSetup (
+  QEMU_VIDEO_PRIVATE_DATA *Private
+  );
+
 VOID
 InstallVbeShim (
   IN CONST CHAR16         *CardName,
   IN EFI_PHYSICAL_ADDRESS FrameBufferBase
   );
+
+VOID
+VmwareSvgaWrite (
+  QEMU_VIDEO_PRIVATE_DATA *Private,
+  UINT16                  Register,
+  UINT32                  Value
+  );
+
+UINT32
+VmwareSvgaRead (
+  QEMU_VIDEO_PRIVATE_DATA *Private,
+  UINT16                  Register
+  );
+
+VOID
+InitializeVmwareSvgaGraphicsMode (
+  QEMU_VIDEO_PRIVATE_DATA  *Private,
+  QEMU_VIDEO_BOCHS_MODES   *ModeData
+  );
+
 #endif
diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c
index 2304afd1e686..73eb2cad0584 100644
--- a/OvmfPkg/QemuVideoDxe/Driver.c
+++ b/OvmfPkg/QemuVideoDxe/Driver.c
@@ -14,8 +14,10 @@
 
 **/
 
-#include "Qemu.h"
+#include <IndustryStandard/VmwareSvga.h>
 #include <IndustryStandard/Acpi.h>
+#include "Qemu.h"
+#include "UnalignedIoInternal.h"
 
 EFI_DRIVER_BINDING_PROTOCOL gQemuVideoDriverBinding = {
   QemuVideoControllerDriverSupported,
@@ -69,6 +71,12 @@ QEMU_VIDEO_CARD gQemuVideoCardList[] = {
         0x1050,
         QEMU_VIDEO_BOCHS_MMIO,
         L"QEMU VirtIO VGA"
+    },{
+        PCI_CLASS_DISPLAY_VGA,
+        VMWARE_PCI_VENDOR_ID_VMWARE,
+        VMWARE_PCI_DEVICE_ID_VMWARE_SVGA2,
+        QEMU_VIDEO_VMWARE_SVGA,
+        L"QEMU VMWare SVGA"
     },{
         0 /* end of list */
     }
@@ -256,6 +264,7 @@ QemuVideoControllerDriverStart (
     goto ClosePciIo;
   }
   Private->Variant = Card->Variant;
+  Private->FrameBufferVramBarIndex = PCI_BAR_IDX0;
 
   //
   // IsQxl is based on the detected Card->Variant, which at a later point might
@@ -330,6 +339,58 @@ QemuVideoControllerDriverStart (
     }
   }
 
+  //
+  // Check if accessing Vmware SVGA interface works
+  //
+  if (Private->Variant == QEMU_VIDEO_VMWARE_SVGA) {
+    EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *IoDesc;
+    UINT32                            TargetId;
+    UINT32                            SvgaIdRead;
+
+    IoDesc = NULL;
+    Status = Private->PciIo->GetBarAttributes (
+                               Private->PciIo,
+                               PCI_BAR_IDX0,
+                               NULL,
+                               (VOID**) &IoDesc
+                               );
+    if (EFI_ERROR (Status) ||
+        IoDesc->ResType != ACPI_ADDRESS_SPACE_TYPE_IO ||
+        IoDesc->AddrRangeMin > MAX_UINT16 + 1 - (VMWARE_SVGA_VALUE_PORT + 4)) {
+      if (IoDesc != NULL) {
+        FreePool (IoDesc);
+      }
+      Status = EFI_DEVICE_ERROR;
+      goto RestoreAttributes;
+    }
+    Private->VmwareSvgaBasePort = (UINT16) IoDesc->AddrRangeMin;
+    FreePool (IoDesc);
+
+    TargetId = VMWARE_SVGA_ID_2;
+    while (TRUE) {
+      VmwareSvgaWrite (Private, VmwareSvgaRegId, TargetId);
+      SvgaIdRead = VmwareSvgaRead (Private, VmwareSvgaRegId);
+      if ((SvgaIdRead == TargetId) || (TargetId <= VMWARE_SVGA_ID_0)) {
+        break;
+      }
+      TargetId--;
+    }
+
+    if (SvgaIdRead != TargetId) {
+      DEBUG ((
+        DEBUG_ERROR,
+        "QemuVideo: QEMU_VIDEO_VMWARE_SVGA ID mismatch "
+        "(got 0x%x, base address 0x%x)\n",
+        SvgaIdRead,
+        Private->VmwareSvgaBasePort
+        ));
+      Status = EFI_DEVICE_ERROR;
+      goto RestoreAttributes;
+    }
+
+    Private->FrameBufferVramBarIndex = PCI_BAR_IDX1;
+  }
+
   //
   // Get ParentDevicePath
   //
@@ -385,6 +446,9 @@ QemuVideoControllerDriverStart (
   case QEMU_VIDEO_BOCHS:
     Status = QemuVideoBochsModeSetup (Private, IsQxl);
     break;
+  case QEMU_VIDEO_VMWARE_SVGA:
+    Status = QemuVideoVmwareSvgaModeSetup (Private);
+    break;
   default:
     ASSERT (FALSE);
     Status = EFI_DEVICE_ERROR;
@@ -446,6 +510,9 @@ DestructQemuVideoGraphics:
 
 FreeModeData:
   FreePool (Private->ModeData);
+  if (Private->VmwareSvgaModeInfo != NULL) {
+    FreePool (Private->VmwareSvgaModeInfo);
+  }
 
 UninstallGopDevicePath:
   gBS->UninstallProtocolInterface (Private->Handle,
@@ -567,6 +634,9 @@ QemuVideoControllerDriverStop (
         );
 
   FreePool (Private->ModeData);
+  if (Private->VmwareSvgaModeInfo != NULL) {
+    FreePool (Private->VmwareSvgaModeInfo);
+  }
   gBS->UninstallProtocolInterface (Private->Handle,
          &gEfiDevicePathProtocolGuid, Private->GopDevicePath);
   FreePool (Private->GopDevicePath);
@@ -764,7 +834,7 @@ ClearScreen (
   Private->PciIo->Mem.Write (
                         Private->PciIo,
                         EfiPciIoWidthFillUint32,
-                        0,
+                        Private->FrameBufferVramBarIndex,
                         0,
                         0x400000 >> 2,
                         &Color
@@ -901,6 +971,38 @@ BochsRead (
   return Data;
 }
 
+VOID
+VmwareSvgaWrite (
+  QEMU_VIDEO_PRIVATE_DATA   *Private,
+  UINT16                    Register,
+  UINT32                    Value
+  )
+{
+  UnalignedIoWrite32 (
+    Private->VmwareSvgaBasePort + VMWARE_SVGA_INDEX_PORT,
+    Register
+    );
+  UnalignedIoWrite32 (
+    Private->VmwareSvgaBasePort + VMWARE_SVGA_VALUE_PORT,
+    Value
+    );
+}
+
+UINT32
+VmwareSvgaRead (
+  QEMU_VIDEO_PRIVATE_DATA   *Private,
+  UINT16                    Register
+  )
+{
+  UnalignedIoWrite32 (
+    Private->VmwareSvgaBasePort + VMWARE_SVGA_INDEX_PORT,
+    Register
+    );
+  return UnalignedIoRead32 (
+           Private->VmwareSvgaBasePort + VMWARE_SVGA_VALUE_PORT
+           );
+}
+
 VOID
 VgaOutb (
   QEMU_VIDEO_PRIVATE_DATA  *Private,
@@ -955,6 +1057,35 @@ InitializeBochsGraphicsMode (
   ClearScreen (Private);
 }
 
+VOID
+InitializeVmwareSvgaGraphicsMode (
+  QEMU_VIDEO_PRIVATE_DATA  *Private,
+  QEMU_VIDEO_BOCHS_MODES   *ModeData
+  )
+{
+  UINT32 Capabilities;
+
+  VmwareSvgaWrite (Private, VmwareSvgaRegWidth, ModeData->Width);
+  VmwareSvgaWrite (Private, VmwareSvgaRegHeight, ModeData->Height);
+
+  Capabilities = VmwareSvgaRead (
+                   Private,
+                   VmwareSvgaRegCapabilities
+                   );
+  if ((Capabilities & VMWARE_SVGA_CAP_8BIT_EMULATION) != 0) {
+    VmwareSvgaWrite (
+      Private,
+      VmwareSvgaRegBitsPerPixel,
+      ModeData->ColorDepth
+      );
+  }
+
+  VmwareSvgaWrite (Private, VmwareSvgaRegEnable, 1);
+
+  SetDefaultPalette (Private);
+  ClearScreen (Private);
+}
+
 EFI_STATUS
 EFIAPI
 InitializeQemuVideo (
diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
index d490fa7a2e6f..c9941ef138bd 100644
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ b/OvmfPkg/QemuVideoDxe/Gop.c
@@ -13,6 +13,7 @@
 
 **/
 
+#include <IndustryStandard/VmwareSvga.h>
 #include "Qemu.h"
 
 STATIC
@@ -78,6 +79,46 @@ QemuVideoCompleteModeData (
   return EFI_SUCCESS;
 }
 
+STATIC
+EFI_STATUS
+QemuVideoVmwareSvgaCompleteModeData (
+  IN  QEMU_VIDEO_PRIVATE_DATA           *Private,
+  OUT EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode
+  )
+{
+  EFI_STATUS                            Status;
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR     *FrameBufDesc;
+  UINT32                                BytesPerLine, FbOffset, BytesPerPixel;
+
+  Info = Mode->Info;
+  CopyMem (Info, &Private->VmwareSvgaModeInfo[Mode->Mode], sizeof (*Info));
+  BytesPerPixel = Private->ModeData[Mode->Mode].ColorDepth / 8;
+  BytesPerLine = Info->PixelsPerScanLine * BytesPerPixel;
+
+  FbOffset = VmwareSvgaRead (Private, VmwareSvgaRegFbOffset);
+
+  Status = Private->PciIo->GetBarAttributes (
+                             Private->PciIo,
+                             PCI_BAR_IDX1,
+                             NULL,
+                             (VOID**) &FrameBufDesc
+                             );
+  if (EFI_ERROR (Status)) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin + FbOffset;
+  Mode->FrameBufferSize = BytesPerLine * Info->VerticalResolution;
+  Mode->FrameBufferSize = EFI_PAGES_TO_SIZE (
+                            EFI_SIZE_TO_PAGES (Mode->FrameBufferSize)
+                            );
+
+  FreePool (FrameBufDesc);
+  return Status;
+}
+
+
 //
 // Graphics Output Protocol Member Functions
 //
@@ -126,10 +167,14 @@ Routine Description:
 
   *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
 
-  ModeData = &Private->ModeData[ModeNumber];
-  (*Info)->HorizontalResolution = ModeData->HorizontalResolution;
-  (*Info)->VerticalResolution   = ModeData->VerticalResolution;
-  QemuVideoCompleteModeInfo (ModeData, *Info);
+  if (Private->Variant == QEMU_VIDEO_VMWARE_SVGA) {
+    CopyMem (*Info, &Private->VmwareSvgaModeInfo[ModeNumber], sizeof (**Info));
+  } else {
+    ModeData = &Private->ModeData[ModeNumber];
+    (*Info)->HorizontalResolution = ModeData->HorizontalResolution;
+    (*Info)->VerticalResolution   = ModeData->VerticalResolution;
+    QemuVideoCompleteModeInfo (ModeData, *Info);
+  }
 
   return EFI_SUCCESS;
 }
@@ -179,6 +224,12 @@ Routine Description:
   case QEMU_VIDEO_BOCHS:
     InitializeBochsGraphicsMode (Private, &QemuVideoBochsModes[ModeData->InternalModeIndex]);
     break;
+  case QEMU_VIDEO_VMWARE_SVGA:
+    InitializeVmwareSvgaGraphicsMode (
+      Private,
+      &QemuVideoBochsModes[ModeData->InternalModeIndex]
+      );
+    break;
   default:
     ASSERT (FALSE);
     return EFI_DEVICE_ERROR;
@@ -189,7 +240,11 @@ Routine Description:
   This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;
   This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
 
-  QemuVideoCompleteModeData (Private, This->Mode);
+  if (Private->Variant == QEMU_VIDEO_VMWARE_SVGA) {
+    QemuVideoVmwareSvgaCompleteModeData (Private, This->Mode);
+  } else {
+    QemuVideoCompleteModeData (Private, This->Mode);
+  }
 
   //
   // Re-initialize the frame buffer configure when mode changes.
diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c b/OvmfPkg/QemuVideoDxe/Initialize.c
index d5d8cfef9661..357124d628e7 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -13,6 +13,7 @@
 
 **/
 
+#include <IndustryStandard/VmwareSvga.h>
 #include "Qemu.h"
 
 
@@ -346,3 +347,159 @@ QemuVideoBochsModeSetup (
   return EFI_SUCCESS;
 }
 
+EFI_STATUS
+QemuVideoVmwareSvgaModeSetup (
+  QEMU_VIDEO_PRIVATE_DATA *Private
+  )
+{
+  EFI_STATUS                            Status;
+  UINT32                                FbSize;
+  UINT32                                MaxWidth, MaxHeight;
+  UINT32                                Capabilities;
+  UINT32                                BitsPerPixel;
+  UINT32                                Index;
+  QEMU_VIDEO_MODE_DATA                  *ModeData;
+  QEMU_VIDEO_BOCHS_MODES                *VideoMode;
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *ModeInfo;
+
+  VmwareSvgaWrite (Private, VmwareSvgaRegEnable, 0);
+
+  Private->ModeData =
+    AllocatePool (sizeof (Private->ModeData[0]) * QEMU_VIDEO_BOCHS_MODE_COUNT);
+  if (Private->ModeData == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ModeDataAllocError;
+  }
+
+  Private->VmwareSvgaModeInfo =
+    AllocatePool (
+      sizeof (Private->VmwareSvgaModeInfo[0]) * QEMU_VIDEO_BOCHS_MODE_COUNT
+      );
+  if (Private->VmwareSvgaModeInfo == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ModeInfoAllocError;
+  }
+
+  FbSize =       VmwareSvgaRead (Private, VmwareSvgaRegFbSize);
+  MaxWidth =     VmwareSvgaRead (Private, VmwareSvgaRegMaxWidth);
+  MaxHeight =    VmwareSvgaRead (Private, VmwareSvgaRegMaxHeight);
+  Capabilities = VmwareSvgaRead (Private, VmwareSvgaRegCapabilities);
+  if ((Capabilities & VMWARE_SVGA_CAP_8BIT_EMULATION) != 0) {
+    BitsPerPixel = VmwareSvgaRead (
+                     Private,
+                     VmwareSvgaRegHostBitsPerPixel
+                     );
+    VmwareSvgaWrite (
+      Private,
+      VmwareSvgaRegBitsPerPixel,
+      BitsPerPixel
+      );
+  } else {
+    BitsPerPixel = VmwareSvgaRead (
+                     Private,
+                     VmwareSvgaRegBitsPerPixel
+                     );
+  }
+
+  if (FbSize == 0       ||
+      MaxWidth == 0     ||
+      MaxHeight == 0    ||
+      BitsPerPixel == 0 ||
+      BitsPerPixel % 8 != 0) {
+    Status = EFI_DEVICE_ERROR;
+    goto Rollback;
+  }
+
+  ModeData = Private->ModeData;
+  ModeInfo = Private->VmwareSvgaModeInfo;
+  VideoMode = &QemuVideoBochsModes[0];
+  for (Index = 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index++) {
+    UINTN RequiredFbSize;
+
+    RequiredFbSize = (UINTN) VideoMode->Width * VideoMode->Height *
+                     (BitsPerPixel / 8);
+    if (RequiredFbSize <= FbSize     &&
+        VideoMode->Width <= MaxWidth &&
+        VideoMode->Height <= MaxHeight) {
+      UINT32  BytesPerLine;
+      UINT32  RedMask, GreenMask, BlueMask, PixelMask;
+
+      VmwareSvgaWrite (
+        Private,
+        VmwareSvgaRegWidth,
+        VideoMode->Width
+        );
+      VmwareSvgaWrite (
+        Private,
+        VmwareSvgaRegHeight,
+        VideoMode->Height
+        );
+
+      ModeData->InternalModeIndex    = Index;
+      ModeData->HorizontalResolution = VideoMode->Width;
+      ModeData->VerticalResolution   = VideoMode->Height;
+      ModeData->ColorDepth           = BitsPerPixel;
+
+      //
+      // Setting VmwareSvgaRegWidth/VmwareSvgaRegHeight actually changes
+      // the device's display mode, so we save all properties of each mode up
+      // front to avoid inadvertent mode changes later.
+      //
+      ModeInfo->Version = 0;
+      ModeInfo->HorizontalResolution = ModeData->HorizontalResolution;
+      ModeInfo->VerticalResolution   = ModeData->VerticalResolution;
+
+      ModeInfo->PixelFormat = PixelBitMask;
+
+      RedMask   = VmwareSvgaRead (Private, VmwareSvgaRegRedMask);
+      ModeInfo->PixelInformation.RedMask = RedMask;
+
+      GreenMask = VmwareSvgaRead (Private, VmwareSvgaRegGreenMask);
+      ModeInfo->PixelInformation.GreenMask = GreenMask;
+
+      BlueMask  = VmwareSvgaRead (Private, VmwareSvgaRegBlueMask);
+      ModeInfo->PixelInformation.BlueMask = BlueMask;
+
+      //
+      // Reserved mask is whatever bits in the pixel not containing RGB data,
+      // so start with binary 1s for every bit in the pixel, then mask off
+      // bits already used for RGB. Special case 32 to avoid undefined
+      // behaviour in the shift.
+      //
+      if (BitsPerPixel == 32) {
+        if (BlueMask == 0xff && GreenMask == 0xff00 && RedMask == 0xff0000) {
+          ModeInfo->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
+        } else if (BlueMask == 0xff0000 &&
+                   GreenMask == 0xff00 &&
+                   RedMask == 0xff) {
+          ModeInfo->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
+        }
+        PixelMask = MAX_UINT32;
+      } else {
+        PixelMask = (1u << BitsPerPixel) - 1;
+      }
+      ModeInfo->PixelInformation.ReservedMask =
+        PixelMask & ~(RedMask | GreenMask | BlueMask);
+
+      BytesPerLine = VmwareSvgaRead (Private, VmwareSvgaRegBytesPerLine);
+      ModeInfo->PixelsPerScanLine = BytesPerLine / (BitsPerPixel / 8);
+
+      ModeData++;
+      ModeInfo++;
+    }
+    VideoMode++;
+  }
+  Private->MaxMode = ModeData - Private->ModeData;
+  return EFI_SUCCESS;
+
+Rollback:
+  FreePool (Private->VmwareSvgaModeInfo);
+  Private->VmwareSvgaModeInfo = NULL;
+
+ModeInfoAllocError:
+  FreePool (Private->ModeData);
+  Private->ModeData = NULL;
+
+ModeDataAllocError:
+  return Status;
+}
-- 
2.19.1.3.g30247aa5d201




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF file"
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
                   ` (2 preceding siblings ...)
  2018-11-09 19:44 ` [PATCH 3/4] Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support" Laszlo Ersek
@ 2018-11-09 19:44 ` Laszlo Ersek
  2018-11-09 20:07 ` [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-11-09 19:44 UTC (permalink / raw)
  To: edk2-devel
  Cc: Anthony Perard, Ard Biesheuvel, Jordan Justen, Julien Grall,
	Philippe Mathieu-Daudé, yuchenlin

This reverts commit e038bde2679bbd200086c25ab43090ad3b8b25a3, reapplying
b2959e9f1a57279506ca46d56bc424fd7fa6b62a.

Note that the commit now being reverted is technically correct; the only
reason we're reverting it is because it should not have been pushed past
the Soft Feature Freeze for the edk2-stable201811 tag.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: yuchenlin <yuchenlin@synology.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1319
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 1 +
 1 file changed, 1 insertion(+)

diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
index 895e6b8dbd4d..a04ed537dd27 100644
--- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
@@ -39,6 +39,7 @@ [Sources.common]
   Gop.c
   Initialize.c
   Qemu.h
+  UnalignedIoInternal.h
 
 [Sources.Ia32, Sources.X64]
   UnalignedIoGcc.c    | GCC
-- 
2.19.1.3.g30247aa5d201



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
                   ` (3 preceding siblings ...)
  2018-11-09 19:44 ` [PATCH 4/4] Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF file" Laszlo Ersek
@ 2018-11-09 20:07 ` Philippe Mathieu-Daudé
  2018-11-09 20:31 ` Ard Biesheuvel
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-09 20:07 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel
  Cc: Anthony Perard, Ard Biesheuvel, Jordan Justen, Julien Grall,
	yuchenlin

On 9/11/18 20:44, Laszlo Ersek wrote:
> Repo:   https://github.com/lersek/edk2.git
> Branch: revert_revert_bz_1319
> 
> Not much to say here, I've written it up in
> <https://bugzilla.tianocore.org/show_bug.cgi?id=1319>.
> 
> One way to verify this series quickly is:
> 
>> $ git diff 62ea70e31285..revert_revert_bz_1319 -- OvmfPkg/
>> [nothing]
> 
> Thanks, and sorry about the churn
> Laszlo
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Cc: yuchenlin <yuchenlin@synology.com>
> 
> Laszlo Ersek (4):
>    Reapply "OvmfPkg: VMWare SVGA display device register definitions"
>    Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port
>      I/O."
>    Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support"
>    Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF
>      file"

Series:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
                   ` (4 preceding siblings ...)
  2018-11-09 20:07 ` [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Philippe Mathieu-Daudé
@ 2018-11-09 20:31 ` Ard Biesheuvel
  2018-11-10  0:33 ` yuchenlin
  2018-11-12 11:36 ` Laszlo Ersek
  7 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-11-09 20:31 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel, Anthony Perard, Jordan Justen, Julien Grall,
	Philippe Mathieu-Daudé, yuchenlin



> On 9 Nov 2018, at 20:44, Laszlo Ersek <lersek@redhat.com> wrote:
> 
> Repo:   https://github.com/lersek/edk2.git
> Branch: revert_revert_bz_1319
> 
> Not much to say here, I've written it up in
> <https://bugzilla.tianocore.org/show_bug.cgi?id=1319>.
> 
> One way to verify this series quickly is:
> 
>> $ git diff 62ea70e31285..revert_revert_bz_1319 -- OvmfPkg/
>> [nothing]
> 
> Thanks, and sorry about the churn
> Laszlo
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Cc: yuchenlin <yuchenlin@synology.com>
> 
> Laszlo Ersek (4):
>  Reapply "OvmfPkg: VMWare SVGA display device register definitions"
>  Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port
>    I/O."
>  Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support"
>  Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF
>    file"
> 
> OvmfPkg/Include/IndustryStandard/VmwareSvga.h | 104 +++++++++++++
> OvmfPkg/QemuVideoDxe/Driver.c                 | 135 ++++++++++++++++-
> OvmfPkg/QemuVideoDxe/Gop.c                    |  65 +++++++-
> OvmfPkg/QemuVideoDxe/Initialize.c             | 157 ++++++++++++++++++++
> OvmfPkg/QemuVideoDxe/Qemu.h                   |  29 ++++
> OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf         |   7 +
> OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c         |  70 +++++++++
> OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c         |  80 ++++++++++
> OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h    |  59 ++++++++
> OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c         |  78 ++++++++++
> OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c |  66 ++++++++
> 11 files changed, 843 insertions(+), 7 deletions(-)
> create mode 100644 OvmfPkg/Include/IndustryStandard/VmwareSvga.h
> create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c
> create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c
> create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h
> create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c
> create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c
> 

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
                   ` (5 preceding siblings ...)
  2018-11-09 20:31 ` Ard Biesheuvel
@ 2018-11-10  0:33 ` yuchenlin
  2018-11-12 11:36 ` Laszlo Ersek
  7 siblings, 0 replies; 9+ messages in thread
From: yuchenlin @ 2018-11-10  0:33 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel, Anthony Perard, Ard Biesheuvel, Jordan Justen,
	Julien Grall, Philippe Mathieu-Daudé

On 2018-11-10 03:44, Laszlo Ersek wrote:
> Repo:   https://github.com/lersek/edk2.git
> Branch: revert_revert_bz_1319
> 
> Not much to say here, I've written it up in
> <https://bugzilla.tianocore.org/show_bug.cgi?id=1319>.
> 
> One way to verify this series quickly is:
> 
>> $ git diff 62ea70e31285..revert_revert_bz_1319 -- OvmfPkg/
>> [nothing]
> 
> Thanks, and sorry about the churn
> Laszlo
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Cc: yuchenlin <yuchenlin@synology.com>
> 
> Laszlo Ersek (4):
>   Reapply "OvmfPkg: VMWare SVGA display device register definitions"
>   Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port
>     I/O."
>   Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support"
>   Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the 
> INF
>     file"
> 
>  OvmfPkg/Include/IndustryStandard/VmwareSvga.h | 104 +++++++++++++
>  OvmfPkg/QemuVideoDxe/Driver.c                 | 135 ++++++++++++++++-
>  OvmfPkg/QemuVideoDxe/Gop.c                    |  65 +++++++-
>  OvmfPkg/QemuVideoDxe/Initialize.c             | 157 
> ++++++++++++++++++++
>  OvmfPkg/QemuVideoDxe/Qemu.h                   |  29 ++++
>  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf         |   7 +
>  OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c         |  70 +++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c         |  80 ++++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h    |  59 ++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c         |  78 ++++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c |  66 ++++++++
>  11 files changed, 843 insertions(+), 7 deletions(-)
>  create mode 100644 OvmfPkg/Include/IndustryStandard/VmwareSvga.h
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c

Thank you for preventing an regression on stable QEMU.

Reviewed-by: yuchenlin <yuchenlin@synology.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts
  2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
                   ` (6 preceding siblings ...)
  2018-11-10  0:33 ` yuchenlin
@ 2018-11-12 11:36 ` Laszlo Ersek
  7 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-11-12 11:36 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jordan Justen, Anthony Perard

On 11/09/18 20:44, Laszlo Ersek wrote:
> Repo:   https://github.com/lersek/edk2.git
> Branch: revert_revert_bz_1319
> 
> Not much to say here, I've written it up in
> <https://bugzilla.tianocore.org/show_bug.cgi?id=1319>.
> 
> One way to verify this series quickly is:
> 
>> $ git diff 62ea70e31285..revert_revert_bz_1319 -- OvmfPkg/
>> [nothing]
> 
> Thanks, and sorry about the churn
> Laszlo
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Cc: yuchenlin <yuchenlin@synology.com>
> 
> Laszlo Ersek (4):
>   Reapply "OvmfPkg: VMWare SVGA display device register definitions"
>   Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port
>     I/O."
>   Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support"
>   Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF
>     file"
> 
>  OvmfPkg/Include/IndustryStandard/VmwareSvga.h | 104 +++++++++++++
>  OvmfPkg/QemuVideoDxe/Driver.c                 | 135 ++++++++++++++++-
>  OvmfPkg/QemuVideoDxe/Gop.c                    |  65 +++++++-
>  OvmfPkg/QemuVideoDxe/Initialize.c             | 157 ++++++++++++++++++++
>  OvmfPkg/QemuVideoDxe/Qemu.h                   |  29 ++++
>  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf         |   7 +
>  OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c         |  70 +++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c         |  80 ++++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h    |  59 ++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c         |  78 ++++++++++
>  OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c |  66 ++++++++
>  11 files changed, 843 insertions(+), 7 deletions(-)
>  create mode 100644 OvmfPkg/Include/IndustryStandard/VmwareSvga.h
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoGcc.c
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoIcc.c
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoInternal.h
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoMsc.c
>  create mode 100644 OvmfPkg/QemuVideoDxe/UnalignedIoUnsupported.c
> 

Thanks all for the quick feedback; pushed as commit range
ade71c52a49d..246604e3a46d.

Laszlo


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-11-12 11:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-09 19:44 [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Laszlo Ersek
2018-11-09 19:44 ` [PATCH 1/4] Reapply "OvmfPkg: VMWare SVGA display device register definitions" Laszlo Ersek
2018-11-09 19:44 ` [PATCH 2/4] Reapply "OvmfPkg/QemuVideoDxe: Helper functions for unaligned port I/O." Laszlo Ersek
2018-11-09 19:44 ` [PATCH 3/4] Reapply "OvmfPkg/QemuVideoDxe: VMWare SVGA device support" Laszlo Ersek
2018-11-09 19:44 ` [PATCH 4/4] Reapply "OvmfPkg/QemuVideoDxe: list "UnalignedIoInternal.h" in the INF file" Laszlo Ersek
2018-11-09 20:07 ` [PATCH 0/4] OvmfPkg: revert some untimely pushed VMW SVGA reverts Philippe Mathieu-Daudé
2018-11-09 20:31 ` Ard Biesheuvel
2018-11-10  0:33 ` yuchenlin
2018-11-12 11:36 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox