diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2001-02-07 06:06:11 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2001-02-07 06:06:11 +0000 |
commit | 93bf3bb3ff29d521fbf66d2a26601b8d2452a30b (patch) | |
tree | 41a52b6f14bf1a744a27b2743523076d99b0a4c9 /sys/arch/powerpc | |
parent | 7e7b127d8c900c769149ea23b9a4c2ad37f6a7ac (diff) |
Add support for bus_space_write_region_[1248] bus_space_read_region_[1248]
as needed for some drivers, primarily drivers from NetBSD, where these
defines came from.
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r-- | sys/arch/powerpc/include/bus.h | 126 |
1 files changed, 125 insertions, 1 deletions
diff --git a/sys/arch/powerpc/include/bus.h b/sys/arch/powerpc/include/bus.h index 366e63ba286..5ae28d7e150 100644 --- a/sys/arch/powerpc/include/bus.h +++ b/sys/arch/powerpc/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.9 2000/11/11 17:27:45 drahn Exp $ */ +/* $OpenBSD: bus.h,v 1.10 2001/02/07 06:06:10 drahn Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom. All rights reserved. @@ -137,6 +137,130 @@ bus_space_write_multi(4,32) #define bus_space_write_multi_8 !!! bus_space_write_multi_8 not implemented !!! +/* + * void bus_space_read_region_N __P((bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, + * u_intN_t *addr, size_t count)); + * + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle and starting at `offset' and copy into + * buffer provided. + */ +#define __BA(t, h, o) ((void *)((h) + (o))) + +static __inline void +bus_space_read_region_1(tag, bsh, offset, addr, count) + bus_space_tag_t tag; + bus_space_handle_t bsh; + bus_size_t offset; + u_int8_t *addr; + size_t count; +{ + volatile u_int8_t *s = __BA(tag, bsh, offset); + + while (count--) + *addr++ = *s++; + __asm __volatile("eieio; sync"); +} + +static __inline void +bus_space_read_region_2(tag, bsh, offset, addr, count) + bus_space_tag_t tag; + bus_space_handle_t bsh; + bus_size_t offset; + u_int16_t *addr; + size_t count; +{ + volatile u_int16_t *s = __BA(tag, bsh, offset); + + while (count--) + __asm __volatile("lhbrx %0, 0, %1" : + "=r"(*addr++) : "r"(s++)); + __asm __volatile("eieio; sync"); +} + +static __inline void +bus_space_read_region_4(tag, bsh, offset, addr, count) + bus_space_tag_t tag; + bus_space_handle_t bsh; + bus_size_t offset; + u_int32_t *addr; + size_t count; +{ + volatile u_int32_t *s = __BA(tag, bsh, offset); + + while (count--) + __asm __volatile("lwbrx %0, 0, %1" : + "=r"(*addr++) : "r"(s++)); + __asm __volatile("eieio; sync"); +} + +#if 0 /* Cause a link error for bus_space_read_region_8 */ +#define bus_space_read_region_8 !!! unimplemented !!! +#endif + + +/* + * void bus_space_write_region_N __P((bus_space_tag_t tag, + * bus_space_handle_t bsh, bus_size_t offset, + * const u_intN_t *addr, size_t count)); + * + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided + * to bus space described by tag/handle starting at `offset'. + */ + +static __inline void +bus_space_write_region_1(tag, bsh, offset, addr, count) + bus_space_tag_t tag; + bus_space_handle_t bsh; + bus_size_t offset; + const u_int8_t *addr; + size_t count; +{ + volatile u_int8_t *d = __BA(tag, bsh, offset); + + while (count--) + *d++ = *addr++; + __asm __volatile("eieio; sync"); +} + +static __inline void +bus_space_write_region_2(tag, bsh, offset, addr, count) + bus_space_tag_t tag; + bus_space_handle_t bsh; + bus_size_t offset; + const u_int16_t *addr; + size_t count; +{ + volatile u_int16_t *d = __BA(tag, bsh, offset); + + while (count--) + __asm __volatile("sthbrx %0, 0, %1" :: + "r"(*addr++), "r"(d++)); + __asm __volatile("eieio; sync"); +} + +static __inline void +bus_space_write_region_4(tag, bsh, offset, addr, count) + bus_space_tag_t tag; + bus_space_handle_t bsh; + bus_size_t offset; + const u_int32_t *addr; + size_t count; +{ + volatile u_int32_t *d = __BA(tag, bsh, offset); + + while (count--) + __asm __volatile("stwbrx %0, 0, %1" :: + "r"(*addr++), "r"(d++)); + __asm __volatile("eieio; sync"); +} + +#if 0 +#define bus_space_write_region_8 !!! bus_space_write_region_8 unimplemented !!! +#endif + + /* These are OpenBSD extensions to the general NetBSD bus interface. */ void bus_space_read_raw_multi_1(bus_space_tag_t bst, bus_space_handle_t bsh, |