From 4b5faa5775bf75bbc36ea513736876da515989eb Mon Sep 17 00:00:00 2001 From: Yi Li Date: Thu, 3 Aug 2023 12:37:40 +0800 Subject: 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 Cc: Jiewen Yao Cc: Xiaoyu Lu Cc: Guomin Jiang Reviewed-by: Jiewen Yao Acked-by: Ard Biesheuvel Tested-by: Ard Biesheuvel Tested-by: Brian J. Johnson Tested-by: Kenneth Lautner --- .../Library/IntrinsicLib/Ia32/MathDivModU64x64.c | 23 +++++++++++++++++++ .../Library/IntrinsicLib/Ia32/MathDivS64x64.c | 22 ++++++++++++++++++ .../Library/IntrinsicLib/Ia32/MathDivU64x64.c | 22 ++++++++++++++++++ .../Library/IntrinsicLib/Ia32/MathModU64x64.c | 26 ++++++++++++++++++++++ CryptoPkg/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 (limited to 'CryptoPkg/Library') 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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/* 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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/* 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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/* 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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/* 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] -- cgit v1.2.3