Index: programs/Xserver/hw/xfree86/common/compiler.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/compiler.h,v retrieving revision 1.8 diff -u -r1.8 compiler.h --- programs/Xserver/hw/xfree86/common/compiler.h 3 Jul 2005 07:01:24 -0000 1.8 +++ programs/Xserver/hw/xfree86/common/compiler.h 20 Jul 2005 19:04:41 -0000 @@ -124,6 +124,8 @@ # define DO_PROTOTYPES # endif +struct BusRec; /* forward decl. to avoid circular dependencies */ + # if defined(NO_INLINE) || defined(DO_PROTOTYPES) # if !defined(__arm__) @@ -131,21 +133,21 @@ && !(defined(__alpha__) && defined(linux)) \ && !(defined(__ia64__) && defined(linux)) \ -extern void outb(unsigned short, unsigned char); -extern void outw(unsigned short, unsigned short); -extern void outl(unsigned short, unsigned int); -extern unsigned int inb(unsigned short); -extern unsigned int inw(unsigned short); -extern unsigned int inl(unsigned short); +extern void outb(BusRec *, unsigned short, unsigned char); +extern void outw(BusRec *, unsigned short, unsigned short); +extern void outl(BusRec *, unsigned short, unsigned int); +extern unsigned int inb(BusRec *, unsigned short); +extern unsigned int inw(BusRec *, unsigned short); +extern unsigned int inl(BusRec *, unsigned short); # else /* __sparc__, __arm32__, __alpha__*/ -extern void outb(unsigned long, unsigned char); -extern void outw(unsigned long, unsigned short); -extern void outl(unsigned long, unsigned int); -extern unsigned int inb(unsigned long); -extern unsigned int inw(unsigned long); -extern unsigned int inl(unsigned long); +extern void outb(BusRec *, unsigned long, unsigned char); +extern void outw(BusRec *, unsigned long, unsigned short); +extern void outl(BusRec *, unsigned long, unsigned int); +extern unsigned int inb(BusRec *, unsigned long); +extern unsigned int inw(BusRec *, unsigned long); +extern unsigned int inl(BusRec *, unsigned long); # endif /* __sparc__, __arm32__, __alpha__ */ # endif /* __arm__ */ @@ -176,42 +178,42 @@ extern void (*_alpha_outb)(char val, unsigned long port); static __inline__ void -outb(unsigned long port, unsigned char val) +outb(BusRec *, unsigned long port, unsigned char val) { _alpha_outb(val, port); } extern void (*_alpha_outw)(short val, unsigned long port); static __inline__ void -outw(unsigned long port, unsigned short val) +outw(BusRec *, unsigned long port, unsigned short val) { _alpha_outw(val, port); } extern void (*_alpha_outl)(int val, unsigned long port); static __inline__ void -outl(unsigned long port, unsigned int val) +outl(BusRec *, unsigned long port, unsigned int val) { _alpha_outl(val, port); } extern unsigned int (*_alpha_inb)(unsigned long port); static __inline__ unsigned int -inb(unsigned long port) +inb(BusRec *, unsigned long port) { return _alpha_inb(port); } extern unsigned int (*_alpha_inw)(unsigned long port); static __inline__ unsigned int -inw(unsigned long port) +inw(BusRec *, unsigned long port) { return _alpha_inw(port); } extern unsigned int (*_alpha_inl)(unsigned long port); static __inline__ unsigned int -inl(unsigned long port) +inl(BusRec *, unsigned long port) { return _alpha_inl(port); } @@ -226,12 +228,12 @@ /* note that the appropriate setup via "ioperm" needs to be done */ /* *before* any inx/outx is done. */ -extern void outb(unsigned int port, unsigned char val); -extern void outw(unsigned int port, unsigned short val); -extern void outl(unsigned int port, unsigned int val); -extern unsigned char inb(unsigned int port); -extern unsigned short inw(unsigned int port); -extern unsigned int inl(unsigned int port); +extern void outb(BusRec *, unsigned int port, unsigned char val); +extern void outw(BusRec *, unsigned int port, unsigned short val); +extern void outl(BusRec *, unsigned int port, unsigned int val); +extern unsigned char inb(BusRec *, unsigned int port); +extern unsigned short inw(BusRec *, unsigned int port); +extern unsigned int inl(BusRec *, unsigned int port); # endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */ @@ -502,12 +504,12 @@ # undef inb # undef inw # undef inl -extern void outb(unsigned long port, unsigned char val); -extern void outw(unsigned long port, unsigned short val); -extern void outl(unsigned long port, unsigned int val); -extern unsigned int inb(unsigned long port); -extern unsigned int inw(unsigned long port); -extern unsigned int inl(unsigned long port); +extern void outb(BusRec *, unsigned long port, unsigned char val); +extern void outw(BusRec *, unsigned long port, unsigned short val); +extern void outl(BusRec *, unsigned long port, unsigned int val); +extern unsigned int inb(BusRec *, unsigned long port); +extern unsigned int inw(BusRec *, unsigned long port); +extern unsigned int inl(BusRec *, unsigned long port); # elif defined(linux) && defined(__amd64__) @@ -527,26 +529,26 @@ static __inline__ void -outb(unsigned short port, unsigned char val) +outb(BusRec *, unsigned short port, unsigned char val) { __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); } static __inline__ void -outw(unsigned short port, unsigned short val) +outw(BusRec *, unsigned short port, unsigned short val) { __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); } static __inline__ void -outl(unsigned short port, unsigned int val) +outl(BusRec *, unsigned short port, unsigned int val) { __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); } static __inline__ unsigned int -inb(unsigned short port) +inb(BusRec *, unsigned short port) { unsigned char ret; __asm__ __volatile__("inb %1,%0" : @@ -556,7 +558,7 @@ } static __inline__ unsigned int -inw(unsigned short port) +inw(BusRec *, unsigned short port) { unsigned short ret; __asm__ __volatile__("inw %1,%0" : @@ -566,7 +568,7 @@ } static __inline__ unsigned int -inl(unsigned short port) +inl(BusRec *, unsigned short port) { unsigned int ret; __asm__ __volatile__("inl %1,%0" : @@ -585,7 +587,7 @@ # define barrier() __asm__ __volatile__(".word 0x8143e00a": : :"memory") static __inline__ void -outb(unsigned long port, unsigned char val) +outb(BusRec *, unsigned long port, unsigned char val) { __asm__ __volatile__("stba %0, [%1] %2" : /* No outputs */ @@ -594,7 +596,7 @@ } static __inline__ void -outw(unsigned long port, unsigned short val) +outw(BusRec *, unsigned long port, unsigned short val) { __asm__ __volatile__("stha %0, [%1] %2" : /* No outputs */ @@ -603,7 +605,7 @@ } static __inline__ void -outl(unsigned long port, unsigned int val) +outl(BusRec *, unsigned long port, unsigned int val) { __asm__ __volatile__("sta %0, [%1] %2" : /* No outputs */ @@ -612,7 +614,7 @@ } static __inline__ unsigned int -inb(unsigned long port) +inb(BusRec *, unsigned long port) { unsigned int ret; __asm__ __volatile__("lduba [%1] %2, %0" @@ -622,7 +624,7 @@ } static __inline__ unsigned int -inw(unsigned long port) +inw(BusRec *, unsigned long port) { unsigned int ret; __asm__ __volatile__("lduha [%1] %2, %0" @@ -632,7 +634,7 @@ } static __inline__ unsigned int -inl(unsigned long port) +inl(BusRec *, unsigned long port) { unsigned int ret; __asm__ __volatile__("lda [%1] %2, %0" @@ -916,40 +918,41 @@ # define PORT_SIZE short # endif +/* This should go away now that in/out take a device id */ unsigned int IOPortBase; /* Memory mapped I/O port area */ static __inline__ void -outb(unsigned PORT_SIZE port, unsigned char val) +outb(BusRec *, unsigned PORT_SIZE port, unsigned char val) { *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; } static __inline__ void -outw(unsigned PORT_SIZE port, unsigned short val) +outw(BusRec *, unsigned PORT_SIZE port, unsigned short val) { *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; } static __inline__ void -outl(unsigned PORT_SIZE port, unsigned int val) +outl(BusRec *, unsigned PORT_SIZE port, unsigned int val) { *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; } static __inline__ unsigned int -inb(unsigned PORT_SIZE port) +inb(BusRec *, unsigned PORT_SIZE port) { return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase); } static __inline__ unsigned int -inw(unsigned PORT_SIZE port) +inw(BusRec *, unsigned PORT_SIZE port) { return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase); } static __inline__ unsigned int -inl(unsigned PORT_SIZE port) +inl(BusRec *, unsigned PORT_SIZE port) { return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase); } @@ -1084,6 +1087,7 @@ # define MAP_FAILED ((void *)-1) # endif +/* This, too, should die. */ extern volatile unsigned char *ioBase; #if defined(linux) && defined(__powerpc64__) @@ -1250,42 +1254,42 @@ static __inline__ void -outb(unsigned short port, unsigned char value) +outb(BusRec *, unsigned short port, unsigned char value) { if(ioBase == MAP_FAILED) return; xf86WriteMmio8((void *)ioBase, port, value); } static __inline__ void -outw(unsigned short port, unsigned short value) +outw(BusRec *, unsigned short port, unsigned short value) { if(ioBase == MAP_FAILED) return; xf86WriteMmio16Le((void *)ioBase, port, value); } static __inline__ void -outl(unsigned short port, unsigned int value) +outl(BusRec *, unsigned short port, unsigned int value) { if(ioBase == MAP_FAILED) return; xf86WriteMmio32Le((void *)ioBase, port, value); } static __inline__ unsigned int -inb(unsigned short port) +inb(BusRec *, unsigned short port) { if(ioBase == MAP_FAILED) return 0; return xf86ReadMmio8((void *)ioBase, port); } static __inline__ unsigned int -inw(unsigned short port) +inw(BusRec *, unsigned short port) { if(ioBase == MAP_FAILED) return 0; return xf86ReadMmio16Le((void *)ioBase, port); } static __inline__ unsigned int -inl(unsigned short port) +inl(BusRec *, unsigned short port) { if(ioBase == MAP_FAILED) return 0; return xf86ReadMmio32Le((void *)ioBase, port); @@ -1380,26 +1384,26 @@ */ static __inline__ void -outb(unsigned short port, unsigned char val) +outb(BusRec *, unsigned short port, unsigned char val) { __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); } static __inline__ void -outw(unsigned short port, unsigned short val) +outw(BusRec *, unsigned short port, unsigned short val) { __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); } static __inline__ void -outl(unsigned short port, unsigned int val) +outl(BusRec *, unsigned short port, unsigned int val) { __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); } static __inline__ unsigned int -inb(unsigned short port) +inb(BusRec *, unsigned short port) { unsigned char ret; __asm__ __volatile__("inb %1,%0" : @@ -1409,7 +1413,7 @@ } static __inline__ unsigned int -inw(unsigned short port) +inw(BusRec *, unsigned short port) { unsigned short ret; __asm__ __volatile__("inw %1,%0" : @@ -1419,7 +1423,7 @@ } static __inline__ unsigned int -inl(unsigned short port) +inl(BusRec *, unsigned short port) { unsigned int ret; __asm__ __volatile__("inl %1,%0" : @@ -1431,25 +1435,25 @@ # else /* GCCUSESGAS */ static __inline__ void -outb(unsigned short port, unsigned char val) +outb(BusRec *, unsigned short port, unsigned char val) { __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); } static __inline__ void -outw(unsigned short port, unsigned short val) +outw(BusRec *, unsigned short port, unsigned short val) { __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); } static __inline__ void -outl(unsigned short port, unsigned int val) +outl(BusRec *, unsigned short port, unsigned int val) { __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); } static __inline__ unsigned int -inb(unsigned short port) +inb(BusRec *, unsigned short port) { unsigned char ret; __asm__ __volatile__("in%B0 (%1)" : @@ -1459,7 +1463,7 @@ } static __inline__ unsigned int -inw(unsigned short port) +inw(BusRec *, unsigned short port) { unsigned short ret; __asm__ __volatile__("in%W0 (%1)" : @@ -1469,7 +1473,7 @@ } static __inline__ unsigned int -inl(unsigned short port) +inl(BusRec *, unsigned short port) { unsigned int ret; __asm__ __volatile__("in%L0 (%1)" : @@ -1483,34 +1487,34 @@ # else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/ static __inline__ void -outb(unsigned short port, unsigned char val) +outb(BusRec *, unsigned short port, unsigned char val) { } static __inline__ void -outw(unsigned short port, unsigned short val) +outw(BusRec *, unsigned short port, unsigned short val) { } static __inline__ void -outl(unsigned short port, unsigned int val) +outl(BusRec *, unsigned short port, unsigned int val) { } static __inline__ unsigned int -inb(unsigned short port) +inb(BusRec *, unsigned short port) { return 0; } static __inline__ unsigned int -inw(unsigned short port) +inw(BusRec *, unsigned short port) { return 0; } static __inline__ unsigned int -inl(unsigned short port) +inl(BusRec *, unsigned short port) { return 0; } @@ -1564,38 +1568,38 @@ # if PPCIO_DEBUG -extern void debug_outb(unsigned int a, unsigned char b, int line, char *file); -extern void debug_outw(unsigned int a, unsigned short w, int line, char *file); -extern void debug_outl(unsigned int a, unsigned int l, int line, char *file); -extern unsigned char debug_inb(unsigned int a, int line, char *file); -extern unsigned short debug_inw(unsigned int a, int line, char *file); -extern unsigned int debug_inl(unsigned int a, int line, char *file); - -# define outb(a,b) debug_outb(a,b, __LINE__, __FILE__) -# define outw(a,w) debug_outw(a,w, __LINE__, __FILE__) -# define outl(a,l) debug_outl(a,l, __LINE__, __FILE__) -# define inb(a) debug_inb(a, __LINE__, __FILE__) -# define inw(a) debug_inw(a, __LINE__, __FILE__) -# define inl(a) debug_inl(a, __LINE__, __FILE__) +extern void debug_outb(BusRec *, unsigned int a, unsigned char b, int line, char *file); +extern void debug_outw(BusRec *, unsigned int a, unsigned short w, int line, char *file); +extern void debug_outl(BusRec *, unsigned int a, unsigned int l, int line, char *file); +extern unsigned char debug_inb(BusRec *, unsigned int a, int line, char *file); +extern unsigned short debug_inw(BusRec *, unsigned int a, int line, char *file); +extern unsigned int debug_inl(BusRec *, unsigned int a, int line, char *file); + +# define outb(d,a,b) debug_outb(d,a,b, __LINE__, __FILE__) +# define outw(d,a,w) debug_outw(d,a,w, __LINE__, __FILE__) +# define outl(d,a,l) debug_outl(d,a,l, __LINE__, __FILE__) +# define inb(d,a) debug_inb(d,a, __LINE__, __FILE__) +# define inw(d,a) debug_inw(d,a, __LINE__, __FILE__) +# define inl(d,a) debug_inl(d,a, __LINE__, __FILE__) # else /* !PPCIO_DEBUG */ -extern unsigned char inb(unsigned int a); -extern unsigned short inw(unsigned int a); -extern unsigned int inl(unsigned int a); +extern unsigned char inb(BusRec *, unsigned int a); +extern unsigned short inw(BusRec *, unsigned int a); +extern unsigned int inl(BusRec *, unsigned int a); # if PPCIO_INLINE -# define outb(a,b) \ +# define outb(d,a,b) \ (*((volatile unsigned char *)(ioBase + (a))) = (b), eieio()) -# define outw(a,w) (stw_brx((w),ioBase,(a)), eieio()) -# define outl(a,l) (stl_brx((l),ioBase,(a)), eieio()) +# define outw(d,a,w) (stw_brx((w),ioBase,(a)), eieio()) +# define outl(d,a,l) (stl_brx((l),ioBase,(a)), eieio()) # else /* !PPCIO_INLINE */ -extern void outb(unsigned int a, unsigned char b); -extern void outw(unsigned int a, unsigned short w); -extern void outl(unsigned int a, unsigned int l); +extern void outb(BusRec *, unsigned int a, unsigned char b); +extern void outw(BusRec *, unsigned int a, unsigned short w); +extern void outl(BusRec *, unsigned int a, unsigned int l); # endif /* PPCIO_INLINE */ @@ -1660,12 +1664,12 @@ # if defined(QNX4) # include -extern unsigned inb(unsigned port); -extern unsigned inw(unsigned port); -extern unsigned inl(unsigned port); -extern void outb(unsigned port, unsigned val); -extern void outw(unsigned port, unsigned val); -extern void outl(unsigned port, unsigned val); +extern unsigned inb(BusRec *, unsigned port); +extern unsigned inw(BusRec *, unsigned port); +extern unsigned inl(BusRec *, unsigned port); +extern void outb(BusRec *, unsigned port, unsigned val); +extern void outw(BusRec *, unsigned port, unsigned val); +extern void outl(BusRec *, unsigned port, unsigned val); # endif /* QNX4 */ # if defined(IODEBUG) && defined(__GNUC__) @@ -1675,13 +1679,13 @@ # undef outb # undef outw # undef outl -# define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) -# define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) -# define inl(a) __extension__ ({unsigned int __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) - -# define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b)) -# define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b)) -# define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b)) +# define inb(d,a) __extension__ ({unsigned char __c=RealInb(d,a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +# define inw(d,a) __extension__ ({unsigned short __c=RealInw(d,a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +# define inl(d,a) __extension__ ({unsigned int __c=RealInl(d,a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) + +# define outb(d,a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(d,a,b)) +# define outw(d,a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(d,a,b)) +# define outl(d,a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(d,a,b)) # endif # endif /* NO_INLINE */ Index: programs/Xserver/hw/xfree86/common/xf86Bus.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v retrieving revision 1.10 diff -u -r1.10 xf86Bus.c --- programs/Xserver/hw/xfree86/common/xf86Bus.c 3 Jul 2005 08:53:42 -0000 1.10 +++ programs/Xserver/hw/xfree86/common/xf86Bus.c 20 Jul 2005 19:04:51 -0000 @@ -3077,7 +3077,9 @@ static void CheckGenericGA() { -/* This needs to be changed for multiple domains */ +/* + * This needs to be changed for multiple domains, should we pass in a device? + */ #if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); CARD8 CurrentValue, TestValue; @@ -3085,13 +3087,13 @@ /* VGA CRTC registers are not used here, so don't bother unlocking them */ /* VGA has one more read/write attribute register than EGA */ - (void) inb(GenericIOBase + VGA_IN_STAT_1_OFFSET); /* Reset flip-flop */ - outb(VGA_ATTR_INDEX, 0x14 | 0x20); - CurrentValue = inb(VGA_ATTR_DATA_R); - outb(VGA_ATTR_DATA_W, CurrentValue ^ 0x0F); - outb(VGA_ATTR_INDEX, 0x14 | 0x20); - TestValue = inb(VGA_ATTR_DATA_R); - outb(VGA_ATTR_DATA_W, CurrentValue); + (void) inb(NULL, GenericIOBase + VGA_IN_STAT_1_OFFSET); /* Reset flip-flop */ + outb(NULL, VGA_ATTR_INDEX, 0x14 | 0x20); + CurrentValue = inb(NULL, VGA_ATTR_DATA_R); + outb(NULL, VGA_ATTR_DATA_W, CurrentValue ^ 0x0F); + outb(NULL, VGA_ATTR_INDEX, 0x14 | 0x20); + TestValue = inb(NULL ,VGA_ATTR_DATA_R); + outb(NULL, VGA_ATTR_DATA_W, CurrentValue); if ((CurrentValue ^ 0x0F) == TestValue) { primaryBus.type = BUS_ISA; Index: programs/Xserver/hw/xfree86/common/xf86Helper.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v retrieving revision 1.9 diff -u -r1.9 xf86Helper.c --- programs/Xserver/hw/xfree86/common/xf86Helper.c 3 Jul 2005 08:53:42 -0000 1.9 +++ programs/Xserver/hw/xfree86/common/xf86Helper.c 20 Jul 2005 19:04:55 -0000 @@ -2107,22 +2107,22 @@ ErrorF("your OS does not support disabling interrupts, then you\n"); FatalError("must specify a Clocks line in the XF86Config file.\n"); } - while ((inb(status) & maskval) == 0x00) + while ((inb(&pScrn->device, status) & maskval) == 0x00) if (sync-- == 0) goto finish; /* Something appears to be happening, so reset sync count */ sync = 200000; - while ((inb(status) & maskval) == maskval) + while ((inb(&pScrn->device, status) & maskval) == maskval) if (sync-- == 0) goto finish; /* Something appears to be happening, so reset sync count */ sync = 200000; - while ((inb(status) & maskval) == 0x00) + while ((inb(&pScrn->device, status) & maskval) == 0x00) if (sync-- == 0) goto finish; for (rcnt = 0; rcnt < 5; rcnt++) { - while (!(inb(status) & maskval)) + while (!(inb(&pScrn->device, status) & maskval)) cnt++; - while ((inb(status) & maskval)) + while ((inb(&pScrn->device, status) & maskval)) cnt++; } Index: programs/Xserver/hw/xfree86/common/xf86str.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86str.h,v retrieving revision 1.8 diff -u -r1.8 xf86str.h --- programs/Xserver/hw/xfree86/common/xf86str.h 3 Jul 2005 08:53:42 -0000 1.8 +++ programs/Xserver/hw/xfree86/common/xf86str.h 20 Jul 2005 19:04:56 -0000 @@ -921,6 +921,7 @@ int clock[MAXCLOCKS]; /* list of clock frequencies */ int videoRam; /* amount of video ram (kb) */ unsigned long biosBase; /* Base address of video BIOS */ + BusRec device; /* Actual device */ unsigned long memPhysBase; /* Physical address of FB */ unsigned long fbOffset; /* Offset of FB in the above */ IOADDRESS domainIOBase; /* Domain I/O base address */ Index: programs/Xserver/hw/xfree86/drivers/apm/apm.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h,v retrieving revision 1.3 diff -u -r1.3 apm.h --- programs/Xserver/hw/xfree86/drivers/apm/apm.h 20 Apr 2005 12:25:22 -0000 1.3 +++ programs/Xserver/hw/xfree86/drivers/apm/apm.h 20 Jul 2005 19:04:56 -0000 @@ -61,6 +61,7 @@ #endif #define TRUE (1) +/* PciBusId? */ #define rdinx(port, ind) (outb((port), (ind)), inb((port) + 1)) #define wrinx(port, ind, val) outb((port), (ind)), outb((port) + 1, (val)) #define modinx(port, ind, mask, bits) \ Index: programs/Xserver/hw/xfree86/drivers/apm/apm_dga.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_dga.c,v retrieving revision 1.3 diff -u -r1.3 apm_dga.c --- programs/Xserver/hw/xfree86/drivers/apm/apm_dga.c 11 Jul 2005 02:29:44 -0000 1.3 +++ programs/Xserver/hw/xfree86/drivers/apm/apm_dga.c 20 Jul 2005 19:04:57 -0000 @@ -340,8 +340,8 @@ } else { /* Wait until vertical retrace is in progress. */ - while (inb(pApm->iobase + 0x3DA) & 0x08); - while (!(inb(pApm->iobase + 0x3DA) & 0x08)); + while (inb(&pScrn->device, pApm->iobase + 0x3DA) & 0x08); + while (!(inb(&pScrn->device, pApm->iobase + 0x3DA) & 0x08)); } } Index: programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c,v retrieving revision 1.4 diff -u -r1.4 ark_accel.c --- programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c 11 Jul 2005 02:29:44 -0000 1.4 +++ programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c 20 Jul 2005 19:04:57 -0000 @@ -52,7 +52,7 @@ IOADDRESS port = pScrn->domainIOBase + 0x3cb; for (;;) { - if (!(inb(port) & 0x40)) + if (!(inb(&pScrn->device, port) & 0x40)) break; } } Index: programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c,v retrieving revision 1.5 diff -u -r1.5 ark_driver.c --- programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c 11 Jul 2005 02:29:44 -0000 1.5 +++ programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c 20 Jul 2005 19:04:58 -0000 @@ -386,9 +386,9 @@ pARK->PciInfo->func); /* unlock CRTC[0-7] */ - outb(hwp->PIOOffset + hwp->IOBase + 4, 0x11); - tmp = inb(hwp->PIOOffset + hwp->IOBase + 5); - outb(hwp->PIOOffset + hwp->IOBase + 5, tmp & 0x7f); + outb(&pScrn->device, hwp->PIOOffset + hwp->IOBase + 4, 0x11); + tmp = inb(&pScrn->device, hwp->PIOOffset + hwp->IOBase + 5); + outb(&pScrn->device, hwp->PIOOffset + hwp->IOBase + 5, tmp & 0x7f); modinx(hwp->PIOOffset + 0x3c4, 0x1d, 0x01, 0x01); /* use membase's later on ??? */ @@ -431,9 +431,9 @@ { int man_id, dev_id; - inb(hwp->PIOOffset + 0x3c6); /* skip cmd register */ - man_id = inb(hwp->PIOOffset + 0x3c6); /* manufacturer id */ - dev_id = inb(hwp->PIOOffset + 0x3c6); /* device id */ + inb(&pScrn->device, hwp->PIOOffset + 0x3c6); /* skip cmd register */ + man_id = inb(&pScrn->device, hwp->PIOOffset + 0x3c6); /* manufacturer id */ + dev_id = inb(&pScrn->device, hwp->PIOOffset + 0x3c6); /* device id */ if (man_id == 0x84 && dev_id == 0x98) { pARK->ramdac = ZOOMDAC; pARK->dac_width = 16; @@ -1139,7 +1139,7 @@ ARKFreeRec(pScrn); } - +/* Needs a pScrn or BusRec... */ static unsigned char get_daccomm(IOADDRESS isaIOBase) { unsigned char tmp; @@ -1155,7 +1155,7 @@ return tmp; } - +/* Same here (see above) */ static unsigned char set_daccom(IOADDRESS isaIOBase, unsigned char comm) { #if 0 Index: programs/Xserver/hw/xfree86/drivers/i810/i810.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v retrieving revision 1.6 diff -u -r1.6 i810.h --- programs/Xserver/hw/xfree86/drivers/i810/i810.h 4 Dec 2004 00:43:09 -0000 1.6 +++ programs/Xserver/hw/xfree86/drivers/i810/i810.h 20 Jul 2005 19:05:00 -0000 @@ -61,6 +61,11 @@ #include "i810_dri.h" #endif +#define I810_USE_EXA + +#ifdef I810_USE_EXA +#include "exa.h" +#endif #include "common.h" #define I810_VERSION 4000 @@ -221,6 +226,20 @@ xf86CursorInfoPtr CursorInfoRec; CloseScreenProcPtr CloseScreen; ScreenBlockHandlerProcPtr BlockHandler; +#ifdef I810_USE_EXA + ExaDriverPtr EXADriverPtr; + int fillPitch, fillBpp, fillXoffs; + CARD32 fillDstBase; + int copySXoffs, copyDXoffs, copyBpp; + int copySPitch, copyDPitch; + CARD32 copySrcBase, copyDstBase; + int copyXdir, copyYdir; + ExaOffscreenArea * exa_scratch; + unsigned int exa_scratch_next; + void * ExaRenderCallback; + void (*ExaRenderCallback)(ScrnInfoPtr); + Time ExaRenderTime; +#endif I810WriteIndexedByteFunc writeControl; I810ReadIndexedByteFunc readControl; @@ -260,6 +279,7 @@ Bool showCache; Bool noAccel; + Bool useEXA; Bool allowPageFlip; Bool have3DWindows; int drmMinor; Index: programs/Xserver/hw/xfree86/drivers/i810/i830.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/i810/i830.h,v retrieving revision 1.11 diff -u -r1.11 i830.h --- programs/Xserver/hw/xfree86/drivers/i810/i830.h 20 May 2005 15:24:02 -0000 1.11 +++ programs/Xserver/hw/xfree86/drivers/i810/i830.h 20 Jul 2005 19:05:00 -0000 @@ -154,6 +154,7 @@ #ifdef I830_XV int XvInUse; #endif + Bool useEXA; } I830EntRec, *I830EntPtr; typedef struct _I830Rec { @@ -272,6 +273,18 @@ xf86CursorInfoPtr CursorInfoRec; CloseScreenProcPtr CloseScreen; +#ifdef I810_USE_EXA + ExaDriverPtr EXADriverPtr; + int fillPitch, fillBpp, fillXoffs; + CARD32 fillDstBase; + int copySXoffs, copyDXoffs, copyBpp; + int copySPitch, copyDPitch; + CARD32 copySrcBase, copyDstBase; + int copyXdir, copyYdir; + ExaOffscreenArea * exa_scratch; + unsigned int exa_scratch_next; +#endif + I830WriteIndexedByteFunc writeControl; I830ReadIndexedByteFunc readControl; I830WriteByteFunc writeStandard; @@ -374,7 +387,7 @@ #define I830PTR(p) ((I830Ptr)((p)->driverPrivate)) #define I830REGPTR(p) (&(I830PTR(p)->ModeReg)) -#define I830_SELECT_FRONT 0 +#DEFINE I830_SELECT_FRONT 0 #define I830_SELECT_BACK 1 #define I830_SELECT_DEPTH 2 Index: programs/Xserver/hw/xfree86/drivers/i810/i830_accel.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/drivers/i810/i830_accel.c,v retrieving revision 1.5 diff -u -r1.5 i830_accel.c --- programs/Xserver/hw/xfree86/drivers/i810/i830_accel.c 11 Jul 2005 02:29:51 -0000 1.5 +++ programs/Xserver/hw/xfree86/drivers/i810/i830_accel.c 20 Jul 2005 19:05:01 -0000 @@ -64,6 +64,276 @@ #include "i830.h" #include "i810_reg.h" +#ifdef I810_USE_EXA +void i830ScratchSave(ScreenPtr pScreen, ExaOffscreenArea *area); +Bool i830UploadToScreen(PixmapPtr pDst, char *src, int src_pitch); +Bool i830UploadToScratch(PixmapPtr pSrc, PixmapPtr pDst); +Bool i830DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch); +#endif + +#ifdef I810_USE_EXA + +static void +i830EXASync(ScreenPtr pScreen, int marker) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (I810_DEBUG & (DEBUG_VERBOSE_ACCEL | DEBUG_VERBOSE_SYNC)) + ErrorF("I830EXASync\n"); + +#ifdef XF86DRI + /* VT switching tries to do this. + */ + if (!pI830->LockHeld && pI830->directRenderingEnabled) { + return; + } +#endif + + if (pI830->entityPrivate && !pI830->entityPrivate->RingRunning) return; + + /* Send a flush instruction and then wait till the ring is empty. + * This is stronger than waiting for the blitter to finish as it also + * flushes the internal graphics caches. + */ + { + BEGIN_LP_RING(2); + OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); + OUT_RING(MI_NOOP); /* pad to quadword */ + ADVANCE_LP_RING(); + } + + I830WaitLpRing(pScrn, pI830->LpRing->mem.Size - 8, 0); + + pI830->LpRing->space = pI830->LpRing->mem.Size - 8; + pI830->nextColorExpandBuf = 0; +} + +static Bool +i830EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); +#if 0 + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830EXAPrepareSolid: %x alu: %x mask: %x\n", + color, rop, planemask); +#endif + pI830->BR[13] = ((XAAGetPatternROP(alu) << 16) | + (pScrn->displayWidth * pI830->cpp)); + + pI830->BR[16] = color; + + switch (pScrn->bitsPerPixel) { + case 8: + break; + case 16: + pI830->BR[13] |= (1 << 24); + break; + case 32: + pI830->BR[13] |= ((1 << 25) | (1 << 24)); + break; + } +} + +static void +i830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + I830Ptr pI830 = I830PTR(pScrn); + int h = y2 - y1, w = x2 - x1; /* assumes x2 > x1 && y2 > y1 */ + + if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) + ErrorF("I830EXASolid (%d, %d)->(%d, %d)\n", x, y, x2, y2); + + { + BEGIN_LP_RING(6); + + if (pScrn->bitsPerPixel == 32) { + OUT_RING(COLOR_BLT_CMD | COLOR_BLT_WRITE_ALPHA | + COLOR_BLT_WRITE_RGB); + } else { + OUT_RING(COLOR_BLT_CMD); + } + OUT_RING(pI830->BR[13]); + OUT_RING((h << 16) | (w * pI830->cpp)); + OUT_RING(pI830->bufferOffset + (y * pScrn->displayWidth + x) * + pI830->cpp); + OUT_RING(pI830->BR[16]); + OUT_RING(0); + + ADVANCE_LP_RING(); + } +} + +static void +i830EXADoneSolid(PixmapPtr pPixmap) +{ +} + +static Bool +i830EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, + int alu, Pixel planemask) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + I810Ptr pI830 = I810PTR(pScrn); + CARD32 srcbase, dstbase; + + /* Planemask not supported */ + if((planemask & ((1 << pSrcPixmap->drawable.depth) - 1)) != + (1 << pSrcPixmap->drawable.depth) - 1) { + return FALSE; + } + + if((pDstPixmap->drawable.bitsPerPixel != 8) && + (pDstPixmap->drawable.bitsPerPixel != 16) && + (pDstPixmap->drawable.bitsPerPixel != 32)) + return FALSE; + + srcbase = (CARD32)((unsigned long)pSrcPixmap->devPrivate.ptr - + (unsigned long)pI830->FbBase + FBOFFSET); + /* TODO: If srcbase is not aligned, need to align it and fix x coordinates */ + if(srcbase & 0x0f) xf86DrvMsg(0, 0, "Copy: Bad source\n"); + pI830->copySXoffs = 0; + + dstbase = (CARD32)((unsigned long)pDstPixmap->devPrivate.ptr - + (unsigned long)pI830->FbBase + FBOFFSET); + /* TODO: If dstbase is not aligned, need to align it and fix x coordinates */ + if(dstbase & 0x0f) xf86DrvMsg(0, 0, "Copy: Bad dest\n"); + pI830->copyDXoffs = 0; + + /* TODO: Will there eventually be overlapping blits? + * If so, good night. Then we must calculate new base addresses + * which are identical for source and dest, otherwise + * the chips direction-logic will fail. Certainly funny + * to re-calculate x and y then... + */ + + i830SetupDSTColorDepth((pDstPixmap->drawable.bitsPerPixel >> 4) << 16); + i830CheckQueue(16 * 3); + i830SetupSRCPitchDSTRect((pSrcPixmap->devKind + 3) & ~3, (pDstPixmap->devKind + 3) & ~3, DEV_HEIGHT) + i830SetupROP(i830GetCopyROP(alu)) + i830SetupSRCDSTBase(srcbase, dstbase) + i830SyncWP + + return TRUE; +} + +static void +i830EXACopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int width, int height) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + I810Ptr pI830 = I810PTR(pScrn); + + srcX += pI830->copySXoffs; + dstX += pI830->copyDXoffs; + + i830CheckQueue(16 * 2); + i830SetupSRCDSTXY(srcX, srcY, dstX, dstY) + i830SetRectDoCMD(width, height) +} + +static void +i830EXADoneCopy(PixmapPtr pDstPixmap) +{ +} + +Bool +i830EXAUploadToScreen(PixmapPtr pDst, char *src, int src_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + I810Ptr pI830 = I810PTR(pScrn); + unsigned char *dst = pDst->devPrivate.ptr; + int dst_pitch = pDst->devKind; + int size = src_pitch < dst_pitch ? src_pitch : dst_pitch; + int h = pDst->drawable.height; + + (pI830->SyncAccel)(pScrn); + + while(h--) { + i830MemCopyToVideoRam(pI830, dst, (unsigned char *)src, size); + src += src_pitch; + dst += dst_pitch; + } + + return TRUE; +} + +Bool +i830EXAUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; + I810Ptr pI830 = I810PTR(pScrn); + unsigned char *src, *dst; + int src_pitch = pSrc->devKind; + int dst_pitch, size, w, h, bytes; + + w = pSrc->drawable.width; + + dst_pitch = ((w * (pSrc->drawable.bitsPerPixel >> 3)) + + pI830->EXADriverPtr->card.offscreenPitch - 1) & + ~(pI830->EXADriverPtr->card.offscreenPitch - 1); + + size = dst_pitch * pSrc->drawable.height; + + if(size > pI830->exa_scratch->size) + return FALSE; + + pI830->exa_scratch_next = (pI830->exa_scratch_next + + pI830->EXADriverPtr->card.offscreenByteAlign - 1) & + ~(pI830->EXADriverPtr->card.offscreenByteAlign - 1); + + if(pI830->exa_scratch_next + size > + pI830->exa_scratch->offset + pI830->exa_scratch->size) { + (pI830->EXADriverPtr->accel.WaitMarker)(pSrc->drawable.pScreen, 0); + pI830->exa_scratch_next = pI830->exa_scratch->offset; + } + + memcpy(pDst, pSrc, sizeof(*pDst)); + pDst->devKind = dst_pitch; + pDst->devPrivate.ptr = pI830->EXADriverPtr->card.memoryBase + pI830->exa_scratch_next; + + pI830->exa_scratch_next += size; + + src = pSrc->devPrivate.ptr; + src_pitch = pSrc->devKind; + dst = pDst->devPrivate.ptr; + + bytes = (src_pitch < dst_pitch) ? src_pitch : dst_pitch; + + h = pSrc->drawable.height; + + (pI830->SyncAccel)(pScrn); + + while(h--) { + i830MemCopyToVideoRam(pI830, dst, src, size); + src += src_pitch; + dst += dst_pitch; + } + + return TRUE; +} + +Bool +i830EXADownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; + I810Ptr pI830 = I810PTR(pScrn); + unsigned char *src = pSrc->devPrivate.ptr; + int src_pitch = pSrc->devKind; + int size = src_pitch < dst_pitch ? src_pitch : dst_pitch; + + (pI830->SyncAccel)(pScrn); + + while(h--) { + i830MemCopyFromVideoRam(pI830, (unsigned char *)dst, src, size); + src += src_pitch; + dst += dst_pitch; + } + + return TRUE; +} +#endif /* EXA */ + int I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis) { @@ -270,9 +540,20 @@ if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) ErrorF("I830AccelInit\n"); - pI830->AccelInfoRec = infoPtr = XAACreateInfoRec(); - if (!infoPtr) - return FALSE; +#ifdef I810_USE_EXA + if(pI830->useEXA) { + if(!(pI830->EXADriverPtr = xnfcalloc(sizeof(ExaDriverRec), 1))) { + pI830->NoAccel = TRUE; + pI830->NoXvideo = TRUE; /* No fbmem manager -> no xv */ + } + } +#else + if (!pI810->useEXA) { + pI830->AccelInfoRec = infoPtr = XAACreateInfoRec(); + if (!infoPtr) + return FALSE; + } +#endif pI830->bufferOffset = 0; infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE;