public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Li, Yi" <yi1.li@intel.com>
To: devel@edk2.groups.io
Cc: Yi Li <yi1.li@intel.com>, Jiewen Yao <jiewen.yao@intel.com>,
	Xiaoyu Lu <xiaoyu1.lu@intel.com>,
	Guomin Jiang <guomin.jiang@intel.com>
Subject: [edk2-devel] [PATCH 22/29] CryptoPkg: add missing gcc instructions
Date: Fri, 28 Jul 2023 14:40:08 +0800	[thread overview]
Message-ID: <6e605ca30e28c9517520bd8b1a8941a79039ef07.1690444292.git.yi1.li@intel.com> (raw)
In-Reply-To: <cover.1690444292.git.yi1.li@intel.com>

Used when build IA32 CryptoPkg by gcc, the definition of the
instructions can be found at:
https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html

Signed-off-by: Yi Li <yi1.li@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
---
 .../IntrinsicLib/Ia32/MathDivModU64x64.c      | 23 ++++++++++++++++
 .../Library/IntrinsicLib/Ia32/MathDivS64x64.c | 22 ++++++++++++++++
 .../Library/IntrinsicLib/Ia32/MathDivU64x64.c | 22 ++++++++++++++++
 .../Library/IntrinsicLib/Ia32/MathModU64x64.c | 26 +++++++++++++++++++
 .../Library/IntrinsicLib/IntrinsicLib.inf     |  5 +++-
 5 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathDivModU64x64.c
 create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathDivS64x64.c
 create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64x64.c
 create mode 100644 CryptoPkg/Library/IntrinsicLib/Ia32/MathModU64x64.c

diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivModU64x64.c b/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivModU64x64.c
new file mode 100644
index 0000000000..6c75a1ff1d
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivModU64x64.c
@@ -0,0 +1,23 @@
+/** @file
+  64-bit Math Worker Function.
+  The 32-bit versions of C compiler generate calls to library routines
+  to handle 64-bit math. These functions use non-standard calling conventions.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+
+/* https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html */
+__attribute__ ((__used__))
+unsigned long long
+__udivmoddi4 (
+  unsigned long long  A,
+  unsigned long long  B,
+  unsigned long long  *C
+  )
+{
+  return DivU64x64Remainder ((UINT64)A, (UINT64)B, (UINT64 *)C);
+}
diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivS64x64.c b/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivS64x64.c
new file mode 100644
index 0000000000..54ff619b61
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivS64x64.c
@@ -0,0 +1,22 @@
+/** @file
+  64-bit Math Worker Function.
+  The 32-bit versions of C compiler generate calls to library routines
+  to handle 64-bit math. These functions use non-standard calling conventions.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+
+/* https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html */
+__attribute__ ((__used__))
+long long
+__divdi3 (
+  long long  A,
+  long long  B
+  )
+{
+  return DivS64x64Remainder ((INT64)A, (INT64)B, NULL);
+}
diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64x64.c b/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64x64.c
new file mode 100644
index 0000000000..dbb7b516fb
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64x64.c
@@ -0,0 +1,22 @@
+/** @file
+  64-bit Math Worker Function.
+  The 32-bit versions of C compiler generate calls to library routines
+  to handle 64-bit math. These functions use non-standard calling conventions.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+
+/* https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html */
+__attribute__ ((__used__))
+unsigned long long
+__udivdi3 (
+  unsigned long long  A,
+  unsigned long long  B
+  )
+{
+  return DivU64x64Remainder ((UINT64)A, (UINT64)B, NULL);
+}
diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathModU64x64.c b/CryptoPkg/Library/IntrinsicLib/Ia32/MathModU64x64.c
new file mode 100644
index 0000000000..eedd96074e
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathModU64x64.c
@@ -0,0 +1,26 @@
+/** @file
+  64-bit Math Worker Function.
+  The 32-bit versions of C compiler generate calls to library routines
+  to handle 64-bit math. These functions use non-standard calling conventions.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+
+/* https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html */
+__attribute__ ((__used__))
+unsigned long long
+__umoddi3 (
+  unsigned long long  A,
+  unsigned long long  B
+  )
+{
+  unsigned long long  Reminder;
+
+  DivU64x64Remainder ((UINT64)A, (UINT64)B, (UINT64 *)&Reminder);
+
+  return Reminder;
+}
diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
index 4d2440466d..ae238ccc0b 100644
--- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
@@ -43,7 +43,10 @@
 
   Ia32/MathLShiftS64.nasm   | GCC
   Ia32/MathRShiftU64.nasm   | GCC
-
+  Ia32/MathDivModU64x64.c   | GCC
+  Ia32/MathDivS64x64.c      | GCC
+  Ia32/MathDivU64x64.c      | GCC
+  Ia32/MathModU64x64.c      | GCC
 [Sources.X64]
   CopyMem.c
 [Sources.RISCV64]
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107360): https://edk2.groups.io/g/devel/message/107360
Mute This Topic: https://groups.io/mt/100406067/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2023-07-28  6:42 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28  6:39 [edk2-devel] [PATCH 00/29] CryptoPkg: Update OpenSSL submodule to 3.0.9 Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 01/29] CryptoPkg/openssl: update submodule to openssl-3.0.9 Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 02/29] CryptoPkg/openssl: cleanup all openssl1.1.1 generated files and code Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 03/29] CryptoPkg/openssl: update Openssl*.inf files for openssl 3.0 Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 04/29] CryptoPkg/openssl: add openssl3 configure scripts Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 05/29] CryptoPkg/openssl: UefiAsm.conf update for openssl 3.0 Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 06/29] CryptoPkg/BaseCryptLib: no openssl deprecation warnings please Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 07/29] CryptoPkg/BaseCryptLib: adapt CryptSm3.c to openssl 3.0 changes Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 08/29] CryptoPkg/BaseCryptLib: drop BIO_* dummy functions Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 09/29] CryptoPkg/TlsLib: ERR_GET_FUNC is gone Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 10/29] CryptoPkg/openssl: adapt rand_pool.c to openssl 3.0 changes Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 11/29] CryptoPkg/openssl: move compiler_flags to buildinf.c Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 12/29] CryptoPkg/openssl: store dummy update for openssl 3.0 Li, Yi
2023-07-28  6:39 ` [edk2-devel] [PATCH 13/29] CryptoPkg/openssl: adapt EcSm2Null.c " Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 14/29] CryptoPkg: Move all UEFI implement of openssl to OpensslStub Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 15/29] CryptoPkg: use UEFI provider as default Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 16/29] CryptoPkg: adapt 3.0 change in SslNull.c Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 17/29] CryptoPkg: Add instrinsics to support building openssl3 on IA32 windows Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 18/29] CryptoPkg: disable C4133 warning in openssl libraries Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 19/29] CryptoPkg/TlsLib: use unsigned long for ErrorCode Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 20/29] CryptoPkg: Align with 4096 when build with OpensslFullAccel Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 21/29] CryptoPkg: Enable memcpy sys call in RISCV64 build Li, Yi
2023-07-28  6:40 ` Li, Yi [this message]
2023-07-28  6:40 ` [edk2-devel] [PATCH 23/29] CryptoPkg: add define of maximum unsigned size_t Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 24/29] CryptoPkg: add implemention of _ftol2_sse() to avoid build error Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 25/29] CryptoPkg: add more dummy implement of openssl for size optimization Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 26/29] CryptoPkg: run configure.py to update all generated files Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 27/29] CryptoPkg: remove strcmp to syscall Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 28/29] CryptoPkg/openssl: update CI config for openssl 3.0 Li, Yi
2023-07-28  6:40 ` [edk2-devel] [PATCH 29/29] CryptoPkg: remove BN and EC accel for size optimization Li, Yi
2023-08-02 10:06 ` 回复: [edk2-devel] [PATCH 00/29] CryptoPkg: Update OpenSSL submodule to 3.0.9 gaoliming via groups.io
2023-08-02 16:41   ` Michael D Kinney
2023-08-02 18:46     ` Leif Lindholm
2023-08-04  9:44       ` 回复: " gaoliming via groups.io
2023-08-04 20:54         ` Brian J. Johnson
2023-08-04 22:55           ` Michael Kubacki
2023-08-08 23:59             ` Yao, Jiewen
2023-08-09  0:45               ` Kenneth Lautner via groups.io
2023-08-09  7:43                 ` Yao, Jiewen
2023-08-03  5:16   ` Li, Yi
2023-08-03  7:57     ` Yao, Jiewen
2023-08-03  9:20       ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e605ca30e28c9517520bd8b1a8941a79039ef07.1690444292.git.yi1.li@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox