Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/random/ivy.c
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | __asm __volatile( | ||||
"dec %0\n\t" /* otherwise, retry-- */ | "dec %0\n\t" /* otherwise, retry-- */ | ||||
"jne 1b\n\t" /* and loop if retries are not exhausted */ | "jne 1b\n\t" /* and loop if retries are not exhausted */ | ||||
"2:" | "2:" | ||||
: "+r" (retry), "=r" (rndval) : : "cc"); | : "+r" (retry), "=r" (rndval) : : "cc"); | ||||
*buf = rndval; | *buf = rndval; | ||||
return (retry); | return (retry); | ||||
} | } | ||||
static int | |||||
x86_unimpl_store(u_long *buf __unused) | |||||
{ | |||||
panic("%s called", __func__); | |||||
} | |||||
DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf), static) | DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf), static) | ||||
{ | { | ||||
has_rdrand = (cpu_feature2 & CPUID2_RDRAND); | has_rdrand = (cpu_feature2 & CPUID2_RDRAND); | ||||
has_rdseed = (cpu_stdext_feature & CPUID_STDEXT_RDSEED); | has_rdseed = (cpu_stdext_feature & CPUID_STDEXT_RDSEED); | ||||
if (has_rdseed) | if (has_rdseed) | ||||
return (x86_rdseed_store); | return (x86_rdseed_store); | ||||
else if (has_rdrand) | else if (has_rdrand) | ||||
return (x86_rdrand_store); | return (x86_rdrand_store); | ||||
else | else | ||||
return (NULL); | return (x86_unimpl_store); | ||||
} | } | ||||
/* It is required that buf length is a multiple of sizeof(u_long). */ | /* It is required that buf length is a multiple of sizeof(u_long). */ | ||||
static u_int | static u_int | ||||
random_ivy_read(void *buf, u_int c) | random_ivy_read(void *buf, u_int c) | ||||
{ | { | ||||
u_long *b, rndval; | u_long *b, rndval; | ||||
u_int count; | u_int count; | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |