forked from microsoft/mu_basecore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore IntrinsicLib to CryptoPkg (microsoft#712)
## Description Some silicon code is making use of the CryptoPkg's Intrinsic lib. Intrinsiclib was removed in afd1f31. Adding the functionality back to allow silicon code to use the library while a better long term solution is created. - [ ] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [ ] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [ ] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... ## How This Was Tested ## Integration Instructions N/A
- Loading branch information
1 parent
d4cc801
commit 6884dc0
Showing
20 changed files
with
1,411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// /** @file | ||
// Intrinsic Routines Wrapper Library Instance. | ||
// | ||
// This module is intrinsic routines wrapper library instance. | ||
// | ||
// Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR> | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
// | ||
// **/ | ||
|
||
|
||
#string STR_MODULE_ABSTRACT #language en-US "Intrinsic Routines Wrapper Library Instance" | ||
|
||
#string STR_MODULE_DESCRIPTION #language en-US "This module is intrinsic routines wrapper library instance." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** @file | ||
Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based | ||
Cryptographic Library. | ||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Base.h> | ||
#include <Library/BaseMemoryLib.h> | ||
|
||
#if defined (__clang__) && !defined (__APPLE__) | ||
|
||
/* Copies bytes between buffers */ | ||
static __attribute__ ((__used__)) | ||
void * | ||
__memcpy ( | ||
void *dest, | ||
const void *src, | ||
unsigned int count | ||
) | ||
{ | ||
return CopyMem (dest, src, (UINTN)count); | ||
} | ||
|
||
__attribute__ ((__alias__ ("__memcpy"))) | ||
void * | ||
memcpy ( | ||
void *dest, | ||
const void *src, | ||
unsigned int count | ||
); | ||
|
||
#else | ||
/* Copies bytes between buffers */ | ||
void * | ||
memcpy ( | ||
void *dest, | ||
const void *src, | ||
unsigned int count | ||
) | ||
{ | ||
return CopyMem (dest, src, (UINTN)count); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__)) | ||
unsigned long long | ||
__udivdi3 ( | ||
unsigned long long A, | ||
unsigned long long B | ||
) | ||
{ | ||
return DivU64x64Remainder ((UINT64)A, (UINT64)B, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** @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) 2019, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
/* | ||
* Floating point to integer conversion. | ||
*/ | ||
__declspec(naked) void | ||
_ftol2 ( | ||
void | ||
) | ||
{ | ||
_asm { | ||
fistp qword ptr [esp-8] | ||
mov edx, [esp-4] | ||
mov eax, [esp-8] | ||
ret | ||
} | ||
} | ||
|
||
__declspec(naked) void | ||
_ftol2_sse ( | ||
void | ||
) | ||
{ | ||
_asm { | ||
fistp dword ptr [esp-4] | ||
mov eax,[esp-4] | ||
ret | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** @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) 2014, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
/* | ||
* Shifts a 64-bit signed value left by a particular number of bits. | ||
*/ | ||
__declspec(naked) void __cdecl | ||
_allshl ( | ||
void | ||
) | ||
{ | ||
_asm { | ||
; | ||
; Handle shifting of 64 or more bits (return 0) | ||
; | ||
|
||
cmp cl, 64 | ||
jae short ReturnZero | ||
|
||
; | ||
; Handle shifting of between 0 and 31 bits | ||
; | ||
cmp cl, 32 | ||
jae short More32 | ||
shld edx, eax, cl | ||
shl eax, cl | ||
ret | ||
|
||
; | ||
; Handle shifting of between 32 and 63 bits | ||
; | ||
More32: | ||
mov edx, eax | ||
xor eax, eax | ||
and cl, 31 | ||
shl edx, cl | ||
ret | ||
|
||
ReturnZero: | ||
xor eax,eax | ||
xor edx,edx | ||
ret | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.