]>
Commit | Line | Data |
---|---|---|
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 | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php.\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "BaseLibInternals.h"\r | |
17 | \r | |
18 | /**\r | |
19 | Generates a 16-bit random number through RDRAND instruction.\r | |
20 | \r | |
21 | if Rand is NULL, then ASSERT().\r | |
22 | \r | |
23 | @param[out] Rand Buffer pointer to store the random result.\r | |
24 | \r | |
25 | @retval TRUE RDRAND call was successful.\r | |
26 | @retval FALSE Failed attempts to call RDRAND.\r | |
27 | \r | |
28 | **/\r | |
29 | BOOLEAN\r | |
30 | EFIAPI\r | |
31 | AsmRdRand16 (\r | |
32 | OUT UINT16 *Rand\r | |
33 | )\r | |
34 | {\r | |
35 | ASSERT (Rand != NULL);\r | |
36 | return InternalX86RdRand16 (Rand);\r | |
37 | }\r | |
38 | \r | |
39 | /**\r | |
40 | Generates a 32-bit random number through RDRAND instruction.\r | |
41 | \r | |
42 | if Rand is NULL, then ASSERT().\r | |
43 | \r | |
44 | @param[out] Rand Buffer pointer to store the random result.\r | |
45 | \r | |
46 | @retval TRUE RDRAND call was successful.\r | |
47 | @retval FALSE Failed attempts to call RDRAND.\r | |
48 | \r | |
49 | **/\r | |
50 | BOOLEAN\r | |
51 | EFIAPI\r | |
52 | AsmRdRand32 (\r | |
53 | OUT UINT32 *Rand\r | |
54 | )\r | |
55 | {\r | |
56 | ASSERT (Rand != NULL);\r | |
57 | return InternalX86RdRand32 (Rand);\r | |
58 | }\r | |
59 | \r | |
60 | /**\r | |
61 | Generates a 64-bit random number through RDRAND instruction.\r | |
62 | \r | |
63 | if Rand is NULL, then ASSERT().\r | |
64 | \r | |
65 | @param[out] Rand Buffer pointer to store the random result.\r | |
66 | \r | |
67 | @retval TRUE RDRAND call was successful.\r | |
68 | @retval FALSE Failed attempts to call RDRAND.\r | |
69 | \r | |
70 | **/\r | |
71 | BOOLEAN\r | |
72 | EFIAPI\r | |
73 | AsmRdRand64 (\r | |
74 | OUT UINT64 *Rand\r | |
75 | )\r | |
76 | {\r | |
77 | ASSERT (Rand != NULL);\r | |
78 | return InternalX86RdRand64 (Rand);\r | |
79 | }\r |