diff options
-rw-r--r-- | hw/serial.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/hw/serial.c b/hw/serial.c index e0ff3a72c0..088886258e 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); } |