From patchwork Tue Dec 20 11:34:33 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: 635451 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2865643pvb; Tue, 20 Dec 2022 03:52:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXtExK9D2owfYVA+rmBi6kVishWCUK7VJsnfZjoMzxKcOqiWVV8Ah7rTeNM+JuIhUwdqshDj X-Received: by 2002:a05:6214:3d02:b0:51a:464f:b317 with SMTP id ol2-20020a0562143d0200b0051a464fb317mr6545546qvb.16.1671537134136; Tue, 20 Dec 2022 03:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671537134; cv=none; d=google.com; s=arc-20160816; b=ZsQIAe7G11AyGcCnfQPxt94yMGoMHkJu590eNYxqG7xZCgM0LQdNTVFFhhYCjRLeL0 p60DHNMoquKKoxPxFWxCxbeHF6AbXD6iZ2kktEKP53qbNnYcJb8m32j5dP0PxPDdyCHd nxOfnAqmYIjBjdWjRFG+bmNgSjihc2mgpq0swhkekc0NM0jbNNrFpdC7fH/GcQky228D 9N1a7k6b5fh+5z1cW1EwcR0N+jmAb9kZ9+EatEo+trib6XxlXGgQasUCRm2+BvtHzncD 3ykojSVLi43V/igZ+eOEkwchZ7he3QFS6XJsNycK78Yn5YMEPSwyy62hxJvlkTF+9LtB qOow== 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=oug+yyfnrjJxQPmigf/yq+rALBMZ7d2PLfBytRZUvRA=; b=MeNnJC4C7ww1xtNH0ELOtmlrZxMUB2S2xjoLOmL6ynSK2LIxt/KtXMF9JmDmSA4niT P35BUGd9VEigEJ3fVHmRRCanbZBwtkxSK9sCpvUcj3n2de+6ETVG1OT9oWIa6Mi0sK2h j1uDyt9wlciJmJcWYe2RHc/PfWntB7Qjki3AOucNvHzrOrkGIxMmP2E7pBTPc/7YIJ7K Y39X4wY99owcDQ0q9rdZYgIMlR3crEOKUsQ4TY2Ngiie1swI0/7EqqWy7lK8DPWPRHDy /ilRhRk2fwh5ust29N47pCS9BY3n/iG0G8c/qLNXU7N5YYex5Gu6nJMQeFnTuRdtvr95 FDjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UjYSTfQx; 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 f10-20020a05620a408a00b006cfa81f5df9si4053027qko.103.2022.12.20.03.52.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2022 03:52:14 -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=UjYSTfQx; 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 1p7atn-0004Ei-TE; Tue, 20 Dec 2022 06:35:07 -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 1p7atl-0004Cc-As for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:35:06 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7ati-00081s-PF for qemu-devel@nongnu.org; Tue, 20 Dec 2022 06:35:04 -0500 Received: by mail-wm1-x32d.google.com with SMTP id o5-20020a05600c510500b003d21f02fbaaso10872973wms.4 for ; Tue, 20 Dec 2022 03:35:02 -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=oug+yyfnrjJxQPmigf/yq+rALBMZ7d2PLfBytRZUvRA=; b=UjYSTfQxscRpDeqRHP3c2/GeRj+b30kTaBmRJv1beC9r+O9adwH9PijuxbnBviYEEA fnJmfBKDvjU1oSgGLqMFC0/FouzKICf01KR5onNmUJPc0E0cTN6kXUX9dm6X891sD0g5 xM9Yh/KvJfCgWXZ9u6V7jUlSPtPzn13Wsnv+L1CvI/I4ihN5MsXKNIE5zVAHkUnkPr+i lewrqV2M9EJVGzR5Ijlq+FStZC8wD7r1uXIOb9ChtwW0xq2sjNwKLWwaajtil33gcfjl UfSPPPYJAflXQcJD+fS0BLNqqfNb/Y70kMhWlu1NUWazroNEWopNBhqAFbtkAyxBtfzQ ZmoA== 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=oug+yyfnrjJxQPmigf/yq+rALBMZ7d2PLfBytRZUvRA=; b=cwGPOCnUd+yeBDmH2fIp2E4R/NS3FXuUlHo3gEjuA09L5xLtv8imeZbsSuXHiCmfSr yt7Ldmlb9pBlDa4Hs7VFgFb22eblOZgCb3DM1mtNtKzrYO+M7oNGyQ4cAPzMWgvYqpT8 0+YCLycyoy+Yru9vNn5bvR2Arhlvz52CpFzaZxylsFHqIBD8laby3/b/I63u4Io0jMXE jmVCebDLIy3aLfQqberOM2QCTfsCYuzcx9F8dqznu86uR0wUeFdHWGjlfz5vLfIMdPkC EBT3MX59dWxGG+PAp9yPPLWdJVfSpEkybJKIVRx67DcEzS/c10xEGTtmvUoluKYbxYxv Zrcw== X-Gm-Message-State: AFqh2koeYR5QA5/lbZuImJmOj4Xly1v32Wq+RYydm0cjC0THVALDnFOD 7/ysKI6Tp2qguMjlGoDZPgdp4cPk7mwh5IqGtKs= X-Received: by 2002:a05:600c:5010:b0:3d3:55ad:a114 with SMTP id n16-20020a05600c501000b003d355ada114mr6833486wmr.38.1671536100963; Tue, 20 Dec 2022 03:35:00 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id m4-20020a05600c3b0400b003c6b7f5567csm2781414wms.0.2022.12.20.03.34.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Dec 2022 03:34:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Thomas Huth , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 4/7] hw/mips/gt64xxx_pci: Add a 'cpu-little-endian' qdev property Date: Tue, 20 Dec 2022 12:34:33 +0100 Message-Id: <20221220113436.14299-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221220113436.14299-1-philmd@linaro.org> References: <20221220113436.14299-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 From: Philippe Mathieu-Daudé This device does not have to be TARGET-dependent. Add a 'cpu_big_endian' property which sets the byte-swapping options if required. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20221209151533.69516-5-philmd@linaro.org> Reviewed-by: Richard Henderson --- hw/mips/gt64xxx_pci.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c index f6fa309ef7..4cafc76a23 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/qdev-properties.h" #include "hw/registerfields.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" @@ -256,6 +257,9 @@ struct GT64120State { PCI_MAPPING_ENTRY(ISD); MemoryRegion pci0_mem; AddressSpace pci0_mem_as; + + /* properties */ + bool cpu_little_endian; }; /* Adjust range to avoid touching space which isn't mappable via PCI */ @@ -998,16 +1002,11 @@ static const MemoryRegionOps isd_mem_ops = { static void gt64120_reset(DeviceState *dev) { GT64120State *s = GT64120_PCI_HOST_BRIDGE(dev); -#if TARGET_BIG_ENDIAN - bool cpu_little_endian = false; -#else - bool cpu_little_endian = true; -#endif /* FIXME: Malta specific hw assumptions ahead */ /* CPU Configuration */ - s->regs[GT_CPU] = cpu_little_endian ? R_GT_CPU_Endianness_MASK : 0; + s->regs[GT_CPU] = s->cpu_little_endian ? R_GT_CPU_Endianness_MASK : 0; s->regs[GT_MULTI] = 0x00000003; /* CPU Address decode */ @@ -1114,7 +1113,7 @@ static void gt64120_reset(DeviceState *dev) s->regs[GT_TC_CONTROL] = 0x00000000; /* PCI Internal */ - s->regs[GT_PCI0_CMD] = cpu_little_endian ? R_GT_PCI0_CMD_ByteSwap_MASK : 0; + s->regs[GT_PCI0_CMD] = s->cpu_little_endian ? R_GT_PCI0_CMD_ByteSwap_MASK : 0; s->regs[GT_PCI0_TOR] = 0x0000070f; s->regs[GT_PCI0_BS_SCS10] = 0x00fff000; s->regs[GT_PCI0_BS_SCS32] = 0x00fff000; @@ -1131,7 +1130,7 @@ 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; - s->regs[GT_PCI1_CMD] = cpu_little_endian ? R_GT_PCI1_CMD_ByteSwap_MASK : 0; + s->regs[GT_PCI1_CMD] = s->cpu_little_endian ? R_GT_PCI1_CMD_ByteSwap_MASK : 0; s->regs[GT_PCI1_TOR] = 0x0000070f; s->regs[GT_PCI1_BS_SCS10] = 0x00fff000; s->regs[GT_PCI1_BS_SCS32] = 0x00fff000; @@ -1224,11 +1223,18 @@ static const TypeInfo gt64120_pci_info = { }, }; +static Property gt64120_properties[] = { + DEFINE_PROP_BOOL("cpu-little-endian", GT64120State, + cpu_little_endian, !TARGET_BIG_ENDIAN), + DEFINE_PROP_END_OF_LIST(), +}; + static void gt64120_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + device_class_set_props(dc, gt64120_properties); dc->realize = gt64120_realize; dc->reset = gt64120_reset; dc->vmsd = &vmstate_gt64120;