From patchwork Thu Jul 22 22:03:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 59654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 23C91B70B8 for ; Fri, 23 Jul 2010 08:15:27 +1000 (EST) Received: from localhost ([127.0.0.1]:50437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oc42k-0006IS-O2 for incoming@patchwork.ozlabs.org; Thu, 22 Jul 2010 18:15:06 -0400 Received: from [140.186.70.92] (port=42696 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oc3wX-00030V-Eh for qemu-devel@nongnu.org; Thu, 22 Jul 2010 18:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oc3s5-0003bI-S7 for qemu-devel@nongnu.org; Thu, 22 Jul 2010 18:04:07 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:34004) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oc3s5-0003bB-NJ for qemu-devel@nongnu.org; Thu, 22 Jul 2010 18:04:05 -0400 Received: by vws19 with SMTP id 19so701201vws.4 for ; Thu, 22 Jul 2010 15:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=M2sS7ogsbrQg07Wmjo1yVznNrTdbxjDl8FPMsxScGZY=; b=kxq/oT6mAUmNbVhdsXTfHNLNAa0jaRi4w00WUN3yI1sTnUpOc2Mum0oBJpNxYBqlGT ZZ27rRQ5oMnauGvLtNX1pTBmzcaX9GKI8pF2Bs0D5YTXk6jCOxWoH4wpJUY1HxxS67w8 q5XDwtd7IN9ME19uoIOQSolXHGpcBH6mn0UR4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=D5oJBpUs8UU9THA9r3UuBr+I+w+ytys0EMDMY/SvuB2+yqbRVeTZUybx1qKcqIu5qQ ScYgc4g8J0sZ3xYUNGEe2txXcRgUJvI20zVG1LYukJL5Gskxu8m3VkCsjidPBUvS4ypz VAaA1TTd/0WfrKnnGDg5cNC8vVxQZxYgu7huk= Received: by 10.224.12.9 with SMTP id v9mr1695383qav.265.1279836240371; Thu, 22 Jul 2010 15:04:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.185.146 with HTTP; Thu, 22 Jul 2010 15:03:39 -0700 (PDT) From: Blue Swirl Date: Thu, 22 Jul 2010 22:03:39 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 32/34] vga: make byte swapping selectable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make byte swapping in VGA selectable. Signed-off-by: Blue Swirl --- hw/mips_jazz.c | 6 +++++- hw/pc.h | 2 +- hw/vga-isa-mm.c | 9 ++++++--- hw/vga-isa.c | 3 ++- hw/vga-pci.c | 2 +- hw/vga.c | 38 +++++++++++++------------------------- hw/vga_int.h | 2 +- hw/vmware_vga.c | 3 ++- 8 files changed, 31 insertions(+), 34 deletions(-) vga_init_vbe(&s->vga); diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 71b05a2..3a3635d 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -217,7 +217,11 @@ void mips_jazz_init (ram_addr_t ram_size, g364fb_mm_init(0x40000000, 0x60000000, 0, rc4030[3]); break; case JAZZ_PICA61: - isa_vga_mm_init(0x40000000, 0x60000000, 0); +#ifdef TARGET_WORDS_BIGENDIAN + isa_vga_mm_init(0x40000000, 0x60000000, 0, 1); +#else + isa_vga_mm_init(0x40000000, 0x60000000, 0, 0); +#endif break; default: break; diff --git a/hw/pc.h b/hw/pc.h index 63b0249..9ab2695 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -157,7 +157,7 @@ int isa_vga_init(void); int pci_vga_init(PCIBus *bus, unsigned long vga_bios_offset, int vga_bios_size); int isa_vga_mm_init(target_phys_addr_t vram_base, - target_phys_addr_t ctrl_base, int it_shift); + target_phys_addr_t ctrl_base, int it_shift, int be); /* cirrus_vga.c */ void pci_cirrus_vga_init(PCIBus *bus); diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c index d4b1e95..1840c3e 100644 --- a/hw/vga-isa-mm.c +++ b/hw/vga-isa-mm.c @@ -92,13 +92,16 @@ static CPUWriteMemoryFunc * const vga_mm_write_ctrl[] = { }; static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base, - target_phys_addr_t ctrl_base, int it_shift) + target_phys_addr_t ctrl_base, int it_shift, int be) { int s_ioport_ctrl, vga_io_memory; s->it_shift = it_shift; s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s); vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s); + if (be) { + vga_io_memory = cpu_physical_memory_toggle_bswap(vga_io_memory); + } vmstate_register(NULL, 0, &vmstate_vga_common, s); @@ -108,14 +111,14 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base, } int isa_vga_mm_init(target_phys_addr_t vram_base, - target_phys_addr_t ctrl_base, int it_shift) + target_phys_addr_t ctrl_base, int it_shift, int be) { ISAVGAMMState *s; s = qemu_mallocz(sizeof(*s)); vga_common_init(&s->vga, VGA_RAM_SIZE); - vga_mm_init(s, vram_base, ctrl_base, it_shift); + vga_mm_init(s, vram_base, ctrl_base, it_shift, be); s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, s); diff --git a/hw/vga-isa.c b/hw/vga-isa.c index 3046054..cc99cdf 100644 --- a/hw/vga-isa.c +++ b/hw/vga-isa.c @@ -36,7 +36,8 @@ int isa_vga_init(void) s = qemu_mallocz(sizeof(*s)); vga_common_init(s, VGA_RAM_SIZE); - vga_init(s); + vga_init(s, -1); + vmstate_register(NULL, 0, &vmstate_vga_common, s); s->ds = graphic_console_init(s->update, s->invalidate, diff --git a/hw/vga-pci.c b/hw/vga-pci.c index 94e3ee0..68fbe36 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -79,7 +79,7 @@ static int pci_vga_initfn(PCIDevice *dev) // vga + console init vga_common_init(s, VGA_RAM_SIZE); - vga_init(s); + vga_init(s, -1); s->ds = graphic_console_init(s->update, s->invalidate, s->screen_dump, s->text_update, s); diff --git a/hw/vga.c b/hw/vga.c index b612529..d85ccd2 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -767,30 +767,22 @@ uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr) static uint32_t vga_mem_readw(void *opaque, target_phys_addr_t addr) { uint32_t v; -#ifdef TARGET_WORDS_BIGENDIAN - v = vga_mem_readb(opaque, addr) << 8; - v |= vga_mem_readb(opaque, addr + 1); -#else + v = vga_mem_readb(opaque, addr); v |= vga_mem_readb(opaque, addr + 1) << 8; -#endif + return v; } static uint32_t vga_mem_readl(void *opaque, target_phys_addr_t addr) { uint32_t v; -#ifdef TARGET_WORDS_BIGENDIAN - v = vga_mem_readb(opaque, addr) << 24; - v |= vga_mem_readb(opaque, addr + 1) << 16; - v |= vga_mem_readb(opaque, addr + 2) << 8; - v |= vga_mem_readb(opaque, addr + 3); -#else + v = vga_mem_readb(opaque, addr); v |= vga_mem_readb(opaque, addr + 1) << 8; v |= vga_mem_readb(opaque, addr + 2) << 16; v |= vga_mem_readb(opaque, addr + 3) << 24; -#endif + return v; } @@ -931,28 +923,16 @@ void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) static void vga_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { -#ifdef TARGET_WORDS_BIGENDIAN - vga_mem_writeb(opaque, addr, (val >> 8) & 0xff); - vga_mem_writeb(opaque, addr + 1, val & 0xff); -#else vga_mem_writeb(opaque, addr, val & 0xff); vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff); -#endif } static void vga_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) { -#ifdef TARGET_WORDS_BIGENDIAN - vga_mem_writeb(opaque, addr, (val >> 24) & 0xff); - vga_mem_writeb(opaque, addr + 1, (val >> 16) & 0xff); - vga_mem_writeb(opaque, addr + 2, (val >> 8) & 0xff); - vga_mem_writeb(opaque, addr + 3, val & 0xff); -#else vga_mem_writeb(opaque, addr, val & 0xff); vga_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff); vga_mem_writeb(opaque, addr + 2, (val >> 16) & 0xff); vga_mem_writeb(opaque, addr + 3, (val >> 24) & 0xff); -#endif } typedef void vga_draw_glyph8_func(uint8_t *d, int linesize, @@ -2287,7 +2267,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size) } /* used by both ISA and PCI */ -void vga_init(VGACommonState *s) +void vga_init(VGACommonState *s, int do_bswap) { int vga_io_memory; @@ -2329,6 +2309,14 @@ void vga_init(VGACommonState *s) #endif /* CONFIG_BOCHS_VBE */ vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s); + + if (do_bswap == -1) { +#ifdef TARGET_WORDS_BIGENDIAN + vga_io_memory = cpu_physical_memory_toggle_bswap(vga_io_memory); +#endif + } else if (do_bswap == 1) { + vga_io_memory = cpu_physical_memory_toggle_bswap(vga_io_memory); + } cpu_register_physical_memory(isa_mem_base + 0x000a0000, 0x20000, vga_io_memory); qemu_register_coalesced_mmio(isa_mem_base + 0x000a0000, 0x20000); diff --git a/hw/vga_int.h b/hw/vga_int.h index 6a46a43..60af53f 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -192,7 +192,7 @@ static inline int c6_to_8(int v) } void vga_common_init(VGACommonState *s, int vga_ram_size); -void vga_init(VGACommonState *s); +void vga_init(VGACommonState *s, int do_bswap); void vga_common_reset(VGACommonState *s); void vga_dirty_log_start(VGACommonState *s); diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index a9ade91..f73f5fa 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -1168,7 +1168,8 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset); vga_common_init(&s->vga, vga_ram_size); - vga_init(&s->vga); + vga_init(&s->vga, -1); + vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);