From nobody Fri Mar 14 13:03:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1738847606; cv=none; d=zohomail.com; s=zohoarc; b=SzqrWMD6aiSVMNFea1OdHWIPC4Z8zoBbulc1XLVrDvfQdf0uHluR1jUqBzWAlTXyvMzap7XboJwmVFSlZ3xTXGvLcRe9c6cK3XCXjTtA88YxZNN8vhCSl0IfnvT7fIehD+1xf40kXgWkVqiBqJyYPl0ICwN5QV2eAJd28b/6S8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738847606; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4hjV9qje+F9WM+1u7JaIIDgc7g6v/WUaxTXGCOTYvnI=; b=bDJc6AvV33yGonzzkOi6fi1naLHok+H1ojHsa/fLT7o4rMX0cQzNG0bplQdprEN6lpUa39zNQUr5vJg9gEy/BK2BPKEvo4N7h/DrM5QEwbSflZ3dZZ/KOnUlJgJAGLCaFF6bvG/kUEP/r6tUqBnHAgfOWgf1MRNMKF7YK1eDWFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173884760673837.07570773330144; Thu, 6 Feb 2025 05:13:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg1f7-00052p-9R; Thu, 06 Feb 2025 08:11:21 -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 1tg1ez-00050h-Ms for qemu-devel@nongnu.org; Thu, 06 Feb 2025 08:11:13 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg1ex-00082Q-Cv for qemu-devel@nongnu.org; Thu, 06 Feb 2025 08:11:13 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-436345cc17bso6243505e9.0 for ; Thu, 06 Feb 2025 05:11:10 -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-38dc5839877sm254030f8f.3.2025.02.06.05.11.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Feb 2025 05:11:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738847469; x=1739452269; 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=4hjV9qje+F9WM+1u7JaIIDgc7g6v/WUaxTXGCOTYvnI=; b=vDFtTl9cLjF3W12hmvrpTXgy6i1fKQSUh5Ac69JywwRisbOPuaGp9A2EL6BiQq1lJL 3Ciz8mU/14SBo53ZEgSEkBTHs0A8wv4S6x6TE1bA7NiEK+UMXmkQDma2QcAFj9qKYjP+ YzxoEmgwksulXEws4tfnvz+ZpCjiSiQWX3xWK2SfRRW/eqiKSHHoQntEW1fCydR+cNqi BJwS8ErSEd3PVhFC6BmK/4PuGUI/Wy+DVl2ZdpKOA2QZFAHln85/V0+yVSF6u99QtYta oZiGbiJXK74UX3IqPd3qXJKKUB5so3OjVphMOozfjCYatHqq3fjFREP/eywabVW3tXQ4 kuew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738847469; x=1739452269; 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=4hjV9qje+F9WM+1u7JaIIDgc7g6v/WUaxTXGCOTYvnI=; b=NjsPgwfnC3x8sK3VjAqssvc6X4Re2q2XUh8m5gCN6frO1oCceOwtt03Er7nqfH1iBj qphmD/LWA0uj9jXWyrRiEJOM3NwpPR4Uw9sDJROWaGiDRssx8eoVgmN66w9HPXR+MXgy /rDAUAuKc3J8itj4qMQmbAIHOixwwiZ8Xd/SJYaLG/Knq30QpytAdU/OM/wdVqEj59vP 28NJS8e5w+gnDoJitDnishJYiObuojDmmVWpZ3gGikzoffunh/kvz50ImmqMk5u+QWEI bHjF5bKAB2KoETY6e0BlLNP80BNAzaxxNt+IBkKkuNscFYW2+PuM/5Uo50hzYpmjG8QS wWyQ== X-Gm-Message-State: AOJu0Yyizam/yWE2NLHnmjArlIw2eBks64o+5SXOsyUOGWjJpGaVx0LN FQTHHMTMk2V0jjZVfYkBp8zV3ccpMblGMK34ZemEzXhaIFIism4Oe5UJY+qkpumfUO24j4u8qm/ snRY= X-Gm-Gg: ASbGnctWd/MjQBdGQOadUyV6iChirXN+d4S5Dt9rq+sinIchameYjARcO/6a650nNI6 fyTfL3FO0QhKVJ5SlXlohPI3P3oYLbIvwG9r00NQcCKppSZNi8rprB+HBXYW/NtihCvLlnj4bL0 kfG305uUXnJML+CxeywyDxYBHmX28Viw8J3L0R68ft/V0r4mq3JlXm7ogsaHR5LgEg9e0TenCbb slgKUC2AVsQbw9KhU4fGc1ujWx/gsiSs89aa+72iMvDF15Ml0i2h/2JWmJ8YLgVRw9VE5cPRRDQ 8jc/Af/EW/v9DJgkyuJPbfKCqlwYA6fEDzO2qk1+ayfQiG3JGn/SGRi5GU8Q5QMANg== X-Google-Smtp-Source: AGHT+IG5KuMThKcuLm7hcVGyYyQeWEVmIbCY6VWXFvAfGUxfab70FuaUwn7dHCHbtG0ugxXJQ+e+8g== X-Received: by 2002:a05:600c:512a:b0:434:f3a1:b214 with SMTP id 5b1f17b1804b1-4390d56cd58mr50851855e9.28.1738847469434; Thu, 06 Feb 2025 05:11:09 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-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=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 03/16] hw/timer/xilinx_timer: Make device endianness configurable Date: Thu, 6 Feb 2025 14:10:39 +0100 Message-ID: <20250206131052.30207-4-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1738847608406019000 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=C3=A9 --- 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) =20 /* 2 timers at irq 2 @ 100 Mhz. */ dev =3D 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/petal= ogix_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) =20 /* 2 timers at irq 2 @ 62 Mhz. */ dev =3D 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) =20 /* 2 timers at irq 2 @ 62 Mhz. */ dev =3D 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"), t= o deal * in the Software without restriction, including without limitation the r= ights @@ -69,6 +72,7 @@ struct XpsTimerState { SysBusDevice parent_obj; =20 + 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); } =20 -static const MemoryRegionOps timer_ops =3D { - .read =3D timer_read, - .write =3D timer_write, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .impl =3D { - .min_access_size =3D 4, - .max_access_size =3D 4, +static const MemoryRegionOps timer_ops[2] =3D { + [0 ... 1] =3D { + .read =3D timer_read, + .write =3D timer_write, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, }, - .valid =3D { - .min_access_size =3D 4, - .max_access_size =3D 4 - } + [0].endianness =3D DEVICE_BIG_ENDIAN, + [1].endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 static void timer_hit(void *opaque) @@ -233,8 +240,9 @@ static void xilinx_timer_realize(DeviceState *dev, Erro= r **errp) ptimer_transaction_commit(xt->ptimer); } =20 - memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "xlnx.xps-ti= mer", - 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); } =20 @@ -247,6 +255,7 @@ static void xilinx_timer_init(Object *obj) } =20 static const Property xilinx_timer_properties[] =3D { + DEFINE_PROP_BOOL("little-endian", XpsTimerState, little_endian_model, = true), DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 100= 0000), DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0), }; --=20 2.47.1