From nobody Tue May 7 21:48:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97585+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97585+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1671496783; cv=none; d=zohomail.com; s=zohoarc; b=DnhzRNBNcMGaHyD1NWHmn3WAM9sD9PgyF8DqxhHafHT1XEFKZsJfIpP0vTmSg237BrWTdoDyN9vzW5YH1Ot9+iGw4xLXUyUHzUqIv1r/8N8w3qFy+NS82XJRq/lfs6jahEW8hGOu/djAYdyyM7NjFHU+xqyTk2nHEU3Tz+X4Yao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671496783; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject; bh=xIvPalmz+kMTu0bOnlHrDnyx3JloHO+HCJi5EpBA6M0=; b=kkEZlnN919H+xNomrsl3kVRATePQ3/2WHjHt993Yd4guwAqRJoBojCe11ciGmWfHke3IkwgtD5yObgFRQTWQhLVARY8wHLmxzezjyhofp7y3/NXQkwe7OuM3oL8FHDFpSwyqx0vc9AtXUbCdJcoJy72CKHhRlcfJ0XnVkuEThPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97585+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1671496783452512.6127074045023; Mon, 19 Dec 2022 16:39:43 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id w3GFYY1788612xH6DW4MQNjy; Mon, 19 Dec 2022 16:39:43 -0800 X-Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mx.groups.io with SMTP id smtpd.web11.2891.1671216492990898577 for ; Fri, 16 Dec 2022 10:48:13 -0800 X-Received: by mail-pl1-f171.google.com with SMTP id l10so3167934plb.8 for ; Fri, 16 Dec 2022 10:48:12 -0800 (PST) X-Gm-Message-State: 6iRaE1M3O0R2ZKz2Rx4GAxhOx1787277AA= X-Google-Smtp-Source: AA0mqf6XU/ig+4YiqKowu02tSxke7Nka8qIU/P8HQkdp9F1enL2yFBRHMIexDG7++eepJChKWK/MwQ== X-Received: by 2002:a05:6a20:ce49:b0:9d:efbe:205b with SMTP id id9-20020a056a20ce4900b0009defbe205bmr50472338pzb.17.1671216492023; Fri, 16 Dec 2022 10:48:12 -0800 (PST) X-Received: from DESKTOP-I1ETA6N.dc1.ventanamicro.com (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id w16-20020a631610000000b00478dad38eacsm1780470pgl.38.2022.12.16.10.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 10:48:11 -0800 (PST) From: "Tuan Phan" To: Cc: devel@edk2.groups.io, sunilvl@ventanamicro.com, michael.d.kinney@intel.com, jiewen.yao@intel.com, jian.j.wang@intel.com, xiaoyu1.lu@intel.com, guomin.jiang@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2] CryptoPkg/IntrinsicLib: RiscV: Provide implementation of memcpy and __ctzdi2 Date: Fri, 16 Dec 2022 10:47:54 -0800 Message-Id: <20221216184754.4381-1-tphan@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1671496783; bh=oIMw3uL182U68nyg0gfBG9yhYOer38iIh2D4SY6Rlog=; h=Cc:Date:From:Reply-To:Subject:To; b=MV2XW6PdEVfISghZOAjquG2Fb/GApDth3Ad6cPiy2UaIItL6fynt7KVfikpdwLhwwba vVOMa4l6c18Mp5foO9e0S187RuBv20Vg+ktf71wuH43CayHlj6eb/QNoaw+vWO33GqIix 1yPSo5YFvM2OK8BNarDuMzKMSVdX9LaTuT0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1671496785025100001 Content-Type: text/plain; charset="utf-8" The RiscV toolchain doesn't provide __ctzdi2 implementation when compiled with -nostdlib that needed by openssl library. So adding the implementation of __ctzdi2. Forcing to use CopyMem of EDK2 as memcpy buildin disabled for RiscV with -fno-builtin-memcpy flag. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4103 Signed-off-by: Tuan Phan Acked-by: Sunil V L --- V2: - Add license header. - Add REF to the bugzilla. .../Library/IntrinsicLib/CompilerHelper.c | 42 +++++++++++++++++++ .../Library/IntrinsicLib/IntrinsicLib.inf | 6 ++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 CryptoPkg/Library/IntrinsicLib/CompilerHelper.c diff --git a/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c b/CryptoPkg/Li= brary/IntrinsicLib/CompilerHelper.c new file mode 100644 index 000000000000..3844fd14ae66 --- /dev/null +++ b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c @@ -0,0 +1,42 @@ +/** @file + Implement functions that not available when compiled with -nostdlib. + + Copyright (c) 2022, Ventana Micro Systems Inc. All Rights Reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +unsigned int +__ctzdi2 (unsigned long long x) +{ + unsigned int ret =3D 0; + + if (!x) { + return 64; + } + if (!(x & 0xffffffff)) { + x >>=3D 32; + ret |=3D 32; + } + if (!(x & 0xffff)) { + x >>=3D 16; + ret |=3D 16; + } + if (!(x & 0xff)) { + x >>=3D 8; + ret |=3D 8; + } + if (!(x & 0xf)) { + x >>=3D 4; + ret |=3D 4; + } + if (!(x & 0x3)) { + x >>=3D 2; + ret |=3D 2; + } + if (!(x & 0x1)) { + x >>=3D 1; + ret |=3D 1; + } + return ret; +} diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf b/CryptoPkg/Li= brary/IntrinsicLib/IntrinsicLib.inf index 86e74b57b109..6796b39b07cf 100644 --- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf +++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf @@ -18,7 +18,7 @@ # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 +# VALID_ARCHITECTURES =3D IA32 X64 RISCV64 # =20 [Sources] @@ -43,6 +43,10 @@ [Sources.X64] CopyMem.c =20 +[Sources.RISCV64] + CopyMem.c + CompilerHelper.c + [Packages] MdePkg/MdePkg.dec =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97585): https://edk2.groups.io/g/devel/message/97585 Mute This Topic: https://groups.io/mt/95777535/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-