From patchwork Fri Dec 9 15:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 632264 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp918244pvb; Fri, 9 Dec 2022 07:18:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6hNjR7VW5d/kjxpvMNLy7FTIZ58cISwfhRmhDgwY3wmQZEymcjxpOb6P3zPkhdky1unXHz X-Received: by 2002:a05:6214:b0d:b0:4c7:1fa7:25e7 with SMTP id u13-20020a0562140b0d00b004c71fa725e7mr9779867qvj.3.1670599115829; Fri, 09 Dec 2022 07:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599115; cv=none; d=google.com; s=arc-20160816; b=toHkKGWqBl+b/3Le9QWyBAcGC7nNObr16J92++rxZsRbmyoPmsqpRURkYohxNLP1aB 8QWBh4ITaDXUD02XoIiIXUyPefPi9+Jpv1xQnO16bTWTCEyhHfp5Z7fmDhyJzDzfLLCk 8dP0CUQ/VMRy43vdJgdFRKOxwRJsItu9dixXQmkTaS90UhqznyJdAASnRtN310fq8wes 5KXampZC9Abe3y/7APh5JJS5yL//priCC25F8LFh0/VuMj32a4XPHQH6rLcgkJiiC3vr KLZ3p9ShvFW8BPQYsU0kUJ+WUJBYJ9Yg1kQOH4sGpLjMS+ZbhbYC4ftDz3z6dzSm7MW1 WAAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KLG0xoWyhhBW457w36XngZbKe3qdM+Ngb1nAJqophKg=; b=FPOQCeUQNXDc6W1TnIG8cohlXoL2zvXwgIXJ6VgQ7VtgqgKgtcT8L8suiulpr4sb7K i56aVfsgJzuGCQnDXONHyO1iwgZbnYZoORDVYUZGX0nJ9EbPWeZzEk/a9xTu6esbzCNk mb1tsuyVy5f6Eth8B8rTQBJjXRV/dTHLBRuoysp97LcVA0xJ+f2v3xVExEMg9Sq5zZir 7V/xYjo/Xr+qFwWH8LP5S49HF5r08/AUFJ2H62Pli3y/rXnpzgMv8J8/3ILzA7r/zsr5 qhyyf979T/JTHzXQQBJk4LMmwdFPanF80QxEUTBwNja/P1yhX2c4jB4hMWPF29nmPQVM gLHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=We5OO8WG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s4-20020a0562140ca400b004c7360e3038si989973qvs.246.2022.12.09.07.18.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Dec 2022 07:18:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=We5OO8WG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3f6U-0004xB-1Q; Fri, 09 Dec 2022 10:15:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3f6R-0004uF-Cs for qemu-devel@nongnu.org; Fri, 09 Dec 2022 10:15:56 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3f6O-0008BK-04 for qemu-devel@nongnu.org; Fri, 09 Dec 2022 10:15:54 -0500 Received: by mail-wr1-x430.google.com with SMTP id u12so5499786wrr.11 for ; Fri, 09 Dec 2022 07:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KLG0xoWyhhBW457w36XngZbKe3qdM+Ngb1nAJqophKg=; b=We5OO8WGgk3OHfscabDzU4Z+6VSJRt9eWXkDMTBwSFMonWU6rdGG61v8AB/V/L8luk zfRhilsHISj4NqNPOEoYUg7RFO/nV6xtT6mFc7NbcogabSm7V0pRC1HHb3T4A7jMVjWM LCUOxaSk39EC7TkTAA2os1MpDjnobP4i0l5ON5B5l0wrBW6YRCq8PWqOFp8cggRSpVnT 1jAdghcjF6TvRFF7xeyR7HQJp8FEEU9j344eRBm0lcv3V4/diye7eyfqwkSMdE6vXFwe nKSobNB/50ylPr+1ni1J8+AHWft3+CSiFtlTSw/DnQ7XnEKzg8Wm10eBDmILJOolbikD 1LgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KLG0xoWyhhBW457w36XngZbKe3qdM+Ngb1nAJqophKg=; b=bagEzM6clceBVt2QLBwGfWGQHP/GQq6vGpBx9pz7WwQveDpiZ5JiMP2QVqPEHFJuiv rrMmJM1GgQD4C0vZOKRSyuVbyo2dBLm+DRAPNd8XHCVnO3qIt2m3+8fOJ5hFQm7iAE9z 36JOMk+WYAkJbPwgNehDl5BLCxGjZzlrl2jVSLHOrek+aQnhob3KvpO/4EnlGrlawozD V1xDBQLGigmjF8s5oy+i6tbiZF9YrNkAeVYhMqSQIJJdMqYE5RUyCURASUCzQDu1VjXC 5V1IByWKX940jI4OmYNn565miR1/LU5vljOvPbf//OHU+bef67IGJrRTx7qPSUKYQJdN 33Hw== X-Gm-Message-State: ANoB5pn7KYbRwvy+2jiGHe+tFq6/kS0xs1LV8nPIzTq57guM1obgWy17 aiitsU5tLfwb+kikSSn2lmv28jPtorQCWEmxkA8= X-Received: by 2002:a5d:68cb:0:b0:242:6f93:d558 with SMTP id p11-20020a5d68cb000000b002426f93d558mr4119540wrw.67.1670598950359; Fri, 09 Dec 2022 07:15:50 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id d4-20020adfe2c4000000b00236488f62d6sm1611230wrj.79.2022.12.09.07.15.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 09 Dec 2022 07:15:50 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Jiaxun Yang , Bernhard Beschow , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno Subject: [PATCH-for-8.0 3/7] hw/mips/gt64xxx_pci: Manage endian bits with the RegisterField API Date: Fri, 9 Dec 2022 16:15:29 +0100 Message-Id: <20221209151533.69516-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209151533.69516-1-philmd@linaro.org> References: <20221209151533.69516-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/gt64xxx_pci.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c index 1b9ac7f792..8c9ec80f7c 100644 --- a/hw/mips/gt64xxx_pci.c +++ b/hw/mips/gt64xxx_pci.c @@ -26,6 +26,7 @@ #include "qapi/error.h" #include "qemu/units.h" #include "qemu/log.h" +#include "hw/registerfields.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/misc/empty_slot.h" @@ -41,6 +42,9 @@ #define GT_CPU (0x000 >> 2) #define GT_MULTI (0x120 >> 2) +REG32(GT_CPU, 0x000) +FIELD(GT_CPU, Endianess, 12, 1) + /* CPU Address Decode */ #define GT_SCS10LD (0x008 >> 2) #define GT_SCS10HD (0x010 >> 2) @@ -210,6 +214,13 @@ #define GT_PCI0_CFGADDR (0xcf8 >> 2) #define GT_PCI0_CFGDATA (0xcfc >> 2) +REG32(GT_PCI0_CMD, 0xc00) +FIELD(GT_PCI0_CMD, MByteSwap, 0, 1) +FIELD(GT_PCI0_CMD, SByteSwap, 16, 1) +REG32(GT_PCI1_CMD, 0xc80) +FIELD(GT_PCI1_CMD, MByteSwap, 0, 1) +FIELD(GT_PCI1_CMD, SByteSwap, 16, 1) + /* Interrupts */ #define GT_INTRCAUSE (0xc18 >> 2) #define GT_INTRMASK (0xc1c >> 2) @@ -983,15 +994,17 @@ static const MemoryRegionOps isd_mem_ops = { static void gt64120_reset(DeviceState *dev) { GT64120State *s = GT64120_PCI_HOST_BRIDGE(dev); +#if TARGET_BIG_ENDIAN + unsigned cpu_le = 0; +#else + unsigned cpu_le = 1; +#endif /* FIXME: Malta specific hw assumptions ahead */ /* CPU Configuration */ -#if TARGET_BIG_ENDIAN s->regs[GT_CPU] = 0x00000000; -#else - s->regs[GT_CPU] = 0x00001000; -#endif + s->regs[GT_CPU] = FIELD_DP32(s->regs[GT_CPU], GT_CPU, Endianess, cpu_le); s->regs[GT_MULTI] = 0x00000003; /* CPU Address decode */ @@ -1098,11 +1111,11 @@ static void gt64120_reset(DeviceState *dev) s->regs[GT_TC_CONTROL] = 0x00000000; /* PCI Internal */ -#if TARGET_BIG_ENDIAN s->regs[GT_PCI0_CMD] = 0x00000000; -#else - s->regs[GT_PCI0_CMD] = 0x00010001; -#endif + s->regs[GT_PCI0_CMD] = FIELD_DP32(s->regs[GT_PCI0_CMD], + GT_PCI0_CMD, MByteSwap, cpu_le); + s->regs[GT_PCI0_CMD] = FIELD_DP32(s->regs[GT_PCI0_CMD], + GT_PCI0_CMD, SByteSwap, cpu_le); s->regs[GT_PCI0_TOR] = 0x0000070f; s->regs[GT_PCI0_BS_SCS10] = 0x00fff000; s->regs[GT_PCI0_BS_SCS32] = 0x00fff000; @@ -1119,11 +1132,11 @@ static void gt64120_reset(DeviceState *dev) s->regs[GT_PCI0_SSCS10_BAR] = 0x00000000; s->regs[GT_PCI0_SSCS32_BAR] = 0x01000000; s->regs[GT_PCI0_SCS3BT_BAR] = 0x1f000000; -#if TARGET_BIG_ENDIAN s->regs[GT_PCI1_CMD] = 0x00000000; -#else - s->regs[GT_PCI1_CMD] = 0x00010001; -#endif + s->regs[GT_PCI1_CMD] = FIELD_DP32(s->regs[GT_PCI1_CMD], + GT_PCI1_CMD, MByteSwap, cpu_le); + s->regs[GT_PCI1_CMD] = FIELD_DP32(s->regs[GT_PCI1_CMD], + GT_PCI1_CMD, SByteSwap, cpu_le); s->regs[GT_PCI1_TOR] = 0x0000070f; s->regs[GT_PCI1_BS_SCS10] = 0x00fff000; s->regs[GT_PCI1_BS_SCS32] = 0x00fff000;