From patchwork Thu Feb 6 11:33:08 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: 862493 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp79045wrv; Thu, 6 Feb 2025 03:35:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUyDs70vHelpGTUEly6zlezXQ66ODIi51tTOz0SBbjdX7wUAEdagfiUnwjhaJL6K/WHClC6Mw==@linaro.org X-Google-Smtp-Source: AGHT+IE6xKzUdldGhv68RO+d5Nv/DXmZc96ZMXFKPuMaJqQi25V3lEVu2FDrs4/gs2pRFRcVd9Dp X-Received: by 2002:a05:6214:20a3:b0:6dd:84b7:dd86 with SMTP id 6a1803df08f44-6e42fc4aebamr108475256d6.36.1738841747112; Thu, 06 Feb 2025 03:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738841747; cv=none; d=google.com; s=arc-20240605; b=hbW9Vl9LhKgbuL2h+9Xi2kE3i4ve7j0Il+sxCcv8dQhaqV1JuKHHin3m5i8B50eqFn F7h3OWdGTOKd3nj/Je9OzfCGREFW7yb9R9cIrXeE7oTThlt+y1e9plQ5XQ2fqhVruJaW nmMmWO/AKO5zu1EDFXAdv3crvpiKbkSdEUh8wtYOFPIzBhoBdQf0aN8ka0txFQa4DSzW 9dOnxRs2tz4tGZ3GblEIXl7M774Tf/Qolwu9LPCZT+xkIc+34rNdw1Rhmeox6G/5WiFY JZpNbuKLzioTzlpiHUd8Jt+Xie+UcpghvZyz+qaew0Y1myeSbxRxOJbDOTFtbrerb7As FXVw== 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=4hjV9qje+F9WM+1u7JaIIDgc7g6v/WUaxTXGCOTYvnI=; fh=KB7JHaNjI5K4DpKM/QhtRxZS6iSNZtGQL2GKAsTumMw=; b=iDgPmGtzHvcwcGbB1mq/fn7o45sBpUoL3auCDUgKaReXP9NWAQqj1asnH6dBqaktfb P4d7z/mTXNZtr4vCJWK+oF14VY4jKrkwHHTnHMIQV42RBuXfBC6g6RATddQ1Eh6Y+7pM h6FSiil/EqPvF57NAHK6lP5BDlnsoTART+dLtkziCGyL5yJWbpAG4eyq7Dv+Bt5tToe+ C4ZE6wvNGhjPK4BUU8Xw7kmTTQYsIQ4uhS3/XrPEXnk/6MyGkFLiqOvzeYKSFI/IZRb0 +O18bQolNR+hNKLc6YANvVYl5G2lCYV8F288XMvvVRKLK6D0mUaWzX42+mkFK3kxThIU aHGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VPaL2ME7; 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 6a1803df08f44-6e43e836310si4991446d6.510.2025.02.06.03.35.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 03:35:47 -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=VPaL2ME7; 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 1tg08n-000776-Ug; Thu, 06 Feb 2025 06:33:54 -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 1tg08c-00072n-7j for qemu-devel@nongnu.org; Thu, 06 Feb 2025 06:33:43 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg08a-0000qE-8a for qemu-devel@nongnu.org; Thu, 06 Feb 2025 06:33:41 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso4307695e9.1 for ; Thu, 06 Feb 2025 03:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738841618; x=1739446418; 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=VPaL2ME7+Jyvnt33FsYFz0VcSH5barU2RrW4u4ErW67S5PC6XdbxXx8PN8Lvd3q3Mz utUcJ1SBJm0YOJL+nHyM2N1a7zaiiDpupwOqkBKHLKV4EMa6/iwCwwWBXnsf0iqV1Y82 S7PM0GMDkET0TBvH3D9FrzHyKPAIkbrDCO8x8/znMyYr2x5HLYBWKFhVYgjr8TZ43M8m btgca6aUkj5zdqxhFI4I/ootefVvcGBXoZW9rvHnlekjCuWzjdjw5N0eDZsgkpzIQsgy 7FO6xXL1nH2nAZ13DogD3VyW5QKhM04uaFb8X4zb53UeTDQUQc0M9rpgvAPzU7RWmYPE ohuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738841618; x=1739446418; 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=Sq6ywV7sWwvaSa4GaDjCP++TktN7zotNgjCk231+Ue/aJJdrLAd7cxELS/rdvEt5EE cnsOodF5mr8YNxyqByVdZbjMaRDzwYwX4mfWc+QVUt9QlyA4z0I5rRcoVzduX145ujJN npRj2WJwCpYlVPyNYzdTxqMFjxmhjZ9NwZcbdw3Sz+4gCWX9dENzYXA5GyF3/km2ipu5 Hdc4/Vx187HqOhzSxGzz34sN11ypMzv9LuHQs9u5iEuZyshXA3tyt1K9d7BsYRqrbc1N Mq+4OD72gb8jQSRzG9/wlyBrJvYmaOKwpG7cGKQPASvGZ9s62Jem9X7xy30RS6U00TbX OcWA== X-Gm-Message-State: AOJu0YwUnmO9mnGKSH7RIfoCWzK2AYiiF7yG/v40JXmzqX28+xLkAjni nieb0cpzP6cOXFiwUfr2d8PFD79e1t2JJrAf5v9qxdSXzbAdcCsvY0D8l+N8vvZUDo97PlaKujj qnfo= X-Gm-Gg: ASbGncs1DBSaIw/4+ZZ1R3WF6taJG2jsmkA37HL9ujXqGhgeUwZbYT7CiBCn/mQhvB4 IYodvxBhCgz3zOd8uQt8RJ8Exxp6xV2GPhbZRLkA3d0BC2ldpqBUYK46uL7qedmd3kODJro7M8F vZ9cbA/0aaOM7X4ICLZWLzbmAiRXINOFuB5zubEa5vPX6zSrTo78JFVy7SBxY+C7Y4OR6RkYdt6 T5IqhswlXiAT18aeJbmhVaOsMFRPpd9S84NLMiOWq3rWGA5jvyX4b59Oehu5/xw+ZVuhdJAuJoe L1GLvE9JWcT7iZ93iTcybY7acbt108fiAhesUZ3/mHit/Hqi6lZKZAKPf/aycrkPHA== X-Received: by 2002:a05:600c:4f50:b0:434:ffb2:f9cf with SMTP id 5b1f17b1804b1-43912d3f2f9mr20851085e9.14.1738841618150; Thu, 06 Feb 2025 03:33:38 -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-38dbde0fd00sm1497546f8f.78.2025.02.06.03.33.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Feb 2025 03:33:37 -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 03/16] hw/timer/xilinx_timer: Make device endianness configurable Date: Thu, 6 Feb 2025 12:33:08 +0100 Message-ID: <20250206113321.94906-4-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::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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/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), };