From patchwork Tue Dec 22 10:24:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 41605 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 C56EFB7BE0 for ; Tue, 22 Dec 2009 21:25:18 +1100 (EST) Received: from localhost ([127.0.0.1]:34625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN1vW-00025S-Si for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2009 05:25:14 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NN1un-00024Y-Iv for qemu-devel@nongnu.org; Tue, 22 Dec 2009 05:24:29 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NN1ui-00023l-KX for qemu-devel@nongnu.org; Tue, 22 Dec 2009 05:24:28 -0500 Received: from [199.232.76.173] (port=41812 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN1ui-00023i-DC for qemu-devel@nongnu.org; Tue, 22 Dec 2009 05:24:24 -0500 Received: from cantor.suse.de ([195.135.220.2]:59233 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NN1ui-0000EH-1Z for qemu-devel@nongnu.org; Tue, 22 Dec 2009 05:24:24 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 2B60594A12; Tue, 22 Dec 2009 11:24:19 +0100 (CET) From: Alexander Graf To: qemu-devel@nongnu.org Date: Tue, 22 Dec 2009 11:24:18 +0100 Message-Id: <1261477458-26222-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Laurent Vivier , Aurelien Jarno Subject: [Qemu-devel] [PATCH] Always swap endianness in DBDMA 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 When we get an MMIO request, we always get variables in host endianness. The only time we need to actually reverse byte order is when we read bytes from guest memory. Apparently the DBDMA implementation is different there. A lot of the logic in there depends on values being big endian. Now, qemu does all the conversion in the MMIO handlers for us already though, so it turns out that we're in the same byte order from a C point of view, but cpu_to_be32 and be32_to_cpu end up being nops. This makes the code work differently on x86 (little endian) than on ppc (big endian). On x86 it works, on ppc it doesn't. This patch (while being seriously hacky and ugly) makes dbdma emulation work on ppc hosts. I'll leave the real fixing to someone else. Signed-off-by: Alexander Graf CC: Laurent Vivier --- hw/mac_dbdma.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c index 98dccfd..4dbfc16 100644 --- a/hw/mac_dbdma.c +++ b/hw/mac_dbdma.c @@ -40,6 +40,14 @@ #include "isa.h" #include "mac_dbdma.h" +/* + * XXX This is just plain wrong. Apparently we don't want to have big endian + * values, but reversed endian ones. The code as is doesn't work on big + * endian hosts. With these defines it does. + */ +#define cpu_to_be32 bswap32 +#define be32_to_cpu bswap32 + /* debug DBDMA */ //#define DEBUG_DBDMA