1 // SPDX-License-Identifier: BSD-2-Clause-Patent 2 /* 3 * This code is based on EDK II MdePkg/Library/BaseLib/Math64.c 4 * Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. 5 */ 6 7 #include "lib.h" 8 9 /** 10 * LShiftU64() - left shift 11 */ 12 UINT64 13 LShiftU64 ( 14 IN UINT64 Operand, 15 IN UINTN Count 16 ) 17 { 18 return Operand << Count; 19 } 20 21 /** 22 * RShiftU64() - right shift 23 */ 24 UINT64 25 RShiftU64 ( 26 IN UINT64 Operand, 27 IN UINTN Count 28 ) 29 { 30 return Operand >> Count; 31 } 32 33 /** 34 * MultU64x32() - multiply 35 */ 36 UINT64 37 MultU64x32 ( 38 IN UINT64 Multiplicand, 39 IN UINTN Multiplier 40 ) 41 { 42 return Multiplicand * Multiplier; 43 } 44 45 /** 46 * DivU64x32() - divide 47 */ 48 UINT64 49 DivU64x32 ( 50 IN UINT64 Dividend, 51 IN UINTN Divisor, 52 OUT UINTN *Remainder OPTIONAL 53 ) 54 { 55 ASSERT(Divisor != 0); 56 57 if (Remainder) { 58 *Remainder = Dividend % Divisor; 59 } 60 61 return Dividend / Divisor; 62 } 63