Add Egberts fixes for 64bit architectures

Add additional checks for the *DRIRec info structure passed in from the
device driver. This ensures that things fallback to indirect rendering if
the DDX driver has had modifications (i.e. removal of the drmAddress field).
This commit is contained in:
Alan Hourihane
2005-08-15 06:59:24 +00:00
parent 69dc32cfac
commit dabec11d27
27 changed files with 107 additions and 36 deletions

View File

@@ -68,6 +68,12 @@ ffbInitDriver(__DRIscreenPrivate *sPriv)
if (getenv("LIBGL_FORCE_XSERVER"))
return GL_FALSE;
if (sPriv->devPrivSize != sizeof(FFBDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(FFBDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area. */
ffbScreen = (ffbScreenPrivate *) MALLOC(sizeof(ffbScreenPrivate));
if (!ffbScreen)
@@ -721,7 +727,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
{
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 0, 0, 1 };
static const __DRIversion ddx_expected = { 0, 1, 1 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 0, 0, 1 };

View File

@@ -21,23 +21,18 @@ typedef struct ffb_dri_state {
typedef struct {
drm_handle_t hFbcRegs;
drmSize sFbcRegs;
drmAddress mFbcRegs;
drm_handle_t hDacRegs;
drmSize sDacRegs;
drmAddress mDacRegs;
drm_handle_t hSfb8r;
drmSize sSfb8r;
drmAddress mSfb8r;
drm_handle_t hSfb32;
drmSize sSfb32;
drmAddress mSfb32;
drm_handle_t hSfb64;
drmSize sSfb64;
drmAddress mSfb64;
/* Fastfill/Pagefill parameters. */
unsigned char disable_pagefill;

View File

@@ -35,6 +35,11 @@ gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv;
int i;
if (sPriv->devPrivSize != sizeof(GLINTDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(GLINTDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
#if 0
/* Check the DRI externsion version */
if ( sPriv->driMajor != 3 || sPriv->driMinor != 1 ) {

View File

@@ -223,6 +223,10 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
i810ScreenPrivate *i810Screen;
I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
if (sPriv->devPrivSize != sizeof(I810DRIRec)) {
fprintf(stderr,"\nERROR! sizeof(I810DRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
i810Screen = (i810ScreenPrivate *)CALLOC(sizeof(i810ScreenPrivate));

View File

@@ -212,7 +212,7 @@ static int I810DRIAgpInit( const DRIDriverContext *ctx, I810Ptr info)
drmAgpAlloc(ctx->drmFD, 4096 * 1024, 1, NULL, &dcacheHandle);
info->dcacheHandle = dcacheHandle;
fprintf(stderr, "[agp] dcacheHandle : %p\n", dcacheHandle);
fprintf(stderr, "[agp] dcacheHandle : 0x%x\n", dcacheHandle);
#define Elements(x) sizeof(x)/sizeof(*x)
for (pitch_idx = 0; pitch_idx < Elements(i810_pitches); pitch_idx++)
@@ -710,7 +710,7 @@ static int I810ScreenInit( DRIDriverContext *ctx, I810Ptr info )
return 0;
}
fprintf(stderr,
"[drm] register handle = 0x%08lx\n", info->regs);
"[drm] register handle = 0x%08x\n", info->regs);
I810DRIAgpPreInit(ctx, info);
/* Need to AddMap the framebuffer and mmio regions here:

View File

@@ -11,7 +11,6 @@
typedef struct {
drm_handle_t regs;
drmSize regsSize;
drmAddress regsMap;
drmSize backbufferSize;
drm_handle_t backbuffer;

View File

@@ -146,6 +146,10 @@ static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
fprintf(stderr,"\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
i830Screen = (i830ScreenPrivate *)CALLOC(sizeof(i830ScreenPrivate));

View File

@@ -18,7 +18,6 @@
typedef struct _I830DRIRec {
drm_handle_t regs;
drmSize regsSize;
drmAddress regsMap;
drmSize backbufferSize;
drm_handle_t backbuffer;

View File

@@ -80,7 +80,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
fprintf(stderr,"\nERROR! sizeof(I830DRIRec) does not match passed size from 2D driver\n");
fprintf(stderr,"\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}

View File

@@ -211,6 +211,10 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv )
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(ATIDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(ATIDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
if ( MACH64_DEBUG & DEBUG_VERBOSE_DRI )
fprintf( stderr, "%s\n", __FUNCTION__ );

View File

@@ -200,6 +200,10 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(MGADRIRec)) {
fprintf(stderr,"\nERROR! sizeof(MGADRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate));
@@ -945,7 +949,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
{
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 1, 1, 1 };
static const __DRIversion ddx_expected = { 1, 2, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 3, 0, 0 };

View File

@@ -206,7 +206,7 @@ static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga)
return 0;
}
fprintf( stderr,
"[agp] WARP microcode handle = 0x%08lx\n",
"[agp] WARP microcode handle = 0x%08x\n",
pMga->warp.handle );
if ( drmMap( ctx->drmFD,
@@ -233,7 +233,7 @@ static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga)
return 0;
}
fprintf( stderr,
"[agp] Primary DMA handle = 0x%08lx\n",
"[agp] Primary DMA handle = 0x%08x\n",
pMga->primary.handle );
if ( drmMap( ctx->drmFD,
@@ -260,7 +260,7 @@ static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga)
return 0;
}
fprintf( stderr,
"[agp] DMA buffers handle = 0x%08lx\n",
"[agp] DMA buffers handle = 0x%08x\n",
pMga->buffers.handle );
if ( drmMap( ctx->drmFD,
@@ -304,7 +304,7 @@ static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga)
}
/* should i map it ? */
fprintf( stderr,
"[agp] agpTexture handle = 0x%08lx\n",
"[agp] agpTexture handle = 0x%08x\n",
pMga->agpTextures.handle );
fprintf( stderr,
"[agp] agpTexture size: %d kb\n", pMga->agpTextures.size/1024 );
@@ -339,7 +339,7 @@ static int MGADRIMapInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
return 0;
}
fprintf( stderr,
"[drm] Status handle = 0x%08lx\n",
"[drm] Status handle = 0x%08x\n",
pMga->status.handle );
if ( drmMap( ctx->drmFD,

View File

@@ -49,6 +49,16 @@
# define DEPRECATED
#endif
#if 1
typedef struct _mgaDrmRegion {
drm_handle_t handle;
unsigned int offset;
drmSize size;
} mgaDrmRegion, *mgaDrmRegionPtr;
#else
#define mgaDrmRegion drmRegion
#endif
typedef struct {
int chipset;
int width DEPRECATED;
@@ -91,10 +101,10 @@ typedef struct {
* for the X.org 6.9 / 7.0 release), these fields should be removed.
*/
/*@{*/
drmRegion registers; /**< MMIO registers. */
drmRegion status DEPRECATED; /**< No longer used on the client-side. */
drmRegion primary; /**< Primary DMA region. */
drmRegion buffers DEPRECATED; /**< No longer used on the client-side. */
mgaDrmRegion registers; /**< MMIO registers. */
mgaDrmRegion status DEPRECATED; /**< No longer used on the client-side. */
mgaDrmRegion primary; /**< Primary DMA region. */
mgaDrmRegion buffers DEPRECATED; /**< No longer used on the client-side. */
/*@}*/
unsigned int sarea_priv_offset;

View File

@@ -102,6 +102,10 @@ r128CreateScreen( __DRIscreenPrivate *sPriv )
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(R128DRIRec)) {
fprintf(stderr,"\nERROR! sizeof(R128DRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
r128Screen = (r128ScreenPtr) CALLOC( sizeof(*r128Screen) );

View File

@@ -164,7 +164,7 @@ static GLboolean R128DRIAgpInit(const DRIDriverContext *ctx)
return GL_FALSE;
}
fprintf(stderr,
"[agp] ring handle = 0x%08lx\n", info->ringHandle);
"[agp] ring handle = 0x%08x\n", info->ringHandle);
if (drmMap(ctx->drmFD, info->ringHandle, info->ringMapSize,
(drmAddressPtr)&info->ring) < 0) {
@@ -182,7 +182,7 @@ static GLboolean R128DRIAgpInit(const DRIDriverContext *ctx)
return GL_FALSE;
}
fprintf(stderr,
"[agp] ring read ptr handle = 0x%08lx\n",
"[agp] ring read ptr handle = 0x%08x\n",
info->ringReadPtrHandle);
if (drmMap(ctx->drmFD, info->ringReadPtrHandle, info->ringReadMapSize,
@@ -398,7 +398,7 @@ static GLboolean R128DRIMapInit(const DRIDriverContext *ctx)
return GL_FALSE;
}
fprintf(stderr,
"[drm] register handle = 0x%08lx\n", info->registerHandle);
"[drm] register handle = 0x%08x\n", info->registerHandle);
return GL_TRUE;
}

View File

@@ -239,6 +239,10 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
screen = (r200ScreenPtr) CALLOC( sizeof(*screen) );

View File

@@ -315,6 +315,10 @@ static radeonScreenPtr radeonCreateScreen(__DRIscreenPrivate * sPriv)
(*dri_interface->getProcAddress("glxEnableExtension"));
void *const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
screen = (radeonScreenPtr) CALLOC(sizeof(*screen));

View File

@@ -212,6 +212,10 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );

View File

@@ -398,7 +398,7 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info)
fprintf(stderr, "[gart] Could not add ring mapping\n");
return 0;
}
fprintf(stderr, "[gart] ring handle = 0x%08lx\n", info->ringHandle);
fprintf(stderr, "[gart] ring handle = 0x%08x\n", info->ringHandle);
if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
@@ -409,7 +409,7 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info)
}
fprintf(stderr,
"[gart] ring read ptr handle = 0x%08lx\n",
"[gart] ring read ptr handle = 0x%08lx\n",
info->ringReadPtrHandle);
if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
@@ -419,7 +419,7 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info)
return 0;
}
fprintf(stderr,
"[gart] vertex/indirect buffers handle = 0x%08lx\n",
"[gart] vertex/indirect buffers handle = 0x%08x\n",
info->bufHandle);
if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize,
@@ -429,7 +429,7 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info)
return 0;
}
fprintf(stderr,
"[gart] AGP texture map handle = 0x%08lx\n",
"[gart] AGP texture map handle = 0x%08lx\n",
info->gartTexHandle);
/* Initialize Radeon's AGP registers */
@@ -486,7 +486,7 @@ static int RADEONDRIPciInit(const DRIDriverContext *ctx, RADEONInfoPtr info)
return 0;
}
fprintf(stderr,
"[pci] ring handle = 0x%08lx\n", info->ringHandle);
"[pci] ring handle = 0x%08x\n", info->ringHandle);
if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) {
@@ -495,7 +495,7 @@ static int RADEONDRIPciInit(const DRIDriverContext *ctx, RADEONInfoPtr info)
return 0;
}
fprintf(stderr,
"[pci] ring read ptr handle = 0x%08lx\n",
"[pci] ring read ptr handle = 0x%08lx\n",
info->ringReadPtrHandle);
if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
@@ -505,7 +505,7 @@ static int RADEONDRIPciInit(const DRIDriverContext *ctx, RADEONInfoPtr info)
return 0;
}
fprintf(stderr,
"[pci] vertex/indirect buffers handle = 0x%08lx\n",
"[pci] vertex/indirect buffers handle = 0x%08lx\n",
info->bufHandle);
if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize,
@@ -515,7 +515,7 @@ static int RADEONDRIPciInit(const DRIDriverContext *ctx, RADEONInfoPtr info)
return 0;
}
fprintf(stderr,
"[pci] GART texture map handle = 0x%08lx\n",
"[pci] GART texture map handle = 0x%08x\n",
info->gartTexHandle);
return 1;

View File

@@ -17,6 +17,11 @@ s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv )
DEBUG(("sPriv->pDevPriv at %p\n", sPriv->pDevPriv));
DEBUG(("size = %i\n", sizeof(*vDRIPriv)));
if (sPriv->devPrivSize != sizeof(S3VDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(S3VDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
s3vScreen = (s3vScreenPtr) CALLOC( sizeof(*s3vScreen) );
if ( !s3vScreen ) return NULL;

View File

@@ -170,6 +170,11 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
savageScreenPrivate *savageScreen;
SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
if (sPriv->devPrivSize != sizeof(SAVAGEDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(SAVAGEDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
savageScreen = (savageScreenPrivate *)Xmalloc(sizeof(savageScreenPrivate));
if (!savageScreen)

View File

@@ -38,7 +38,6 @@ typedef struct {
typedef struct {
drm_handle_t handle;
drmSize size;
drmAddress map;
} sisRegion, *sisRegionPtr;
typedef struct {

View File

@@ -129,6 +129,10 @@ sisCreateScreen( __DRIscreenPrivate *sPriv )
sisScreenPtr sisScreen;
SISDRIPtr sisDRIPriv = (SISDRIPtr)sPriv->pDevPriv;
if (sPriv->devPrivSize != sizeof(SISDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(SISDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
sisScreen = (sisScreenPtr)CALLOC( sizeof(*sisScreen) );
@@ -427,7 +431,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
{
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = {0, 1, 0};
static const __DRIversion ddx_expected = {0, 8, 0};
static const __DRIversion dri_expected = {4, 0, 0};
static const __DRIversion drm_expected = {1, 0, 0};

View File

@@ -9,7 +9,6 @@
typedef struct {
drm_handle_t regs;
drmSize regsSize;
drmAddress regsMap;
int deviceID;
int width;
int height;

View File

@@ -74,6 +74,11 @@ tdfxCreateScreen( __DRIscreenPrivate *sPriv )
tdfxScreenPrivate *fxScreen;
TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv;
if (sPriv->devPrivSize != sizeof(TDFXDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(TDFXDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
fxScreen = (tdfxScreenPrivate *) CALLOC( sizeof(tdfxScreenPrivate) );
if ( !fxScreen )
@@ -441,7 +446,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
__GLcontextModes ** driver_modes )
{
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 1, 0, 0 };
static const __DRIversion ddx_expected = { 1, 1, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 1, 0, 0 };

View File

@@ -358,6 +358,10 @@ tridentScreenPtr tridentCreateScreen( __DRIscreenPrivate *sPriv )
TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
tridentScreenPtr tridentScreen;
if (sPriv->devPrivSize != sizeof(TRIDENTDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(TRIDENTDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
tridentScreen = (tridentScreenPtr) CALLOC( sizeof(*tridentScreen) );

View File

@@ -101,6 +101,10 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
void * const psc = sPriv->psc->screenConfigs;
if (sPriv->devPrivSize != sizeof(VIADRIRec)) {
fprintf(stderr,"\nERROR! sizeof(VIADRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}
/* Allocate the private area */
viaScreen = (viaScreenPrivate *) CALLOC(sizeof(viaScreenPrivate));