diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1998-10-05 09:58:22 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1998-10-05 09:58:22 +0000 |
commit | 340ef50f8afaf2acb98f93fc6f701292e00d0af4 (patch) | |
tree | c305c9a807558f9eed88d57e981fe3e2add70f14 /sys/arch/amiga/include/bus.h | |
parent | 5e187a86c35435598995f45c4f1bb4d3e711e053 (diff) |
Update the API to be more compatibe with NetBSD, but also add new extensions:
bus_sapce_{read,write}_raw_region_[248] a la the raw_multi variants. These
last ones are not yet used.
Diffstat (limited to 'sys/arch/amiga/include/bus.h')
-rw-r--r-- | sys/arch/amiga/include/bus.h | 109 |
1 files changed, 93 insertions, 16 deletions
diff --git a/sys/arch/amiga/include/bus.h b/sys/arch/amiga/include/bus.h index a4783578a80..4eeb17b2592 100644 --- a/sys/arch/amiga/include/bus.h +++ b/sys/arch/amiga/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.7 1998/03/26 12:45:00 niklas Exp $ */ +/* $OpenBSD: bus.h,v 1.8 1998/10/05 09:58:21 niklas Exp $ */ /* * Copyright (c) 1996 Niklas Hallqvist. @@ -62,7 +62,7 @@ struct amiga_bus_space { /* We need swapping of 16-bit entities */ int bs_swapped; - /* How much to shift an bus_addr_t */ + /* How much to shift an bus_size_t */ int bs_shift; }; @@ -72,13 +72,21 @@ struct amiga_bus_space { (*(t)->bs_unmap)((t), (bshp), (size)) static __inline u_int8_t -bus_space_read_1(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba) +bus_space_subregion(bus_space_tag_t bst, bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp) +{ + *nbshp = bsh + (offset << bst->bs_shift); + return (0); +} + +static __inline u_int8_t +bus_space_read_1(bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t ba) { return *(volatile u_int8_t *)(bsh + (ba << bst->bs_shift)); } static __inline u_int16_t -bus_space_read_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba) +bus_space_read_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t ba) { u_int16_t x = *(volatile u_int16_t *)((bsh & ~1) + (ba << bst->bs_shift)); @@ -87,7 +95,7 @@ bus_space_read_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba) } static __inline u_int32_t -bus_space_read_4(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba) +bus_space_read_4(bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t ba) { panic("bus_space_read_4: operation not allowed on this bus (tag %x)", bst); @@ -99,7 +107,7 @@ bus_space_read_4(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba) #define bus_space_read_multi(n, m) \ static __inline void \ CAT(bus_space_read_multi_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ - bus_addr_t ba, CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ + bus_size_t ba, CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ { \ while (cnt--) \ *buf++ = CAT(bus_space_read_,n)(bst, bsh, ba); \ @@ -114,7 +122,7 @@ bus_space_read_multi(4,32) #define bus_space_read_region(n, m) \ static __inline void \ CAT(bus_space_read_region_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ - bus_addr_t ba, CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ + bus_size_t ba, CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ { \ while (cnt--) { \ *buf++ = CAT(bus_space_read_,n)(bst, bsh, ba); \ @@ -129,14 +137,14 @@ bus_space_read_region(4,32) #define bus_space_read_region_8 !!! bus_space_read_region_8 not implemented !!! static __inline void -bus_space_write_1(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba, +bus_space_write_1(bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t ba, u_int8_t x) { *(volatile u_int8_t *)(bsh + (ba << bst->bs_shift)) = x; } static __inline void -bus_space_write_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba, +bus_space_write_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t ba, u_int16_t x) { *(volatile u_int16_t *)((bsh & ~1) + (ba << bst->bs_shift)) = @@ -144,7 +152,7 @@ bus_space_write_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba, } static __inline void -bus_space_write_4(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba, +bus_space_write_4(bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t ba, u_int32_t x) { panic("bus_space_write_4: operation not allowed on this bus (tag %x)", @@ -156,7 +164,7 @@ bus_space_write_4(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba, #define bus_space_write_multi(n, m) \ static __inline void \ CAT(bus_space_write_multi_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ - bus_addr_t ba, const CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ + bus_size_t ba, const CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ { \ while (cnt--) \ CAT(bus_space_write_,n)(bst, bsh, ba, *buf++); \ @@ -171,7 +179,7 @@ bus_space_write_multi(4,32) #define bus_space_write_region(n, m) \ static __inline void \ CAT(bus_space_write_region_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ - bus_addr_t ba, const CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ + bus_size_t ba, const CAT3(u_int,m,_t) *buf, bus_size_t cnt) \ { \ while (cnt--) { \ CAT(bus_space_write_,n)(bst, bsh, ba, *buf++); \ @@ -186,10 +194,26 @@ bus_space_write_region(4,32) #define bus_space_write_region_8 \ !!! bus_space_write_region_8 not implemented !!! +#define bus_space_set_region(n, m) \ +static __inline void \ +CAT(bus_space_set_region_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ + bus_size_t bs, CAT3(u_int,m,_t) val, size_t count) \ +{ \ + while (count--) \ + CAT(bus_space_write_,n)(bst, bsh, bs++, val); \ +} + +bus_space_set_region(1,8) +bus_space_set_region(2,16) +bus_space_set_region(4,32) + +#define bus_space_set_region_8 \ + !!! bus_space_set_region_8 not implemented !!! + /* OpenBSD extensions */ static __inline void bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh, - bus_addr_t ba, u_int8_t *buf, bus_size_t cnt) + bus_size_t ba, u_int8_t *buf, bus_size_t cnt) { u_int16_t *buf16 = (u_int16_t *)buf; @@ -204,7 +228,7 @@ bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh, static __inline void bus_space_read_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh, - bus_addr_t ba, u_int8_t *buf, bus_size_t cnt) + bus_size_t ba, u_int8_t *buf, bus_size_t cnt) { panic("%s: operation not allowed on this bus (tag %x)", "bus_space_read_raw_multi_4", bst); @@ -214,8 +238,35 @@ bus_space_read_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh, !!! bus_space_read_raw_multi_8 not implemented !!! static __inline void +bus_space_read_raw_region_2(bus_space_tag_t bst, bus_space_handle_t bsh, + bus_size_t ba, u_int8_t *buf, bus_size_t cnt) +{ + u_int16_t *buf16 = (u_int16_t *)buf; + + while (cnt) { + u_int16_t x = *(volatile u_int16_t *) + ((bsh & ~1) + (ba << bst->bs_shift)); + + *buf16++ = bst->bs_swapped ? x : swap16(x); + ba += 2; + cnt -= 2; + } +} + +static __inline void +bus_space_read_raw_region_4(bus_space_tag_t bst, bus_space_handle_t bsh, + bus_size_t ba, u_int8_t *buf, bus_size_t cnt) +{ + panic("%s: operation not allowed on this bus (tag %x)", + "bus_space_read_raw_region_4", bst); +} + +#define bus_space_read_raw_region_8 \ + !!! bus_space_read_raw_region_8 not implemented !!! + +static __inline void bus_space_write_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh, - bus_addr_t ba, const u_int8_t *buf, bus_size_t cnt) + bus_size_t ba, const u_int8_t *buf, bus_size_t cnt) { const u_int16_t *buf16 = (const u_int16_t *)buf; @@ -229,7 +280,7 @@ bus_space_write_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh, static __inline void bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh, - bus_addr_t ba, const u_int8_t *buf, bus_size_t cnt) + bus_size_t ba, const u_int8_t *buf, bus_size_t cnt) { panic("%s: operation not allowed on this bus (tag %x)", "bus_space_write_raw_multi_4", bst); @@ -238,4 +289,30 @@ bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh, #define bus_space_write_raw_multi_8 \ !!! bus_space_write_raw_multi_8 not implemented !!! +static __inline void +bus_space_write_raw_region_2(bus_space_tag_t bst, bus_space_handle_t bsh, + bus_size_t ba, const u_int8_t *buf, bus_size_t cnt) +{ + const u_int16_t *buf16 = (const u_int16_t *)buf; + + while (cnt) { + *(volatile u_int16_t *)((bsh & ~1) + (ba << bst->bs_shift)) = + bst->bs_swapped ? *buf16 : swap16(*buf16); + buf16++; + ba += 2; + cnt -= 2; + } +} + +static __inline void +bus_space_write_raw_region_4(bus_space_tag_t bst, bus_space_handle_t bsh, + bus_size_t ba, const u_int8_t *buf, bus_size_t cnt) +{ + panic("%s: operation not allowed on this bus (tag %x)", + "bus_space_write_raw_region_4", bst); +} + +#define bus_space_write_raw_region_8 \ + !!! bus_space_write_raw_region_8 not implemented !!! + #endif /* _AMIGA_BUS_H_ */ |