gnu-efi/lib/riscv64/math.c
Heinrich Schuchardt b95f138fa1 Initial support for RISCV64
Add the RISCV64 architecture

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-01 17:17:33 +02:00

63 lines
859 B
C

// SPDX-License-Identifier: BSD-2-Clause-Patent
/*
* This code is based on EDK II MdePkg/Library/BaseLib/Math64.c
* Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
*/
#include "lib.h"
/**
* LShiftU64() - left shift
*/
UINT64
LShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
return Operand << Count;
}
/**
* RShiftU64() - right shift
*/
UINT64
RShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
return Operand >> Count;
}
/**
* MultU64x32() - multiply
*/
UINT64
MultU64x32 (
IN UINT64 Multiplicand,
IN UINTN Multiplier
)
{
return Multiplicand * Multiplier;
}
/**
* DivU64x32() - divide
*/
UINT64
DivU64x32 (
IN UINT64 Dividend,
IN UINTN Divisor,
OUT UINTN *Remainder OPTIONAL
)
{
ASSERT(Divisor != 0);
if (Remainder) {
*Remainder = Dividend % Divisor;
}
return Dividend / Divisor;
}