]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
4ea9375a HT |
3 | Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 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 x64\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Efi.h"\r | |
23 | #include "Pei.h"\r | |
24 | #include "PeiLib.h"\r | |
25 | \r | |
26 | \r | |
27 | UINT64\r | |
28 | LShiftU64 (\r | |
29 | IN UINT64 Operand,\r | |
30 | IN UINTN Count\r | |
31 | )\r | |
32 | /*++\r | |
33 | \r | |
34 | Routine Description:\r | |
35 | \r | |
36 | This routine allows a 64 bit value to be left shifted by 32 bits and returns the \r | |
37 | shifted value.\r | |
38 | Count is valid up 63. (Only Bits 0-5 is valid for Count)\r | |
39 | \r | |
40 | Arguments:\r | |
41 | \r | |
42 | Operand - Value to be shifted\r | |
43 | \r | |
44 | Count - Number of times to shift left.\r | |
45 | \r | |
46 | Returns:\r | |
47 | \r | |
48 | Value shifted left identified by the Count.\r | |
49 | \r | |
50 | --*/\r | |
51 | {\r | |
52 | return Operand << Count;\r | |
53 | }\r | |
54 | \r | |
55 | \r | |
56 | UINT64\r | |
57 | MultU64x32 (\r | |
58 | IN UINT64 Multiplicand,\r | |
59 | IN UINTN Multiplier\r | |
60 | )\r | |
61 | /*++\r | |
62 | \r | |
63 | Routine Description:\r | |
64 | \r | |
65 | This routine allows a 64 bit value to be multiplied with a 32 bit value returns \r | |
66 | 64bit result.\r | |
67 | No checking if the result is greater than 64bits\r | |
68 | \r | |
69 | Arguments:\r | |
70 | \r | |
71 | Multiplicand - \r | |
72 | \r | |
73 | Multiplier - \r | |
74 | \r | |
75 | Returns:\r | |
76 | \r | |
77 | Multiplicand * Multiplier\r | |
78 | \r | |
79 | --*/\r | |
80 | {\r | |
81 | return Multiplicand * Multiplier;\r | |
82 | }\r | |
3eb9473e | 83 | \r |
84 | UINT64\r | |
85 | DivU64x32 (\r | |
86 | IN UINT64 Dividend,\r | |
87 | IN UINTN Divisor,\r | |
88 | OUT UINTN *Remainder OPTIONAL\r | |
89 | )\r | |
90 | /*++\r | |
91 | \r | |
92 | Routine Description:\r | |
93 | \r | |
94 | This routine allows a 64 bit value to be divided with a 32 bit value returns \r | |
95 | 64bit result and the Remainder.\r | |
96 | \r | |
97 | Arguments:\r | |
98 | \r | |
99 | Dividend - \r | |
100 | \r | |
101 | Divisor - \r | |
102 | \r | |
103 | Remainder -\r | |
104 | \r | |
105 | Returns:\r | |
106 | \r | |
107 | Dividend / Divisor\r | |
108 | Remainder = Dividend mod Divisor\r | |
109 | \r | |
110 | N.B. only works for 31bit divisors!!\r | |
111 | \r | |
112 | --*/\r | |
113 | {\r | |
114 | return Dividend/Divisor;\r | |
115 | }\r | |
116 | \r |