88e3cf9535
Subject: [PATCH 1/2] Relicense ARM and AARCH64 source files as both BSD and GPL This updates the licenses of the files authored by me under lib/arm and lib/aarch64 to be both 2-clause BSD and GPL v2+ Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>
64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
/*
|
|
* Copright (C) 2014 Linaro Ltd.
|
|
* Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice and this list of conditions, without modification.
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
* derived from this software without specific prior written permission.
|
|
*
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
* GNU General Public License as published by the Free Software Foundation;
|
|
* either version 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include "lib.h"
|
|
|
|
UINT64
|
|
LShiftU64 (
|
|
IN UINT64 Operand,
|
|
IN UINTN Count
|
|
)
|
|
// Left shift 64bit by 32bit and get a 64bit result
|
|
{
|
|
return Operand << Count;
|
|
}
|
|
|
|
UINT64
|
|
RShiftU64 (
|
|
IN UINT64 Operand,
|
|
IN UINTN Count
|
|
)
|
|
// Right shift 64bit by 32bit and get a 64bit result
|
|
{
|
|
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!!
|
|
{
|
|
if (Remainder)
|
|
*Remainder = Dividend % Divisor;
|
|
return Dividend / Divisor;
|
|
}
|