[PATCH 13/16] int10: Use pciaccess rom fetch for !PC machines

Matt Turner mattst88 at gmail.com
Fri Sep 16 10:50:19 PDT 2011


From: Adam Jackson <ajax at redhat.com>

... instead of rolling our own, badly.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/xfree86/int10/generic.c |   58 +-------------------------------------------
 1 files changed, 1 insertions(+), 57 deletions(-)

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index aa39db5..2bb66e3 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -62,62 +62,6 @@ static void UnmapVRam(xf86Int10InfoPtr pInt);
 
 static void *sysMem = NULL;
 
-/**
- * Read legacy VGA video BIOS associated with specified domain.
- * 
- * Attempts to read up to 128KiB of legacy VGA video BIOS.
- * 
- * \return
- * The number of bytes read on success or -1 on failure.
- *
- * \bug
- * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA,
- * etc.).  How do we know that \c pci_device_read_rom will return the
- * legacy VGA BIOS image?
- */
-#ifndef _PC
-static int
-read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf)
-{
-    const ADDRESS Base = 0xC0000;
-    const int Len = 0x10000 * 2;
-    const int pagemask = getpagesize() - 1;
-    const ADDRESS offset = Base & ~pagemask;
-    const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset;
-    unsigned char *ptr, *src;
-    int len;
-
-
-    /* Try to use the civilized PCI interface first.
-     */
-    if (pci_device_read_rom(dev, Buf) == 0) {
-	return dev->rom_size;
-    }
-
-    ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size);
-
-    if (!ptr)
-	return -1;
-
-    /* Using memcpy() here can hang the system */
-    src = ptr + (Base - offset);
-    for (len = 0; len < (Len / 2); len++) {
-	Buf[len] = src[len];
-    }
-
-    if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) {
-	for ( /* empty */ ; len < Len; len++) {
-	    Buf[len] = src[len];
-	}
-    }
-
-    xf86UnMapVidMem(-1, ptr, size);
-
-    return Len;
-}
-#endif /* _PC */
-
-
 xf86Int10InfoPtr
 xf86ExtendedInitInt10(int entityIndex, int Flags)
 {
@@ -244,7 +188,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
      */
     vbiosMem = (char *)base + V_BIOS;
     memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
-    if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
+    if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
 	xf86DrvMsg(screen, X_WARNING,
 		   "Unable to retrieve all of segment 0x0C0000.\n");
     }
-- 
1.7.3.4



More information about the xorg-devel mailing list