From patchwork Thu Feb 6 11:33:06 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: 862484 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp78496wrv; Thu, 6 Feb 2025 03:34:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXr6vJnp0U6xF+VppswBQbivQ2tHg93VgBAVSL3020KyK/j7JX5RZnHTpRfFLknaeXYukHwRA==@linaro.org X-Google-Smtp-Source: AGHT+IGsmk+tUvGYZJuuvbU7QNPJvSFm/hZduaicrKP7NKgQq3XRMqvAWnqBOTLRqvEhwP8Q0ygG X-Received: by 2002:a05:620a:1728:b0:7b6:c714:f65c with SMTP id af79cd13be357-7c039ff4a3bmr858051285a.28.1738841669143; Thu, 06 Feb 2025 03:34:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738841669; cv=none; d=google.com; s=arc-20240605; b=Jp9sBST2SMhdJelvM2znlEN9M9K7v52F4lPL/wWIjL7rCoKezlpff3hpcrxASaClsV S9woIazQoKa5fexeiDikn1wwcxzLUfZlCE12kOihRoLRBOAmojejIETZ7xXt+X6yr54x ryITRWvMzXgWl/bobhZdVqM6JmHOCtroL3f/bbkjfELOttxotMoLbVfvfucR3xmNmrxP NrYr7nASmdCqHLnKPi1arcRRgAP4rC6DVLTLDqFtWazIfkXOPOigm9ijniZq4jZ1e/7A hFIhJFM1EnLYD58XjKUQmctjAxVvbXYOFGShK6Drc35im0iEJAfEe78siZdAvv735CYw EgXw== 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=KB7JHaNjI5K4DpKM/QhtRxZS6iSNZtGQL2GKAsTumMw=; b=R/taX53+cv5mO/VUJZqYaj/PsTLMUFZV3MQd9emKQpsYqNxVlBuspfhT3x6fthq0eD wUpIo6u0DCIeOHXaB8OY9rPfMWXo6fnMZKwFEKsvqCddkK+JyKTx98xMFpbKY/KJlgN8 vQllt1peQ5tvYCCgJJbTc8xUlk9dEGv37yOq0OVjYPQOm5K2i6ak9Sh/nekOgXqy59tL w4PokDFvp1sD8VbfteLJ2zH/A2JkuGBf/t9gkMNNgjXiRgkv/MVsuX7vKjISh1Oe9Bgy du3meX36GyAB4d3AU56HAprNkRgsIJOfnb2CZ4AEyItVybkefFuzarx6nDUu/9vH1iHz OzCQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hJEElWJG; 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 af79cd13be357-7c041e0a5f9si96895485a.183.2025.02.06.03.34.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 03:34:29 -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=hJEElWJG; 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 1tg08j-000751-Qd; Thu, 06 Feb 2025 06:33:50 -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 1tg08U-000716-9h for qemu-devel@nongnu.org; Thu, 06 Feb 2025 06:33:40 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg08S-0000pT-47 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 06:33:34 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-43690d4605dso5098615e9.0 for ; Thu, 06 Feb 2025 03:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738841609; x=1739446409; 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=hJEElWJGQsup4krVTIZy+CSmipGfB3HqSZwSD4ldvUNKm065/NQnli3YV6Peuy8/I9 NxaVMs17Xbg6OK8llGvvZziGJN64PbN6OCYsyzNCk+rIyuvINAd5wAYDE7bsTYWTJZCd IX6NK2F0Qj+61NlikUlmPzLpLaRxIZ5hfIy32Jk9c2RtFqZAYoaPD7WBeg7toLUtFxBc Jm4JUBqKYjYuEVxZaU0yc4COxSj3XT1hHdS+G4LaXlx78RwGS/1Ux0nFJZv9vquemXMO XUeyAovvfesoNFNSqP66ZkjhL4hRJ504CctR6Ic9L4yPjNwTCWWt6gpp//WoO95ZwbN6 FMLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738841609; x=1739446409; 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=RP7RpTzxIzCk1/BLJKyMw/uSgJKANtWmKgpc2haKYSWPjJgGOq/Jxz/xgPViCi4gvQ AYmTFyoKDBdAtfo4Sn6DbXJLZkBbf/Uod07Hxp5RmMZdtwo1O4gTH4q6tcaLCNk33ygX 92bV8+pB3xqMQWo6BzRAT7efdGQlw/5RXR9ljzvQJG2LmQ+KkhU1IraKmiFfvDZP4VcX e5fA7fb+ZJcuTdkDjpNAnuBIoXreQlWVUKdCO3YzoKR2WLxbK0j2fq0yWYOARmh5OYid ThjR7WnEcOoYW5aPBGRn+rDoIXjVXXF07eU75BDI9gWVPOAqgZPqxL6C0iewyF13ZOU+ dn3A== X-Gm-Message-State: AOJu0YzLnusxXHh3nfdJgomvpCSHgAouh14y5fVVhs8kwd/9nfxHzqCw /j7i95eT2Lr9ZbkGmN0jlEYvvewZbP1wgmkJM+DqGnKRkrPARHyC/SmPXPOsTHx8n62gi6XrYaU non0= X-Gm-Gg: ASbGnct6s+rzn2D2mBw3sEcHrC7Iiybr2aUgGQWIBwsRMvPCZ0Mm2fmz28AlS+5C6HV nSZn9xcM4VdsLEcytrZAz0Cgcof50pkpSBBUd8VpMGlO4ew4SV+4mt77xrE9RH338l7ypfdmZBy yeSVRYyYfrbvruPuldgzJaGDqyhnsXFLJmoMMupWsYoBRbWLDEUo4etO+Wntnu8vbUaoG1TK7B9 j8hec80AdnrPvYbhF/hcSpWlJX+fzk+v223S+wn4ObQGgL4Usuz51tUdZmn/9eBmTKJCI50z3KL law6vx6Bg+Z9dHHRLv4lV6sENGGQtilFaXF3sqqLWh8zvCmlugoRtmSD6j4EowcsZg== X-Received: by 2002:a05:600c:1c91:b0:434:a902:97cd with SMTP id 5b1f17b1804b1-4390d434b2bmr58253815e9.12.1738841608835; Thu, 06 Feb 2025 03:33:28 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390692bbeesm42205645e9.0.2025.02.06.03.33.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Feb 2025 03:33:28 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Anton Johansson , Alistair Francis , Richard Henderson , Thomas Huth , Jason Wang , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PATCH v4 01/16] hw/intc/xilinx_intc: Make device endianness configurable Date: Thu, 6 Feb 2025 12:33:06 +0100 Message-ID: <20250206113321.94906-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206113321.94906-1-philmd@linaro.org> References: <20250206113321.94906-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 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);