mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-24 06:04:52 +02:00
UefiCpuPkg/CpuPageTableLib: Add intrinsic lib to fix MSVC build
For the bitfield access, MSVC apparently uses a right shift of the base type of the bitfield member. In our case, is is cased by IA32_PTE_4K and IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE and other structures which uses uint64 bitfields and 32-bit x86 doesn't have a 64-bit integer shift (except using MMX or SSE2). With -Od (NOOPT) even for constant counts it puts the data in EDX:EAX, the shift count in cl and calls __aullshr. Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
This commit is contained in:
parent
c2778bdbd5
commit
0177e0ac42
91
CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64xU64Rem.c
Normal file
91
CryptoPkg/Library/IntrinsicLib/Ia32/MathDivU64xU64Rem.c
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/** @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) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials are licensed and made available
|
||||||
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php.
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Divides a 64-bit unsigned value by another 64-bit unsigned value and returns
|
||||||
|
* the 64-bit unsigned remainder.
|
||||||
|
*/
|
||||||
|
__declspec(naked) void __cdecl
|
||||||
|
_aullrem(void)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Wrapper Implementation over EDKII DivU64x64Remainder() routine
|
||||||
|
// UINT64
|
||||||
|
// EFIAPI
|
||||||
|
// DivU64x64Remainder (
|
||||||
|
// IN UINT64 Dividend,
|
||||||
|
// IN UINT64 Divisor,
|
||||||
|
// OUT UINT64 *Remainder OPTIONAL
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
_asm {
|
||||||
|
; Original local stack when calling _aullrem
|
||||||
|
; -----------------
|
||||||
|
; | |
|
||||||
|
; |---------------|
|
||||||
|
; | |
|
||||||
|
; |-- Divisor --|
|
||||||
|
; | |
|
||||||
|
; |---------------|
|
||||||
|
; | |
|
||||||
|
; |-- Dividend --|
|
||||||
|
; | |
|
||||||
|
; |---------------|
|
||||||
|
; | ReturnAddr** |
|
||||||
|
; ESP---->|---------------|
|
||||||
|
;
|
||||||
|
|
||||||
|
;
|
||||||
|
; Set up the local stack for Reminder pointer
|
||||||
|
;
|
||||||
|
sub esp, 8
|
||||||
|
push esp
|
||||||
|
|
||||||
|
;
|
||||||
|
; Set up the local stack for Divisor parameter
|
||||||
|
;
|
||||||
|
mov eax, [esp + 28]
|
||||||
|
push eax
|
||||||
|
mov eax, [esp + 28]
|
||||||
|
push eax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Set up the local stack for Dividend parameter
|
||||||
|
;
|
||||||
|
mov eax, [esp + 28]
|
||||||
|
push eax
|
||||||
|
mov eax, [esp + 28]
|
||||||
|
push eax
|
||||||
|
|
||||||
|
;
|
||||||
|
; Call native DivU64x64Remainder of BaseLib
|
||||||
|
;
|
||||||
|
call DivU64x64Remainder
|
||||||
|
|
||||||
|
;
|
||||||
|
; Put the Reminder in EDX:EAX as return value
|
||||||
|
;
|
||||||
|
mov eax, [esp + 20]
|
||||||
|
mov edx, [esp + 24]
|
||||||
|
|
||||||
|
;
|
||||||
|
; Adjust stack
|
||||||
|
;
|
||||||
|
add esp, 28
|
||||||
|
|
||||||
|
ret 16
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,7 @@
|
|||||||
[Sources.IA32]
|
[Sources.IA32]
|
||||||
CopyMem.c
|
CopyMem.c
|
||||||
|
|
||||||
|
Ia32/MathDivU64xU64Rem.c | MSFT
|
||||||
Ia32/MathLShiftS64.c | MSFT
|
Ia32/MathLShiftS64.c | MSFT
|
||||||
Ia32/MathRShiftU64.c | MSFT
|
Ia32/MathRShiftU64.c | MSFT
|
||||||
Ia32/MathFtol.c | MSFT
|
Ia32/MathFtol.c | MSFT
|
||||||
@ -37,6 +38,7 @@
|
|||||||
Ia32/MathLldiv.asm | MSFT
|
Ia32/MathLldiv.asm | MSFT
|
||||||
Ia32/MathUllrem.asm | MSFT
|
Ia32/MathUllrem.asm | MSFT
|
||||||
|
|
||||||
|
Ia32/MathDivU64xU64Rem.c | INTEL
|
||||||
Ia32/MathLShiftS64.c | INTEL
|
Ia32/MathLShiftS64.c | INTEL
|
||||||
Ia32/MathRShiftU64.c | INTEL
|
Ia32/MathRShiftU64.c | INTEL
|
||||||
Ia32/MathFtol.c | INTEL
|
Ia32/MathFtol.c | INTEL
|
||||||
|
@ -33,3 +33,4 @@
|
|||||||
BaseLib
|
BaseLib
|
||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
DebugLib
|
DebugLib
|
||||||
|
IntrinsicLib
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf
|
UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf
|
||||||
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
|
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
|
||||||
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.inf
|
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.inf
|
||||||
|
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
|
||||||
|
|
||||||
[LibraryClasses.common.SEC]
|
[LibraryClasses.common.SEC]
|
||||||
PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
|
PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
|
||||||
@ -124,6 +125,9 @@
|
|||||||
UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf
|
UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf
|
||||||
UefiCpuPkg/MicrocodeMeasurementDxe/MicrocodeMeasurementDxe.inf
|
UefiCpuPkg/MicrocodeMeasurementDxe/MicrocodeMeasurementDxe.inf
|
||||||
|
|
||||||
|
[Components.IA32]
|
||||||
|
CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
|
||||||
|
|
||||||
[Components.IA32, Components.X64]
|
[Components.IA32, Components.X64]
|
||||||
UefiCpuPkg/CpuDxe/CpuDxe.inf
|
UefiCpuPkg/CpuDxe/CpuDxe.inf
|
||||||
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf {
|
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user