summaryrefslogtreecommitdiffstats
path: root/CryptoPkg
diff options
context:
space:
mode:
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]