]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/X86RdRand.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86RdRand.c
CommitLineData
9ec9a7a5
QL
1/** @file\r
2 IA-32/x64 AsmRdRandxx()\r
3 Generates random number through CPU RdRand instruction.\r
4\r
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
9344f092 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
9ec9a7a5
QL
7\r
8**/\r
9\r
10#include "BaseLibInternals.h"\r
11\r
12/**\r
13 Generates a 16-bit random number through RDRAND instruction.\r
14\r
15 if Rand is NULL, then ASSERT().\r
16\r
17 @param[out] Rand Buffer pointer to store the random result.\r
18\r
19 @retval TRUE RDRAND call was successful.\r
20 @retval FALSE Failed attempts to call RDRAND.\r
21\r
22 **/\r
23BOOLEAN\r
24EFIAPI\r
25AsmRdRand16 (\r
2f88bd3a 26 OUT UINT16 *Rand\r
9ec9a7a5
QL
27 )\r
28{\r
29 ASSERT (Rand != NULL);\r
30 return InternalX86RdRand16 (Rand);\r
31}\r
32\r
33/**\r
34 Generates a 32-bit random number through RDRAND instruction.\r
35\r
36 if Rand is NULL, then ASSERT().\r
37\r
38 @param[out] Rand Buffer pointer to store the random result.\r
39\r
40 @retval TRUE RDRAND call was successful.\r
41 @retval FALSE Failed attempts to call RDRAND.\r
42\r
43**/\r
44BOOLEAN\r
45EFIAPI\r
46AsmRdRand32 (\r
2f88bd3a 47 OUT UINT32 *Rand\r
9ec9a7a5
QL
48 )\r
49{\r
50 ASSERT (Rand != NULL);\r
51 return InternalX86RdRand32 (Rand);\r
52}\r
53\r
54/**\r
55 Generates a 64-bit random number through RDRAND instruction.\r
56\r
57 if Rand is NULL, then ASSERT().\r
58\r
59 @param[out] Rand Buffer pointer to store the random result.\r
60\r
61 @retval TRUE RDRAND call was successful.\r
62 @retval FALSE Failed attempts to call RDRAND.\r
63\r
64**/\r
65BOOLEAN\r
66EFIAPI\r
67AsmRdRand64 (\r
2f88bd3a 68 OUT UINT64 *Rand\r
9ec9a7a5
QL
69 )\r
70{\r
71 ASSERT (Rand != NULL);\r
72 return InternalX86RdRand64 (Rand);\r
73}\r