diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/config/cf/NetBSD.cf xsrc/xc/config/cf/NetBSD.cf
*** netbsd/xsrc/xc/config/cf/NetBSD.cf	Fri Sep  3 05:13:40 1999
--- xsrc/xc/config/cf/NetBSD.cf	Sat Dec 11 23:33:10 1999
***************
*** 274,280 ****
  # define ServerOSDefines	-DDDXOSINIT -DDDXTIME
  # define ServerExtraDefines	GccGasOption XFree86ServerDefines
  # ifndef XFree86ConsoleDefines
! #  define XFree86ConsoleDefines -DPCCONS_SUPPORT
  # endif
  # define PexDynamicModule	NO
  # define XieDynamicModule	NO
--- 274,280 ----
  # define ServerOSDefines	-DDDXOSINIT -DDDXTIME
  # define ServerExtraDefines	GccGasOption XFree86ServerDefines
  # ifndef XFree86ConsoleDefines
! #  define XFree86ConsoleDefines -DPCCONS_SUPPORT -DPCVT_SUPPORT
  # endif
  # define PexDynamicModule	NO
  # define XieDynamicModule	NO
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/config/cf/site.def xsrc/xc/config/cf/site.def
*** netbsd/xsrc/xc/config/cf/site.def	Tue Apr 27 04:33:35 1999
--- xsrc/xc/config/cf/site.def	Sat Dec 11 23:38:48 1999
***************
*** 34,46 ****
  
  #ifdef BeforeVendorCF
  
- #if defined(NetBSDArchitecture) && defined(arm32Architecture)
- /*
-  * This causes a problem with the X server, so I'm disabling it for now. -JJK
-  */
- #define BuildXKB              NO
- #endif
- 
  /*
   * Include this for easy XFree86 customisations
   */
--- 34,39 ----
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/config/cf/xf86site.def xsrc/xc/config/cf/xf86site.def
*** netbsd/xsrc/xc/config/cf/xf86site.def	Thu Sep  2 04:17:47 1999
--- xsrc/xc/config/cf/xf86site.def	Sat Dec 11 23:35:21 1999
***************
*** 314,324 ****
   */
  
  /*
!  * The following servers are supported on arm32/SHARK platforms:
   *
  #define XF86SVGAServer          NO
  #define XF86VGA16Server         NO
  #define XF86MonoServer          NO
   */
  
  /*
--- 314,326 ----
   */
  
  /*
!  * The following servers are supported on arm32/{SHARK,CATS} platforms:
   *
  #define XF86SVGAServer          NO
  #define XF86VGA16Server         NO
  #define XF86MonoServer          NO
+ #define XF86S3VServer           NO
+ #define XF86Mach64Server        NO
   */
  
  /*
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/config/cf/xfree86.cf xsrc/xc/config/cf/xfree86.cf
*** netbsd/xsrc/xc/config/cf/xfree86.cf	Thu Sep  2 04:17:47 1999
--- xsrc/xc/config/cf/xfree86.cf	Sat Dec 11 23:35:31 1999
***************
*** 170,175 ****
--- 170,181 ----
  #ifndef XF86MonoServer
  #define XF86MonoServer		YES
  #endif
+ #ifndef XF86S3VServer
+ #define XF86S3VServer		YES
+ #endif
+ #ifndef XF86Mach64Server
+ #define XF86Mach64Server	YES
+ #endif
  #ifndef XF86SvgaDrivers
  #define XF86SvgaDrivers		chips igs generic
  #endif
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/programs/Xserver/hw/xfree86/accel/mach64/mach64.c xsrc/xc/programs/Xserver/hw/xfree86/accel/mach64/mach64.c
*** netbsd/xsrc/xc/programs/Xserver/hw/xfree86/accel/mach64/mach64.c	Thu Sep  2 04:18:46 1999
--- xsrc/xc/programs/Xserver/hw/xfree86/accel/mach64/mach64.c	Sat Dec 11 23:33:10 1999
***************
*** 801,806 ****
--- 801,808 ----
  		info.RegisterBase = pcrp->_base2 & 0xFFFFF000;
  	    }
  
+ 	    mach64InfoRec.BIOSbase = pcrp->_baserom;
+ 
  	    /*
  	     * The docs say check (pcrp->_user_config_0 & 0x04) for BlockIO
  	     * but this doesn't seem to be reliable.  Instead check if
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/programs/Xserver/hw/xfree86/common_hw/Imakefile xsrc/xc/programs/Xserver/hw/xfree86/common_hw/Imakefile
*** netbsd/xsrc/xc/programs/Xserver/hw/xfree86/common_hw/Imakefile	Tue Apr 27 04:34:22 1999
--- xsrc/xc/programs/Xserver/hw/xfree86/common_hw/Imakefile	Sat Dec 11 23:33:10 1999
***************
*** 26,38 ****
  
  SRCS = I2061Acal.c I2061Aset.c I2061Aalt.c xf86_ClkPr.c \
         SC11412.c ATTDac.c S3gendac.c Ti3025clk.c \
!        ICS2595.c CirrusClk.c Ch8391clk.c xf86_PCI.c Ti3026clk.c IBMRGB.c \
         STG1703clk.c ICS1562.c $(XSRCS)
  
  OBJS = I2061Acal.o I2061Aset.o I2061Aalt.o xf86_ClkPr.o \
         SC11412.o ATTDac.o S3gendac.o Ti3025clk.o \
!        ICS2595.o CirrusClk.o Ch8391clk.o xf86_PCI.o Ti3026clk.o IBMRGB.o \
         STG1703clk.o ICS1562.o $(XOBJS)
  
  INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
  	   -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I../accel/s3
--- 26,46 ----
  
  SRCS = I2061Acal.c I2061Aset.c I2061Aalt.c xf86_ClkPr.c \
         SC11412.c ATTDac.c S3gendac.c Ti3025clk.c \
!        ICS2595.c CirrusClk.c Ch8391clk.c Ti3026clk.c IBMRGB.c \
         STG1703clk.c ICS1562.c $(XSRCS)
  
  OBJS = I2061Acal.o I2061Aset.o I2061Aalt.o xf86_ClkPr.o \
         SC11412.o ATTDac.o S3gendac.o Ti3025clk.o \
!        ICS2595.o CirrusClk.o Ch8391clk.o Ti3026clk.o IBMRGB.o \
         STG1703clk.o ICS1562.o $(XOBJS)
+ 
+ #if defined(arm32Architecture)
+ SRCS += xf86_PCI_DC21285.c
+ OBJS += xf86_PCI_DC21285.o
+ #else
+ SRCS += xf86_PCI.c
+ OBJS += xf86_PCI.o
+ #endif
  
  INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
  	   -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I../accel/s3
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c xsrc/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c
*** netbsd/xsrc/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c	Tue Apr 27 04:34:28 1999
--- xsrc/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c	Sat Dec 11 23:33:11 1999
***************
*** 63,68 ****
--- 63,71 ----
  #include "xf86_OSlib.h"
  #include "xf86_Config.h"
  
+ #define CATS
+ /*#define SHARK*/
+ 
  #ifdef __arm32__
  #include <machine/devmap.h>
  struct memAccess
***************
*** 77,83 ****
--- 80,100 ----
  static pointer xf86MapInfoMap();
  static void xf86MapInfoUnmap();
  static struct memAccess *checkMapInfo();
+ #ifdef CATS
+ int vgaPhysLinearBase;
+ unsigned int IOPortBase;
+ #endif
+ #ifdef SHARK
  extern int vgaPhysLinearBase;
+ #endif
+ 
+ #ifdef CATS
+ /* On CATS systems PCI memory is accessable from 2GB physical */
+ #define PHYSMEM_OFFSET	0x80000000;
+ #else
+ #define PHYSMEM_OFFSET	0x00000000;
+ #endif
+ 
  
  /* A memAccess structure is needed for each possible region */ 
  struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, 
***************
*** 249,254 ****
--- 266,272 ----
  		FatalError("xf86MapVidMem: failed to open %s (%s)\n",
  			   DEV_MEM, strerror(errno));
  	    }
+ 	    Base += PHYSMEM_OFFSET;
  	    base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
  				 MAP_FLAGS, devMemFd,
  				 (off_t)(unsigned long) Base);
***************
*** 563,569 ****
--- 581,593 ----
  #if defined(USE_ARC_MMAP) || defined(__arm32__)
  
  #ifdef USE_ARM32_MMAP
+ #ifdef SHARK
  #define	DEV_MEM_IOBASE	0x43000000
+ #define	DEV_MEM_IOSIZE	0x400
+ #elif defined(CATS)
+ #define	DEV_MEM_IOBASE	0x7c000000	/* PCI I/O space */
+ #define	DEV_MEM_IOSIZE	0x10000	
+ #endif
  #endif
  
  static Bool ScreenEnabled[MAXSCREENS];
***************
*** 655,663 ****
  
  	if (devMemFd >= 0 && useDevMem)
  	{
! 	    base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ|PROT_WRITE,
! 				 MAP_FILE, devMemFd, (off_t)DEV_MEM_IOBASE);
! 
  	    if (base != (pointer)-1)
  		IOPortBase = (unsigned int)base;
  	}
--- 679,687 ----
  
  	if (devMemFd >= 0 && useDevMem)
  	{
! 	    base = (pointer)mmap((caddr_t)0, DEV_MEM_IOSIZE,
! 	        PROT_READ|PROT_WRITE, MAP_FILE, devMemFd,
! 		(off_t)DEV_MEM_IOBASE);
  	    if (base != (pointer)-1)
  		IOPortBase = (unsigned int)base;
  	}
***************
*** 704,710 ****
  		if (ScreenEnabled[i])
  			return;
  
! 	munmap((caddr_t)IOPortBase, 0x400);
  	IOPortBase = (unsigned int)-1;
  	ExtendedEnabled = FALSE;
  #endif
--- 728,734 ----
  		if (ScreenEnabled[i])
  			return;
  
! 	munmap((caddr_t)IOPortBase, DEV_MEM_IOSIZE);
  	IOPortBase = (unsigned int)-1;
  	ExtendedEnabled = FALSE;
  #endif
diff -c -r --exclude CVS --exclude Makefile netbsd/xsrc/xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c xsrc/xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c
*** netbsd/xsrc/xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c	Fri Aug 22 02:23:41 1997
--- xsrc/xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c	Sat Dec 11 23:33:11 1999
***************
*** 118,124 ****
  		       strerror(errno));
  		return(-1);
  	}
! 
  	if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
  	{
  		ErrorF("xf86ReadBios: %s seek failed (%s)\n", DEV_MEM,
--- 118,127 ----
  		       strerror(errno));
  		return(-1);
  	}
! #if defined(__arm32__)
! 	/* PCI memory has a 2GB physical offset */
! 	Base += 0x80000000;
! #endif
  	if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
  	{
  		ErrorF("xf86ReadBios: %s seek failed (%s)\n", DEV_MEM,
diff -c -r --exclude CVS --exclude Makefile /dev/null xsrc/xc/config/cf/NetBSD.cf
*** /dev/null	Sun Dec 12 00:09:57 1999
--- xsrc/xc/programs/Xserver/hw/xfree86/common_hw/xf86_PCI_DC21285.c	Sun Dec 12 00:44:10 1999
***************
*** 0 ****
--- 1,395 ----
+ /* $XFree86$ */
+ /*
+  * Copyright 1999 by Mark Brinicombe <mark@causality.com>
+  *
+  * Based of xf86_PCI.c and adapted for the DC21285
+  *
+  * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+  *
+  * Permission to use, copy, modify, distribute, and sell this software and its
+  * documentation for any purpose is hereby granted without fee, provided that
+  * the above copyright notice appear in all copies and that both that
+  * copyright notice and this permission notice appear in supporting
+  * documentation, and that the names of the above listed copyright holder(s)
+  * not be used in advertising or publicity pertaining to distribution of 
+  * the software without specific, written prior permission.  The above listed
+  * copyright holder(s) make(s) no representations about the suitability of this 
+  * software for any purpose.  It is provided "as is" without express or 
+  * implied warranty.
+  *
+  * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD 
+  * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+  * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE 
+  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 
+  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 
+  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 
+  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+  *
+  */
+ /* $XConsortium: xf86_PCI.c /main/14 1996/10/27 11:47:50 kaleb $ */
+ 
+ /* #define DEBUGPCI  1 */
+ 
+ #include <stdio.h>
+ #include "os.h"
+ #include "compiler.h"
+ #include "input.h"
+ #include "xf86Procs.h"
+ #include "xf86_OSlib.h"
+ #include "xf86_PCI.h"
+ 
+ static pciConfigPtr pci_devp[MAX_PCI_DEVICES + 1] = {NULL, };
+ 
+ /* New PCI code */
+ 
+ /*
+  * This is based heavily on the code in FreeBSD-current, which was written
+  * by Wolfgang Stanglmeier, and contains the following copyright:
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. The name of the author may not be used to endorse or promote products
+  *    derived from this software without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  */
+ 
+ #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+ 
+ static int pciConfigType = 0;
+ static int pciMaxDevice = 0;
+ 
+ static CARD8* pci_base;
+ static int pci_fd;
+ 
+ static Bool
+ pcibusCheck()
+ {
+     CARD8 device;
+ 
+     for (device = 0; device < pciMaxDevice; device++) {
+ 	CARD32 id;
+ 	id = pcibusRead(pcibusTag(0, device, 0), 0);
+ 	if (id && id != 0xffffffff) {
+ 	    return TRUE;
+ 	}
+     }
+     return 0;
+ }
+ 
+ static void
+ pcibusSetup()
+ {
+ 	pciConfigType = 1;
+ 	pciMaxDevice = 20;
+ }
+ 
+ pciTagRec
+ pcibusTag(CARD8 bus, CARD8 cardnum, CARD8 func)
+ {
+ 	pciTagRec tag;
+ 	CARD32 address;
+ 	tag.cfg1 = 0;
+ 
+ 	if (func > 7)
+ 		return tag;
+ 
+ 	if (bus == 0) {
+ 		address = 0x01000000 | (3 << 22) | (cardnum << 11);
+ 	} else {
+ 		address = 0x00000000 | (bus << 16) | (cardnum << 11);
+ 	}
+ 	address |= (func << 8);
+ 	tag.cfg1 = address;
+ 
+ 	return tag;
+ }
+ 
+ static pciTagRec
+ pcibusFTag(pciTagRec tag, CARD8 func)
+ {
+ 	if (func > 7)
+ 		return tag;
+ 
+ 	tag.cfg1 &= ~0x700UL;
+ 	tag.cfg1 |= ((CARD32)func << 8);
+ 	return tag;
+ }
+ 
+ CARD32
+ pcibusRead(pciTagRec tag, CARD32 reg)
+ {
+ 	CARD32 *ptr;
+ 
+ 	if (!tag.cfg1)
+ 		return 0xffffffff;
+ 
+ 	ptr = (CARD32 *)(pci_base + (tag.cfg1 | (reg & 0xfc)));
+ 
+ 	return *ptr;
+ }
+ 
+ CARD16
+ pciReadWord(pciTagRec tag, CARD32 reg)
+ {
+ 	CARD16 *ptr;
+ 
+ 	if (!tag.cfg1)
+ 		return 0xffff;
+ 
+ 	ptr = (CARD16 *)(pci_base + (tag.cfg1 | (reg & 0xfe)));
+ 
+ 	return *ptr;
+ }
+ 
+ CARD8
+ pciReadByte(pciTagRec tag, CARD32 reg)
+ {
+ 	CARD8 *ptr;
+ 
+ 	if (!tag.cfg1)
+ 		return 0xff;
+ 
+ 	ptr = (CARD8 *)(pci_base + (tag.cfg1 | (reg & 0xff)));
+ 
+ 	return *ptr;
+ }
+ 
+ void
+ pcibusWrite(pciTagRec tag, CARD32 reg, CARD32 data)
+ {
+ 	CARD32 *ptr;
+ 
+ 	if (!tag.cfg1)
+ 		return;
+ 
+ 	ptr = (CARD32 *)(pci_base + (tag.cfg1 | (reg & 0xfc)));
+ 
+ 	*ptr = data;
+ }
+ 
+ void
+ pciWriteWord(pciTagRec tag, CARD32 reg, CARD16 data)
+ {
+ 	CARD16 *ptr;
+ 
+ 	if (!tag.cfg1)
+ 		return;
+ 
+ 	ptr = (CARD16 *)(pci_base + (tag.cfg1 | (reg & 0xfe)));
+ 
+ 	*ptr = data;
+ }
+ 
+ void
+ pciWriteByte(pciTagRec tag, CARD32 reg, CARD8 data)
+ {
+ 	CARD8 *ptr;
+ 
+ 	if (!tag.cfg1)
+ 		return;
+ 
+ 	ptr = (CARD8 *)(pci_base + (tag.cfg1 | (reg & 0xff)));
+ 
+ 	*ptr = data;
+ }
+ 
+ static void
+ pciEnableIO(int scrnIndex)
+ {
+ 	if ((pci_fd = open("/dev/mem", O_RDWR)) >= 0) {
+ 		pci_base = (pointer)mmap((caddr_t)0, 0x02000000,
+ 		    PROT_READ|PROT_WRITE, MAP_FLAGS, pci_fd,
+ 		    (off_t)0x7a000000);
+ 
+ 		if (pci_base != (pointer)-1) {
+ 			return;
+ 		}
+ 	}
+ 	FatalError("Cannot map PCI config space\n");
+ }
+ 
+ static void
+ pciDisableIO(int scrnIndex)
+ {
+ 	munmap((caddr_t)pci_base, 0x02000000);
+ 	close(pci_fd);
+ }
+ 
+ static Bool
+ pciMfDev(CARD8 bus, CARD8 cardnum)
+ {
+     pciTagRec tag0, tag1;
+     CARD32 id0, id1;
+ 
+     /* Detect a multi-function device that complies to the PCI 2.0 spec */
+ 
+     tag0 = pcibusTag(bus, cardnum, 0);
+     if (pcibusRead(tag0, PCI_HEADER_MISC) & PCI_HEADER_MULTIFUNCTION)
+ 	return TRUE;
+ 
+     /*
+      * Now, to find non-compliant devices...
+      * If there is a valid ID for function 1 and the ID for func 0 and 1
+      * are different, or the base0 values of func 0 and 1 are differend,
+      * then assume there is a multi-function device.
+      */
+     tag1 = pcibusTag(bus, cardnum, 1);
+     id1 = pcibusRead(tag1, PCI_ID_REG);
+     if (id1 != 0xffffffff) {
+ 	id0 = pcibusRead(tag0, PCI_ID_REG);
+ 	if (id0 != id1)
+ 	    return TRUE;
+ 	if (pcibusRead(tag0, PCI_MAP_REG_START)
+ 	    != pcibusRead(tag1, PCI_MAP_REG_START))
+ 	    return TRUE;
+     }
+     return FALSE;
+ }
+ 
+ pciConfigPtr *
+ xf86scanpci(int scrnIndex)
+ {
+     pciConfigRec pcr;
+     int pcibusidx, pcinumbus, pcibuses[16];
+     int idx = 0, hostbridges = 0;
+ 
+     if (pci_devp[0])
+ 	return pci_devp;
+ 
+     pciEnableIO(scrnIndex);
+ 
+     /* Check for a PCI bus, and find the config type */
+     pcibusSetup();
+ 
+     if (pciConfigType == 0)
+ 	return (pciConfigPtr *)NULL;
+ 
+     pcibusidx = 0;
+     pcibuses[0] = 0;
+     pcinumbus = 1;
+ 
+     do {
+ 	for (pcr._cardnum = 0; pcr._cardnum < pciMaxDevice; pcr._cardnum++) {
+ 	    int maxfunc = 0;
+ 	    pciTagRec tag;
+ 
+ 	    pcr._bus = pcibuses[pcibusidx];
+ 
+ 	    tag = pcibusTag(pcr._bus, pcr._cardnum, 0);
+ 	    for (pcr._func = 0; pcr._func <= maxfunc; pcr._func++) {
+ 		tag = pcibusFTag(tag, pcr._func);
+ 		pcr._device_vendor = pcibusRead(tag, PCI_ID_REG);
+ 		if (pcr._device_vendor == 0xffffffff)	/* nothing there */
+ 		    continue;
+ 
+ 		if (pciMfDev(pcr._bus, pcr._cardnum))
+ 		    maxfunc = 7;
+ 
+ 		pcr._status_command = pcibusRead(tag, PCI_CMD_STAT_REG);
+ 		pcr._class_revision = pcibusRead(tag, PCI_CLASS_REG);
+ 		pcr._bist_header_latency_cache =
+ 			pcibusRead(tag, PCI_HEADER_MISC);
+ 		pcr._base0 = pcibusRead(tag, PCI_MAP_REG_START);
+ 		pcr._base1 = pcibusRead(tag, PCI_MAP_REG_START + 0x04);
+ 		pcr._base2 = pcibusRead(tag, PCI_MAP_REG_START + 0x08);
+ 		pcr._base3 = pcibusRead(tag, PCI_MAP_REG_START + 0x0c);
+ 		pcr._base4 = pcibusRead(tag, PCI_MAP_REG_START + 0x10);
+ 		pcr._base5 = pcibusRead(tag, PCI_MAP_REG_START + 0x14);
+ 		pcr.rsvd1  = pcibusRead(tag, PCI_MAP_REG_START + 0x18);
+ 		pcr.rsvd2  = pcibusRead(tag, PCI_MAP_REG_START + 0x1C);
+ 		pcr._baserom = pcibusRead(tag, PCI_MAP_ROM_REG) & ~1;
+ 		pcr._max_min_ipin_iline = pcibusRead(tag, PCI_INTERRUPT_REG);
+ 		pcr._user_config = pcibusRead(tag, PCI_REG_USERCONFIG);
+ 
+ 		/* Check for PCI-PCI bridges */
+ 		if (pcr._base_class == PCI_CLASS_BRIDGE) {
+ 		    if (pcr._sub_class == PCI_SUBCLASS_BRIDGE_PCI) {
+ 		        if (pcr._secondary_bus_number > 0)
+ 			    pcibuses[pcinumbus++] = pcr._secondary_bus_number;
+ 		    } else if (pcr._sub_class == PCI_SUBCLASS_BRIDGE_HOST &&
+ 				 ++hostbridges > 1) {
+ 			    pcibuses[pcinumbus] = pcinumbus;
+ 			    pcinumbus++;
+ 		    }
+ 		}
+ 
+ 		if (idx >= MAX_PCI_DEVICES)
+ 		    continue;
+ 
+ 		if ((pci_devp[idx] = (pciConfigPtr)xalloc(sizeof(pciConfigRec)))
+ 		    == (pciConfigPtr)NULL) {
+ 		    pciDisableIO(scrnIndex);
+ 		    return (pciConfigPtr *)NULL;
+ 		}
+ 
+ 		memcpy(pci_devp[idx++], &pcr, sizeof(pciConfigRec));
+ 		pci_devp[idx] = (pciConfigPtr)NULL;
+ 		if (xf86Verbose > 1) {
+ 		    ErrorF("PCI: Bus 0x%x Card 0x%02x Func 0x%x ID 0x%04x,"
+ 			   "0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n",
+ 			   pcr._bus, pcr._cardnum, pcr._func, pcr._vendor,
+ 			   pcr._device, pcr._rev_id, pcr._base_class,
+ 			   pcr._sub_class);
+ 		}
+ 	    }
+ 	}
+     } while (++pcibusidx < pcinumbus);
+     pciDisableIO(scrnIndex);
+     return pci_devp;
+ }
+ 
+ void
+ xf86writepci(int scrnIndex, int bus, int cardnum, int func, int reg,
+ 	     CARD32 mask, CARD32 value)
+ {
+     pciTagRec tag;
+     CARD32 data;
+ 
+     pciEnableIO(scrnIndex);
+ 
+     /* Check for a PCI bus, and find the config type */
+     pcibusSetup();
+ 
+     if (pciConfigType == 0)
+ 	return;
+ 
+     tag = pcibusTag(bus, cardnum, func);
+     data = pcibusRead(tag, reg) & ~mask | (value & mask);
+     pcibusWrite(tag, reg, data);
+ 
+     if (xf86Verbose > 2) {
+ 	ErrorF("PCI: xf86writepci: Bus=0x%x Card=0x%x Func=0x%x Reg=0x%02x "
+ 	       "Mask=0x%08x Val=0x%08x\n",
+ 	       bus, cardnum, func, reg, mask, value);
+     }
+ 
+     pciDisableIO(scrnIndex);
+ }
+ 
+ void
+ xf86cleanpci()
+ {
+     int idx = 0;
+ 
+     while (pci_devp[idx])
+ 	xfree((pointer)pci_devp[idx++]);
+ 
+     pci_devp[0] = (pciConfigPtr)NULL;
+ }
