]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/Math.c
Renamed to match filename naming recommendations.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Pei / PeiLib / Ipf / Math.c
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/Math.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Ipf/Math.c
new file mode 100644 (file)
index 0000000..860d129
--- /dev/null
@@ -0,0 +1,139 @@
+/*++\r
+\r
+Copyright (c) 2004, 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
+  math.c\r
+\r
+Abstract:\r
+\r
+  64-bit Math worker functions for Intel Itanium(TM) processors.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "Pei.h"\r
+#include "PeiLib.h"\r
+\r
+UINT64\r
+LShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be left shifted by 32 bits and \r
+  returns the shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift left.\r
\r
+Returns:\r
+\r
+  Value shifted left identified by the Count.\r
+\r
+--*/\r
+{\r
+  return Operand << Count;\r
+}\r
+\r
+UINT64\r
+RShiftU64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Count\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be right shifted by 32 bits and returns the \r
+  shifted value.\r
+  Count is valid up 63. (Only Bits 0-5 is valid for Count)\r
+\r
+Arguments:\r
+\r
+  Operand - Value to be shifted\r
+  Count   - Number of times to shift right.\r
\r
+Returns:\r
+\r
+  Value shifted right identified by the Count.\r
+\r
+--*/\r
+{\r
+  return Operand >> Count;\r
+}\r
+\r
+UINT64\r
+MultU64x32 (\r
+  IN UINT64   Multiplicand,\r
+  IN UINTN    Multiplier\r
+  )\r
+/*++  \r
+  \r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be multiplied with a 32 bit \r
+  value returns 64bit result.\r
+  No checking if the result is greater than 64bits\r
+\r
+Arguments:\r
+\r
+  Multiplicand  - multiplicand\r
+  Multiplier    - multiplier\r
+\r
+Returns:\r
+\r
+  Multiplicand * Multiplier\r
+  \r
+--*/\r
+{\r
+  return Multiplicand * Multiplier;\r
+}\r
+\r
+UINT64\r
+DivU64x32 (\r
+  IN UINT64   Dividend,\r
+  IN UINTN    Divisor,\r
+  OUT UINTN   *Remainder OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This routine allows a 64 bit value to be divided with a 32 bit value returns \r
+  64bit result and the Remainder.\r
+  N.B. only works for 31bit divisors!!\r
+\r
+Arguments:\r
+\r
+  Dividend  - dividend\r
+  Divisor   - divisor\r
+  Remainder - buffer for remainder\r
\r
+Returns:\r
+\r
+  Dividend  / Divisor\r
+  Remainder = Dividend mod Divisor\r
+\r
+--*/\r
+{\r
+  if (Remainder) {\r
+    *Remainder = Dividend % Divisor;\r
+  }\r
+\r
+  return Dividend / Divisor;\r
+}\r