From patchwork Mon Feb 10 20:41:36 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: 863829 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1791454wrt; Mon, 10 Feb 2025 12:43:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW5maOHKIFDVlUq7MvqFtC3vDSu65Oug9awYdIJK7mmcAYco0ySUFvN5uSm3ays1pTZn/g13w==@linaro.org X-Google-Smtp-Source: AGHT+IEiHHWERUjSaaLyD05cK+BJTd2zxEf3rlma8vpB6w7fkaHQZeNhjXKxhTHnZPo/S7LPMI9V X-Received: by 2002:a05:620a:2792:b0:7b6:d050:720f with SMTP id af79cd13be357-7c0686e14ffmr172033785a.22.1739220238601; Mon, 10 Feb 2025 12:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739220238; cv=none; d=google.com; s=arc-20240605; b=ANA7jcq3YC4KuC3SOWi/kr2Uisk3pKZAwyCGvdaYaotcrQudpyL6RRzeHvznE/p+LY 2EDheG0UXByQgLlNlhXCHU+cnUnfArK1Hq2yZuZrMSB9Ri1kfUinN56zQTS3BIsWWTHm kkg+J05Z6fXP1XrGfVcrroi3OeTIiyz8ll3aFpymH72BqcjrVnSv/LGKpafRAJzZS/gS EsZS6v9jPHcwtWWpGxCrdmZ+Mkk0iD2hNdoWsMXPqdY2xLfOnLJ8P4gWjEhku90DuLdp 4wmzHq0Ewyi4LxKyedY3Tq58Kxyx+wt9bCVGz3kVmx2oT7H2tJIoZPNbpxeYUlJIQU3L 4keA== 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=vxnVqTrw69QSOa26f2GLgtndlndnd+p0IrIRgpQeBXY=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=IZ+t5sADtnNHK+RLK3iuSAU9EDLQhV5G5DfaQV5Ol1fgGGwnwats8BZy7UNEtqx6NK iRUr/9Kavd0lQHzQyufCV5X7aaih83zj9pC7KJ543ZjvnIoBi+yhe//XjUchYBrBTCZA WblTpTJlJNqUUopU7Ri3VE8aoIjbfD0sJbFSmiPGNiMfo02TnGUS8qA4OWbB1F37ZgSO 3jyTeQdIPQ9cPotvTzZUu6N8Mtmlm/U4vmgBWQgDesWgq6f+2Rs4EbcIzsBJM1D/5D7d PAdBbvNXZGDjcaoVkjTtTtet6cD2253H4Dp3qbr0R/cFa+yf0/qdbJ6WG3fZg5teLFiY GnUQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CaLkFbNQ; 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-7c064563e86si141376885a.11.2025.02.10.12.43.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 12:43:58 -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=CaLkFbNQ; 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 1thac0-00067G-79; Mon, 10 Feb 2025 15:42:36 -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 1thabv-00066U-PW for qemu-devel@nongnu.org; Mon, 10 Feb 2025 15:42:32 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thabt-0003ab-KG for qemu-devel@nongnu.org; Mon, 10 Feb 2025 15:42:31 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-38dc33931d3so2063167f8f.1 for ; Mon, 10 Feb 2025 12:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739220147; x=1739824947; 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=vxnVqTrw69QSOa26f2GLgtndlndnd+p0IrIRgpQeBXY=; b=CaLkFbNQaufLSaZt/3GgdFgSt6PHjU0eUKRON9j+rKf8uXFNZQsZHZ4F19xWLkWet3 xuturYDUadzaNbFPlUKJkvHODoBPhyOZk7HTfyCYvlNSgJb1NLXwBLQGPvWOBL4mLD8N FMvP/iJxUcsZXEjzK7k6e5L3JAKOjBCAiDmvuDYrzwzV9lJV9M/65CkW43HqXZ81xNIt 8zteiLkGp8rKTwzwIUs87xONG34Rm+3VxVCYovWPTJauJsOkyuubkmaErtFd+BExXqlp nDkhxFH8lyXFD+rlpjwyeCo8XJb5aq7UO4Hp7msxa4Jzjb2c1/rXhY3jP7L9DN+qA5IB c8Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739220147; x=1739824947; 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=vxnVqTrw69QSOa26f2GLgtndlndnd+p0IrIRgpQeBXY=; b=WebwFN3/5FOjr//xWMvAqOFXbPX6OT8WVHOZu3KmjPizmD4UpuS0mpIcX9AFzTmkja vMNyJPAnkhYCaVP+4av5/KicqTXhq7jR61jBVo42hUswGAwxR3L0571PIprZ+iDQxpfK DvU2blkoEoUXzq1ywskveRxaTeeSSgD7tbW1bQevntGQLYuuDMomwfy85+2/3L/WD0Rv J82UYf4n9OCjHWCKvKneE3vBPnfLRXkX5rT3446t9/TlmnXcrt2LKintdUkDt43JvViE dxGOYnng+pK/3GGgOHTR9wRd7y2TkgWaHVe4VX/T5/8sWftFrt2+9LfLOfOa8Yl0Wo6d 1p0A== X-Gm-Message-State: AOJu0YxJ3VpUufyyk8RTrRS60SaxWvuENEgFOVP69/7/DklzLs84uMk5 vsGglKdb9WLWcP9u8hcGHIiIox/Yv9tEQZ+4sY4Stm8oS43mDNU/SVxGEX2T0RQHAYZYjE6Gb5b gnZY= X-Gm-Gg: ASbGncvJkIfHTWDrw4Usudra9L0JUSOLHf9Y0Xq5x0ima+720xpCIsv1gdJdwHtYv7z 2ixJrmrTsWB/M4dvNAmfJWPDymgaamLJVqKji6WAbjj7vUIE7IjFYzLooNQNMsGba1+mBvVlPam hXP/Ahl77+4FEOLnhS2bUJf+nD+/isryP37VS/5DxxKG/kzdso1hGqTwqi6Fy+LMln1GyD33/ZE uovG8s6UUVg+vPI0cO6bVL7TS7VkpNWpFkfePIRkToXlgf9UcqWL2MwBMhZk7kCfdJgSfThNasn ekqPnoij5VZ7vGyk8vE3j32nxz92JzWE1e3BA7cZ40pzPe408rydv8pI6hR8gQh4tQ== X-Received: by 2002:a05:6000:1fac:b0:38d:d8c0:1f8c with SMTP id ffacd0b85a97d-38dd8c023f7mr7909327f8f.38.1739220147257; Mon, 10 Feb 2025 12:42:27 -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-38dde7d3f8asm3800777f8f.21.2025.02.10.12.42.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Feb 2025 12:42:26 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 04/32] hw/timer/xilinx_timer: Make device endianness configurable Date: Mon, 10 Feb 2025 21:41:36 +0100 Message-ID: <20250210204204.54407-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250210204204.54407-1-philmd@linaro.org> References: <20250210204204.54407-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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é Message-Id: <20250206131052.30207-5-philmd@linaro.org> --- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/ppc/virtex_ml507.c | 1 + hw/timer/xilinx_timer.c | 35 +++++++++++++++--------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index cf3b9574db3..bbda70aa93b 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -127,6 +127,7 @@ petalogix_ml605_init(MachineState *machine) /* 2 timers at irq 2 @ 100 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_bit(dev, "little-endian", true); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 100 * 1000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index fbf52ba8f2f..9d4316b4036 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -114,6 +114,7 @@ petalogix_s3adsp1800_init(MachineState *machine) /* 2 timers at irq 2 @ 62 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_bit(dev, "little-endian", !TARGET_BIG_ENDIAN); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 23238119273..f87c221d076 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -230,6 +230,7 @@ static void virtex_init(MachineState *machine) /* 2 timers at irq 2 @ 62 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_bit(dev, "little-endian", false); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c index 6595cf5f517..d942ac226e6 100644 --- a/hw/timer/xilinx_timer.c +++ b/hw/timer/xilinx_timer.c @@ -3,6 +3,9 @@ * * Copyright (c) 2009 Edgar E. Iglesias. * + * DS573: https://docs.amd.com/v/u/en-US/xps_timer + * LogiCORE IP XPS Timer/Counter (v1.02a) + * * 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 @@ -69,6 +72,7 @@ struct XpsTimerState { SysBusDevice parent_obj; + bool little_endian_model; MemoryRegion mmio; qemu_irq irq; uint8_t one_timer_only; @@ -189,18 +193,21 @@ timer_write(void *opaque, hwaddr addr, timer_update_irq(t); } -static const MemoryRegionOps timer_ops = { - .read = timer_read, - .write = timer_write, - .endianness = DEVICE_NATIVE_ENDIAN, - .impl = { - .min_access_size = 4, - .max_access_size = 4, +static const MemoryRegionOps timer_ops[2] = { + [0 ... 1] = { + .read = timer_read, + .write = timer_write, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, + .valid = { + .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 timer_hit(void *opaque) @@ -233,8 +240,9 @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp) ptimer_transaction_commit(xt->ptimer); } - memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "xlnx.xps-timer", - R_MAX * 4 * num_timers(t)); + memory_region_init_io(&t->mmio, OBJECT(t), + &timer_ops[t->little_endian_model], t, + "xlnx.xps-timer", R_MAX * 4 * num_timers(t)); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &t->mmio); } @@ -247,6 +255,7 @@ static void xilinx_timer_init(Object *obj) } static const Property xilinx_timer_properties[] = { + DEFINE_PROP_BOOL("little-endian", XpsTimerState, little_endian_model, true), DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000), DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0), };