diff options
-rw-r--r-- | sys/arch/sparc/dev/stp_sbus.c | 7 | ||||
-rw-r--r-- | sys/arch/sparc/dev/ts102.c | 19 | ||||
-rw-r--r-- | sys/arch/sparc/include/bus.h | 94 | ||||
-rw-r--r-- | sys/dev/ic/if_wireg.h | 4 |
4 files changed, 80 insertions, 44 deletions
diff --git a/sys/arch/sparc/dev/stp_sbus.c b/sys/arch/sparc/dev/stp_sbus.c index e22391c17fb..79cdc9cd3ee 100644 --- a/sys/arch/sparc/dev/stp_sbus.c +++ b/sys/arch/sparc/dev/stp_sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stp_sbus.c,v 1.1 2003/06/23 09:27:55 miod Exp $ */ +/* $OpenBSD: stp_sbus.c,v 1.2 2003/06/25 17:39:00 miod Exp $ */ /* $NetBSD: stp4020.c,v 1.23 2002/06/01 23:51:03 lukem Exp $ */ /*- @@ -65,6 +65,7 @@ struct stp4020_sbus_softc { struct stp4020_softc stp; struct sbusdev sc_sd; /* SBus device */ struct rom_reg sc_reg; + struct rom_reg sc_reg_le; /* rev. copy for pcmcia bus_space access */ struct intrhand sc_ih[2]; }; @@ -105,6 +106,8 @@ stpattach(parent, self, aux) /* Transfer bus tags */ ssc->sc_reg = ca->ca_ra.ra_reg[0]; + ssc->sc_reg_le = ca->ca_ra.ra_reg[0]; + SET_TAG_LITTLE_ENDIAN(&ssc->sc_reg_le); sc->sc_bustag = &ssc->sc_reg; /* Set up per-socket static initialization */ @@ -153,9 +156,11 @@ stpattach(parent, self, aux) } else if (i < STP4020_BANK_CTRL) { /* banks 1-3 */ sc->sc_socks[0].windows[i-1].winaddr = bh; + sc->sc_socks[0].wintag = &ssc->sc_reg_le; } else { /* banks 5-7 */ sc->sc_socks[1].windows[i-5].winaddr = bh; + sc->sc_socks[1].wintag = &ssc->sc_reg_le; } } diff --git a/sys/arch/sparc/dev/ts102.c b/sys/arch/sparc/dev/ts102.c index 678b4a7f119..926f7fbe9f4 100644 --- a/sys/arch/sparc/dev/ts102.c +++ b/sys/arch/sparc/dev/ts102.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts102.c,v 1.3 2003/06/24 22:55:43 miod Exp $ */ +/* $OpenBSD: ts102.c,v 1.4 2003/06/25 17:39:00 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * @@ -123,6 +123,7 @@ struct tslot_data { struct device *td_pcmcia; volatile u_int8_t *td_regs; + struct rom_reg td_rr; vaddr_t td_space[TS102_RANGE_CNT]; /* Interrupt handler */ @@ -230,7 +231,6 @@ tslot_attach(struct device *parent, struct device *self, void *args) struct confargs *ca = args; struct tslot_softc *sc = (struct tslot_softc *)self; struct romaux *ra; - struct rom_reg reg; struct rom_range ranges[TS102_NUM_RANGES], *range; struct tslot_data *td; volatile u_int8_t *regs; @@ -283,17 +283,18 @@ tslot_attach(struct device *parent, struct device *self, void *args) td = &sc->sc_slot[slot]; for (rnum = 0; rnum < TS102_RANGE_CNT; rnum++) { range = ranges + (slot * TS102_RANGE_CNT + rnum); - reg = ra->ra_reg[0]; - reg.rr_iospace = range->pspace; - reg.rr_paddr = (void *) - ((u_int32_t)reg.rr_paddr + range->poffset); - td->td_space[rnum] = (vaddr_t)mapiodev(®, 0, + td->td_rr = ra->ra_reg[0]; + td->td_rr.rr_iospace = range->pspace; + td->td_rr.rr_paddr = (void *) + ((u_int32_t)td->td_rr.rr_paddr + range->poffset); + td->td_space[rnum] = (vaddr_t)mapiodev(&td->td_rr, 0, TS102_ARBITRARY_MAP_SIZE); } td->td_parent = sc; td->td_regs = regs + slot * (TS102_REG_CARD_B_INT - TS102_REG_CARD_A_INT); td->td_slot = slot; + SET_TAG_LITTLE_ENDIAN(&td->td_rr); tslot_reset(td, TS102_ARBITRARY_MAP_SIZE); } } @@ -407,7 +408,7 @@ tslot_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset, printf("[io map %x-%x", offset, size); #endif - pih->iot = 0; + pih->iot = &td->td_rr; pih->ioh = (bus_space_handle_t)(td->td_space[TS102_RANGE_IO]); *windowp = TS102_RANGE_IO; @@ -465,7 +466,7 @@ tslot_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t addr, addr += pmh->addr; - pmh->memt = 0; + pmh->memt = &td->td_rr; pmh->memh = (bus_space_handle_t)(td->td_space[slot] + addr); pmh->realsize = TS102_ARBITRARY_MAP_SIZE - addr; *offsetp = 0; diff --git a/sys/arch/sparc/include/bus.h b/sys/arch/sparc/include/bus.h index d691fb176de..b37786899ed 100644 --- a/sys/arch/sparc/include/bus.h +++ b/sys/arch/sparc/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.3 2003/06/25 00:02:56 mickey Exp $ */ +/* $OpenBSD: bus.h,v 1.4 2003/06/25 17:39:00 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * @@ -47,8 +47,20 @@ #include <machine/pmap.h> typedef u_int32_t bus_space_handle_t; + +/* + * bus_space_tag_t are pointer to *modified* rom_reg structures. + * rr_iospace is used to also carry bus endianness information. + */ typedef struct rom_reg *bus_space_tag_t; +#define TAG_LITTLE_ENDIAN 0x80000000 + +#define SET_TAG_BIG_ENDIAN(t) ((t))->rr_iospace &= ~TAG_LITTLE_ENDIAN +#define SET_TAG_LITTLE_ENDIAN(t) ((t))->rr_iospace |= TAG_LITTLE_ENDIAN + +#define IS_TAG_LITTLE_ENDIAN(t) ((t)->rr_iospace & TAG_LITTLE_ENDIAN) + typedef u_int32_t bus_addr_t; typedef u_int32_t bus_size_t; @@ -71,7 +83,7 @@ static __inline__ int bus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size, int flags, bus_space_handle_t *handle) { - if ((*handle = (bus_space_handle_t)mapiodev((struct rom_reg *)tag, + if ((*handle = (bus_space_handle_t)mapiodev(tag, addr, size)) != NULL) return (0); @@ -101,7 +113,13 @@ bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t handle, static __inline__ void * bus_space_vaddr(bus_space_tag_t tag, bus_space_handle_t handle) { - return (void *)(REG2PHYS((struct rom_reg *)tag, 0) | PMAP_NC); + u_int32_t iospace = tag->rr_iospace; + void *rc; + + tag->rr_iospace &= ~TAG_LITTLE_ENDIAN; + rc = (void *)(REG2PHYS(tag, 0) | PMAP_NC); + tag->rr_iospace = iospace; + return (rc); } static __inline__ int @@ -120,12 +138,18 @@ bus_space_subregion(bus_space_tag_t tag, bus_space_handle_t handle, #define bus_space_read_1(tag, handle, offset) \ ((void)(tag), *(volatile u_int8_t *)((handle) + (offset))) - +#define __bus_space_read_2(tag, handle, offset) \ + *(volatile u_int16_t *)((handle) + (offset)) +#define __bus_space_read_4(tag, handle, offset) \ + *(volatile u_int32_t *)((handle) + (offset)) #define bus_space_read_2(tag, handle, offset) \ - ((void)(tag), *(volatile u_int16_t *)((handle) + (offset))) - + ((IS_TAG_LITTLE_ENDIAN(tag)) ? \ + letoh16(__bus_space_read_2(tag, handle, offset)) : \ + __bus_space_read_2(tag, handle, offset)) #define bus_space_read_4(tag, handle, offset) \ - ((void)(tag), *(volatile u_int32_t *)((handle) + (offset))) + ((IS_TAG_LITTLE_ENDIAN(tag)) ? \ + letoh32(__bus_space_read_4(tag, handle, offset)) : \ + __bus_space_read_4(tag, handle, offset)) static void bus_space_read_multi_1(bus_space_tag_t, bus_space_handle_t, bus_addr_t, u_int8_t *, size_t); @@ -169,7 +193,8 @@ bus_space_read_raw_multi_2(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 1; while ((int)--size >= 0) { - *(u_int16_t *)dest = bus_space_read_2(tag, handle, offset); + *(u_int16_t *)dest = + __bus_space_read_2(tag, handle, offset); dest += 2; } } @@ -183,19 +208,24 @@ bus_space_read_raw_multi_4(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 2; while ((int)--size >= 0) { - *(u_int32_t *)dest = bus_space_read_4(tag, handle, offset); + *(u_int32_t *)dest = + __bus_space_read_4(tag, handle, offset); dest += 4; } } #define bus_space_write_1(tag, handle, offset, value) \ ((void)(tag), *(volatile u_int8_t *)((handle) + (offset)) = (value)) - +#define __bus_space_write_2(tag, handle, offset, value) \ + *(volatile u_int16_t *)((handle) + (offset)) = (value) +#define __bus_space_write_4(tag, handle, offset, value) \ + *(volatile u_int32_t *)((handle) + (offset)) = (value) #define bus_space_write_2(tag, handle, offset, value) \ - ((void)(tag), *(volatile u_int16_t *)((handle) + (offset)) = (value)) - + __bus_space_write_2(tag, handle, offset, \ + (IS_TAG_LITTLE_ENDIAN(tag)) ? htole16(value) : (value)) #define bus_space_write_4(tag, handle, offset, value) \ - ((void)(tag), *(volatile u_int32_t *)((handle) + (offset)) = (value)) + __bus_space_write_4(tag, handle, offset, \ + (IS_TAG_LITTLE_ENDIAN(tag)) ? htole32(value) : (value)) static void bus_space_write_multi_1(bus_space_tag_t, bus_space_handle_t, bus_addr_t, u_int8_t *, size_t); @@ -239,7 +269,8 @@ bus_space_write_raw_multi_2(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 1; while ((int)--size >= 0) { - bus_space_write_2(tag, handle, offset, *(u_int16_t *)dest); + __bus_space_write_2(tag, handle, offset, + *(u_int16_t *)dest); dest += 2; } } @@ -253,7 +284,8 @@ bus_space_write_raw_multi_4(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 2; while ((int)--size >= 0) { - bus_space_write_4(tag, handle, offset, *(u_int32_t *)dest); + __bus_space_write_4(tag, handle, offset, + *(u_int32_t *)dest); dest += 4; } } @@ -263,10 +295,10 @@ static void bus_space_set_multi_1(bus_space_tag_t, bus_space_handle_t, static __inline__ void bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t handle, - bus_addr_t offset, u_int8_t dest, size_t count) + bus_addr_t offset, u_int8_t value, size_t count) { while ((int)--count >= 0) - bus_space_write_1(tag, handle, offset, dest); + bus_space_write_1(tag, handle, offset, value); } static void bus_space_set_multi_2(bus_space_tag_t, bus_space_handle_t, @@ -274,10 +306,10 @@ static void bus_space_set_multi_2(bus_space_tag_t, bus_space_handle_t, static __inline__ void bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t handle, - bus_addr_t offset, u_int16_t dest, size_t count) + bus_addr_t offset, u_int16_t value, size_t count) { while ((int)--count >= 0) - bus_space_write_2(tag, handle, offset, dest); + bus_space_write_2(tag, handle, offset, value); } static void bus_space_set_multi_4(bus_space_tag_t, bus_space_handle_t, @@ -285,10 +317,10 @@ static void bus_space_set_multi_4(bus_space_tag_t, bus_space_handle_t, static __inline__ void bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t handle, - bus_addr_t offset, u_int32_t dest, size_t count) + bus_addr_t offset, u_int32_t value, size_t count) { while ((int)--count >= 0) - bus_space_write_4(tag, handle, offset, dest); + bus_space_write_4(tag, handle, offset, value); } static void bus_space_write_region_1(bus_space_tag_t, bus_space_handle_t, @@ -337,7 +369,7 @@ bus_space_write_raw_region_2(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 1; while ((int)--size >= 0) { - bus_space_write_2(tag, handle, offset, *(u_int16_t *)dest); + __bus_space_write_2(tag, handle, offset, *(u_int16_t *)dest); offset += 2; dest += 2; } @@ -352,7 +384,7 @@ bus_space_write_raw_region_4(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 2; while ((int)--size >= 0) { - bus_space_write_4(tag, handle, offset, *(u_int32_t *)dest); + __bus_space_write_4(tag, handle, offset, *(u_int32_t *)dest); offset += 4; dest += 4; } @@ -400,10 +432,10 @@ static void bus_space_set_region_1(bus_space_tag_t, bus_space_handle_t, static __inline__ void bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t handle, - bus_addr_t offset, u_int8_t dest, size_t count) + bus_addr_t offset, u_int8_t value, size_t count) { while ((int)--count >= 0) - bus_space_write_1(tag, handle, offset++, dest); + bus_space_write_1(tag, handle, offset++, value); } static void bus_space_set_region_2(bus_space_tag_t, bus_space_handle_t, @@ -411,10 +443,10 @@ static void bus_space_set_region_2(bus_space_tag_t, bus_space_handle_t, static __inline__ void bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t handle, - bus_addr_t offset, u_int16_t dest, size_t count) + bus_addr_t offset, u_int16_t value, size_t count) { while ((int)--count >= 0) { - bus_space_write_2(tag, handle, offset, dest); + bus_space_write_2(tag, handle, offset, value); offset += 2; } } @@ -424,10 +456,10 @@ static void bus_space_set_region_4(bus_space_tag_t, bus_space_handle_t, static __inline__ void bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t handle, - bus_addr_t offset, u_int32_t dest, size_t count) + bus_addr_t offset, u_int32_t value, size_t count) { while ((int)--count >= 0) { - bus_space_write_4(tag, handle, offset, dest); + bus_space_write_4(tag, handle, offset, value); offset += 4; } } @@ -441,7 +473,7 @@ bus_space_read_raw_region_2(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 1; while ((int)--size >= 0) { - *(u_int16_t *)dest = bus_space_read_2(tag, handle, offset); + *(u_int16_t *)dest = __bus_space_read_2(tag, handle, offset); offset += 2; dest += 2; } @@ -456,7 +488,7 @@ bus_space_read_raw_region_4(bus_space_tag_t tag, bus_space_handle_t handle, { size >>= 2; while ((int)--size >= 0) { - *(u_int32_t *)dest = bus_space_read_4(tag, handle, offset); + *(u_int32_t *)dest = __bus_space_read_4(tag, handle, offset); offset += 4; dest += 4; } diff --git a/sys/dev/ic/if_wireg.h b/sys/dev/ic/if_wireg.h index db9144209db..8fb60205cd5 100644 --- a/sys/dev/ic/if_wireg.h +++ b/sys/dev/ic/if_wireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wireg.h,v 1.31 2003/01/10 22:10:19 millert Exp $ */ +/* $OpenBSD: if_wireg.h,v 1.32 2003/06/25 17:38:55 miod Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -82,8 +82,6 @@ #if defined(__sparc64__) #define WI_BIG_ENDIAN_POSSIBLE (sc->wi_flags & WI_FLAGS_BUS_PCMCIA) -#elif defined(__sparc__) -#define WI_BIG_ENDIAN_POSSIBLE 1 #else #define WI_BIG_ENDIAN_POSSIBLE 0 #endif |