]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/TianoTools/Common/PeiLib/Ipf/math.c
Add <FrameworkModules> in EdkModulePkg-All-Archs.fpd and MdePkg-All-Archs.fpd file...
[mirror_edk2.git] / Tools / Source / TianoTools / Common / PeiLib / Ipf / math.c
1 /*++
2
3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 math.c
15
16 Abstract:
17
18 64-bit Math worker functions for Intel Itanium(TM) processors.
19
20 --*/
21
22 #include "Tiano.h"
23 #include "Pei.h"
24 #include "PeiLib.h"
25
26 UINT64
27 LShiftU64 (
28 IN UINT64 Operand,
29 IN UINTN Count
30 )
31 /*++
32
33 Routine Description:
34
35 This routine allows a 64 bit value to be left shifted by 32 bits and
36 returns the shifted value.
37 Count is valid up 63. (Only Bits 0-5 is valid for Count)
38
39 Arguments:
40
41 Operand - Value to be shifted
42 Count - Number of times to shift left.
43
44 Returns:
45
46 Value shifted left identified by the Count.
47
48 --*/
49 {
50 return Operand << Count;
51 }
52
53 UINT64
54 RShiftU64 (
55 IN UINT64 Operand,
56 IN UINTN Count
57 )
58 /*++
59
60 Routine Description:
61
62 This routine allows a 64 bit value to be right shifted by 32 bits and returns the
63 shifted value.
64 Count is valid up 63. (Only Bits 0-5 is valid for Count)
65
66 Arguments:
67
68 Operand - Value to be shifted
69 Count - Number of times to shift right.
70
71 Returns:
72
73 Value shifted right identified by the Count.
74
75 --*/
76 {
77 return Operand >> Count;
78 }
79
80 UINT64
81 MultU64x32 (
82 IN UINT64 Multiplicand,
83 IN UINTN Multiplier
84 )
85 /*++
86
87 Routine Description:
88
89 This routine allows a 64 bit value to be multiplied with a 32 bit
90 value returns 64bit result.
91 No checking if the result is greater than 64bits
92
93 Arguments:
94
95 Multiplicand - multiplicand
96 Multiplier - multiplier
97
98 Returns:
99
100 Multiplicand * Multiplier
101
102 --*/
103 {
104 return Multiplicand * Multiplier;
105 }
106
107 UINT64
108 DivU64x32 (
109 IN UINT64 Dividend,
110 IN UINTN Divisor,
111 OUT UINTN *Remainder OPTIONAL
112 )
113 /*++
114
115 Routine Description:
116
117 This routine allows a 64 bit value to be divided with a 32 bit value returns
118 64bit result and the Remainder.
119 N.B. only works for 31bit divisors!!
120
121 Arguments:
122
123 Dividend - dividend
124 Divisor - divisor
125 Remainder - buffer for remainder
126
127 Returns:
128
129 Dividend / Divisor
130 Remainder = Dividend mod Divisor
131
132 --*/
133 {
134 if (Remainder) {
135 *Remainder = Dividend % Divisor;
136 }
137
138 return Dividend / Divisor;
139 }