Suggested by Blue.
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 e5180f2..84198f2 100644 --- a/include/arch/ppc/io.h +++ b/include/arch/ppc/io.h @@ -17,22 +17,6 @@ extern unsigned long virt_offset; extern uint32_t 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(phys_addr_t port, void *buf, int ns) +{ + _insw((uint16_t *)(port + isa_io_base), buf, ns); +} + +static inline void outsw(phys_addr_t port, void *buf, int ns) +{ + _outsw((uint16_t *)(port + isa_io_base), buf, ns); +} + + +static inline int inb(phys_addr_t port) +{ + return in_8((uint8_t *)(port + isa_io_base)); +} + +static inline void outb(int val, phys_addr_t port) +{ + out_8((uint8_t *)(port + isa_io_base), val); +} + +static inline int inw(phys_addr_t port) +{ + return in_le16((uint16_t *)(port + isa_io_base)); +} + +static inline void outw(int val, phys_addr_t port) +{ + out_le16((uint16_t *)(port + isa_io_base), val); +} + +static inline unsigned inl(phys_addr_t port) +{ + return in_le32((uint32_t *)(port + isa_io_base)); +} + +static inline void outl(int val, phys_addr_t port) +{ + out_le32((uint32_t *)(port + isa_io_base), val); +} + #else /* BOOTSTRAP */ #ifdef FCOMPILER #define inb(reg) ((u8)0xff)