summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hppa/hppa/dma.c230
-rw-r--r--sys/arch/hppa/hppa/mainbus.c726
-rw-r--r--sys/arch/hppa/include/bus.h469
3 files changed, 933 insertions, 492 deletions
diff --git a/sys/arch/hppa/hppa/dma.c b/sys/arch/hppa/hppa/dma.c
deleted file mode 100644
index a5661162d60..00000000000
--- a/sys/arch/hppa/hppa/dma.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/* $OpenBSD: dma.c,v 1.5 1999/09/10 17:00:03 mickey Exp $ */
-
-/*
- * Copyright (c) 1998 Michael Shalayeff
- * All rights reserved.
- *
- * 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 Michael Shalayeff.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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/proc.h>
-#include <sys/user.h>
-#include <sys/extent.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/file.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/mount.h>
-
-#include <vm/vm.h>
-#include <vm/vm_kern.h>
-#include <uvm/uvm.h>
-#include <uvm/uvm_page.h>
-
-#include <machine/bus.h>
-
-int
-_dmamap_create(v, size, nsegments, maxsegsz, boundary, flags, dmamp)
- void *v;
- bus_size_t size;
- int nsegments;
- bus_size_t maxsegsz;
- bus_size_t boundary;
- int flags;
- bus_dmamap_t *dmamp;
-{
- register struct hppa_bus_dmamap *map;
- register size_t mapsize;
-
- mapsize = sizeof(struct hppa_bus_dmamap) +
- (sizeof(bus_dma_segment_t) * (nsegments - 1));
- MALLOC(map, struct hppa_bus_dmamap *, mapsize, M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
- if (!map)
- return (ENOMEM);
-
- bzero(map, mapsize);
- map->_dm_size = size;
- map->_dm_segcnt = nsegments;
- map->_dm_maxsegsz = maxsegsz;
- map->_dm_boundary = boundary;
- map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
-
- *dmamp = map;
- return (0);
-}
-
-void
-_dmamap_destroy(v, map)
- void *v;
- bus_dmamap_t map;
-{
- free(map, M_DEVBUF);
-}
-
-int
-_dmamap_load(v, map, addr, size, p, flags)
- void *v;
- bus_dmamap_t map;
- void *addr;
- bus_size_t size;
- struct proc *p;
- int flags;
-{
- panic("_dmamap_load: not implemented");
-}
-
-int
-_dmamap_load_mbuf(v, map, m, flags)
- void *v;
- bus_dmamap_t map;
- struct mbuf *m;
- int flags;
-{
- panic("_dmamap_load_mbuf: not implemented");
-}
-
-int
-_dmamap_load_uio(v, map, uio, flags)
- void *v;
- bus_dmamap_t map;
- struct uio *uio;
- int flags;
-{
- panic("_dmamap_load_uio: not implemented");
-}
-
-int
-_dmamap_load_raw(v, map, segs, nsegs, size, flags)
- void *v;
- bus_dmamap_t map;
- bus_dma_segment_t *segs;
- int nsegs;
- bus_size_t size;
- int flags;
-{
- panic("_dmamap_load_raw: not implemented");
-}
-
-void
-_dmamap_unload(v, map)
- void *v;
- bus_dmamap_t map;
-{
- panic("_dmamap_unload: not implemented");
-}
-
-void
-_dmamap_sync(v, map, ops)
- void *v;
- bus_dmamap_t map;
- bus_dmasync_op_t ops;
-{
- __asm __volatile ("syncdma");
-}
-
-int
-_dmamem_alloc(v, size, alignment, boundary, segs, nsegs, rsegs, flags)
- void *v;
- bus_size_t size, alignment, boundary;
- bus_dma_segment_t *segs;
- int nsegs;
- int *rsegs;
- int flags;
-{
- vaddr_t va;
- paddr_t spa, epa;
-
- size = round_page(size);
-
- if (!(va = uvm_pagealloc_contig(size, VM_MIN_KERNEL_ADDRESS,
- VM_MAX_KERNEL_ADDRESS, NBPG)))
- return (ENOMEM);
-
- segs[0].ds_addr = va;
- segs[0].ds_len = size;
- *rsegs = 1;
-
- /* XXX for now */
- for (epa = size + (spa = kvtop((caddr_t)va)); spa < epa; spa += NBPG)
- pmap_changebit(spa, TLB_UNCACHEABLE, 0);
-
- return 0;
-
-}
-
-void
-_dmamem_free(v, segs, nsegs)
- void *v;
- bus_dma_segment_t *segs;
- int nsegs;
-{
- uvm_km_free(kmem_map, segs[0].ds_addr, M_DEVBUF);
-}
-
-int
-_dmamem_map(v, segs, nsegs, size, kvap, flags)
- void *v;
- bus_dma_segment_t *segs;
- int nsegs;
- size_t size;
- caddr_t *kvap;
- int flags;
-{
- *kvap = (caddr_t)segs[0].ds_addr;
- return 0;
-}
-
-void
-_dmamem_unmap(v, kva, size)
- void *v;
- caddr_t kva;
- size_t size;
-{
-}
-
-int
-_dmamem_mmap(v, segs, nsegs, off, prot, flags)
- void *v;
- bus_dma_segment_t *segs;
- int nsegs, off, prot, flags;
-{
- panic("_dmamem_mmap: not implemented");
-}
-
-int
-dma_cachectl(p, size)
- caddr_t p;
- int size;
-{
- fdcache(HPPA_SID_KERNEL, (vaddr_t)p, size);
- sync_caches();
- return 0;
-}
diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c
index 6cc416084a6..17fa8ca01e6 100644
--- a/sys/arch/hppa/hppa/mainbus.c
+++ b/sys/arch/hppa/hppa/mainbus.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: mainbus.c,v 1.4 1999/04/20 20:43:25 mickey Exp $ */
+/* $OpenBSD: mainbus.c,v 1.5 1999/11/25 18:25:31 mickey Exp $ */
/*
- * Copyright (c) 1998 Michael Shalayeff
+ * Copyright (c) 1998,1999 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -14,26 +14,37 @@
* 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 Michael Shalayeff.
+ * This product includes software developed by Michael Shalayeff.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES 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 MIND, 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.
*/
+
+#undef BTLBDEBUG
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/reboot.h>
+#include <sys/extent.h>
+#include <sys/mbuf.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+#include <uvm/uvm_page.h>
+#include <uvm/uvm.h>
#include <machine/pdc.h>
#include <machine/iomod.h>
@@ -56,22 +67,681 @@ struct cfdriver mainbus_cd = {
NULL, "mainbus", DV_DULL
};
-struct hppa_bus_dma_tag hppa_dmatag = {
+/* from machdep.c */
+extern struct extent *hppa_ex;
+extern struct pdc_btlb pdc_btlb;
+
+int
+mbus_add_mapping(bus_addr_t bpa, bus_size_t size, int cacheable,
+ bus_space_handle_t *bshp)
+{
+ extern u_int virtual_avail;
+ register u_int64_t spa, epa;
+ int bank, off;
+
+#ifdef BTLBDEBUG
+ printf("bus_mem_add_mapping(%x,%x,%scaceable,%p)\n",
+ bpa, size, cacheable?"":"non", bshp);
+#endif
+ if (bpa > 0 && bpa < virtual_avail)
+ *bshp = bpa;
+ else if ((bank = vm_physseg_find(atop(bpa), &off)) < 0) {
+ /*
+ * determine if we are mapping IO space, or beyond the physmem
+ * region. use block mapping then
+ *
+ * we map the whole bus module (there are 1024 of those max)
+ * so, check here if it's mapped already, map if needed.
+ * all mappings are equal mappings.
+ */
+ static u_int32_t bmm[0x4000/32];
+ int flex = HPPA_FLEX(bpa);
+
+ /* need a new mapping */
+ if (!(bmm[flex / 32] & (1 << (flex % 32)))) {
+ spa = bpa & FLEX_MASK;
+ epa = ((u_long)((u_int64_t)bpa + size +
+ ~FLEX_MASK - 1) & FLEX_MASK) - 1;
+#ifdef BTLBDEBUG
+ printf ("bus_mem_add_mapping: adding flex=%x "
+ "%qx-%qx, ", flex, spa, epa);
+#endif
+ while (spa < epa) {
+ vsize_t len = epa - spa;
+ u_int64_t pa;
+ if (len > pdc_btlb.max_size << PGSHIFT)
+ len = pdc_btlb.max_size << PGSHIFT;
+ if (btlb_insert(kernel_pmap->pmap_space, spa,
+ spa, &len,
+ kernel_pmap->pmap_pid |
+ pmap_prot(kernel_pmap,
+ VM_PROT_ALL)) < 0)
+ return -1;
+ pa = spa + len - 1;
+#ifdef BTLBDEBUG
+ printf ("--- %x/%x, %qx, %qx-%qx",
+ flex, HPPA_FLEX(pa), pa, spa, epa);
+#endif
+ /* do the mask */
+ for (; flex <= HPPA_FLEX(pa); flex++) {
+#ifdef BTLBDEBUG
+ printf ("mask %x ", flex);
+#endif
+ bmm[flex / 32] |= (1 << (flex % 32));
+ }
+ spa = pa;
+ }
+#ifdef BTLBDEBUG
+ printf ("\n");
+#endif
+ }
+#ifdef BTLBDEBUG
+ else {
+ printf("+++ already mapped flex=%x, mask=%x",
+ flex, bmm[flex / 8]);
+ }
+#endif
+ *bshp = bpa;
+ } else {
+ register vaddr_t va;
+
+#ifdef PMAPDEBUG
+ printf ("%d, %d, %x\n", bank, off, vm_physmem[0].end);
+#endif
+ spa = hppa_trunc_page(bpa);
+ epa = hppa_round_page(bpa + size);
+
+#ifdef DIAGNOSTIC
+ if (epa <= spa)
+ panic("bus_mem_add_mapping: overflow");
+#endif
+
+ if (!(va = uvm_pagealloc_contig(epa - spa, spa, epa, NBPG)))
+ return (ENOMEM);
+
+ *bshp = (bus_space_handle_t)(va + (bpa & PGOFSET));
+
+ for (; spa < epa; spa += NBPG, va += NBPG) {
+ if (!cacheable)
+ pmap_changebit(spa, TLB_UNCACHEABLE, ~0);
+ else
+ pmap_changebit(spa, 0, ~TLB_UNCACHEABLE);
+ }
+ }
+
+ return 0;
+}
+
+int
+mbus_map(void *v, bus_addr_t bpa, bus_size_t size,
+ int cacheable, bus_space_handle_t *bshp)
+{
+ register int error;
+
+ if ((error = extent_alloc_region(hppa_ex, bpa, size, EX_NOWAIT)))
+ return (error);
+
+ if ((error = mbus_add_mapping(bpa, size, cacheable, bshp))) {
+ if (extent_free(hppa_ex, bpa, size, EX_NOWAIT)) {
+ printf ("bus_space_map: pa 0x%lx, size 0x%lx\n",
+ bpa, size);
+ printf ("bus_space_map: can't free region\n");
+ }
+ }
+
+ return error;
+}
+
+void
+mbus_unmap(void *v, bus_space_handle_t bsh, bus_size_t size)
+{
+ register u_long sva, eva;
+ register bus_addr_t bpa;
+
+ sva = hppa_trunc_page(bsh);
+ eva = hppa_round_page(bsh + size);
+
+#ifdef DIAGNOSTIC
+ if (eva <= sva)
+ panic("bus_space_unmap: overflow");
+#endif
+
+ bpa = kvtop((caddr_t)bsh);
+ if (bpa != bsh)
+ uvm_km_free(kernel_map, sva, eva - sva);
+
+ if (extent_free(hppa_ex, bpa, size, EX_NOWAIT)) {
+ printf("bus_space_unmap: ps 0x%lx, size 0x%lx\n",
+ bpa, size);
+ printf("bus_space_unmap: can't free region\n");
+ }
+}
+
+int
+mbus_alloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size,
+ bus_size_t align, bus_size_t boundary, int cacheable,
+ bus_addr_t *addrp, bus_space_handle_t *bshp)
+{
+ u_long bpa;
+ int error;
+
+ if (rstart < hppa_ex->ex_start || rend > hppa_ex->ex_end)
+ panic("bus_space_alloc: bad region start/end");
+
+ if ((error = extent_alloc_subregion(hppa_ex, rstart, rend, size,
+ align, boundary, EX_NOWAIT, &bpa)))
+ return (error);
+
+ if ((error = mbus_add_mapping(bpa, size, cacheable, bshp))) {
+ if (extent_free(hppa_ex, bpa, size, EX_NOWAIT)) {
+ printf("bus_space_alloc: pa 0x%lx, size 0x%lx\n",
+ bpa, size);
+ printf("bus_space_alloc: can't free region\n");
+ }
+ }
+
+ *addrp = bpa;
+
+ return error;
+}
+
+void
+mbus_free(void *v, bus_space_handle_t h, bus_size_t size)
+{
+ /* bus_space_unmap() does all that we need to do. */
+ mbus_unmap(v, h, size);
+}
+
+int
+mbus_subregion(void *v, bus_space_handle_t bsh, bus_size_t offset,
+ bus_size_t size, bus_space_handle_t *nbshp)
+{
+ panic("mbus_subregion: unimplemented");
+}
+
+void
+mbus_barrier(void *v, bus_space_handle_t h, bus_size_t o, bus_size_t l, int op)
+{
+ sync_caches();
+}
+
+u_int8_t
+mbus_r1(void *v, bus_space_handle_t h, bus_size_t o)
+{
+ return *((volatile u_int8_t *)(h + o));
+}
+
+u_int16_t
+mbus_r2(void *v, bus_space_handle_t h, bus_size_t o)
+{
+ return *((volatile u_int16_t *)(h + o));
+}
+
+u_int32_t
+mbus_r4(void *v, bus_space_handle_t h, bus_size_t o)
+{
+ return *((volatile u_int32_t *)(h + o));
+}
+
+u_int64_t
+mbus_r8(void *v, bus_space_handle_t h, bus_size_t o)
+{
+ return *((volatile u_int64_t *)(h + o));
+}
+
+void
+mbus_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv)
+{
+ *((volatile u_int8_t *)(h + o)) = vv;
+}
+
+void
+mbus_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv)
+{
+ *((volatile u_int16_t *)(h + o)) = vv;
+}
+
+void
+mbus_w4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv)
+{
+ *((volatile u_int32_t *)(h + o)) = vv;
+}
+
+void
+mbus_w8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv)
+{
+ *((volatile u_int64_t *)(h + o)) = vv;
+}
+
+
+void
+mbus_rm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *(volatile u_int8_t *)h;
+}
+
+void
+mbus_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *(volatile u_int16_t *)h;
+}
+
+void
+mbus_rm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *(volatile u_int32_t *)h;
+}
+
+void
+mbus_rm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *(volatile u_int64_t *)h;
+}
+
+void
+mbus_wm_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int8_t *)h = *(a++);
+}
+
+void
+mbus_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int16_t *)h = *(a++);
+}
+
+void
+mbus_wm_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int32_t *)h = *(a++);
+}
+
+void
+mbus_wm_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int64_t *)h = *(a++);
+}
+
+void
+mbus_sm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int8_t *)h = vv;
+}
+
+void
+mbus_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int16_t *)h = vv;
+}
+
+void
+mbus_sm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int32_t *)h = vv;
+}
+
+void
+mbus_sm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *(volatile u_int64_t *)h = vv;
+}
+
+void mbus_rrm_2 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t*a, size_t c));
+void mbus_rrm_4 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t*a, size_t c));
+void mbus_rrm_8 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t*a, size_t c));
+
+void mbus_wrm_2 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int16_t *a, size_t c));
+void mbus_wrm_4 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int32_t *a, size_t c));
+void mbus_wrm_8 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int64_t *a, size_t c));
+
+void
+mbus_rr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *((volatile u_int8_t *)h)++;
+}
+
+void
+mbus_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *((volatile u_int16_t *)h)++;
+}
+
+void
+mbus_rr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *((volatile u_int32_t *)h)++;
+}
+
+void
+mbus_rr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *(a++) = *((volatile u_int64_t *)h)++;
+}
+
+void
+mbus_wr_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int8_t *)h)++ = *(a++);
+}
+
+void
+mbus_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int16_t *)h)++ = *(a++);
+}
+
+void
+mbus_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int32_t *)h)++ = *(a++);
+}
+
+void
+mbus_wr_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int64_t *)h)++ = *(a++);
+}
+
+void mbus_rrr_2 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t *a, size_t c));
+void mbus_rrr_4 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t *a, size_t c));
+void mbus_rrr_8 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t *a, size_t c));
+
+void mbus_wrr_2 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int16_t *a, size_t c));
+void mbus_wrr_4 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int32_t *a, size_t c));
+void mbus_wrr_8 __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int64_t *a, size_t c));
+
+void
+mbus_sr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int8_t *)h)++ = vv;
+}
+
+void
+mbus_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int16_t *)h)++ = vv;
+}
+
+void
+mbus_sr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int32_t *)h)++ = vv;
+}
+
+void
+mbus_sr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, size_t c)
+{
+ h += o;
+ while (c--)
+ *((volatile u_int64_t *)h)++ = vv;
+}
+
+void
+mbus_cp_1(void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+ h1 += o1;
+ h2 += o2;
+ while (c--)
+ *((volatile u_int8_t *)h1)++ =
+ *((volatile u_int8_t *)h2)++;
+}
+
+void
+mbus_cp_2(void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+ h1 += o1;
+ h2 += o2;
+ while (c--)
+ *((volatile u_int16_t *)h1)++ =
+ *((volatile u_int16_t *)h2)++;
+}
+
+void
+mbus_cp_4(void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+ h1 += o1;
+ h2 += o2;
+ while (c--)
+ *((volatile u_int32_t *)h1)++ =
+ *((volatile u_int32_t *)h2)++;
+}
+
+void
+mbus_cp_8(void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+ h1 += o1;
+ h2 += o2;
+ while (c--)
+ *((volatile u_int64_t *)h1)++ =
+ *((volatile u_int64_t *)h2)++;
+}
+
+
+const struct hppa_bus_space_tag hppa_bustag = {
NULL,
- _dmamap_create,
- _dmamap_destroy,
- _dmamap_load,
- _dmamap_load_mbuf,
- _dmamap_load_uio,
- _dmamap_load_raw,
- _dmamap_unload,
- _dmamap_sync,
-
- _dmamem_alloc,
- _dmamem_free,
- _dmamem_map,
- _dmamem_unmap,
- _dmamem_mmap
+
+ mbus_map, mbus_unmap, mbus_subregion, mbus_alloc, mbus_free,
+ mbus_barrier,
+ mbus_r1, mbus_r2, mbus_r4, mbus_r8,
+ mbus_w1, mbus_w2, mbus_w4, mbus_w8,
+ mbus_rm_1, mbus_rm_2, mbus_rm_4, mbus_rm_8,
+ mbus_wm_1, mbus_wm_2, mbus_wm_4, mbus_wm_8,
+ mbus_sm_1, mbus_sm_2, mbus_sm_4, mbus_sm_8,
+ /* *_raw_* are the same as non-raw for native busses */
+ mbus_rm_2, mbus_rm_4, mbus_rm_8,
+ mbus_wm_2, mbus_wm_4, mbus_wm_8,
+ mbus_rr_1, mbus_rr_2, mbus_rr_4, mbus_rr_8,
+ mbus_wr_1, mbus_wr_2, mbus_wr_4, mbus_wr_8,
+ /* *_raw_* are the same as non-raw for native busses */
+ mbus_rr_2, mbus_rr_4, mbus_rr_8,
+ mbus_wr_2, mbus_wr_4, mbus_wr_8,
+ mbus_sr_1, mbus_sr_2, mbus_sr_4, mbus_sr_8,
+ mbus_cp_1, mbus_cp_2, mbus_cp_4, mbus_cp_8
+};
+
+int
+mbus_dmamap_create(void *v, bus_size_t size, int nsegments,
+ bus_size_t maxsegsz, bus_size_t boundary, int flags,
+ bus_dmamap_t *dmamp)
+{
+ register struct hppa_bus_dmamap *map;
+ register size_t mapsize;
+
+ mapsize = sizeof(struct hppa_bus_dmamap) +
+ (sizeof(bus_dma_segment_t) * (nsegments - 1));
+ MALLOC(map, struct hppa_bus_dmamap *, mapsize, M_DEVBUF,
+ (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
+ if (!map)
+ return (ENOMEM);
+
+ bzero(map, mapsize);
+ map->_dm_size = size;
+ map->_dm_segcnt = nsegments;
+ map->_dm_maxsegsz = maxsegsz;
+ map->_dm_boundary = boundary;
+ map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
+
+ *dmamp = map;
+ return (0);
+}
+
+void
+mbus_dmamap_destroy(void *v, bus_dmamap_t map)
+{
+ free(map, M_DEVBUF);
+}
+
+int
+mbus_dmamap_load(void *v, bus_dmamap_t map, void *addr, bus_size_t size,
+ struct proc *p, int flags)
+{
+ panic("_dmamap_load: not implemented");
+}
+
+int
+mbus_dmamap_load_mbuf(void *v, bus_dmamap_t map, struct mbuf *m, int flags)
+{
+ panic("_dmamap_load_mbuf: not implemented");
+}
+
+int
+mbus_dmamap_load_uio(void *v, bus_dmamap_t map, struct uio *uio, int flags)
+{
+ panic("_dmamap_load_uio: not implemented");
+}
+
+int
+mbus_dmamap_load_raw(void *v, bus_dmamap_t map, bus_dma_segment_t *segs,
+ int nsegs, bus_size_t size, int flags)
+{
+ panic("_dmamap_load_raw: not implemented");
+}
+
+void
+mbus_dmamap_unload(void *v, bus_dmamap_t map)
+{
+ panic("_dmamap_unload: not implemented");
+}
+
+void
+mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_dmasync_op_t ops)
+{
+ __asm __volatile ("syncdma");
+}
+
+int
+mbus_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment,
+ bus_size_t boundary, bus_dma_segment_t *segs, int nsegs,
+ int *rsegs, int flags)
+{
+ vaddr_t va;
+ paddr_t spa, epa;
+
+ size = round_page(size);
+
+ if (!(va = uvm_pagealloc_contig(size, VM_MIN_KERNEL_ADDRESS,
+ VM_MAX_KERNEL_ADDRESS, NBPG)))
+ return (ENOMEM);
+
+ segs[0].ds_addr = va;
+ segs[0].ds_len = size;
+ *rsegs = 1;
+
+ /* XXX for now */
+ for (epa = size + (spa = kvtop((caddr_t)va)); spa < epa; spa += NBPG)
+ pmap_changebit(spa, TLB_UNCACHEABLE, 0);
+
+ return 0;
+
+}
+
+void
+mbus_dmamem_free(void *v, bus_dma_segment_t *segs, int nsegs)
+{
+ uvm_km_free(kmem_map, segs[0].ds_addr, M_DEVBUF);
+}
+
+int
+mbus_dmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, size_t size,
+ caddr_t *kvap, int flags)
+{
+ *kvap = (caddr_t)segs[0].ds_addr;
+ return 0;
+}
+
+void
+mbus_dmamem_unmap(void *v, caddr_t kva, size_t size)
+{
+}
+
+int
+mbus_dmamem_mmap(void *v, bus_dma_segment_t *segs, int nsegs, int off,
+ int prot, int flags)
+{
+ panic("_dmamem_mmap: not implemented");
+}
+
+int
+dma_cachectl(p, size)
+ caddr_t p;
+ int size;
+{
+ fdcache(HPPA_SID_KERNEL, (vaddr_t)p, size);
+ sync_caches();
+ return 0;
+}
+
+const struct hppa_bus_dma_tag hppa_dmatag = {
+ NULL,
+ mbus_dmamap_create, mbus_dmamap_destroy,
+ mbus_dmamap_load, mbus_dmamap_load_mbuf,
+ mbus_dmamap_load_uio, mbus_dmamap_load_raw,
+ mbus_dmamap_unload, mbus_dmamap_sync,
+
+ mbus_dmamem_alloc, mbus_dmamem_free, mbus_dmamem_map,
+ mbus_dmamem_unmap, mbus_dmamem_mmap
};
int
@@ -83,7 +753,7 @@ mbmatch(parent, cfdata, aux)
struct cfdata *cf = cfdata;
/* there will be only one */
- if (cf->cf_unit > 0)
+ if (cf->cf_unit)
return 0;
return 1;
@@ -104,7 +774,7 @@ mbattach(parent, self, aux)
if (pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdc_hpa) < 0)
panic("mbattach: PDC_HPA failed");
- if (bus_space_map(0, pdc_hpa.hpa, IOMOD_HPASIZE, 0, &ioh))
+ if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, IOMOD_HPASIZE, 0, &ioh))
panic("mbattach: cannot map mainbus IO space");
/*
@@ -120,12 +790,14 @@ mbattach(parent, self, aux)
bzero (&nca, sizeof(nca));
nca.ca_name = "pdc";
nca.ca_hpa = 0;
+ nca.ca_iot = &hppa_bustag;
nca.ca_dmatag = &hppa_dmatag;
config_found(self, &nca, mbprint);
bzero (&nca, sizeof(nca));
nca.ca_name = "mainbus";
nca.ca_hpa = 0;
+ nca.ca_iot = &hppa_bustag;
nca.ca_dmatag = &hppa_dmatag;
pdc_scanbus(self, &nca, -1, MAXMODBUS);
}
diff --git a/sys/arch/hppa/include/bus.h b/sys/arch/hppa/include/bus.h
index 7f81a150e86..7bc26803133 100644
--- a/sys/arch/hppa/include/bus.h
+++ b/sys/arch/hppa/include/bus.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: bus.h,v 1.8 1999/02/25 17:32:39 mickey Exp $ */
+/* $OpenBSD: bus.h,v 1.9 1999/11/25 18:25:31 mickey Exp $ */
/*
- * Copyright (c) 1998 Michael Shalayeff
+ * Copyright (c) 1998,1999 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -14,22 +14,24 @@
* 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 Michael Shalayeff.
+ * This product includes software developed by Michael Shalayeff.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES 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 MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef _MACHINE_BUS_H_
#define _MACHINE_BUS_H_
@@ -40,233 +42,250 @@ typedef u_long bus_addr_t;
typedef u_long bus_size_t;
/* access methods for bus space */
-typedef u_long bus_space_tag_t;
typedef u_long bus_space_handle_t;
-/* we are trying to avoid using bus.h interface whenever we can to avoid
- overheads because of different bus access types */
-#define HPPA_BUS_TAG_CORE (0x000)
-#define HPPA_BUS_TAG_ISA (0x001)
-#define HPPA_BUS_TAG_EISA (0x002)
-#define HPPA_BUS_TAG_PCI (0x003)
-#define HPPA_BUS_TAG_VME (0x004)
-#define HPPA_BUS_TAG_BUSMASK (0x00f)
-#define HPPA_BUS_TAG_MASK (0xfff)
-#define HPPA_BUS_TAG_SET_BASE(tag,base) \
- ((((tag) & HPPA_BUS_TAG_MASK)) | ((base) & ~HPPA_BUS_TAG_MASK))
-#define HPPA_BUS_TAG_BASE(tag) ((tag) & ~HPPA_BUS_TAG_MASK)
+struct hppa_bus_space_tag {
+ void *hbt_cookie;
+
+ int (*hbt_map) __P((void *v, bus_addr_t addr, bus_size_t size,
+ int cacheable, bus_space_handle_t *bshp));
+ void (*hbt_unmap) __P((void *v, bus_space_handle_t bsh,
+ bus_size_t size));
+ int (*hbt_subregion) __P((void *v, bus_space_handle_t bsh,
+ bus_size_t offset, bus_size_t size,
+ bus_space_handle_t *nbshp));
+ int (*hbt_alloc) __P((void *v, bus_addr_t rstart, bus_addr_t rend,
+ bus_size_t size, bus_size_t align,
+ bus_size_t boundary, int cacheable,
+ bus_addr_t *addrp, bus_space_handle_t *bshp));
+ void (*hbt_free) __P((void *, bus_space_handle_t, bus_size_t));
+ void (*hbt_barrier) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, bus_size_t l, int op));
+
+ u_int8_t (*hbt_r1) __P((void *, bus_space_handle_t, bus_size_t));
+ u_int16_t (*hbt_r2) __P((void *, bus_space_handle_t, bus_size_t));
+ u_int32_t (*hbt_r4) __P((void *, bus_space_handle_t, bus_size_t));
+ u_int64_t (*hbt_r8) __P((void *, bus_space_handle_t, bus_size_t));
+
+ void (*hbt_w1)__P((void *, bus_space_handle_t, bus_size_t, u_int8_t));
+ void (*hbt_w2)__P((void *, bus_space_handle_t, bus_size_t, u_int16_t));
+ void (*hbt_w4)__P((void *, bus_space_handle_t, bus_size_t, u_int32_t));
+ void (*hbt_w8)__P((void *, bus_space_handle_t, bus_size_t, u_int64_t));
+
+ void (*hbt_rm_1) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int8_t *a, size_t c));
+ void (*hbt_rm_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t *a, size_t c));
+ void (*hbt_rm_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t *a, size_t c));
+ void (*hbt_rm_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t *a, size_t c));
+
+ void (*hbt_wm_1) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ const u_int8_t *a, size_t c));
+ void (*hbt_wm_2) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ const u_int16_t *a, size_t c));
+ void (*hbt_wm_4) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ const u_int32_t *a, size_t c));
+ void (*hbt_wm_8) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ const u_int64_t *a, size_t c));
+
+ void (*hbt_sm_1) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ u_int8_t vv, size_t c));
+ void (*hbt_sm_2) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ u_int16_t vv, size_t c));
+ void (*hbt_sm_4) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ u_int32_t vv, size_t c));
+ void (*hbt_sm_8) __P((void *v, bus_space_handle_t h, bus_size_t o,
+ u_int64_t vv, size_t c));
+
+ void (*hbt_rrm_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t*a, size_t c));
+ void (*hbt_rrm_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t*a, size_t c));
+ void (*hbt_rrm_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t*a, size_t c));
+
+ void (*hbt_wrm_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int16_t *a, size_t c));
+ void (*hbt_wrm_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int32_t *a, size_t c));
+ void (*hbt_wrm_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int64_t *a, size_t c));
+
+ void (*hbt_rr_1) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int8_t *a, size_t c));
+ void (*hbt_rr_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t *a, size_t c));
+ void (*hbt_rr_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t *a, size_t c));
+ void (*hbt_rr_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t *a, size_t c));
+
+ void (*hbt_wr_1) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int8_t *a, size_t c));
+ void (*hbt_wr_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int16_t *a, size_t c));
+ void (*hbt_wr_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int32_t *a, size_t c));
+ void (*hbt_wr_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int64_t *a, size_t c));
+
+ void (*hbt_rrr_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t *a, size_t c));
+ void (*hbt_rrr_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t *a, size_t c));
+ void (*hbt_rrr_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t *a, size_t c));
+
+ void (*hbt_wrr_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int16_t *a, size_t c));
+ void (*hbt_wrr_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int32_t *a, size_t c));
+ void (*hbt_wrr_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, const u_int64_t *a, size_t c));
+
+ void (*hbt_sr_1) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int8_t vv, size_t c));
+ void (*hbt_sr_2) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int16_t vv, size_t c));
+ void (*hbt_sr_4) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int32_t vv, size_t c));
+ void (*hbt_sr_8) __P((void *v, bus_space_handle_t h,
+ bus_size_t o, u_int64_t vv, size_t c));
+
+ void (*hbt_cp_1) __P((void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c));
+ void (*hbt_cp_2) __P((void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c));
+ void (*hbt_cp_4) __P((void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c));
+ void (*hbt_cp_8) __P((void *v, bus_space_handle_t h1, bus_size_t o1,
+ bus_space_handle_t h2, bus_size_t o2, bus_size_t c));
+};
+typedef const struct hppa_bus_space_tag *bus_space_tag_t;
+extern const struct hppa_bus_space_tag hppa_bustag;
/* bus access routines */
#define DCIAS(pa) ((void)(pa))
-int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int cacheable, bus_space_handle_t *bshp));
-void bus_space_unmap __P((bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size));
-
-int bus_space_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp));
-
-int bus_space_alloc __P((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 cacheable, bus_addr_t *addrp,
- bus_space_handle_t *bshp));
-void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size));
-
-#define bus_space_read_1(t, h, o) \
- ((void)(t), (*((volatile u_int8_t *)((h) + (o)))))
-#define bus_space_read_2(t, h, o) \
- ((void)(t), (*((volatile u_int16_t *)((h) + (o)))))
-#define bus_space_read_4(t, h, o) \
- ((void)(t), (*((volatile u_int32_t *)((h) + (o)))))
-#define bus_space_read_8(t, h, o) \
- ((void)(t), (*((volatile u_int64_t *)((h) + (o)))))
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int8_t *a, size_t c)
-{
- h += o;
- while (c--)
- *(a++) = *((volatile u_int8_t *)h)++;
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int16_t *a, size_t c)
-{
- h += o;
- while (c--)
- *(a++) = *((volatile u_int16_t *)h)++;
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int32_t *a, size_t c)
-{
- h += o;
- while (c--)
- *(a++) = *((volatile u_int32_t *)h)++;
-}
-
-static __inline void
-bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, u_int64_t *a, size_t c)
-{
- h += o;
- while (c--)
- *(a++) = *((volatile u_int64_t *)h)++;
-}
-
+#define bus_space_map(t,a,c,ca,hp) \
+ (((t)->hbt_map)((t)->hbt_cookie,(a),(c),(ca),(hp)))
+#define bus_space_unmap(t,h,c) \
+ (((t)->hbt_unmap)((t)->hbt_cookie,(h),(c)))
+#define bus_space_subregion(t,h,o,c,hp) \
+ (((t)->hbt_subregion)((t)->hbt_cookie,(h),(o),(c),(hp)))
+#define bus_space_alloc(t,b,e,c,al,bn,ca,ap,hp) \
+ (((t)->hbt_alloc)((t)->hbt_alloc,(b),(e),(c),(al),(bn),(ca),(ap),(hp)))
+#define bus_space_free(t,h,c) \
+ (((t)->hbt_free)((t)->hbt_cookie,(h),(c)))
+
+#define bus_space_read_1(t,h,o) (((t)->hbt_r1)((t)->hbt_cookie,(h),(o)))
+#define bus_space_read_2(t,h,o) (((t)->hbt_r2)((t)->hbt_cookie,(h),(o)))
+#define bus_space_read_4(t,h,o) (((t)->hbt_r4)((t)->hbt_cookie,(h),(o)))
+#define bus_space_read_8(t,h,o) (((t)->hbt_r8)((t)->hbt_cookie,(h),(o)))
+
+#define bus_space_write_1(t,h,o,v) (((t)->hbt_w1)((t)->hbt_cookie,(h),(o),(v)))
+#define bus_space_write_2(t,h,o,v) (((t)->hbt_w2)((t)->hbt_cookie,(h),(o),(v)))
+#define bus_space_write_4(t,h,o,v) (((t)->hbt_w4)((t)->hbt_cookie,(h),(o),(v)))
+#define bus_space_write_8(t,h,o,v) (((t)->hbt_w8)((t)->hbt_cookie,(h),(o),(v)))
+
+#define bus_space_read_multi_1(t,h,o,a,c) \
+ (((t)->hbt_rm_1)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_multi_2(t,h,o,a,c) \
+ (((t)->hbt_rm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_multi_4(t,h,o,a,c) \
+ (((t)->hbt_rm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_multi_8(t,h,o,a,c) \
+ (((t)->hbt_rm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
+
+#define bus_space_write_multi_1(t,h,o,a,c) \
+ (((t)->hbt_wm_1)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_write_multi_2(t,h,o,a,c) \
+ (((t)->hbt_wm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_write_multi_4(t,h,o,a,c) \
+ (((t)->hbt_wm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_write_multi_8(t,h,o,a,c) \
+ (((t)->hbt_wm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
+
+#define bus_space_set_multi_1(t,h,o,v,c) \
+ (((t)->hbt_sm_1)((t)->hbt_cookie, (h), (o), (v), (c)))
+#define bus_space_set_multi_2(t,h,o,v,c) \
+ (((t)->hbt_sm_2)((t)->hbt_cookie, (h), (o), (v), (c)))
+#define bus_space_set_multi_4(t,h,o,v,c) \
+ (((t)->hbt_sm_4)((t)->hbt_cookie, (h), (o), (v), (c)))
+#define bus_space_set_multi_8(t,h,o,v,c) \
+ (((t)->hbt_sm_8)((t)->hbt_cookie, (h), (o), (v), (c)))
#define bus_space_read_raw_multi_2(t, h, o, a, c) \
- bus_space_read_multi_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
+ (((t)->hbt_rm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_read_raw_multi_4(t, h, o, a, c) \
- bus_space_read_multi_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
+ (((t)->hbt_rm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_read_raw_multi_8(t, h, o, a, c) \
- bus_space_read_multi_8((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
-
-#if 0
-#define bus_space_read_region_1(t, h, o, a, c) do { \
-} while (0)
-
-#define bus_space_read_region_2(t, h, o, a, c) do { \
-
-} while (0)
-
-#define bus_space_read_region_4(t, h, o, a, c) do { \
-} while (0)
-
-#define bus_space_read_region_8
-#endif
-
-#define bus_space_read_raw_region_2(t, h, o, a, c) \
- bus_space_read_region_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
-#define bus_space_read_raw_region_4(t, h, o, a, c) \
- bus_space_read_region_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
-#define bus_space_read_raw_region_8(t, h, o, a, c) \
- bus_space_read_region_8((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
-
-#define bus_space_write_1(t, h, o, v) \
- ((void)(t), *((volatile u_int8_t *)((h) + (o))) = (v))
-#define bus_space_write_2(t, h, o, v) \
- ((void)(t), *((volatile u_int16_t *)((h) + (o))) = (v))
-#define bus_space_write_4(t, h, o, v) \
- ((void)(t), *((volatile u_int32_t *)((h) + (o))) = (v))
-#define bus_space_write_8(t, h, o, v) \
- ((void)(t), *((volatile u_int64_t *)((h) + (o))) = (v))
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, const u_int8_t *a, size_t c)
-{
- h += o;
- while (c--)
- *((volatile u_int8_t *)h)++ = *(a++);
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, const u_int16_t *a, size_t c)
-{
- h += o;
- while (c--)
- *((volatile u_int16_t *)h)++ = *(a++);
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, const u_int32_t *a, size_t c)
-{
- h += o;
- while (c--)
- *((volatile u_int32_t *)h)++ = *(a++);
-}
-
-static __inline void
-bus_space_write_multi_8(bus_space_tag_t t, bus_space_handle_t h,
- bus_size_t o, const u_int64_t *a, size_t c)
-{
- h += o;
- while (c--)
- *((volatile u_int64_t *)h)++ = *(a++);
-}
-
+ (((t)->hbt_rm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_write_raw_multi_2(t, h, o, a, c) \
- bus_space_write_multi_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
+ (((t)->hbt_wm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_write_raw_multi_4(t, h, o, a, c) \
- bus_space_write_multi_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
+ (((t)->hbt_wm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_write_raw_multi_8(t, h, o, a, c) \
- bus_space_write_multi_8((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
-
-#if 0
-#define bus_space_write_region_1(t, h, o, a, c) do { \
-} while (0)
-
-#define bus_space_write_region_2(t, h, o, a, c) do { \
-} while (0)
-
-#define bus_space_write_region_4(t, h, o, a, c) do { \
-} while (0)
+ (((t)->hbt_wm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
+
+#define bus_space_read_region_1(t, h, o, a, c) \
+ (((t)->hbt_rr_1)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_region_2(t, h, o, a, c) \
+ (((t)->hbt_rr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_region_4(t, h, o, a, c) \
+ (((t)->hbt_rr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_region_8(t, h, o, a, c) \
+ (((t)->hbt_rr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
+
+#define bus_space_write_region_1(t, h, o, a, c) \
+ (((t)->hbt_wr_1)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_write_region_2(t, h, o, a, c) \
+ (((t)->hbt_wr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_write_region_4(t, h, o, a, c) \
+ (((t)->hbt_wr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_write_region_8(t, h, o, a, c) \
+ (((t)->hbt_wr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
-#define bus_space_write_region_8
-#endif
+#define bus_space_read_raw_region_2(t, h, o, a, c) \
+ (((t)->hbt_rrr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_raw_region_4(t, h, o, a, c) \
+ (((t)->hbt_rrr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
+#define bus_space_read_raw_region_8(t, h, o, a, c) \
+ (((t)->hbt_rrr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_write_raw_region_2(t, h, o, a, c) \
- bus_space_write_region_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
+ (((t)->hbt_wrr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_write_raw_region_4(t, h, o, a, c) \
- bus_space_write_region_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
+ (((t)->hbt_wrr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
#define bus_space_write_raw_region_8(t, h, o, a, c) \
- bus_space_write_region_8((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
-
-#if 0
-#define bus_space_set_multi_1(t, h, o, v, c) do { \
-} while (0)
-
-#define bus_space_set_multi_2(t, h, o, v, c) do { \
-} while (0)
-
-#define bus_space_set_multi_4(t, h, o, v, c) do { \
-} while (0)
-
-#define bus_space_set_multi_8
-#endif
-
-#if 0
-#define bus_space_set_region_1(t, h, o, v, c) do { \
-} while (0)
-
-#define bus_space_set_region_2(t, h, o, v, c) do { \
-} while (0)
-
-#define bus_space_set_region_4(t, h, o, v, c) do { \
-} while (0)
-
-#define bus_space_set_region_8
-#endif
-
-#if 0
-#define bus_space_copy_1(t, h1, o1, h2, o2, c) do { \
-} while (0)
-
-#define bus_space_copy_2(t, h1, o1, h2, o2, c) do { \
-} while (0)
-
-#define bus_space_copy_4(t, h1, o1, h2, o2, c) do { \
-} while (0)
-
-#define bus_space_copy_8
-#endif
+ (((t)->hbt_wrr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
+
+#define bus_space_set_region_1(t, h, o, v, c) \
+ (((t)->hbt_sr_1)((t)->hbt_cookie, (h), (o), (v), (c)))
+#define bus_space_set_region_2(t, h, o, v, c) \
+ (((t)->hbt_sr_2)((t)->hbt_cookie, (h), (o), (v), (c)))
+#define bus_space_set_region_4(t, h, o, v, c) \
+ (((t)->hbt_sr_4)((t)->hbt_cookie, (h), (o), (v), (c)))
+#define bus_space_set_region_8(t, h, o, v, c) \
+ (((t)->hbt_sr_8)((t)->hbt_cookie, (h), (o), (v), (c)))
+
+#define bus_space_copy_1(t, h1, o1, h2, o2, c) \
+ (((t)->hbt_cp_1)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
+#define bus_space_copy_2(t, h1, o1, h2, o2, c) \
+ (((t)->hbt_cp_2)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
+#define bus_space_copy_4(t, h1, o1, h2, o2, c) \
+ (((t)->hbt_cp_4)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
+#define bus_space_copy_8(t, h1, o1, h2, o2, c) \
+ (((t)->hbt_cp_8)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
#define BUS_SPACE_BARRIER_READ 0
#define BUS_SPACE_BARRIER_WRITE 1
-#define bus_space_barrier(t,h,o,l,op) { \
- ((void)(t),(void)(h),(void)(o),(void)(l),(void)(op)); \
- sync_caches(); \
-}
+#define bus_space_barrier(t,h,o,l,op) \
+ ((t)->hbt_barrier((t)->hbt_cookie, (h), (o), (l), (op)))
#define BUS_DMA_WAITOK 0x00
#define BUS_DMA_NOWAIT 0x01
@@ -285,7 +304,7 @@ typedef enum {
BUS_DMASYNC_PREWRITE
} bus_dmasync_op_t;
-typedef struct hppa_bus_dma_tag *bus_dma_tag_t;
+typedef const struct hppa_bus_dma_tag *bus_dma_tag_t;
typedef struct hppa_bus_dmamap *bus_dmamap_t;
/*
@@ -369,26 +388,6 @@ struct hppa_bus_dma_tag {
#define bus_dmamem_mmap(t, sg, n, o, p, f) \
(*(t)->_dmamem_mmap)((t)->_cookie, (sg), (n), (o), (p), (f))
-int _dmamap_create __P((void *, bus_size_t, int,
- bus_size_t, bus_size_t, int, bus_dmamap_t *));
-void _dmamap_destroy __P((void *, bus_dmamap_t));
-int _dmamap_load __P((void *, bus_dmamap_t, void *,
- bus_size_t, struct proc *, int));
-int _dmamap_load_mbuf __P((void *, bus_dmamap_t, struct mbuf *, int));
-int _dmamap_load_uio __P((void *, bus_dmamap_t, struct uio *, int));
-int _dmamap_load_raw __P((void *, bus_dmamap_t,
- bus_dma_segment_t *, int, bus_size_t, int));
-void _dmamap_unload __P((void *, bus_dmamap_t));
-void _dmamap_sync __P((void *, bus_dmamap_t, bus_dmasync_op_t));
-
-int _dmamem_alloc __P((void *, bus_size_t, bus_size_t,
- bus_size_t, bus_dma_segment_t *, int, int *, int));
-void _dmamem_free __P((void *, bus_dma_segment_t *, int));
-int _dmamem_map __P((void *, bus_dma_segment_t *,
- int, size_t, caddr_t *, int));
-void _dmamem_unmap __P((void *, caddr_t, size_t));
-int _dmamem_mmap __P((void *, bus_dma_segment_t *, int, int, int, int));
-
/*
* bus_dmamap_t
*