summaryrefslogtreecommitdiffstats
path: root/CryptoPkg
diff options
context:
space:
mode:
authorYi Li <yi1.li@intel.com>2023-08-03 12:37:40 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-08-09 07:10:31 +0000
commit4b5faa5775bf75bbc36ea513736876da515989eb (patch)
treea2b49e02ef5ba67c263eca57d9cfbc4cf0a9d3e7 /CryptoPkg
parent43e0ede26b7ad720175fa83f7cf0d1d78742b181 (diff)
downloadedk2-4b5faa5775bf75bbc36ea513736876da515989eb.tar.gz
edk2-4b5faa5775bf75bbc36ea513736876da515989eb.tar.bz2
edk2-4b5faa5775bf75bbc36ea513736876da515989eb.zip
CryptoPkg: add missing gcc instructions
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> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Brian J. Johnson <brian.johnson@hpe.com> Tested-by: Kenneth Lautner <klautner@microsoft.com>
Diffstat (limited to 'CryptoPkg')
-rw-r--r--CryptoPkg/Library/IntrinsicLib/Ia32/MathDivModU64x64.c23
-rw-r--r--CryptoPkg/Library/IntrinsicLib/Ia32/MathDivS64x64.c22
-rw-r--r--CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64x64.c22
-rw-r--r--CryptoPkg/Library/IntrinsicLib/Ia32/MathModU64x64.c26
-rw-r--r--CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf5
5 files changed, 97 insertions, 1 deletions
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]