summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authormatt <matt@NetBSD.org>2003-03-18 16:40:18 +0000
committermatt <matt@NetBSD.org>2003-03-18 16:40:18 +0000
commit8a5a3a480afa607d9e58e4e9db7511cb175f47f8 (patch)
treeff2efb8f6c9c989c438d4ceca3b1ee7f9b28f3c6 /sys
parent923175a28acd58f42d8673718459372456205e10 (diff)
Switch/adapt to new bus space infrastructure.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/bebox/bebox/bus_space.c206
-rw-r--r--sys/arch/bebox/bebox/locore.S7
-rw-r--r--sys/arch/bebox/bebox/machdep.c63
-rw-r--r--sys/arch/bebox/conf/files.bebox4
-rw-r--r--sys/arch/bebox/include/bus.h4
-rw-r--r--sys/arch/mvmeppc/conf/files.mvmeppc6
-rw-r--r--sys/arch/mvmeppc/include/bus.h15
-rw-r--r--sys/arch/mvmeppc/mvmeppc/bus_space.c373
-rw-r--r--sys/arch/mvmeppc/mvmeppc/locore.S7
-rw-r--r--sys/arch/mvmeppc/mvmeppc/machdep.c78
-rw-r--r--sys/arch/mvmeppc/pci/pci_machdep.c4
-rw-r--r--sys/arch/powerpc/include/bus.h1036
-rw-r--r--sys/arch/prep/conf/files.prep4
-rw-r--r--sys/arch/prep/include/bus.h4
-rw-r--r--sys/arch/prep/pci/prep_pciconf_direct.c4
-rw-r--r--sys/arch/prep/prep/bus_space.c206
-rw-r--r--sys/arch/prep/prep/locore.S15
-rw-r--r--sys/arch/prep/prep/machdep.c65
-rw-r--r--sys/arch/sandpoint/conf/files.sandpoint4
-rw-r--r--sys/arch/sandpoint/include/bus.h5
-rw-r--r--sys/arch/sandpoint/sandpoint/bus_space.c204
-rw-r--r--sys/arch/sandpoint/sandpoint/locore.S7
-rw-r--r--sys/arch/sandpoint/sandpoint/machdep.c64
23 files changed, 627 insertions, 1758 deletions
diff --git a/sys/arch/bebox/bebox/bus_space.c b/sys/arch/bebox/bebox/bus_space.c
deleted file mode 100644
index 97c4fbfd0f6..00000000000
--- a/sys/arch/bebox/bebox/bus_space.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/* $NetBSD: bus_space.c,v 1.4 2003/03/06 05:25:18 matt Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
- * Simulation Facility, NASA Ames Research Center.
- *
- * 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/extent.h>
-#include <sys/mbuf.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <machine/bus.h>
-
-static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
-static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
- bus_space_handle_t *);
-static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
-static int memio_alloc(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 *);
-static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
-
-struct powerpc_bus_space bebox_io_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
- BEBOX_BUS_SPACE_IO, 0x00000000, 0x3f800000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space bebox_isa_io_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
- BEBOX_BUS_SPACE_IO, 0x00000000, 0x00010000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space bebox_mem_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
- BEBOX_BUS_SPACE_MEM, 0x00000000, 0x3f000000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space bebox_isa_mem_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
- BEBOX_BUS_SPACE_MEM, 0x00000000, 0x01000000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-
-static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
- __attribute__((aligned(8)));
-
-static int extent_flags;
-
-void
-bebox_bus_space_init(void)
-{
- int error;
-
- bebox_io_bs_tag.pbs_extent = extent_create("ioport",
- bebox_io_bs_tag.pbs_base, bebox_io_bs_tag.pbs_limit - 1,
- M_DEVBUF,
- ex_storage[0], sizeof(ex_storage[0]),
- EX_NOCOALESCE|EX_NOWAIT);
- error = extent_alloc_region(bebox_io_bs_tag.pbs_extent,
- 0x10000, 0x7F0000, EX_NOWAIT);
- if (error)
- panic("bebox_bus_space_init: can't block out reserved "
- " I/O space 0x10000-0x7fffff: error=%d", error);
- bebox_mem_bs_tag.pbs_extent = extent_create("iomem",
- bebox_io_bs_tag.pbs_base, bebox_io_bs_tag.pbs_limit - 1,
- M_DEVBUF,
- ex_storage[1], sizeof(ex_storage[1]),
- EX_NOCOALESCE|EX_NOWAIT);
-
- bebox_isa_io_bs_tag.pbs_extent = bebox_io_bs_tag.pbs_extent;
- bebox_isa_mem_bs_tag.pbs_extent = bebox_mem_bs_tag.pbs_extent;
-}
-
-void
-bebox_bus_space_mallocok(void)
-{
- extent_flags = EX_MALLOCOK;
-}
-
-paddr_t
-memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
-{
- return (trunc_page(bpa + offset));
-}
-
-int
-memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
- bus_space_handle_t *bshp)
-{
- int error;
-
- if (bpa + size > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Can't map I/O space as linear.
- */
- if ((flags & BUS_SPACE_MAP_LINEAR) &&
- (t->pbs_flags & _BUS_SPACE_IO_TYPE))
- return (EOPNOTSUPP);
-
- /*
- * Before we go any further, let's make sure that this
- * region is available.
- */
- error = extent_alloc_region(t->pbs_extent, bpa, size,
- EX_NOWAIT | extent_flags);
- if (error)
- return (error);
-
- *bshp = t->pbs_offset + bpa;
-
- return (0);
-}
-
-void
-memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- bus_addr_t bpa = bsh - t->pbs_offset;
-
- if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
- printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
- (t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
- (unsigned long)bpa, (unsigned long)size);
- printf("memio_unmap: can't free region\n");
- }
-}
-
-int
-memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
- bus_size_t size, bus_size_t alignment, bus_size_t boundary,
- int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
-{
- u_long bpa;
- int error;
-
- if (rstart + size > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Can't map I/O space as linear.
- */
- if ((flags & BUS_SPACE_MAP_LINEAR) &&
- (t->pbs_flags & _BUS_SPACE_IO_TYPE))
- return (EOPNOTSUPP);
-
- if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
- panic("memio_alloc: bad region start/end");
-
- error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
- alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
-
- if (error)
- return (error);
-
- *bpap = bpa;
- *bshp = t->pbs_offset + bpa;
-
- return (0);
-}
-
-void
-memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- /* memio_unmap() does all that we need to do. */
- memio_unmap(t, bsh, size);
-}
diff --git a/sys/arch/bebox/bebox/locore.S b/sys/arch/bebox/bebox/locore.S
index c0b2d73f092..b69298d8c4b 100644
--- a/sys/arch/bebox/bebox/locore.S
+++ b/sys/arch/bebox/bebox/locore.S
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.9 2003/02/02 20:43:17 matt Exp $ */
+/* $NetBSD: locore.S,v 1.10 2003/03/18 16:40:18 matt Exp $ */
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
/*
@@ -199,3 +199,8 @@ _C_LABEL(debug_led):
* Pull in common trap vector code.
*/
#include <powerpc/powerpc/trap_subr.S>
+
+/*
+ * Pull in common pio / bus_space code.
+ */
+#include <powerpc/powerpc/pio_subr.S>
diff --git a/sys/arch/bebox/bebox/machdep.c b/sys/arch/bebox/bebox/machdep.c
index 3dbce8dbb3b..1def89146cb 100644
--- a/sys/arch/bebox/bebox/machdep.c
+++ b/sys/arch/bebox/bebox/machdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.77 2003/02/03 17:09:54 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.78 2003/03/18 16:40:18 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -40,6 +40,7 @@
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/exec.h>
+#include <sys/extent.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@@ -117,6 +118,10 @@ char *bootpath;
paddr_t avail_end; /* XXX temporary */
+void bebox_bus_space_init(void);
+void consinit(void);
+void ext_intr(void);
+
extern void *startsym, *endsym;
void
@@ -124,9 +129,6 @@ initppc(startkernel, endkernel, args, btinfo)
u_int startkernel, endkernel, args;
void *btinfo;
{
- extern void consinit __P((void));
- extern void ext_intr __P((void));
-
/*
* copy bootinfo
*/
@@ -254,7 +256,7 @@ cpu_startup()
/*
* Now that we have VM, malloc's are OK in bus_space.
*/
- bebox_bus_space_mallocok();
+ bus_space_mallocok();
/*
* Now allow hardware interrupts.
@@ -439,3 +441,54 @@ lcsplx(ipl)
{
splx(ipl);
}
+
+struct powerpc_bus_space bebox_io_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ BEBOX_BUS_SPACE_IO, 0x00000000, 0x3f800000,
+};
+struct powerpc_bus_space bebox_isa_io_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ BEBOX_BUS_SPACE_IO, 0x00000000, 0x00010000,
+};
+struct powerpc_bus_space bebox_mem_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ BEBOX_BUS_SPACE_MEM, 0x00000000, 0x3f000000,
+};
+struct powerpc_bus_space bebox_isa_mem_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ BEBOX_BUS_SPACE_MEM, 0x00000000, 0x01000000,
+};
+
+static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
+ __attribute__((aligned(8)));
+
+void
+bebox_bus_space_init(void)
+{
+ int error;
+
+ error = bus_space_init(&bebox_io_bs_tag, "ioport",
+ ex_storage[0], sizeof(ex_storage[0]));
+ if (error)
+ panic("bebox_bus_space_init: can't init io tag");
+
+ error = extent_alloc_region(bebox_io_bs_tag.pbs_extent,
+ 0x10000, 0x7F0000, EX_NOWAIT);
+ if (error)
+ panic("bebox_bus_space_init: can't block out reserved I/O"
+ " space 0x10000-0x7fffff: error=%d", error);
+ error = bus_space_init(&bebox_mem_bs_tag, "iomem",
+ ex_storage[1], sizeof(ex_storage[1]));
+ if (error)
+ panic("bebox_bus_space_init: can't init mem tag");
+
+ bebox_isa_io_bs_tag.pbs_extent = bebox_io_bs_tag.pbs_extent;
+ error = bus_space_init(&bebox_isa_io_bs_tag, "isa-ioport", NULL, 0);
+ if (error)
+ panic("bebox_bus_space_init: can't init isa io tag");
+
+ bebox_isa_mem_bs_tag.pbs_extent = bebox_mem_bs_tag.pbs_extent;
+ error = bus_space_init(&bebox_isa_mem_bs_tag, "isa-iomem", NULL, 0);
+ if (error)
+ panic("bebox_bus_space_init: can't init isa mem tag");
+}
diff --git a/sys/arch/bebox/conf/files.bebox b/sys/arch/bebox/conf/files.bebox
index 619ce8573ce..25b0b9f042e 100644
--- a/sys/arch/bebox/conf/files.bebox
+++ b/sys/arch/bebox/conf/files.bebox
@@ -1,4 +1,4 @@
-# $NetBSD: files.bebox,v 1.38 2003/03/05 05:43:52 matt Exp $
+# $NetBSD: files.bebox,v 1.39 2003/03/18 16:40:19 matt Exp $
#
# First try for bebox specific configuration info
#
@@ -7,13 +7,13 @@ maxpartitions 16
maxusers 2 8 64
file arch/bebox/bebox/autoconf.c
-file arch/bebox/bebox/bus_space.c
file arch/bebox/bebox/clock.c
file arch/bebox/bebox/disksubr.c disk
file arch/bebox/bebox/extintr.c
file arch/bebox/bebox/machdep.c
file arch/powerpc/powerpc/bus_dma.c
+file arch/powerpc/powerpc/bus_space.c
file arch/powerpc/powerpc/procfs_machdep.c procfs
# General files
diff --git a/sys/arch/bebox/include/bus.h b/sys/arch/bebox/include/bus.h
index 92746290806..5fdc4f3ace5 100644
--- a/sys/arch/bebox/include/bus.h
+++ b/sys/arch/bebox/include/bus.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.26 2003/03/06 05:25:18 matt Exp $ */
+/* $NetBSD: bus.h,v 1.27 2003/03/18 16:40:19 matt Exp $ */
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
/*-
@@ -121,8 +121,6 @@
#define BUS_MEM_TO_PHYS(t,x) ((x) & ~MPC105_DIRECT_MAPPED_SPACE)
#ifdef _KERNEL
-void bebox_bus_space_init __P((void));
-void bebox_bus_space_mallocok __P((void));
extern struct powerpc_bus_space bebox_io_bs_tag;
extern struct powerpc_bus_space bebox_mem_bs_tag;
extern struct powerpc_bus_space bebox_isa_io_bs_tag;
diff --git a/sys/arch/mvmeppc/conf/files.mvmeppc b/sys/arch/mvmeppc/conf/files.mvmeppc
index 48952ad39e0..9adcafafb32 100644
--- a/sys/arch/mvmeppc/conf/files.mvmeppc
+++ b/sys/arch/mvmeppc/conf/files.mvmeppc
@@ -1,4 +1,4 @@
-# $NetBSD: files.mvmeppc,v 1.6 2003/03/05 05:43:44 matt Exp $
+# $NetBSD: files.mvmeppc,v 1.7 2003/03/18 16:40:20 matt Exp $
#
# Motorola's MVMEPPC boards specific configuration info
#
@@ -12,15 +12,15 @@ defflag opt_mvmetype.h SUPPORT_MVME230X
defflag opt_mvmetype.h SUPPORT_MVME240X
file arch/mvmeppc/mvmeppc/autoconf.c
-file arch/mvmeppc/mvmeppc/bus_space.c
file arch/mvmeppc/mvmeppc/clock.c
file arch/mvmeppc/mvmeppc/disksubr.c disk
file arch/mvmeppc/mvmeppc/extintr.c
file arch/mvmeppc/mvmeppc/machdep.c
file arch/mvmeppc/mvmeppc/platform.c
file arch/mvmeppc/mvmeppc/platform_160x.c support_mvme160x
-file arch/powerpc/powerpc/bus_dma.c
+file arch/powerpc/powerpc/bus_dma.c
+file arch/powerpc/powerpc/bus_space.c
file arch/powerpc/powerpc/procfs_machdep.c procfs
# General files
file dev/cons.c
diff --git a/sys/arch/mvmeppc/include/bus.h b/sys/arch/mvmeppc/include/bus.h
index 79869065367..0ba1e9d52bd 100644
--- a/sys/arch/mvmeppc/include/bus.h
+++ b/sys/arch/mvmeppc/include/bus.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.1 2002/02/27 21:02:14 scw Exp $ */
+/* $NetBSD: bus.h,v 1.2 2003/03/18 16:40:20 matt Exp $ */
/*-
* Copyright (c) 200e The NetBSD Foundation, Inc.
@@ -58,15 +58,14 @@
#define MVMEPPC_BUS_SPACE_MEM 1
#define MVMEPPC_BUS_SPACE_NUM_REGIONS 2
-#define PHYS_TO_PCI_MEM(x) ((x) | 0x80000000)
-#define PCI_MEM_TO_PHYS(x) ((x) & ~0x80000000)
+#define PHYS_TO_BUS_MEM(t,x) ((x) | 0x80000000)
+#define BUS_MEM_TO_PHYS(t,x) ((x) & ~0x80000000)
#ifdef _KERNEL
-extern void mvmeppc_bus_space_init(void);
-extern const struct powerpc_bus_space mvmeppc_isa_io_bs_tag;
-extern const struct powerpc_bus_space mvmeppc_isa_mem_bs_tag;
-extern const struct powerpc_bus_space mvmeppc_pci_io_bs_tag;
-extern const struct powerpc_bus_space mvmeppc_pci_mem_bs_tag;
+extern struct powerpc_bus_space mvmeppc_isa_io_bs_tag;
+extern struct powerpc_bus_space mvmeppc_isa_mem_bs_tag;
+extern struct powerpc_bus_space mvmeppc_pci_io_bs_tag;
+extern struct powerpc_bus_space mvmeppc_pci_mem_bs_tag;
#endif
#endif /* _MVMEPPC_BUS_H_ */
diff --git a/sys/arch/mvmeppc/mvmeppc/bus_space.c b/sys/arch/mvmeppc/mvmeppc/bus_space.c
deleted file mode 100644
index a2879b5478a..00000000000
--- a/sys/arch/mvmeppc/mvmeppc/bus_space.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/* $NetBSD: bus_space.c,v 1.4 2003/03/06 05:25:19 matt Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
- * Simulation Facility, NASA Ames Research Center.
- *
- * 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/extent.h>
-#include <sys/mbuf.h>
-
-#include <machine/bat.h>
-#define _POWERPC_BUS_DMA_PRIVATE
-#include <machine/bus.h>
-#undef _POWERPC_BUS_DMA_PRIVATE
-
-paddr_t mvmeppc_memio_mmap (bus_space_tag_t, bus_addr_t, off_t, int, int);
-int mvmeppc_memio_map (bus_space_tag_t, bus_addr_t, bus_size_t, int,
- bus_space_handle_t *);
-void mvmeppc_memio_unmap (bus_space_tag_t, bus_space_handle_t, bus_size_t);
-int mvmeppc_memio_alloc (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 mvmeppc_memio_free (bus_space_tag_t, bus_space_handle_t, bus_size_t);
-
-
-const struct powerpc_bus_space mvmeppc_isa_io_bs_tag = {
- MVMEPPC_BUS_SPACE_IO,
- MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of ISA I/O Space */
- 0x00000000, /* Corresponds to ISA-bus I/O address 0x0 */
- 0x00010000, /* End of ISA-bus I/O address space, +1 */
- mvmeppc_memio_mmap,
- mvmeppc_memio_map, mvmeppc_memio_unmap,
- mvmeppc_memio_alloc, mvmeppc_memio_free
-};
-
-const struct powerpc_bus_space mvmeppc_pci_io_bs_tag = {
- MVMEPPC_BUS_SPACE_IO,
- MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of PCI I/O Space */
- 0x00000000, /* Corresponds to PCI-bus I/O address 0x0 */
- MVMEPPC_PHYS_SIZE_IO, /* End of PCI-bus I/O address space, +1 */
- mvmeppc_memio_mmap,
- mvmeppc_memio_map, mvmeppc_memio_unmap,
- mvmeppc_memio_alloc, mvmeppc_memio_free
-};
-
-const struct powerpc_bus_space mvmeppc_isa_mem_bs_tag = {
- MVMEPPC_BUS_SPACE_MEM,
- MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of ISA Memory Space */
- 0x00000000, /* Corresponds to ISA-bus Memory addr 0x0 */
- 0x01000000, /* End of ISA-bus Memory addr space, +1 */
- mvmeppc_memio_mmap,
- mvmeppc_memio_map, mvmeppc_memio_unmap,
- mvmeppc_memio_alloc, mvmeppc_memio_free
-};
-
-const struct powerpc_bus_space mvmeppc_pci_mem_bs_tag = {
- MVMEPPC_BUS_SPACE_MEM,
- MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of PCI Memory Space */
- 0x00000000, /* Corresponds to PCI-bus Memory addr 0x0 */
- MVMEPPC_PHYS_SIZE_MEM, /* End of PCI-bus Memory addr space, +1 */
- mvmeppc_memio_mmap,
- mvmeppc_memio_map, mvmeppc_memio_unmap,
- mvmeppc_memio_alloc, mvmeppc_memio_free
-};
-
-/*
- * Evaluates true if `t' is not a valid tag type
- */
-#define BAD_TAG(t) ((t) < 0 || (t) >= MVMEPPC_BUS_SPACE_NUM_REGIONS)
-
-/*
- * Bus Space region accounting
- */
-static struct extent *bus_ex[MVMEPPC_BUS_SPACE_NUM_REGIONS];
-
-/*
- * We maintain BAT mappings for subsets of I/O and Memory space...
- */
-struct mvmeppc_bat_region {
- vaddr_t br_kva;
- bus_addr_t br_len;
-};
-static const struct mvmeppc_bat_region bat_regions[] = {
- {MVMEPPC_KVA_BASE_IO, MVMEPPC_KVA_SIZE_IO},
- {MVMEPPC_KVA_BASE_MEM, MVMEPPC_KVA_SIZE_MEM}
-};
-
-#define page_offset(a) ((a) - trunc_page(a))
-
-
-void
-mvmeppc_bus_space_init(void)
-{
-
- bus_ex[MVMEPPC_BUS_SPACE_IO] = extent_create("bus_io",
- 0, MVMEPPC_PHYS_SIZE_IO,
- M_DEVBUF, NULL, 0, EX_NOCOALESCE | EX_NOWAIT | EX_MALLOCOK);
-
- if (extent_alloc_region(bus_ex[MVMEPPC_BUS_SPACE_IO],
- MVMEPPC_PHYS_RESVD_START_IO, MVMEPPC_PHYS_RESVD_SIZE_IO,
- EX_NOWAIT | EX_MALLOCOK) != 0)
- panic("mvmeppc_bus_space_init: reserving I/O hole");
-
- bus_ex[MVMEPPC_BUS_SPACE_MEM] = extent_create("bus_mem",
- 0, MVMEPPC_PHYS_SIZE_MEM,
- M_DEVBUF, NULL, 0, EX_NOCOALESCE | EX_NOWAIT | EX_MALLOCOK);
-}
-
-paddr_t
-mvmeppc_memio_mmap(t, bpa, offset, prot, flags)
- bus_space_tag_t t;
- bus_addr_t bpa;
- off_t offset;
- int prot, flags;
-{
-
- return (trunc_page(bpa + offset));
-}
-
-int
-mvmeppc_memio_map(t, bpa, size, flags, bshp)
- bus_space_tag_t t;
- bus_addr_t bpa;
- bus_size_t size;
- int flags;
- bus_space_handle_t *bshp;
-{
- const struct mvmeppc_bat_region *br;
- struct extent *ex;
- bus_addr_t kpa;
- vaddr_t va;
- int error, i;
-
-#ifdef DEBUG
- if (BAD_TAG(t->pbs_type))
- panic("mvmeppc_memio_map: bad tag: %d", t->pbs_type);
-#endif
-
- if ((flags & BUS_SPACE_MAP_LINEAR) != 0 &&
- t->pbs_type == MVMEPPC_BUS_SPACE_IO)
- return (EOPNOTSUPP);
-
- br = &bat_regions[t->pbs_type];
- ex = bus_ex[t->pbs_type];
-
- if ((bpa + size) > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Bail if trying to map a region which overlaps the end of
- * a BAT mapping.
- *
- * XXX: Watch out, one day we'll trip over this...
- */
- if (bpa < br->br_len && (bpa + size) > br->br_len)
- return (EINVAL);
-
- if (ex) {
- /*
- * Before we go any further, let's make sure that this
- * region is available.
- */
- if ((error = extent_alloc_region(ex, bpa, size,
- EX_NOWAIT | EX_MALLOCOK)) != 0)
- return (error);
- }
-
- /*
- * Does the requested bus space region fall within the KVA mapping
- * set up for this space by a BAT register?
- */
- if ((bpa + size) < br->br_len) {
- /* We can satisfy this request directly from the BAT mapping */
- *bshp = (bus_space_handle_t)(bpa + (bus_addr_t)br->br_kva);
- return (0);
- }
-
- /*
- * Otherwise, we have to manually fix up a mapping.
- */
- va = uvm_km_valloc(kernel_map, round_page(size));
- if (va == NULL) {
- (void) extent_free(ex, bpa, size, EX_NOWAIT | EX_MALLOCOK);
- return (ENOMEM);
- }
-
- *bshp = (bus_space_handle_t)((caddr_t)va + page_offset(bpa));
- kpa = trunc_page(t->pbs_offset + bpa);
-
- for (i = round_page(size) / NBPG; i > 0; i--, kpa += NBPG, va += NBPG)
- pmap_enter(pmap_kernel(), va, kpa,
- VM_PROT_READ | VM_PROT_WRITE,
- VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
-
- return (0);
-}
-
-void
-mvmeppc_memio_unmap(t, bsh, size)
- bus_space_tag_t t;
- bus_space_handle_t bsh;
- bus_size_t size;
-{
- const struct mvmeppc_bat_region *br;
- struct extent *ex;
- bus_addr_t bpa;
-
-#ifdef DEBUG
- if (BAD_TAG(t->pbs_type))
- panic("mvmeppc_memio_unmap: bad tag: %d", t->pbs_type);
-#endif
-
- br = &bat_regions[t->pbs_type];
- ex = bus_ex[t->pbs_type];
-
- /*
- * Was the mapping within the BAT region of this space?
- */
- if (bsh < br->br_kva || bsh >= (br->br_kva + br->br_len)) {
- /*
- * Nope. We have to figure out the physical address
- * and unmap it for real.
- */
- if (!pmap_extract(pmap_kernel(), (vaddr_t)bsh, (void *)&bpa))
- panic("mvmeppc_memio_unmap: bad bus handle: 0x%x", bsh);
- uvm_km_free(kernel_map, (vaddr_t)trunc_page(bsh),
- round_page(size));
- bpa -= t->pbs_offset;
- } else
- bpa = (bus_addr_t) bsh - (bus_addr_t) br->br_kva;
-
- if (ex && extent_free(ex, bpa, size, EX_NOWAIT | EX_MALLOCOK)) {
- printf("mvmeppc_memio_unmap: %s 0x%lx, size 0x%lx\n",
- (t->pbs_type == MVMEPPC_BUS_SPACE_IO) ? "port" : "mem",
- (u_long)bpa, (u_long)size);
- printf("mvmeppc_memio_unmap: can't free region\n");
- }
-}
-
-int
-mvmeppc_memio_alloc(t, rstart, rend, size, alignment, boundary, flags,
- bpap, bshp)
- bus_space_tag_t t;
- bus_addr_t rstart, rend;
- bus_size_t size, alignment, boundary;
- int flags;
- bus_addr_t *bpap;
- bus_space_handle_t *bshp;
-{
- const struct mvmeppc_bat_region *br;
- struct extent *ex;
- bus_dma_segment_t seg;
- caddr_t va;
- u_long bpa;
- int error;
-
-#ifdef DEBUG
- if (BAD_TAG(t->pbs_type))
- panic("mvmeppc_memio_alloc: bad tag: %d", t->pbs_type);
-#endif
-
- if ((flags & BUS_SPACE_MAP_LINEAR) != 0 &&
- t->pbs_type == MVMEPPC_BUS_SPACE_IO)
- return (EOPNOTSUPP);
-
- br = &bat_regions[t->pbs_type];
- ex = bus_ex[t->pbs_type];
-
- if ((rstart + size) > t->pbs_limit)
- return (EINVAL);
-
- if (rstart < ex->ex_start || rend > ex->ex_end)
- panic("mvmeppc_memio_alloc: bad region start/end");
-
- if (ex) {
- error = extent_alloc_subregion(ex, rstart, rend, size,
- alignment, boundary, EX_FAST | EX_NOWAIT | EX_MALLOCOK,
- &bpa);
- if (error)
- return (error);
- }
-
- /*
- * Bail if trying to map a region which overlaps the end of
- * a BAT mapping.
- *
- * XXX: Watch out, one day we'll trip over this...
- */
- if (bpa < br->br_len && (bpa + size) > br->br_len) {
- if (ex) {
- (void) extent_free(ex, bpa, size,
- EX_NOWAIT | EX_MALLOCOK);
- }
- return (EINVAL);
- }
-
- /*
- * Does the requested bus space region fall within the KVA mapping
- * set up for this space by a BAT register?
- */
- if ((bpa + size) < br->br_len) {
- /* We can satisfy this request directly from the BAT mapping */
- *bpap = bpa;
- *bshp = (bus_space_handle_t)(bpa + (bus_addr_t)br->br_kva);
- return (0);
- }
-
- /*
- * Otherwise, we have to manually fix up a mapping.
- */
- seg.ds_addr = trunc_page(t->pbs_base + bpa);
- seg.ds_len = round_page(size);
-
- if (_bus_dmamem_map(NULL, &seg, 1, seg.ds_len, &va,
- flags | BUS_DMA_COHERENT)) {
- if (ex) {
- (void) extent_free(ex, bpa, size,
- EX_NOWAIT | EX_MALLOCOK);
- }
- return (ENOMEM);
- }
-
- *bpap = bpa;
- *bshp = (bus_space_handle_t)(va + page_offset(bpa));
-
- return (0);
-}
-
-void
-mvmeppc_memio_free(t, bsh, size)
- bus_space_tag_t t;
- bus_space_handle_t bsh;
- bus_size_t size;
-{
-
- /* mvmeppc_memio_unmap() does all that we need to do. */
- mvmeppc_memio_unmap(t, bsh, size);
-}
diff --git a/sys/arch/mvmeppc/mvmeppc/locore.S b/sys/arch/mvmeppc/mvmeppc/locore.S
index 748ab5c494c..622adb367a2 100644
--- a/sys/arch/mvmeppc/mvmeppc/locore.S
+++ b/sys/arch/mvmeppc/mvmeppc/locore.S
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.2 2003/02/02 20:43:20 matt Exp $ */
+/* $NetBSD: locore.S,v 1.3 2003/03/18 16:40:21 matt Exp $ */
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
/*
@@ -202,3 +202,8 @@ _C_LABEL(disable_intr):
* Pull in common trap vector code.
*/
#include <powerpc/powerpc/trap_subr.S>
+
+/*
+ * Pull in common pio / bus_space code.
+ */
+#include <powerpc/powerpc/pio_subr.S>
diff --git a/sys/arch/mvmeppc/mvmeppc/machdep.c b/sys/arch/mvmeppc/mvmeppc/machdep.c
index c83d9b603b8..d6f65206029 100644
--- a/sys/arch/mvmeppc/mvmeppc/machdep.c
+++ b/sys/arch/mvmeppc/mvmeppc/machdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.9 2003/02/03 17:09:58 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.10 2003/03/18 16:40:21 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -40,6 +40,7 @@
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/exec.h>
+#include <sys/extent.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@@ -104,6 +105,7 @@ void comsoft(void);
void initppc(u_long, u_long, void *);
void strayintr(int);
int lcsplx(int);
+void mvmeppc_bus_space_init(void);
/*
@@ -178,14 +180,18 @@ initppc(startkernel, endkernel, btinfo)
*/
oea_init(platform->ext_intr);
+ /*
+ * Init bus_space so consinit can work.
+ */
+ mvmeppc_bus_space_init();
+
#ifdef DEBUG
/*
- * i386 port says, that this shouldn't be here,
- * but I really think the console should be initialized
- * as early as possible.
+ * The console should be initialized as early as possible.
*/
consinit();
#endif
+
/*
* Set the page size.
*/
@@ -245,7 +251,7 @@ cpu_startup()
: "=r"(msr) : "K"(PSL_EE));
}
- mvmeppc_bus_space_init();
+ bus_space_mallocok();
}
/*
@@ -299,7 +305,7 @@ dokbd:
#if (NCOM > 0)
if (!strcmp(bootinfo.bi_consoledev, "PC16550")) {
bus_space_tag_t tag = &mvmeppc_isa_io_bs_tag;
- bus_addr_t caddr[2] = {0x3f8, 0x2f8};
+ static const bus_addr_t caddr[2] = {0x3f8, 0x2f8};
int rv;
rv = comcnattach(tag, caddr[bootinfo.bi_consolechan],
bootinfo.bi_consolespeed, COM_FREQ,
@@ -398,12 +404,68 @@ lcsplx(ipl)
{
int oldcpl;
- __asm__ volatile("sync; eieio\n"); /* reorder protect */
+ __asm __volatile("sync; eieio\n"); /* reorder protect */
oldcpl = cpl;
cpl = ipl;
if (ipending & ~ipl)
do_pending_int();
- __asm__ volatile("sync; eieio\n"); /* reorder protect */
+ __asm __volatile("sync; eieio\n"); /* reorder protect */
return (oldcpl);
}
+
+
+struct powerpc_bus_space mvmeppc_isa_io_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of ISA I/O Space */
+ 0x00000000, /* Corresponds to ISA-bus I/O address 0x0 */
+ 0x00010000, /* End of ISA-bus I/O address space, +1 */
+};
+
+struct powerpc_bus_space mvmeppc_pci_io_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of PCI I/O Space */
+ 0x00000000, /* Corresponds to PCI-bus I/O address 0x0 */
+ MVMEPPC_PHYS_SIZE_IO, /* End of PCI-bus I/O address space, +1 */
+};
+
+struct powerpc_bus_space mvmeppc_isa_mem_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of ISA Memory Space */
+ 0x00000000, /* Corresponds to ISA-bus Memory addr 0x0 */
+ 0x01000000, /* End of ISA-bus Memory addr space, +1 */
+};
+
+struct powerpc_bus_space mvmeppc_pci_mem_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of PCI Memory Space */
+ 0x00000000, /* Corresponds to PCI-bus Memory addr 0x0 */
+ MVMEPPC_PHYS_SIZE_MEM, /* End of PCI-bus Memory addr space, +1 */
+};
+static char ex_storage[MVMEPPC_BUS_SPACE_NUM_REGIONS][EXTENT_FIXED_STORAGE_SIZE(8)]
+ __attribute__((aligned(8)));
+
+
+void
+mvmeppc_bus_space_init(void)
+{
+
+ int error;
+
+ error = bus_space_init(&mvmeppc_pci_io_bs_tag, "bus_io",
+ ex_storage[MVMEPPC_BUS_SPACE_IO],
+ sizeof(ex_storage[MVMEPPC_BUS_SPACE_IO]));
+
+ if (extent_alloc_region(mvmeppc_pci_io_bs_tag.pbs_extent,
+ MVMEPPC_PHYS_RESVD_START_IO, MVMEPPC_PHYS_RESVD_SIZE_IO,
+ EX_NOWAIT) != 0)
+ panic("mvmeppc_bus_space_init: reserving I/O hole");
+
+ mvmeppc_isa_io_bs_tag.pbs_extent = mvmeppc_pci_io_bs_tag.pbs_extent;
+
+ error = bus_space_init(&mvmeppc_pci_mem_bs_tag, "bus_mem",
+ ex_storage[MVMEPPC_BUS_SPACE_MEM],
+ sizeof(ex_storage[MVMEPPC_BUS_SPACE_MEM]));
+
+ mvmeppc_isa_mem_bs_tag.pbs_extent = mvmeppc_pci_mem_bs_tag.pbs_extent;
+}
diff --git a/sys/arch/mvmeppc/pci/pci_machdep.c b/sys/arch/mvmeppc/pci/pci_machdep.c
index b96d4799721..63cf4ea6385 100644
--- a/sys/arch/mvmeppc/pci/pci_machdep.c
+++ b/sys/arch/mvmeppc/pci/pci_machdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.2 2002/09/27 15:36:27 provos Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.3 2003/03/18 16:40:21 matt Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -52,6 +52,8 @@
#include <machine/intr.h>
#include <machine/platform.h>
+#include <powerpc/pio.h>
+
#include <dev/isa/isavar.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
diff --git a/sys/arch/powerpc/include/bus.h b/sys/arch/powerpc/include/bus.h
index c444c419058..1162279c155 100644
--- a/sys/arch/powerpc/include/bus.h
+++ b/sys/arch/powerpc/include/bus.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.7 2003/03/06 00:20:39 matt Exp $ */
+/* $NetBSD: bus.h,v 1.8 2003/03/18 16:40:22 matt Exp $ */
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
/*-
@@ -104,8 +104,6 @@
#ifndef _POWERPC_BUS_H_
#define _POWERPC_BUS_H_
-#include <powerpc/pio.h>
-
/*
* Bus access types.
*/
@@ -116,27 +114,107 @@ typedef const struct powerpc_bus_space *bus_space_tag_t;
struct extent;
+struct powerpc_bus_space_scalar {
+ u_int8_t (*pbss_read_1)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+ u_int16_t (*pbss_read_2)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+ u_int32_t (*pbss_read_4)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+ u_int64_t (*pbss_read_8)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t);
+
+ void (*pbss_write_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int8_t);
+ void (*pbss_write_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int16_t);
+ void (*pbss_write_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int32_t);
+ void (*pbss_write_8)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ u_int64_t);
+};
+
+struct powerpc_bus_space_group {
+ void (*pbsg_read_1)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t *, size_t);
+ void (*pbsg_read_2)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t *, size_t);
+ void (*pbsg_read_4)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t *, size_t);
+ void (*pbsg_read_8)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int64_t *, size_t);
+
+ void (*pbsg_write_1)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, size_t);
+ void (*pbsg_write_2)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int16_t *, size_t);
+ void (*pbsg_write_4)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int32_t *, size_t);
+ void (*pbsg_write_8)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, const u_int64_t *, size_t);
+};
+
+struct powerpc_bus_space_set {
+ void (*pbss_set_1)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int8_t, size_t);
+ void (*pbss_set_2)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int16_t, size_t);
+ void (*pbss_set_4)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int32_t, size_t);
+ void (*pbss_set_8)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, u_int64_t, size_t);
+};
+
+struct powerpc_bus_space_copy {
+ void (*pbsc_copy_1)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t, bus_size_t, size_t);
+ void (*pbsc_copy_2)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t, bus_size_t, size_t);
+ void (*pbsc_copy_4)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t, bus_size_t, size_t);
+ void (*pbsc_copy_8)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_space_handle_t, bus_size_t, size_t);
+};
+
struct powerpc_bus_space {
int pbs_flags;
-#define _BUS_SPACE_BIG_ENDIAN 0x00000001
+#define _BUS_SPACE_BIG_ENDIAN 0x00000100
#define _BUS_SPACE_LITTLE_ENDIAN 0x00000000
-#define _BUS_SPACE_IO_TYPE 0x00000002
+#define _BUS_SPACE_IO_TYPE 0x00000200
#define _BUS_SPACE_MEM_TYPE 0x00000000
+#define _BUS_SPACE_STRIDE_MASK 0x0000001f
bus_addr_t pbs_offset; /* offset to real start */
bus_addr_t pbs_base; /* extent base */
bus_addr_t pbs_limit; /* extent limit */
struct extent *pbs_extent;
- paddr_t (*pbs_mmap) __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
- int (*pbs_map) __P((bus_space_tag_t, bus_addr_t, bus_size_t, int,
- bus_space_handle_t *));
- void (*pbs_unmap) __P((bus_space_tag_t, bus_space_handle_t,
- bus_size_t));
- int (*pbs_alloc) __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
- bus_size_t, bus_size_t align, bus_size_t, int, bus_addr_t *,
- bus_space_handle_t *));
- void (*pbs_free) __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
+
+ paddr_t (*pbs_mmap)(bus_space_tag_t, bus_addr_t, off_t, int, int);
+ int (*pbs_map)(bus_space_tag_t, bus_addr_t, bus_size_t, int,
+ bus_space_handle_t *);
+ void (*pbs_unmap)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
+ int (*pbs_alloc)(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
+ bus_size_t align, bus_size_t, int, bus_addr_t *,
+ bus_space_handle_t *);
+ void (*pbs_free)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
+ int (*pbs_subregion)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
+ bus_size_t, bus_space_handle_t *);
+
+ struct powerpc_bus_space_scalar pbs_scalar;
+ struct powerpc_bus_space_scalar pbs_scalar_stream;
+ const struct powerpc_bus_space_group *pbs_multi;
+ const struct powerpc_bus_space_group *pbs_multi_stream;
+ const struct powerpc_bus_space_group *pbs_region;
+ const struct powerpc_bus_space_group *pbs_region_stream;
+ const struct powerpc_bus_space_set *pbs_set;
+ const struct powerpc_bus_space_set *pbs_set_stream;
+ const struct powerpc_bus_space_copy *pbs_copy;
};
+#define _BUS_SPACE_STRIDE(t, o) \
+ ((o) << ((t)->pbs_flags & _BUS_SPACE_STRIDE_MASK))
+#define _BUS_SPACE_UNSTRIDE(t, o) \
+ ((o) >> ((t)->pbs_flags & _BUS_SPACE_STRIDE_MASK))
+
#define BUS_SPACE_MAP_CACHEABLE 0x01
#define BUS_SPACE_MAP_LINEAR 0x02
#define BUS_SPACE_MAP_PREFETCHABLE 0x04
@@ -149,6 +227,9 @@ struct powerpc_bus_space {
#define CAT3(a,b,c) a/**/b/**/c
#endif
+int bus_space_init(struct powerpc_bus_space *, const char *, caddr_t, size_t);
+void bus_space_mallocok(void);
+
/*
* Access methods for bus resources
*/
@@ -156,7 +237,7 @@ struct powerpc_bus_space {
#define __BUS_SPACE_HAS_STREAM_METHODS
/*
- * void *bus_space_vaddr __P((bus_space_tag_t, bus_space_handle_t));
+ * void *bus_space_vaddr (bus_space_tag_t, bus_space_handle_t);
*
* Get the kernel virtual address for the mapped bus space.
* Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
@@ -165,8 +246,8 @@ struct powerpc_bus_space {
#define bus_space_vaddr(t, h) ((void *)(h))
/*
- * paddr_t bus_space_mmap __P((bus_space_tag_t t, bus_addr_t addr,
- * off_t offset, int prot, int flags));
+ * paddr_t bus_space_mmap (bus_space_tag_t t, bus_addr_t addr,
+ * off_t offset, int prot, int flags);
*
* Mmap a region of bus space.
*/
@@ -175,8 +256,8 @@ struct powerpc_bus_space {
((*(t)->pbs_mmap)((t), (b), (o), (p), (f)))
/*
- * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
- * bus_size_t size, int flags, bus_space_handle_t *bshp));
+ * int bus_space_map (bus_space_tag_t t, bus_addr_t addr,
+ * bus_size_t size, int flags, bus_space_handle_t *bshp);
*
* Map a region of bus space.
*/
@@ -185,8 +266,8 @@ struct powerpc_bus_space {
((*(t)->pbs_map)((t), (a), (s), (f), (hp)))
/*
- * int bus_space_unmap __P((bus_space_tag_t t,
- * bus_space_handle_t bsh, bus_size_t size));
+ * int bus_space_unmap (bus_space_tag_t t,
+ * bus_space_handle_t bsh, bus_size_t size);
*
* Unmap a region of bus space.
*/
@@ -195,21 +276,21 @@ struct powerpc_bus_space {
((void)(*(t)->pbs_unmap)((t), (h), (s)))
/*
- * int bus_space_subregion __P((bus_space_tag_t t,
+ * int bus_space_subregion (bus_space_tag_t t,
* bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
- * bus_space_handle_t *nbshp));
+ * bus_space_handle_t *nbshp);
*
* Get a new handle for a subregion of an already-mapped area of bus space.
*/
#define bus_space_subregion(t, h, o, s, hp) \
- ((*(hp) = (h) + (o)), 0)
+ ((*(t)->pbs_subregion)((t), (h), (o), (s), (hp)))
/*
- * int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
+ * int bus_space_alloc (bus_space_tag_t t, bus_addr_t rstart,
* bus_addr_t rend, bus_size_t size, bus_size_t align,
* bus_size_t boundary, int flags, bus_addr_t *bpap,
- * bus_space_handle_t *bshp));
+ * bus_space_handle_t *bshp);
*
* Allocate a region of bus space.
*/
@@ -218,8 +299,8 @@ struct powerpc_bus_space {
((*(t)->pbs_alloc)((t), (rs), (re), (s), (a), (b), (f), (ap), (hp)))
/*
- * int bus_space_free __P((bus_space_tag_t t,
- * bus_space_handle_t bsh, bus_size_t size));
+ * int bus_space_free (bus_space_tag_t t,
+ * bus_space_handle_t bsh, bus_size_t size);
*
* Free a region of bus space.
*/
@@ -228,765 +309,301 @@ struct powerpc_bus_space {
((void)(*(t)->pbs_free)((t), (h), (s)))
/*
- * u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
- * bus_space_handle_t bsh, bus_size_t offset));
+ * u_intN_t bus_space_read_N (bus_space_tag_t tag,
+ * bus_space_handle_t bsh, bus_size_t offset);
*
* Read a 1, 2, 4, or 8 byte quantity from bus space
* described by tag/handle/offset.
*/
-#define bus_space_read(n,m) \
-static __inline CAT3(u_int,m,_t) \
-CAT(bus_space_read_,n)(bus_space_tag_t tag, bus_space_handle_t bsh, \
- bus_size_t offset) \
-{ \
- if ((tag)->pbs_flags & _BUS_SPACE_BIG_ENDIAN) \
- return CAT(in,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset))); \
- return CAT3(in,m,rb)((volatile CAT3(u_int,m,_t) *)(bsh + (offset))); \
-}
-
-bus_space_read(1,8)
-bus_space_read(2,16)
-bus_space_read(4,32)
-#define bus_space_read_8 !!! bus_space_read_8 unimplemented !!!
+#define bus_space_read_1(t, h, o) \
+ ((*(t)->pbs_scalar.pbss_read_1)((t), (h), (o)))
+#define bus_space_read_2(t, h, o) \
+ ((*(t)->pbs_scalar.pbss_read_2)((t), (h), (o)))
+#define bus_space_read_4(t, h, o) \
+ ((*(t)->pbs_scalar.pbss_read_4)((t), (h), (o)))
+#define bus_space_read_8(t, h, o) \
+ ((*(t)->pbs_scalar.pbss_read_8)((t), (h), (o)))
/*
- * u_intN_t bus_space_read_stream_N __P((bus_space_tag_t tag,
- * bus_space_handle_t bsh, bus_size_t offset));
+ * u_intN_t bus_space_read_stream_N (bus_space_tag_t tag,
+ * bus_space_handle_t bsh, bus_size_t offset);
*
- * Read a 2, 4, or 8 byte stream quantity from bus space
- * described by tag/handle/offset.
+ * Read a 2, 4, or 8 byte quantity from bus space
+ * described by tag/handle/offset ignoring endianness.
*/
-#define bus_space_read_stream(n,m) \
-static __inline CAT3(u_int,m,_t) \
-CAT(bus_space_read_stream_,n)(bus_space_tag_t tag, bus_space_handle_t bsh, \
- bus_size_t offset) \
-{ \
- return CAT(in,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset))); \
-}
-
-bus_space_read_stream(2,16)
-bus_space_read_stream(4,32)
-#define bus_space_read_stream_8 !!! bus_space_read_stream_8 unimplemented !!!
+#define bus_space_read_stream_2(t, h, o) \
+ ((*(t)->pbs_scalar_stream.pbss_read_2)((t), (h), (o)))
+#define bus_space_read_stream_4(t, h, o) \
+ ((*(t)->pbs_scalar_stream.pbss_read_4)((t), (h), (o)))
+#define bus_space_read_stream_8(t, h, o) \
+ ((*(t)->pbs_scalar_stream.pbss_read_8)((t), (h), (o)))
/*
- * void bus_space_read_multi_N __P((bus_space_tag_t tag,
+ * void bus_space_read_multi_N _P((bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * u_intN_t *addr, size_t count));
+ * u_intN_t *addr, size_t count);
*
* Read `count' 1, 2, 4, or 8 byte quantities from bus space
* described by tag/handle/offset and copy into buffer provided.
*/
-#define bus_space_read_multi(n,m) \
-static __inline void \
-CAT(bus_space_read_multi_,n)(bus_space_tag_t tag, bus_space_handle_t bsh, \
- bus_size_t offset, CAT3(u_int,m,_t) *addr, size_t count) \
-{ \
- if ((tag)->pbs_flags & _BUS_SPACE_BIG_ENDIAN) \
- CAT(ins,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), \
- (CAT3(u_int,m,_t) *)addr, (size_t)count); \
- else \
- CAT3(ins,m,rb)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), \
- (CAT3(u_int,m,_t) *)addr, (size_t)count); \
-}
-
-bus_space_read_multi(1,8)
-bus_space_read_multi(2,16)
-bus_space_read_multi(4,32)
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 not implemented !!!
+#define bus_space_read_multi_1(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_read_1)((t), (h), (o), (a), (c)))
+#define bus_space_read_multi_2(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_read_2)((t), (h), (o), (a), (c)))
+#define bus_space_read_multi_4(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_read_4)((t), (h), (o), (a), (c)))
+#define bus_space_read_multi_8(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_read_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_read_multi_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_read_multi_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * u_intN_t *addr, size_t count));
+ * u_intN_t *addr, size_t count);
*
* Read `count' 2, 4, or 8 byte stream quantities from bus space
* described by tag/handle/offset and copy into buffer provided.
*/
-#define bus_space_read_multi_stream(n,m) \
-static __inline void \
-CAT(bus_space_read_multi_stream_,n)(bus_space_tag_t tag, \
- bus_space_handle_t bsh, \
- bus_size_t offset, CAT3(u_int,m,_t) *addr, size_t count) \
-{ \
- CAT(ins,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), \
- (CAT3(u_int,m,_t) *)addr, (size_t)count); \
-}
-
-bus_space_read_multi_stream(2,16)
-bus_space_read_multi_stream(4,32)
-#define bus_space_read_multi_stream_8 \
- !!! bus_space_read_multi_stream_8 not implemented !!!
+#define bus_space_read_multi_stream_2(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_read_2)((t), (h), (o), (a), (c)))
+#define bus_space_read_multi_stream_4(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_read_4)((t), (h), (o), (a), (c)))
+#define bus_space_read_multi_stream_8(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_read_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_write_N __P((bus_space_tag_t tag,
+ * void bus_space_write_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * u_intN_t value));
+ * u_intN_t value);
*
* Write the 1, 2, 4, or 8 byte value `value' to bus space
* described by tag/handle/offset.
*/
-#define bus_space_write(n,m) \
-static __inline void \
-CAT(bus_space_write_,n)(bus_space_tag_t tag, bus_space_handle_t bsh, \
- bus_size_t offset, CAT3(u_int,m,_t) x) \
-{ \
- if ((tag)->pbs_flags & _BUS_SPACE_BIG_ENDIAN) \
- CAT(out,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), x); \
- else \
- CAT3(out,m,rb)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), x);\
-}
-
-bus_space_write(1,8)
-bus_space_write(2,16)
-bus_space_write(4,32)
-#define bus_space_write_8 !!! bus_space_write_8 unimplemented !!!
+#define bus_space_write_1(t, h, o, v) \
+ ((*(t)->pbs_scalar.pbss_write_1)((t), (h), (o), (v)))
+#define bus_space_write_2(t, h, o, v) \
+ ((*(t)->pbs_scalar.pbss_write_2)((t), (h), (o), (v)))
+#define bus_space_write_4(t, h, o, v) \
+ ((*(t)->pbs_scalar.pbss_write_4)((t), (h), (o), (v)))
+#define bus_space_write_8(t, h, o, v) \
+ ((*(t)->pbs_scalar.pbss_write_8)((t), (h), (o), (v)))
/*
- * void bus_space_write_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_write_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * u_intN_t value));
+ * u_intN_t value);
*
* Write the 2, 4, or 8 byte stream value `value' to bus space
* described by tag/handle/offset.
*/
-#define bus_space_write_stream(n,m) \
-static __inline void \
-CAT(bus_space_write_stream_,n)(bus_space_tag_t tag, bus_space_handle_t bsh, \
- bus_size_t offset, CAT3(u_int,m,_t) x) \
-{ \
- CAT(out,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), x); \
-}
-
-bus_space_write_stream(2,16)
-bus_space_write_stream(4,32)
-#define bus_space_write_stream_8 !!! bus_space_write_stream_8 unimplemented !!!
+#define bus_space_write_stream_1(t, h, o, v) \
+ ((*(t)->pbs_scalar_stream.pbss_write_1)((t), (h), (o), (v)))
+#define bus_space_write_stream_2(t, h, o, v) \
+ ((*(t)->pbs_scalar_stream.pbss_write_2)((t), (h), (o), (v)))
+#define bus_space_write_stream_4(t, h, o, v) \
+ ((*(t)->pbs_scalar_stream.pbss_write_4)((t), (h), (o), (v)))
+#define bus_space_write_stream_8(t, h, o, v) \
+ ((*(t)->pbs_scalar_stream.pbss_write_8)((t), (h), (o), (v)))
/*
- * void bus_space_write_multi_N __P((bus_space_tag_t tag,
+ * void bus_space_write_multi_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * const u_intN_t *addr, size_t count));
+ * const u_intN_t *addr, size_t count);
*
* Write `count' 1, 2, 4, or 8 byte quantities from the buffer
* provided to bus space described by tag/handle/offset.
*/
-#define bus_space_write_multi(n,m) \
-static __inline void \
-CAT(bus_space_write_multi_,n)(bus_space_tag_t tag, bus_space_handle_t bsh, \
- bus_size_t offset, const CAT3(u_int,m,_t) *addr, size_t count) \
-{ \
- if ((tag)->pbs_flags & _BUS_SPACE_BIG_ENDIAN) \
- CAT(outs,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), \
- (CAT3(u_int,m,_t) *)addr, (size_t)count); \
- else \
- CAT3(outs,m,rb)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)),\
- (CAT3(u_int,m,_t) *)addr, (size_t)count); \
-}
-
-bus_space_write_multi(1,8)
-bus_space_write_multi(2,16)
-bus_space_write_multi(4,32)
-#define bus_space_write_multi_8 !!! bus_space_write_multi_8 not implemented !!!
+#define bus_space_write_multi_1(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_write_1)((t), (h), (o), (a), (c)))
+#define bus_space_write_multi_2(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_write_2)((t), (h), (o), (a), (c)))
+#define bus_space_write_multi_4(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_write_4)((t), (h), (o), (a), (c)))
+#define bus_space_write_multi_8(t, h, o, a, c) \
+ ((*(t)->pbs_multi->pbsg_write_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_write_multi_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_write_multi_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * const u_intN_t *addr, size_t count));
+ * const u_intN_t *addr, size_t count);
*
* Write `count' 2, 4, or 8 byte stream quantities from the buffer
* provided to bus space described by tag/handle/offset.
*/
-#define bus_space_write_multi_stream(n,m) \
-static __inline void \
-CAT(bus_space_write_multi_stream_,n)(bus_space_tag_t tag, \
- bus_space_handle_t bsh, \
- bus_size_t offset, const CAT3(u_int,m,_t) *addr, size_t count) \
-{ \
- CAT(outs,m)((volatile CAT3(u_int,m,_t) *)(bsh + (offset)), \
- (CAT3(u_int,m,_t) *)addr, (size_t)count); \
-}
-
-bus_space_write_multi_stream(2,16)
-bus_space_write_multi_stream(4,32)
-#define bus_space_write_multi_stream_8 \
- !!! bus_space_write_multi_stream_8 not implemented !!!
+#define bus_space_write_multi_stream_1(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_write_1)((t), (h), (o), (a), (c)))
+#define bus_space_write_multi_stream_2(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_write_2)((t), (h), (o), (a), (c)))
+#define bus_space_write_multi_stream_4(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_write_4)((t), (h), (o), (a), (c)))
+#define bus_space_write_multi_stream_8(t, h, o, a, c) \
+ ((*(t)->pbs_multi_stream->pbsg_write_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_read_region_N __P((bus_space_tag_t tag,
+ * void bus_space_read_region_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * u_intN_t *addr, size_t count));
+ * u_intN_t *addr, size_t count);
*
* Read `count' 1, 2, 4, or 8 byte quantities from bus space
* described by tag/handle and starting at `offset' and copy into
* buffer provided.
*/
-static __inline void bus_space_read_region_1 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int8_t *, size_t));
-static __inline void bus_space_read_region_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int16_t *, size_t));
-static __inline void bus_space_read_region_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int32_t *, size_t));
-
-static __inline void
-bus_space_read_region_1(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int8_t *addr;
- size_t count;
-{
- volatile u_int8_t *s;
-
- s = (volatile u_int8_t *)(bsh + offset);
- while (count--)
- *addr++ = *s++;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_read_region_2(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int16_t *addr;
- size_t count;
-{
- volatile u_int16_t *s;
-
- s = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("lhbrx %0, 0, %1" :
- "=r"(*addr++) : "r"(s++));
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_read_region_4(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int32_t *addr;
- size_t count;
-{
- volatile u_int32_t *s;
-
- s = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("lwbrx %0, 0, %1" :
- "=r"(*addr++) : "r"(s++));
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
+#define bus_space_read_region_1(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_read_1)((t), (h), (o), (a), (c)))
+#define bus_space_read_region_2(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_read_2)((t), (h), (o), (a), (c)))
+#define bus_space_read_region_4(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_read_4)((t), (h), (o), (a), (c)))
+#define bus_space_read_region_8(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_read_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_read_region_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_read_region_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * u_intN_t *addr, size_t count));
+ * u_intN_t *addr, size_t count);
*
* Read `count' 2, 4, or 8 byte stream quantities from bus space
* described by tag/handle and starting at `offset' and copy into
* buffer provided.
*/
-static __inline void bus_space_read_region_stream_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int16_t *, size_t));
-static __inline void bus_space_read_region_stream_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int32_t *, size_t));
-
-static __inline void
-bus_space_read_region_stream_2(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int16_t *addr;
- size_t count;
-{
- volatile u_int16_t *s;
-
- s = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- *addr++ = *s++;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_read_region_stream_4(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int32_t *addr;
- size_t count;
-{
- volatile u_int32_t *s;
-
- s = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- *addr++ = *s++;
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_read_region_stream_8 \
- !!! bus_space_read_region_stream_8 unimplemented !!!
+#define bus_space_read_region_stream_2(t, h, o, a, c) \
+ ((*(t)->pbs_region_stream->pbsg_read_2)((t), (h), (o), (a), (c)))
+#define bus_space_read_region_stream_4(t, h, o, a, c) \
+ ((*(t)->pbs_region_stream->pbsg_read_4)((t), (h), (o), (a), (c)))
+#define bus_space_read_region_stream_8(t, h, o, a, c) \
+ ((*(t)->pbs_region_stream->pbsg_read_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_write_region_N __P((bus_space_tag_t tag,
+ * void bus_space_write_region_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * const u_intN_t *addr, size_t count));
+ * const u_intN_t *addr, size_t count);
*
* Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
* to bus space described by tag/handle starting at `offset'.
*/
-static __inline void bus_space_write_region_1 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, const u_int8_t *, size_t));
-static __inline void bus_space_write_region_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, const u_int16_t *, size_t));
-static __inline void bus_space_write_region_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, const u_int32_t *, size_t));
-
-static __inline void
-bus_space_write_region_1(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- const u_int8_t *addr;
- size_t count;
-{
- volatile u_int8_t *d;
-
- d = (volatile u_int8_t *)(bsh + offset);
- while (count--)
- *d++ = *addr++;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_write_region_2(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- const u_int16_t *addr;
- size_t count;
-{
- volatile u_int16_t *d;
-
- d = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("sthbrx %0, 0, %1" ::
- "r"(*addr++), "r"(d++));
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_write_region_4(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- const u_int32_t *addr;
- size_t count;
-{
- volatile u_int32_t *d;
-
- d = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("stwbrx %0, 0, %1" ::
- "r"(*addr++), "r"(d++));
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_write_region_8 !!! bus_space_write_region_8 unimplemented !!!
+#define bus_space_write_region_1(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_write_1)((t), (h), (o), (a), (c)))
+#define bus_space_write_region_2(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_write_2)((t), (h), (o), (a), (c)))
+#define bus_space_write_region_4(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_write_4)((t), (h), (o), (a), (c)))
+#define bus_space_write_region_8(t, h, o, a, c) \
+ ((*(t)->pbs_region->pbsg_write_8)((t), (h), (o), (a), (c)))
/*
- * void bus_space_write_region_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_write_region_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * const u_intN_t *addr, size_t count));
+ * const u_intN_t *addr, size_t count);
*
* Write `count' 2, 4, or 8 byte stream quantities from the buffer provided
* to bus space described by tag/handle starting at `offset'.
*/
-static __inline void bus_space_write_region_stream_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, const u_int16_t *, size_t));
-static __inline void bus_space_write_region_stream_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, const u_int32_t *, size_t));
-
-static __inline void
-bus_space_write_region_stream_2(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- const u_int16_t *addr;
- size_t count;
-{
- volatile u_int16_t *d;
-
- d = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- *d++ = *addr++;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_write_region_stream_4(tag, bsh, offset, addr, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- const u_int32_t *addr;
- size_t count;
-{
- volatile u_int32_t *d;
-
- d = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- *d++ = *addr++;
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_write_region_stream_8 \
- !!! bus_space_write_region_stream_8 unimplemented !!!
+#define bus_space_write_region_stream_2(t, h, o, a, c) \
+ ((*(t)->pbs_region_stream->pbsg_write_2)((t), (h), (o), (a), (c)))
+#define bus_space_write_region_stream_4(t, h, o, a, c) \
+ ((*(t)->pbs_region_stream->pbsg_write_4)((t), (h), (o), (a), (c)))
+#define bus_space_write_region_stream_8(t, h, o, a, c) \
+ ((*(t)->pbs_region_stream->pbsg_write_8)((t), (h), (o), (a), (c)))
+#if 0
/*
- * void bus_space_set_multi_N __P((bus_space_tag_t tag,
+ * void bus_space_set_multi_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
- * size_t count));
+ * size_t count);
*
* Write the 1, 2, 4, or 8 byte value `val' to bus space described
* by tag/handle/offset `count' times.
*/
-static __inline void bus_space_set_multi_1 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int8_t, size_t));
-static __inline void bus_space_set_multi_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int16_t, size_t));
-static __inline void bus_space_set_multi_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int32_t, size_t));
-
-static __inline void
-bus_space_set_multi_1(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int8_t val;
- size_t count;
-{
- volatile u_int8_t *d;
-
- d = (volatile u_int8_t *)(bsh + offset);
- while (count--)
- *d = val;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_set_multi_2(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int16_t val;
- size_t count;
-{
- volatile u_int16_t *d;
-
- d = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("sthbrx %0, 0, %1" ::
- "r"(val), "r"(d));
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_set_multi_4(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int32_t val;
- size_t count;
-{
- volatile u_int32_t *d;
-
- d = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("stwbrx %0, 0, %1" ::
- "r"(val), "r"(d));
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
+#define bus_space_set_multi_1(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_1)((t), (h), (o), (v), (c)))
+#define bus_space_set_multi_2(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_2)((t), (h), (o), (v), (c)))
+#define bus_space_set_multi_4(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_4)((t), (h), (o), (v), (c)))
+#define bus_space_set_multi_8(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_8)((t), (h), (o), (v), (c)))
/*
- * void bus_space_set_multi_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_set_multi_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
- * size_t count));
+ * size_t count);
*
* Write the 2, 4, or 8 byte stream value `val' to bus space described
* by tag/handle/offset `count' times.
*/
-static __inline void bus_space_set_multi_stream_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int16_t, size_t));
-static __inline void bus_space_set_multi_stream_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int32_t, size_t));
-
-static __inline void
-bus_space_set_multi_stream_2(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int16_t val;
- size_t count;
-{
- volatile u_int16_t *d;
-
- d = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- *d = val;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_set_multi_stream_4(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int32_t val;
- size_t count;
-{
- volatile u_int32_t *d;
-
- d = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- *d = val;
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_set_multi_stream_8 \
- !!! bus_space_set_multi_stream_8 unimplemented !!!
+#define bus_space_set_multi_stream_2(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_stream_2)((t), (h), (o), (v), (c)))
+#define bus_space_set_multi_stream_4(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_stream_4)((t), (h), (o), (v), (c)))
+#define bus_space_set_multi_stream_8(t, h, o, v, c)
+ ((*(t)->pbs_set_multi_stream_8)((t), (h), (o), (v), (c)))
+
+#endif
/*
- * void bus_space_set_region_N __P((bus_space_tag_t tag,
+ * void bus_space_set_region_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
- * size_t count));
+ * size_t count);
*
* Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
* by tag/handle starting at `offset'.
*/
-static __inline void bus_space_set_region_1 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int8_t, size_t));
-static __inline void bus_space_set_region_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int16_t, size_t));
-static __inline void bus_space_set_region_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int32_t, size_t));
-
-static __inline void
-bus_space_set_region_1(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int8_t val;
- size_t count;
-{
- volatile u_int8_t *d;
-
- d = (volatile u_int8_t *)(bsh + offset);
- while (count--)
- *d++ = val;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_set_region_2(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int16_t val;
- size_t count;
-{
- volatile u_int16_t *d;
-
- d = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("sthbrx %0, 0, %1" ::
- "r"(val), "r"(d++));
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_set_region_4(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int32_t val;
- size_t count;
-{
- volatile u_int32_t *d;
-
- d = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- __asm__ volatile("stwbrx %0, 0, %1" ::
- "r"(val), "r"(d++));
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
+#define bus_space_set_region_1(t, h, o, v, c) \
+ ((*(t)->pbs_set->pbss_set_1)((t), (h), (o), (v), (c)))
+#define bus_space_set_region_2(t, h, o, v, c) \
+ ((*(t)->pbs_set->pbss_set_2)((t), (h), (o), (v), (c)))
+#define bus_space_set_region_4(t, h, o, v, c) \
+ ((*(t)->pbs_set->pbss_set_4)((t), (h), (o), (v), (c)))
+#define bus_space_set_region_8(t, h, o, v, c) \
+ ((*(t)->pbs_set->pbss_set_8)((t), (h), (o), (v), (c)))
/*
- * void bus_space_set_region_stream_N __P((bus_space_tag_t tag,
+ * void bus_space_set_region_stream_N (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
- * size_t count));
+ * size_t count);
*
* Write `count' 2, 4, or 8 byte stream value `val' to bus space described
* by tag/handle starting at `offset'.
*/
-static __inline void bus_space_set_region_stream_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int16_t, size_t));
-static __inline void bus_space_set_region_stream_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, u_int32_t, size_t));
-
-
-static __inline void
-bus_space_set_region_stream_2(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int16_t val;
- size_t count;
-{
- volatile u_int16_t *d;
-
- d = (volatile u_int16_t *)(bsh + offset);
- while (count--)
- *d++ = val;
- __asm__ volatile("eieio; sync");
-}
-
-static __inline void
-bus_space_set_region_stream_4(tag, bsh, offset, val, count)
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_size_t offset;
- u_int32_t val;
- size_t count;
-{
- volatile u_int32_t *d;
-
- d = (volatile u_int32_t *)(bsh + offset);
- while (count--)
- *d++ = val;
- __asm__ volatile("eieio; sync");
-}
-
-#define bus_space_set_region_stream_8 \
- !!! bus_space_set_region_stream_8 unimplemented !!!
+#define bus_space_set_region_stream_2(t, h, o, v, c) \
+ ((*(t)->pbs_set_stream->pbss_set_2)((t), (h), (o), (v), (c)))
+#define bus_space_set_region_stream_4(t, h, o, v, c) \
+ ((*(t)->pbs_set_stream->pbss_set_4)((t), (h), (o), (v), (c)))
+#define bus_space_set_region_stream_8(t, h, o, v, c) \
+ ((*(t)->pbs_set_stream->pbss_set_8)((t), (h), (o), (v), (c)))
+
/*
- * void bus_space_copy_region_N __P((bus_space_tag_t tag,
+ * void bus_space_copy_region_N (bus_space_tag_t tag,
* bus_space_handle_t bsh1, bus_size_t off1,
* bus_space_handle_t bsh2, bus_size_t off2,
- * size_t count));
+ * size_t count);
*
* Copy `count' 1, 2, 4, or 8 byte values from bus space starting
* at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
*/
-
-static __inline void bus_space_copy_region_1 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, bus_space_handle_t,
- bus_size_t, size_t));
-static __inline void bus_space_copy_region_2 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, bus_space_handle_t,
- bus_size_t, size_t));
-static __inline void bus_space_copy_region_4 __P((bus_space_tag_t,
- bus_space_handle_t, bus_size_t, bus_space_handle_t,
- bus_size_t, size_t));
-
-static __inline void
-bus_space_copy_region_1(t, h1, o1, h2, o2, c)
- bus_space_tag_t t;
- bus_space_handle_t h1;
- bus_size_t o1;
- bus_space_handle_t h2;
- bus_size_t o2;
- size_t c;
-{
- bus_addr_t addr1 = h1 + o1;
- bus_addr_t addr2 = h2 + o2;
-
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; c != 0; c--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (c - 1), addr2 += (c - 1);
- c != 0; c--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
-}
-
-static __inline void
-bus_space_copy_region_2(t, h1, o1, h2, o2, c)
- bus_space_tag_t t;
- bus_space_handle_t h1;
- bus_size_t o1;
- bus_space_handle_t h2;
- bus_size_t o2;
- size_t c;
-{
- bus_addr_t addr1 = h1 + o1;
- bus_addr_t addr2 = h2 + o2;
-
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; c != 0; c--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1);
- c != 0; c--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
-}
-
-static __inline void
-bus_space_copy_region_4(t, h1, o1, h2, o2, c)
- bus_space_tag_t t;
- bus_space_handle_t h1;
- bus_size_t o1;
- bus_space_handle_t h2;
- bus_size_t o2;
- size_t c;
-{
- bus_addr_t addr1 = h1 + o1;
- bus_addr_t addr2 = h2 + o2;
-
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; c != 0; c--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (c - 1), addr2 += 4 * (c - 1);
- c != 0; c--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
-}
-
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
+#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
+ ((*(t)->pbs_copy->pbsc_copy_1)((t), (h1), (o1), (h2), (o2), (c)))
+#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
+ ((*(t)->pbs_copy->pbsc_copy_2)((t), (h1), (o1), (h2), (o2), (c)))
+#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
+ ((*(t)->pbs_copy->pbsc_copy_4)((t), (h1), (o1), (h2), (o2), (c)))
+#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
+ ((*(t)->pbs_copy->pbsc_copy_8)((t), (h1), (o1), (h2), (o2), (c)))
/*
* Bus read/write barrier methods.
*
- * void bus_space_barrier __P((bus_space_tag_t tag,
+ * void bus_space_barrier (bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,
- * bus_size_t len, int flags));
+ * bus_size_t len, int flags);
*
*/
#define bus_space_barrier(t, h, o, l, f) \
@@ -1017,6 +634,7 @@ bus_space_copy_region_4(t, h1, o1, h2, o2, c)
#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
/* Forwards needed by prototypes below. */
+struct proc;
struct mbuf;
struct uio;
@@ -1064,33 +682,33 @@ struct powerpc_bus_dma_tag {
/*
* DMA mapping methods.
*/
- int (*_dmamap_create) __P((bus_dma_tag_t, bus_size_t, int,
- bus_size_t, bus_size_t, int, bus_dmamap_t *));
- void (*_dmamap_destroy) __P((bus_dma_tag_t, bus_dmamap_t));
- int (*_dmamap_load) __P((bus_dma_tag_t, bus_dmamap_t, void *,
- bus_size_t, struct proc *, int));
- int (*_dmamap_load_mbuf) __P((bus_dma_tag_t, bus_dmamap_t,
- struct mbuf *, int));
- int (*_dmamap_load_uio) __P((bus_dma_tag_t, bus_dmamap_t,
- struct uio *, int));
- int (*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t,
- bus_dma_segment_t *, int, bus_size_t, int));
- void (*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
- void (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
- bus_addr_t, bus_size_t, int));
+ int (*_dmamap_create) (bus_dma_tag_t, bus_size_t, int,
+ bus_size_t, bus_size_t, int, bus_dmamap_t *);
+ void (*_dmamap_destroy) (bus_dma_tag_t, bus_dmamap_t);
+ int (*_dmamap_load) (bus_dma_tag_t, bus_dmamap_t, void *,
+ bus_size_t, struct proc *, int);
+ int (*_dmamap_load_mbuf) (bus_dma_tag_t, bus_dmamap_t,
+ struct mbuf *, int);
+ int (*_dmamap_load_uio) (bus_dma_tag_t, bus_dmamap_t,
+ struct uio *, int);
+ int (*_dmamap_load_raw) (bus_dma_tag_t, bus_dmamap_t,
+ bus_dma_segment_t *, int, bus_size_t, int);
+ void (*_dmamap_unload) (bus_dma_tag_t, bus_dmamap_t);
+ void (*_dmamap_sync) (bus_dma_tag_t, bus_dmamap_t,
+ bus_addr_t, bus_size_t, int);
/*
* DMA memory utility functions.
*/
- int (*_dmamem_alloc) __P((bus_dma_tag_t, bus_size_t, bus_size_t,
- bus_size_t, bus_dma_segment_t *, int, int *, int));
- void (*_dmamem_free) __P((bus_dma_tag_t,
- bus_dma_segment_t *, int));
- int (*_dmamem_map) __P((bus_dma_tag_t, bus_dma_segment_t *,
- int, size_t, caddr_t *, int));
- void (*_dmamem_unmap) __P((bus_dma_tag_t, caddr_t, size_t));
- paddr_t (*_dmamem_mmap) __P((bus_dma_tag_t, bus_dma_segment_t *,
- int, off_t, int, int));
+ int (*_dmamem_alloc) (bus_dma_tag_t, bus_size_t, bus_size_t,
+ bus_size_t, bus_dma_segment_t *, int, int *, int);
+ void (*_dmamem_free) (bus_dma_tag_t,
+ bus_dma_segment_t *, int);
+ int (*_dmamem_map) (bus_dma_tag_t, bus_dma_segment_t *,
+ int, size_t, caddr_t *, int);
+ void (*_dmamem_unmap) (bus_dma_tag_t, caddr_t, size_t);
+ paddr_t (*_dmamem_mmap) (bus_dma_tag_t, bus_dma_segment_t *,
+ int, off_t, int, int);
};
#define bus_dmamap_create(t, s, n, m, b, f, p) \
@@ -1149,36 +767,36 @@ struct powerpc_bus_dmamap {
};
#ifdef _POWERPC_BUS_DMA_PRIVATE
-int _bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
- bus_size_t, int, bus_dmamap_t *));
-void _bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
-int _bus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
- bus_size_t, struct proc *, int));
-int _bus_dmamap_load_mbuf __P((bus_dma_tag_t, bus_dmamap_t,
- struct mbuf *, int));
-int _bus_dmamap_load_uio __P((bus_dma_tag_t, bus_dmamap_t,
- struct uio *, int));
-int _bus_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t,
- bus_dma_segment_t *, int, bus_size_t, int));
-void _bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
-void _bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
- bus_size_t, int));
-
-int _bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
+int _bus_dmamap_create (bus_dma_tag_t, bus_size_t, int, bus_size_t,
+ bus_size_t, int, bus_dmamap_t *);
+void _bus_dmamap_destroy (bus_dma_tag_t, bus_dmamap_t);
+int _bus_dmamap_load (bus_dma_tag_t, bus_dmamap_t, void *,
+ bus_size_t, struct proc *, int);
+int _bus_dmamap_load_mbuf (bus_dma_tag_t, bus_dmamap_t,
+ struct mbuf *, int);
+int _bus_dmamap_load_uio (bus_dma_tag_t, bus_dmamap_t,
+ struct uio *, int);
+int _bus_dmamap_load_raw (bus_dma_tag_t, bus_dmamap_t,
+ bus_dma_segment_t *, int, bus_size_t, int);
+void _bus_dmamap_unload (bus_dma_tag_t, bus_dmamap_t);
+void _bus_dmamap_sync (bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
+ bus_size_t, int);
+
+int _bus_dmamem_alloc (bus_dma_tag_t tag, bus_size_t size,
bus_size_t alignment, bus_size_t boundary,
- bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags));
-void _bus_dmamem_free __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
- int nsegs));
-int _bus_dmamem_map __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
- int nsegs, size_t size, caddr_t *kvap, int flags));
-void _bus_dmamem_unmap __P((bus_dma_tag_t tag, caddr_t kva,
- size_t size));
-paddr_t _bus_dmamem_mmap __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
- int nsegs, off_t off, int prot, int flags));
-
-int _bus_dmamem_alloc_range __P((bus_dma_tag_t tag, bus_size_t size,
+ bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
+void _bus_dmamem_free (bus_dma_tag_t tag, bus_dma_segment_t *segs,
+ int nsegs);
+int _bus_dmamem_map (bus_dma_tag_t tag, bus_dma_segment_t *segs,
+ int nsegs, size_t size, caddr_t *kvap, int flags);
+void _bus_dmamem_unmap (bus_dma_tag_t tag, caddr_t kva,
+ size_t size);
+paddr_t _bus_dmamem_mmap (bus_dma_tag_t tag, bus_dma_segment_t *segs,
+ int nsegs, off_t off, int prot, int flags);
+
+int _bus_dmamem_alloc_range (bus_dma_tag_t tag, bus_size_t size,
bus_size_t alignment, bus_size_t boundary,
bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
- paddr_t low, paddr_t high));
+ paddr_t low, paddr_t high);
#endif /* _POWERPC_BUS_DMA_PRIVATE */
#endif /* _POWERPC_BUS_H_ */
diff --git a/sys/arch/prep/conf/files.prep b/sys/arch/prep/conf/files.prep
index e55ad2eda37..12dc658b217 100644
--- a/sys/arch/prep/conf/files.prep
+++ b/sys/arch/prep/conf/files.prep
@@ -1,4 +1,4 @@
-# $NetBSD: files.prep,v 1.41 2003/03/05 05:43:50 matt Exp $
+# $NetBSD: files.prep,v 1.42 2003/03/18 16:40:22 matt Exp $
#
# prep-specific configuration info
#
@@ -28,7 +28,6 @@ file arch/prep/prep/mot_ulmb60xa.c platform_motorola_ulmb60xa
file arch/prep/prep/platform.c
file arch/prep/prep/autoconf.c
-file arch/prep/prep/bus_space.c
file arch/prep/prep/clock.c
file arch/prep/prep/consinit.c
file arch/prep/prep/disksubr.c disk
@@ -37,6 +36,7 @@ file arch/prep/prep/machdep.c
file arch/prep/prep/residual.c residual_data_dump
file arch/powerpc/powerpc/bus_dma.c
+file arch/powerpc/powerpc/bus_space.c
file arch/powerpc/powerpc/procfs_machdep.c procfs
# General files
diff --git a/sys/arch/prep/include/bus.h b/sys/arch/prep/include/bus.h
index 3a8eb4f80ca..320723bb01d 100644
--- a/sys/arch/prep/include/bus.h
+++ b/sys/arch/prep/include/bus.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.8 2003/03/06 00:20:41 matt Exp $ */
+/* $NetBSD: bus.h,v 1.9 2003/03/18 16:40:22 matt Exp $ */
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
/*-
@@ -120,8 +120,6 @@
#define BUS_MEM_TO_PHYS(t, x) ((x) & ~MPC105_DIRECT_MAPPED_SPACE)
#ifdef _KERNEL
-void prep_bus_space_init __P((void));
-void prep_bus_space_mallocok __P((void));
extern struct powerpc_bus_space prep_io_space_tag;
extern struct powerpc_bus_space prep_isa_io_space_tag;
extern struct powerpc_bus_space prep_mem_space_tag;
diff --git a/sys/arch/prep/pci/prep_pciconf_direct.c b/sys/arch/prep/pci/prep_pciconf_direct.c
index 6b4eb537f43..dc82e872bce 100644
--- a/sys/arch/prep/pci/prep_pciconf_direct.c
+++ b/sys/arch/prep/pci/prep_pciconf_direct.c
@@ -1,4 +1,4 @@
-/* $NetBSD: prep_pciconf_direct.c,v 1.1 2002/02/24 13:19:08 kleink Exp $ */
+/* $NetBSD: prep_pciconf_direct.c,v 1.2 2003/03/18 16:40:23 matt Exp $ */
/*
* Copyright (c) 2002 Klaus J. Klein. All rights reserved.
@@ -52,6 +52,8 @@
#include <machine/intr.h>
#include <machine/platform.h>
+#include <powerpc/pio.h>
+
#include <dev/isa/isavar.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
diff --git a/sys/arch/prep/prep/bus_space.c b/sys/arch/prep/prep/bus_space.c
deleted file mode 100644
index e75781903fd..00000000000
--- a/sys/arch/prep/prep/bus_space.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/* $NetBSD: bus_space.c,v 1.10 2003/03/06 05:25:19 matt Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
- * Simulation Facility, NASA Ames Research Center.
- *
- * 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/extent.h>
-#include <sys/mbuf.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <machine/bus.h>
-
-static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
-static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
- bus_space_handle_t *);
-static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
-static int memio_alloc(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 *);
-static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
-
-struct powerpc_bus_space prep_io_space_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
- 0x80000000, 0x00000000, 0x3f800000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space prep_isa_io_space_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
- 0x80000000, 0x00000000, 0x00010000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space prep_mem_space_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
- 0xC0000000, 0x00000000, 0x3f000000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space prep_isa_mem_space_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
- 0xC0000000, 0x00000000, 0x01000000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-
-static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
- __attribute__((aligned(8)));
-
-static int extent_flags;
-
-void
-prep_bus_space_init(void)
-{
- int error;
-
- prep_io_space_tag.pbs_extent = extent_create("ioport",
- prep_io_space_tag.pbs_base, prep_io_space_tag.pbs_limit - 1,
- M_DEVBUF,
- ex_storage[0], sizeof(ex_storage[0]),
- EX_NOCOALESCE|EX_NOWAIT);
- error = extent_alloc_region(prep_io_space_tag.pbs_extent,
- 0x10000, 0x7F0000, EX_NOWAIT);
- if (error)
- panic("prep_bus_space_init: can't block out reserved I/O"
- " space 0x10000-0x7fffff: error=%d", error);
- prep_mem_space_tag.pbs_extent = extent_create("iomem",
- prep_mem_space_tag.pbs_base, prep_mem_space_tag.pbs_limit - 1,
- M_DEVBUF,
- ex_storage[1], sizeof(ex_storage[1]),
- EX_NOCOALESCE|EX_NOWAIT);
-
- prep_isa_io_space_tag.pbs_extent = prep_io_space_tag.pbs_extent;
- prep_isa_mem_space_tag.pbs_extent = prep_mem_space_tag.pbs_extent;
-}
-
-void
-prep_bus_space_mallocok(void)
-{
- extent_flags = EX_MALLOCOK;
-}
-
-paddr_t
-memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
-{
- return (trunc_page(bpa + offset));
-}
-
-int
-memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
- bus_space_handle_t *bshp)
-{
- int error;
-
- if (bpa + size > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Can't map I/O space as linear.
- */
- if ((flags & BUS_SPACE_MAP_LINEAR) &&
- (t->pbs_flags & _BUS_SPACE_IO_TYPE))
- return (EOPNOTSUPP);
-
- /*
- * Before we go any further, let's make sure that this
- * region is available.
- */
- error = extent_alloc_region(t->pbs_extent, bpa, size,
- EX_NOWAIT | extent_flags);
- if (error)
- return (error);
-
- *bshp = t->pbs_offset + bpa;
-
- return (0);
-}
-
-void
-memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- bus_addr_t bpa = bsh - t->pbs_offset;
-
- if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
- printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
- (t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
- (unsigned long)bpa, (unsigned long)size);
- printf("memio_unmap: can't free region\n");
- }
-}
-
-int
-memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
- bus_size_t size, bus_size_t alignment, bus_size_t boundary,
- int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
-{
- u_long bpa;
- int error;
-
- if (rstart + size > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Can't map I/O space as linear.
- */
- if ((flags & BUS_SPACE_MAP_LINEAR) &&
- (t->pbs_flags & _BUS_SPACE_IO_TYPE))
- return (EOPNOTSUPP);
-
- if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
- panic("memio_alloc: bad region start/end");
-
- error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
- alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
-
- if (error)
- return (error);
-
- *bpap = bpa;
- *bshp = t->pbs_offset + bpa;
-
- return (0);
-}
-
-void
-memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- /* memio_unmap() does all that we need to do. */
- memio_unmap(t, bsh, size);
-}
diff --git a/sys/arch/prep/prep/locore.S b/sys/arch/prep/prep/locore.S
index 106b1392eb6..5fb124d6a6b 100644
--- a/sys/arch/prep/prep/locore.S
+++ b/sys/arch/prep/prep/locore.S
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.4 2003/02/02 20:43:25 matt Exp $ */
+/* $NetBSD: locore.S,v 1.5 2003/03/18 16:40:24 matt Exp $ */
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
/*
@@ -173,15 +173,15 @@ loop:
.globl _C_LABEL(enable_intr)
_C_LABEL(enable_intr):
mfmsr 3
- ori 3,3,PSL_EE@l
- mtmsr 3
+ ori 4,3,PSL_EE@l
+ mtmsr 4
blr
.globl _C_LABEL(disable_intr)
_C_LABEL(disable_intr):
mfmsr 3
- andi. 3,3,~PSL_EE@l
- mtmsr 3
+ andi. 4,3,~PSL_EE@l
+ mtmsr 4
blr
/*
@@ -193,3 +193,8 @@ _C_LABEL(disable_intr):
* Pull in common trap vector code.
*/
#include <powerpc/powerpc/trap_subr.S>
+
+/*
+ * Pull in common pio / bus_space code.
+ */
+#include <powerpc/powerpc/pio_subr.S>
diff --git a/sys/arch/prep/prep/machdep.c b/sys/arch/prep/prep/machdep.c
index c571a5db33f..306e5a39b46 100644
--- a/sys/arch/prep/prep/machdep.c
+++ b/sys/arch/prep/prep/machdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.45 2003/02/03 17:10:13 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.46 2003/03/18 16:40:24 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -39,6 +39,7 @@
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/exec.h>
+#include <sys/extent.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@@ -84,10 +85,11 @@ void comsoft(void);
#include <ddb/db_extern.h>
#endif
-void initppc __P((u_long, u_long, u_int, void *));
-void dumpsys __P((void));
-void strayintr __P((int));
-int lcsplx __P((int));
+void initppc(u_long, u_long, u_int, void *);
+void dumpsys(void);
+void strayintr(int);
+int lcsplx(int);
+void prep_bus_space_init(void);
char bootinfo[BOOTINFO_MAXSIZE];
@@ -259,7 +261,7 @@ cpu_startup()
/*
* Now safe for bus space allocation to use malloc.
*/
- prep_bus_space_mallocok();
+ bus_space_mallocok();
}
/*
@@ -376,3 +378,54 @@ lcsplx(ipl)
return (oldcpl);
}
+
+struct powerpc_bus_space prep_io_space_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ 0x80000000, 0x00000000, 0x3f800000,
+};
+struct powerpc_bus_space prep_isa_io_space_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ 0x80000000, 0x00000000, 0x00010000,
+};
+struct powerpc_bus_space prep_mem_space_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ 0xC0000000, 0x00000000, 0x3f000000,
+};
+struct powerpc_bus_space prep_isa_mem_space_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ 0xC0000000, 0x00000000, 0x01000000,
+};
+
+static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
+ __attribute__((aligned(8)));
+
+void
+prep_bus_space_init(void)
+{
+ int error;
+
+ error = bus_space_init(&prep_io_space_tag, "ioport",
+ ex_storage[0], sizeof(ex_storage[0]));
+ if (error)
+ panic("prep_bus_space_init: can't init io tag");
+
+ error = extent_alloc_region(prep_io_space_tag.pbs_extent,
+ 0x10000, 0x7F0000, EX_NOWAIT);
+ if (error)
+ panic("prep_bus_space_init: can't block out reserved I/O"
+ " space 0x10000-0x7fffff: error=%d", error);
+ error = bus_space_init(&prep_mem_space_tag, "iomem",
+ ex_storage[1], sizeof(ex_storage[1]));
+ if (error)
+ panic("prep_bus_space_init: can't init mem tag");
+
+ prep_isa_io_space_tag.pbs_extent = prep_io_space_tag.pbs_extent;
+ error = bus_space_init(&prep_isa_io_space_tag, "isa-ioport", NULL, 0);
+ if (error)
+ panic("prep_bus_space_init: can't init isa io tag");
+
+ prep_isa_mem_space_tag.pbs_extent = prep_mem_space_tag.pbs_extent;
+ error = bus_space_init(&prep_isa_mem_space_tag, "isa-iomem", NULL, 0);
+ if (error)
+ panic("prep_bus_space_init: can't init isa mem tag");
+}
diff --git a/sys/arch/sandpoint/conf/files.sandpoint b/sys/arch/sandpoint/conf/files.sandpoint
index 448344d6f68..67f421e6684 100644
--- a/sys/arch/sandpoint/conf/files.sandpoint
+++ b/sys/arch/sandpoint/conf/files.sandpoint
@@ -1,4 +1,4 @@
-# $NetBSD: files.sandpoint,v 1.15 2003/03/05 05:43:49 matt Exp $
+# $NetBSD: files.sandpoint,v 1.16 2003/03/18 16:40:24 matt Exp $
#
# Motorola's "SandPoint" evaluation board's specific configuration info
#
@@ -7,13 +7,13 @@ maxpartitions 16
maxusers 2 8 64
file arch/sandpoint/sandpoint/autoconf.c
-file arch/sandpoint/sandpoint/bus_space.c
file arch/sandpoint/sandpoint/clock.c
file arch/sandpoint/sandpoint/disksubr.c disk
file arch/sandpoint/sandpoint/extintr.c
file arch/sandpoint/sandpoint/machdep.c
file arch/powerpc/powerpc/bus_dma.c
+file arch/powerpc/powerpc/bus_space.c
file arch/powerpc/powerpc/procfs_machdep.c procfs
# General files
diff --git a/sys/arch/sandpoint/include/bus.h b/sys/arch/sandpoint/include/bus.h
index f48f06c8c4f..2428ad60fd0 100644
--- a/sys/arch/sandpoint/include/bus.h
+++ b/sys/arch/sandpoint/include/bus.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.4 2003/03/06 00:20:40 matt Exp $ */
+/* $NetBSD: bus.h,v 1.5 2003/03/18 16:40:24 matt Exp $ */
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
#ifndef _SANDPOINT_BUS_H_
@@ -25,7 +25,4 @@ extern struct powerpc_bus_space sandpoint_io_bs_tag;
extern struct powerpc_bus_space sandpoint_isa_io_bs_tag;
extern struct powerpc_bus_space sandpoint_mem_bs_tag;
-void sandpoint_bus_space_init(void);
-void sandpoint_bus_space_mallocok(void);
-
#endif /* _SANDPOINT_BUS_H_ */
diff --git a/sys/arch/sandpoint/sandpoint/bus_space.c b/sys/arch/sandpoint/sandpoint/bus_space.c
deleted file mode 100644
index 75773f00b41..00000000000
--- a/sys/arch/sandpoint/sandpoint/bus_space.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* $NetBSD: bus_space.c,v 1.5 2003/03/06 05:25:19 matt Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
- * Simulation Facility, NASA Ames Research Center.
- *
- * 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/extent.h>
-#include <sys/mbuf.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <machine/bus.h>
-
-static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
-static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
- bus_space_handle_t *);
-static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
-static int memio_alloc(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 *);
-static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
-
-struct powerpc_bus_space sandpoint_io_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
- 0xfe000000, 0x00000000, 0x00c00000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space sandpoint_isa_io_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
- 0xfe000000, 0x00000000, 0x00010000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space sandpoint_mem_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
- 0x00000000, 0x80000000, 0xfe000000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-struct powerpc_bus_space sandpoint_isa_mem_bs_tag = {
- _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
- 0x00000000, 0xfd000000, 0xfe000000,
- NULL,
- memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
-};
-
-static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
- __attribute__((aligned(8)));
-
-static int extent_flags;
-
-void
-sandpoint_bus_space_init(void)
-{
- int error;
-
- sandpoint_io_bs_tag.pbs_extent = extent_create("ioport",
- sandpoint_io_bs_tag.pbs_base, sandpoint_io_bs_tag.pbs_limit - 1,
- M_DEVBUF,
- ex_storage[0], sizeof(ex_storage[0]),
- EX_NOCOALESCE|EX_NOWAIT);
- error = extent_alloc_region(sandpoint_io_bs_tag.pbs_extent,
- 0x00010000, 0x7F0000, EX_NOWAIT);
- if (error)
- panic("sandpoint_bus_space_init: can't block out reserved"
- " I/O space 0x10000-0x7fffff: error=%d", error);
-
- sandpoint_mem_bs_tag.pbs_extent = extent_create("iomem",
- sandpoint_mem_bs_tag.pbs_base, sandpoint_mem_bs_tag.pbs_limit - 1,
- M_DEVBUF,
- ex_storage[1], sizeof(ex_storage[1]),
- EX_NOCOALESCE|EX_NOWAIT);
-}
-
-void
-sandpoint_bus_space_mallocok(void)
-{
- extent_flags = EX_MALLOCOK;
-}
-
-paddr_t
-memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
-{
- return (trunc_page(bpa + offset));
-}
-
-int
-memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
- bus_space_handle_t *bshp)
-{
- int error;
-
- if (bpa + size > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Can't map I/O space as linear.
- */
- if ((flags & BUS_SPACE_MAP_LINEAR) &&
- (t->pbs_flags & _BUS_SPACE_IO_TYPE))
- return (EOPNOTSUPP);
-
- /*
- * Before we go any further, let's make sure that this
- * region is available.
- */
- error = extent_alloc_region(t->pbs_extent, bpa, size,
- EX_NOWAIT | extent_flags);
- if (error)
- return (error);
-
- *bshp = t->pbs_offset + bpa;
-
- return (0);
-}
-
-void
-memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- bus_addr_t bpa = bsh - t->pbs_offset;
-
- if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
- printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
- (t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
- (unsigned long)bpa, (unsigned long)size);
- printf("memio_unmap: can't free region\n");
- }
-}
-
-int
-memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
- bus_size_t size, bus_size_t alignment, bus_size_t boundary,
- int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
-{
- u_long bpa;
- int error;
-
- if (rstart + size > t->pbs_limit)
- return (EINVAL);
-
- /*
- * Can't map I/O space as linear.
- */
- if ((flags & BUS_SPACE_MAP_LINEAR) &&
- (t->pbs_flags & _BUS_SPACE_IO_TYPE))
- return (EOPNOTSUPP);
-
- if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
- panic("memio_alloc: bad region start/end");
-
- error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
- alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
-
- if (error)
- return (error);
-
- *bpap = bpa;
- *bshp = t->pbs_offset + bpa;
-
- return (0);
-}
-
-void
-memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- /* memio_unmap() does all that we need to do. */
- memio_unmap(t, bsh, size);
-}
diff --git a/sys/arch/sandpoint/sandpoint/locore.S b/sys/arch/sandpoint/sandpoint/locore.S
index 36098d760c7..9cca85a9395 100644
--- a/sys/arch/sandpoint/sandpoint/locore.S
+++ b/sys/arch/sandpoint/sandpoint/locore.S
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.6 2003/02/03 17:10:14 matt Exp $ */
+/* $NetBSD: locore.S,v 1.7 2003/03/18 16:40:25 matt Exp $ */
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
/*
@@ -172,3 +172,8 @@ _C_LABEL(sandpoint_reboot):
* Include common trap / execption code
*/
#include <powerpc/powerpc/trap_subr.S>
+
+/*
+ * Include common pio / bus_space code
+ */
+#include <powerpc/powerpc/pio_subr.S>
diff --git a/sys/arch/sandpoint/sandpoint/machdep.c b/sys/arch/sandpoint/sandpoint/machdep.c
index 46ff27753d5..2903f60cfd5 100644
--- a/sys/arch/sandpoint/sandpoint/machdep.c
+++ b/sys/arch/sandpoint/sandpoint/machdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.24 2003/02/03 17:10:14 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.25 2003/03/18 16:40:25 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -44,6 +44,7 @@
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/exec.h>
+#include <sys/extent.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@@ -123,8 +124,9 @@ void lcsplx __P((int));
#ifdef DDB
extern void *startsym, *endsym;
#endif
-extern void consinit (void);
-extern void ext_intr (void);
+void consinit(void);
+void ext_intr(void);
+void sandpoint_bus_space_init(void);
void
initppc(u_int startkernel, u_int endkernel, u_int args, void *btinfo)
@@ -252,7 +254,7 @@ cpu_startup(void)
/*
* Now that we have VM, malloc()s are OK in bus_space.
*/
- sandpoint_bus_space_mallocok();
+ bus_space_mallocok();
/*
* Now allow hardware interrupts.
@@ -374,3 +376,57 @@ lcsplx(int ipl)
{
splx(ipl);
}
+
+struct powerpc_bus_space sandpoint_io_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ 0xfe000000, 0x00000000, 0x00c00000,
+};
+struct powerpc_bus_space sandpoint_isa_io_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
+ 0xfe000000, 0x00000000, 0x00010000,
+};
+struct powerpc_bus_space sandpoint_mem_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ 0x00000000, 0x80000000, 0xfe000000,
+};
+struct powerpc_bus_space sandpoint_isa_mem_bs_tag = {
+ _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
+ 0x00000000, 0xfd000000, 0xfe000000,
+};
+
+static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
+ __attribute__((aligned(8)));
+
+void
+sandpoint_bus_space_init(void)
+{
+ int error;
+
+ error = bus_space_init(&sandpoint_io_bs_tag, "ioport",
+ ex_storage[0], sizeof(ex_storage[0]));
+ if (error)
+ panic("sandpoint_bus_space_init: can't init ioport tag");
+
+ error = extent_alloc_region(sandpoint_io_bs_tag.pbs_extent,
+ 0x00010000, 0x7F0000, EX_NOWAIT);
+ if (error)
+ panic("sandpoint_bus_space_init: can't block out reserved"
+ " I/O space 0x10000-0x7fffff: error=%d", error);
+
+ sandpoint_isa_io_bs_tag.pbs_extent = sandpoint_io_bs_tag.pbs_extent;
+ error = bus_space_init(&sandpoint_isa_io_bs_tag, "isa-iomem",
+ ex_storage[1], sizeof(ex_storage[1]));
+ if (error)
+ panic("sandpoint_bus_space_init: can't init isa iomem tag");
+
+ error = bus_space_init(&sandpoint_mem_bs_tag, "iomem",
+ ex_storage[2], sizeof(ex_storage[2]));
+ if (error)
+ panic("sandpoint_bus_space_init: can't init iomem tag");
+
+ sandpoint_isa_mem_bs_tag.pbs_extent = sandpoint_mem_bs_tag.pbs_extent;
+ error = bus_space_init(&sandpoint_isa_mem_bs_tag, "isa-iomem",
+ ex_storage[3], sizeof(ex_storage[3]));
+ if (error)
+ panic("sandpoint_bus_space_init: can't init isa iomem tag");
+}