From patchwork Fri Jun 21 07:56:07 2024 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: 806317 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp650026wrt; Fri, 21 Jun 2024 00:57:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVtp3Hk6qPk67XlQk3XVSsLeEaCot91PXjSgdqs/8OZKlnwSzBL1mYwByoxkxFH+FkxXEv3iHtrUl013/fs5WZo X-Google-Smtp-Source: AGHT+IFKcWj+8u84v4+O5hswyJIGWpR7WlGIgd2Buhsl33RrG5emBVP6z+twDHfp1/CVGKeTTu5s X-Received: by 2002:a05:622a:7d93:b0:444:b691:35a1 with SMTP id d75a77b69052e-444b6913e7cmr37407761cf.43.1718956635758; Fri, 21 Jun 2024 00:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718956635; cv=none; d=google.com; s=arc-20160816; b=EELjY1jCkMqCXt0LodUHObCiMH5QF6V9mbBv8SPdfXbH4ZhkGP8/IsooC+9+FkZ/NZ HcE8ZUWWsedMBc7Xc2vNkX+wM52fdKszisx+vLFCjMm4NFXWgtkf0/OgEMbAAgiNpDG7 vHWXF2JGwaXKKav/EGvIlc6HDRSWTKN8rxB/XrrXqC3tKVLN+XceX/VsSg9wJaruMc30 I5Mngwb+GjuPjygyUGxWFQtW6fo5nuOZzrjFGnmVmW6+kOsWCdPafPTbSKBZPjRFsShG n0iSn9Jjmah0zqiEsli0Dmu/st4A2N7oynWXFu1D2J6o7GVtKNIA2cWs1VpeNqp2veLv uQ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=IzQLNAGPwNKDPbpDvBTrnLSOC5ryk7VLNi38y6lx6kE=; fh=CrzyMzWHyyQymo1P85WBNpQCRTEGvk3sFixEZBXFU5E=; b=Z1lndO9/EDK9q+5Ibq2YOuNN4UISWkFso4MQwDLJa4uegDXAnMgVDBWG6HT9m3JjSV IH2s05MlkGU0VYYUry5j9CbTaKR01A6tVQwWO7myxMQ0/wKUHIRDwYqaigwtYSA1nZXA gAC7O4kYIPYCWtzeg/WBA+euo/mshxycir8hGOrNaM7SKSVrCVceN2AxJCB5Rie+FzY6 JK19iuhxXbvXqqGDpJdv6yC2bsCvSCgpsrctfEXixY/xZ+Oep43DE7HNrTeQWEttFORY 08ICHLfjaS9CPYNcRCln++uVxtnP/lx8IYFe1YKR3sA99WZtYjL/78kw8N+hHp+e5zhv rFAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIXdWOyB; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2c07e6fsi11136041cf.302.2024.06.21.00.57.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jun 2024 00:57:15 -0700 (PDT) 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=dIXdWOyB; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKZ84-0007aU-TQ; Fri, 21 Jun 2024 03:56:16 -0400 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 1sKZ83-0007aI-6U for qemu-devel@nongnu.org; Fri, 21 Jun 2024 03:56:15 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKZ81-0006EN-JP for qemu-devel@nongnu.org; Fri, 21 Jun 2024 03:56:14 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-57cbc2a2496so2015016a12.0 for ; Fri, 21 Jun 2024 00:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718956571; x=1719561371; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IzQLNAGPwNKDPbpDvBTrnLSOC5ryk7VLNi38y6lx6kE=; b=dIXdWOyB2FTRQZ+eytOEFh04ceuxyFlsOotedyouz+OiUSluMoBHGrT+3t9HIwtyuN EHAcYjQJyH6JQafXlmgt4PQly80rle8tfSiYoBJK8Uv4ZhF+ST6OZzRizE2ghKPVWFTE KvoErW1yaC60MnnS/WDzmn1Ln9GF0XYGiMfC6sDjI/jhsagr/0JV0geYN0uEztugqjUL mpzjXWiE2PlzOTzLD7/RfFsxsDEEsCab+DHIB5GrDiZSROjLwBCcVAjApg7tN8stYYRv Q8dAm4GbsLHhfVQH+iUIWS22V6apWqJd0IPhHztiCr6zgk3kt+l8A1yXcph3vku/l6JO 9KRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718956571; x=1719561371; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IzQLNAGPwNKDPbpDvBTrnLSOC5ryk7VLNi38y6lx6kE=; b=Cdqy6VKpnP+pV5LJC2QxUIiiwO2raHz342aZzd/cR5+m8AzFpRCSzX+QQ4UaJ8Z74L y7LwhKxw3oEZdRY7vtW5hmxmfj+i9VAY7coX4ZaJ2fvDNkalwq4uRPQVfPO11X+m+47a 2Oko0W1Ne063Ij8K102aBzZeQzgNsBgz/rMlNVei0jGZ7APY01TMXrBvlOUOkYl3Q1em I3tNuh2ptV+8PdmT+ibE7fD97rRYjzek1jwM2+cSck2Icv5kqpv/wxTSKPTBmyG8ZxGu og4pRj+CBCFjhDY+9ni26dJ3YbOEkV7xe2BtylCca5Ub7BWXuNNm0CCopcD9kgri15AA Y0GA== X-Gm-Message-State: AOJu0YyiJaCC+7F7SppahLfEDLpt9pDMWcGRRd59GXgA1/ezNk5RdJZ6 mtZwNVMUhK8pr6MS1v95baGv/44jRtm6UdqSwvr5V4eapJTQUeL129eTx7XMflu4is2I+iUx68f b X-Received: by 2002:a17:907:a608:b0:a6f:6389:4aba with SMTP id a640c23a62f3a-a6fab609e80mr626933066b.3.1718956570755; Fri, 21 Jun 2024 00:56:10 -0700 (PDT) Received: from m1x-phil.lan ([176.176.128.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf56ea09sm54361966b.201.2024.06.21.00.56.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 21 Jun 2024 00:56:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Joel Stanley , Fan Ni , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Jonathan Cameron , Ira Weiny , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH] bswap: Add st24_be_p() to store 24 bits in big-endian order Date: Fri, 21 Jun 2024 09:56:07 +0200 Message-ID: <20240621075607.17902-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=philmd@linaro.org; helo=mail-ed1-x52a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Commit 14180d6221 ("bswap: Add the ability to store to an unaligned 24 bit field") added st24_le_p() for little endianness, add st24_be_p() equivalent for bit one. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Reviewed-by: Richard Henderson --- Some SD card registers are 3 bytes wide stored MSB first. --- include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index bd67468e5e..ad22910a5d 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -38,12 +38,14 @@ static inline void bswap64s(uint64_t *s) #if HOST_BIG_ENDIAN #define be_bswap(v, size) (v) #define le_bswap(v, size) glue(__builtin_bswap, size)(v) +#define be_bswap24(v) (v) #define le_bswap24(v) bswap24(v) #define be_bswaps(v, size) #define le_bswaps(p, size) \ do { *p = glue(__builtin_bswap, size)(*p); } while (0) #else #define le_bswap(v, size) (v) +#define be_bswap24(v) bswap24(v) #define le_bswap24(v) (v) #define be_bswap(v, size) glue(__builtin_bswap, size)(v) #define le_bswaps(v, size) @@ -357,6 +359,11 @@ static inline void stw_be_p(void *ptr, uint16_t v) stw_he_p(ptr, be_bswap(v, 16)); } +static inline void st24_be_p(void *ptr, uint32_t v) +{ + st24_he_p(ptr, be_bswap24(v)); +} + static inline void stl_be_p(void *ptr, uint32_t v) { stl_he_p(ptr, be_bswap(v, 32));