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