summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/Math64.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-19 17:37:07 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-19 17:37:07 +0000
commit1ea5ca46c7eefe66a01cb4db3b72fc0e5a04e2cb (patch)
tree11db61e6d73e5a6b0bca974e7e4a8e29f1344a49 /MdePkg/Library/BaseLib/Math64.c
parentebfe209ec07c4105baba33576457a4bd6c798a2b (diff)
downloadedk2-platforms-1ea5ca46c7eefe66a01cb4db3b72fc0e5a04e2cb.tar.xz
1. added functions header for BaseUefiDecompressLi
2. added some internal functions header for BaseLib 3. added EFIAPI for some internal assembly files declare git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1050 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BaseLib/Math64.c')
-rw-r--r--MdePkg/Library/BaseLib/Math64.c201
1 files changed, 193 insertions, 8 deletions
diff --git a/MdePkg/Library/BaseLib/Math64.c b/MdePkg/Library/BaseLib/Math64.c
index 57dcca387f..a8756967be 100644
--- a/MdePkg/Library/BaseLib/Math64.c
+++ b/MdePkg/Library/BaseLib/Math64.c
@@ -15,8 +15,20 @@
**/
+/**
+ Worker functons that shifts a 64-bit integer left between 0 and 63 bits. The low bits
+ are filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the left by Count bits. The
+ low Count bits are set to zero. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift left.
+ @param Count The number of bits to shift left.
+
+ @return Operand << Count
+
+**/
UINT64
-EFIAPI
InternalMathLShiftU64 (
IN UINT64 Operand,
IN UINTN Count
@@ -25,6 +37,19 @@ InternalMathLShiftU64 (
return Operand << Count;
}
+/**
+ Worker functon that shifts a 64-bit integer right between 0 and 63 bits. This high bits
+ are filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to zero. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand >> Count
+
+**/
UINT64
EFIAPI
InternalMathRShiftU64 (
@@ -35,6 +60,21 @@ InternalMathRShiftU64 (
return Operand >> Count;
}
+/**
+ Worker function that shifts a 64-bit integer right between 0 and 63 bits. The high bits
+ are filled with original integer's bit 63. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to bit 63 of Operand. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand arithmetically shifted right by Count
+
+**/
UINT64
EFIAPI
InternalMathARShiftU64 (
@@ -59,6 +99,21 @@ InternalMathARShiftU64 (
((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0);
}
+
+/**
+ Worker function that rotates a 64-bit integer left between 0 and 63 bits, filling
+ the low bits with the high bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ @param Operand The 64-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
UINT64
EFIAPI
InternalMathLRotU64 (
@@ -69,6 +124,20 @@ InternalMathLRotU64 (
return (Operand << Count) | (Operand >> (64 - Count));
}
+/**
+ Worker function that rotates a 64-bit integer right between 0 and 63 bits, filling
+ the high bits with the high low bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ @param Operand The 64-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
UINT64
EFIAPI
InternalMathRRotU64 (
@@ -79,6 +148,18 @@ InternalMathRRotU64 (
return (Operand >> Count) | (Operand << (64 - Count));
}
+/**
+ Worker function that switches the endianess of a 64-bit integer.
+
+ This function swaps the bytes in a 64-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 64-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
UINT64
EFIAPI
InternalMathSwapBytes64 (
@@ -91,6 +172,20 @@ InternalMathSwapBytes64 (
);
}
+/**
+ Worker function that multiples a 64-bit unsigned integer by a 32-bit unsigned integer
+ and generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 32-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
UINT64
EFIAPI
InternalMathMultU64x32 (
@@ -101,6 +196,21 @@ InternalMathMultU64x32 (
return Multiplicand * Multiplier;
}
+
+/**
+ Worker function that multiples a 64-bit unsigned integer by a 64-bit unsigned integer
+ and generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 64-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
UINT64
EFIAPI
InternalMathMultU64x64 (
@@ -111,6 +221,20 @@ InternalMathMultU64x64 (
return Multiplicand * Multiplier;
}
+/**
+ Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. This
+ function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend / Divisor
+
+**/
UINT64
EFIAPI
InternalMathDivU64x32 (
@@ -121,8 +245,21 @@ InternalMathDivU64x32 (
return Dividend / Divisor;
}
+/**
+ Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer
+ and generates a 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 32-bit remainder. This function
+ returns the 32-bit unsigned remainder.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend % Divisor
+
+**/
UINT32
-EFIAPI
InternalMathModU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
@@ -131,12 +268,28 @@ InternalMathModU64x32 (
return (UINT32)(Dividend % Divisor);
}
+/**
+ Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+ @param Remainder A pointer to a 32-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
UINT64
-EFIAPI
InternalMathDivRemU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor,
- OUT UINT32 *Remainder
+ OUT UINT32 *Remainder OPTIONAL
)
{
if (Remainder != NULL) {
@@ -145,12 +298,28 @@ InternalMathDivRemU64x32 (
return Dividend / Divisor;
}
+/**
+ Worker function that divides a 64-bit unsigned integer by a 64-bit unsigned integer and
+ generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 64-bit unsigned value.
+ @param Remainder A pointer to a 64-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
UINT64
-EFIAPI
InternalMathDivRemU64x64 (
IN UINT64 Dividend,
IN UINT64 Divisor,
- OUT UINT64 *Remainder
+ OUT UINT64 *Remainder OPTIONAL
)
{
if (Remainder != NULL) {
@@ -159,12 +328,28 @@ InternalMathDivRemU64x64 (
return Dividend / Divisor;
}
+/**
+ Worker function that divides a 64-bit signed integer by a 64-bit signed integer and
+ generates a 64-bit signed result and a optional 64-bit signed remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit signed value.
+ @param Divisor A 64-bit signed value.
+ @param Remainder A pointer to a 64-bit signed value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
INT64
-EFIAPI
InternalMathDivRemS64x64 (
IN INT64 Dividend,
IN INT64 Divisor,
- OUT INT64 *Remainder
+ OUT INT64 *Remainder OPTIONAL
)
{
if (Remainder != NULL) {