From patchwork Mon Jun 23 23:11:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 363243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BC3F814008F for ; Tue, 24 Jun 2014 09:18:03 +1000 (EST) Received: from localhost ([::1]:56510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzDUv-0006Ay-8C for incoming@patchwork.ozlabs.org; Mon, 23 Jun 2014 19:18:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzDP5-00078G-Ue for qemu-devel@nongnu.org; Mon, 23 Jun 2014 19:12:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzDP0-0003Rb-Tq for qemu-devel@nongnu.org; Mon, 23 Jun 2014 19:11:59 -0400 Received: from gate.crashing.org ([63.228.1.57]:40458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzDP0-0003RD-Dq for qemu-devel@nongnu.org; Mon, 23 Jun 2014 19:11:54 -0400 Received: from pasglop.au.ibm.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id s5NNBAed030798; Mon, 23 Jun 2014 18:11:33 -0500 From: Benjamin Herrenschmidt To: qemu-devel@nongnu.org Date: Tue, 24 Jun 2014 09:11:05 +1000 Message-Id: <1403565068-15229-12-git-send-email-benh@kernel.crashing.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403565068-15229-1-git-send-email-benh@kernel.crashing.org> References: <1403565068-15229-1-git-send-email-benh@kernel.crashing.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 Cc: Gerd Hoffmann Subject: [Qemu-devel] [RFC 11/14] vga: Make fb endian a common state variable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org And initialize it based on target endian Signed-off-by: Benjamin Herrenschmidt --- hw/display/vga.c | 17 ++++++++++++++--- hw/display/vga_int.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 909518c..e0c8dc7 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1418,10 +1418,10 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) uint8_t *d; uint32_t v, addr1, addr; vga_draw_line_func *vga_draw_line = NULL; -#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) - static const bool byteswap = false; +#ifdef HOST_WORDS_BIGENDIAN + bool byteswap = !s->big_endian_fb; #else - static const bool byteswap = true; + bool byteswap = s->big_endian_fb; #endif full_update |= update_basic_params(s); @@ -2082,6 +2082,17 @@ void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate) s->update_retrace_info = vga_precise_update_retrace_info; break; } + + /* + * Set default fb endian based on target, should probably be turned + * into a device attribute set by the machine/platform to remove + * all target endian dependencies from this file. + */ +#ifdef TARGET_WORDS_BIGENDIAN + s->big_endian_fb = true; +#else + s->big_endian_fb = false; +#endif vga_dirty_log_start(s); } diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h index 14e777a..ae64321 100644 --- a/hw/display/vga_int.h +++ b/hw/display/vga_int.h @@ -155,6 +155,7 @@ typedef struct VGACommonState { const GraphicHwOps *hw_ops; bool full_update_text; bool full_update_gfx; + bool big_endian_fb; /* hardware mouse cursor support */ uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; void (*cursor_invalidate)(struct VGACommonState *s);