From patchwork Thu Feb 13 12:22:12 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: 864820 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp395326wrb; Thu, 13 Feb 2025 04:24:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV0/B4QKrdkLnmJf0jiz8ivobcEUtLlsNX2oh+YRriSWxRi7kaDPpxTzhmAIBC6enPqGrqGuw==@linaro.org X-Google-Smtp-Source: AGHT+IFJFjI+4437AAYWOdshEw7TIrvP+iK615Dq9RTq1/l4HtlLftrAZrlgoQ7unLvUKx9+mU0C X-Received: by 2002:a05:622a:1e85:b0:45d:8be9:b0e6 with SMTP id d75a77b69052e-471bee35d02mr53787541cf.43.1739449494862; Thu, 13 Feb 2025 04:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739449494; cv=none; d=google.com; s=arc-20240605; b=BLfp/5ZpLkmQKGKcFMU+YtO1gGuVi87plaEKfdwg2Y9nSDuUotMqkiy9booci4vv5y owbFIagwXRjMNeXicDPANR25Qtt0GwbvTir5yJhkaUsPdjW2eWxtT1BEcWWDIjYxVeu2 mNCaWcldvtu9KqLnbJtm3Tvlw5qCHHqHdlaXZIOtx8HO8VMb1z6l6WHUMxrJ1olhglIJ CvK4X5ZlTCndgNEcdgWAArHLdyaVmeDHn0dT/rqZACY0NNqzmZDwWaEVVhxZYd9AcCWP lm3l2WeUDon4F8TtChSyunAYs2weOFkXOM8SlajzPECvCECb6tkD83M/6i46eozyPye8 hmLQ== 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=a0QIUZ9G9ceuu7BOeFAVNnHGygrUdl1K5aeRH+HplWk=; fh=7G23nAa7ccyiTxKVJ+ZzEMcKfCbp3J9CFWyGkTQOXRo=; b=BXuc5MZmoG6shrkEyX7n0EZZ+DzidPXBGUqFG6ppEp0IWjx660dr++XMxRlCT1hh7f 96v93tJtQaLI/YpP3kX6t/pB1mN2E6LrQ2UBBXsDGTVAyWrTtn3Tjj+IMtItCej2rOrZ T4lT077gG+OcHpFo/PPSUTMyG8+JcZje1ZC480cC2BRvlKj/I6XMZ+RYh/vmJTV0lM7I G8i2yROjAvEVS2BYUz0DZqIVVvXSnhdSJxykAF9W0jpjPRoF+h93na8+yDljuldoy+vc aHbWw9UtxO28zxfR3AC0DzRWQV3hkLnlvsPsE9B9hzKxM5ADPKg0J+/zdpXM7Fv+1beo a/Zw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wj28MKwQ; 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 d75a77b69052e-471c29ef8d0si12683221cf.57.2025.02.13.04.24.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2025 04:24:54 -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=Wj28MKwQ; 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 1tiYEs-00025O-TB; Thu, 13 Feb 2025 07:22:42 -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 1tiYEm-00022G-84 for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:36 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiYEh-0002U2-1I for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:33 -0500 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-aaf0f1adef8so159164666b.3 for ; Thu, 13 Feb 2025 04:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739449348; x=1740054148; 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=a0QIUZ9G9ceuu7BOeFAVNnHGygrUdl1K5aeRH+HplWk=; b=Wj28MKwQjCLsaCYr0OPKaCevm2TVyfbZqzveO0WvPlt8+TxlJAUji1141zrGwpoahS l/zIIQeVXN68kXcYgx9EkxmwmNOCPBHUKCKH4iJMwiToY69GcfGU/mYTt4qI86W26YYX PRswk59ilZopiS1T+VzVpNfOXS/vWuDxussSEen4wF6pDd9p9KOnU0r2LxXViRgwcqxT V5bRCmlnS2+WexzqVoamHSFtsCL/28iQOuuzTNigwR3OUkLRvF90GlL8i+hMwzBOhZzu +cBAKy8VJVuVe3qIU828cpz9rEhzGdRw/OWzwAEmYzSe1zjz4/m1S4/095YeunaE1FQF UWNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739449348; x=1740054148; 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=a0QIUZ9G9ceuu7BOeFAVNnHGygrUdl1K5aeRH+HplWk=; b=kz+YLsPGSxvy1giSVroAVfMU1OO8xjSqZk/AgDqrvqH/0D6kqh5O23D7sfqLZe7gaI VYmgmk56UuR1GJ662pPE/olUbrzhssSIB30OLsgpdG/jwKWmOOQBRkJvXL29CNLBoZ/Y 0TgwNQ6NjPdGDjwzRR3GnmpTyZt6hNtMoG1UDtYq2QjAugnsKljDYWh084WmUJWzTMuK FKo3eaP0eJHXKrRlDljQyF0YqzFzaChKxue+IrQXTRKSi0VK5VuP7mCfChed/T8xJfbE ukVyZEAnoCKSxLGJgM+fHyeC2MMu+3PS3GLrMHrq+9/RuepW9jNfLyY+bVFI1pxafFIm CzPw== X-Gm-Message-State: AOJu0YzCQUL/VPkim806D84Lga2gBXmhVQuze5c7midLZPYnI2M50psg XAcXiu+5cOIKV/IjEQUX+d8OPT4rRMq/t1avP8poEoBCec/6MzBZD61MEG9oQCCHxTRAIuwGzIX 7aQ0= X-Gm-Gg: ASbGncsWwhz7ubedPhxDEOABmlVTopRTrzkSCaAPpX/VROS4FeZGMObPPY2vFxlHTMY urb9tjYM5VbFQdDhHWD1L8HpqosLgg0keA2OiX1HVCSsqoUh+rUcbxiKk21N0TbuagoYv4M/NuB BX0ApmId2mCEivmCJPtgt2VFTMugBfesLI+lsJzw0Fjy9ZhwMuY25f3Oh0K+fQ66Zi4wUfeOdku hRy4h9rJGsUzKoivIK4fyj3cXgGSHSL5hlIqybUYcm3l0gk0pthEh1M14s0A/+l8TTKFS15Ox1B q06otcmpGvdRsDJEuCOqw+9y46S3kQwAPzupuHdzT0IaeiIWfugkxHvsG+Ma X-Received: by 2002:a17:907:3da2:b0:a9e:b2da:b4a3 with SMTP id a640c23a62f3a-ab7f347dc2bmr670610566b.42.1739449347940; Thu, 13 Feb 2025 04:22:27 -0800 (PST) Received: from localhost.localdomain (6.170.88.92.rev.sfr.net. [92.88.170.6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aba5325ac21sm122673766b.73.2025.02.13.04.22.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Feb 2025 04:22:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v8 1/6] hw/qdev-properties-system: Introduce EndianMode QAPI enum Date: Thu, 13 Feb 2025 13:22:12 +0100 Message-ID: <20250213122217.62654-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250213122217.62654-1-philmd@linaro.org> References: <20250213122217.62654-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Introduce the EndianMode type and the DEFINE_PROP_ENDIAN() macros. Endianness can be BIG, LITTLE or unspecified (default). Reviewed-by: Thomas Huth Acked-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- qapi/common.json | 14 ++++++++++++++ include/hw/qdev-properties-system.h | 7 +++++++ hw/core/qdev-properties-system.c | 11 +++++++++++ 3 files changed, 32 insertions(+) diff --git a/qapi/common.json b/qapi/common.json index 6ffc7a37890..0e3a0bbbfb0 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -212,3 +212,17 @@ ## { 'struct': 'HumanReadableText', 'data': { 'human-readable-text': 'str' } } + +## +# @EndianMode: +# +# @unspecified: Endianness not specified +# +# @little: Little endianness +# +# @big: Big endianness +# +# Since: 10.0 +## +{ 'enum': 'EndianMode', + 'data': [ 'unspecified', 'little', 'big' ] } diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h index 7ec37f6316c..ead4dfc2f02 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -30,6 +30,7 @@ extern const PropertyInfo qdev_prop_pcie_link_speed; extern const PropertyInfo qdev_prop_pcie_link_width; extern const PropertyInfo qdev_prop_cpus390entitlement; extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; +extern const PropertyInfo qdev_prop_endian_mode; #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) @@ -97,4 +98,10 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; DEFINE_PROP(_name, _state, _field, qdev_prop_iothread_vq_mapping_list, \ IOThreadVirtQueueMappingList *) +#define DEFINE_PROP_ENDIAN(_name, _state, _field, _default) \ + DEFINE_PROP_UNSIGNED(_name, _state, _field, _default, \ + qdev_prop_endian_mode, EndianMode) +#define DEFINE_PROP_ENDIAN_NODEFAULT(_name, _state, _field) \ + DEFINE_PROP_ENDIAN(_name, _state, _field, ENDIAN_MODE_UNSPECIFIED) + #endif diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index a96675beb0d..89f954f569e 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -1283,3 +1283,14 @@ const PropertyInfo qdev_prop_iothread_vq_mapping_list = { .set = set_iothread_vq_mapping_list, .release = release_iothread_vq_mapping_list, }; + +/* --- Endian modes */ + +const PropertyInfo qdev_prop_endian_mode = { + .name = "EndianMode", + .description = "Endian mode, big/little/unspecified", + .enum_table = &EndianMode_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +}; From patchwork Thu Feb 13 12:22:13 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: 864821 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp395348wrb; Thu, 13 Feb 2025 04:24:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXpYjDJE+1xU6+4oe6YBSjuFDbu0usOmRjnRepvmOi2M5qOdE4NAfyQpoA58UBhLCvzUR7WeQ==@linaro.org X-Google-Smtp-Source: AGHT+IHIT8Hof9gzjiMH9wqkb3qXWfZTtUTBPs7uD6xDdX76RineilppVmYAYzSCoHIuhmXr/SGR X-Received: by 2002:ad4:574e:0:b0:6e6:6071:64d2 with SMTP id 6a1803df08f44-6e660716758mr18624836d6.7.1739449497518; Thu, 13 Feb 2025 04:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739449497; cv=none; d=google.com; s=arc-20240605; b=PAxI0diEDwflxNuavuPUfdpEUwGjG4dskUIv88MD3eeCvCXSMxVnkFsIVF8JYcKf/J 8J2qgDFmOM2b5IsG9xr0F6wRYG72QSP98vSX4HSH4hKgag3ss4y3M1NaObU/qbyYSWbx IlYsZy0Zw8bZKqzoK27g6Pf9Gy/3rXGrk7xYRFif7ysOk925mXkB6czaITyOT/E+PXrC SzA+WfFDcXEtijA6J/WzY/rAUBTiaFTVfcuszeHxPzTV2CPS8Ol5Q8XjjelnwKzarPWQ mKBJsHhYAFGYOt65CYJWIxlgc5PDI6TE7UDF9jR6BsCID7gnG4HyiN1p5cutu4HyGJ/1 7sxQ== 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=kzVstd/WanADpU0G4jEJI1w8lBuZvtH+Hm5ddGyKGck=; fh=7G23nAa7ccyiTxKVJ+ZzEMcKfCbp3J9CFWyGkTQOXRo=; b=NeZxM4TTQii5VAW0x5k2+PiwxvRdiT/SkPhwjyEwszlLC2EBXdYkKFzDa+TKg3Oiim qlgnw8S+NhLl1KDSV+8N47CKiUfjNE0lYkH+V4+1q0rXOF7vu5+5JOvw7s6B6L1aRfss 4UjWXnHLpNZ/Qw0l18IRHajt9DAKUERQLZ9nOm3Hn/0B3sGiGf+sgowmaWwVpST2l4bF fary7owSi/cu002dMtB30Fg0w/DBVojNcS2/AJaJv72VIpsXF33rNrtdG9LcMUauvlO9 8cxKF/8HDOZSjE7MvWQWcVC+tRUnEv/9KmfnnG5CrQeigrRujg24jnzrP4AqDW5yn58g x0Ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0Es762X; 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-6e65d9a1f91si12513666d6.257.2025.02.13.04.24.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2025 04:24:57 -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=m0Es762X; 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 1tiYEs-00024v-He; Thu, 13 Feb 2025 07:22:42 -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 1tiYEq-00022b-Ls for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:40 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiYEm-0002VE-9u for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:39 -0500 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ab7c81b8681so160088266b.0 for ; Thu, 13 Feb 2025 04:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739449354; x=1740054154; 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=kzVstd/WanADpU0G4jEJI1w8lBuZvtH+Hm5ddGyKGck=; b=m0Es762XKKw7U0KAdLkDhMCVSi1qitphoAdmadDcp3YdkOZbAuxOjpVFqGcmb77Aav 7fqrilR3NeTGpTATw7hJzuefi2/HnT2m/LAHHweE1he5dcYAqyqgEIiL4kaAF28USpvb bJohADTb+ntbNdChm5F1no9NzN+/jfCbqC+DIyqaK1N73ksIH9Ee0Q7U5Yhua2idQTZo JidppUK3sMuN1TiI9/X4/S8MHkixNwd9/E0HQh5QDgBN16qIyK14C0GN3+MLpz/ZG833 faVigDgkjrligrXZe/IC8svNdUHl1nNLHyKa6z84ZTZplCmxQRHPef7G7gNlT/7CH7su MB5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739449354; x=1740054154; 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=kzVstd/WanADpU0G4jEJI1w8lBuZvtH+Hm5ddGyKGck=; b=EFUb2cVLfk98Omz+VkkFuszSWrbp4j+S6SgQX4sExKerkI0W44kE6VEx6fsWxNIjEZ U3Lf7r0Z2Bofo3eQdB77uC+qEt1aoh8QjHhaBwhcQvv4pT2Vw4s8o4YOriJZnrYVD7Ku 1q0NL67M4yNudW10SGgY3KL2CIuuYU5NSwn5J6vUWNPmUUtp1vnbEOsr+j2k32wjAY0t rYqcDLwOlDY2yFDBFw7hkDdv6BYReGXRQL9rOeHB2ciy9nTBLetJTnNCPH1BgAh3++L9 9yNn+xOS4vbYsXQVaE7Ci6AY8hM+gOUdM6CccH5MoneU3BcXzJOYRhc+5VOtQ0muT+CL y+0Q== X-Gm-Message-State: AOJu0YyDxkHuWQW50w9xfuTeq4rdM9K5H2NLNwuJXbfZGuvyCCKTaoS5 WUHujptq0IeXOQ6P12BJ4jp+53Awj1bm6N0pQjvANBEi+ZGRRfKwCPWIsUAfN9WkpUgkU6ZHn0C qyIo= X-Gm-Gg: ASbGncvTokCv+vVXzzVVoxXXhzyQNzgmC32BST0Mu972SRXVttRV8KbZi1OF6sKnxHB nvQA/7e45aZ6YCKcgK3uIIYCz3gGumAZv51c1tBpNZlA5Tyq2t2XpfkkW+iWrbk5d73Cycyzk5G kmIlE+Ckh98CJzBx/dOr9exKD6IN9+y3NUqU0Ig7SG0gnk7IAsg1qRPr0Bdf5AHz20PsZMa42Sj copp4HTLJPTylp9phevBe9N4+us3JYsBv0gJljPE+dbog3IL98k1+ws2UIG5ln7fzMA4LKTdR3h Q1/RQAws3wn1Zk3iCofMrzYBKUG1wPENqndF58rT39zz69UnQOsGhhSkbUgA X-Received: by 2002:a17:907:28d1:b0:ab9:63bd:91be with SMTP id a640c23a62f3a-ab963bd9feamr245210466b.3.1739449354114; Thu, 13 Feb 2025 04:22:34 -0800 (PST) Received: from localhost.localdomain (6.170.88.92.rev.sfr.net. [92.88.170.6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aba532552a2sm122968766b.52.2025.02.13.04.22.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Feb 2025 04:22:33 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v8 2/6] hw/intc/xilinx_intc: Make device endianness configurable Date: Thu, 13 Feb 2025 13:22:13 +0100 Message-ID: <20250213122217.62654-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250213122217.62654-1-philmd@linaro.org> References: <20250213122217.62654-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.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+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 "endianness" property to select the device endianness. This property is unspecified by default, and machines need to make it explicit. Set the proper endianness for each machine using the device. Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/intc/xilinx_intc.c | 59 ++++++++++++++++++------ hw/microblaze/petalogix_ml605_mmu.c | 3 ++ hw/microblaze/petalogix_s3adsp1800_mmu.c | 3 ++ hw/ppc/virtex_ml507.c | 1 + hw/riscv/microblaze-v-generic.c | 1 + 5 files changed, 53 insertions(+), 14 deletions(-) diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c index 6930f83907a..ab1c4a32221 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 @@ -23,10 +26,12 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "qemu/module.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qom/object.h" #define D(x) @@ -49,6 +54,7 @@ struct XpsIntc { SysBusDevice parent_obj; + EndianMode model_endianness; MemoryRegion mmio; qemu_irq parent_irq; @@ -140,18 +146,28 @@ 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, + .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_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static void irq_handler(void *opaque, int irq, int level) @@ -174,13 +190,27 @@ 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); + + if (p->model_endianness == ENDIAN_MODE_UNSPECIFIED) { + error_setg(errp, TYPE_XILINX_INTC " property 'endianness'" + " must be set to 'big' or 'little'"); + return; + } + + memory_region_init_io(&p->mmio, OBJECT(dev), + &pic_ops[p->model_endianness == ENDIAN_MODE_BIG], + p, "xlnx.xps-intc", + R_MAX * 4); +} + static const Property xilinx_intc_properties[] = { + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XpsIntc, model_endianness), DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0), }; @@ -188,6 +218,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..a876aeb0bba 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -80,6 +80,8 @@ petalogix_ml605_init(MachineState *machine) MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1); MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; + EndianMode endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG + : ENDIAN_MODE_LITTLE; /* init CPUs */ cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); @@ -111,6 +113,7 @@ petalogix_ml605_init(MachineState *machine) dev = qdev_new("xlnx.xps-intc"); + qdev_prop_set_enum(dev, "endianness", endianness); 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..15cabe11777 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -71,6 +71,8 @@ petalogix_s3adsp1800_init(MachineState *machine) MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; MemoryRegion *sysmem = get_system_memory(); + EndianMode endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG + : ENDIAN_MODE_LITTLE; cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort); @@ -95,6 +97,7 @@ petalogix_s3adsp1800_init(MachineState *machine) 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); dev = qdev_new("xlnx.xps-intc"); + qdev_prop_set_enum(dev, "endianness", endianness); qdev_prop_set_uint32(dev, "kind-of-intr", 1 << ETHLITE_IRQ | 1 << UARTLITE_IRQ); 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..df8f9644829 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -217,6 +217,7 @@ static void virtex_init(MachineState *machine) cpu_irq = qdev_get_gpio_in(DEVICE(cpu), PPC40x_INPUT_INT); dev = qdev_new("xlnx.xps-intc"); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_BIG); qdev_prop_set_uint32(dev, "kind-of-intr", 0); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR); diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c index 26788a1824a..ebdd461ae98 100644 --- a/hw/riscv/microblaze-v-generic.c +++ b/hw/riscv/microblaze-v-generic.c @@ -79,6 +79,7 @@ static void mb_v_generic_init(MachineState *machine) memory_region_add_subregion(sysmem, ddr_base, phys_ram); dev = qdev_new("xlnx.xps-intc"); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE); qdev_prop_set_uint32(dev, "kind-of-intr", 1 << UARTLITE_IRQ); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); From patchwork Thu Feb 13 12:22:14 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: 864822 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp395352wrb; Thu, 13 Feb 2025 04:24:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV1oxcH+/vKACVwe4vOurYiQvqKZziPVT9cRSxkgWKUTpfbVRKnvOQ24dAo28uPaGX0+GyB+Q==@linaro.org X-Google-Smtp-Source: AGHT+IEcpbIsfN6bHZsnJf/J4XGDJVRfh3v4gXwRgFlX18xiE5Mtx/Kkcwkna/L3ipZFdem0gnMZ X-Received: by 2002:a05:6214:f0b:b0:6d4:18ce:117f with SMTP id 6a1803df08f44-6e65bf48ae8mr62168776d6.20.1739449498237; Thu, 13 Feb 2025 04:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739449498; cv=none; d=google.com; s=arc-20240605; b=Wnf/xV4VlrcQv6T+DwEDDNoovN8VsARQn3Zl7VZvq7ntJkpjEyVSJlNEbROAB9f6cy CRmMP+RNiYH298ZjkQr+8F8n4IgDDglnS3hhCuPnMcMO3oehagrKYcReyhmCewr2Pp71 IbLflzxkWIhGlNJW8DEnBORn30s+LSn6mzcQMUXoEpLGTKDU6MU3/4RgeXqmw61j8VYT OfEx+Rv4pC1t9clrxCxx5f//A8X6zRnIwa3QsFMk991eyUGV+VaBa76L8LkAbe+iudRE o7d/OkjFMRymIDIhWULF0fUQW0QBYP/JzDIwNmVDZVzC9FDjk6ppyGdv8mKp3Cft7LMZ 814A== 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=r3JDPQWYy24MD735D0eYi/u2QpMsBv2AYsysjl3US+0=; fh=7G23nAa7ccyiTxKVJ+ZzEMcKfCbp3J9CFWyGkTQOXRo=; b=L5QmagD+9WhtvNi+/6QAWysWs4V80+HGI2bww1BwxkI2QHV0LU49EOsnAXaSqJsFBG NdLElBsLKkG1yC81QmaTX9n20dAEin/ryhAhgIsX8l/ujdze+JV0QHpkAmEasAd4RIg2 pwRXYGM6GYaymB/bQx94+BcnfK8GFU77TR/3SpMBN3jXU5o0CqWAhima3bOEkfLca9Kc aWnxoetfyzl9wf4aUSbpxZRNhkIzSu4Oz08bQBfwh0+qx3nAGz/NRLMs9f/3RZX1cS5R Ow2daEUH5iMcQtsqff1/J49HX55B4PbenEB8xwU8O6FtDC+bCixUPYbYLydK6XM/6K6S 84CQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mNfBdApz; 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-6e65d9ba826si12564156d6.273.2025.02.13.04.24.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2025 04:24: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=mNfBdApz; 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 1tiYEv-00026P-Oq; Thu, 13 Feb 2025 07:22:45 -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 1tiYEu-000263-7B for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:44 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiYEs-0002Wo-98 for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:43 -0500 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-aaee2c5ee6eso141410466b.1 for ; Thu, 13 Feb 2025 04:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739449360; x=1740054160; 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=r3JDPQWYy24MD735D0eYi/u2QpMsBv2AYsysjl3US+0=; b=mNfBdApziv2SIrFJzQPxLi4yEHCwQQBlXEGGY4dSu08SqJCQrW2jKNQWe+JQ9KN9ha Sq9ds4ZdoM5ZbjITcwikcW8xGW6MvMQm7TANt3a9w/XeJvNNcrR2xgc4fphiFeFWJzWo v9hsVAexUcS6HH5Odray6GZW/7BpDclyTID4uZvkt3ruiWS1eYuRZwFJ0lw2KO2uFMNg K1gDYQgbnS1bTn640kOrL+YAzyK+fW7ZtSBwhqwPXX8dmVn4jA7DuhF/cHgJxbLMY+OF zNizKncyW447jPaSFRj/c0FgJ16Ppm/IYE1yXcLgyT1l06fKxRKeBVAGkVzVFu1DVi2Q rSTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739449360; x=1740054160; 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=r3JDPQWYy24MD735D0eYi/u2QpMsBv2AYsysjl3US+0=; b=Nzcn6yBtg34xKiHK5p+yFgbAcBnLkV+YszKgeowqqK8xQyLm8sSAOeorzDAGdjsYIP vhHG2ND55U8W6UnmmhZKW5IKYiecbz2QhbdHcf6qB5k8gS9boAqEAJmP7LkJ8A22tVmQ xaAf1Ze5sVpdl2nSVuA2cmmgt9DmsREDdP278TFvzazsjtZyGdmqlpwr7WRyeIXftMiC j4jHXlXiCI4H+JbGGGNCurgEcC10Qt4Ha6xJTQcMgiFk7kcOAmd0XYGEa5O1TtSklk6p isTBiGSS30Iq3DJUik7jbl6Etmomj90+LkNRkeMRHsLZtNRi7knuozhCFAxa1gpCnYFE joHw== X-Gm-Message-State: AOJu0Yyj394dju+tBnhjgLWHEUcYbsIfa9Qst/SV/TN7UkcIstKATOnh fqq1FRpc2kuMhGx4cnP8IUsBzfFRxcouwDizmHoSyOfmnmoXC2e7OwkkMXMs/miuyjAfCvHctwq bUvE= X-Gm-Gg: ASbGncu1iKy904C7q+t353mTO5NIfeWwD67m4c/z3Y3jA2vcbs/XQW3mA6hpomh07Eg 6eYcT4AN82qF2EV1th7SUo1G0ThtoziiuydjYOojX0OIlBLCXBNIdUArStqvMPXuNlf/SQle1q/ kggl2AjBkPx797tOWvN3ck0LygcLqUNKVrWFZoT4VaMvvzv/z9DhM91ysMqsi08eOawAWHSKP5O oE8bLCDlOv6UzC+Qll0/i30Hal2b8zaUEUSwX1R2LevP3IKCDbm5X1b8+J3PrDGqf90JcFSPPJY 9Qs+gqrfurIBWQtWMqbqys7ReRRR5uc8TvPRHOMc79ycPUHjaeZl0UAZfMr3 X-Received: by 2002:a17:907:7206:b0:ab7:ee47:993f with SMTP id a640c23a62f3a-ab7f34a31c4mr634545966b.47.1739449360292; Thu, 13 Feb 2025 04:22:40 -0800 (PST) Received: from localhost.localdomain (6.170.88.92.rev.sfr.net. [92.88.170.6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aba53398364sm122047166b.128.2025.02.13.04.22.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Feb 2025 04:22:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v8 3/6] hw/net/xilinx_ethlite: Make device endianness configurable Date: Thu, 13 Feb 2025 13:22:14 +0100 Message-ID: <20250213122217.62654-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250213122217.62654-1-philmd@linaro.org> References: <20250213122217.62654-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.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+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 "endianness" property to select the device endianness. This property is unspecified by default, and machines need to make it explicit. Set the proper endianness for each machine using the device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson --- hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/net/xilinx_ethlite.c | 29 +++++++++++++++++++----- hw/riscv/microblaze-v-generic.c | 1 + 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index 15cabe11777..d419dc49a25 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -123,6 +123,7 @@ petalogix_s3adsp1800_init(MachineState *machine) sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]); dev = qdev_new("xlnx.xps-ethernetlite"); + qdev_prop_set_enum(dev, "endianness", endianness); qemu_configure_nic_device(dev, true, NULL); qdev_prop_set_uint32(dev, "tx-ping-pong", 0); qdev_prop_set_uint32(dev, "rx-ping-pong", 0); diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index 14bf2b2e17a..15d9b95aa80 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -34,6 +34,7 @@ #include "hw/sysbus.h" #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/misc/unimp.h" #include "net/net.h" #include "trace.h" @@ -85,6 +86,7 @@ struct XlnxXpsEthLite { SysBusDevice parent_obj; + EndianMode model_endianness; MemoryRegion container; qemu_irq irq; NICState *nic; @@ -183,10 +185,10 @@ static void port_tx_write(void *opaque, hwaddr addr, uint64_t value, } } -static const MemoryRegionOps eth_porttx_ops = { +static const MemoryRegionOps eth_porttx_ops[2] = { + [0 ... 1] = { .read = port_tx_read, .write = port_tx_write, - .endianness = DEVICE_NATIVE_ENDIAN, .impl = { .min_access_size = 4, .max_access_size = 4, @@ -195,6 +197,9 @@ static const MemoryRegionOps eth_porttx_ops = { .min_access_size = 4, .max_access_size = 4, }, + }, + [0].endianness = DEVICE_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static uint64_t port_rx_read(void *opaque, hwaddr addr, unsigned int size) @@ -232,10 +237,10 @@ static void port_rx_write(void *opaque, hwaddr addr, uint64_t value, } } -static const MemoryRegionOps eth_portrx_ops = { +static const MemoryRegionOps eth_portrx_ops[2] = { + [0 ... 1] = { .read = port_rx_read, .write = port_rx_write, - .endianness = DEVICE_NATIVE_ENDIAN, .impl = { .min_access_size = 4, .max_access_size = 4, @@ -244,6 +249,9 @@ static const MemoryRegionOps eth_portrx_ops = { .min_access_size = 4, .max_access_size = 4, }, + }, + [0].endianness = DEVICE_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static bool eth_can_rx(NetClientState *nc) @@ -300,6 +308,14 @@ static NetClientInfo net_xilinx_ethlite_info = { static void xilinx_ethlite_realize(DeviceState *dev, Error **errp) { XlnxXpsEthLite *s = XILINX_ETHLITE(dev); + unsigned ops_index; + + if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) { + error_setg(errp, TYPE_XILINX_ETHLITE " property 'endianness'" + " must be set to 'big' or 'little'"); + return; + } + ops_index = s->model_endianness == ENDIAN_MODE_BIG ? 1 : 0; memory_region_init(&s->container, OBJECT(dev), "xlnx.xps-ethernetlite", 0x2000); @@ -328,7 +344,7 @@ static void xilinx_ethlite_realize(DeviceState *dev, Error **errp) BUFSZ_MAX, &error_abort); memory_region_add_subregion(&s->container, 0x0800 * i, &s->port[i].txbuf); memory_region_init_io(&s->port[i].txio, OBJECT(dev), - ð_porttx_ops, s, + ð_porttx_ops[ops_index], s, i ? "ethlite.tx[1]io" : "ethlite.tx[0]io", 4 * TX_MAX); memory_region_add_subregion(&s->container, i ? A_TX_BASE1 : A_TX_BASE0, @@ -340,7 +356,7 @@ static void xilinx_ethlite_realize(DeviceState *dev, Error **errp) memory_region_add_subregion(&s->container, 0x1000 + 0x0800 * i, &s->port[i].rxbuf); memory_region_init_io(&s->port[i].rxio, OBJECT(dev), - ð_portrx_ops, s, + ð_portrx_ops[ops_index], s, i ? "ethlite.rx[1]io" : "ethlite.rx[0]io", 4 * RX_MAX); memory_region_add_subregion(&s->container, i ? A_RX_BASE1 : A_RX_BASE0, @@ -363,6 +379,7 @@ static void xilinx_ethlite_init(Object *obj) } static const Property xilinx_ethlite_properties[] = { + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XlnxXpsEthLite, model_endianness), DEFINE_PROP_UINT32("tx-ping-pong", XlnxXpsEthLite, c_tx_pingpong, 1), DEFINE_PROP_UINT32("rx-ping-pong", XlnxXpsEthLite, c_rx_pingpong, 1), DEFINE_NIC_PROPERTIES(XlnxXpsEthLite, conf), diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c index ebdd461ae98..a21fdfbe6db 100644 --- a/hw/riscv/microblaze-v-generic.c +++ b/hw/riscv/microblaze-v-generic.c @@ -120,6 +120,7 @@ static void mb_v_generic_init(MachineState *machine) /* Emaclite */ dev = qdev_new("xlnx.xps-ethernetlite"); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE); qemu_configure_nic_device(dev, true, NULL); qdev_prop_set_uint32(dev, "tx-ping-pong", 0); qdev_prop_set_uint32(dev, "rx-ping-pong", 0); From patchwork Thu Feb 13 12:22:15 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: 864817 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp394888wrb; Thu, 13 Feb 2025 04:23:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU+IAfgqELf/OVKr1TFxjVbyvOJ7uIADW0kVZIvpqLIdlDgID7DMHrMXJZ1tBvLeXGnYTtbGQ==@linaro.org X-Google-Smtp-Source: AGHT+IGbKQfp/xAoDcKWdUXe8cysHX+1hQnInD7SpNbV5cYO++4anzOtuC8F++nZPv/1tja0kGpx X-Received: by 2002:ad4:40cb:0:b0:6e4:25ff:4bac with SMTP id 6a1803df08f44-6e65c9ba194mr38053706d6.10.1739449427172; Thu, 13 Feb 2025 04:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739449427; cv=none; d=google.com; s=arc-20240605; b=VXHxWW+61C2omXvACWJqJWagXcq26OMqLo+lm0QXkvmR51S9OlyWL7+ZrYXymA/6XD lxZCMBHjc1r28N6XMKSLM6xaBlpTLxKtPEZm1nYenR10flz3obqzR65pXG1s3H6sSxyr Q7VziZgNZCIJrwYb1tGSikDyOtwLdqvkrCfEq6o2/Gfsuux5D1aQgDIngB7//qplRdF2 86CSmqKuDOT6JM7B/RuNY2W8z/iBsRB0rn5Ss5tFl020MKw543IoBIH+TxCbuc++xdRC /0iscpswvB7sDTZh5Gc+dRQXfhzUtqtIY1Dsy9pXspzHVwx2syhkQPvRmUYQW/cTBP1q Z2IA== 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=beBXQzm8Odt1Uvf1Ve10OQizHRpq30qh6q1sWSZQAuE=; fh=7G23nAa7ccyiTxKVJ+ZzEMcKfCbp3J9CFWyGkTQOXRo=; b=ins9NWzOJbkASpVzoFPpzUmraC9PLIw11VEVvsg8Mn4dSphKiWnKo0IUpSyJTEGBdV N9TYL7Yvl/0lZweEiWIzqZZXDZajODVbWaPBa14v5WmvLs0bmfryNKTNTU9ae62uA31L 2Va8koVNcK2V2RCgY7UY/YLE1jUWzL6oBX4ajsLS6/1+Hl9tbHfl5dH6nUFGGy2+G/7b hP28D0+k6zBeK1eX+FN+7m3I8AEpjCfG8SuLZQZr+3JwACM9IzqiN2tmC4hG4B/ff1kg I2DJOt/q6dPsXlG8a3orZhnPZib/+o34Dp8uFJLRPUlrKNY/okpI7mBhMi9rd9NeBtcH PlEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ufmcSU/R"; 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-6e65d9c4b4fsi12691516d6.368.2025.02.13.04.23.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2025 04:23: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="ufmcSU/R"; 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 1tiYF2-00028h-De; Thu, 13 Feb 2025 07:22:52 -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 1tiYF0-000282-Or for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:50 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiYEy-0002Y4-QW for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:50 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5d9837f201aso3954249a12.0 for ; Thu, 13 Feb 2025 04:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739449367; x=1740054167; 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=beBXQzm8Odt1Uvf1Ve10OQizHRpq30qh6q1sWSZQAuE=; b=ufmcSU/Rmk+KYqCAPHEiAdBc+dtGS+8yGroT/ZNKtYOEOc96GJlXuBVOK0Og6aVJz6 YypEmVIaXVet5lIBNEp05MbVsXJXQ3rWxRYauAXXDg3iR9xcsKcoTyDOj+hByQZBni1e RWkMnstgaszBkD+M33zE9wnsS07UvynrhyH5q9Pg/NAdlagKABQY5JTzhP4mqngyKic6 iPOVDF/eWG9Cg0LPp3ZaVWAybRr/BdjvdYpy6UAPh1id6BcVA8Ho+EaH09pwZwdvowRM t7pRi2ecIapYGSsZJ23MEba5I+VaqeGe6bz4ltMydHQLehpE33wwiPsCnz2S7nUa6xC5 /qYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739449367; x=1740054167; 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=beBXQzm8Odt1Uvf1Ve10OQizHRpq30qh6q1sWSZQAuE=; b=g+wIlikhAyoYr6Rbteed7Xy2FDeLPHJhGKwvxha5zRJgkHVN18q+ZC3AM43ABO+0VY xvxg5u88TV1QBgDD9w5USHVrjrjM3MRN6BjJ+AZq9VSzY0WXyHyTyRNLBK2BNTedMHdm 3fLnGOFngCiu0P6OAKIHXpngCPZpmAENoSbNdrIsmsg0uMxr3vMK6EUjv5+SgQPBdLL5 bJgLDgE0x5zYRQuoEguBnBNS0BuWiTowpnGpmfXqz2yEwgTBbrPM9MpbM0TAb4voCY7G V9GZ/Zy2+3WJE3BhIOJ+Ku/exIhOeYx75eY//wibEQ4QTyPKD3ok7KoLgUCp5rceb0ZG jVJg== X-Gm-Message-State: AOJu0YywomX0gJKkAdMNmPmpzPFOI4XejF1mOWmg0YFhFJLYGKlFb1HB mdeRM/rgLom2yYdKiviOw61GvEqpF7JsM6VoBG8fgFyGo1DB9t1xssvZfJDjAaqgiUvNYw5FvkD bTiw= X-Gm-Gg: ASbGncv2nAbrThdzy6iVUgTdbsQiVypOLin7uUXhLamGQtNLahqAUk0kmappBHSus3x rxP0P9t2QIYHl2biWV4l4Xt7T74+Qp4hxDaJMwHSscH2FPy9nQMqfOaKEB+YRr9+WjGyTHsKhDp zD5kw/+EzmsHsu5HcK8fsajWL/5nZPADafhbrRsJ1uRxX254Dce9r2+mASWUzezmWTECD/UPfoE kBCOeVU4Mryn8v20hYUCb+Djbns2uE1Nl3TmUwK6T0C5BFBxluONS31O3071JUxBPKgJzQCnCPT WdNuoDWvSsDLDd8rD35gd9uM0aXEew/3QfDPDLksnmoeQXoeXKLYlbGiYh0s X-Received: by 2002:a05:6402:1d50:b0:5db:68bd:ab78 with SMTP id 4fb4d7f45d1cf-5decba815dcmr2753720a12.10.1739449366641; Thu, 13 Feb 2025 04:22:46 -0800 (PST) Received: from localhost.localdomain (6.170.88.92.rev.sfr.net. [92.88.170.6]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dece1b4e8dsm1087391a12.14.2025.02.13.04.22.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Feb 2025 04:22:46 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v8 4/6] hw/timer/xilinx_timer: Make device endianness configurable Date: Thu, 13 Feb 2025 13:22:15 +0100 Message-ID: <20250213122217.62654-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250213122217.62654-1-philmd@linaro.org> References: <20250213122217.62654-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.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 "endianness" property to select the device endianness. This property is unspecified by default, and machines need to make it explicit. Set the proper endianness for each machine using the device. Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/ppc/virtex_ml507.c | 1 + hw/riscv/microblaze-v-generic.c | 2 ++ hw/timer/xilinx_timer.c | 43 +++++++++++++++++------- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index a876aeb0bba..984287fdc53 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -129,6 +129,7 @@ petalogix_ml605_init(MachineState *machine) /* 2 timers at irq 2 @ 100 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_enum(dev, "endianness", endianness); 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 d419dc49a25..caaea222a8c 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -116,6 +116,7 @@ petalogix_s3adsp1800_init(MachineState *machine) /* 2 timers at irq 2 @ 62 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_enum(dev, "endianness", endianness); 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 df8f9644829..a01354d991d 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -231,6 +231,7 @@ static void virtex_init(MachineState *machine) /* 2 timers at irq 2 @ 62 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_BIG); 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/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c index a21fdfbe6db..3c79f5733b2 100644 --- a/hw/riscv/microblaze-v-generic.c +++ b/hw/riscv/microblaze-v-generic.c @@ -104,6 +104,7 @@ static void mb_v_generic_init(MachineState *machine) /* 2 timers at irq 0 @ 100 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 100000000); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -112,6 +113,7 @@ static void mb_v_generic_init(MachineState *machine) /* 2 timers at irq 3 @ 100 Mhz. */ dev = qdev_new("xlnx.xps-timer"); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 100000000); 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..4620528f985 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 @@ -23,10 +26,12 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "hw/irq.h" #include "hw/ptimer.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qemu/log.h" #include "qemu/module.h" #include "qom/object.h" @@ -69,6 +74,7 @@ struct XpsTimerState { SysBusDevice parent_obj; + EndianMode model_endianness; MemoryRegion mmio; qemu_irq irq; uint8_t one_timer_only; @@ -189,18 +195,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_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static void timer_hit(void *opaque) @@ -220,6 +229,12 @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp) XpsTimerState *t = XILINX_TIMER(dev); unsigned int i; + if (t->model_endianness == ENDIAN_MODE_UNSPECIFIED) { + error_setg(errp, TYPE_XILINX_TIMER " property 'endianness'" + " must be set to 'big' or 'little'"); + return; + } + /* Init all the ptimers. */ t->timers = g_malloc0(sizeof t->timers[0] * num_timers(t)); for (i = 0; i < num_timers(t); i++) { @@ -233,8 +248,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->model_endianness == ENDIAN_MODE_BIG], + t, "xlnx.xps-timer", R_MAX * 4 * num_timers(t)); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &t->mmio); } @@ -247,6 +263,7 @@ static void xilinx_timer_init(Object *obj) } static const Property xilinx_timer_properties[] = { + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XpsTimerState, model_endianness), DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000), DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0), }; From patchwork Thu Feb 13 12:22:16 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: 864818 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp394893wrb; Thu, 13 Feb 2025 04:23:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU3r2ULpcGK4G0wv8uyXqj2imj8LkStLrKCpMFLrNbYlUhN4RtYvCNEtjWOq2JPvSwbvWcpBA==@linaro.org X-Google-Smtp-Source: AGHT+IHNPOWeo/Yq8AQaA/ine6CckoPvhyLIKpR2tuHctimWz2Oy84H2JHqymaw2R723rg+bepB2 X-Received: by 2002:a05:620a:390f:b0:7c0:56ba:559 with SMTP id af79cd13be357-7c06fce2e60mr1203687485a.47.1739449428646; Thu, 13 Feb 2025 04:23:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739449428; cv=none; d=google.com; s=arc-20240605; b=aIOd52oeaK+ree+iPa316pRkqvlP6xkp4IUWg9MtDvlZHoOEAY2RhNDvWBzbRY7u3U /BwFZjnBh3e1iSHl6Bkp18W6OzeAc60R2wSUzRu1pmZXdNG0O+BFCkuT4t+oa6PPPJaM 74NJXYiyHfUdcLl4G3tsIIFTsAySUItS4yQD9IEvmZA+W1t+QgpjbogViOr4Z/WoI8le TWZcB55BZQbU4No5nNd3Nuvw0twcEc4EpWuJv6rS87/JdYt2g17KRo/c/VJ95QquKk8R CCr3dFSfqbJdrYhmUot24X74YtdlrefO9rbdhrdn+5U2pF7CI/UHHg9XWn/MfQSKdVkA xJGw== 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=q9MrYcI98DZnIhdDN9JLb40jpmFmxWLeEaWhZtHGUKQ=; fh=7G23nAa7ccyiTxKVJ+ZzEMcKfCbp3J9CFWyGkTQOXRo=; b=YrxHPcmGwoiF61j3pDh1ZXjNZfLw9icI5r4bT55CT1nSmmwILlgWxc96WmP2/l64Qs cWSyT4/J7SBdvOc+xNkQPLFON7KMdjtjzfDbQsPvCPYb8iGX0HoeH5rZzpF+Vo0XV+2m vF0IIXcCpk4mh2U+dv4oxSh/bhYxp+7Iwi2FSKPJWf4PJXTMNBXpF8trkUDpmJJFLOBR weXB5E4XXnb5K7p3qBCUfxHM2dl8LTHaDZZAO4yNYqB/Mtf+Vku8WCFQq/2c9AZkRdvW jZ/r8loxxk9d+b+JyOwc0Mjq2hfvH0mixlL5QQXUQl2FThj1DRIYdtzpw56QQ2w9C1eS cXMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TYAyAHp2; 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-7c07c8bab74si115441085a.524.2025.02.13.04.23.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2025 04:23:48 -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=TYAyAHp2; 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 1tiYF9-0002BZ-P9; Thu, 13 Feb 2025 07:22:59 -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 1tiYF8-0002At-VY for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:58 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiYF6-0002ZK-2Z for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:22:58 -0500 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5de38c3d2acso1334927a12.1 for ; Thu, 13 Feb 2025 04:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739449374; x=1740054174; 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=q9MrYcI98DZnIhdDN9JLb40jpmFmxWLeEaWhZtHGUKQ=; b=TYAyAHp2NEkddWbTvCy1WUFVILw7IC3TiC8Rr6jjlv/6G8bR7YQj/W9jdZ942LXVdF SOLRZxjWG8glB/afTOomDAg64svXf/jnWRoGxU2xn220oDqr10FrfSBLQSUn5wxZsejw YcKTWJaxzNWZ48kT8wp4NDiPXXqWgXaZV/nod0slOok2WBqZEWn/CHtDWAnLLMSu/Y2p Clnn6cfJtAXKJGDbeP2+wZx6je7lUq1PS3zd9kwwEwiYAdHA2RfKieo0f7lVfU/klUb0 9KMYDJJYYmuKtgm+9lnNWuJFSsBG4ut6Xe8/ISXPUo3PFGdsqcblkT44vZ2YbvpOMTQP hilg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739449374; x=1740054174; 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=q9MrYcI98DZnIhdDN9JLb40jpmFmxWLeEaWhZtHGUKQ=; b=HnlcUGiqnkkC3E0pCJChvBVmGE+/39g6GVEMYvMsiFZ5Ws6lxGEvK3vHBWLnNUvGgx gCqTphhWH7ttcqzoIRd+Y0g8IwN91B7XOhzLyX8lhfICSn5NVd6Jcby7Adi82ZQSZWTK 3MNBQm4TO+/ITuDjQlKThrLgbAw1jMdufUb87536KBy5T8Npgpyd9DfxafYYAApwNSTe /KSEWqw83uTdBXleZeUFy7huDedz5uQPeRSqwdi3MZq4Ti7XJjopCiPzxkQNxPFeP6Nf Hw/mkvEDgpEcMpqiU6c9thPsZeLUdonnB4VHY4P2vF/T/6JI+hR3ZbAgh6Lz5RRN+vBU Us1w== X-Gm-Message-State: AOJu0Yz7eQHq5OpT/J3bLbsZOGuaN/3YqlN0hydkGqYZHvm1cPzkZwLQ BLUETipRaueE3cFVlONQ4x+A8QlRZQn2Nlc2038R/58YpW8taaq6yjgKR0h/VKxKZaAiWvdBHGZ eEl8= X-Gm-Gg: ASbGnctcIBpI3fxHchleIyXJc26qBmeQcKzzCh6JHD/YeV4eOtpOH4Zj3EL4+fDMU7B tP6Mhr12H1Fe40nnsOTNo/6ZHatiX7N5L/NhX+gHbE37/tEWcMvS+j2H6qPZs4uk32gV5CcU/75 7//0nCslsS7xYYHUpMlEfdR61fR50hQxe3S4mtxsrmiNP3FULz/LQF8vXEapH8RysBkmdgpPpX0 I3/SfVNEQt/oIdVu3hwsxiam27sqMLqQo+AxzTGZ+rf71dsKuxJRoVJWlie/L/5f2H0zMTHzBGP ddgxF+Y15Xd9HN7iX1jcPf7AyOKYgiMefmukFrB3SpYUnn7zep7BL674AvMr X-Received: by 2002:a05:6402:50cc:b0:5d9:fc81:e197 with SMTP id 4fb4d7f45d1cf-5deadd8e4a1mr6069944a12.8.1739449374292; Thu, 13 Feb 2025 04:22:54 -0800 (PST) Received: from localhost.localdomain (6.170.88.92.rev.sfr.net. [92.88.170.6]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dece1c4646sm1104999a12.27.2025.02.13.04.22.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Feb 2025 04:22:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v8 5/6] hw/char/xilinx_uartlite: Make device endianness configurable Date: Thu, 13 Feb 2025 13:22:16 +0100 Message-ID: <20250213122217.62654-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250213122217.62654-1-philmd@linaro.org> References: <20250213122217.62654-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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+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 "endianness" property to select the device endianness. This property is unspecified by default, and machines need to make it explicit. Set the proper endianness for each machine using the device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson --- hw/char/xilinx_uartlite.c | 34 ++++++++++++++++-------- hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + hw/riscv/microblaze-v-generic.c | 1 + 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c index 56955e0d74a..4037c937eeb 100644 --- a/hw/char/xilinx_uartlite.c +++ b/hw/char/xilinx_uartlite.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" +#include "qapi/error.h" #include "hw/char/xilinx_uartlite.h" #include "hw/irq.h" #include "hw/qdev-properties.h" @@ -57,6 +58,7 @@ struct XilinxUARTLite { SysBusDevice parent_obj; + EndianMode model_endianness; MemoryRegion mmio; CharBackend chr; qemu_irq irq; @@ -166,17 +168,21 @@ uart_write(void *opaque, hwaddr addr, uart_update_irq(s); } -static const MemoryRegionOps uart_ops = { - .read = uart_read, - .write = uart_write, - .endianness = DEVICE_NATIVE_ENDIAN, - .valid = { - .min_access_size = 1, - .max_access_size = 4 - } +static const MemoryRegionOps uart_ops[2] = { + [0 ... 1] = { + .read = uart_read, + .write = uart_write, + .valid = { + .min_access_size = 1, + .max_access_size = 4, + }, + }, + [0].endianness = DEVICE_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static const Property xilinx_uartlite_properties[] = { + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XilinxUARTLite, model_endianness), DEFINE_PROP_CHR("chardev", XilinxUARTLite, chr), }; @@ -214,6 +220,15 @@ static void xilinx_uartlite_realize(DeviceState *dev, Error **errp) { XilinxUARTLite *s = XILINX_UARTLITE(dev); + if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) { + error_setg(errp, TYPE_XILINX_UARTLITE " property 'endianness'" + " must be set to 'big' or 'little'"); + return; + } + + memory_region_init_io(&s->mmio, OBJECT(dev), + &uart_ops[s->model_endianness == ENDIAN_MODE_BIG], + s, "xlnx.xps-uartlite", R_MAX * 4); qemu_chr_fe_set_handlers(&s->chr, uart_can_rx, uart_rx, uart_event, NULL, s, NULL, true); } @@ -223,9 +238,6 @@ static void xilinx_uartlite_init(Object *obj) XilinxUARTLite *s = XILINX_UARTLITE(obj); sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); - - memory_region_init_io(&s->mmio, obj, &uart_ops, s, - "xlnx.xps-uartlite", R_MAX * 4); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); } diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index caaea222a8c..bdba2006b72 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -109,6 +109,7 @@ petalogix_s3adsp1800_init(MachineState *machine) } dev = qdev_new(TYPE_XILINX_UARTLITE); + qdev_prop_set_enum(dev, "endianness", endianness); qdev_prop_set_chr(dev, "chardev", serial_hd(0)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, UARTLITE_BASEADDR); diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c index 3c79f5733b2..d8e67906d26 100644 --- a/hw/riscv/microblaze-v-generic.c +++ b/hw/riscv/microblaze-v-generic.c @@ -92,6 +92,7 @@ static void mb_v_generic_init(MachineState *machine) /* Uartlite */ dev = qdev_new(TYPE_XILINX_UARTLITE); + qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_LITTLE); qdev_prop_set_chr(dev, "chardev", serial_hd(0)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, UARTLITE_BASEADDR); From patchwork Thu Feb 13 12:22:17 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: 864819 Delivered-To: patch@linaro.org Received: by 2002:a5d:47a6:0:b0:38f:210b:807b with SMTP id 6csp395071wrb; Thu, 13 Feb 2025 04:24:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV2HUVLVoKpAgNjKLI51SM8igfzKtW64ZK0tFfmPO6EeqTr2IVC10lDulqwYb0GG+laoAIJ4A==@linaro.org X-Google-Smtp-Source: AGHT+IGmCIZi17vCRBw0qd/OfPD4JvQCC/bFnMWN4G+a9fpgDjAHfESJdzLJFd0rNsb9zRZUzmlZ X-Received: by 2002:a05:6214:20e9:b0:6d8:9e9d:c223 with SMTP id 6a1803df08f44-6e46ed77567mr129921496d6.7.1739449459152; Thu, 13 Feb 2025 04:24:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739449459; cv=none; d=google.com; s=arc-20240605; b=ldWh9ME/MRrYGUUf4werJLIeMy6X0GEVtMZ9HZ1k0x5Go5Y5Rz8a3JlzdofgKcZCpS iaGauFWCkEgYH0Wtkb/N2Mqvdfgubku7j4bLF5e+dNe32NHUFJTuXfczYqsv/aJlPc8d 1dZoIJfu13z6bf13UYrPsWf88QjpuoNgzYEk81A5dBM6uSJOFy9021rQFEUkwHYsWV+4 HiHhrbcF966+6/zykpegL5OpZr1ZBVcqogvTAMIgy8Oyqqdq/nVcLY4zHWs9OEeIWNh0 cdE2hPs7bkmHzNwyAnKsWoexc4r0fEdkCTWK3dFOoS8FlRDfkW6LFaJMBX1Yb5/J3col zuOw== 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=r5LQvdlT1sMf3RQG3zaZimZ3xYwH68boESfP4z93+Xs=; fh=7G23nAa7ccyiTxKVJ+ZzEMcKfCbp3J9CFWyGkTQOXRo=; b=JacI/bp/ai5xwSUJvDDXH3IeCTHOfJ6LJwBYbE/BV+04IbnT4BJki1ASUIRssR16gp nMGqL4nKLZ6IvFTkegsYKHgAs/WZkfRB2sigPa0ub6epeeia2cSfw5l0hNNHEepNbk09 K6BuctWIVse3Qo/qzS9NJnGeR7TSI0Vh2SNiaU3DhC6bDYqzsML2H8h9gmikq7WWNdKd jSS/NXDAAPT0xq4EsXCXRVT08J/QthHsJRLsJQ8+AHBFivzRZsZTBCSwsMwACstAcHGW jF6F1yUo48HdOksf7uegjQ/0rCiGunJK+COyvBAOrzpp/WoRSjdVVCb8CodjcQHlMcHS 5NuA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MsQvugnh; 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-6e65d9d1845si13106436d6.508.2025.02.13.04.24.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2025 04:24:19 -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=MsQvugnh; 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 1tiYFH-0002Gd-H3; Thu, 13 Feb 2025 07:23:07 -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 1tiYFF-0002Fw-3d for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:23:05 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiYFC-0002aV-7b for qemu-devel@nongnu.org; Thu, 13 Feb 2025 07:23:04 -0500 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ab7e80c4b55so180093366b.0 for ; Thu, 13 Feb 2025 04:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739449380; x=1740054180; 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=r5LQvdlT1sMf3RQG3zaZimZ3xYwH68boESfP4z93+Xs=; b=MsQvugnhOZPJvwbc+gryVwJMynIrz7ScTdSYg+t8M6IRHpQkfMITjSe7vAZbV6uFo8 u5UpwVnfHfxtbRrC7UeKJIIDvx6Uz8Sxtn/hlIw3IGem/SSYJPs8hrRNmVOEha19dKQZ rXpkqljH6A/RBTGMyHPaThicHr+2qNskoglUtp2uzdOzoCv8WBbgaafRak4Rs3lwKv3n RCCIgiZZUqtIPiLZAzDLuX4VXg/P2E15BWHP8rl/iSX+vNjEkNYykp/PHmodbnclWtAu 6hoAGuECw06fLzzT886idewsOXcbZ6XMuPz5VwoyK/T/7JFk7+j6GjCGnv1HwV3fqWMa 20sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739449380; x=1740054180; 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=r5LQvdlT1sMf3RQG3zaZimZ3xYwH68boESfP4z93+Xs=; b=N8fMo5LWbU542qJ7CnRg0YxaLVxPWkfTV8xyH7go+V1udU+dQI8P3bHoo0U0ee1NUe S/gEj1KO4pvw2W2Cd5MsRn2giXTwJ0CUsQ3FvA5kosRHc0EKcIOTC1dvGijJICo4CsQW Wk+1RJznZUI0a9HVfTn40xXaW4xlvVH7PtsSKFZVKqCN8vzUm8108Nx9lX1T4fCB2nRm mZl9f2IWW4PL5euQT0uTt4DZkw0zMJ2JrhEkgL6WnKqoWBOlgdlqRD0pwImXOzBwHLtM xbQC+u6h3MpI5o02POccgaR6D0kL8k3nErns96TOgLgNSTfMH+xZLykuUh86ui6wKf4j nLJw== X-Gm-Message-State: AOJu0Yyb73Niy5kfLx8zk0Hn5USkL8ilUtYpvPF//cltOnE3gBKO9RYD /melnFSjqg6NI80prAvQ+kVE+z/nvOEBHt5NyF9HsTitJtquqv24HJHLnNjDg0fERSLDIAIWYSz 1MiY= X-Gm-Gg: ASbGncuc2F14uu3cgmhho7e94LW2izBDzoQZZnKCbo8FKm5U9zedMR2GXpD1tsNUEal wZlPfZqh81saYp8PjUNTdPAb8lLwW19MFL6Zvb2R32NkXI6vSbwczBL4ba1opciFeacmclekKtc WAuFSPyGXSH8Ze3nx7iXY/OSro7wDbRU1pRo7coJ/zt6Wxc+/eNc6XGByIexdSDod0/dkGlI97i mVBiS+fZmyb289kBMRUtuSGhUR4irr5/MB3Uyej7Hs+Edh6s2as3qssfsLksjGGsCeXh/PJIlEZ xPhRVHlWf6qOBjvdwbN9UPfPcsr9vMsXIu2/TmHNKz76fR6zhcnYEqFrJBnw X-Received: by 2002:a17:907:7dab:b0:ab7:cc43:c51e with SMTP id a640c23a62f3a-aba4eba808amr304929766b.13.1739449380395; Thu, 13 Feb 2025 04:23:00 -0800 (PST) Received: from localhost.localdomain (6.170.88.92.rev.sfr.net. [92.88.170.6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aba532832dcsm121008166b.85.2025.02.13.04.22.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Feb 2025 04:22:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v8 6/6] hw/ssi/xilinx_spi: Make device endianness configurable Date: Thu, 13 Feb 2025 13:22:17 +0100 Message-ID: <20250213122217.62654-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250213122217.62654-1-philmd@linaro.org> References: <20250213122217.62654-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.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+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 "endianness" property to select the device endianness. This property is unspecified by default, and machines need to make it explicit. Set the proper endianness on the single machine using the device. Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/ssi/xilinx_spi.c | 32 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index 984287fdc53..21ad215e442 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -177,6 +177,7 @@ petalogix_ml605_init(MachineState *machine) SSIBus *spi; dev = qdev_new("xlnx.xps-spi"); + qdev_prop_set_enum(dev, "endianness", endianness); qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES); busdev = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(busdev, &error_fatal); diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c index fd1ff12eb1d..be5baa6b350 100644 --- a/hw/ssi/xilinx_spi.c +++ b/hw/ssi/xilinx_spi.c @@ -25,6 +25,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "qemu/module.h" @@ -32,6 +33,7 @@ #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "qom/object.h" @@ -83,6 +85,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(XilinxSPI, XILINX_SPI) struct XilinxSPI { SysBusDevice parent_obj; + EndianMode model_endianness; MemoryRegion mmio; qemu_irq irq; @@ -313,14 +316,17 @@ done: xlx_spi_update_irq(s); } -static const MemoryRegionOps spi_ops = { - .read = spi_read, - .write = spi_write, - .endianness = DEVICE_NATIVE_ENDIAN, - .valid = { - .min_access_size = 4, - .max_access_size = 4 - } +static const MemoryRegionOps spi_ops[2] = { + [0 ... 1] = { + .read = spi_read, + .write = spi_write, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, + }, + [0].endianness = DEVICE_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static void xilinx_spi_realize(DeviceState *dev, Error **errp) @@ -329,6 +335,12 @@ static void xilinx_spi_realize(DeviceState *dev, Error **errp) XilinxSPI *s = XILINX_SPI(dev); int i; + if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) { + error_setg(errp, TYPE_XILINX_SPI " property 'endianness'" + " must be set to 'big' or 'little'"); + return; + } + DB_PRINT("\n"); s->spi = ssi_create_bus(dev, "spi"); @@ -339,7 +351,8 @@ static void xilinx_spi_realize(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->cs_lines[i]); } - memory_region_init_io(&s->mmio, OBJECT(s), &spi_ops, s, + memory_region_init_io(&s->mmio, OBJECT(s), + &spi_ops[s->model_endianness == ENDIAN_MODE_BIG], s, "xilinx-spi", R_MAX * 4); sysbus_init_mmio(sbd, &s->mmio); @@ -362,6 +375,7 @@ static const VMStateDescription vmstate_xilinx_spi = { }; static const Property xilinx_spi_properties[] = { + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XilinxSPI, model_endianness), DEFINE_PROP_UINT8("num-ss-bits", XilinxSPI, num_cs, 1), };