From nobody Thu Nov 21 17:51:44 2024 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=1730942653; cv=none; d=zohomail.com; s=zohoarc; b=nCqrRGKDs6gKCOjiGWqE/nG8beonrVGwssPYRYGGEQc2O50wcu2OVhASCoGDas8EO+N7I7adSXcwCCLeEGzP0pCmNucNekVEngz+AzQDc+PMPRmbGPFniQ5YRDcZ5OjRu2bDhrf7rnCq7DPbaiaympoRjSuWcf/Cf3U7ApQbZ9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730942653; 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=vxVvEHAlcUJ/WXDJ+TYNZZ5nqed3WsROD6+NvXJeuxE=; b=asQbjIlZlqcbm0V9Siwlsry6DnMMKNxcoP9EQloPi7bI2dEzImumI/C06j3U3Ycfc4uoibB+EyVePKmdMgOf7J7b1L8HvuXOS9tw57KwgsyKxHYZjOncP9nA1K2aJBdNTwK4sX8PEwYh0E+Vq8DnsXVDX3+sVzeQxzEbeVJvBXA= 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 173094265358041.85763166109666; Wed, 6 Nov 2024 17:24:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8rEs-00050y-Gt; Wed, 06 Nov 2024 20:23:10 -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 1t8rEp-0004w1-Tf for qemu-devel@nongnu.org; Wed, 06 Nov 2024 20:23:08 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8rEn-00037a-FA for qemu-devel@nongnu.org; Wed, 06 Nov 2024 20:23:07 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3807dd08cfcso357989f8f.1 for ; Wed, 06 Nov 2024 17:23:05 -0800 (PST) Received: from localhost.localdomain ([89.101.241.141]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381eda066fdsm229541f8f.104.2024.11.06.17.23.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 06 Nov 2024 17:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730942584; x=1731547384; 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=vxVvEHAlcUJ/WXDJ+TYNZZ5nqed3WsROD6+NvXJeuxE=; b=jyHT7UcadNY8qW2oQIDXJPVhlWuE6GymdZ4dogdSYrJbCniu3lwL8YPdJ9z5pksi/D UvQDI9SJOkTHfVkKg87AwukuBuQtx5fZSchA1pomdimuu5+nPkHloSrxq7e38JbKuNAL EIj/qu5YaKwZVzjEqpYCPuph3a09hRCjc8N0ZaYUj8DmeQbpwcNh/JvLuLNJoPoHhrCv CwraB7pV2BffCRVRbE0hltgXR1kN/FkiikZUSlXLegH/zCt925sYJZVVZBEH7UsI89q1 K2D6ja5hHzXrC/HwMx9Es10KAmvVZUPrjN6VuvNKIhShAg7U0wD8z86srV1abiw7X9t/ 2CDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730942584; x=1731547384; 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=vxVvEHAlcUJ/WXDJ+TYNZZ5nqed3WsROD6+NvXJeuxE=; b=DcOhtKJkStM73SpJuPudn+/iZj/rML30uoVY8/kQf8Eua29rR/V3WPBrSvsXYFS9qY HF4pNQ/RNrNoJlhkqImyqdn1805wti3FaGLC1B58TdyBhhrZL9dhRRTO7Fy06ED68iZr i2ppWpU0hkVx1zSGXKo21XdXKILfcc87bFivMgWPtP2es1uI/HQWh8c4KQmeEpMc9ZX3 z8E+zWc/iwY0YQYgy0LW7ENsAW5uDGuGvJp/hBm87A3eaXEyf32Tznl+eGh7jjxqB+vH RPg7EaVUWYp7WcKzPIAOqfG/WGrjdHSkL+6maoW/wMNT+HO1m+7VosifGI3Z1J8IQjM8 jiRg== X-Forwarded-Encrypted: i=1; AJvYcCUCWcWhFwtGQfP1OmDv3s+EZUf0TjHcmE+elFYA1B8JX9WmUmvMkYiz5KtcVrnquknBEKRl6VuVvX1c@nongnu.org X-Gm-Message-State: AOJu0YyE28WzH7QAZoSO/G9GuH+ezsDMOY9rKOT+byJ+HhTOpXjVC5xR ar24CtcZxRgTZPS0mLjcAzMJNOuQs5yz38YQdWjYzcfNNIMGERa5eu+p77WcLAk= X-Google-Smtp-Source: AGHT+IHaW6cANGsgb/OCdjGpI4Q7XorCstWHGd8J+l9LgT/JCdH0l+c1qfiYCUmcl64I+dVf/Rd6Dw== X-Received: by 2002:a5d:47a7:0:b0:37d:53d1:84f2 with SMTP id ffacd0b85a97d-381c7a465cdmr23323925f8f.11.1730942583986; Wed, 06 Nov 2024 17:23:03 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Anton Johansson , qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Jason Wang , devel@lists.libvirt.org, qemu-ppc@nongnu.org, Alistair Francis , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Edgar E. Iglesias" , qemu-arm@nongnu.org, Peter Maydell , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 06/16] hw/timer/xilinx_timer: Make device endianness configurable Date: Thu, 7 Nov 2024 01:22:12 +0000 Message-ID: <20241107012223.94337-7-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241107012223.94337-1-philmd@linaro.org> References: <20241107012223.94337-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::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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: 1730942654640116600 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. 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 | 46 +++++++++++++++++------- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_= ml605_mmu.c index 64e8cadbee..f4ec983fee 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 f2e2dc2fd7..c0136d84c3 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 f378e5c4a9..ea0b3a56fe 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 c117bff225..d356807d7c 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,17 +193,31 @@ 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, - }, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 4 +static const MemoryRegionOps timer_ops[2] =3D { + { + .read =3D timer_read, + .write =3D timer_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, + }, { + .read =3D timer_read, + .write =3D timer_write, + .endianness =3D DEVICE_BIG_ENDIAN, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, } }; =20 @@ -233,8 +251,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 +266,7 @@ static void xilinx_timer_init(Object *obj) } =20 static 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), DEFINE_PROP_END_OF_LIST(), --=20 2.45.2