From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@ventanamicro.com header.s=google header.b=TjNroWLn; spf=pass (domain: ventanamicro.com, ip: 209.85.214.171, mailfrom: tphan@ventanamicro.com) Received: by mail-pl1-f171.google.com with SMTP id l10so3167934plb.8 for ; Fri, 16 Dec 2022 10:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3DRXB+Jj3DGwnlYeiePXENbgesuzheD42rjeHl6PqqY=; b=TjNroWLnkQ2HvAnbp7t8wWWJe1pc4jCHnuRz5hNOqNUp93sQ8hn+0QTUfKUsDBX4SB VPJdqzyVqXj0ZYulNTTjNhi/1QjeViD54a4NatwlfJFd+n4e6sSVI+FuzWDhYv64YcXt atV3T8IDuDaDgaIyWfunwi9wY2iMWmjrN7AErlabPOE2LIb0PD/8yS59xaU167jZiZiY 50Ao/ScnN/Wxzp1qZxXzW7BkmpXG496qPIeVF9s5/lZ0KdU9O+slwBrfKmbwPn9WJfzz WpgHCIb0tyi1KO1viKMjQCu9cpC4O6XEu5xUW5vUH3MNnKbbcYLjkt79jTZkCFi+xobs oFrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3DRXB+Jj3DGwnlYeiePXENbgesuzheD42rjeHl6PqqY=; b=1X6+kcMnGu7lAjIqw7zbTspFHLpRMrfV8bH9+TO27ruPDBls25AtBsnyxMiUUeaaMn XBGhjgO1Efw0+/RYT2tsu0Yl76hdeKoq1dgV/rxVlvjnrCoB9Y5b8ZG7EOItbXff2yJd I/5WltFRvc9dLFmbK8S+vjoJ4orJahrpsRQgNnotFA3cr3HXyzeK0rFQj8Z9XPN4Jgqx zpm+5q/tMh9tT9DPiw20iUCz5J6VQNUH8FARozRe8ZIVTWYiyi8dx7A/LNxA/jJxZgR+ 241H7WM5l2Cb0uAnIeetIZZemMK4IW5MlH+ADxjbTA62Ea6ISJZwPWUvfA4KS0jcK6qk dmtg== X-Gm-Message-State: ANoB5pknjbmNBujK+nonyvY7Z+vRm8AiiHYLr6KV4ldQGzIRGaSn93li b1t9kKptZMdegMGY4EFM5/N88vgpbr63gqEQMR8= 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 @@ #=0D # The following information is for reference only and not required by the = build tools.=0D #=0D -# VALID_ARCHITECTURES =3D IA32 X64=0D +# VALID_ARCHITECTURES =3D IA32 X64 RISCV64=0D #=0D =0D [Sources]=0D @@ -43,6 +43,10 @@ [Sources.X64]=0D CopyMem.c=0D =0D +[Sources.RISCV64]=0D + CopyMem.c=0D + CompilerHelper.c=0D +=0D [Packages]=0D MdePkg/MdePkg.dec=0D =0D --=20 2.25.1