]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuVideoDxe: the VBE shim needs no 64-bit shifts (VS2010)
authorScott Duplichan <scott@notabs.org>
Fri, 14 Nov 2014 10:23:55 +0000 (10:23 +0000)
committerlersek <lersek@Edk2>
Fri, 14 Nov 2014 10:23:55 +0000 (10:23 +0000)
The SegmentC local variable has type EFI_PHYSICAL_ADDRESS for (justified)
style reasons. However, the 64-bit bit-shifts that it undergoes result in
intrinsic calls when built with VS2010 for Ia32 / NOOPT.

The concrete value of SegmentC, 0xC0000, and the results  of the bitops
that are based on it, are statically computeable. Cast SegmentC to UINT32
before subjecting it to bitwise operations; we can see in advance that
this won't lead to range loss.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Scott Duplichan <scott@notabs.org>
[lersek@redhat.com: dropped now superfluous outermost parens; commit msg]

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Build-tested-by: Scott Duplichan <scott@notabs.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16385 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/QemuVideoDxe/VbeShim.c

index 81c11664f4938a514375ff6a94657dadf69629f3..6bb175bfd4443f2c6225bf8c13fb9b95c2e15d57 100644 (file)
@@ -153,13 +153,13 @@ InstallVbeShim (
   CopyMem (VbeInfo->Signature, "VESA", 4);\r
   VbeInfo->VesaVersion = 0x0300;\r
 \r
-  VbeInfo->OemNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  VbeInfo->OemNameAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr;\r
   CopyMem (Ptr, "QEMU", 5);\r
   Ptr += 5;\r
 \r
   VbeInfo->Capabilities = BIT0; // DAC can be switched into 8-bit mode\r
 \r
-  VbeInfo->ModeListAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  VbeInfo->ModeListAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr;\r
   *(UINT16*)Ptr = 0x00f1; // mode number\r
   Ptr += 2;\r
   *(UINT16*)Ptr = 0xFFFF; // mode list terminator\r
@@ -168,17 +168,17 @@ InstallVbeShim (
   VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);\r
   VbeInfo->OemSoftwareVersion = 0x0000;\r
 \r
-  VbeInfo->VendorNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  VbeInfo->VendorNameAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr;\r
   CopyMem (Ptr, "OVMF", 5);\r
   Ptr += 5;\r
 \r
-  VbeInfo->ProductNameAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr;\r
   Printed = AsciiSPrint ((CHAR8 *)Ptr,\r
               sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s",\r
               CardName);\r
   Ptr += Printed + 1;\r
 \r
-  VbeInfo->ProductRevAddress = (UINT32)(SegmentC << 12 | (UINT16)(UINTN)Ptr);\r
+  VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr;\r
   CopyMem (Ptr, mProductRevision, sizeof mProductRevision);\r
   Ptr += sizeof mProductRevision;\r
 \r
@@ -268,7 +268,7 @@ InstallVbeShim (
   //\r
   // Second, point the Int10h vector at the shim.\r
   //\r
-  Int0x10->Segment = (UINT16) (SegmentC >> 4);\r
+  Int0x10->Segment = (UINT16) ((UINT32)SegmentC >> 4);\r
   Int0x10->Offset  = (UINT16) ((UINTN) (VbeModeInfo + 1) - SegmentC);\r
 \r
   DEBUG ((EFI_D_INFO, "%a: VBE shim installed\n", __FUNCTION__));\r