MdePkg/BaseRngLib: Add support for ARMv8.5 RNG instructions
Make BaseRngLib more generic by moving x86-specific functionality into 'Rand' and adding files under 'AArch64' to support the optional ARMv8.5 RNG instruction RNDR that is a part of FEAT_RNG. Signed-off-by: Rebecca Cran <rebecca@nuviainc.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
committed by
mergify[bot]
parent
ef3840c1ff
commit
9301e5644c
78
MdePkg/Library/BaseRngLib/BaseRngLibInternals.h
Normal file
78
MdePkg/Library/BaseRngLib/BaseRngLibInternals.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/** @file
|
||||
|
||||
Architecture specific interface to RNG functionality.
|
||||
|
||||
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef BASE_RNGLIB_INTERNALS_H_
|
||||
|
||||
/**
|
||||
Generates a 16-bit random number.
|
||||
|
||||
@param[out] Rand Buffer pointer to store the 16-bit random value.
|
||||
|
||||
@retval TRUE Random number generated successfully.
|
||||
@retval FALSE Failed to generate the random number.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ArchGetRandomNumber16 (
|
||||
OUT UINT16 *Rand
|
||||
);
|
||||
|
||||
/**
|
||||
Generates a 32-bit random number.
|
||||
|
||||
@param[out] Rand Buffer pointer to store the 32-bit random value.
|
||||
|
||||
@retval TRUE Random number generated successfully.
|
||||
@retval FALSE Failed to generate the random number.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ArchGetRandomNumber32 (
|
||||
OUT UINT32 *Rand
|
||||
);
|
||||
|
||||
/**
|
||||
Generates a 64-bit random number.
|
||||
|
||||
@param[out] Rand Buffer pointer to store the 64-bit random value.
|
||||
|
||||
@retval TRUE Random number generated successfully.
|
||||
@retval FALSE Failed to generate the random number.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ArchGetRandomNumber64 (
|
||||
OUT UINT64 *Rand
|
||||
);
|
||||
|
||||
/**
|
||||
Checks whether the RNG instruction is supported.
|
||||
|
||||
@retval TRUE RNG instruction is supported.
|
||||
@retval FALSE RNG instruction is not supported.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
ArchIsRngSupported (
|
||||
VOID
|
||||
);
|
||||
|
||||
#if defined (MDE_CPU_AARCH64)
|
||||
|
||||
// RNDR, Random Number
|
||||
#define RNDR S3_3_C2_C4_0
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BASE_RNGLIB_INTERNALS_H_
|
Reference in New Issue
Block a user