[Intel-gfx] [PATCH] Eliminate INT10 call to get BIOS contents

Keith Packard keithp at keithp.com
Tue Sep 30 04:09:45 CEST 2008


Here's another pass at this patch, it moves the remaining vbe defines to
i810.h to make sure no modern driver can use them. It also error-checks
the return from the BIOS read functions in case something bad happens
there. Please take a look, send comments and test results.

[PATCH] Eliminate INT10 call to get BIOS contents

libpciaccess (and the old X server PCI code as well) provides a function to
get the ROM contents. Code to use that was already present in the driver and
used if the INT10 function failed. Skip the INT10 and just use libpciaccess
as that eliminates several module loads and scary use of vm86.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 src/common.h      |   16 ----------------
 src/i810_driver.c |   10 +---------
 src/i830_bios.c   |   41 +++++++++++++++++------------------------
 src/i830_driver.c |    5 -----
 4 files changed, 18 insertions(+), 54 deletions(-)

diff --git a/src/common.h b/src/common.h
index 840d30a..0f23bd5 100644
--- a/src/common.h
+++ b/src/common.h
@@ -81,7 +81,6 @@ extern void I830InitpScrn(ScrnInfoPtr pScrn);
 extern int I830EntityIndex;
 extern const char *I810vgahwSymbols[];
 extern const char *I810ramdacSymbols[];
-extern const char *I810int10Symbols[];
 extern const char *I810vbeSymbols[];
 extern const char *I810ddcSymbols[];
 extern const char *I810fbSymbols[];
@@ -106,21 +105,6 @@ extern void I830DPRINTF_stub(const char *filename, int line,
 #define RecPtr pI810
 #endif
 
-/* BIOS debug macro */
-#define xf86ExecX86int10_wrapper(pInt, pScrn) do {			\
-   ErrorF("Executing (ax == 0x%x) BIOS call at %s:%d\n", pInt->ax, __FILE__, __LINE__);	\
-   if (I810_DEBUG & DEBUG_VERBOSE_BIOS) {				\
-      ErrorF("Checking Error state before execution\n");		\
-      PrintErrorState(pScrn);						\
-   }									\
-   xf86ExecX86int10(pInt);						\
-   if(I810_DEBUG & DEBUG_VERBOSE_BIOS) {				\
-      ErrorF("Checking Error state after execution\n");			\
-      usleep(50000);							\
-      PrintErrorState(pScrn);						\
-   }									\
-} while (0)
-
 static inline void memset_volatile(volatile void *b, int c, size_t len)
 {
     int i;
diff --git a/src/i810_driver.c b/src/i810_driver.c
index a7f408c..cc28ad8 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -342,14 +342,6 @@ const char *I810ddcSymbols[] = {
    NULL
 };
 
-const char *I810int10Symbols[] = {
-   "xf86ExecX86int10",
-   "xf86InitInt10",
-   "xf86Int10AllocPages",
-   "xf86int10Addr",
-   NULL
-};
-
 const char *I810xaaSymbols[] = {
    "XAACreateInfoRec",
    "XAADestroyInfoRec",
@@ -518,7 +510,7 @@ i810Setup(pointer module, pointer opts, int *errmaj, int *errmin)
 #endif
 			I810shadowFBSymbols,
 			I810vbeSymbols, vbeOptionalSymbols,
-			I810ddcSymbols, I810int10Symbols, NULL);
+			I810ddcSymbols, NULL);
 
       /*
        * The return value must be non-NULL on success even though there
diff --git a/src/i830_bios.c b/src/i830_bios.c
index ff49025..6f935fd 100644
--- a/src/i830_bios.c
+++ b/src/i830_bios.c
@@ -47,9 +47,6 @@
 				 (bios[_addr + 2] << 16)	\
 				 (bios[_addr + 3] << 24))
 
-/* XXX */
-#define INTEL_VBIOS_SIZE (64 * 1024)
-
 static void *
 find_section(struct bdb_header *bdb, int section_id)
 {
@@ -161,6 +158,11 @@ parse_general_features(I830Ptr pI830, struct bdb_header *bdb)
     }
 }
 
+#ifndef XSERVER_LIBPCIACCESS
+/* XXX */
+#define INTEL_VBIOS_SIZE (64 * 1024)
+#endif
+
 /**
  * i830_bios_init - map VBIOS, find VBT
  *
@@ -179,34 +181,25 @@ i830_bios_init(ScrnInfoPtr pScrn)
     struct bdb_header *bdb;
     int vbt_off, bdb_off;
     unsigned char *bios;
-    vbeInfoPtr	pVbe;
-    pointer pVBEModule = NULL;
+    int ret;
+    int size;
 
-    bios = xalloc(INTEL_VBIOS_SIZE);
-    if (bios == NULL)
+#if XSERVER_LIBPCIACCESS
+    size = pI830->PciInfo->rom_size;
+#else
+    size = INTEL_VBIOS_SIZE;
+#endif
+    if (size == 0)
 	return -1;
-
-    /* Load vbe module */
-    if (!(pVBEModule = xf86LoadSubModule(pScrn, "vbe")))
-	return FALSE;
-    xf86LoaderReqSymLists(I810vbeSymbols, NULL);
-
-    pVbe = VBEInit(NULL, pI830->pEnt->index);
-    if (pVbe != NULL) {
-	memcpy(bios, xf86int10Addr(pVbe->pInt10,
-				   pVbe->pInt10->BIOSseg << 4),
-	       INTEL_VBIOS_SIZE);
-	vbeFree (pVbe);
-    } else {
+    
 #if XSERVER_LIBPCIACCESS
-	pci_device_read_rom (pI830->PciInfo, bios);
+    ret = pci_device_read_rom (pI830->PciInfo, bios);
 #else
-	xf86ReadPciBIOS(0, pI830->PciTag, 0, bios, INTEL_VBIOS_SIZE);
+    xf86ReadPciBIOS(0, pI830->PciTag, 0, bios, INTEL_VBIOS_SIZE);
 #endif
-    }
 
     vbt_off = INTEL_BIOS_16(0x1a);
-    if (vbt_off >= INTEL_VBIOS_SIZE) {
+    if (vbt_off >= size) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Bad VBT offset: 0x%x\n",
 		   vbt_off);
 	xfree(bios);
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 9bf0a64..40d7afc 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1412,11 +1412,6 @@ I830LoadSyms(ScrnInfoPtr pScrn)
     if (pI830->use_drm_mode)
 	return TRUE;
 
-    /* Load int10 module */
-    if (!xf86LoadSubModule(pScrn, "int10"))
-	return FALSE;
-    xf86LoaderReqSymLists(I810int10Symbols, NULL);
-
     /* The vgahw module should be loaded here when needed */
     if (!xf86LoadSubModule(pScrn, "vgahw"))
 	return FALSE;
-- 
1.5.6.5


-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20080929/514ca750/attachment.sig>


More information about the Intel-gfx mailing list