diff options
author | Bart Kuivenhoven <bemk@redhat.com> | 2013-10-08 11:26:24 +0200 |
---|---|---|
committer | Bart Kuivenhoven <bemk@redhat.com> | 2013-10-08 11:36:08 +0200 |
commit | c8ed17fd278ceff71b4069974f5f17e71058c8de (patch) | |
tree | 393e89b2837e3e69c698e084134b399fdb71e525 | |
parent | 8396d3b75b552a878a2cc57cc774bca06589773f (diff) | |
download | gnu-efi-3.0-c8ed17fd278ceff71b4069974f5f17e71058c8de.tar.gz gnu-efi-3.0-c8ed17fd278ceff71b4069974f5f17e71058c8de.tar.xz gnu-efi-3.0-c8ed17fd278ceff71b4069974f5f17e71058c8de.zip |
aarch64: math: Port over math functions
Signed-off-by: Bart Kuivenhoven <bemk@redhat.com>
-rw-r--r-- | gnu-efi-3.0/lib/aarch64/math.c | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/gnu-efi-3.0/lib/aarch64/math.c b/gnu-efi-3.0/lib/aarch64/math.c index ffe24e2..52cd9e7 100644 --- a/gnu-efi-3.0/lib/aarch64/math.c +++ b/gnu-efi-3.0/lib/aarch64/math.c @@ -1,5 +1,55 @@ -/* A stub to keep the compiler happy! */ - /* - * TODO: Port this file + * (c) Bart Kuivenhoven <bemk@redhat.com> - Red Hat - 2013 */ +#ifndef __GNUC__ +#error "This file has not been ported for anything but GCC" +#endif + +#include "lib.h" + +UINT64 +LShiftU64 ( + UINT64 operand, + UINTN count + ) +{ + return operand << count; +} + +UINT64 +RShiftU64 ( + UINT64 operand, + UINTN count + ) +{ + return operand >> count; +} + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +// Multiple 64bit by 32bit and get a 64bit result +{ + return Multiplicand * Multiplier; +} + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +// divide 64bit by 32bit and get a 64bit result +// N.B. only works for 31bit divisors!! +{ + /* + * This assert isn't in the other architectures either, but I think it + * will prove itself useful some time. + */ + ASSERT(Divisor != 0) + if (Remainder) + *Remainder = Dividend % Divisor; + return Dividend / Divisor; +} |