From e918ee04e96dd2d8809cf9d78c14a4d900001211 Mon Sep 17 00:00:00 2001 From: ths Date: Wed, 6 Jun 2007 16:28:07 +0000 Subject: Big endian byte swap for serial mmapped interface. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2946 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/serial.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'hw') diff --git a/hw/serial.c b/hw/serial.c index e0ff3a7..0888862 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -384,30 +384,44 @@ void serial_mm_writeb (void *opaque, uint32_t serial_mm_readw (void *opaque, target_phys_addr_t addr) { SerialState *s = opaque; + uint32_t val; - return serial_ioport_read(s, (addr - s->base) >> s->it_shift) & 0xFFFF; + val = serial_ioport_read(s, (addr - s->base) >> s->it_shift) & 0xFFFF; +#ifdef TARGET_WORDS_BIGENDIAN + val = bswap16(val); +#endif + return val; } void serial_mm_writew (void *opaque, target_phys_addr_t addr, uint32_t value) { SerialState *s = opaque; - +#ifdef TARGET_WORDS_BIGENDIAN + value = bswap16(value); +#endif serial_ioport_write(s, (addr - s->base) >> s->it_shift, value & 0xFFFF); } uint32_t serial_mm_readl (void *opaque, target_phys_addr_t addr) { SerialState *s = opaque; + uint32_t val; - return serial_ioport_read(s, (addr - s->base) >> s->it_shift); + val = serial_ioport_read(s, (addr - s->base) >> s->it_shift); +#ifdef TARGET_WORDS_BIGENDIAN + val = bswap32(val); +#endif + return val; } void serial_mm_writel (void *opaque, target_phys_addr_t addr, uint32_t value) { SerialState *s = opaque; - +#ifdef TARGET_WORDS_BIGENDIAN + value = bswap32(value); +#endif serial_ioport_write(s, (addr - s->base) >> s->it_shift, value); } -- cgit v1.1