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...@intel.com> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Xiaoyu Lu <xiaoyu1...@intel.com> Cc: Guomin Jiang <guomin.ji...@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 (#107503): https://edk2.groups.io/g/devel/message/107503 Mute This Topic: https://groups.io/mt/100520606/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-