From patchwork Thu Nov 7 01:22:09 2024 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: 841374 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp833435wru; Wed, 6 Nov 2024 17:23:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW1POnHXZRm4bBYjduEkjf0YPRwJu190I2Xen7KpSFmV7+KlwvxTkSYTUX58gLN7dA3Ny8AjQ==@linaro.org X-Google-Smtp-Source: AGHT+IEMLSzj0jP9UWRBg2jbqVMEk94SM9cxCiy8A4/CAz/2lxIw8M0ActVEuEFXWJ2oU6Fspw0V X-Received: by 2002:a05:690c:4a0e:b0:6e9:beda:5db6 with SMTP id 00721157ae682-6ead16b6db7mr2211977b3.29.1730942608565; Wed, 06 Nov 2024 17:23:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1730942608; cv=none; d=google.com; s=arc-20240605; b=D1FS0DQ1hjSHPxTnPyXFl7csWlcru3G5fY9eUwU9g8tYKDz/jKxNoQ1WsorqLPY4s3 1OxW0DEQb2wYLuJLc5WI4yfSKMGErce5AhUVKCTYNewKWBJmj1Q2h04lVQhHugAEKDU6 Bh/1M2Jakb2OnnKqz+Fabt1GFXLxJnlT2SSe3KBAQm2W+huqVxvvj3Ym5ifAAgsBAEIw WO1aA0Tly24nc4BUogNN6piQjf1YIvDuxYeNtiFktF3TU/ddIH6AHKtCnFBhnfxYJ5dq m1N2BjizKJ8YuF3CiX8pd6z/OqxWvGQUFXFpDW9LC30wFNetm9/Hg2ayBYUyOV5k74PZ hlww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=H0xKl6nA7staO4iH2UaQJzM1VdTiwao+cQyR6Rr+V3w=; fh=bMgGG3YFcK2zJ9p2JxDmxjHsn4useJs3ghWJ1tsMQv0=; b=MMh6uOzc3uWwdZmj+Xwmjh4Xkl0bfEKdFISfgcmnSTisK2hO0B2vRF9928Skp9r1pM cSYU1oinvDgVM6Nt2gAFeg2V5ZsBqjyZse8YYPEY1zHMUuKfMUXx5CUorXxEOo0Cyz7n KlfmfNRXgrFB68S9ttxgt3hjlR1Ihd4vjg4eVrKeNQeO9lmL6zJdF9U9NpLXsu9KwA1u zZaMY+6Gg8RSfbBGZ+M754L52v83oQWqVjpaVMIRBu3zg3uMTaVj7odScIsYyDwmg7i+ ppsENl0beohKO6w56WIl0Cw0aVFO8BZ2F7c7GZCy1+lBdj6hkvAyktsoLtnDyutjGeRv uVxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wbph3yvK; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d3966667a3si3442276d6.366.2024.11.06.17.23.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Nov 2024 17:23:28 -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=wbph3yvK; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8rEd-0004lS-Hq; Wed, 06 Nov 2024 20:22:55 -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 1t8rEY-0004hV-5p for qemu-devel@nongnu.org; Wed, 06 Nov 2024 20:22:52 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8rEV-00034g-Q5 for qemu-devel@nongnu.org; Wed, 06 Nov 2024 20:22:49 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-37d4c482844so232684f8f.0 for ; Wed, 06 Nov 2024 17:22:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730942566; x=1731547366; darn=nongnu.org; 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=H0xKl6nA7staO4iH2UaQJzM1VdTiwao+cQyR6Rr+V3w=; b=wbph3yvKnjuWP3vMlEtDnP7HqmDsGDRRM5CocpJ7EWuRUzk5WJP8m4Ijfz5xsn7Afv 2ZGYEh6ce7MF1iIbLRD9r0rxuN7C9uToJA43mCru2kl2k4v24yowOZM9nPH8XhUVQ56n iE38irW2WjuV3P9vUNNzrZjJ+8H7qURdlWQm70quuG9lGWztO+HjX6ZCpmzqnF7N22xB sjZ0zho/BBVK+dENIcUt8oytRxcsNennLcWIHP90/kkLLI4h9wIeJLMRhzLwXp2KzDJA NtgE85YyV2J8Ay0V+tU3/K0ms8c8mqxmKkPZ3SRH9yZtanz/HiPbEL5spg6nEiN7K5pH XJLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730942566; x=1731547366; 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=H0xKl6nA7staO4iH2UaQJzM1VdTiwao+cQyR6Rr+V3w=; b=QCrps6zvKU1eop6gkANmYQdW4SCU1FpdBIl8YbHCWFZhAr+qPbESAVuzJQVmgx2AA3 nrICkBNfOfS6eTgAgafpFcECFa4oIwa+xRbrmgpO6EusWZaDTAyXFwuSG2tPmxl0qhwy ZyxYNeFflz7gXy49yT3PP543DMj6o1rnMuplvQ8PJQLxDAM16LWN0SKT2kS5e1UDnEWm 5aPtrp85dP4zdxU80oEMkxqd8xOTYFe6JZJ+YdC9OPp2+K8BdpqG7Q/wVQvyIfRW/h97 O4ym4Q6+4JBO/nZ5bHxuozagGRE5zD4EAdfA/DGMgindX1gKflXmh3F9Go5JRPNJ0l5S 4LJw== X-Forwarded-Encrypted: i=1; AJvYcCVjq/0CaozA3G5WKEhECgrKbBbQ1tmUJLa9F6bK2zUjnhllO7T4Nxe/lvcJdk8yGSPy7QAa82EnUz6D@nongnu.org X-Gm-Message-State: AOJu0YyB7esI0r+3Q6yxlvPm66w6CkfCRAYniybct83XQoyWgiKKKHdT N2jctFP9j1pZNneWsMGec4eNwVnkevFDa7G+LlnhX1BMCR8hLlgN7WLrJU79yTk= X-Received: by 2002:a5d:5f41:0:b0:37d:4f1b:35d with SMTP id ffacd0b85a97d-380611ff128mr33748982f8f.48.1730942566070; Wed, 06 Nov 2024 17:22:46 -0800 (PST) Received: from localhost.localdomain ([154.14.63.34]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed97cfaesm240812f8f.38.2024.11.06.17.22.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 06 Nov 2024 17:22:44 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Anton Johansson , qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Jason Wang , devel@lists.libvirt.org, qemu-ppc@nongnu.org, Alistair Francis , =?utf-8?q?M?= =?utf-8?q?arc-Andr=C3=A9_Lureau?= , "Edgar E. Iglesias" , qemu-arm@nongnu.org, Peter Maydell , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v2 03/16] hw/intc/xilinx_intc: Make device endianness configurable Date: Thu, 7 Nov 2024 01:22:09 +0000 Message-ID: <20241107012223.94337-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241107012223.94337-1-philmd@linaro.org> References: <20241107012223.94337-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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=unavailable 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 Replace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN. Add the "little-endian" property to select the device endianness, defaulting to little endian. Set the proper endianness for each machine using the device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/intc/xilinx_intc.c | 61 +++++++++++++++++++----- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c index 8fb6b4f1a5..4fffde961a 100644 --- a/hw/intc/xilinx_intc.c +++ b/hw/intc/xilinx_intc.c @@ -3,6 +3,9 @@ * * Copyright (c) 2009 Edgar E. Iglesias. * + * https://docs.amd.com/v/u/en-US/xps_intc + * DS572: LogiCORE IP XPS Interrupt Controller (v2.01a) + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights @@ -49,6 +52,7 @@ struct XpsIntc { SysBusDevice parent_obj; + bool little_endian_model; MemoryRegion mmio; qemu_irq parent_irq; @@ -140,17 +144,39 @@ static void pic_write(void *opaque, hwaddr addr, update_irq(p); } -static const MemoryRegionOps pic_ops = { - .read = pic_read, - .write = pic_write, - .endianness = DEVICE_NATIVE_ENDIAN, - .impl = { - .min_access_size = 4, - .max_access_size = 4, +static const MemoryRegionOps pic_ops[2] = { + { + .read = pic_read, + .write = pic_write, + .endianness = DEVICE_BIG_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, + .valid = { + /* + * All XPS INTC registers are accessed through the PLB interface. + * The base address for these registers is provided by the + * configuration parameter, C_BASEADDR. Each register is 32 bits + * although some bits may be unused and is accessed on a 4-byte + * boundary offset from the base address. + */ + .min_access_size = 4, + .max_access_size = 4, + }, }, - .valid = { - .min_access_size = 4, - .max_access_size = 4 + { + .read = pic_read, + .write = pic_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, } }; @@ -174,13 +200,21 @@ static void xilinx_intc_init(Object *obj) qdev_init_gpio_in(DEVICE(obj), irq_handler, 32); sysbus_init_irq(SYS_BUS_DEVICE(obj), &p->parent_irq); - - memory_region_init_io(&p->mmio, obj, &pic_ops, p, "xlnx.xps-intc", - R_MAX * 4); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &p->mmio); } +static void xilinx_intc_realize(DeviceState *dev, Error **errp) +{ + XpsIntc *p = XILINX_INTC(dev); + + memory_region_init_io(&p->mmio, OBJECT(dev), + &pic_ops[p->little_endian_model], + p, "xlnx.xps-intc", + R_MAX * 4); +} + static Property xilinx_intc_properties[] = { + DEFINE_PROP_BOOL("little-endian", XpsIntc, little_endian_model, true), DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -189,6 +223,7 @@ static void xilinx_intc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->realize = xilinx_intc_realize; device_class_set_props(dc, xilinx_intc_properties); } diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index d2b2109065..64e8cadbee 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -111,6 +111,7 @@ petalogix_ml605_init(MachineState *machine) dev = qdev_new("xlnx.xps-intc"); + qdev_prop_set_bit(dev, "little-endian", true); qdev_prop_set_uint32(dev, "kind-of-intr", 1 << TIMER_IRQ); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR); diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index 8110be8371..af949196d3 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -95,6 +95,7 @@ petalogix_s3adsp1800_init(MachineState *machine) 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); dev = qdev_new("xlnx.xps-intc"); + qdev_prop_set_bit(dev, "little-endian", !TARGET_BIG_ENDIAN); qdev_prop_set_uint32(dev, "kind-of-intr", 1 << ETHLITE_IRQ | 1 << UARTLITE_IRQ); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);