mirror of
https://github.com/X11Libre/xf86-video-r128.git
synced 2026-03-24 01:24:26 +00:00
Fix segfault from trying to access nonexistent VGA BIOS ROM on non-x86 platforms
On non-x86 platforms such as PowerPC Macs with r128 chipsets, the VGA BIOS ROM doesn't exist, and the driver segfaults when trying to access it. Fix this by only accessing the VGA BIOS on x86/x86_64. Signed-off-by: Avraham Hollander <anhollander516@gmail.com>
This commit is contained in:
@@ -94,7 +94,12 @@
|
||||
#include "xf86RandR12.h"
|
||||
#include "xf86cmap.h"
|
||||
#include "xf86xv.h"
|
||||
/* VBE and int10 are only available on x86. */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#include "vbe.h"
|
||||
#else
|
||||
typedef void *xf86Int10InfoPtr;
|
||||
#endif
|
||||
|
||||
/* fbdevhw & vgahw */
|
||||
#ifdef WITH_VGAHW
|
||||
@@ -419,11 +424,15 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* VBE and int10 are only available on x86. */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (pInt10) {
|
||||
info->BIOSAddr = pInt10->BIOSseg << 4;
|
||||
(void)memcpy(info->VBIOS, xf86int10Addr(pInt10, info->BIOSAddr),
|
||||
R128_VBIOS_SIZE);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#ifdef XSERVER_LIBPCIACCESS
|
||||
if (pci_device_read_rom(info->PciInfo, info->VBIOS)) {
|
||||
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
||||
@@ -1011,7 +1020,8 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
|
||||
|
||||
static Bool R128PreInitDDC(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10)
|
||||
{
|
||||
#if !defined(__powerpc__) && !defined(__alpha__) && !defined(__sparc__)
|
||||
/* VBE and int10 are only available on x86. */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
R128InfoPtr info = R128PTR(pScrn);
|
||||
vbeInfoPtr pVbe;
|
||||
#endif
|
||||
@@ -1019,8 +1029,7 @@ static Bool R128PreInitDDC(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10)
|
||||
if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE;
|
||||
if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE;
|
||||
|
||||
#if defined(__powerpc__) || defined(__alpha__) || defined(__sparc__)
|
||||
/* Int10 is broken on PPC and some Alphas */
|
||||
#if !defined(__i386__) && !defined(__x86_64__)
|
||||
return TRUE;
|
||||
#else
|
||||
if (xf86LoadSubModule(pScrn, "vbe")) {
|
||||
@@ -1056,9 +1065,9 @@ static Bool R128PreInitCursor(ScrnInfoPtr pScrn)
|
||||
|
||||
static Bool R128PreInitInt10(ScrnInfoPtr pScrn, xf86Int10InfoPtr *ppInt10)
|
||||
{
|
||||
/* VBE and int10 are only available on x86. */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
R128InfoPtr info = R128PTR(pScrn);
|
||||
#if !defined(__powerpc__) && !defined(__alpha__)
|
||||
/* int10 is broken on some Alphas and powerpc */
|
||||
if (xf86LoadSubModule(pScrn, "int10")) {
|
||||
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n");
|
||||
*ppInt10 = xf86InitInt10(info->pEnt->index);
|
||||
@@ -1402,9 +1411,12 @@ static Bool R128LegacyMS(ScrnInfoPtr pScrn)
|
||||
ret = TRUE;
|
||||
freeInt10:
|
||||
/* Free int10 info */
|
||||
/* VBE and int10 are only available on x86. */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (pInt10) {
|
||||
xf86FreeInt10(pInt10);
|
||||
}
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
|
||||
@@ -483,6 +483,7 @@ R128GetConnectorInfoFromBIOS(ScrnInfoPtr pScrn, R128OutputType *otypes)
|
||||
} else {
|
||||
otypes[0] = OUTPUT_VGA;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bios_header = R128_BIOS16(0x48);
|
||||
|
||||
Reference in New Issue
Block a user