<OutputFileBasename>Ebc</OutputFileBasename>\r
</ModuleDefinitions>\r
<LibraryClassDefinitions>\r
+ <LibraryClass Usage="ALWAYS_CONSUMED">\r
+ <Keyword>BaseLib</Keyword>\r
+ </LibraryClass>\r
<LibraryClass Usage="ALWAYS_CONSUMED">\r
<Keyword>DebugLib</Keyword>\r
</LibraryClass>\r
<Filename>Ebc.dxs</Filename>\r
<Filename SupArchList="IA32">Ia32/EbcLowLevel.asm</Filename>\r
<Filename SupArchList="IA32">Ia32/EbcLowLevel.S</Filename>\r
- <Filename SupArchList="IA32">Ia32/Ia32Math.asm</Filename>\r
- <Filename SupArchList="IA32">Ia32/Ia32Math.S</Filename>\r
<Filename SupArchList="IA32">Ia32/EbcSupport.c</Filename>\r
<Filename SupArchList="X64">x64/EbcLowLevel.asm</Filename>\r
- <Filename SupArchList="X64">x64/x64Math.c</Filename>\r
<Filename SupArchList="X64">x64/EbcSupport.c</Filename>\r
<Filename SupArchList="IPF">Ipf/EbcLowLevel.s</Filename>\r
- <Filename SupArchList="IPF">Ipf/IpfMath.c</Filename>\r
- <Filename SupArchList="IPF">Ipf/IpfMul.s</Filename>\r
<Filename SupArchList="IPF">Ipf/EbcSupport.c</Filename>\r
</SourceFiles>\r
<PackageDependencies>\r
\r
--*/\r
{\r
- INT64 ResultHigh;\r
-\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return MulS64x64 (Op1, Op2, &ResultHigh);\r
+ return MultS64x64 ((INT64)Op1, (INT64)Op2);\r
} else {\r
return (UINT64) ((INT64) ((INT32) Op1 * (INT32) Op2));\r
}\r
\r
--*/\r
{\r
- INT64 ResultHigh;\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return MulU64x64 (Op1, Op2, (UINT64 *)&ResultHigh);\r
+ return MultU64x64 (Op1, Op2);\r
} else {\r
return (UINT64) ((UINT32) Op1 * (UINT32) Op2);\r
}\r
--*/\r
{\r
INT64 Remainder;\r
- UINT32 Error;\r
\r
//\r
// Check for divide-by-0\r
return 0;\r
} else {\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return (UINT64) (DivS64x64 (Op1, Op2, &Remainder, &Error));\r
+ return (UINT64) (DivS64x64Remainder (Op1, Op2, &Remainder));\r
} else {\r
return (UINT64) ((INT64) ((INT32) Op1 / (INT32) Op2));\r
}\r
--*/\r
{\r
UINT64 Remainder;\r
- UINT32 Error;\r
\r
//\r
// Check for divide-by-0\r
// Get the destination register\r
//\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return (UINT64) (DivU64x64 (Op1, Op2, &Remainder, &Error));\r
+ return (UINT64) (DivU64x64Remainder ((INT64)Op1, (INT64)Op2, &Remainder));\r
} else {\r
return (UINT64) ((UINT32) Op1 / (UINT32) Op2);\r
}\r
--*/\r
{\r
INT64 Remainder;\r
- UINT32 Error;\r
\r
//\r
// Check for divide-by-0\r
);\r
return 0;\r
} else {\r
- DivS64x64 ((INT64) Op1, (INT64) Op2, &Remainder, &Error);\r
+ DivS64x64Remainder ((INT64)Op1, (INT64)Op2, &Remainder);\r
return Remainder;\r
}\r
}\r
--*/\r
{\r
UINT64 Remainder;\r
- UINT32 Error;\r
\r
//\r
// Check for divide-by-0\r
);\r
return 0;\r
} else {\r
- DivU64x64 (Op1, Op2, &Remainder, &Error);\r
+ DivU64x64Remainder (Op1, Op2, &Remainder);\r
return Remainder;\r
}\r
}\r
--*/\r
{\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return LeftShiftU64 (Op1, Op2);\r
+ return LShiftU64 (Op1, (UINTN)Op2);\r
} else {\r
return (UINT64) ((UINT32) ((UINT32) Op1 << (UINT32) Op2));\r
}\r
--*/\r
{\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return RightShiftU64 (Op1, Op2);\r
+ return RShiftU64 (Op1, (UINTN)Op2);\r
} else {\r
return (UINT64) ((UINT32) Op1 >> (UINT32) Op2);\r
}\r
--*/\r
{\r
if (*VmPtr->Ip & DATAMANIP_M_64) {\r
- return ARightShift64 (Op1, Op2);\r
+ return ARShiftU64 (Op1, (UINTN)Op2);\r
} else {\r
return (UINT64) ((INT64) ((INT32) Op1 >> (UINT32) Op2));\r
}\r
--*/\r
{\r
UINT64 Index;\r
- UINT64 Remainder;\r
INT64 Offset;\r
INT64 C;\r
INT64 N;\r
//\r
// Get the mask for N. First get the number of bits from the index.\r
//\r
- NBits = RightShiftU64 ((Index & 0x7000000000000000ULL), 60);\r
+ NBits = RShiftU64 ((Index & 0x7000000000000000ULL), 60);\r
\r
//\r
// Scale it for 64-bit indexes (multiply by 8 by shifting left 3)\r
//\r
- NBits = LeftShiftU64 (NBits, 3);\r
+ NBits = LShiftU64 ((UINT64)NBits, 3);\r
\r
//\r
// Now using the number of bits, create a mask.\r
//\r
- Mask = (LeftShiftU64 ((UINT64)~0, (UINT64) NBits));\r
+ Mask = (LShiftU64 ((UINT64)~0, (UINTN)NBits));\r
\r
//\r
// Now using the mask, extract N from the lower bits of the index.\r
//\r
// Now compute C\r
//\r
- C = ARightShift64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN) NBits);\r
+ C = ARShiftU64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN)NBits);\r
\r
- Offset = MulU64x64 (N, sizeof (UINTN), &Remainder) + C;\r
+ Offset = MultU64x64 (N, sizeof (UINTN)) + C;\r
\r
//\r
// Now set the sign\r
//\r
if (Index & 0x8000000000000000ULL) {\r
- Offset = MulS64x64 (Offset, -1, (INT64 *)&Index);\r
+ Offset = MultS64x64 (Offset, -1);\r
}\r
\r
return Offset;\r
)\r
;\r
\r
-//\r
-// Math library routines\r
-//\r
-INT64\r
-DivS64x64 (\r
- IN INT64 Value1,\r
- IN INT64 Value2,\r
- OUT INT64 *Remainder,\r
- OUT UINT32 *Error\r
- )\r
-;\r
-#if 0\r
-UINT64\r
-DivU64x64 (\r
- IN UINT64 Value1,\r
- IN UINT64 Value2,\r
- OUT UINT64 *Remainder,\r
- OUT UINT32 *Error\r
- )\r
-;\r
-#endif\r
-\r
-INT64\r
-MulS64x64 (\r
- IN INT64 Value1,\r
- IN INT64 Value2,\r
- OUT INT64 *ResultHigh\r
- )\r
-;\r
-\r
-UINT64\r
-MulU64x64 (\r
- IN UINT64 Value1,\r
- IN UINT64 Value2,\r
- OUT UINT64 *ResultHigh\r
- )\r
-;\r
\r
-UINT64\r
-DivU64x64 (\r
- IN UINT64 Value1,\r
- IN UINT64 Value2,\r
- OUT UINT64 *Remainder,\r
- OUT UINT32 *Error\r
- )\r
-;\r
-\r
-INT64\r
-ARightShift64 (\r
- IN INT64 Operand,\r
- IN INT64 Count\r
- )\r
-;\r
-\r
-UINT64\r
-LeftShiftU64 (\r
- IN UINT64 Operand,\r
- IN UINT64 Count\r
- )\r
-;\r
-\r
-UINT64\r
-RightShiftU64 (\r
- IN UINT64 Operand,\r
- IN UINT64 Count\r
- )\r
-;\r
\r
UINT64\r
GetVmVersion (\r
+++ /dev/null
-#------------------------------------------------------------------------------
-#
-# Copyright (c) 2006, Intel Corporation
-# All rights reserved. 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:
-#
-# Ia32math.S
-#
-# Abstract:
-#
-# Generic math routines for EBC interpreter running on IA32 processor
-#
-#------------------------------------------------------------------------------
-.globl _LeftShiftU64
-_LeftShiftU64:
- push %ebp
- mov %esp,%ebp
- push %ecx
- cmpl $0x0,0x14(%ebp)
- jne _LeftShiftU64+0x12
- mov 0x10(%ebp),%ecx
- cmp $0x3f,%ecx
- jbe _LeftShiftU64+0x18
- xor %eax,%eax
- xor %edx,%edx
- jmp _LeftShiftU64+0x2c
- mov 0x8(%ebp),%eax
- mov 0xc(%ebp),%edx
- shld %cl,%eax,%edx
- shl %cl,%eax
- cmp $0x20,%ecx
- jb _LeftShiftU64+0x2c
- mov %eax,%edx
- xor %eax,%eax
- pop %ecx
- leave
- ret
-
-.globl _RightShiftU64
-_RightShiftU64:
- push %ebp
- mov %esp,%ebp
- push %ecx
- cmpl $0x0,0x14(%ebp)
- jne _RightShiftU64+0x12
- mov 0x10(%ebp),%ecx
- cmp $0x3f,%ecx
- jbe _RightShiftU64+0x18
- xor %eax,%eax
- xor %edx,%edx
- jmp _RightShiftU64+0x2c
- mov 0x8(%ebp),%eax
- mov 0xc(%ebp),%edx
- shrd %cl,%edx,%eax
- shr %cl,%edx
- cmp $0x20,%ecx
- jb _RightShiftU64+0x2c
- mov %edx,%eax
- xor %edx,%edx
- pop %ecx
- leave
- ret
-
-.globl _ARightShift64
-_ARightShift64:
- push %ebp
- mov %esp,%ebp
- push %ecx
- cmpl $0x0,0x14(%ebp)
- jne _ARightShift64+0x12
- mov 0x10(%ebp),%ecx
- cmp $0x3f,%ecx
- jbe _ARightShift64+0x27
- btl $0x1f,0xc(%ebp)
- jae _ARightShift64+0x21
- or $0xffffffff,%eax
- or $0xffffffff,%edx
- jmp _ARightShift64+0x3c
- xor %eax,%eax
- xor %edx,%edx
- jmp _ARightShift64+0x3c
- mov 0x8(%ebp),%eax
- mov 0xc(%ebp),%edx
- shrd %cl,%edx,%eax
- sar %cl,%edx
- cmp $0x20,%ecx
- jb _ARightShift64+0x3c
- mov %edx,%eax
- sar $0x1f,%edx
- pop %ecx
- leave
- ret
-
-.globl _MulU64x64
-_MulU64x64:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %ecx
- mov 0x18(%ebp),%ebx
- mov 0x8(%ebp),%eax
- mull 0x10(%ebp)
- push %eax
- mov %edx,%ecx
- mov 0xc(%ebp),%eax
- mull 0x10(%ebp)
- add %eax,%ecx
- adc $0x0,%edx
- mov %edx,(%ebx)
- mov 0x8(%ebp),%eax
- mull 0x14(%ebp)
- add %eax,%ecx
- push %ecx
- adc $0x0,%edx
- mov %edx,%ecx
- mov 0xc(%ebp),%eax
- mull 0x14(%ebp)
- add %eax,%ecx
- adc $0x0,%edx
- add %ecx,(%ebx)
- adc $0x0,%edx
- mov %edx,0x4(%ebx)
- pop %edx
- pop %eax
- pop %ecx
- pop %ebx
- leave
- ret
-
-.globl _MulS64x64
-_MulS64x64:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %ecx
- mov 0x18(%ebp),%ebx
- xor %ecx,%ecx
- mov 0xc(%ebp),%edx
- bt $0x1f,%edx
- jae _MulS64x64+0x2a
- mov 0x8(%ebp),%eax
- not %edx
- not %eax
- add $0x1,%eax
- adc $0x0,%edx
- mov %eax,0x8(%ebp)
- mov %edx,0xc(%ebp)
- btc $0x0,%ecx
- mov 0x14(%ebp),%edx
- bt $0x1f,%edx
- jae _MulS64x64+0x4a
- mov 0x10(%ebp),%eax
- not %edx
- not %eax
- add $0x1,%eax
- adc $0x0,%edx
- mov %eax,0x10(%ebp)
- mov %edx,0x14(%ebp)
- btc $0x0,%ecx
- pushl 0x18(%ebp)
- pushl 0x14(%ebp)
- pushl 0x10(%ebp)
- pushl 0xc(%ebp)
- pushl 0x8(%ebp)
- call _MulU64x64
- add $0x14,%esp
- bt $0x0,%ecx
- jae _MulS64x64+0x7d
- not %eax
- not %edx
- notl (%ebx)
- notl 0x4(%ebx)
- add $0x1,%eax
- adc $0x0,%edx
- adcl $0x0,(%ebx)
- adcl $0x0,0x4(%ebx)
- pop %ecx
- pop %ebx
- leave
- ret
-
-.globl _DivU64x64
-_DivU64x64:
- push %ebp
- mov %esp,%ebp
- push %ecx
- mov 0x1c(%ebp),%eax
- movl $0x0,(%eax)
- cmpl $0x0,0x10(%ebp)
- jne _DivU64x64+0x3e
- cmpl $0x0,0x14(%ebp)
- jne _DivU64x64+0x3e
- movl $0x1,(%eax)
- cmpl $0x0,0x18(%ebp)
- je _DivU64x64+0x35
- mov 0x18(%ebp),%eax
- movl $0x0,(%eax)
- movl $0x80000000,0x4(%eax)
- xor %eax,%eax
- mov $0x80000000,%edx
- jmp _DivU64x64+0x7e
- xor %edx,%edx
- xor %eax,%eax
- mov $0x40,%ecx
- shll 0x8(%ebp)
- rcll 0xc(%ebp)
- rcl %eax
- rcl %edx
- cmp 0x14(%ebp),%edx
- ja _DivU64x64+0x5d
- jb _DivU64x64+0x68
- cmp 0x10(%ebp),%eax
- jb _DivU64x64+0x68
- btsl $0x0,0x8(%ebp)
- sub 0x10(%ebp),%eax
- sbb 0x14(%ebp),%edx
- loop _DivU64x64+0x47
- cmpl $0x0,0x18(%ebp)
- je _DivU64x64+0x78
- mov 0x18(%ebp),%ecx
- mov %eax,(%ecx)
- mov %edx,0x4(%ecx)
- mov 0x8(%ebp),%eax
- mov 0xc(%ebp),%edx
- pop %ecx
- leave
- ret
-
-.globl _DivS64x64
-_DivS64x64:
- push %ebp
- mov %esp,%ebp
- push %ecx
- mov 0x1c(%ebp),%eax
- movl $0x0,(%eax)
- cmpl $0x0,0x10(%ebp)
- jne _DivS64x64+0x41
- cmpl $0x0,0x14(%ebp)
- jne _DivS64x64+0x41
- movl $0x1,(%eax)
- cmpl $0x0,0x18(%ebp)
- je _DivS64x64+0x35
- mov 0x18(%ebp),%eax
- movl $0x0,(%eax)
- movl $0x80000000,0x4(%eax)
- xor %eax,%eax
- mov $0x80000000,%edx
- jmp _DivS64x64+0xc6
- xor %ecx,%ecx
- mov 0xc(%ebp),%edx
- bt $0x1f,%edx
- jae _DivS64x64+0x67
- mov 0x8(%ebp),%eax
- not %edx
- not %eax
- add $0x1,%eax
- adc $0x0,%edx
- mov %eax,0x8(%ebp)
- mov %edx,0xc(%ebp)
- btc $0x0,%ecx
- btc $0x1,%ecx
- mov 0x14(%ebp),%edx
- bt $0x1f,%edx
- jae _DivS64x64+0x87
- mov 0x10(%ebp),%eax
- not %edx
- not %eax
- add $0x1,%eax
- adc $0x0,%edx
- mov %eax,0x10(%ebp)
- mov %edx,0x14(%ebp)
- btc $0x0,%ecx
- pushl 0x1c(%ebp)
- pushl 0x18(%ebp)
- pushl 0x14(%ebp)
- pushl 0x10(%ebp)
- pushl 0xc(%ebp)
- pushl 0x8(%ebp)
- call _DivU64x64
- add $0x18,%esp
- bt $0x0,%ecx
- jae _DivS64x64+0xb1
- not %eax
- not %edx
- add $0x1,%eax
- adc $0x0,%edx
- bt $0x1,%ecx
- jae _DivS64x64+0xc6
- mov 0x18(%ebp),%ecx
- notl (%ecx)
- notl 0x4(%ecx)
- addl $0x1,(%ecx)
- adcl $0x0,0x4(%ecx)
- pop %ecx
- leave
- ret
+++ /dev/null
- TITLE Ia32math.asm: Generic math routines for EBC interpreter running on IA32 processor\r
-\r
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2006, Intel Corporation \r
-; All rights reserved. This program and the accompanying materials \r
-; are licensed and made available under the terms and conditions of the BSD License \r
-; which accompanies this distribution. The full text of the license may be found at \r
-; http://opensource.org/licenses/bsd-license.php \r
-; \r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-; \r
-; Module Name:\r
-;\r
-; Ia32math.asm\r
-; \r
-; Abstract:\r
-; \r
-; Generic math routines for EBC interpreter running on IA32 processor\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .686P\r
- .XMM\r
- .MODEL SMALL\r
- .CODE\r
-\r
-LeftShiftU64 PROTO C Operand: QWORD, CountIn: QWORD\r
-RightShiftU64 PROTO C Operand: QWORD, CountIn: QWORD\r
-ARightShift64 PROTO C Operand: QWORD, CountIn: QWORD\r
-MulU64x64 PROTO C Value1: QWORD, Value2: QWORD, ResultHigh: DWORD\r
-MulS64x64 PROTO C Value1: QWORD, Value2: QWORD, ResultHigh: DWORD\r
-DivU64x64 PROTO C Dividend: QWORD, Divisor: QWORD, Remainder: DWORD, Error: DWORD\r
-DivS64x64 PROTO C Dividend: QWORD, Divisor: QWORD, Remainder: DWORD, Error: DWORD\r
-\r
- \r
-LeftShiftU64 PROC C Operand: QWORD, CountIn: QWORD\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; LeftShiftU64 (\r
-; IN UINT64 Operand,\r
-; IN UINT64 CountIn\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; Left-shift a 64-bit value.\r
-;\r
-; Arguments:\r
-;\r
-; Operand - the value to shift\r
-; Count - shift count\r
-;\r
-; Returns:\r
-;\r
-; Operand << Count\r
-;------------------------------------------------------------------------------\r
-\r
- push ecx\r
- ;\r
- ; if (CountIn > 63) return 0;\r
- ;\r
- cmp dword ptr CountIn[4], 0\r
- jne _LeftShiftU64_Overflow\r
- mov ecx, dword ptr CountIn[0]\r
- cmp ecx, 63\r
- jbe _LeftShiftU64_Calc\r
- \r
-_LeftShiftU64_Overflow:\r
- xor eax, eax\r
- xor edx, edx\r
- jmp _LeftShiftU64_Done\r
- \r
-_LeftShiftU64_Calc:\r
- mov eax, dword ptr Operand[0]\r
- mov edx, dword ptr Operand[4]\r
- \r
- shld edx, eax, cl\r
- shl eax, cl\r
- cmp ecx, 32\r
- jc short _LeftShiftU64_Done\r
- \r
- mov edx, eax\r
- xor eax, eax\r
- \r
-_LeftShiftU64_Done:\r
- pop ecx\r
- ret\r
-\r
-LeftShiftU64 ENDP\r
-\r
-\r
-RightShiftU64 PROC C Operand: QWORD, CountIn: QWORD\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; RightShiftU64 (\r
-; IN UINT64 Operand,\r
-; IN UINT64 CountIn\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; Right-shift an unsigned 64-bit value.\r
-;\r
-; Arguments:\r
-;\r
-; Operand - the value to shift\r
-; Count - shift count\r
-;\r
-; Returns:\r
-;\r
-; Operand >> Count\r
-;------------------------------------------------------------------------------\r
-\r
- push ecx\r
- ;\r
- ; if (CountIn > 63) return 0;\r
- ;\r
- cmp dword ptr CountIn[4], 0\r
- jne _RightShiftU64_Overflow\r
- mov ecx, dword ptr CountIn[0]\r
- cmp ecx, 63\r
- jbe _RightShiftU64_Calc\r
- \r
-_RightShiftU64_Overflow:\r
- xor eax, eax\r
- xor edx, edx\r
- jmp _RightShiftU64_Done\r
- \r
-_RightShiftU64_Calc:\r
- mov eax, dword ptr Operand[0]\r
- mov edx, dword ptr Operand[4]\r
- \r
- shrd eax, edx, cl\r
- shr edx, cl\r
- cmp ecx, 32\r
- jc short _RightShiftU64_Done\r
- \r
- mov eax, edx\r
- xor edx, edx\r
- \r
-_RightShiftU64_Done:\r
- pop ecx\r
- ret\r
-\r
-RightShiftU64 ENDP\r
-\r
-\r
-ARightShift64 PROC C Operand: QWORD, CountIn: QWORD\r
-\r
-;------------------------------------------------------------------------------\r
-; INT64\r
-; ARightShift64 (\r
-; IN INT64 Operand,\r
-; IN UINT64 CountIn\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; Arithmatic shift a 64 bit signed value.\r
-;\r
-; Arguments:\r
-;\r
-; Operand - the value to shift\r
-; Count - shift count\r
-;\r
-; Returns:\r
-;\r
-; Operand >> Count\r
-;------------------------------------------------------------------------------\r
-\r
- push ecx\r
- ;\r
- ; If they exceeded the max shift count, then return either 0 or all F's\r
- ; depending on the sign bit.\r
- ;\r
- cmp dword ptr CountIn[4], 0\r
- jne _ARightShiftU64_Overflow\r
- mov ecx, dword ptr CountIn[0]\r
- cmp ecx, 63\r
- jbe _ARightShiftU64_Calc\r
- \r
-_ARightShiftU64_Overflow:\r
- ;\r
- ; Check the sign bit of Operand\r
- ;\r
- bt dword ptr Operand[4], 31\r
- jnc _ARightShiftU64_Return_Zero\r
- ;\r
- ; return -1\r
- ;\r
- or eax, 0FFFFFFFFh\r
- or edx, 0FFFFFFFFh\r
- jmp _ARightShiftU64_Done\r
-\r
-_ARightShiftU64_Return_Zero:\r
- xor eax, eax\r
- xor edx, edx\r
- jmp _ARightShiftU64_Done\r
- \r
-_ARightShiftU64_Calc:\r
- mov eax, dword ptr Operand[0]\r
- mov edx, dword ptr Operand[4]\r
-\r
- shrd eax, edx, cl\r
- sar edx, cl\r
- cmp ecx, 32\r
- jc short _ARightShiftU64_Done\r
-\r
- ;\r
- ; if ecx >= 32, then eax = edx, and edx = sign bit\r
- ;\r
- mov eax, edx\r
- sar edx, 31\r
-\r
-_ARightShiftU64_Done:\r
- pop ecx\r
- ret\r
-\r
-ARightShift64 ENDP\r
-\r
-\r
-MulU64x64 PROC C Value1: QWORD, Value2: QWORD, ResultHigh: DWORD\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64 \r
-; MulU64x64 (\r
-; UINT64 Value1, \r
-; UINT64 Value2, \r
-; UINT64 *ResultHigh\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; Multiply two unsigned 64-bit values.\r
-;\r
-; Arguments:\r
-;\r
-; Value1 - first value to multiply\r
-; Value2 - value to multiply by Value1\r
-; ResultHigh - result to flag overflows\r
-;\r
-; Returns:\r
-; \r
-; Value1 * Value2\r
-; The 128-bit result is the concatenation of *ResultHigh and the return value \r
-;------------------------------------------------------------------------------\r
-\r
- push ebx\r
- push ecx\r
- mov ebx, ResultHigh ; ebx points to the high 4 words of result\r
- ;\r
- ; The result consists of four double-words.\r
- ; Here we assume their names from low to high: dw0, dw1, dw2, dw3\r
- ;\r
- mov eax, dword ptr Value1[0]\r
- mul dword ptr Value2[0]\r
- push eax ; eax contains final result of dw0, push it\r
- mov ecx, edx ; ecx contains partial result of dw1\r
- \r
- mov eax, dword ptr Value1[4]\r
- mul dword ptr Value2[0]\r
- add ecx, eax ; add eax to partial result of dw1\r
- adc edx, 0 \r
- mov dword ptr [ebx], edx ; lower double-word of ResultHigh contains partial result of dw2\r
- \r
- mov eax, dword ptr Value1[0]\r
- mul dword ptr Value2[4]\r
- add ecx, eax ; add eax to partial result of dw1\r
- push ecx ; ecx contains final result of dw1, push it\r
- adc edx, 0\r
- mov ecx, edx ; ecx contains partial result of dw2, together with ResultHigh\r
-\r
- mov eax, dword ptr Value1[4]\r
- mul dword ptr Value2[4]\r
- add ecx, eax ; add eax to partial result of dw2\r
- adc edx, 0\r
- add dword ptr [ebx], ecx ; lower double-word of ResultHigh contains final result of dw2\r
- adc edx, 0\r
- mov dword ptr [ebx + 4], edx ; high double-word of ResultHigh contains final result of dw3\r
- \r
- pop edx ; edx contains the final result of dw1\r
- pop eax ; edx contains the final result of dw0\r
- pop ecx\r
- pop ebx\r
- ret\r
-\r
-MulU64x64 ENDP\r
-\r
-\r
-MulS64x64 PROC C Value1: QWORD, Value2: QWORD, ResultHigh: DWORD\r
-\r
-;------------------------------------------------------------------------------\r
-; INT64\r
-; MulS64x64 (\r
-; INT64 Value1,\r
-; INT64 Value2,\r
-; INT64 *ResultHigh\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; Multiply two signed 64-bit values.\r
-;\r
-; Arguments:\r
-;\r
-; Value1 - first value to multiply\r
-; Value2 - value to multiply by Value1\r
-; ResultHigh - result to flag overflows\r
-;\r
-; Returns:\r
-;\r
-; Value1 * Value2\r
-; The 128-bit result is the concatenation of *ResultHigh and the return value \r
-;------------------------------------------------------------------------------\r
-\r
- push ebx\r
- push ecx\r
- mov ebx, ResultHigh ; ebx points to the high 4 words of result\r
- xor ecx, ecx ; the lowest bit of ecx flags the sign\r
- \r
- mov edx, dword ptr Value1[4]\r
- bt edx, 31\r
- jnc short _MulS64x64_A_Positive\r
- ;\r
- ; a is negative\r
- ;\r
- mov eax, dword ptr Value1[0]\r
- not edx\r
- not eax\r
- add eax, 1\r
- adc edx, 0\r
- mov dword ptr Value1[0], eax\r
- mov dword ptr Value1[4], edx\r
- btc ecx, 0\r
- \r
-_MulS64x64_A_Positive:\r
- mov edx, dword ptr Value2[4]\r
- bt edx, 31\r
- jnc short _MulS64x64_B_Positive\r
- ;\r
- ; b is negative\r
- ;\r
- mov eax, dword ptr Value2[0]\r
- not edx\r
- not eax\r
- add eax, 1\r
- adc edx, 0\r
- mov dword ptr Value2[0], eax\r
- mov dword ptr Value2[4], edx\r
- btc ecx, 0\r
- \r
-_MulS64x64_B_Positive:\r
- invoke MulU64x64, Value1, Value2, ResultHigh\r
- bt ecx, 0\r
- jnc short _MulS64x64_Done\r
- ;\r
- ;negate the result\r
- ;\r
- not eax\r
- not edx\r
- not dword ptr [ebx]\r
- not dword ptr [ebx + 4]\r
- add eax, 1\r
- adc edx, 0\r
- adc dword ptr [ebx], 0\r
- adc dword ptr [ebx + 4], 0\r
- \r
-_MulS64x64_Done:\r
- pop ecx\r
- pop ebx\r
- ret\r
-\r
-MulS64x64 ENDP\r
-\r
-\r
-DivU64x64 PROC C Dividend: QWORD, Divisor: QWORD, Remainder: DWORD, Error: DWORD, \r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; DivU64x64 (\r
-; IN UINT64 Dividend,\r
-; IN UINT64 Divisor,\r
-; OUT UINT64 *Remainder OPTIONAL,\r
-; OUT UINT32 *Error\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; This routine allows a 64 bit value to be divided with a 64 bit value returns \r
-; 64bit result and the Remainder\r
-;\r
-; Arguments:\r
-;\r
-; Dividend - dividend\r
-; Divisor - divisor\r
-; ResultHigh - result to flag overflows\r
-; Error - flag for error\r
-;\r
-; Returns:\r
-; \r
-; Dividend / Divisor\r
-; Remainder = Dividend mod Divisor\r
-;------------------------------------------------------------------------------\r
-\r
- push ecx\r
- \r
- mov eax, Error\r
- mov dword ptr [eax], 0 \r
- \r
- cmp dword ptr Divisor[0], 0\r
- jne _DivU64x64_Valid\r
- cmp dword ptr Divisor[4], 0\r
- jne _DivU64x64_Valid\r
- ;\r
- ; the divisor is zero\r
- ;\r
- mov dword ptr [eax], 1 \r
- cmp Remainder, 0\r
- je _DivU64x64_Invalid_Return\r
- ;\r
- ; fill the remainder if the pointer is not null\r
- ;\r
- mov eax, Remainder\r
- mov dword ptr [eax], 0\r
- mov dword ptr [eax + 4], 80000000h\r
- \r
-_DivU64x64_Invalid_Return:\r
- xor eax, eax\r
- mov edx, 80000000h\r
- jmp _DivU64x64_Done\r
-\r
-_DivU64x64_Valid:\r
- ;\r
- ; let edx and eax contain the intermediate result of remainder\r
- ;\r
- xor edx, edx\r
- xor eax, eax\r
- mov ecx, 64\r
- \r
-_DivU64x64_Wend:\r
- ;\r
- ; shift dividend left one\r
- ;\r
- shl dword ptr Dividend[0], 1\r
- rcl dword ptr Dividend[4], 1 \r
- ;\r
- ; rotate intermediate result of remainder left one\r
- ;\r
- rcl eax, 1\r
- rcl edx, 1 \r
- \r
- cmp edx, dword ptr Divisor[4]\r
- ja _DivU64x64_Sub_Divisor\r
- jb _DivU64x64_Cont\r
- cmp eax, dword ptr Divisor[0]\r
- jb _DivU64x64_Cont\r
- \r
-_DivU64x64_Sub_Divisor:\r
- ;\r
- ; If intermediate result of remainder is larger than\r
- ; or equal to divisor, then set the lowest bit of dividend,\r
- ; and subtract divisor from intermediate remainder\r
- ;\r
- bts dword ptr Dividend[0], 0\r
- sub eax, dword ptr Divisor[0]\r
- sbb edx, dword ptr Divisor[4]\r
- \r
-_DivU64x64_Cont:\r
- loop _DivU64x64_Wend\r
- \r
- cmp Remainder, 0\r
- je _DivU64x64_Assign\r
- mov ecx, Remainder\r
- mov dword ptr [ecx], eax\r
- mov dword ptr [ecx + 4], edx\r
- \r
-_DivU64x64_Assign:\r
- mov eax, dword ptr Dividend[0]\r
- mov edx, dword ptr Dividend[4]\r
- \r
-_DivU64x64_Done:\r
- pop ecx\r
- ret\r
- \r
-DivU64x64 ENDP\r
-\r
-DivS64x64 PROC C Dividend: QWORD, Divisor: QWORD, Remainder: DWORD, Error: DWORD, \r
-\r
-;------------------------------------------------------------------------------\r
-; INT64\r
-; DivU64x64 (\r
-; IN INT64 Dividend,\r
-; IN INT64 Divisor,\r
-; OUT UINT64 *Remainder OPTIONAL,\r
-; OUT UINT32 *Error\r
-; )\r
-;\r
-; Routine Description:\r
-; \r
-; This routine allows a 64 bit signed value to be divided with a 64 bit \r
-; signed value returns 64bit result and the Remainder.\r
-;\r
-; Arguments:\r
-;\r
-; Dividend - dividend\r
-; Divisor - divisor\r
-; ResultHigh - result to flag overflows\r
-; Error - flag for error\r
-;\r
-; Returns:\r
-; \r
-; Dividend / Divisor\r
-; Remainder = Dividend mod Divisor\r
-;------------------------------------------------------------------------------\r
-\r
- push ecx\r
- \r
- mov eax, Error\r
- mov dword ptr [eax], 0 \r
- \r
- cmp dword ptr Divisor[0], 0\r
- jne _DivS64x64_Valid\r
- cmp dword ptr Divisor[4], 0\r
- jne _DivS64x64_Valid\r
- ;\r
- ; the divisor is zero\r
- ;\r
- mov dword ptr [eax], 1 \r
- cmp Remainder, 0\r
- je _DivS64x64_Invalid_Return\r
- ;\r
- ; fill the remainder if the pointer is not null\r
- ;\r
- mov eax, Remainder\r
- mov dword ptr [eax], 0\r
- mov dword ptr [eax + 4], 80000000h\r
- \r
-_DivS64x64_Invalid_Return:\r
- xor eax, eax\r
- mov edx, 80000000h\r
- jmp _DivS64x64_Done\r
-\r
-_DivS64x64_Valid:\r
- ;\r
- ; The lowest bit of ecx flags the sign of quotient,\r
- ; The seconde lowest bit flags the sign of remainder\r
- ;\r
- xor ecx, ecx \r
- \r
- mov edx, dword ptr Dividend[4]\r
- bt edx, 31\r
- jnc short _DivS64x64_Dividend_Positive\r
- ;\r
- ; dividend is negative\r
- ;\r
- mov eax, dword ptr Dividend[0]\r
- not edx\r
- not eax\r
- add eax, 1\r
- adc edx, 0\r
- mov dword ptr Dividend[0], eax\r
- mov dword ptr Dividend[4], edx\r
- ;\r
- ; set both the flags for signs of quotient and remainder\r
- ;\r
- btc ecx, 0\r
- btc ecx, 1\r
- \r
-_DivS64x64_Dividend_Positive:\r
- mov edx, dword ptr Divisor[4]\r
- bt edx, 31\r
- jnc short _DivS64x64_Divisor_Positive\r
- ;\r
- ; divisor is negative\r
- ;\r
- mov eax, dword ptr Divisor[0]\r
- not edx\r
- not eax\r
- add eax, 1\r
- adc edx, 0\r
- mov dword ptr Divisor[0], eax\r
- mov dword ptr Divisor[4], edx\r
- ;\r
- ; just complement the flag for sign of quotient\r
- ;\r
- btc ecx, 0\r
- \r
-_DivS64x64_Divisor_Positive:\r
- invoke DivU64x64, Dividend, Divisor, Remainder, Error\r
- bt ecx, 0\r
- jnc short _DivS64x64_Remainder\r
- ;\r
- ; negate the quotient\r
- ;\r
- not eax\r
- not edx\r
- add eax, 1\r
- adc edx, 0\r
- \r
-_DivS64x64_Remainder:\r
- bt ecx, 1\r
- jnc short _DivS64x64_Done\r
- ;\r
- ; negate the remainder\r
- ;\r
- mov ecx, remainder\r
- not dword ptr [ecx]\r
- not dword ptr [ecx + 4]\r
- add dword ptr [ecx], 1\r
- adc dword ptr [ecx + 4], 0\r
- \r
-_DivS64x64_Done:\r
- pop ecx\r
- ret\r
-\r
-DivS64x64 ENDP\r
-\r
-END
\ No newline at end of file
UINT8 *Ptr;\r
UINT8 *ThunkBase;\r
UINT64 Addr;\r
- UINT64 Code[3]; // Code in a bundle\r
- UINT64 RegNum; // register number for MOVL\r
- UINT64 I; // bits of MOVL immediate data\r
- UINT64 Ic; // bits of MOVL immediate data\r
- UINT64 Imm5c; // bits of MOVL immediate data\r
- UINT64 Imm9d; // bits of MOVL immediate data\r
- UINT64 Imm7b; // bits of MOVL immediate data\r
- UINT64 Br; // branch register for loading and jumping\r
+ UINT64 Code[3]; // Code in a bundle\r
+ UINT64 RegNum; // register number for MOVL\r
+ UINT64 I; // bits of MOVL immediate data\r
+ UINT64 Ic; // bits of MOVL immediate data\r
+ UINT64 Imm5c; // bits of MOVL immediate data\r
+ UINT64 Imm9d; // bits of MOVL immediate data\r
+ UINT64 Imm7b; // bits of MOVL immediate data\r
+ UINT64 Br; // branch register for loading and jumping\r
UINT64 *Data64Ptr;\r
UINT32 ThunkSize;\r
UINT32 Size;\r
//\r
// Next is simply Addr[62:22] (41 bits) of the address\r
//\r
- Code[1] = RightShiftU64 (Addr, 22) & 0x1ffffffffff;\r
+ Code[1] = RShiftU64 (Addr, 22) & 0x1ffffffffff;\r
\r
//\r
// Extract bits from the address for insertion into the instruction\r
// i = Addr[63:63]\r
//\r
- I = RightShiftU64 (Addr, 63) & 0x01;\r
+ I = RShiftU64 (Addr, 63) & 0x01;\r
//\r
// ic = Addr[21:21]\r
//\r
- Ic = RightShiftU64 (Addr, 21) & 0x01;\r
+ Ic = RShiftU64 (Addr, 21) & 0x01;\r
//\r
// imm5c = Addr[20:16] for 5 bits\r
//\r
- Imm5c = RightShiftU64 (Addr, 16) & 0x1F;\r
+ Imm5c = RShiftU64 (Addr, 16) & 0x1F;\r
//\r
// imm9d = Addr[15:7] for 9 bits\r
//\r
- Imm9d = RightShiftU64 (Addr, 7) & 0x1FF;\r
+ Imm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
//\r
// imm7b = Addr[6:0] for 7 bits\r
//\r
//\r
// Next is jumbled data, including opcode and rest of address\r
//\r
- Code[2] = LeftShiftU64 (Imm7b, 13)\r
- | LeftShiftU64 (0x00, 20) // vc\r
- | LeftShiftU64 (Ic, 21)\r
- | LeftShiftU64 (Imm5c, 22)\r
- | LeftShiftU64 (Imm9d, 27)\r
- | LeftShiftU64 (I, 36)\r
- | LeftShiftU64 ((UINT64)MOVL_OPCODE, 37)\r
- | LeftShiftU64 ((RegNum & 0x7F), 6);\r
+ Code[2] = LShiftU64 (Imm7b, 13)\r
+ | LShiftU64 (0x00, 20) // vc\r
+ | LShiftU64 (Ic, 21)\r
+ | LShiftU64 (Imm5c, 22)\r
+ | LShiftU64 (Imm9d, 27)\r
+ | LShiftU64 (I, 36)\r
+ | LShiftU64 ((UINT64)MOVL_OPCODE, 37)\r
+ | LShiftU64 ((RegNum & 0x7F), 6);\r
\r
WriteBundle ((VOID *) Ptr, 0x05, Code[0], Code[1], Code[2]);\r
\r
//\r
// Next is simply Addr[62:22] (41 bits) of the address\r
//\r
- Code[1] = RightShiftU64 (Addr, 22) & 0x1ffffffffff;\r
+ Code[1] = RShiftU64 (Addr, 22) & 0x1ffffffffff;\r
\r
//\r
// Extract bits from the address for insertion into the instruction\r
// i = Addr[63:63]\r
//\r
- I = RightShiftU64 (Addr, 63) & 0x01;\r
+ I = RShiftU64 (Addr, 63) & 0x01;\r
//\r
// ic = Addr[21:21]\r
//\r
- Ic = RightShiftU64 (Addr, 21) & 0x01;\r
+ Ic = RShiftU64 (Addr, 21) & 0x01;\r
//\r
// imm5c = Addr[20:16] for 5 bits\r
//\r
- Imm5c = RightShiftU64 (Addr, 16) & 0x1F;\r
+ Imm5c = RShiftU64 (Addr, 16) & 0x1F;\r
//\r
// imm9d = Addr[15:7] for 9 bits\r
//\r
- Imm9d = RightShiftU64 (Addr, 7) & 0x1FF;\r
+ Imm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
//\r
// imm7b = Addr[6:0] for 7 bits\r
//\r
//\r
// Next is jumbled data, including opcode and rest of address\r
//\r
- Code[2] = LeftShiftU64 (Imm7b, 13)\r
- | LeftShiftU64 (0x00, 20) // vc\r
- | LeftShiftU64 (Ic, 21)\r
- | LeftShiftU64 (Imm5c, 22)\r
- | LeftShiftU64 (Imm9d, 27)\r
- | LeftShiftU64 (I, 36)\r
- | LeftShiftU64 ((UINT64)MOVL_OPCODE, 37)\r
- | LeftShiftU64 ((RegNum & 0x7F), 6);\r
+ Code[2] = LShiftU64 (Imm7b, 13)\r
+ | LShiftU64 (0x00, 20) // vc\r
+ | LShiftU64 (Ic, 21)\r
+ | LShiftU64 (Imm5c, 22)\r
+ | LShiftU64 (Imm9d, 27)\r
+ | LShiftU64 (I, 36)\r
+ | LShiftU64 ((UINT64)MOVL_OPCODE, 37)\r
+ | LShiftU64 ((RegNum & 0x7F), 6);\r
\r
WriteBundle ((VOID *) Ptr, 0x05, Code[0], Code[1], Code[2]);\r
\r
//\r
// Next is simply Addr[62:22] (41 bits) of the address\r
//\r
- Code[1] = RightShiftU64 (Addr, 22) & 0x1ffffffffff;\r
+ Code[1] = RShiftU64 (Addr, 22) & 0x1ffffffffff;\r
\r
//\r
// Extract bits from the address for insertion into the instruction\r
// i = Addr[63:63]\r
//\r
- I = RightShiftU64 (Addr, 63) & 0x01;\r
+ I = RShiftU64 (Addr, 63) & 0x01;\r
//\r
// ic = Addr[21:21]\r
//\r
- Ic = RightShiftU64 (Addr, 21) & 0x01;\r
+ Ic = RShiftU64 (Addr, 21) & 0x01;\r
//\r
// imm5c = Addr[20:16] for 5 bits\r
//\r
- Imm5c = RightShiftU64 (Addr, 16) & 0x1F;\r
+ Imm5c = RShiftU64 (Addr, 16) & 0x1F;\r
//\r
// imm9d = Addr[15:7] for 9 bits\r
//\r
- Imm9d = RightShiftU64 (Addr, 7) & 0x1FF;\r
+ Imm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
//\r
// imm7b = Addr[6:0] for 7 bits\r
//\r
//\r
// Next is jumbled data, including opcode and rest of address\r
//\r
- Code[2] = LeftShiftU64(Imm7b, 13)\r
- | LeftShiftU64 (0x00, 20) // vc\r
- | LeftShiftU64 (Ic, 21)\r
- | LeftShiftU64 (Imm5c, 22)\r
- | LeftShiftU64 (Imm9d, 27)\r
- | LeftShiftU64 (I, 36)\r
- | LeftShiftU64 ((UINT64)MOVL_OPCODE, 37)\r
- | LeftShiftU64 ((RegNum & 0x7F), 6);\r
+ Code[2] = LShiftU64(Imm7b, 13)\r
+ | LShiftU64 (0x00, 20) // vc\r
+ | LShiftU64 (Ic, 21)\r
+ | LShiftU64 (Imm5c, 22)\r
+ | LShiftU64 (Imm9d, 27)\r
+ | LShiftU64 (I, 36)\r
+ | LShiftU64 ((UINT64)MOVL_OPCODE, 37)\r
+ | LShiftU64 ((RegNum & 0x7F), 6);\r
\r
WriteBundle ((VOID *) Ptr, 0x05, Code[0], Code[1], Code[2]);\r
\r
// register and user register (same user register as previous bundle).\r
//\r
Br = 6;\r
- Code[2] |= LeftShiftU64 (Br, 6);\r
- Code[2] |= LeftShiftU64 (RegNum, 13);\r
+ Code[2] |= LShiftU64 (Br, 6);\r
+ Code[2] |= LShiftU64 (RegNum, 13);\r
WriteBundle ((VOID *) Ptr, 0x0d, Code[0], Code[1], Code[2]);\r
\r
//\r
Code[0] = OPCODE_NOP;\r
Code[1] = OPCODE_NOP;\r
Code[2] = OPCODE_BR_COND_SPTK_FEW;\r
- Code[2] |= LeftShiftU64 (Br, 13);\r
+ Code[2] |= LShiftU64 (Br, 13);\r
WriteBundle ((VOID *) Ptr, 0x1d, Code[0], Code[1], Code[2]);\r
\r
//\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Low64 = LeftShiftU64 (Slot1, 46) | LeftShiftU64 (Slot0, 5) | Template;\r
- High64 = RightShiftU64 (Slot1, 18) | LeftShiftU64 (Slot2, 23);\r
+ Low64 = LShiftU64 (Slot1, 46) | LShiftU64 (Slot0, 5) | Template;\r
+ High64 = RShiftU64 (Slot1, 18) | LShiftU64 (Slot2, 23);\r
\r
//\r
// Now write it all out\r
BPtr = (UINT8 *) MemPtr;\r
for (Index = 0; Index < 8; Index++) {\r
*BPtr = (UINT8) Low64;\r
- Low64 = RightShiftU64 (Low64, 8);\r
+ Low64 = RShiftU64 (Low64, 8);\r
BPtr++;\r
}\r
\r
for (Index = 0; Index < 8; Index++) {\r
*BPtr = (UINT8) High64;\r
- High64 = RightShiftU64 (High64, 8);\r
+ High64 = RShiftU64 (High64, 8);\r
BPtr++;\r
}\r
\r
goto Action;\r
}\r
\r
- CodeOne18 = RightShiftU64 (*((UINT64 *)CalleeAddr + 2), 46) & 0x3FFFF;\r
+ CodeOne18 = RShiftU64 (*((UINT64 *)CalleeAddr + 2), 46) & 0x3FFFF;\r
CodeOne23 = (*((UINT64 *)CalleeAddr + 3)) & 0x7FFFFF;\r
- CodeTwoI = RightShiftU64 (*((UINT64 *)CalleeAddr + 3), 59) & 0x1;\r
- CodeTwoIc = RightShiftU64 (*((UINT64 *)CalleeAddr + 3), 44) & 0x1;\r
- CodeTwo7b = RightShiftU64 (*((UINT64 *)CalleeAddr + 3), 36) & 0x7F;\r
- CodeTwo5c = RightShiftU64 (*((UINT64 *)CalleeAddr + 3), 45) & 0x1F;\r
- CodeTwo9d = RightShiftU64 (*((UINT64 *)CalleeAddr + 3), 50) & 0x1FF;\r
+ CodeTwoI = RShiftU64 (*((UINT64 *)CalleeAddr + 3), 59) & 0x1;\r
+ CodeTwoIc = RShiftU64 (*((UINT64 *)CalleeAddr + 3), 44) & 0x1;\r
+ CodeTwo7b = RShiftU64 (*((UINT64 *)CalleeAddr + 3), 36) & 0x7F;\r
+ CodeTwo5c = RShiftU64 (*((UINT64 *)CalleeAddr + 3), 45) & 0x1F;\r
+ CodeTwo9d = RShiftU64 (*((UINT64 *)CalleeAddr + 3), 50) & 0x1FF;\r
\r
TargetEbcAddr = CodeTwo7b\r
- | LeftShiftU64 (CodeTwo9d, 7)\r
- | LeftShiftU64 (CodeTwo5c, 16)\r
- | LeftShiftU64 (CodeTwoIc, 21)\r
- | LeftShiftU64 (CodeOne18, 22)\r
- | LeftShiftU64 (CodeOne23, 40)\r
- | LeftShiftU64 (CodeTwoI, 63)\r
+ | LShiftU64 (CodeTwo9d, 7)\r
+ | LShiftU64 (CodeTwo5c, 16)\r
+ | LShiftU64 (CodeTwoIc, 21)\r
+ | LShiftU64 (CodeOne18, 22)\r
+ | LShiftU64 (CodeOne23, 40)\r
+ | LShiftU64 (CodeTwoI, 63)\r
;\r
\r
Action:\r
+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- Ipfmath.c\r
-\r
-Abstract:\r
-\r
- Math routines for IPF.\r
-\r
---*/\r
-\r
-UINT64\r
-LeftShiftU64 (\r
- IN UINT64 Operand,\r
- IN UINT64 Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Left-shift a 64 bit value.\r
-\r
-Arguments:\r
-\r
- Operand - 64-bit value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand << Count\r
-\r
---*/\r
-{\r
- if (Count > 63) {\r
- return 0;\r
- }\r
-\r
- return Operand << Count;\r
-}\r
-\r
-UINT64\r
-RightShiftU64 (\r
- IN UINT64 Operand,\r
- IN UINT64 Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Right-shift a 64 bit value.\r
-\r
-Arguments:\r
-\r
- Operand - 64-bit value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand >> Count\r
-\r
---*/\r
-{\r
- if (Count > 63) {\r
- return 0;\r
- }\r
-\r
- return Operand >> Count;\r
-}\r
-\r
-INT64\r
-ARightShift64 (\r
- IN INT64 Operand,\r
- IN UINT64 Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Right-shift a 64 bit signed value.\r
-\r
-Arguments:\r
-\r
- Operand - 64-bit value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand >> Count\r
-\r
---*/\r
-{\r
- if (Count > 63) {\r
-\r
- if (Operand & (0x01 << 63)) {\r
- return (INT64)~0;\r
- }\r
-\r
- return 0;\r
- }\r
-\r
- return Operand >> Count;\r
-}\r
-\r
-#if 0\r
-//\r
-// The compiler generates true assembly for these, so we don't need them.\r
-//\r
-INT32\r
-ARightShift32 (\r
- IN INT32 Operand,\r
- IN UINTN Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Right shift a 32-bit value\r
-\r
-Arguments:\r
-\r
- Operand - value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand >> Count\r
-\r
---*/\r
-{\r
- return Operand >> (Count & 0x1f);\r
-}\r
-\r
-INT32\r
-MulS32x32 (\r
- INT32 Value1,\r
- INT32 Value2,\r
- INT32 *ResultHigh\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Multiply two signed 32-bit numbers.\r
-\r
-Arguments:\r
-\r
- Value1 - first value to multiply\r
- Value2 - value to multiply Value1 by\r
- ResultHigh - overflow\r
-\r
-Returns:\r
-\r
- Value1 * Value2\r
-\r
-Notes:\r
-\r
- The 64-bit result is the concatenation of *ResultHigh and the return value\r
-\r
- The product fits in 32 bits if\r
- (*ResultHigh == 0x00000000 AND *ResultLow_bit31 == 0)\r
- OR\r
- (*ResultHigh == 0xffffffff AND *ResultLow_bit31 == 1)\r
-\r
---*/\r
-{\r
- INT64 Rres64;\r
- INT32 Result;\r
-\r
- Res64 = (INT64) Value1 * (INT64) Value2;\r
- *ResultHigh = (Res64 >> 32) & 0xffffffff;\r
- Result = Res64 & 0xffffffff;\r
- return Result;\r
-}\r
-\r
-UINT32\r
-MulU32x32 (\r
- UINT32 Value1,\r
- UINT32 Value2,\r
- UINT32 *ResultHigh\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Multiply two unsigned 32-bit values.\r
-\r
-Arguments:\r
-\r
- Value1 - first number\r
- Value2 - number to multiply by Value1 \r
- ResultHigh - overflow\r
-\r
-Returns:\r
-\r
- Value1 * Value2\r
-\r
-Notes:\r
-\r
- The 64-bit result is the concatenation of *ResultHigh and the return value.\r
- The product fits in 32 bits if *ResultHigh == 0x00000000\r
-\r
---*/\r
-{\r
- UINT64 Res64;\r
- UINT32 Result;\r
-\r
- Res64 = (INT64) Value1 * (INT64) Value2;\r
- *ResultHigh = (Res64 >> 32) & 0xffffffff;\r
- Result = Res64 & 0xffffffff;\r
- return Result;\r
-}\r
-\r
-INT32\r
-DivS32x32 (\r
- INT32 Value1,\r
- INT32 Value2,\r
- INT32 *Remainder,\r
- UINTN *error\r
- )\r
-//\r
-// signed 32-bit by signed 32-bit divide; the 32-bit remainder is\r
-// in *Remainder and the quotient is the return value; *error = 1 if the\r
-// divisor is 0, and it is 1 otherwise\r
-//\r
-{\r
- INT32 Result;\r
-\r
- *error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *error = 1;\r
- Result = 0x80000000;\r
- *Remainder = 0x80000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
-\r
-UINT32\r
-DivU32x32 (\r
- UINT32 Value1,\r
- UINT32 Value2,\r
- UINT32 *Remainder,\r
- UINTN *Error\r
- )\r
-//\r
-// unsigned 32-bit by unsigned 32-bit divide; the 32-bit remainder is\r
-// in *Remainder and the quotient is the return value; *error = 1 if the\r
-// divisor is 0, and it is 1 otherwise\r
-//\r
-{\r
- UINT32 Result;\r
-\r
- *Error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *Error = 1;\r
- Result = 0x80000000;\r
- *Remainder = 0x80000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
-\r
-#endif\r
-\r
-INT64\r
-DivS64x64 (\r
- INT64 Value1,\r
- INT64 Value2,\r
- INT64 *Remainder,\r
- UINTN *Error\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Divide two 64-bit signed values.\r
-\r
-Arguments:\r
-\r
- Value1 - dividend\r
- Value2 - divisor\r
- Remainder - remainder of Value1/Value2\r
- Error - to flag errors (divide-by-0)\r
-\r
-Returns:\r
-\r
- Value1 / Valu2\r
-\r
-Note:\r
-\r
- The 64-bit remainder is in *Remainder and the quotient is the return value.\r
- *Error = 1 if the divisor is 0, and it is 1 otherwise\r
-\r
---*/\r
-{\r
- INT64 Result;\r
-\r
- *Error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *Error = 1;\r
- Result = 0x8000000000000000;\r
- *Remainder = 0x8000000000000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
-\r
-UINT64\r
-DivU64x64 (\r
- UINT64 Value1,\r
- UINT64 Value2,\r
- UINT64 *Remainder,\r
- UINTN *Error\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Divide two 64-bit unsigned values.\r
-\r
-Arguments:\r
-\r
- Value1 - dividend\r
- Value2 - divisor\r
- Remainder - remainder of Value1/Value2\r
- Error - to flag errors (divide-by-0)\r
-\r
-Returns:\r
-\r
- Value1 / Valu2\r
-\r
-Note:\r
-\r
- The 64-bit remainder is in *Remainder and the quotient is the return value.\r
- *Error = 1 if the divisor is 0, and it is 1 otherwise\r
-\r
---*/\r
-{\r
- UINT64 Result;\r
-\r
- *Error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *Error = 1;\r
- Result = 0x8000000000000000;\r
- *Remainder = 0x8000000000000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
+++ /dev/null
-///*++\r
-//\r
-// Copyright (c) 2006, Intel Corporation \r
-// All rights reserved. This program and the accompanying materials \r
-// are licensed and made available under the terms and conditions of the BSD License \r
-// which accompanies this distribution. The full text of the license may be found at \r
-// http://opensource.org/licenses/bsd-license.php \r
-// \r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-// \r
-//Module Name: \r
-//\r
-// IpfMul.s\r
-// \r
-//Abstract:\r
-//\r
-// Low level routines for IPF multiply support\r
-// \r
-//--*/ \r
-\r
-.file "IpfMul.s"\r
-.section .text\r
-\r
- .proc MulS64x64#\r
- .align 32\r
- .globl MulS64x64#\r
- .align 32\r
-\r
-///*++\r
-//\r
-//Routine Description:\r
-//\r
-// Multiply two 64-bit signed numbers.\r
-//\r
-// \r
-//Arguments:\r
-//\r
-// INT64 \r
-// MulS64x64 (\r
-// IN INT64 Value1, \r
-// IN INT64 Value2, \r
-// OUT INT64 *ResultHigh);\r
-//\r
-//Returns:\r
-//\r
-// 64-bit signed result\r
-// \r
-//--*/\r
-\r
-MulS64x64:\r
- // signed 64x64->128-bit multiply\r
- // A in r32, B in r33, Q_hi stored in [r34], Q_lo returned in r8\r
-{ .mfi\r
- alloc r31=ar.pfs,3,0,0,0 // r32-r34\r
- nop.f 0\r
- nop.i 0;;\r
-}\r
-{.mmi\r
- setf.sig f6=r32\r
- setf.sig f7=r33\r
- nop.i 0;;\r
-}\r
-\r
-{.mfi\r
- nop.m 0\r
- xma.h f8=f6,f7,f0\r
- nop.i 0\r
-}\r
-{.mfi\r
- nop.m 0\r
- xma.l f6=f6,f7,f0\r
- nop.i 0;;\r
-}\r
-\r
-\r
-{.mmb\r
- stf8 [r34]=f8\r
- getf.sig r8=f6\r
- br.ret.sptk b0;;\r
-}\r
-\r
-.endp MulS64x64\r
-\r
- .proc MulU64x64#\r
- .align 32\r
- .globl MulU64x64#\r
- .align 32\r
-\r
-\r
-///*++\r
-//\r
-//Routine Description:\r
-//\r
-// Multiply two 64-bit unsigned numbers.\r
-//\r
-// \r
-//Arguments:\r
-//\r
-// UINT64 \r
-// MulU64x64 (\r
-// IN UINT64 Value1, \r
-// IN UINT64 Value2, \r
-// OUT UINT64 *ResultHigh);\r
-//\r
-//Returns:\r
-//\r
-// 64-bit unsigned result\r
-// \r
-//--*/\r
-MulU64x64:\r
- // A in r32, B in r33, Q_hi stored in [r34], Q_lo returned in r8\r
-{ .mfi\r
- alloc r31=ar.pfs,3,0,0,0 // r32-r34\r
- nop.f 0\r
- nop.i 0;;\r
-}\r
-{.mmi\r
- setf.sig f6=r32\r
- setf.sig f7=r33\r
- nop.i 0;;\r
-}\r
-\r
-{.mfi\r
- nop.m 0\r
- xma.hu f8=f6,f7,f0\r
- nop.i 0\r
-}\r
-{.mfi\r
- nop.m 0\r
- xma.l f6=f6,f7,f0\r
- nop.i 0;;\r
-}\r
-\r
-\r
-{.mmb\r
- stf8 [r34]=f8\r
- getf.sig r8=f6\r
- br.ret.sptk b0;;\r
-}\r
-\r
-.endp MulU64x64\r
-\r
-\r
+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation.\r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- x64math.c\r
-\r
-Abstract:\r
-\r
- Math routines for x64.\r
-\r
---*/\r
-\r
-UINT64\r
-LeftShiftU64 (\r
- IN UINT64 Operand,\r
- IN UINT64 Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Left-shift a 64 bit value.\r
-\r
-Arguments:\r
-\r
- Operand - 64-bit value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand << Count\r
-\r
---*/\r
-{\r
- if (Count > 63) {\r
- return 0;\r
- }\r
-\r
- return Operand << Count;\r
-}\r
-\r
-UINT64\r
-RightShiftU64 (\r
- IN UINT64 Operand,\r
- IN UINT64 Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Right-shift a 64 bit value.\r
-\r
-Arguments:\r
-\r
- Operand - 64-bit value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand >> Count\r
-\r
---*/\r
-{\r
- if (Count > 63) {\r
- return 0;\r
- }\r
-\r
- return Operand >> Count;\r
-}\r
-\r
-INT64\r
-ARightShift64 (\r
- IN INT64 Operand,\r
- IN UINT64 Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Right-shift a 64 bit signed value.\r
-\r
-Arguments:\r
-\r
- Operand - 64-bit value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand >> Count\r
-\r
---*/\r
-{\r
- if (Count > 63) {\r
-\r
- if (Operand & 0x8000000000000000ULL) {\r
- return (INT64)~0;\r
- }\r
-\r
- return 0;\r
- }\r
-\r
- return Operand >> Count;\r
-}\r
-\r
-#if 0\r
-//\r
-// The compiler generates true assembly for these, so we don't need them.\r
-//\r
-INT32\r
-ARightShift32 (\r
- IN INT32 Operand,\r
- IN UINTN Count\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Right shift a 32-bit value\r
-\r
-Arguments:\r
-\r
- Operand - value to shift\r
- Count - shift count\r
-\r
-Returns:\r
-\r
- Operand >> Count\r
-\r
---*/\r
-{\r
- return Operand >> (Count & 0x1f);\r
-}\r
-\r
-INT32\r
-MulS32x32 (\r
- INT32 Value1,\r
- INT32 Value2,\r
- INT32 *ResultHigh\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Multiply two signed 32-bit numbers.\r
-\r
-Arguments:\r
-\r
- Value1 - first value to multiply\r
- Value2 - value to multiply Value1 by\r
- ResultHigh - overflow\r
-\r
-Returns:\r
-\r
- Value1 * Value2\r
-\r
-Notes:\r
-\r
- The 64-bit result is the concatenation of *ResultHigh and the return value\r
-\r
- The product fits in 32 bits if\r
- (*ResultHigh == 0x00000000 AND *ResultLow_bit31 == 0)\r
- OR\r
- (*ResultHigh == 0xffffffff AND *ResultLow_bit31 == 1)\r
-\r
---*/\r
-{\r
- INT64 Rres64;\r
- INT32 Result;\r
-\r
- Res64 = (INT64) Value1 * (INT64) Value2;\r
- *ResultHigh = (Res64 >> 32) & 0xffffffff;\r
- Result = Res64 & 0xffffffff;\r
- return Result;\r
-}\r
-\r
-UINT32\r
-MulU32x32 (\r
- UINT32 Value1,\r
- UINT32 Value2,\r
- UINT32 *ResultHigh\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Multiply two unsigned 32-bit values.\r
-\r
-Arguments:\r
-\r
- Value1 - first number\r
- Value2 - number to multiply by Value1 \r
- ResultHigh - overflow\r
-\r
-Returns:\r
-\r
- Value1 * Value2\r
-\r
-Notes:\r
-\r
- The 64-bit result is the concatenation of *ResultHigh and the return value.\r
- The product fits in 32 bits if *ResultHigh == 0x00000000\r
-\r
---*/\r
-{\r
- UINT64 Res64;\r
- UINT32 Result;\r
-\r
- Res64 = (INT64) Value1 * (INT64) Value2;\r
- *ResultHigh = (Res64 >> 32) & 0xffffffff;\r
- Result = Res64 & 0xffffffff;\r
- return Result;\r
-}\r
-\r
-INT32\r
-DivS32x32 (\r
- INT32 Value1,\r
- INT32 Value2,\r
- INT32 *Remainder,\r
- UINTN *error\r
- )\r
-//\r
-// signed 32-bit by signed 32-bit divide; the 32-bit remainder is\r
-// in *Remainder and the quotient is the return value; *error = 1 if the\r
-// divisor is 0, and it is 1 otherwise\r
-//\r
-{\r
- INT32 Result;\r
-\r
- *error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *error = 1;\r
- Result = 0x80000000;\r
- *Remainder = 0x80000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
-\r
-UINT32\r
-DivU32x32 (\r
- UINT32 Value1,\r
- UINT32 Value2,\r
- UINT32 *Remainder,\r
- UINTN *Error\r
- )\r
-//\r
-// unsigned 32-bit by unsigned 32-bit divide; the 32-bit remainder is\r
-// in *Remainder and the quotient is the return value; *error = 1 if the\r
-// divisor is 0, and it is 1 otherwise\r
-//\r
-{\r
- UINT32 Result;\r
-\r
- *Error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *Error = 1;\r
- Result = 0x80000000;\r
- *Remainder = 0x80000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
-\r
-#endif\r
-\r
-INT64\r
-MulS64x64 (\r
- INT64 Value1,\r
- INT64 Value2,\r
- INT64 *ResultHigh\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Multiply two signed 32-bit numbers.\r
-\r
-Arguments:\r
-\r
- Value1 - first value to multiply\r
- Value2 - value to multiply Value1 by\r
- ResultHigh - overflow\r
-\r
-Returns:\r
-\r
- Value1 * Value2\r
-\r
-Notes:\r
-\r
- The 64-bit result is the concatenation of *ResultHigh and the return value\r
-\r
- The product fits in 32 bits if\r
- (*ResultHigh == 0x00000000 AND *ResultLow_bit31 == 0)\r
- OR\r
- (*ResultHigh == 0xffffffff AND *ResultLow_bit31 == 1)\r
-\r
---*/\r
-{\r
- INT64 Result;\r
- \r
- Result = Value1 * Value2;\r
-\r
- return Result;\r
-}\r
-\r
-UINT64\r
-MulU64x64 (\r
- UINT64 Value1,\r
- UINT64 Value2,\r
- UINT64 *ResultHigh\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Multiply two unsigned 32-bit values.\r
-\r
-Arguments:\r
-\r
- Value1 - first number\r
- Value2 - number to multiply by Value1 \r
- ResultHigh - overflow\r
-\r
-Returns:\r
-\r
- Value1 * Value2\r
-\r
-Notes:\r
-\r
- The 64-bit result is the concatenation of *ResultHigh and the return value.\r
- The product fits in 32 bits if *ResultHigh == 0x00000000\r
-\r
---*/\r
-{\r
- UINT64 Result;\r
-\r
- Result = Value1 * Value2;\r
-\r
- return Result;\r
-}\r
-\r
-INT64\r
-DivS64x64 (\r
- INT64 Value1,\r
- INT64 Value2,\r
- INT64 *Remainder,\r
- UINTN *Error\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Divide two 64-bit signed values.\r
-\r
-Arguments:\r
-\r
- Value1 - dividend\r
- Value2 - divisor\r
- Remainder - remainder of Value1/Value2\r
- Error - to flag errors (divide-by-0)\r
-\r
-Returns:\r
-\r
- Value1 / Valu2\r
-\r
-Note:\r
-\r
- The 64-bit remainder is in *Remainder and the quotient is the return value.\r
- *Error = 1 if the divisor is 0, and it is 1 otherwise\r
-\r
---*/\r
-{\r
- INT64 Result;\r
-\r
- *Error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *Error = 1;\r
- Result = 0x8000000000000000;\r
- *Remainder = 0x8000000000000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r
-\r
-UINT64\r
-DivU64x64 (\r
- UINT64 Value1,\r
- UINT64 Value2,\r
- UINT64 *Remainder,\r
- UINTN *Error\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Divide two 64-bit unsigned values.\r
-\r
-Arguments:\r
-\r
- Value1 - dividend\r
- Value2 - divisor\r
- Remainder - remainder of Value1/Value2\r
- Error - to flag errors (divide-by-0)\r
-\r
-Returns:\r
-\r
- Value1 / Valu2\r
-\r
-Note:\r
-\r
- The 64-bit remainder is in *Remainder and the quotient is the return value.\r
- *Error = 1 if the divisor is 0, and it is 1 otherwise\r
-\r
---*/\r
-{\r
- UINT64 Result;\r
-\r
- *Error = 0;\r
-\r
- if (Value2 == 0x0) {\r
- *Error = 1;\r
- Result = 0x8000000000000000;\r
- *Remainder = 0x8000000000000000;\r
- } else {\r
- Result = Value1 / Value2;\r
- *Remainder = Value1 - Result * Value2;\r
- }\r
-\r
- return Result;\r
-}\r