Sat Jan 22 15:14:28 2011 UTC ()
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@
(cegger)
diff -r1.24 -r1.25 src/sys/dev/pci/chipsfb.c
diff -r1.335 -r1.336 src/sys/dev/pci/files.pci
diff -r1.26 -r1.27 src/sys/dev/pci/genfb_pci.c
diff -r1.26 -r1.27 src/sys/dev/pci/voodoofb.c
diff -r1.62 -r1.63 src/sys/dev/pci/machfb.c
diff -r1.6 -r1.7 src/sys/dev/pci/pm2fb.c
diff -r1.6 -r1.7 src/sys/dev/pci/voyagerfb.c
diff -r1.19 -r1.20 src/sys/dev/pci/r128fb.c
diff -r1.40 -r1.41 src/sys/dev/pci/radeonfb.c
diff -r1.80 -r1.81 src/sys/dev/pci/tga.c
diff -r1.17 -r1.18 src/sys/dev/pci/unichromefb.c
diff -r1.52 -r1.53 src/sys/dev/pci/vga_pci.c
diff -r1.7 -r1.8 src/sys/dev/pci/wcfb.c
diff -r0 -r1.1 src/sys/dev/pci/wsdisplay_pci.c
diff -r0 -r1.1 src/sys/dev/pci/wsdisplay_pci.h
diff -r1.93 -r1.94 src/sys/dev/wscons/wsconsio.h
--- src/sys/dev/pci/chipsfb.c 2010/12/23 21:11:37 1.24
+++ src/sys/dev/pci/chipsfb.c 2011/01/22 15:14:27 1.25
@@ -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>
@@ -849,6 +850,10 @@
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;
--- src/sys/dev/pci/files.pci 2010/12/11 18:18:09 1.335
+++ src/sys/dev/pci/files.pci 2011/01/22 15:14:27 1.336
@@ -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
@@ -27,6 +27,8 @@
file dev/pci/pcibusprint.c pcibus
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:
--- src/sys/dev/pci/genfb_pci.c 2010/12/16 06:45:50 1.26
+++ src/sys/dev/pci/genfb_pci.c 2011/01/22 15:14:28 1.27
@@ -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) {
--- src/sys/dev/pci/voodoofb.c 2010/12/25 11:51:21 1.26
+++ src/sys/dev/pci/voodoofb.c 2011/01/22 15:14:28 1.27
@@ -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) {
--- src/sys/dev/pci/machfb.c 2010/12/16 06:45:50 1.62
+++ src/sys/dev/pci/machfb.c 2011/01/22 15:14:28 1.63
@@ -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,
--- src/sys/dev/pci/pm2fb.c 2010/12/16 06:45:50 1.6
+++ src/sys/dev/pci/pm2fb.c 2011/01/22 15:14:28 1.7
@@ -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>
@@ -316,6 +317,10 @@
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_GINFO:
if (ms == NULL)
--- src/sys/dev/pci/Attic/voyagerfb.c 2010/12/23 21:34:02 1.6
+++ src/sys/dev/pci/Attic/voyagerfb.c 2011/01/22 15:14:28 1.7
@@ -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>
@@ -324,6 +325,10 @@
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_GINFO:
if (ms == NULL)
--- src/sys/dev/pci/r128fb.c 2011/01/06 07:43:05 1.19
+++ src/sys/dev/pci/r128fb.c 2011/01/22 15:14:28 1.20
@@ -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)
--- src/sys/dev/pci/radeonfb.c 2010/12/16 06:45:50 1.40
+++ src/sys/dev/pci/radeonfb.c 2011/01/22 15:14:28 1.41
@@ -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>
@@ -1095,6 +1096,10 @@
case PCI_IOC_CFGREAD:
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;
--- src/sys/dev/pci/tga.c 2010/11/13 13:52:08 1.80
+++ src/sys/dev/pci/tga.c 2011/01/22 15:14:28 1.81
@@ -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;
}
--- src/sys/dev/pci/unichromefb.c 2010/12/16 06:45:50 1.17
+++ src/sys/dev/pci/unichromefb.c 2011/01/22 15:14:28 1.18
@@ -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 <jmcneill@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;
--- src/sys/dev/pci/vga_pci.c 2010/12/16 06:45:50 1.52
+++ src/sys/dev/pci/vga_pci.c 2011/01/22 15:14:28 1.53
@@ -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"
@@ -312,6 +313,10 @@
case PCI_IOC_CFGWRITE:
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;
--- src/sys/dev/pci/wcfb.c 2010/12/16 06:45:51 1.7
+++ src/sys/dev/pci/wcfb.c 2011/01/22 15:14:28 1.8
@@ -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;*/
}
/* $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;
}
/* $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_ */
--- src/sys/dev/wscons/wsconsio.h 2010/10/02 00:52:02 1.93
+++ src/sys/dev/wscons/wsconsio.h 2011/01/22 15:14:28 1.94
@@ -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.
@@ -541,5 +541,27 @@
#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_ */