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>
This commit is contained in:
Yi Li 2023-08-03 12:37:40 +08:00 committed by mergify[bot]
parent 43e0ede26b
commit 4b5faa5775
5 changed files with 97 additions and 1 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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]