Subject: New X diffs
To: None <port-macppc@netbsd.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: port-macppc
Date: 10/02/2001 23:41:42
This is a new set of diffs, against the -current (i.e. as of right
now) xsrc/xfree tree.  It uses /dev/pci now, so: a) it should work on
machines with the bandit or grackle bridges, and b) it *requires* a
-current kernel.

I also fixed a byte-swapping problem with Xvideo, so it works cleanly
now (at least with planar YUV).  And I added a couple more missing
keys.

Let me know if you try this, whether or not it works.


Index: programs/Xserver/hw/xfree86/common/Imakefile
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/common/Imakefile,v
retrieving revision 1.1.1.3
diff -c -2 -r1.1.1.3 Imakefile
*** programs/Xserver/hw/xfree86/common/Imakefile	2001/06/09 15:03:52	1.1.1.3
--- programs/Xserver/hw/xfree86/common/Imakefile	2001/10/02 22:05:15
***************
*** 18,22 ****
  #endif /* GNUMachArchitecture */
  #else
! # if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) \
  	|| defined(OpenBSDArchitecture) && defined(PpcArchitecture)
          KBD = xf86KbdBSD
--- 18,23 ----
  #endif /* GNUMachArchitecture */
  #else
! # if defined(NetBSDArchitecture) \
! 	|| defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) \
  	|| defined(OpenBSDArchitecture) && defined(PpcArchitecture)
          KBD = xf86KbdBSD
Index: programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v
retrieving revision 1.1.1.3
diff -c -2 -r1.1.1.3 xf86_OSlib.h
*** programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h	2001/06/09 15:08:12	1.1.1.3
--- programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h	2001/10/02 21:51:40
***************
*** 482,489 ****
  #     else
  #      if defined(__NetBSD__) || defined(__OpenBSD__)
! #       if defined(WSCONS_SUPPORT)
!          /* NetBSD's wscons has a PCVT-compatibility module. */
! #        include <dev/wscons/wsdisplay_usl_io.h>
! #       else
  #        include <machine/pcvt_ioctl.h>
  #       endif /* WSCONS_SUPPORT */
--- 482,486 ----
  #     else
  #      if defined(__NetBSD__) || defined(__OpenBSD__)
! #       if !defined(WSCONS_SUPPORT)
  #        include <machine/pcvt_ioctl.h>
  #       endif /* WSCONS_SUPPORT */
***************
*** 502,505 ****
--- 499,503 ----
  #   ifdef WSCONS_SUPPORT
  #    include <dev/wscons/wsconsio.h>
+ #    include <dev/wscons/wsdisplay_usl_io.h>
  #   endif /* WSCONS_SUPPORT */
  #   if defined(__FreeBSD__)
Index: programs/Xserver/hw/xfree86/drivers/ati/r128.h
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h,v
retrieving revision 1.1.1.3
diff -c -2 -r1.1.1.3 r128.h
*** programs/Xserver/hw/xfree86/drivers/ati/r128.h	2001/06/09 15:05:47	1.1.1.3
--- programs/Xserver/hw/xfree86/drivers/ati/r128.h	2001/10/02 21:51:38
***************
*** 61,65 ****
  #define R128_DEBUG    0         /* Turn off debugging output                */
  #define R128_TIMEOUT  2000000   /* Fall out of wait loops after this count */
! #define R128_MMIOSIZE 0x80000
  
  #define R128_VBIOS_SIZE 0x00010000
--- 61,65 ----
  #define R128_DEBUG    0         /* Turn off debugging output                */
  #define R128_TIMEOUT  2000000   /* Fall out of wait loops after this count */
! #define R128_MMIOSIZE 0x4000
  
  #define R128_VBIOS_SIZE 0x00010000
Index: programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c,v
retrieving revision 1.7
diff -c -2 -r1.7 bsd_video.c
*** programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c	2001/09/17 11:00:15	1.7
--- programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c	2001/10/02 21:51:41
***************
*** 731,740 ****
  	     int Len)
  {
  	int rv;
  	int kmem;
  
!  	kmem = open("/dev/kmem", 2);
   	if (kmem == -1) {
!  		FatalError("xf86ReadBIOS: open /dev/kmem\n");
   	}
  
--- 731,741 ----
  	     int Len)
  {
+ #if 0
  	int rv;
  	int kmem;
  
!  	kmem = open("/dev/mem", 2);
   	if (kmem == -1) {
!  		FatalError("xf86ReadBIOS: open /dev/mem\n");
   	}
  
***************
*** 753,756 ****
--- 754,760 ----
  
  	return rv;
+ #else
+ 	return -1;
+ #endif
  }
  
Index: programs/Xserver/hw/xfree86/os-support/bus/Imakefile
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v
retrieving revision 1.4
diff -c -2 -r1.4 Imakefile
*** programs/Xserver/hw/xfree86/os-support/bus/Imakefile	2001/06/09 17:56:50	1.4
--- programs/Xserver/hw/xfree86/os-support/bus/Imakefile	2001/10/02 23:08:43
***************
*** 42,45 ****
--- 42,52 ----
  PCIDRVROBJ = freebsdPci.o
  
+ #elif defined(NetBSDArchitecture) && defined(PpcArchitecture)
+ 
+ XCOMM NetBSD/powerpc
+ 
+ PCIDRVRSRC = netbsdPci.c
+ PCIDRVROBJ = netbsdPci.o
+ 
  #elif defined(PpcArchitecture)
  
Index: programs/Xserver/hw/xfree86/os-support/bus/Pci.h
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v
retrieving revision 1.4
diff -c -2 -r1.4 Pci.h
*** programs/Xserver/hw/xfree86/os-support/bus/Pci.h	2001/06/09 17:56:50	1.4
--- programs/Xserver/hw/xfree86/os-support/bus/Pci.h	2001/10/02 23:15:00
***************
*** 148,151 ****
--- 148,154 ----
  # define  ARCH_PCI_INIT freebsdPciInit
  # define INCLUDE_XF86_MAP_PCI_MEM
+ #elif defined(__powerpc__) && defined(__NetBSD__)
+ # define ARCH_PCI_INIT netbsdPciInit
+ # define INCLUDE_XF86_MAP_PCI_MEM
  #elif defined(__powerpc__)
  # define ARCH_PCI_INIT ppcPciInit
Index: programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c,v
retrieving revision 1.3
diff -c -2 -r1.3 netbsdPci.c
*** programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c	2001/01/15 15:00:20	1.3
--- programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c	2001/10/02 23:08:43
***************
*** 1,71 ****
! /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.1 2000/02/12 20:45:42 dawes Exp $ */
  
- /*-
-  * Copyright (c) 2001 The NetBSD Foundation, Inc.
-  * All rights reserved.
-  *
-  * This code is derived from software contributed to The NetBSD Foundation
-  * by Simon Burge.
-  *
-  * 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. All advertising materials mentioning features or use of this software
-  *    must display the following acknowledgement:
-  *        This product includes software developed by the NetBSD
-  *        Foundation, Inc. and its contributors.
-  * 4. Neither the name of The NetBSD Foundation nor the names of its
-  *    contributors may be used to endorse or promote products derived
-  *    from this software without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-  * ``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 FOUNDATION OR CONTRIBUTORS
-  * 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.
-  */
- 
  #include "Pci.h"
  
! #if defined(__alpha__)
! #include <machine/pio.h>
! #include <machine/sysarch.h>
! 
! /*
!  * NetBSD/alpha platform specific PCI access functions.
!  * Needs NetBSD kernel version 1.5 or later.
!  */
! CARD32 netbsdPciCfgRead(PCITAG tag, int off);
! void netbsdPciCfgWrite(PCITAG, int off, CARD32 val);
! void netbsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
  
  pciBusInfo_t netbsdPci0 = {
! 	PCI_CFG_MECH_OTHER, 32, FALSE, 0, 0, 0,
! 	{ netbsdPciCfgRead, netbsdPciCfgWrite, netbsdPciCfgSetBits,
! 	  pciAddrNOOP, pciAddrNOOP},
! 	NULL
  };
- 
- #define BUS(tag)	(((tag)>>16)&0xff)
- #define DFN(tag)	(((tag)>>8)&0xff)
- #define DEV(dfn)	(((DFN(tag))>>3)&0x1f)
- #define FNC(dfn)	((DFN(tag))&0x7)
  
! void  
  netbsdPciInit()
  {
! 	if (alpha_pci_io_enable(1) != 0)
! 		fprintf(stderr, "alpha_pci_io_enable failed!\n");
  
  	pciNumBuses    = 1;
--- 1,46 ----
! #include <sys/types.h>
! #include <sys/mman.h>
! #include <sys/ioctl.h>
! #include <fcntl.h>
! #include <stdio.h>
! #include <unistd.h>
! #include <dev/pci/pciio.h>
! 
! #include "xf86.h"
! #include "xf86Priv.h"
! #include "xf86OSpriv.h"
  
  #include "Pci.h"
+ 
+ CARD32 netbsdPciConfRead(PCITAG, int);
+ void netbsdPciConfWrite(PCITAG, int, CARD32);
+ void netbsdPciSetBits(PCITAG, int, CARD32, CARD32);
  
! static int devpci = -1;
  
  pciBusInfo_t netbsdPci0 = {
! /* configMech  */	PCI_CFG_MECH_OTHER,
! /* numDevices  */	32,
! /* secondary   */	FALSE,
! /* primary_bus */	0,
! /* io_base */		0,	/* XXX */
! /* io_size */		0,	/* XXX */
! /* funcs       */	{
! 				netbsdPciConfRead,
! 				netbsdPciConfWrite,
! 				netbsdPciSetBits,
! 				pciAddrNOOP,
! 				pciAddrNOOP
! 			},
! /* pciBusPriv  */	NULL
  };
  
! void
  netbsdPciInit()
  {
! 
! 	devpci = open("/dev/pci0", O_RDWR);
! 	if (devpci == -1)
! 		FatalError("netbsdPciInit: can't open /dev/pci0\n");
  
  	pciNumBuses    = 1;
***************
*** 76,100 ****
  
  CARD32
! netbsdPciCfgRead(PCITAG tag, int off)
  {
! 	return(alpha_pci_conf_read(BUS(tag), DEV(tag), FNC(tag), off));
! 		return ~0;
  }
  
  void
! netbsdPciCfgWrite(PCITAG tag, int off, CARD32 val)
  {
! 	alpha_pci_conf_write(BUS(tag), DEV(tag), FNC(tag), off, val);
  }
  
  void
! netbsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
  {
! 	CARD32	val = netbsdPciCfgRead(tag, off);
  	val = (val & ~mask) | (bits & mask);
! 	netbsdPciCfgWrite(tag, off, val);
  }
- /* #elif defined(__something_else__) */
- #else
- # error architecture not supported
- #endif
--- 51,93 ----
  
  CARD32
! netbsdPciConfRead(PCITAG tag, int reg)
  {
! 	struct pciio_bdf_cfgreg bdfr;
! 
! 	bdfr.bus      = PCI_BUS_FROM_TAG(tag);
! 	bdfr.device   = PCI_DEV_FROM_TAG(tag);
! 	bdfr.function = PCI_FUNC_FROM_TAG(tag);
! 	bdfr.cfgreg.reg = reg;
! 
! 	if (ioctl(devpci, PCI_IOC_BDF_CFGREAD, &bdfr) == -1)
! 		FatalError("netbsdPciConfRead: failed on %d/%d/%d\n",
! 		    bdfr.bus, bdfr.device, bdfr.function);
! 
! 	return (bdfr.cfgreg.val);
  }
  
  void
! netbsdPciConfWrite(PCITAG tag, int reg, CARD32 val)
  {
! 	struct pciio_bdf_cfgreg bdfr;
! 
! 	bdfr.bus      = PCI_BUS_FROM_TAG(tag);
! 	bdfr.device   = PCI_DEV_FROM_TAG(tag);
! 	bdfr.function = PCI_FUNC_FROM_TAG(tag);
! 	bdfr.cfgreg.reg = reg;
! 	bdfr.cfgreg.val = val;
! 
! 	if (ioctl(devpci, PCI_IOC_BDF_CFGWRITE, &bdfr) == -1)
! 		FatalError("netbsdPciConfWrite: failed on %d/%d/%d\n",
! 		    bdfr.bus, bdfr.device, bdfr.function);
  }
  
  void
! netbsdPciSetBits(PCITAG tag, int reg, CARD32 mask, CARD32 bits)
  {
! 	CARD32 val;
! 
! 	val = netbsdPciConfRead(tag, reg);
  	val = (val & ~mask) | (bits & mask);
! 	netbsdPciConfWrite(tag, reg, val);
  }