Module Name:    src
Committed By:   dyoung
Date:           Mon Apr 19 18:24:27 UTC 2010

Modified Files:
        src/sys/arch/i386/isa: isapnp_machdep.c
        src/sys/dev/ic: com.c i82365.c pckbc.c tcic2.c vga.c
        src/sys/dev/isa: isadma.c pcdisplay.c
        src/sys/dev/pci: cy82c693.c pccbb.c
        src/sys/kern: kern_stub.c
        src/sys/sys: bus.h

Log Message:
Add default implementations for bus_space_is_equal(9),
bus_space_tag_create(9), and bus_space_tag_destroy(9).  Use
bus_space_is_equal(9) throughout the kernel to compare
bus_space_tag_t's.  Tested on i386 and on sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/i386/isa/isapnp_machdep.c
cvs rdiff -u -r1.296 -r1.297 src/sys/dev/ic/com.c
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/ic/i82365.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/ic/pckbc.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ic/tcic2.c
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/ic/vga.c
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/isa/isadma.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/isa/pcdisplay.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/cy82c693.c
cvs rdiff -u -r1.197 -r1.198 src/sys/dev/pci/pccbb.c
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/kern_stub.c
cvs rdiff -u -r1.2 -r1.3 src/sys/sys/bus.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/arch/i386/isa/isapnp_machdep.c
diff -u src/sys/arch/i386/isa/isapnp_machdep.c:1.13 src/sys/arch/i386/isa/isapnp_machdep.c:1.14
--- src/sys/arch/i386/isa/isapnp_machdep.c:1.13	Mon Apr 28 20:23:24 2008
+++ src/sys/arch/i386/isa/isapnp_machdep.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: isapnp_machdep.c,v 1.13 2008/04/28 20:23:24 martin Exp $	*/
+/*	$NetBSD: isapnp_machdep.c,v 1.14 2010/04/19 18:24:26 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isapnp_machdep.c,v 1.13 2008/04/28 20:23:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isapnp_machdep.c,v 1.14 2010/04/19 18:24:26 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -67,7 +67,7 @@
 {
 
 #ifdef DIAGNOSTIC
-	if (sc->sc_iot != X86_BUS_SPACE_IO)
+	if (!bus_space_is_equal(sc->sc_iot, x86_bus_space_io))
 		panic("isapnp_map: bogus bus space tag");
 #endif
 
@@ -100,7 +100,7 @@
 #endif
 
 #ifdef DIAGNOSTIC
-	if (sc->sc_iot != X86_BUS_SPACE_IO)
+	if (!bus_space_is_equal(sc->sc_iot, x86_bus_space_io))
 		panic("isapnp_map_readport: bogus bus space tag");
 #endif
 

Index: src/sys/dev/ic/com.c
diff -u src/sys/dev/ic/com.c:1.296 src/sys/dev/ic/com.c:1.297
--- src/sys/dev/ic/com.c:1.296	Mon Mar 22 23:00:08 2010
+++ src/sys/dev/ic/com.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.296 2010/03/22 23:00:08 dyoung Exp $ */
+/* $NetBSD: com.c,v 1.297 2010/04/19 18:24:26 dyoung Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.296 2010/03/22 23:00:08 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.297 2010/04/19 18:24:26 dyoung Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -263,13 +263,6 @@
 #define COM_BARRIER(r, f) \
 	bus_space_barrier((r)->cr_iot, (r)->cr_ioh, 0, (r)->cr_nports, (f))
 
-/* XXX Comparing bus_space_tag_t's is not allowed! */
-static bool
-tags_are_equal(const bus_space_tag_t lt, const bus_space_tag_t rt)
-{
-	return true;
-}
-
 /*ARGSUSED*/
 int
 comspeed(long speed, long frequency, int type)
@@ -399,7 +392,7 @@
 
 	CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
 
-	if (tags_are_equal(regsp->cr_iot, comcons_info.regs.cr_iot) &&
+	if (bus_space_is_equal(regsp->cr_iot, comcons_info.regs.cr_iot) &&
 	    regsp->cr_iobase == comcons_info.regs.cr_iobase) {
 		comconsattached = 1;
 
@@ -548,7 +541,7 @@
 	 * exclusive use.  If it's the console _and_ the
 	 * kgdb device, it doesn't.
 	 */
-	if (tags_are_equal(regsp->cr_iot, comkgdbregs.cr_iot) &&
+	if (bus_space_is_equal(regsp->cr_iot, comkgdbregs.cr_iot) &&
 	    regsp->cr_iobase == comkgdbregs.cr_iobase) {
 		if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
 			com_kgdb_attached = 1;
@@ -2309,7 +2302,7 @@
 {
 	int res;
 
-	if (tags_are_equal(regsp->cr_iot, comcons_info.regs.cr_iot) &&
+	if (bus_space_is_equal(regsp->cr_iot, comcons_info.regs.cr_iot) &&
 	    regsp->cr_iobase == comcons_info.regs.cr_iobase) {
 #if !defined(DDB)
 		return (EBUSY); /* cannot share with console */
@@ -2378,12 +2371,13 @@
 	bus_space_handle_t help;
 
 	if (!comconsattached &&
-	    tags_are_equal(iot, comcons_info.regs.cr_iot) &&
+	    bus_space_is_equal(iot, comcons_info.regs.cr_iot) &&
 	    iobase == comcons_info.regs.cr_iobase)
 		help = comcons_info.regs.cr_ioh;
 #ifdef KGDB
 	else if (!com_kgdb_attached &&
-	    tags_are_equal(iot, comkgdbregs.cr_iot) && iobase == comkgdbregs.cr_iobase)
+	    bus_space_is_equal(iot, comkgdbregs.cr_iot) &&
+	    iobase == comkgdbregs.cr_iobase)
 		help = comkgdbregs.cr_ioh;
 #endif
 	else

Index: src/sys/dev/ic/i82365.c
diff -u src/sys/dev/ic/i82365.c:1.112 src/sys/dev/ic/i82365.c:1.113
--- src/sys/dev/ic/i82365.c:1.112	Mon Mar 22 22:22:57 2010
+++ src/sys/dev/ic/i82365.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82365.c,v 1.112 2010/03/22 22:22:57 dyoung Exp $	*/
+/*	$NetBSD: i82365.c,v 1.113 2010/04/19 18:24:26 dyoung Exp $	*/
 
 /*
  * Copyright (c) 2004 Charles M. Hannum.  All rights reserved.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.112 2010/03/22 22:22:57 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.113 2010/04/19 18:24:26 dyoung Exp $");
 
 #define	PCICDEBUG
 
@@ -992,13 +992,11 @@
 
 	/* XXX this is pretty gross */
 
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
 {
 	struct pcic_softc *sc = device_private(h->ph_parent);
-	if (sc->memt != pcmhp->memt)
+	if (!bus_space_is_equal(sc->memt, pcmhp->memt))
 		panic("pcic_chip_mem_map memt is bogus");
 }
-#endif
 
 	busaddr = pcmhp->addr;
 
@@ -1207,10 +1205,8 @@
 
 	/* XXX this is pretty gross */
 
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-	if (sc->iot != pcihp->iot)
+	if (!bus_space_is_equal(sc->iot, pcihp->iot))
 		panic("pcic_chip_io_map iot is bogus");
-#endif
 
 	DPRINTF(("pcic_chip_io_map window %d %s port %lx+%lx\n",
 	    win, width_names[width], (u_long) ioaddr, (u_long) size));

Index: src/sys/dev/ic/pckbc.c
diff -u src/sys/dev/ic/pckbc.c:1.49 src/sys/dev/ic/pckbc.c:1.50
--- src/sys/dev/ic/pckbc.c:1.49	Mon Mar 22 23:08:34 2010
+++ src/sys/dev/ic/pckbc.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbc.c,v 1.49 2010/03/22 23:08:34 dyoung Exp $ */
+/* $NetBSD: pckbc.c,v 1.50 2010/04/19 18:24:26 dyoung Exp $ */
 
 /*
  * Copyright (c) 2004 Ben Harris.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.49 2010/03/22 23:08:34 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.50 2010/04/19 18:24:26 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -238,9 +238,7 @@
 pckbc_is_console(bus_space_tag_t iot, bus_addr_t addr)
 {
 	if (pckbc_console && !pckbc_console_attached &&
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-	    pckbc_consdata.t_iot == iot &&
-#endif
+	    bus_space_is_equal(pckbc_consdata.t_iot, iot) &&
 	    pckbc_consdata.t_addr == addr)
 		return (1);
 	return (0);

Index: src/sys/dev/ic/tcic2.c
diff -u src/sys/dev/ic/tcic2.c:1.34 src/sys/dev/ic/tcic2.c:1.35
--- src/sys/dev/ic/tcic2.c:1.34	Mon Mar 22 23:08:34 2010
+++ src/sys/dev/ic/tcic2.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcic2.c,v 1.34 2010/03/22 23:08:34 dyoung Exp $	*/
+/*	$NetBSD: tcic2.c,v 1.35 2010/04/19 18:24:26 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christoph Badura.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcic2.c,v 1.34 2010/03/22 23:08:34 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcic2.c,v 1.35 2010/04/19 18:24:26 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -883,10 +883,8 @@
 
 	/* XXX this is pretty gross */
 
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-	if (h->sc->memt != pcmhp->memt)
+	if (!bus_space_is_equal(h->sc->memt, pcmhp->memt))
 		panic("tcic_chip_mem_map memt is bogus");
-#endif
 
 	busaddr = pcmhp->addr;
 
@@ -1104,10 +1102,8 @@
 
 	/* XXX this is pretty gross */
 
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-	if (h->sc->iot != pcihp->iot)
+	if (!bus_space_is_equal(h->sc->iot, pcihp->iot))
 		panic("tcic_chip_io_map iot is bogus");
-#endif
 
 	DPRINTF(("tcic_chip_io_map window %d %s port %lx+%lx\n",
 		 win, width_names[width], (u_long) ioaddr, (u_long) size));

Index: src/sys/dev/ic/vga.c
diff -u src/sys/dev/ic/vga.c:1.103 src/sys/dev/ic/vga.c:1.104
--- src/sys/dev/ic/vga.c:1.103	Mon Mar 22 23:08:34 2010
+++ src/sys/dev/ic/vga.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: vga.c,v 1.103 2010/03/22 23:08:34 dyoung Exp $ */
+/* $NetBSD: vga.c,v 1.104 2010/04/19 18:24:26 dyoung Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.103 2010/03/22 23:08:34 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.104 2010/04/19 18:24:26 dyoung Exp $");
 
 /* for WSCONS_SUPPORT_PCVTFONTS */
 #include "opt_wsdisplay_compat.h"
@@ -736,9 +736,7 @@
 {
 	if (vgaconsole &&
 	    !vga_console_attached &&
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-	    iot == vga_console_vc.hdl.vh_iot &&
-#endif
+	    bus_space_is_equal(iot, vga_console_vc.hdl.vh_iot) &&
 	    (vga_console_type == -1 || (type == vga_console_type)))
 		return (1);
 	return (0);

Index: src/sys/dev/isa/isadma.c
diff -u src/sys/dev/isa/isadma.c:1.63 src/sys/dev/isa/isadma.c:1.64
--- src/sys/dev/isa/isadma.c:1.63	Mon Mar 22 22:30:58 2010
+++ src/sys/dev/isa/isadma.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: isadma.c,v 1.63 2010/03/22 22:30:58 dyoung Exp $	*/
+/*	$NetBSD: isadma.c,v 1.64 2010/04/19 18:24:26 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1.63 2010/03/22 22:30:58 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1.64 2010/04/19 18:24:26 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -155,10 +155,9 @@
 		 * configuration mechanisms, the space and dma tags
 		 * must be the same!
 		 */
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-		if (ids->ids_bst != bst || ids->ids_dmat != dmat)
+		if (!bus_space_is_equal(ids->ids_bst, bst) ||
+		    ids->ids_dmat != dmat)
 			panic("_isa_dmainit: inconsistent ISA tags");
-#endif
 	} else {
 		ids->ids_bst = bst;
 		ids->ids_dmat = dmat;

Index: src/sys/dev/isa/pcdisplay.c
diff -u src/sys/dev/isa/pcdisplay.c:1.39 src/sys/dev/isa/pcdisplay.c:1.40
--- src/sys/dev/isa/pcdisplay.c:1.39	Mon Mar 22 22:30:58 2010
+++ src/sys/dev/isa/pcdisplay.c	Mon Apr 19 18:24:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: pcdisplay.c,v 1.39 2010/03/22 22:30:58 dyoung Exp $ */
+/* $NetBSD: pcdisplay.c,v 1.40 2010/04/19 18:24:26 dyoung Exp $ */
 
 /*
  * Copyright (c) 1998
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcdisplay.c,v 1.39 2010/03/22 22:30:58 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcdisplay.c,v 1.40 2010/04/19 18:24:26 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -360,11 +360,8 @@
 pcdisplay_is_console(bus_space_tag_t iot)
 {
 	if (pcdisplayconsole &&
-	    !pcdisplay_console_attached
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-	    && iot == pcdisplay_console_dc.dc_ph.ph_iot
-#endif
-	    )
+	    !pcdisplay_console_attached &&
+	    bus_space_is_equal(iot, pcdisplay_console_dc.dc_ph.ph_iot))
 		return (1);
 	return (0);
 }

Index: src/sys/dev/pci/cy82c693.c
diff -u src/sys/dev/pci/cy82c693.c:1.7 src/sys/dev/pci/cy82c693.c:1.8
--- src/sys/dev/pci/cy82c693.c:1.7	Mon Mar 22 22:36:07 2010
+++ src/sys/dev/pci/cy82c693.c	Mon Apr 19 18:24:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: cy82c693.c,v 1.7 2010/03/22 22:36:07 dyoung Exp $ */
+/* $NetBSD: cy82c693.c,v 1.8 2010/04/19 18:24:27 dyoung Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cy82c693.c,v 1.7 2010/03/22 22:36:07 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cy82c693.c,v 1.8 2010/04/19 18:24:27 dyoung Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -79,10 +79,7 @@
 
 	if (cyhc_initialized) {
 		CYHC_UNLOCK(s);
-#if 0	/* XXX Comparing bus_space_tag_t is a no-no! */
-		if (iot != cyhc_handle.cyhc_iot)
-			panic("cy82c693_init");
-#endif
+		KASSERT(bus_space_is_equal(iot, cyhc_handle.cyhc_iot));
 		return (&cyhc_handle);
 	}
 

Index: src/sys/dev/pci/pccbb.c
diff -u src/sys/dev/pci/pccbb.c:1.197 src/sys/dev/pci/pccbb.c:1.198
--- src/sys/dev/pci/pccbb.c:1.197	Mon Mar 15 20:02:55 2010
+++ src/sys/dev/pci/pccbb.c	Mon Apr 19 18:24:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pccbb.c,v 1.197 2010/03/15 20:02:55 dyoung Exp $	*/
+/*	$NetBSD: pccbb.c,v 1.198 2010/04/19 18:24:27 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 and 2000
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pccbb.c,v 1.197 2010/03/15 20:02:55 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pccbb.c,v 1.198 2010/04/19 18:24:27 dyoung Exp $");
 
 /*
 #define CBB_DEBUG
@@ -2085,7 +2085,7 @@
 
 	/* Sanity check I/O handle. */
 
-	if (sc->sc_iot != pcihp->iot) {
+	if (!bus_space_is_equal(sc->sc_iot, pcihp->iot)) {
 		panic("pccbb_pcmcia_io_map iot is bogus");
 	}
 
@@ -2703,7 +2703,7 @@
 
 	/* XXX this is pretty gross */
 
-	if (sc->sc_memt != pcmhp->memt) {
+	if (!bus_space_is_equal(sc->sc_memt, pcmhp->memt)) {
 		panic("pccbb_pcmcia_mem_map memt is bogus");
 	}
 
@@ -2838,7 +2838,7 @@
 		align = size;
 	}
 
-	if (rb->rb_bt == sc->sc_memt) {
+	if (bus_space_is_equal(rb->rb_bt, sc->sc_memt)) {
 		if (align < 16) {
 			return 1;
 		}
@@ -2856,7 +2856,7 @@
 		if (align < 0x1000) {
 			align = 0x1000;
 		}
-	} else if (rb->rb_bt == sc->sc_iot) {
+	} else if (bus_space_is_equal(rb->rb_bt, sc->sc_iot)) {
 		if (align < 4) {
 			return 1;
 		}
@@ -2901,8 +2901,8 @@
 
 	pccbb_close_win(sc, bt, bsh, size);
 
-	if (bt == sc->sc_memt) {
-	} else if (bt == sc->sc_iot) {
+	if (bus_space_is_equal(bt, sc->sc_memt)) {
+	} else if (bus_space_is_equal(bt, sc->sc_iot)) {
 	} else {
 		return 1;
 		/* XXX: panic here? */
@@ -2923,7 +2923,7 @@
 
 	head = &sc->sc_iowindow;
 	align = 0x04;
-	if (sc->sc_memt == bst) {
+	if (bus_space_is_equal(sc->sc_memt, bst)) {
 		head = &sc->sc_memwindow;
 		align = 0x1000;
 		DPRINTF(("using memory window, 0x%lx 0x%lx 0x%lx\n\n",
@@ -2950,7 +2950,7 @@
 
 	head = &sc->sc_iowindow;
 	align = 0x04;
-	if (sc->sc_memt == bst) {
+	if (bus_space_is_equal(sc->sc_memt, bst)) {
 		head = &sc->sc_memwindow;
 		align = 0x1000;
 	}
@@ -3039,7 +3039,7 @@
 
 	chainp = TAILQ_FIRST(&sc->sc_iowindow);
 	offs = PCI_CB_IOBASE0;
-	if (sc->sc_memt == bst) {
+	if (bus_space_is_equal(sc->sc_memt, bst)) {
 		chainp = TAILQ_FIRST(&sc->sc_memwindow);
 		offs = PCI_CB_MEMBASE0;
 	}
@@ -3128,7 +3128,7 @@
 	    (unsigned long)pci_conf_read(pc, tag, offs + 8),
 	    (unsigned long)pci_conf_read(pc, tag, offs + 12) + align));
 
-	if (bst == sc->sc_memt) {
+	if (bus_space_is_equal(bst, sc->sc_memt)) {
 		pcireg_t bcr = pci_conf_read(pc, tag, PCI_BRIDGE_CONTROL_REG);
 
 		bcr &= ~(CB_BCR_PREFETCH_MEMWIN0 | CB_BCR_PREFETCH_MEMWIN1);

Index: src/sys/kern/kern_stub.c
diff -u src/sys/kern/kern_stub.c:1.25 src/sys/kern/kern_stub.c:1.26
--- src/sys/kern/kern_stub.c:1.25	Wed Apr 14 15:15:37 2010
+++ src/sys/kern/kern_stub.c	Mon Apr 19 18:24:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_stub.c,v 1.25 2010/04/14 15:15:37 pooka Exp $	*/
+/*	$NetBSD: kern_stub.c,v 1.26 2010/04/19 18:24:27 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.25 2010/04/14 15:15:37 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.26 2010/04/19 18:24:27 dyoung Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_ktrace.h"
@@ -78,6 +78,9 @@
 #include <sys/intr.h>
 #include <sys/cpu.h>
 #include <sys/module.h>
+#include <sys/bus.h>
+
+bool default_bus_space_is_equal(bus_space_tag_t, bus_space_tag_t);
 
 /*
  * Nonexistent system call-- signal process (may want to handle it).  Flag
@@ -122,6 +125,9 @@
 __weak_alias(spldebug_start, voidop);
 __weak_alias(spldebug_stop, voidop);
 __weak_alias(machdep_init,nullop);
+__weak_alias(bus_space_tag_create, eopnotsupp);
+__weak_alias(bus_space_tag_destroy, voidop);
+__weak_alias(bus_space_is_equal, default_bus_space_is_equal);
 
 #if !defined(KERN_SA)
 /*
@@ -253,3 +259,9 @@
 
 	return (0);
 }
+
+bool
+default_bus_space_is_equal(bus_space_tag_t t1, bus_space_tag_t t2)
+{
+	return memcmp(&t1, &t2, sizeof(t1)) == 0;
+}

Index: src/sys/sys/bus.h
diff -u src/sys/sys/bus.h:1.2 src/sys/sys/bus.h:1.3
--- src/sys/sys/bus.h:1.2	Mon Apr 28 20:24:10 2008
+++ src/sys/sys/bus.h	Mon Apr 19 18:24:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus.h,v 1.2 2008/04/28 20:24:10 martin Exp $	*/
+/*	$NetBSD: bus.h,v 1.3 2010/04/19 18:24:27 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -31,4 +31,73 @@
 
 #include <machine/bus.h>
 
+struct bus_space_reservation;
+
+typedef struct bus_space_reservation /* {
+	bus_addr_t	sr_addr;
+	bus_size_t	sr_size;
+} */ bus_space_reservation_t;
+
+enum bus_space_override_idx {
+	  BUS_SPACE_OVERRIDE_SPACE_MAP		= __BIT(0)
+	, BUS_SPACE_OVERRIDE_SPACE_UNMAP	= __BIT(1)
+	, BUS_SPACE_OVERRIDE_SPACE_ALLOC	= __BIT(2)
+	, BUS_SPACE_OVERRIDE_SPACE_FREE		= __BIT(3)
+	, BUS_SPACE_OVERRIDE_SPACE_EXTEND	= __BIT(4)
+	, BUS_SPACE_OVERRIDE_SPACE_TRIM		= __BIT(5)
+};
+
+/* Only add new members at the end of this struct! */
+struct bus_space_overrides {
+	int (*bs_space_map)(void *, bus_space_tag_t, bus_addr_t, bus_size_t,
+	    int, bus_space_handle_t *);
+
+	void (*bs_space_unmap)(void *, bus_space_tag_t, bus_space_handle_t,
+	    bus_size_t);
+
+	int (*bs_space_alloc)(void *, bus_space_tag_t, bus_addr_t, bus_addr_t,
+	    bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *,
+	    bus_space_handle_t *);
+
+	void (*bs_space_free)(void *, bus_space_tag_t, bus_space_handle_t,
+	    bus_size_t);
+
+	int (*bs_space_reserve)(void *, bus_space_tag_t, bus_addr_t, bus_size_t,
+	    bus_space_reservation_t *);
+
+	void (*bus_space_release)(void *, bus_space_tag_t,
+	    bus_space_reservation_t);
+
+	int (*bs_space_extend)(void *, bus_space_tag_t, bus_space_reservation_t,
+	    bus_size_t, bus_size_t);
+
+	void (*bs_space_trim)(void *, bus_space_tag_t, bus_space_reservation_t,
+	    bus_size_t, bus_size_t);
+};
+
+bool	bus_space_is_equal(bus_space_tag_t, bus_space_tag_t);
+int	bus_space_tag_create(bus_space_tag_t, uint64_t,
+	                     const struct bus_space_overrides *, void *,
+	                     bus_space_tag_t *);
+void	bus_space_tag_destroy(bus_space_tag_t);
+
+/* Reserve a region of bus space.  Reserved bus space cannot be allocated
+ * with bus_space_alloc().  Reserved space has not been bus_space_map()'d.
+ */
+int	bus_space_reserve(bus_space_tag_t, bus_addr_t, bus_size_t,
+	                  bus_space_reservation_t *);
+
+/* Cancel a reservation. */
+void	bus_space_release(bus_space_tag_t, bus_space_reservation_t);
+
+/* Extend a reservation to the left and/or to the right.  The extension
+ * has not been bus_space_map()'d.
+ */
+int	bus_space_extend(bus_space_tag_t, bus_space_reservation_t, bus_size_t,
+	                 bus_size_t);
+
+/* Trim bus space from a reservation on the left and/or on the right. */
+void	bus_space_trim(bus_space_tag_t, bus_space_reservation_t, bus_size_t,
+	               bus_size_t);
+
 #endif	/* _SYS_BUS_H_ */

Reply via email to