Received: by 2002:a17:505:610b:b0:1be9:327d:8ee3 with SMTP id tt11csp5009321njc; Fri, 8 Nov 2024 07:46:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXIqe2S/uCOvLk1/y4xKBGn4E3KaKJ0z1kLc199sAhlAdyIQaHB4myYedpO0qBPlUhYJjf9XaTuHWTQmA==@linaro.org X-Google-Smtp-Source: AGHT+IGkfizh9Sl5x9TNAHVlkPJjvs+Gh9/tY8HEr/DBNMbzw297ZJdRtcE3m1R0QnMOeX9aCj/L X-Received: by 2002:ac8:5dc6:0:b0:460:ae04:9f9e with SMTP id d75a77b69052e-46309431956mr46822931cf.48.1731080766294; Fri, 08 Nov 2024 07:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731080766; cv=none; d=google.com; s=arc-20240605; b=BOkY8YnWUPe7ZwZucsj8wB6iDtre2+sGHOkrBvB7uMRxL3P0q+MWa50D/nIZdFDwS8 XVTbRmJD2w1tpwDmiv+0NWMAUpSd2PslLK+TrwOAwoYeWRIv1NajwantcIEqRzNPvd+4 zVdqt/qfzM7A6JXAxsVrTg573UkhBkzQTww/sGWTw+VvPXhP8iwX8kJ5nE4RwWC6ltMi w1sth/+JC+3QQPhq45jhTKwNqemEm6/6Hi2UPPli8Fk7Czp+sT0k8N+RIy6ABH6UrfKl /zVqDweQw7W55WjUmVJ5G7NryoAVL1tWCLNydYrVrMsKnXRoEwTE9d57RFnCi3Vkynbr Jpjg== 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=jcB7qkOMOiyB8tsoussWhpdxJCkkhiJl/8TU9dtEiFk=; fh=BnUgilU6vFcDkhsiWVmyvhQNOSEJl6nGMmWyFGi3WDs=; b=BPByh+k9SEK/hV4Aqok8DSwgmrAUCnsUw/6YZEkfSIeKYooqHeA7fQsyALwugnCSMd vqLXkq0RAkNxUGFAf7nzqvzQfwqmsBB0kQaAWtczMKl4QHCOPTU8SEJ+iIa9/ryHDNCR OZt+ZmhCdUyXbnxBO70ExOWc9J4GeiKo/rXZdpIRhxrmNItXYh0JkuR5iWc6lZ8UHOeV 2jTeH1fieNJgK4ZNtP2pPlrVqySzjI+hdLvUdl6fvY9tGIke4q0cn22GyO7iqJuxHA+7 5jfHSQoeXP53p5yFu3Ih7v7o/XjUSELCpkLE9dker3g8oCwZFT99k8Y41gDx4B1KUTzb YyoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xao4HKFr; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=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 d75a77b69052e-462ff40e734si45172121cf.8.2024.11.08.07.46.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 07:46:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=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=Xao4HKFr; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=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 1t9R9S-0003d6-BN; Fri, 08 Nov 2024 10:43: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 1t9R9A-00032C-Hd for qemu-devel@nongnu.org; Fri, 08 Nov 2024 10:43:41 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9R96-0005Qy-Dr for qemu-devel@nongnu.org; Fri, 08 Nov 2024 10:43:39 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4315c1c7392so20698615e9.1 for ; Fri, 08 Nov 2024 07:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731080614; x=1731685414; 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=jcB7qkOMOiyB8tsoussWhpdxJCkkhiJl/8TU9dtEiFk=; b=Xao4HKFrHHd7PUq1pRA/tApiZvp4Ev9QPUu2aCylWQdtjRhEw55CnicYb7eg168BuO 52qRL6JV+dItwOwLx4r/QZyb6KM4rN4bG5tRmN+NabIs1ZlovJJE9YsA0sdjFYvmRfpt g+MxG+P64Lt5EOWGSTgcDHsl7HLLLWUyPDGH06QxneqwHz53CVh+4DWk2jeZl5z/QTy6 aMdWEY7ilB6jQb/sgB2oMPFAG+bI0wLcCoXcCZ2GGuZ0xaafXe11SClwbky6Qi7yqxri OXxmDficHQHRM3rbrtu+hqZuuA+M+pwGAFO9JYQ2a9pCYRnjhWvd2HHTb3XnWY9cYPIt XEaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731080614; x=1731685414; 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=jcB7qkOMOiyB8tsoussWhpdxJCkkhiJl/8TU9dtEiFk=; b=ErpLrb9UaEl5J925tbzAA5vOpxXl7OG5mu46qwv0oLLgwuT40LuovlRlxJVGZl03+C xhmbIBFv1w4k0qgPqBzDUiKYfhs21qv5L2aKe4rapRLAzlAaMJO8b6IsJpPTNAY0PCHv sQ90oAPgfHBlinIz3wzjMF1ItiofRyuEc8Rrx83T7s8zC/vVAYayWYWjk5fxg/8BJifD qmCb1n4aXqUEeQWqeJY0kggA92z6s11e2U5FBBBqzfCRvRnSY4lfYr16Vb9xopb+4o8+ gsAe0PRRJf8n2KUIlyMcTj+yBuqtPBsnleYv5QQfclQXJRGFZN2OQ5jl7ZxP3qNSwmYN shgA== X-Gm-Message-State: AOJu0YzchEgcTv3rEodhfsCgbO9xiIXxY75MWPTZbW8fDgQDbSXiImBa JJUVDMXjltT/ZJ6YU4tS+x0iWr+Ox4XmnvyQHUjTOfOzCA4FC2+s4nJi2cAm+luhqqf6nAMP18Q Z X-Received: by 2002:a05:600c:510a:b0:430:5846:7582 with SMTP id 5b1f17b1804b1-432b74fda3dmr27458515e9.7.1731080614485; Fri, 08 Nov 2024 07:43:34 -0800 (PST) Received: from localhost.localdomain ([89.101.134.25]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed97ce1bsm5240064f8f.36.2024.11.08.07.43.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 08 Nov 2024 07:43:34 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Anton Johansson Cc: Jason Wang , Paolo Bonzini , Richard Henderson , devel@lists.libvirt.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Edgar E. Iglesias" , Thomas Huth , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Peter Maydell , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 03/17] hw/intc/xilinx_intc: Make device endianness configurable Date: Fri, 8 Nov 2024 15:43:03 +0000 Message-ID: <20241108154317.12129-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108154317.12129-1-philmd@linaro.org> References: <20241108154317.12129-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: aBkqTS3dUDDm 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 8fb6b4f1a5..fc55c8afca 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 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 +212,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); -- 2.45.2