From 14f6d58d4b5a277a68d9d8ddee7f79be2179f34f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sat, 30 Sep 2006 15:14:42 +0200 Subject: radeon: Check ROM more thoroughly before treating it as an x86 BIOS. This prevents the ROMs on some Mac cards getting treated as x86 BIOSen, resulting in garbage values. (cherry picked from c979c7f87fc449cc9631820101edff82c3013e66 commit) --- src/radeon_bios.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/radeon_bios.c b/src/radeon_bios.c index 1ea0550..7857ff1 100644 --- a/src/radeon_bios.c +++ b/src/radeon_bios.c @@ -46,6 +46,7 @@ Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) { RADEONInfoPtr info = RADEONPTR(pScrn); int tmp; + unsigned short dptr; if (!(info->VBIOS = xalloc(RADEON_VBIOS_SIZE))) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -77,7 +78,22 @@ Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10) xfree (info->VBIOS); info->VBIOS = NULL; return FALSE; - } + } + + /* Verify it's an x86 BIOS not OF firmware, copied from radeonfb */ + dptr = RADEON_BIOS16(0x18); + /* If PCI data signature is wrong assume x86 video BIOS anyway */ + if (RADEON_BIOS32(dptr) != (('R' << 24) | ('I' << 16) | ('C' << 8) | 'P')) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "ROM PCI data signature incorrect, ignoring\n"); + } + else if (info->VBIOS[dptr + 0x14] != 0x0) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Not an x86 BIOS ROM image, BIOS data will not be used\n"); + xfree (info->VBIOS); + info->VBIOS = NULL; + return FALSE; + } if (info->VBIOS) info->ROMHeaderStart = RADEON_BIOS16(0x48); -- cgit v1.2.3