diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2013-01-29 01:15:58 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2013-01-29 01:15:58 +0000 |
commit | 0ca8a6aa1dbde8c1d492b6a2824b3febe978abb1 (patch) | |
tree | faad3b82dfa800a33f452a4f8eace97bb5ce5504 /sys/arch | |
parent | e7781db457bec7a21a0ce5468cd81e5a7f29aafb (diff) |
the bus_space api implies that there's a bus endianness that it will
swap for you to the hosts endianness. sometimes you dont want this hand
holding and just want raw access to the registers. bus_space does have
stuff to do this already, but they deal with buffers which can be awkward
if you just want to get or set a single register.
this adds the following to i386 and amd64:
bus_space_read_raw_2() bus_space_read_raw_4() bus_space_read_raw_8()
bus_space_write_raw_2() bus_space_write_raw_4() bus_space_write_raw_8()
sparc64 already implements this, even though it wasnt part of the
official api. how handy.
i'll do other archs as i can.
kettenis@ and miod@ seem ok with this
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/include/bus.h | 13 | ||||
-rw-r--r-- | sys/arch/i386/include/bus.h | 20 |
2 files changed, 29 insertions, 4 deletions
diff --git a/sys/arch/amd64/include/bus.h b/sys/arch/amd64/include/bus.h index 0ee92b63f07..4cd23ba63ad 100644 --- a/sys/arch/amd64/include/bus.h +++ b/sys/arch/amd64/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.27 2013/01/18 01:54:40 dlg Exp $ */ +/* $OpenBSD: bus.h,v 1.28 2013/01/29 01:15:57 dlg Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -143,6 +143,10 @@ struct x86_bus_space_ops { #define bus_space_read_4(_t, _h, _o) ((_t)->read_4((_h), (_o))) #define bus_space_read_8(_t, _h, _o) ((_t)->read_8((_h), (_o))) +#define bus_space_read_raw_2(_t, _h, _o) ((_t)->read_2((_h), (_o))) +#define bus_space_read_raw_4(_t, _h, _o) ((_t)->read_4((_h), (_o))) +#define bus_space_read_raw_8(_t, _h, _o) ((_t)->read_8((_h), (_o))) + /* * void bus_space_read_multi_N(bus_space_tag_t tag, * bus_space_handle_t bsh, bus_size_t offset, @@ -258,6 +262,13 @@ struct x86_bus_space_ops { #define bus_space_write_8(_t, _h, _o, _v) \ ((_t)->write_8((_h), (_o), (_v))) +#define bus_space_write_raw_2(_t, _h, _o, _v) \ + ((_t)->write_2((_h), (_o), (_v))) +#define bus_space_write_raw_4(_t, _h, _o, _v) \ + ((_t)->write_4((_h), (_o), (_v))) +#define bus_space_write_raw_8(_t, _h, _o, _v) \ + ((_t)->write_8((_h), (_o), (_v))) + /* * void bus_space_write_multi_N(bus_space_tag_t tag, * bus_space_handle_t bsh, bus_size_t offset, diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h index a6f92620a44..a6b79e9333a 100644 --- a/sys/arch/i386/include/bus.h +++ b/sys/arch/i386/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.56 2012/12/04 20:51:10 kettenis Exp $ */ +/* $OpenBSD: bus.h,v 1.57 2013/01/29 01:15:57 dlg Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -126,8 +126,15 @@ u_int16_t bus_space_read_2(bus_space_tag_t, bus_space_handle_t, u_int32_t bus_space_read_4(bus_space_tag_t, bus_space_handle_t, bus_size_t); -#if 0 /* Cause a link error for bus_space_read_8 */ +#define bus_space_read_raw_2(t, h, o) \ + bus_space_read_2((t), (h), (o)) +#define bus_space_read_raw_4(t, h, o) \ + bus_space_read_4((t), (h), (o)) + +#if 0 +/* Cause a link error for bus_space_read_8 and bus_space_read_raw_8 */ #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! +#define bus_space_read_raw_8(t, h, o) !!! bus_space_read_raw_8 unimplemented !!! #endif /* @@ -235,8 +242,15 @@ void bus_space_write_2(bus_space_tag_t, bus_space_handle_t, void bus_space_write_4(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t); -#if 0 /* Cause a link error for bus_space_write_8 */ +#define bus_space_write_raw_2(t, h, o, v) \ + bus_space_write_2((t), (h), (o), (v)) +#define bus_space_write_raw_4(t, h, o, v) \ + bus_space_write_4((t), (h), (o), (v)) + +#if 0 +/* Cause a link error for bus_space_write_8 and bus_space_write_raw_8 */ #define bus_space_write_8 !!! bus_space_write_8 not implemented !!! +#define bus_space_write_raw_8 !!! bus_space_write_raw_8 not implemented !!! #endif /* |