diff options
author | Qin Long <qin.long@intel.com> | 2015-11-16 06:38:00 +0000 |
---|---|---|
committer | vanjeff <vanjeff@Edk2> | 2015-11-16 06:38:00 +0000 |
commit | 01c307eacd05fc15cfc1d2d0444867f7f9e9da82 (patch) | |
tree | 2116f5cd0439d461a7ad2d60ccafb603a49ef577 /MdePkg/Include | |
parent | af7fca3649779f0e55220a7acda9bd11bc660fc3 (diff) | |
download | edk2-platforms-01c307eacd05fc15cfc1d2d0444867f7f9e9da82.tar.xz |
MdePkg: Add CPU RdRand access APIs for random number generation
Add AsmRdRand16/32/64 APIs for RdRand instruction access to generate
high-quality random number.
(Sync patch r18518 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@18785 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Include')
-rw-r--r-- | MdePkg/Include/Library/BaseLib.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h index 7e10804082..c41fa783df 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -7647,6 +7647,57 @@ AsmPrepareAndThunk16 ( IN OUT THUNK_CONTEXT *ThunkContext
);
+/**
+ Generates a 16-bit random number through RDRAND instruction.
+
+ if Rand is NULL, then ASSERT().
+
+ @param[out] Rand Buffer pointer to store the random result.
+
+ @retval TRUE RDRAND call was successful.
+ @retval FALSE Failed attempts to call RDRAND.
+
+ **/
+BOOLEAN
+EFIAPI
+AsmRdRand16 (
+ OUT UINT16 *Rand
+ );
+
+/**
+ Generates a 32-bit random number through RDRAND instruction.
+
+ if Rand is NULL, then ASSERT().
+
+ @param[out] Rand Buffer pointer to store the random result.
+
+ @retval TRUE RDRAND call was successful.
+ @retval FALSE Failed attempts to call RDRAND.
+
+**/
+BOOLEAN
+EFIAPI
+AsmRdRand32 (
+ OUT UINT32 *Rand
+ );
+
+/**
+ Generates a 64-bit random number through RDRAND instruction.
+
+ if Rand is NULL, then ASSERT().
+
+ @param[out] Rand Buffer pointer to store the random result.
+
+ @retval TRUE RDRAND call was successful.
+ @retval FALSE Failed attempts to call RDRAND.
+
+**/
+BOOLEAN
+EFIAPI
+AsmRdRand64 (
+ OUT UINT64 *Rand
+ );
+
#endif
#endif
|