CryptoPkg Updates to support RFC3161 timestamp signature verification.
The main changes includes: 1. Enabling SHA384 and SHA512 digest algorithm; (Sha512.c) 2. RFC 3161 timestamp signature verification support; (CryptTs.c) 3. Fixed one ASN.1 length encoding issue in Authenticode verification routine. (CryptAuthenticode.c) 4. Add the corresponding test cases in Cryptest utility (SHA384 & SHA512 & Timestamp verification) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Guo Dong <guo.dong@intel.com> Reviewed-by: Ting Ye <ting.ye@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16339 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# MathDivU64x64.S
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit Math Worker Function.
|
||||
# Divides a 64-bit unsigned value with a 64-bit unsigned value and returns
|
||||
# a 64-bit unsigned result.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.686:
|
||||
.code:
|
||||
|
||||
ASM_GLOBAL ASM_PFX(__udivdi3), ASM_PFX(DivU64x64Remainder)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# void __cdecl __udivdi3 (void)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(__udivdi3):
|
||||
# Original local stack when calling __udivdi3
|
||||
# -----------------
|
||||
# | |
|
||||
# |---------------|
|
||||
# | |
|
||||
# |-- Divisor --|
|
||||
# | |
|
||||
# |---------------|
|
||||
# | |
|
||||
# |-- Dividend --|
|
||||
# | |
|
||||
# |---------------|
|
||||
# | ReturnAddr** |
|
||||
# ESP---->|---------------|
|
||||
#
|
||||
|
||||
#
|
||||
# Set up the local stack for NULL Reminder pointer
|
||||
#
|
||||
xorl %eax, %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Set up the local stack for Divisor parameter
|
||||
#
|
||||
movl 20(%esp), %eax
|
||||
push %eax
|
||||
movl 20(%esp), %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Set up the local stack for Dividend parameter
|
||||
#
|
||||
movl 20(%esp), %eax
|
||||
push %eax
|
||||
movl 20(%esp), %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Call native DivU64x64Remainder of BaseLib
|
||||
#
|
||||
jmp ASM_PFX(DivU64x64Remainder)
|
||||
|
||||
#
|
||||
# Adjust stack
|
||||
#
|
||||
addl $20, %esp
|
||||
|
||||
ret $16
|
@@ -1,88 +0,0 @@
|
||||
/** @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 - 2010, 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 with a 64-bit unsigned value and returns
|
||||
* a 64-bit unsigned result.
|
||||
*/
|
||||
__declspec(naked) void __cdecl _aulldiv (void)
|
||||
{
|
||||
//
|
||||
// Wrapper Implementation over EDKII DivU64x64Reminder() routine
|
||||
// UINT64
|
||||
// EFIAPI
|
||||
// DivU64x64Remainder (
|
||||
// IN UINT64 Dividend,
|
||||
// IN UINT64 Divisor,
|
||||
// OUT UINT64 *Remainder OPTIONAL
|
||||
// )
|
||||
//
|
||||
_asm {
|
||||
|
||||
; Original local stack when calling _aulldiv
|
||||
; -----------------
|
||||
; | |
|
||||
; |---------------|
|
||||
; | |
|
||||
; |-- Divisor --|
|
||||
; | |
|
||||
; |---------------|
|
||||
; | |
|
||||
; |-- Dividend --|
|
||||
; | |
|
||||
; |---------------|
|
||||
; | ReturnAddr** |
|
||||
; ESP---->|---------------|
|
||||
;
|
||||
|
||||
;
|
||||
; Set up the local stack for NULL Reminder pointer
|
||||
;
|
||||
xor eax, eax
|
||||
push eax
|
||||
|
||||
;
|
||||
; Set up the local stack for Divisor parameter
|
||||
;
|
||||
mov eax, [esp + 20]
|
||||
push eax
|
||||
mov eax, [esp + 20]
|
||||
push eax
|
||||
|
||||
;
|
||||
; Set up the local stack for Dividend parameter
|
||||
;
|
||||
mov eax, [esp + 20]
|
||||
push eax
|
||||
mov eax, [esp + 20]
|
||||
push eax
|
||||
|
||||
;
|
||||
; Call native DivU64x64Remainder of BaseLib
|
||||
;
|
||||
call DivU64x64Remainder
|
||||
|
||||
;
|
||||
; Adjust stack
|
||||
;
|
||||
add esp, 20
|
||||
|
||||
ret 16
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# MathLShiftS64.S
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit Math Worker Function.
|
||||
# Shifts a 64-bit signed value left by a certain number of bits.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.686:
|
||||
.code:
|
||||
|
||||
ASM_GLOBAL ASM_PFX(__ashldi3)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# void __cdecl __ashldi3 (void)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(__ashldi3):
|
||||
#
|
||||
# Handle shifting of 64 or more bits (return 0)
|
||||
#
|
||||
cmpb $64, %cl
|
||||
jae ReturnZero
|
||||
|
||||
#
|
||||
# Handle shifting of between 0 and 31 bits
|
||||
#
|
||||
cmpb $32, %cl
|
||||
jae More32
|
||||
shld %cl, %eax, %edx
|
||||
shl %cl, %eax
|
||||
ret
|
||||
|
||||
#
|
||||
# Handle shifting of between 32 and 63 bits
|
||||
#
|
||||
More32:
|
||||
movl %eax, %edx
|
||||
xor %eax, %eax
|
||||
and $31, %cl
|
||||
shl %cl, %edx
|
||||
ret
|
||||
|
||||
ReturnZero:
|
||||
xor %eax, %eax
|
||||
xor %edx, %edx
|
||||
ret
|
@@ -1,54 +0,0 @@
|
||||
/** @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 - 2010, 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.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# MathMultS64x64.S
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit Math Worker Function.
|
||||
# Multiplies a 64-bit signed or unsigned value by a 64-bit signed or unsigned value
|
||||
# and returns a 64-bit result
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.686:
|
||||
.code:
|
||||
|
||||
ASM_GLOBAL ASM_PFX(_mulll), ASM_PFX(MultS64x64)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# void __cdecl __mulll (void)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(__mulll):
|
||||
# Original local stack when calling __mulll
|
||||
# -----------------
|
||||
# | |
|
||||
# |---------------|
|
||||
# | |
|
||||
# |--Multiplier --|
|
||||
# | |
|
||||
# |---------------|
|
||||
# | |
|
||||
# |--Multiplicand-|
|
||||
# | |
|
||||
# |---------------|
|
||||
# | ReturnAddr** |
|
||||
# ESP---->|---------------|
|
||||
#
|
||||
|
||||
#
|
||||
# Set up the local stack for Multiplicand parameter
|
||||
#
|
||||
movl 16(%esp), %eax
|
||||
push %eax
|
||||
movl 16(%esp), %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Set up the local stack for Multiplier parameter
|
||||
#
|
||||
movl 16(%esp), %eax
|
||||
push %eax
|
||||
movl 16(%esp), %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Call native MulS64x64 of BaseLib
|
||||
#
|
||||
jmp ASM_PFX(MultS64x64)
|
||||
|
||||
#
|
||||
# Adjust stack
|
||||
#
|
||||
add $16, %esp
|
||||
|
||||
ret $16
|
@@ -1,79 +0,0 @@
|
||||
/** @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 - 2010, 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>
|
||||
|
||||
/*
|
||||
* Multiplies a 64-bit signed or unsigned value by a 64-bit signed or unsigned value
|
||||
* and returns a 64-bit result.
|
||||
*/
|
||||
__declspec(naked) void __cdecl _allmul (void)
|
||||
{
|
||||
//
|
||||
// Wrapper Implementation over EDKII MultS64x64() routine
|
||||
// INT64
|
||||
// EFIAPI
|
||||
// MultS64x64 (
|
||||
// IN INT64 Multiplicand,
|
||||
// IN INT64 Multiplier
|
||||
// )
|
||||
//
|
||||
_asm {
|
||||
; Original local stack when calling _allmul
|
||||
; -----------------
|
||||
; | |
|
||||
; |---------------|
|
||||
; | |
|
||||
; |--Multiplier --|
|
||||
; | |
|
||||
; |---------------|
|
||||
; | |
|
||||
; |--Multiplicand-|
|
||||
; | |
|
||||
; |---------------|
|
||||
; | ReturnAddr** |
|
||||
; ESP---->|---------------|
|
||||
;
|
||||
|
||||
;
|
||||
; Set up the local stack for Multiplicand parameter
|
||||
;
|
||||
mov eax, [esp + 16]
|
||||
push eax
|
||||
mov eax, [esp + 16]
|
||||
push eax
|
||||
|
||||
;
|
||||
; Set up the local stack for Multiplier parameter
|
||||
;
|
||||
mov eax, [esp + 16]
|
||||
push eax
|
||||
mov eax, [esp + 16]
|
||||
push eax
|
||||
|
||||
;
|
||||
; Call native MulS64x64 of BaseLib
|
||||
;
|
||||
call MultS64x64
|
||||
|
||||
;
|
||||
; Adjust stack
|
||||
;
|
||||
add esp, 16
|
||||
|
||||
ret 16
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2009 - 2013, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# MathRShiftU64.S
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit Math Worker Function.
|
||||
# Shifts a 64-bit unsigned value right by a certain number of bits.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.686:
|
||||
.code:
|
||||
|
||||
ASM_GLOBAL ASM_PFX(__ashrdi3)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# void __cdecl __ashrdi3 (void)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(__ashrdi3):
|
||||
#
|
||||
# Checking: Only handle 64bit shifting or more
|
||||
#
|
||||
cmpb $64, %cl
|
||||
jae _Exit
|
||||
|
||||
#
|
||||
# Handle shifting between 0 and 31 bits
|
||||
#
|
||||
cmpb $32, %cl
|
||||
jae More32
|
||||
shrd %cl, %edx, %eax
|
||||
shr %cl, %edx
|
||||
ret
|
||||
|
||||
#
|
||||
# Handle shifting of 32-63 bits
|
||||
#
|
||||
More32:
|
||||
movl %edx, %eax
|
||||
xor %edx, %edx
|
||||
and $31, %cl
|
||||
shr %cl, %eax
|
||||
ret
|
||||
|
||||
#
|
||||
# Invalid number (less then 32bits), return 0
|
||||
#
|
||||
_Exit:
|
||||
xor %eax, %eax
|
||||
xor %edx, %edx
|
||||
ret
|
@@ -1,57 +0,0 @@
|
||||
/** @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 - 2010, 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.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
/*
|
||||
* Shifts a 64-bit unsigned value right by a certain number of bits.
|
||||
*/
|
||||
__declspec(naked) void __cdecl _aullshr (void)
|
||||
{
|
||||
_asm {
|
||||
;
|
||||
; Checking: Only handle 64bit shifting or more
|
||||
;
|
||||
cmp cl, 64
|
||||
jae _Exit
|
||||
|
||||
;
|
||||
; Handle shifting between 0 and 31 bits
|
||||
;
|
||||
cmp cl, 32
|
||||
jae More32
|
||||
shrd eax, edx, cl
|
||||
shr edx, cl
|
||||
ret
|
||||
|
||||
;
|
||||
; Handle shifting of 32-63 bits
|
||||
;
|
||||
More32:
|
||||
mov eax, edx
|
||||
xor edx, edx
|
||||
and cl, 31
|
||||
shr eax, cl
|
||||
ret
|
||||
|
||||
;
|
||||
; Invalid number (less then 32bits), return 0
|
||||
;
|
||||
_Exit:
|
||||
xor eax, eax
|
||||
xor edx, edx
|
||||
ret
|
||||
}
|
||||
}
|
@@ -1,89 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# MathReminderU64x64.S
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# 64-bit Math Worker Function.
|
||||
# Divides a 64-bit unsigned value by another 64-bit unsigned value and returns
|
||||
# the 64-bit unsigned remainder
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
.686:
|
||||
.code:
|
||||
|
||||
ASM_GLOBAL ASM_PFX(__umoddi3), ASM_PFX(DivU64x64Remainder)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# void __cdecl __umoddi3 (void)
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_PFX(__umoddi3):
|
||||
# Original local stack when calling __umoddi3
|
||||
# -----------------
|
||||
# | |
|
||||
# |---------------|
|
||||
# | |
|
||||
# |-- Divisor --|
|
||||
# | |
|
||||
# |---------------|
|
||||
# | |
|
||||
# |-- Dividend --|
|
||||
# | |
|
||||
# |---------------|
|
||||
# | ReturnAddr** |
|
||||
# ESP---->|---------------|
|
||||
#
|
||||
|
||||
#
|
||||
# Set up the local stack for Reminder pointer
|
||||
#
|
||||
sub $8, %esp
|
||||
push %esp
|
||||
|
||||
#
|
||||
# Set up the local stack for Divisor parameter
|
||||
#
|
||||
movl 28(%esp), %eax
|
||||
push %eax
|
||||
movl 28(%esp), %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Set up the local stack for Dividend parameter
|
||||
#
|
||||
movl 28(%esp), %eax
|
||||
push %eax
|
||||
movl 28(%esp), %eax
|
||||
push %eax
|
||||
|
||||
#
|
||||
# Call native DivU64x64Remainder of BaseLib
|
||||
#
|
||||
jmp ASM_PFX(DivU64x64Remainder)
|
||||
|
||||
#
|
||||
# Put the Reminder in EDX:EAX as return value
|
||||
#
|
||||
movl 20(%esp), %eax
|
||||
movl 24(%esp), %edx
|
||||
|
||||
#
|
||||
# Adjust stack
|
||||
#
|
||||
add $28, %esp
|
||||
|
||||
ret $16
|
@@ -1,93 +0,0 @@
|
||||
/** @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 - 2010, 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user