diff options
author | Martin Reindl <martin@cvs.openbsd.org> | 2005-09-12 10:07:30 +0000 |
---|---|---|
committer | Martin Reindl <martin@cvs.openbsd.org> | 2005-09-12 10:07:30 +0000 |
commit | 0323a692667ac28ff4145de60bd4304dada9ffc6 (patch) | |
tree | fd308bdd35028a01a33faae88c7e7467c6c82630 /sys/arch/mac68k | |
parent | ecff9cfc1dd353f56283227b34cdec69a47493fb (diff) |
- Add byte-swap and stride options to bus_space.
- Add bus_space_*_stream_N functions
- Replace PGOFSET with m68k_trunc_page() or m68k_page_offset()
from NetBSD, testing help by otto@
Diffstat (limited to 'sys/arch/mac68k')
-rw-r--r-- | sys/arch/mac68k/dev/asc.c | 5 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grf_iv.c | 8 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/grf_mv.c | 8 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_ae.c | 12 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/if_sn.c | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/ncr5380.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/include/bus.h | 540 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/bus_space.c | 1019 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/mem.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/pmap_bootstrap.c | 8 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/trap.c | 4 |
11 files changed, 1318 insertions, 300 deletions
diff --git a/sys/arch/mac68k/dev/asc.c b/sys/arch/mac68k/dev/asc.c index bf1bb50b386..361bb0dcbd8 100644 --- a/sys/arch/mac68k/dev/asc.c +++ b/sys/arch/mac68k/dev/asc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asc.c,v 1.19 2005/07/23 23:28:58 martin Exp $ */ +/* $OpenBSD: asc.c,v 1.20 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: asc.c,v 1.20 1997/02/24 05:47:33 scottr Exp $ */ /* @@ -284,7 +284,8 @@ ascmmap(dev, off, prot) sc = asc_cd.cd_devs[unit]; if (off >= 0 && off < MAC68K_ASC_LEN) { - pmap_extract(pmap_kernel(), (vaddr_t)sc->sc_handle, &pa); + (void)pmap_extract(pmap_kernel(), (vaddr_t)sc->sc_handle.base, + &pa); return m68k_btop(pa + off); } diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c index fccc9ec53d7..96a64919ee4 100644 --- a/sys/arch/mac68k/dev/grf_iv.c +++ b/sys/arch/mac68k/dev/grf_iv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grf_iv.c,v 1.26 2005/08/06 19:51:43 martin Exp $ */ +/* $OpenBSD: grf_iv.c,v 1.27 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: grf_iv.c,v 1.17 1997/02/20 00:23:27 scottr Exp $ */ /* @@ -278,7 +278,7 @@ grfiv_attach(parent, self, aux) break; default: sc->sc_basepa = m68k_trunc_page(mac68k_vidphys); - sc->sc_fbofs = mac68k_vidphys & PGOFSET; + sc->sc_fbofs = m68k_page_offset(mac68k_vidphys); length = mac68k_vidlen + sc->sc_fbofs; printf(" @ %lx: On-board video\n", @@ -294,7 +294,7 @@ grfiv_attach(parent, self, aux) if (sc->sc_basepa <= mac68k_vidphys && mac68k_vidphys < (sc->sc_basepa + length)) - videoaddr = sc->sc_handle + sc->sc_fbofs; /* XXX big ol' hack */ + videoaddr = sc->sc_handle.base + sc->sc_fbofs; /* XXX big ol' hack */ gm = &(sc->curr_mode); gm->mode_id = 0; @@ -306,7 +306,7 @@ grfiv_attach(parent, self, aux) gm->hres = 80; /* XXX Hack */ gm->vres = 80; /* XXX Hack */ gm->fbsize = gm->height * gm->rowbytes; - gm->fbbase = (caddr_t)sc->sc_handle; /* XXX yet another hack */ + gm->fbbase = (caddr_t)sc->sc_handle.base; /* XXX yet another hack */ gm->fboff = sc->sc_fbofs; /* Perform common video attachment. */ diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c index ae2deee1206..9893193d021 100644 --- a/sys/arch/mac68k/dev/grf_mv.c +++ b/sys/arch/mac68k/dev/grf_mv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grf_mv.c,v 1.25 2005/08/06 19:51:43 martin Exp $ */ +/* $OpenBSD: grf_mv.c,v 1.26 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: grf_nubus.c,v 1.62 2001/01/22 20:27:02 briggs Exp $ */ /* @@ -211,7 +211,7 @@ bad: gm->hres = image.hRes; gm->vres = image.vRes; gm->fbsize = gm->height * gm->rowbytes; - gm->fbbase = (caddr_t)sc->sc_regh; /* XXX evil hack */ + gm->fbbase = (caddr_t)(sc->sc_handle.base); /* XXX evil hack */ gm->fboff = image.offset; strncpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_regh, @@ -525,7 +525,7 @@ grfmv_intr_cb264(vsc) volatile char *slotbase; sc = (struct grfbus_softc *)vsc; - slotbase = (volatile char *)sc->sc_regh; /* XXX evil hack */ + slotbase = (volatile char *)(sc->sc_handle.base); /* XXX evil hack */ asm volatile(" movl %0,a0 movl a0@(0xff6028),d0 andl #0x2,d0 @@ -580,7 +580,7 @@ grfmv_intr_cb364(vsc) volatile char *slotbase; sc = (struct grfbus_softc *)vsc; - slotbase = (volatile char *)sc->sc_regh; /* XXX evil hack */ + slotbase = (volatile char *)(sc->sc_handle.base); /* XXX evil hack */ asm volatile(" movl %0,a0 movl a0@(0xfe6028),d0 andl #0x2,d0 diff --git a/sys/arch/mac68k/dev/if_ae.c b/sys/arch/mac68k/dev/if_ae.c index 08ffe9dfe18..95aa021cad6 100644 --- a/sys/arch/mac68k/dev/if_ae.c +++ b/sys/arch/mac68k/dev/if_ae.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ae.c,v 1.26 2005/08/05 14:22:21 martin Exp $ */ +/* $OpenBSD: if_ae.c,v 1.27 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: if_ae.c,v 1.62 1997/04/24 16:52:05 scottr Exp $ */ /* @@ -507,7 +507,8 @@ loop: * the NIC. */ bus_space_read_region_1(sc->sc_buft, sc->sc_bufh, - packet_ptr, &packet_hdr, sizeof(struct ae_ring)); + packet_ptr, (u_int8_t *)&packet_hdr, + sizeof(struct ae_ring)); lenp = (u_int8_t *)&packet_hdr.count; /* sigh. */ len = lenp[0] | (lenp[1] << 8); packet_hdr.count = len; @@ -1070,7 +1071,7 @@ ae_put(sc, m, buf) if (wantbyte) { savebyte[1] = *data; bus_space_write_region_2(sc->sc_buft, - sc->sc_bufh, buf, savebyte, 1); + sc->sc_bufh, buf, (u_int16_t *)savebyte, 1); buf += 2; data++; len--; @@ -1079,7 +1080,8 @@ ae_put(sc, m, buf) /* Output contiguous words. */ if (len > 1) { bus_space_write_region_2(sc->sc_buft, - sc->sc_bufh, buf, data, len >> 1); + sc->sc_bufh, buf, (u_int16_t *)data, + len >> 1); buf += len & ~1; data += len & ~1; len &= 1; @@ -1095,7 +1097,7 @@ ae_put(sc, m, buf) if (wantbyte) { savebyte[1] = 0; bus_space_write_region_2(sc->sc_buft, sc->sc_bufh, - buf, savebyte, 1); + buf, (u_int16_t *)savebyte, 1); } return (totlen); } diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index 54c85c55b60..83b277199ee 100644 --- a/sys/arch/mac68k/dev/if_sn.c +++ b/sys/arch/mac68k/dev/if_sn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn.c,v 1.37 2005/07/23 23:28:58 martin Exp $ */ +/* $OpenBSD: if_sn.c,v 1.38 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: if_sn.c,v 1.13 1997/04/25 03:40:10 briggs Exp $ */ /* @@ -1008,8 +1008,8 @@ sonicrxint(sc) len = SRO(bitmode, rda, RXPKT_BYTEC) - sizeof(struct ether_header) - FCSSIZE; if (status & RCR_PRX) { - caddr_t pkt = - sc->rbuf[orra & RBAMASK] + (rxpkt_ptr & PGOFSET); + caddr_t pkt = sc->rbuf[orra & RBAMASK] + + m68k_page_offset(rxpkt_ptr); if (sonic_read(sc, pkt, len)) sc->sc_if.if_ipackets++; else diff --git a/sys/arch/mac68k/dev/ncr5380.c b/sys/arch/mac68k/dev/ncr5380.c index 9ce6a12ed86..00c41d08d31 100644 --- a/sys/arch/mac68k/dev/ncr5380.c +++ b/sys/arch/mac68k/dev/ncr5380.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr5380.c,v 1.24 2004/01/13 21:15:06 miod Exp $ */ +/* $OpenBSD: ncr5380.c,v 1.25 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: ncr5380.c,v 1.38 1996/12/19 21:48:18 scottr Exp $ */ /* @@ -1790,7 +1790,7 @@ SC_REQ *reqp; */ dm->dm_addr = phy_buf = kvtop(req_addr); while (req_len) { - if (req_len < (phy_len = NBPG - ((u_long)req_addr & PGOFSET))) + if (req_len < (phy_len = NBPG - m68k_page_offset(req_addr))) phy_len = req_len; req_addr += phy_len; diff --git a/sys/arch/mac68k/include/bus.h b/sys/arch/mac68k/include/bus.h index df57512c318..8836c5aca29 100644 --- a/sys/arch/mac68k/include/bus.h +++ b/sys/arch/mac68k/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.8 2002/03/19 17:51:04 millert Exp $ */ +/* $OpenBSD: bus.h,v 1.9 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: bus.h,v 1.9 1998/01/13 18:32:15 scottr Exp $ */ /*- @@ -81,8 +81,95 @@ typedef u_long bus_size_t; /* * Access methods for bus resources and address space. */ +#define BSH_T struct bus_space_handle_s typedef int bus_space_tag_t; -typedef u_long bus_space_handle_t; +typedef struct bus_space_handle_s { + u_long base; + int swapped; + int stride; + + u_int8_t (*bsr1)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int16_t (*bsr2)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int32_t (*bsr4)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int8_t (*bsrs1)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int16_t (*bsrs2)(bus_space_tag_t, BSH_T *, bus_size_t); + u_int32_t (*bsrs4)(bus_space_tag_t, BSH_T *, bus_size_t); + void (*bsrm1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrm2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrm4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrms2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrms4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrr1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrr2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrr4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsrrs1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t *, size_t); + void (*bsrrs2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t *, size_t); + void (*bsrrs4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t *, size_t); + void (*bsw1)(bus_space_tag_t, BSH_T *, bus_size_t, u_int8_t); + void (*bsw2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t); + void (*bsw4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t); + void (*bsws1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t); + void (*bsws2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t); + void (*bsws4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t); + void (*bswm1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswm2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswm4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswms1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswms2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswms4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswr1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswr2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswr4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bswrs1)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int8_t *, size_t); + void (*bswrs2)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int16_t *, size_t); + void (*bswrs4)(bus_space_tag_t, BSH_T *, bus_size_t, + const u_int32_t *, size_t); + void (*bssm1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t v, size_t); + void (*bssm2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t v, size_t); + void (*bssm4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t v, size_t); + void (*bssr1)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int8_t v, size_t); + void (*bssr2)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int16_t v, size_t); + void (*bssr4)(bus_space_tag_t, BSH_T *, bus_size_t, + u_int32_t v, size_t); +} bus_space_handle_t; +#undef BSH_T + +void mac68k_bus_space_handle_swapped(bus_space_tag_t, + bus_space_handle_t *h); +void mac68k_bus_space_handle_set_stride(bus_space_tag_t t, + bus_space_handle_t *h, int stride); /* * int bus_space_map(bus_space_tag_t t, bus_addr_t addr, @@ -162,14 +249,29 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * described by tag/handle/offset. */ -#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)))) +u_int8_t mac68k_bsr1(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int8_t mac68k_bsr1_gen(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int16_t mac68k_bsr2(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int16_t mac68k_bsr2_swap(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int16_t mac68k_bsr2_gen(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int32_t mac68k_bsr4(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int32_t mac68k_bsr4_swap(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); +u_int32_t mac68k_bsr4_gen(bus_space_tag_t tag, bus_space_handle_t *bsh, + bus_size_t offset); + +#define bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o)) +#define bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o)) +#define bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o)) +#define bus_space_read_stream_1(t,h,o) (h).bsrs1((t), &(h), (o)) +#define bus_space_read_stream_2(t,h,o) (h).bsrs2((t), &(h), (o)) +#define bus_space_read_stream_4(t,h,o) (h).bsrs4((t), &(h), (o)) #if 0 /* Cause a link error for bus_space_read_8 */ #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! @@ -184,47 +286,32 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * described by tag/handle/offset and copy into buffer provided. */ -#define bus_space_read_multi_1(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movb a0@,a1@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_read_multi_2(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movw a0@,a1@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_read_multi_4(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movl a0@,a1@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); +void mac68k_bsrm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrms2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrms4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrms4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); + +#define bus_space_read_multi_1(t, h, o, a, c) (h).bsrm1(t, &(h), o, a, c) +#define bus_space_read_multi_2(t, h, o, a, c) (h).bsrm2(t, &(h), o, a, c) +#define bus_space_read_multi_4(t, h, o, a, c) (h).bsrm4(t, &(h), o, a, c) #if 0 /* Cause a link error for bus_space_read_multi_8 */ #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! @@ -240,47 +327,30 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * buffer provided. */ -#define bus_space_read_region_1(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movb a0@+,a1@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_read_region_2(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movw a0@+,a1@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_read_region_4(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movl a0@+,a1@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); +void mac68k_bsrr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t *, size_t); +void mac68k_bsrr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t *, size_t); +void mac68k_bsrr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); +void mac68k_bsrrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t *, size_t); + +#define bus_space_read_region_1(t, h, o, a, c) (h).bsrr1(t,&(h),o,a,c) +#define bus_space_read_region_2(t, h, o, a, c) (h).bsrr2(t,&(h),o,a,c) +#define bus_space_read_region_4(t, h, o, a, c) (h).bsrr4(t,&(h),o,a,c) #if 0 /* Cause a link error for bus_space_read_region_8 */ #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! @@ -295,14 +365,30 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * described by tag/handle/offset. */ -#define bus_space_write_1(t, h, o, v) \ - ((void) t, ((void)(*(volatile u_int8_t *)((h) + (o)) = (v)))) - -#define bus_space_write_2(t, h, o, v) \ - ((void) t, ((void)(*(volatile u_int16_t *)((h) + (o)) = (v)))) - -#define bus_space_write_4(t, h, o, v) \ - ((void) t, ((void)(*(volatile u_int32_t *)((h) + (o)) = (v)))) +void mac68k_bsw1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int8_t); +void mac68k_bsw1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int8_t); +void mac68k_bsw2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int16_t); +void mac68k_bsw2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsw2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsws2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int16_t); +void mac68k_bsw4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int32_t); +void mac68k_bsw4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); +void mac68k_bsw4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); +void mac68k_bsws4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + u_int32_t); + +#define bus_space_write_1(t, h, o, v) (h).bsw1(t, &(h), o, v) +#define bus_space_write_2(t, h, o, v) (h).bsw2(t, &(h), o, v) +#define bus_space_write_4(t, h, o, v) (h).bsw4(t, &(h), o, v) +#define bus_space_write_stream_1(t, h, o, v) (h).bsws1(t, &(h), o, v) +#define bus_space_write_stream_2(t, h, o, v) (h).bsws2(t, &(h), o, v) +#define bus_space_write_stream_4(t, h, o, v) (h).bsws4(t, &(h), o, v) #if 0 /* Cause a link error for bus_space_write_8 */ #define bus_space_write_8 !!! bus_space_write_8 not implemented !!! @@ -317,47 +403,30 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * provided to bus space described by tag/handle/offset. */ -#define bus_space_write_multi_1(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movb a1@+,a0@ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_write_multi_2(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movw a1@+,a0@ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_write_multi_4(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movl a1@+,a0@ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); +void mac68k_bswm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswm1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswms2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswm4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswms4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); + +#define bus_space_write_multi_1(t, h, o, a, c) (h).bswm1(t, &(h), o, a, c) +#define bus_space_write_multi_2(t, h, o, a, c) (h).bswm2(t, &(h), o, a, c) +#define bus_space_write_multi_4(t, h, o, a, c) (h).bswm4(t, &(h), o, a, c) #if 0 /* Cause a link error for bus_space_write_8 */ #define bus_space_write_multi_8(t, h, o, a, c) \ @@ -373,47 +442,30 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * to bus space described by tag/handle starting at `offset'. */ -#define bus_space_write_region_1(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movb a1@+,a0@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_write_region_2(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movw a1@+,a0@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); - -#define bus_space_write_region_4(t, h, o, a, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,a1 ; \ - movl %2,d0 ; \ - 1: movl a1@+,a0@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (a), "g" (c) : \ - "a0","a1","d0"); \ -} while (0); +void mac68k_bswr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswr1_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int8_t *, size_t); +void mac68k_bswr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswrs2_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int16_t *, size_t); +void mac68k_bswr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswr4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); +void mac68k_bswrs4_gen(bus_space_tag_t, bus_space_handle_t *, bus_size_t, + const u_int32_t *, size_t); + +#define bus_space_write_region_1(t, h, o, a, c) (h).bswr1(t, &(h), o, a, c) +#define bus_space_write_region_2(t, h, o, a, c) (h).bswr2(t, &(h), o, a, c) +#define bus_space_write_region_4(t, h, o, a, c) (h).bswr4(t, &(h), o, a, c) #if 0 /* Cause a link error for bus_space_write_region_8 */ #define bus_space_write_region_8 \ @@ -429,47 +481,26 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * by tag/handle/offset `count' times. */ -#define bus_space_set_multi_1(t, h, o, val, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,d1 ; \ - movl %2,d0 ; \ - 1: movb d1,a0@ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (val), "g" (c) : \ - "a0","d0","d1"); \ -} while (0); - -#define bus_space_set_multi_2(t, h, o, val, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,d1 ; \ - movl %2,d0 ; \ - 1: movw d1,a0@ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (val), "g" (c) : \ - "a0","d0","d1"); \ -} while (0); - -#define bus_space_set_multi_4(t, h, o, val, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,d1 ; \ - movl %2,d0 ; \ - 1: movl d1,a0@ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (val), "g" (c) : \ - "a0","d0","d1"); \ -} while (0); +void mac68k_bssm1(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int8_t v, size_t c); +void mac68k_bssm1_gen(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int8_t v, size_t c); +void mac68k_bssm2(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int16_t v, size_t c); +void mac68k_bssm2_swap(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int16_t v, size_t c); +void mac68k_bssm2_gen(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int16_t v, size_t c); +void mac68k_bssm4(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int32_t v, size_t c); +void mac68k_bssm4_swap(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int32_t v, size_t c); +void mac68k_bssm4_gen(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int32_t v, size_t c); + +#define bus_space_set_multi_1(t, h, o, val, c) (h).bssm1(t, &(h), o, val, c) +#define bus_space_set_multi_2(t, h, o, val, c) (h).bssm2(t, &(h), o, val, c) +#define bus_space_set_multi_4(t, h, o, val, c) (h).bssm4(t, &(h), o, val, c) #if 0 /* Cause a link error for bus_space_set_multi_8 */ #define bus_space_set_multi_8 \ @@ -485,47 +516,26 @@ int mac68k_bus_space_probe(bus_space_tag_t t, * by tag/handle starting at `offset'. */ -#define bus_space_set_region_1(t, h, o, val, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,d1 ; \ - movl %2,d0 ; \ - 1: movb d1,a0@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (val), "g" (c) : \ - "a0","d0","d1"); \ -} while (0); - -#define bus_space_set_region_2(t, h, o, val, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,d1 ; \ - movl %2,d0 ; \ - 1: movw d1,a0@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (val), "g" (c) : \ - "a0","d0","d1"); \ -} while (0); - -#define bus_space_set_region_4(t, h, o, val, c) do { \ - (void) t; \ - __asm __volatile (" \ - movl %0,a0 ; \ - movl %1,d1 ; \ - movl %2,d0 ; \ - 1: movl d1,a0@+ ; \ - subql #1,d0 ; \ - jne 1b" : \ - : \ - "r" ((h) + (o)), "g" (val), "g" (c) : \ - "a0","d0","d1"); \ -} while (0); +void mac68k_bssr1(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int8_t v, size_t c); +void mac68k_bssr1_gen(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int8_t v, size_t c); +void mac68k_bssr2(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int16_t v, size_t c); +void mac68k_bssr2_swap(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int16_t v, size_t c); +void mac68k_bssr2_gen(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int16_t v, size_t c); +void mac68k_bssr4(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int32_t v, size_t c); +void mac68k_bssr4_swap(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int32_t v, size_t c); +void mac68k_bssr4_gen(bus_space_tag_t t, bus_space_handle_t *h, + bus_size_t o, u_int32_t v, size_t c); + +#define bus_space_set_region_1(t, h, o, val, c) (h).bssr1(t, &(h), o, val, c) +#define bus_space_set_region_2(t, h, o, val, c) (h).bssr2(t, &(h), o, val, c) +#define bus_space_set_region_4(t, h, o, val, c) (h).bssr4(t, &(h), o, val, c) #if 0 /* Cause a link error for bus_space_set_region_8 */ #define bus_space_set_region_8 \ @@ -557,7 +567,7 @@ __CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c) \ { \ bus_size_t o; \ \ - if ((h1 + o1) >= (h2 + o2)) { \ + if ((h1.base + o1) >= (h2.base + o2)) { \ /* src after dest: copy forward */ \ for (o = 0; c != 0; c--, o += BYTES) \ __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ diff --git a/sys/arch/mac68k/mac68k/bus_space.c b/sys/arch/mac68k/mac68k/bus_space.c index 9a44bcddc4b..282c8476867 100644 --- a/sys/arch/mac68k/mac68k/bus_space.c +++ b/sys/arch/mac68k/mac68k/bus_space.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_space.c,v 1.17 2004/11/28 14:04:24 miod Exp $ */ +/* $OpenBSD: bus_space.c,v 1.18 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: bus_space.c,v 1.5 1999/03/26 23:41:30 mycroft Exp $ */ /*- @@ -169,7 +169,33 @@ bus_mem_add_mapping(bpa, size, flags, bshp) if (va == 0) return (ENOMEM); - *bshp = (bus_space_handle_t)(va + (bpa & PGOFSET)); + bshp->base = (u_long)(va + m68k_page_offset(bpa)); + bshp->swapped = 0; + bshp->stride = 1; + bshp->bsr1 = mac68k_bsr1; + bshp->bsr2 = mac68k_bsr2; + bshp->bsr4 = mac68k_bsr4; + bshp->bsrm1 = mac68k_bsrm1; + bshp->bsrm2 = mac68k_bsrm2; + bshp->bsrm4 = mac68k_bsrm4; + bshp->bsrr1 = mac68k_bsrr1; + bshp->bsrr2 = mac68k_bsrr2; + bshp->bsrr4 = mac68k_bsrr4; + bshp->bsw1 = mac68k_bsw1; + bshp->bsw2 = mac68k_bsw2; + bshp->bsw4 = mac68k_bsw4; + bshp->bswm1 = mac68k_bswm1; + bshp->bswm2 = mac68k_bswm2; + bshp->bswm4 = mac68k_bswm4; + bshp->bswr1 = mac68k_bswr1; + bshp->bswr2 = mac68k_bswr2; + bshp->bswr4 = mac68k_bswr4; + bshp->bssm1 = mac68k_bssm1; + bshp->bssm2 = mac68k_bssm2; + bshp->bssm4 = mac68k_bssm4; + bshp->bssr1 = mac68k_bssr1; + bshp->bssr2 = mac68k_bssr2; + bshp->bssr4 = mac68k_bssr4; for (; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { pmap_enter(pmap_kernel(), va, pa, @@ -196,8 +222,8 @@ bus_space_unmap(t, bsh, size) vaddr_t va, endva; bus_addr_t bpa; - va = m68k_trunc_page(bsh); - endva = m68k_round_page((bsh + size) - 1); + va = m68k_trunc_page(bsh.base); + endva = m68k_round_page((bsh.base + size) - 1); #ifdef DIAGNOSTIC if (endva <= va) @@ -205,7 +231,7 @@ bus_space_unmap(t, bsh, size) #endif pmap_extract(pmap_kernel(), va, &bpa); - bpa += (bsh & PGOFSET); + bpa += m68k_page_offset(bsh.base); /* * Free the kernel virtual mapping. @@ -237,8 +263,8 @@ bus_space_subregion(t, bsh, offset, size, nbshp) bus_size_t offset, size; bus_space_handle_t *nbshp; { - - *nbshp = bsh + offset; + *nbshp = bsh; + nbshp->base += offset; return (0); } @@ -277,3 +303,982 @@ mac68k_bus_space_probe(t, bsh, offset, sz) nofault = (label_t *)0; return (1); } + +void +mac68k_bus_space_handle_swapped(t, h) + bus_space_tag_t t; + bus_space_handle_t *h; +{ + h->swapped = 1; + if (h->stride == 1) { + h->bsr2 = mac68k_bsr2_swap; + h->bsr4 = mac68k_bsr4_swap; + h->bsrm2 = mac68k_bsrm2_swap; + h->bsrm4 = mac68k_bsrm4_swap; + h->bsrr2 = mac68k_bsrr2_swap; + h->bsrr4 = mac68k_bsrr4_swap; + h->bsw2 = mac68k_bsw2_swap; + h->bsw4 = mac68k_bsw4_swap; + h->bswm2 = mac68k_bswm2_swap; + h->bswm4 = mac68k_bswm4_swap; + h->bswr2 = mac68k_bswr2_swap; + h->bswr4 = mac68k_bswr4_swap; + h->bssm2 = mac68k_bssm2_swap; + h->bssm4 = mac68k_bssm4_swap; + h->bssr2 = mac68k_bssr2_swap; + h->bssr4 = mac68k_bssr4_swap; + } +} + +void +mac68k_bus_space_handle_set_stride(bus_space_tag_t t, bus_space_handle_t *h, + int stride) +{ + h->stride = stride; + h->bsr1 = mac68k_bsr1_gen; + h->bsr2 = mac68k_bsr2_gen; + h->bsr4 = mac68k_bsr4_gen; + h->bsrm1 = mac68k_bsrm1_gen; +h->bsrm2 = mac68k_bsrm2_gen; +h->bsrm4 = mac68k_bsrm4_gen; +h->bsrr1 = mac68k_bsrr1_gen; +h->bsrr2 = mac68k_bsrr2_gen; +h->bsrr4 = mac68k_bsrr4_gen; +h->bsw1 = mac68k_bsw1_gen; +h->bsw2 = mac68k_bsw2_gen; +h->bsw4 = mac68k_bsw4_gen; +h->bswm1 = mac68k_bswm1_gen; +h->bswm2 = mac68k_bswm2_gen; +h->bswm4 = mac68k_bswm4_gen; +h->bswr1 = mac68k_bswr1_gen; +h->bswr2 = mac68k_bswr2_gen; +h->bswr4 = mac68k_bswr4_gen; +h->bssm1 = mac68k_bssm1_gen; +h->bssm2 = mac68k_bssm2_gen; +h->bssm4 = mac68k_bssm4_gen; +h->bssr1 = mac68k_bssr1_gen; +h->bssr2 = mac68k_bssr2_gen; +h->bssr4 = mac68k_bssr4_gen; +} + +u_int8_t +mac68k_bsr1(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + return (*(volatile u_int8_t *) (bsh->base + offset)); +} + +u_int8_t +mac68k_bsr1_gen(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + return (*(volatile u_int8_t *) (bsh->base + offset * bsh->stride)); +} + +u_int16_t +mac68k_bsr2(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + return (*(volatile u_int16_t *) (bsh->base + offset)); +} + +u_int16_t +mac68k_bsr2_swap(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + u_int16_t v; + + v = (*(volatile u_int16_t *) (bsh->base + offset)); + return swap16(v); +} + +u_int16_t +mac68k_bsr2_gen(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + u_int16_t v; + + v = (*(volatile u_int8_t *) (bsh->base + offset++ * bsh->stride)) << 8; + v |= (*(volatile u_int8_t *) (bsh->base + offset * bsh->stride)); + if (bsh->swapped) { + swap16(v); + } + return v; +} + +u_int32_t +mac68k_bsr4(bus_space_tag_t tag, bus_space_handle_t *bsh, bus_size_t offset) +{ + return (*(volatile u_int32_t *) (bsh->base + offset)); +} + +u_int32_t +mac68k_bsr4_swap(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + u_int32_t v; + + v = (*(volatile u_int32_t *) (bsh->base + offset)); + return swap32(v); +} + +u_int32_t +mac68k_bsr4_gen(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) +{ + u_int32_t v; + + v = (*(volatile u_int8_t *) (bsh->base + offset++ * bsh->stride)); + v <<= 8; + v |= (*(volatile u_int8_t *) (bsh->base + offset++ * bsh->stride)); + v <<= 8; + v |= (*(volatile u_int8_t *) (bsh->base + offset++ * bsh->stride)); + v <<= 8; + v |= (*(volatile u_int8_t *) (bsh->base + offset++ * bsh->stride)); + if (bsh->swapped) { + v = swap32(v); + } + return v; +} + +void +mac68k_bsrm1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movb a0@,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrm1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_1(t, *h, offset); + } +} + +void +mac68k_bsrm2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a0@,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrm2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a0@,d1 ;" + " rolw #8,d1 ;" + " movw d1,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bsrm2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_2(t, *h, offset); + } +} + +void +mac68k_bsrms2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_stream_2(t, *h, offset); + } +} + +void +mac68k_bsrm4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,%d0 ;" + "1: movl a0@,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrm4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a0@,d1 ;" + " rolw #8,d1 ;" + " swap d1 ;" + " rolw #8,d1 ;" + " movl d1,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bsrm4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_4(t, *h, offset); + } +} + +void +mac68k_bsrms4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_stream_4(t, *h, offset); + } +} + +void +mac68k_bsrr1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movb a0@+,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrr1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_1(t, *h, offset); + offset++; + } +} + +void +mac68k_bsrr2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a0@+,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrr2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a0@+,d1 ;" + " rolw #8,d1 ;" + " movw d1,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bsrr2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_2(t, *h, offset); + offset += 2; + } +} + +void +mac68k_bsrrs2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_stream_2(t, *h, offset); + offset += 2; + } +} + +void +mac68k_bsrr4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a0@+,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrr4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a0@+,d1 ;" + " rolw #8,d1 ;" + " swap d1 ;" + " rolw #8,d1 ;" + " movl d1,a1@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bsrr4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_4(t, *h, offset); + offset += 4; + } +} + +void +mac68k_bsrrs4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t *a, size_t c) +{ + while (c--) { + *a++ = bus_space_read_stream_4(t, *h, offset); + offset += 4; + } +} + +void +mac68k_bsw1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t v) +{ + (*(volatile u_int8_t *)(h->base + offset)) = v; +} + +void +mac68k_bsw1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t v) +{ + (*(volatile u_int8_t *)(h->base + offset * h->stride)) = v; +} + +void +mac68k_bsw2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v) +{ + (*(volatile u_int16_t *)(h->base + offset)) = v; +} + +void +mac68k_bsw2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v) +{ + v = swap16(v); + (*(volatile u_int16_t *)(h->base + offset)) = v; +} + +void +mac68k_bsws2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v) +{ + u_int8_t v1; + + v1 = (v & 0xff00) >> 8; + (*(volatile u_int8_t *)(h->base + offset++ * h->stride)) = v1; + (*(volatile u_int8_t *)(h->base + offset * h->stride)) = v & 0xff; +} + +void +mac68k_bsw2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v) +{ + if (h->swapped) { + v = swap16(v); + } + mac68k_bsws2_gen(t, h, offset, v); +} + +void +mac68k_bsw4(bus_space_tag_t tag, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v) +{ + (*(volatile u_int32_t *)(h->base + offset)) = v; +} + +void +mac68k_bsw4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v) +{ + v = swap32(v); + (*(volatile u_int32_t *)(h->base + offset)) = v; +} + +void +mac68k_bsws4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v) +{ + u_int8_t v1,v2,v3; + + v1 = (v & 0xff000000) >> 24; + v2 = (v & 0x00ff0000) >> 16; + v3 = (v & 0x0000ff00) >> 8; + (*(volatile u_int8_t *)(h->base + offset++ * h->stride)) = v1; + (*(volatile u_int8_t *)(h->base + offset++ * h->stride)) = v2; + (*(volatile u_int8_t *)(h->base + offset++ * h->stride)) = v3; + (*(volatile u_int8_t *)(h->base + offset * h->stride)) = v & 0xff; +} + +void +mac68k_bsw4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v) +{ + if (h->swapped) { + v = swap32(v); + } + mac68k_bsws4_gen(t, h, offset, v); +} + +void +mac68k_bswm1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int8_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movb a1@+,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bswm1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int8_t *a, size_t c) +{ + while (c--) { + bus_space_write_1(t, *h, offset, *a++); + } +} + +void +mac68k_bswm2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a1@+,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bswm2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a1@+,d1 ;" + " rolw #8,d1 ;" + " movw d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bswm2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + while (c--) { + bus_space_write_2(t, *h, offset, *a++); + } +} + +void +mac68k_bswms2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + while (c--) { + bus_space_write_stream_2(t, *h, offset, *a++); + } +} + +void +mac68k_bswm4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a1@+,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bswm4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a1@+,d1 ;" + " rolw #8,d1 ;" + " swap d1 ;" + " rolw #8,d1 ;" + " movl d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bswm4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + while (c--) { + bus_space_write_4(t, *h, offset, *a++); + } +} + +void +mac68k_bswms4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + while (c--) { + bus_space_write_stream_4(t, *h, offset, *a++); + } +} + +void +mac68k_bswr1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int8_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movb a1@+,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bswr1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int8_t *a, size_t c) +{ + while (c--) { + bus_space_write_1(t, *h, offset, *a++); + offset++; + } +} + +void +mac68k_bswr2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a1@+,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bswr2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movw a1@+,d1 ;" + " rolw #8,d1 ;" + " movw d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bswr2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + while (c--) { + bus_space_write_2(t, *h, offset, *a++); + offset += 2; + } +} + +void +mac68k_bswrs2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int16_t *a, size_t c) +{ + while (c--) { + bus_space_write_stream_2(t, *h, offset, *a++); + offset += 2; + } +} + +void +mac68k_bswr4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a1@+,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0"); +} + +void +mac68k_bswr4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,a1 ;" + " movl %2,d0 ;" + "1: movl a1@+,d1 ;" + " rolw #8,d1 ;" + " swap d1 ;" + " rolw #8,d1 ;" + " movl d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" (a), "g" (c) : + "a0","a1","d0","d1"); +} + +void +mac68k_bswr4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + while (c--) { + bus_space_write_4(t, *h, offset, *a++); + offset += 4; + } +} + +void +mac68k_bswrs4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + const u_int32_t *a, size_t c) +{ + while (c--) { + bus_space_write_4(t, *h, offset, *a++); + offset += 4; + } +} + +void +mac68k_bssm1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " movl %2,d0 ;" + "1: movb d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssm1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t v, size_t c) +{ + while (c--) { + bus_space_write_1(t, *h, offset, v); + } +} + +void +mac68k_bssm2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " movl %2,d0 ;" + "1: movw d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssm2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " rolw #8,d1 ;" + " movl %2,d0 ;" + "1: movw d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssm2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v, size_t c) +{ + while (c--) { + bus_space_write_2(t, *h, offset, v); + } +} + +void +mac68k_bssm4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " movl %2,d0 ;" + "1: movl d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssm4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " rolw #8,d1 ;" + " swap d1 ;" + " rolw #8,d1 ;" + " movl %2,d0 ;" + "1: movl d1,a0@ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssm4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v, size_t c) +{ + while (c--) { + bus_space_write_4(t, *h, offset, v); + } +} + +void +mac68k_bssr1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " movl %2,d0 ;" + "1: movb d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssr1_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int8_t v, size_t c) +{ + while (c--) { + bus_space_write_1(t, *h, offset, v); + offset++; + } +} + +void +mac68k_bssr2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " movl %2,d0 ;" + "1: movw d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssr2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " rolw #8,d1 ;" + " movl %2,d0 ;" + "1: movw d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssr2_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int16_t v, size_t c) +{ + while (c--) { + bus_space_write_2(t, *h, offset, v); + offset += 2; + } +} + +void +mac68k_bssr4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " movl %2,d0 ;" + "1: movl d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssr4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v, size_t c) +{ + __asm __volatile ( + " movl %0,a0 ;" + " movl %1,d1 ;" + " rolw #8,d1 ;" + " swap d1 ;" + " rolw #8,d1 ;" + " movl %2,d0 ;" + "1: movl d1,a0@+ ;" + " subql #1,d0 ;" + " jne 1b" : + : + "r" (h->base + offset), "g" ((u_long)v), "g" (c) : + "a0","d0","d1"); +} + +void +mac68k_bssr4_gen(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, + u_int32_t v, size_t c) +{ + while (c--) { + bus_space_write_4(t, *h, offset, v); + offset += 4; + } +} diff --git a/sys/arch/mac68k/mac68k/mem.c b/sys/arch/mac68k/mac68k/mem.c index 63c0f055746..58474aa8d5a 100644 --- a/sys/arch/mac68k/mac68k/mem.c +++ b/sys/arch/mac68k/mac68k/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.18 2003/06/02 23:27:49 millert Exp $ */ +/* $OpenBSD: mem.c,v 1.19 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: mem.c,v 1.22 1999/03/27 00:30:07 mycroft Exp $ */ /* @@ -144,7 +144,7 @@ mmrw(dev, uio, flags) pmap_enter(pmap_kernel(), (vaddr_t)vmmap, trunc_page(v), prot, prot|PMAP_WIRED); pmap_update(pmap_kernel()); - o = uio->uio_offset & PGOFSET; + o = m68k_page_offset(uio->uio_offset); c = min(uio->uio_resid, (int)(NBPG - o)); error = uiomove((caddr_t)vmmap + o, c, uio); pmap_remove(pmap_kernel(), (vaddr_t)vmmap, diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c index 5533ad6a0f9..94a94a29568 100644 --- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c +++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.31 2005/08/06 19:51:44 martin Exp $ */ +/* $OpenBSD: pmap_bootstrap.c,v 1.32 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: pmap_bootstrap.c,v 1.50 1999/04/07 06:14:33 scottr Exp $ */ /* @@ -121,7 +121,7 @@ extern caddr_t kernel_start; int i; \ \ vidlen = round_page(((videosize >> 16) & 0xffff) * videorowbytes + \ - (mac68k_vidphys & PGOFSET)); + m68k_page_offset(mac68k_vidphys)); #define PMAP_MD_RELOC1() \ do { \ @@ -149,7 +149,7 @@ do { \ if (vidlen != 0) { \ pte = PA2VA(vidpa, u_int *); \ epte = pte + VIDMAPSIZE; \ - protopte = (mac68k_vidphys & ~PGOFSET) | \ + protopte = m68k_trunc_page(mac68k_vidphys) | \ PG_RW | PG_V | PG_CI; \ while (pte < epte) { \ *pte++ = protopte; \ @@ -164,7 +164,7 @@ do { \ ROMBase = (char *)(iiobase + m68k_ptob(IIOMAPSIZE)); \ if (vidlen != 0) { \ newvideoaddr = iiobase + m68k_ptob(IIOMAPSIZE + ROMMAPSIZE) \ - + (mac68k_vidphys & PGOFSET); \ + + m68k_page_offset(mac68k_vidphys); \ } \ } while (0) diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index 5b313ae4982..8569e020657 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.44 2005/07/31 15:37:51 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.45 2005/09/12 10:07:29 martin Exp $ */ /* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ /* @@ -710,7 +710,7 @@ writeback(fp, docachepush) trunc_page((vaddr_t)f->f_fa), VM_PROT_WRITE, VM_PROT_WRITE|PMAP_WIRED); pmap_update(pmap_kernel()); - fa = (u_int)&vmmap[(f->f_fa & PGOFSET) & ~0xF]; + fa = (u_int)&vmmap[m68k_page_offset(f->f_fa) & ~0xF]; bcopy((caddr_t)&f->f_pd0, (caddr_t)fa, 16); pmap_extract(pmap_kernel(), (vaddr_t)fa, &pa); DCFL(pa); |