Suggested by Blue.
v3: * Split off isa_io_base changes.
v2: * Make port uint16_t, suggested by Alex. * Adapt isa_io_base for ppc64.
Cc: Blue Swirl blauwirbel@gmail.com Cc: Alexander Graf agraf@suse.de Signed-off-by: Andreas Färber andreas.faerber@web.de --- include/arch/ppc/io.h | 66 +++++++++++++++++++++++++++++++++++++------------ 1 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/include/arch/ppc/io.h b/include/arch/ppc/io.h index 267f167..3479a87 100644 --- a/include/arch/ppc/io.h +++ b/include/arch/ppc/io.h @@ -17,22 +17,6 @@ extern unsigned long virt_offset; extern unsigned long isa_io_base;
/* - * The insw/outsw/insl/outsl macros don't do byte-swapping. - * They are only used in practice for transferring buffers which - * are arrays of bytes, and byte-swapping is not appropriate in - * that case. - paulus - */ -#define insw(port, buf, ns) _insw((uint16_t *)(uintptr_t)((port)+isa_io_base), (buf), (ns)) -#define outsw(port, buf, ns) _outsw((uint16_t *)(uintptr_t)((port)+isa_io_base), (buf), (ns)) - -#define inb(port) in_8((uint8_t *)(uintptr_t)((port)+isa_io_base)) -#define outb(val, port) out_8((uint8_t *)(uintptr_t)((port)+isa_io_base), (val)) -#define inw(port) in_le16((uint16_t *)(uintptr_t)((port)+isa_io_base)) -#define outw(val, port) out_le16((uint16_t *)(uintptr_t)((port)+isa_io_base), (val)) -#define inl(port) in_le32((uint32_t *)(uintptr_t)((port)+isa_io_base)) -#define outl(val, port) out_le32((uint32_t *)(uintptr_t)((port)+isa_io_base), (val)) - -/* * 8, 16 and 32 bit, big and little endian I/O operations, with barrier. */ static inline int in_8(volatile unsigned char *addr) @@ -145,6 +129,56 @@ static inline void _outsw(volatile uint16_t * port, const void *buf, ns--; } } + + +/* + * The insw/outsw/insl/outsl functions don't do byte-swapping. + * They are only used in practice for transferring buffers which + * are arrays of bytes, and byte-swapping is not appropriate in + * that case. - paulus + */ + +static inline void insw(uint16_t port, void *buf, int ns) +{ + _insw((uint16_t *)(port + isa_io_base), buf, ns); +} + +static inline void outsw(uint16_t port, void *buf, int ns) +{ + _outsw((uint16_t *)(port + isa_io_base), buf, ns); +} + + +static inline int inb(uint16_t port) +{ + return in_8((uint8_t *)(port + isa_io_base)); +} + +static inline void outb(int val, uint16_t port) +{ + out_8((uint8_t *)(port + isa_io_base), val); +} + +static inline int inw(uint16_t port) +{ + return in_le16((uint16_t *)(port + isa_io_base)); +} + +static inline void outw(int val, uint16_t port) +{ + out_le16((uint16_t *)(port + isa_io_base), val); +} + +static inline unsigned inl(uint16_t port) +{ + return in_le32((uint32_t *)(port + isa_io_base)); +} + +static inline void outl(int val, uint16_t port) +{ + out_le32((uint32_t *)(port + isa_io_base), val); +} + #else /* BOOTSTRAP */ #ifdef FCOMPILER #define inb(reg) ((u8)0xff)