19 currentSeed ^= currentSeed << 13;
20 currentSeed ^= currentSeed >> 7;
21 currentSeed ^= currentSeed << 17;
49 LOG_WARN(
"cpu%d rdrand instruction failed, disabling\n",
SELF->id);
56 LOG_WARN(
"cpu%d rdrand producing same value repeatedly, disabling\n",
SELF->id);
68 if (!pcpu_rand->rdrandAvail)
75 while (remaining >=
sizeof(
uint32_t))
94 memcpy(ptr, &value, remaining);
EFI_PHYSICAL_ADDRESS buffer
#define CLI_SCOPE()
Macro to increment CLI depth for the duration of the current scope.
#define SELF_PTR(ptr)
Macro to get a pointer to a percpu variable on the current CPU.
#define SELF
Macro to access data in the current cpu.
#define PERCPU_DEFINE_CTOR(type, name)
Macro to define a percpu variable with a constructor.
uint64_t rdrand_do(uint32_t *value, uint8_t retries)
Generates a random 32-bit unsigned integer using the RDRAND instruction.
uint64_t rand_gen(void *buffer, uint64_t size)
Fills a buffer with random bytes.
#define LOG_WARN(format,...)
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
static void cpuid_feature_info(cpuid_feature_info_t *info)
Wrapper to get CPU feature information.
#define ERR
Integer error value.
static uint64_t rand_gen_fallback(void *buffer, uint64_t size)
static atomic_uint64_t seed
#define atomic_store(object, desired)
#define atomic_load(object)
#define ATOMIC_VAR_INIT(value)
_PUBLIC void * memcpy(void *_RESTRICT s1, const void *_RESTRICT s2, size_t n)
CPU feature information structure.
cpuid_ecx_features_t featuresEcx
CPU random number generator context.
bool rdrandAvail
If set, the RDRAND instruction is available and working.