From patchwork Thu Feb 6 13:10:37 2025 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: 862500 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp118774wrv; Thu, 6 Feb 2025 05:12:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUUAYCKgPIvVd/LQbAilFPNwh1wB/OGEBTAURMdmpc0AbKY2CGuDzhAr38CU1nBRPomuHQu7g==@linaro.org X-Google-Smtp-Source: AGHT+IHMRKjW+UevResQqaUi3wpSWVfLRyWqk827L/7DmWWqKB4j76gEQorSSlwu6JdwkMQ1Ib8V X-Received: by 2002:a05:6102:80b:b0:4ba:70c4:f016 with SMTP id ada2fe7eead31-4ba70c4f0e7mr1566400137.16.1738847567311; Thu, 06 Feb 2025 05:12:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738847567; cv=none; d=google.com; s=arc-20240605; b=GFoAPeHN/JiBj4FV3hgPi7XAWlzYGMw3UPOxMyMLCtiIBBALM5STXLlb5MxocuGgoh zN+ZHeacJi35stvi+ubj5xAcAZUr+6GwRvBU1nuQLRzRhB2yqYMGig4uy1UYYZw6tfc5 L+vqsIkZqCQU3w52pjHXoAOZaDZoo8n5mWHlJc8zmFNI1TrgvwzyNuDgyYBd2JjyEe3L dgbG/pG3vlvu2J81i1wDv5nkrtb42egzG/ZL7FbN8w04X87MgGKbUtKvTe/InSkedPGg 3cHUEoP/8LynVx3oWl2a1X4imlgned74W2HBxALUIjk83e71Y6BvFy3aujboaXPuLEWB b4BA== 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=503eeF5KhCNoQH5RB4G8vUQc3vp07cA9yV4AIGoAB5A=; fh=7NsVx5R+L140HvZ0es4udPXCD2KdHoHcZm3kdyNBbE4=; b=LgR2YDpaapT7R08XF6Ox+GJvUU9cbfWSRE4RW3laYmYZvNnKpkeDuKbwCo4FwuoA0x gaANA53VEy+ZeOwHjcJyBs0Hnlr7XF/BwcCzTty5cJzmxZLKHbpsQSzJHUM7ATL78Nr5 OWQddlpWzUQ+xhRodIeeBOtrYAkyeZU3jU1R1uereIX+XRQNjtcb290f66rQVzSEVXxj MaoYfVJsrzu/HvhBaHMKEcvaKaWOaTAAJxcPtuZeJQ144ySJ1Bz+vkiGOUGhIAX+Ih1b +c7SaT92Y987U2ZHzJlBNP50LsPAwG+GEpnqIW95COrCqYmS2wBaX9Bqa0KymCwMejug se2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Of55DvB6; 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 ada2fe7eead31-4ba77923867si190446137.638.2025.02.06.05.12.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 05:12:47 -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=Of55DvB6; 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 1tg1es-0004z1-Dg; Thu, 06 Feb 2025 08:11:06 -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 1tg1eq-0004yI-Me for qemu-devel@nongnu.org; Thu, 06 Feb 2025 08:11:04 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg1eo-00080O-P6 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 08:11:04 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43690d4605dso5890725e9.0 for ; Thu, 06 Feb 2025 05:11:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738847460; x=1739452260; 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=503eeF5KhCNoQH5RB4G8vUQc3vp07cA9yV4AIGoAB5A=; b=Of55DvB6vd+SPEzGdUwkBcgo7J8Nav2wQvUKPeQsIDYWx+PRr6iNZ8tCKqwFxDWqTi 1Fyysh14Ee+2FfJtIEMrovg6VQAZXswYSw4r5eIdEPZj1oxPhwMsCDqKO/HbfpPRLUGc kS50brSJTW+wr6x5xGq2Byb73GhiUBq4g4n4tmnZiNgsBnRD6QnMqM2I6NbY30FB8LBJ pazOejYnyhN2hukS0+oPgTcwebgEWE0TrtVD7y8o5hdNbbGfmj8NuC+J0QJTZRt/O1yX cJQ2R++uqqAQer9Pwlo71Xh3wKbv5DE3VzH9iUANsdNtPN1V6aqVtISxYI7QZqcH5JAY RTcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738847460; x=1739452260; 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=503eeF5KhCNoQH5RB4G8vUQc3vp07cA9yV4AIGoAB5A=; b=rlYy/VrX6RBaRfhVaA+497Z4CzKZJEeo2yC45z3CkPJcU2dy+pNvb3+QRJSkag3+Gg 8VP/KXMXNr1uHIWrgaX1xJm0JENTOu39KRC1iPb7TpxsSz7hk4q3tSA8DPksMnOa0m0H wb6MC0NhB3jSCgtnBBe03zPjKBgMOI5ETQnJA1pPersxXI4vtX7HXIpT5T6FY2MBKSHo DGvY3K0MOeTRUu5r0fLc66UGTRP7OTXkIaPB0kKhLh5xLVBgIAd6+gIFQP6NYA3tjat9 EZs/Ypcp7BTtRgPeWNc3+N3CZtrnAUhRvNEmv4+Z7mC9ppo25QDp1JNX6tc/ImtIyf7d xJMg== X-Gm-Message-State: AOJu0YwAiWhMf33w08QnGSgZdp+xHxKUceUmREq5sIUMY9+ZnEC/z6SD 5f0YkX33dtJLN9MOHOhruFt2Nfqmnp4S8rPp6gGYRMSz28J8cDqWY8/46ZPO+ZkebSF91mnxkNA DX3A= X-Gm-Gg: ASbGncuNZTLloXJHtsWak6BOOqArte2m7bCc6lBljDzE7beeeWCLgxCbUgQ32OFjCl/ kCPZzU/MOyvyigVNoR0sUTRJLPO5zNd3+HfHYcgRpe0+sQHDQydr0hy8689C8BruiI1Ngyzy/px 7ACgfscVijyCFdGsP9vm9gaBevuFoBDxhIZ2wIjCQFYPLzv9hofDX8g0cO3itq1WGPLkRcg9t4l hqPK3WpB5DlA6SE/d+iysh5QSf4XPbNU/7Of4PCBXhldPMKjNdZcxK3pTbxAPQeETzLPcigaVgU Dyyzr/o7zqsmlTK/fzCKYlofmqw7I714oQ2EA4lTRV2MzX/lxvBeptV2lRiA9oGXGw== X-Received: by 2002:a05:600c:3595:b0:430:563a:b20a with SMTP id 5b1f17b1804b1-4390d4347ddmr70713625e9.11.1738847459396; Thu, 06 Feb 2025 05:10:59 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbdd35742sm1685808f8f.21.2025.02.06.05.10.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Feb 2025 05:10:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Anton Johansson , Jason Wang , Paolo Bonzini , Alistair Francis , Thomas Huth , Richard Henderson , Peter Maydell , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PATCH v5 01/16] hw/intc/xilinx_intc: Make device endianness configurable Date: Thu, 6 Feb 2025 14:10:37 +0100 Message-ID: <20250206131052.30207-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206131052.30207-1-philmd@linaro.org> References: <20250206131052.30207-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/intc/xilinx_intc.c | 52 +++++++++++++++++------- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c index 6930f83907a..cd79ac4d4ff 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,18 +144,29 @@ 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] = { + [0 ... 1] = { + .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 - } + [0].endianness = DEVICE_BIG_ENDIAN, + [1].endianness = DEVICE_LITTLE_ENDIAN, }; static void irq_handler(void *opaque, int irq, int level) @@ -174,13 +189,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 const 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), }; @@ -188,6 +211,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 8b44be75a22..cf3b9574db3 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 2c0d8c34cd2..0506497ad0a 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);