Module Name:    src
Committed By:   cegger
Date:           Sat Jan 22 15:14:28 UTC 2011

Modified Files:
        src/sys/dev/pci: chipsfb.c files.pci genfb_pci.c machfb.c pm2fb.c
            r128fb.c radeonfb.c tga.c unichromefb.c vga_pci.c voodoofb.c
            voyagerfb.c wcfb.c
        src/sys/dev/wscons: wsconsio.h
Added Files:
        src/sys/dev/pci: wsdisplay_pci.c wsdisplay_pci.h

Log Message:
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/chipsfb.c
cvs rdiff -u -r1.335 -r1.336 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/genfb_pci.c \
    src/sys/dev/pci/voodoofb.c
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/machfb.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/pm2fb.c src/sys/dev/pci/voyagerfb.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/r128fb.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/radeonfb.c
cvs rdiff -u -r1.80 -r1.81 src/sys/dev/pci/tga.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/unichromefb.c
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/pci/vga_pci.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/wcfb.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/wsdisplay_pci.c \
    src/sys/dev/pci/wsdisplay_pci.h
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/wscons/wsconsio.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/chipsfb.c
diff -u src/sys/dev/pci/chipsfb.c:1.24 src/sys/dev/pci/chipsfb.c:1.25
--- src/sys/dev/pci/chipsfb.c:1.24	Thu Dec 23 21:11:37 2010
+++ src/sys/dev/pci/chipsfb.c	Sat Jan 22 15:14:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: chipsfb.c,v 1.24 2010/12/23 21:11:37 cegger Exp $	*/
+/*	$NetBSD: chipsfb.c,v 1.25 2011/01/22 15:14:27 cegger Exp $	*/
 
 /*
  * Copyright (c) 2006 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: chipsfb.c,v 1.24 2010/12/23 21:11:37 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: chipsfb.c,v 1.25 2011/01/22 15:14:27 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -55,6 +55,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -850,6 +851,10 @@
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
 
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(&sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_SMODE: {
 		int new_mode = *(int*)data;
 		if (new_mode != sc->sc_mode) {

Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.335 src/sys/dev/pci/files.pci:1.336
--- src/sys/dev/pci/files.pci:1.335	Sat Dec 11 18:18:09 2010
+++ src/sys/dev/pci/files.pci	Sat Jan 22 15:14:27 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.335 2010/12/11 18:18:09 matt Exp $
+#	$NetBSD: files.pci,v 1.336 2011/01/22 15:14:27 cegger Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -28,6 +28,8 @@
 
 file	dev/pci/pci_verbose.c		pci & pciverbose
 
+file	dev/pci/wsdisplay_pci.c		wsdisplay & pci
+
 # Cypress 82c693 hyperCache(tm) Stand-Alone PCI Peripheral Controller
 # with USB.  This is a combo chip:
 #

Index: src/sys/dev/pci/genfb_pci.c
diff -u src/sys/dev/pci/genfb_pci.c:1.26 src/sys/dev/pci/genfb_pci.c:1.27
--- src/sys/dev/pci/genfb_pci.c:1.26	Thu Dec 16 06:45:50 2010
+++ src/sys/dev/pci/genfb_pci.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb_pci.c,v 1.26 2010/12/16 06:45:50 cegger Exp $ */
+/*	$NetBSD: genfb_pci.c,v 1.27 2011/01/22 15:14:28 cegger Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb_pci.c,v 1.26 2010/12/16 06:45:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb_pci.c,v 1.27 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -46,6 +46,7 @@
 #include <dev/pci/pciio.h>
 
 #include <dev/wsfb/genfbvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/pci/genfb_pcivar.h>
 
@@ -197,6 +198,11 @@
 	case PCI_IOC_CFGWRITE:
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_gen.sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_SMODE: {
 		int new_mode = *(int*)data, i;
 		if (new_mode == WSDISPLAYIO_MODE_EMUL) {
Index: src/sys/dev/pci/voodoofb.c
diff -u src/sys/dev/pci/voodoofb.c:1.26 src/sys/dev/pci/voodoofb.c:1.27
--- src/sys/dev/pci/voodoofb.c:1.26	Sat Dec 25 11:51:21 2010
+++ src/sys/dev/pci/voodoofb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: voodoofb.c,v 1.26 2010/12/25 11:51:21 macallan Exp $	*/
+/*	$NetBSD: voodoofb.c,v 1.27 2011/01/22 15:14:28 cegger Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.26 2010/12/25 11:51:21 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.27 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -64,6 +64,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include "opt_wsemul.h"
 
@@ -936,7 +937,11 @@
 	case PCI_IOC_CFGWRITE:
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
-		    
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_SMODE: {
 		int new_mode = *(int*)data;
 		if (new_mode != sc->sc_mode) {

Index: src/sys/dev/pci/machfb.c
diff -u src/sys/dev/pci/machfb.c:1.62 src/sys/dev/pci/machfb.c:1.63
--- src/sys/dev/pci/machfb.c:1.62	Thu Dec 16 06:45:50 2010
+++ src/sys/dev/pci/machfb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machfb.c,v 1.62 2010/12/16 06:45:50 cegger Exp $	*/
+/*	$NetBSD: machfb.c,v 1.63 2011/01/22 15:14:28 cegger Exp $	*/
 
 /*
  * Copyright (c) 2002 Bang Jun-Young
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 __KERNEL_RCSID(0, 
-	"$NetBSD: machfb.c,v 1.62 2010/12/16 06:45:50 cegger Exp $");
+	"$NetBSD: machfb.c,v 1.63 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,6 +65,7 @@
 #include <dev/wscons/wsconsio.h>
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/wscons/wsdisplay_vconsvar.h>
 
@@ -1709,7 +1710,11 @@
 	case PCI_IOC_CFGWRITE:
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
-		    
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_SMODE: {
 		int new_mode = *(int*)data;
 		if (new_mode != sc->sc_mode) {
@@ -2007,6 +2012,11 @@
 #endif
 		return ret;
 		}
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	default:
 #ifdef MACHFB_DEBUG
 		log(LOG_NOTICE, "machfb_fbioctl(0x%lx) (%s[%d])\n", cmd,

Index: src/sys/dev/pci/pm2fb.c
diff -u src/sys/dev/pci/pm2fb.c:1.6 src/sys/dev/pci/pm2fb.c:1.7
--- src/sys/dev/pci/pm2fb.c:1.6	Thu Dec 16 06:45:50 2010
+++ src/sys/dev/pci/pm2fb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pm2fb.c,v 1.6 2010/12/16 06:45:50 cegger Exp $	*/
+/*	$NetBSD: pm2fb.c,v 1.7 2011/01/22 15:14:28 cegger Exp $	*/
 
 /*
  * Copyright (c) 2009 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pm2fb.c,v 1.6 2010/12/16 06:45:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pm2fb.c,v 1.7 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -54,6 +54,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -317,6 +318,10 @@
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
 
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_GINFO:
 		if (ms == NULL)
 			return ENODEV;
Index: src/sys/dev/pci/voyagerfb.c
diff -u src/sys/dev/pci/voyagerfb.c:1.6 src/sys/dev/pci/voyagerfb.c:1.7
--- src/sys/dev/pci/voyagerfb.c:1.6	Thu Dec 23 21:34:02 2010
+++ src/sys/dev/pci/voyagerfb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: voyagerfb.c,v 1.6 2010/12/23 21:34:02 cegger Exp $	*/
+/*	$NetBSD: voyagerfb.c,v 1.7 2011/01/22 15:14:28 cegger Exp $	*/
 
 /*
  * Copyright (c) 2009 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.6 2010/12/23 21:34:02 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.7 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -54,6 +54,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -325,6 +326,10 @@
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
 
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_GINFO:
 		if (ms == NULL)
 			return ENODEV;

Index: src/sys/dev/pci/r128fb.c
diff -u src/sys/dev/pci/r128fb.c:1.19 src/sys/dev/pci/r128fb.c:1.20
--- src/sys/dev/pci/r128fb.c:1.19	Thu Jan  6 07:43:05 2011
+++ src/sys/dev/pci/r128fb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: r128fb.c,v 1.19 2011/01/06 07:43:05 macallan Exp $	*/
+/*	$NetBSD: r128fb.c,v 1.20 2011/01/22 15:14:28 cegger Exp $	*/
 
 /*
  * Copyright (c) 2007 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.19 2011/01/06 07:43:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.20 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -54,6 +54,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -349,8 +350,11 @@
 	/* PCI config read/write passthrough. */
 	case PCI_IOC_CFGREAD:
 	case PCI_IOC_CFGWRITE:
-		return (pci_devioctl(sc->sc_pc, sc->sc_pcitag,
-		    cmd, data, flag, l));
+		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
+		    cmd, data, flag, l);
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc, sc->sc_pcitag, data);
 
 	case WSDISPLAYIO_GINFO:
 		if (ms == NULL)

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.40 src/sys/dev/pci/radeonfb.c:1.41
--- src/sys/dev/pci/radeonfb.c:1.40	Thu Dec 16 06:45:50 2010
+++ src/sys/dev/pci/radeonfb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.40 2010/12/16 06:45:50 cegger Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.41 2011/01/22 15:14:28 cegger Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.40 2010/12/16 06:45:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.41 2011/01/22 15:14:28 cegger Exp $");
 
 #define RADEONFB_DEFAULT_DEPTH 8
 
@@ -90,6 +90,7 @@
 #include <dev/videomode/videomode.h>
 #include <dev/videomode/edidvar.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/pci/pcidevs.h>
 #include <dev/pci/pcireg.h>
@@ -1096,6 +1097,10 @@
 	case PCI_IOC_CFGWRITE:
 		return pci_devioctl(sc->sc_pc, sc->sc_pt, cmd, d, flag, l);
 
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(&sc->sc_dev, sc->sc_pc,
+		    sc->sc_pt, d);
+
 	default:
 		return EPASSTHROUGH;
 	}

Index: src/sys/dev/pci/tga.c
diff -u src/sys/dev/pci/tga.c:1.80 src/sys/dev/pci/tga.c:1.81
--- src/sys/dev/pci/tga.c:1.80	Sat Nov 13 13:52:08 2010
+++ src/sys/dev/pci/tga.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tga.c,v 1.80 2010/11/13 13:52:08 uebayasi Exp $ */
+/* $NetBSD: tga.c,v 1.81 2011/01/22 15:14:28 cegger Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tga.c,v 1.80 2010/11/13 13:52:08 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tga.c,v 1.81 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,6 +58,8 @@
 #include <dev/wscons/wscons_raster.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wsfont/wsfont.h>
+#include <dev/pci/wsdisplay_pci.h>
+
 int	tgamatch(device_t, cfdata_t, void *);
 void	tgaattach(device_t, device_t, void *);
 int	tgaprint(void *, const char *);
@@ -594,6 +596,10 @@
 	case PCI_IOC_CFGWRITE:
 		return pci_devioctl(dc->dc_pc, dc->dc_pcitag,
 		    cmd, data, flag, l);
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(vc->softc->sc_dev, dc->dc_pc,
+		    dc->dc_pcitag, data);
 	}
 	return EPASSTHROUGH;
 }

Index: src/sys/dev/pci/unichromefb.c
diff -u src/sys/dev/pci/unichromefb.c:1.17 src/sys/dev/pci/unichromefb.c:1.18
--- src/sys/dev/pci/unichromefb.c:1.17	Thu Dec 16 06:45:50 2010
+++ src/sys/dev/pci/unichromefb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: unichromefb.c,v 1.17 2010/12/16 06:45:50 cegger Exp $ */
+/* $NetBSD: unichromefb.c,v 1.18 2011/01/22 15:14:28 cegger Exp $ */
 
 /*-
  * Copyright (c) 2006, 2008 Jared D. McNeill <jmcne...@invisible.ca>
@@ -51,7 +51,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: unichromefb.c,v 1.17 2010/12/16 06:45:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: unichromefb.c,v 1.18 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -70,6 +70,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include <dev/pci/unichromereg.h>
 #include <dev/pci/unichromemode.h>
@@ -478,6 +479,11 @@
 	case PCI_IOC_CFGWRITE:
 		return (pci_devioctl(sc->sc_pa.pa_pc, sc->sc_pa.pa_tag,
 		    cmd, data, flag, l));
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev,
+		    sc->sc_pa.pa_pc, sc->sc_pa.pa_tag, data);
+
 	}
 
 	return EPASSTHROUGH;

Index: src/sys/dev/pci/vga_pci.c
diff -u src/sys/dev/pci/vga_pci.c:1.52 src/sys/dev/pci/vga_pci.c:1.53
--- src/sys/dev/pci/vga_pci.c:1.52	Thu Dec 16 06:45:50 2010
+++ src/sys/dev/pci/vga_pci.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vga_pci.c,v 1.52 2010/12/16 06:45:50 cegger Exp $	*/
+/*	$NetBSD: vga_pci.c,v 1.53 2011/01/22 15:14:28 cegger Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.52 2010/12/16 06:45:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.53 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -51,6 +51,7 @@
 
 #include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsdisplayvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include "opt_vga.h"
 
@@ -313,6 +314,10 @@
 		return pci_devioctl(psc->sc_pc, psc->sc_pcitag,
 		    cmd, data, flag, l);
 
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(vc->softc->sc_dev,
+		    psc->sc_pc, psc->sc_pcitag, data);
+
 	default:
 		return EPASSTHROUGH;
 	}

Index: src/sys/dev/pci/wcfb.c
diff -u src/sys/dev/pci/wcfb.c:1.7 src/sys/dev/pci/wcfb.c:1.8
--- src/sys/dev/pci/wcfb.c:1.7	Thu Dec 16 06:45:51 2010
+++ src/sys/dev/pci/wcfb.c	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: wcfb.c,v 1.7 2010/12/16 06:45:51 cegger Exp $ */
+/*	$NetBSD: wcfb.c,v 1.8 2011/01/22 15:14:28 cegger Exp $ */
 
 /*-
  * Copyright (c) 2010 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.7 2010/12/16 06:45:51 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wcfb.c,v 1.8 2011/01/22 15:14:28 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,6 +52,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/pci/wsdisplay_pci.h>
 
 #include "opt_wsfb.h"
 #include "opt_wsdisplay_compat.h"
@@ -318,6 +319,11 @@
 	case PCI_IOC_CFGWRITE:
 		return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
 		    cmd, data, flag, l);
+
+	case WSDISPLAYIO_GET_BUSID:
+		return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
+		    sc->sc_pcitag, data);
+
 	case WSDISPLAYIO_SMODE: {
 		/*int new_mode = *(int*)data, i;*/
 		}

Index: src/sys/dev/wscons/wsconsio.h
diff -u src/sys/dev/wscons/wsconsio.h:1.93 src/sys/dev/wscons/wsconsio.h:1.94
--- src/sys/dev/wscons/wsconsio.h:1.93	Sat Oct  2 00:52:02 2010
+++ src/sys/dev/wscons/wsconsio.h	Sat Jan 22 15:14:28 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: wsconsio.h,v 1.93 2010/10/02 00:52:02 macallan Exp $ */
+/* $NetBSD: wsconsio.h,v 1.94 2011/01/22 15:14:28 cegger Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -542,4 +542,26 @@
 #define	WSMUXIO_INJECTEVENT	_IOW('W', 100, struct wscons_event)
 #define	WSMUX_INJECTEVENT	WSMUXIO_INJECTEVENT /* XXX compat */
 
+/* Mapping information retrieval. */
+struct wsdisplayio_bus_id {
+    u_int bus_type;
+#define WSDISPLAYIO_BUS_PCI	0
+#define WSDISPLAYIO_BUS_SBUS	1
+    union bus_data {
+        struct bus_pci {
+            uint32_t domain;
+            uint32_t bus;
+            uint32_t device;
+            uint32_t function;
+        } pci;
+        struct bus_sbus {
+            uint32_t fb_instance;
+        } sbus;
+        /* so the size doesn't change if we add more bus types */
+        char pad[32];
+    } ubus;
+};
+
+#define WSDISPLAYIO_GET_BUSID	_IOR('W', 101, struct wsdisplayio_bus_id)
+
 #endif /* _DEV_WSCONS_WSCONSIO_H_ */

Added files:

Index: src/sys/dev/pci/wsdisplay_pci.c
diff -u /dev/null src/sys/dev/pci/wsdisplay_pci.c:1.1
--- /dev/null	Sat Jan 22 15:14:28 2011
+++ src/sys/dev/pci/wsdisplay_pci.c	Sat Jan 22 15:14:28 2011
@@ -0,0 +1,53 @@
+/*	$NetBSD: wsdisplay_pci.c,v 1.1 2011/01/22 15:14:28 cegger Exp $ */
+/*
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christoph Egger.
+ *
+ * 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.
+ *
+ * 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_pci.c,v 1.1 2011/01/22 15:14:28 cegger Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <dev/pci/pcivar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/pci/wsdisplay_pci.h>
+
+int
+wsdisplayio_busid_pci(device_t self, pci_chipset_tag_t pc,
+    pcitag_t tag, void *data)
+{
+	struct wsdisplayio_bus_id *busid = data;
+
+	KASSERT(device_is_a(device_parent(self), "pci"));
+	busid->bus_type = WSDISPLAYIO_BUS_PCI;
+	busid->ubus.pci.domain = device_unit(device_parent(self));
+	pci_decompose_tag(pc, tag,
+	    &busid->ubus.pci.bus, &busid->ubus.pci.device,
+	    &busid->ubus.pci.function);
+	return 0;
+}
Index: src/sys/dev/pci/wsdisplay_pci.h
diff -u /dev/null src/sys/dev/pci/wsdisplay_pci.h:1.1
--- /dev/null	Sat Jan 22 15:14:28 2011
+++ src/sys/dev/pci/wsdisplay_pci.h	Sat Jan 22 15:14:28 2011
@@ -0,0 +1,40 @@
+/*	$NetBSD: wsdisplay_pci.h,v 1.1 2011/01/22 15:14:28 cegger Exp $ */
+/*
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christoph Egger.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#ifndef _SYS_DEV_PCI_WSDISPLAYPCI_H_
+#define _SYS_DEV_PCI_WSDISPLAYPCI_H_
+
+#include <dev/pci/pcivar.h>
+#include <sys/device_if.h>
+
+int
+wsdisplayio_busid_pci(device_t, pci_chipset_tag_t, pcitag_t, void *);
+
+#endif /* _SYS_DEV_PCI_WSDISPLAYPCI_H_ */

Reply via email to