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