diff options
author | grehan <grehan@FreeBSD.org> | 2003-04-18 02:38:10 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2003-04-18 02:38:10 +0000 |
commit | 185952a327bdaccc38b84118f6e114d659f96a95 (patch) | |
tree | 36f20e7b92a8b8a6b5eb7caddc4e878ce506adb2 | |
parent | 2efab590ba16db1073b4d439a1651f6de61d7520 (diff) | |
download | FreeBSD-src-185952a327bdaccc38b84118f6e114d659f96a95.zip FreeBSD-src-185952a327bdaccc38b84118f6e114d659f96a95.tar.gz |
- Convert NetBSD-derived macros to inline functions for better
type-checking and future debug code.
- Remove sparse addressing hack, since the only consumer, the macio ATA
driver, doesn't require it anymore.
-rw-r--r-- | sys/powerpc/include/bus.h | 241 |
1 files changed, 176 insertions, 65 deletions
diff --git a/sys/powerpc/include/bus.h b/sys/powerpc/include/bus.h index 5104fcb..153231f 100644 --- a/sys/powerpc/include/bus.h +++ b/sys/powerpc/include/bus.h @@ -90,37 +90,30 @@ #define __BUS_SPACE_HAS_STREAM_METHODS 1 /* - * Values for the ppc bus space tag, not to be used directly by MI code. - * Low byte contains the shift value - */ -#define PPC_BUS_SPACE_MEM 0x100 /* space is mem space */ -#define PPC_BUS_MEM_MASK 0x0ff - -/* - * Flags for bus_resource_alloc(MEM|IOPORT). XXX this is very bad: it's - * assumed that this won't conflict with resource flags :-( - */ -#define PPC_BUS_SPARSE4 0x800000 /* shift offset left 4 bits */ - -/* * Bus address and size types */ typedef u_int32_t bus_addr_t; typedef u_int32_t bus_size_t; /* + * Define the PPC tag values + */ +#define PPC_BUS_SPACE_MEM 1 /* space is mem space */ +#define PPC_BUS_SPACE_IO 2 /* space is io space */ + +/* * Access methods for bus resources and address space. */ typedef u_int32_t bus_space_tag_t; typedef u_int32_t bus_space_handle_t; static __inline void * -__ppc_ba(bus_space_tag_t tag, bus_space_handle_t handle, bus_size_t offset) +__ppc_ba(bus_space_tag_t tag __unused, bus_space_handle_t handle, + bus_size_t offset) { - return ((void *)(handle + (offset << (tag & PPC_BUS_MEM_MASK)))); + return ((void *)(handle + offset)); } - /* * int bus_space_map(bus_space_tag_t t, bus_addr_t addr, * bus_size_t size, int flags, bus_space_handle_t *bshp)); @@ -138,7 +131,11 @@ bus_space_map(t, addr, size, flags, bshp) ! not implemented ! * Unmap a region of bus space. */ -#define bus_space_unmap(t, bsh, size) +static __inline void +bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused, + bus_size_t size __unused) +{ +} /* * int bus_space_subregion(bus_space_tag_t t, @@ -148,9 +145,14 @@ bus_space_map(t, addr, size, flags, bshp) ! not implemented ! * Get a new handle for a subregion of an already-mapped area of bus space. */ -#define bus_space_subregion(t, bsh, offset, size, bshp) \ - ((*(bshp) = (bus_space_handle_t)__ppc_ba( \ - (t & ~PPC_BUS_MEM_MASK), bsh, offset)), 0) +static __inline int +bus_space_subregion(bus_space_tag_t t __unused, bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size __unused, bus_space_handle_t *nbshp) +{ + *nbshp = bsh + offset; + return (0); +} + /* * int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, * bus_addr_t rend, bus_size_t size, bus_size_t align, @@ -182,16 +184,46 @@ bus_space_map(t, addr, size, flags, bshp) ! not implemented ! * described by tag/handle/offset. */ -#define bus_space_read_1(t, h, o) (in8(__ppc_ba(t, h, o))) -#define bus_space_read_2(t, h, o) (in16rb(__ppc_ba(t, h, o))) -#define bus_space_read_4(t, h, o) (in32rb(__ppc_ba(t, h, o))) +static __inline u_int8_t +bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) +{ + return (in8(__ppc_ba(t, h, o))); +} + +static __inline u_int16_t +bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) +{ + return (in16rb(__ppc_ba(t, h, o))); +} + +static __inline u_int32_t +bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) +{ + return (in32rb(__ppc_ba(t, h, o))); +} + #if 0 /* Cause a link error for bus_space_read_8 */ #define bus_space_read_8(t, h, o) !!! unimplemented !!! #endif -#define bus_space_read_stream_1(t, h, o) (in8(__ppc_ba(t, h, o))) -#define bus_space_read_stream_2(t, h, o) (in16(__ppc_ba(t, h, o))) -#define bus_space_read_stream_4(t, h, o) (in32(__ppc_ba(t, h, o))) +static __inline u_int8_t +bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) +{ + return (in8(__ppc_ba(t, h, o))); +} + +static __inline u_int16_t +bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) +{ + return (in16(__ppc_ba(t, h, o))); +} + +static __inline u_int32_t +bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) +{ + return (in32(__ppc_ba(t, h, o))); +} + #if 0 /* Cause a link error for bus_space_read_stream_8 */ #define bus_space_read_stream_8(t, h, o) !!! unimplemented !!! #endif @@ -205,33 +237,51 @@ bus_space_map(t, addr, size, flags, bshp) ! not implemented ! * described by tag/handle/offset and copy into buffer provided. */ -#define bus_space_read_multi_1(t, h, o, a, c) do { \ - ins8(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +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) +{ + ins8(__ppc_ba(t, h, o), a, c); +} -#define bus_space_read_multi_2(t, h, o, a, c) do { \ - ins16rb(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +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) +{ + ins16rb(__ppc_ba(t, h, o), a, c); +} -#define bus_space_read_multi_4(t, h, o, a, c) do { \ - ins32rb(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +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) +{ + ins32rb(__ppc_ba(t, h, o), a, c); +} #if 0 /* Cause a link error for bus_space_read_multi_8 */ #define bus_space_read_multi_8 !!! unimplemented !!! #endif -#define bus_space_read_multi_stream_1(t, h, o, a, c) do { \ - ins8(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, + bus_size_t o, u_int8_t *a, size_t c) +{ + ins8(__ppc_ba(t, h, o), a, c); +} -#define bus_space_read_multi_stream_2(t, h, o, a, c) do { \ - ins16(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, + bus_size_t o, u_int16_t *a, size_t c) +{ + ins16(__ppc_ba(t, h, o), a, c); +} -#define bus_space_read_multi_stream_4(t, h, o, a, c) do { \ - ins32(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, + bus_size_t o, u_int32_t *a, size_t c) +{ + ins32(__ppc_ba(t, h, o), a, c); +} #if 0 /* Cause a link error for bus_space_read_multi_stream_8 */ #define bus_space_read_multi_stream_8 !!! unimplemented !!! @@ -321,18 +371,57 @@ bus_space_read_region_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh, * described by tag/handle/offset. */ -#define bus_space_write_1(t, h, o, v) out8(__ppc_ba(t, h, o), (v)) -#define bus_space_write_2(t, h, o, v) out16rb(__ppc_ba(t, h, o), (v)) -#define bus_space_write_4(t, h, o, v) out32rb(__ppc_ba(t, h, o), (v)) +static __inline void +bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint8_t v) +{ + out8(__ppc_ba(t, h, o), v); +} + +static __inline void +bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint16_t v) +{ + out16rb(__ppc_ba(t, h, o), v); +} -#define bus_space_write_stream_1(t, h, o, v) out8(__ppc_ba(t, h, o), (v)) -#define bus_space_write_stream_2(t, h, o, v) out16(__ppc_ba(t, h, o), (v)) -#define bus_space_write_stream_4(t, h, o, v) out32(__ppc_ba(t, h, o), (v)) +static __inline void +bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint32_t v) +{ + out32rb(__ppc_ba(t, h, o), v); +} #if 0 /* Cause a link error for bus_space_write_8 */ #define bus_space_write_8 !!! unimplemented !!! #endif +static __inline void +bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint8_t v) +{ + out8(__ppc_ba(t, h, o), v); +} + +static __inline void +bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint16_t v) +{ + out16(__ppc_ba(t, h, o), v); +} + +static __inline void +bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint32_t v) +{ + out32(__ppc_ba(t, h, o), v); +} + +#if 0 /* Cause a link error for bus_space_write_stream_8 */ +#define bus_space_write_stream_8 !!! unimplemented !!! +#endif + + /* * void bus_space_write_multi_N(bus_space_tag_t tag, * bus_space_handle_t bsh, bus_size_t offset, @@ -342,29 +431,51 @@ bus_space_read_region_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh, * provided to bus space described by tag/handle/offset. */ -#define bus_space_write_multi_1(t, h, o, a, c) do { \ - outsb(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint8_t *a, size_t c) +{ + outsb(__ppc_ba(t, h, o), a, c); +} -#define bus_space_write_multi_2(t, h, o, a, c) do { \ - outsw(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint16_t *a, size_t c) +{ + outsw(__ppc_ba(t, h, o), a, c); +} -#define bus_space_write_multi_4(t, h, o, a, c) do { \ - outsl(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, + uint32_t *a, size_t c) +{ + outsl(__ppc_ba(t, h, o), a, c); +} #if 0 #define bus_space_write_multi_8 !!! unimplemented !!! #endif -#define bus_space_write_multi_stream_2(t, h, o, a, c) do { \ - outsw(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, + bus_size_t o, const u_int8_t *a, size_t c) +{ + outsb(__ppc_ba(t, h, o), a, c); +} + +static __inline void +bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, + bus_size_t o, const u_int16_t *a, size_t c) +{ + outsw(__ppc_ba(t, h, o), a, c); +} -#define bus_space_write_multi_stream_4(t, h, o, a, c) do { \ - outsl(__ppc_ba(t, h, o), (a), (c)); \ - } while (0) +static __inline void +bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, + bus_size_t o, const u_int32_t *a, size_t c) +{ + outsl(__ppc_ba(t, h, o), a, c); +} #if 0 #define bus_space_write_multi_stream_8 !!! unimplemented !!! |