Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/random/randomdev.c
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | while (!p_random_alg_context->ra_seeded()) { | ||||
p_random_alg_context->ra_pre_read(); | p_random_alg_context->ra_pre_read(); | ||||
/* Only bother the console every 10 seconds or so */ | /* Only bother the console every 10 seconds or so */ | ||||
if (spamcount == 0) | if (spamcount == 0) | ||||
printf("random: %s unblock wait\n", __func__); | printf("random: %s unblock wait\n", __func__); | ||||
spamcount = (spamcount + 1)%100; | spamcount = (spamcount + 1)%100; | ||||
error = tsleep(&random_alg_context, PCATCH, "randseed", hz/10); | error = tsleep(&random_alg_context, PCATCH, "randseed", hz/10); | ||||
if (error == ERESTART || error == EINTR) | if (error == ERESTART || error == EINTR) | ||||
break; | break; | ||||
/* Squash tsleep timeout condition */ | |||||
if (error == EWOULDBLOCK) | |||||
error = 0; | |||||
KASSERT(error == 0, ("unexpected tsleep error %d", error)); | |||||
} | } | ||||
if (error == 0) { | if (error == 0) { | ||||
read_rate_increment((uio->uio_resid + sizeof(uint32_t))/sizeof(uint32_t)); | read_rate_increment((uio->uio_resid + sizeof(uint32_t))/sizeof(uint32_t)); | ||||
total_read = 0; | total_read = 0; | ||||
while (uio->uio_resid && !error) { | while (uio->uio_resid && !error) { | ||||
read_len = uio->uio_resid; | read_len = uio->uio_resid; | ||||
/* | /* | ||||
* Belt-and-braces. | * Belt-and-braces. | ||||
Show All 12 Lines | while (uio->uio_resid && !error) { | ||||
*/ | */ | ||||
error = uiomove(random_buf, c, uio); | error = uiomove(random_buf, c, uio); | ||||
total_read += c; | total_read += c; | ||||
/* | /* | ||||
* Poll for signals every few MBs to avoid very long | * Poll for signals every few MBs to avoid very long | ||||
* uninterruptible syscalls. | * uninterruptible syscalls. | ||||
*/ | */ | ||||
if (error == 0 && uio->uio_resid != 0 && | if (error == 0 && uio->uio_resid != 0 && | ||||
total_read % sigchk_period == 0) | total_read % sigchk_period == 0) { | ||||
error = tsleep_sbt(&random_alg_context, PCATCH, | error = tsleep_sbt(&random_alg_context, PCATCH, | ||||
"randrd", SBT_1NS, 0, C_HARDCLOCK); | "randrd", SBT_1NS, 0, C_HARDCLOCK); | ||||
/* Squash tsleep timeout condition */ | |||||
if (error == EWOULDBLOCK) | |||||
error = 0; | |||||
} | |||||
} | } | ||||
if (error == ERESTART || error == EINTR) | if (error == ERESTART || error == EINTR) | ||||
error = 0; | error = 0; | ||||
} | } | ||||
free(random_buf, M_ENTROPY); | free(random_buf, M_ENTROPY); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |