Lines Matching refs:rng
463 * synchronous self-tests and the first RNG draw.
484 * Set up the RNG. This will try to synchronously draw the
491 * Self-test has passed and first RNG draw has finished. Use
1315 struct sun8i_crypto_rng *rng = &sc->sc_rng;
1322 error = sun8i_crypto_allocbuf(sc, SUN8I_CRYPTO_RNGBYTES, &rng->cr_buf,
1325 aprint_error_dev(self, "failed to allocate RNG buffer: %d\n",
1331 task = rng->cr_task = sun8i_crypto_task_get(sc, sun8i_crypto_rng_done,
1332 rng, PR_WAITOK);
1333 if (rng->cr_task == NULL) {
1334 aprint_error_dev(self, "failed to allocate RNG task\n");
1341 rng->cr_buf.cb_kva, SUN8I_CRYPTO_RNGBYTES, NULL, BUS_DMA_NOWAIT);
1343 aprint_error_dev(self, "failed to load RNG buffer: %d\n",
1352 rndsource_setcb(&rng->cr_rndsource, sun8i_crypto_rng_get, sc);
1353 rnd_attach_source(&rng->cr_rndsource, device_xname(self),
1358 * Poll for the first call to the RNG to complete. If not done
1361 for (; rng->cr_pending && timo --> 0; DELAY(1000)) {
1365 if (rng->cr_pending) {
1368 KASSERT(!rng->cr_pending);
1376 fail1: sun8i_crypto_freebuf(sc, SUN8I_CRYPTO_RNGBYTES, &rng->cr_buf);
1390 struct sun8i_crypto_rng *rng = &sc->sc_rng;
1391 struct sun8i_crypto_task *task = rng->cr_task;
1396 * Test and set the RNG-pending flag. If it's already in
1400 pending = rng->cr_pending;
1401 rng->cr_pending = true;
1420 rng->cr_pending = false;
1428 struct sun8i_crypto_rng *rng = cookie;
1429 uint8_t *buf = rng->cr_buf.cb_kva;
1432 KASSERT(rng == &sc->sc_rng);
1457 rnd_add_data(&rng->cr_rndsource, buf, SUN8I_CRYPTO_RNGBYTES,
1461 out: /* Done -- clear the RNG-pending flag. */
1463 rng->cr_pending = false;
1681 /* hw.sun8icryptoN.rng (`struct', 4096-byte array) */
1684 "rng", SYSCTL_DESCR("Read up to 4096 bytes out of the TRNG"),
1688 "failed to set up sysctl hw.%s.rng: %d\n",
1728 /* Allocate a buffer for the RNG output. */