Skip to content

Commit

Permalink
TEST COMMIT: Update OcCompilerIntrinsicsLib so that it can build the …
Browse files Browse the repository at this point in the history
…network stack
  • Loading branch information
mikebeaton committed Sep 7, 2024
1 parent 5c94885 commit 2253496
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 9 deletions.
22 changes: 22 additions & 0 deletions Library/OcCompilerIntrinsicsLib/Ia32/MathDivS64x64.c
Original file line number Diff line number Diff line change
@@ -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);
}
42 changes: 42 additions & 0 deletions Library/OcCompilerIntrinsicsLib/Ia32/MathLShiftS64.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; MathLShiftS64.nasm
;
; Abstract:
;
; 64-bit Math Worker Function.
; Shifts a 64-bit signed value left by a certain number of bits.
;
;------------------------------------------------------------------------------

SECTION .text

global ASM_PFX(__ashldi3)
;------------------------------------------------------------------------------
;
; void __cdecl __ashldi3 (void)
;
;------------------------------------------------------------------------------
ASM_PFX(__ashldi3):
cmp cl,0x40
jnc ReturnZero
cmp cl,0x20
jnc More32
shld edx,eax,cl
shl eax,cl
ret
More32:
mov edx,eax
xor eax,eax
and cl,0x1f
shl edx,cl
ret
ReturnZero:
xor eax,eax
xor edx,edx
ret
26 changes: 26 additions & 0 deletions Library/OcCompilerIntrinsicsLib/Ia32/MathModU64x64.c
Original file line number Diff line number Diff line change
@@ -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;
}
67 changes: 67 additions & 0 deletions Library/OcCompilerIntrinsicsLib/Ia32/MathRShiftU64.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; MathRShiftU64.nasm
;
; Abstract:
;
; 64-bit Math Worker Function.
; Shifts a 64-bit unsigned value right by a certain number of bits.
;
;------------------------------------------------------------------------------

SECTION .text

;------------------------------------------------------------------------------
;
; void __cdecl __ashrdi3 (void)
;
;------------------------------------------------------------------------------
global ASM_PFX(__ashrdi3)
ASM_PFX(__ashrdi3):
cmp cl,0x40
jnc ReturnZero
cmp cl,0x20
jnc CounterMore32
shrd eax,edx,cl
sar edx,cl
ret
CounterMore32:
mov eax,edx
xor edx,edx
and cl,0x1f
sar eax,cl
ret
ReturnZero:
xor eax,eax
xor edx,edx
ret

;------------------------------------------------------------------------------
;
; void __cdecl __lshrdi3 (void)
;
;------------------------------------------------------------------------------
global ASM_PFX(__lshrdi3)
ASM_PFX(__lshrdi3):
cmp cl,0x40
jnc _Exit
cmp cl,0x20
jnc More32
shrd eax,edx,cl
shr edx,cl
ret
More32:
mov eax,edx
xor edx,edx
and cl,0x1f
shr eax,cl
ret
_Exit:
xor eax,eax
xor edx,edx
ret
12 changes: 11 additions & 1 deletion Library/OcCompilerIntrinsicsLib/OcCompilerIntrinsicsLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
**/

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>

GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN gOcCompilerIntrinsicsLib;

#if defined (MDE_CPU_IA32) && defined (__clang__) && defined (__apple_build_version__) && __apple_build_version__ < 11000000
#if defined (MDE_CPU_IA32) && defined (__clang__) && defined (__APPLE__)

/**
Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
Expand All @@ -32,6 +33,15 @@ __udivdi3 (
return DivU64x64Remainder (Dividend, Divisor, NULL);
}

void
__bzero (
void *src,
unsigned int count
)
{
ZeroMem (src, count);
}

#endif

typedef UINTN size_t;
Expand Down
7 changes: 6 additions & 1 deletion Library/OcCompilerIntrinsicsLib/OcCompilerIntrinsicsLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
OcCompilerIntrinsicsLib.c

[Sources.Ia32]
MsvcMath32.c | MSFT
Ia32/MsvcMath32.c | MSFT

Ia32/MathLShiftS64.nasm | GCC
Ia32/MathRShiftU64.nasm | GCC
Ia32/MathDivS64x64.c | GCC
Ia32/MathModU64x64.c | GCC

[Packages]
MdePkg/MdePkg.dec
Expand Down
6 changes: 2 additions & 4 deletions OpenCorePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
# FileExplorerLib is for TlsAuthConfigDxe only (not used by us, but enabled by NETWORK_TLS_ENABLE)
FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
IntrinsicLib|OpenCorePkg/Library/OcCompilerIntrinsicsLib/OcCompilerIntrinsicsLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
Expand Down Expand Up @@ -398,10 +398,8 @@
#
MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf

CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

[LibraryClasses]
NULL|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
NULL|OpenCorePkg/Library/OcCompilerIntrinsicsLib/OcCompilerIntrinsicsLib.inf

[PcdsFixedAtBuild]
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|0
Expand Down
4 changes: 1 addition & 3 deletions OpenDuetPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,8 @@
OpenCorePkg/Legacy/BootPlatform/LegacyRegion2Dxe/LegacyRegion2Dxe.inf
OpenCorePkg/Legacy/BootPlatform/BiosVideo/BiosVideo.inf

CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

[LibraryClasses]
NULL|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
NULL|OpenCorePkg/Library/OcCompilerIntrinsicsLib/OcCompilerIntrinsicsLib.inf

[PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol|FALSE
Expand Down

0 comments on commit 2253496

Please sign in to comment.