Lines Matching +full:extra +full:- +full:byte
5 * SPDX-License-Identifier: Apache-2.0
27 * values must be read out by the CPU byte-by-byte. But once started,
30 * The generation time for byte 0 after starting generation (with BIAS
33 * nRF51822 - 677us
34 * nRF52810 - 248us
35 * nRF52840 - 248us
37 * The generation time for byte N >= 1 after starting generation (with
40 * nRF51822 - 677us
41 * nRF52810 - 120us
42 * nRF52840 - 120us
44 * Due to the first byte in a stream of bytes being more costly on
46 * amortize the cost of the first byte.
57 * Setting a low threshold will highly amortize the extra 120us cost
58 * of the first byte on nRF52.
64 * low or high depending on the HFCLK-usage pattern of other
69 * entropy is requested there will be no extra current-consumption for
86 (CONFIG_ENTROPY_NRF5_ISR_POOL_SIZE - 1)) == 0,
90 (CONFIG_ENTROPY_NRF5_THR_POOL_SIZE - 1)) == 0,
105 int retval = -EAGAIN; in random_byte_get()
122 uint32_t last = rngp->last; in rng_pool_get()
123 uint32_t mask = rngp->mask; in rng_pool_get()
130 first = rngp->first_alloc; in rng_pool_get()
133 * The other_read_in_progress is non-zero if rngp->first_read != first, in rng_pool_get()
134 * which means that lower-priority code (which was interrupted by this in rng_pool_get()
137 other_read_in_progress = (rngp->first_read ^ first); in rng_pool_get()
139 available = (last - first) & mask; in rng_pool_get()
148 rngp->first_alloc = (first + len) & mask; in rng_pool_get()
151 while (likely(len--)) { in rng_pool_get()
152 *dst++ = rngp->buffer[first]; in rng_pool_get()
163 rngp->first_read = rngp->first_alloc; in rng_pool_get()
167 len = dst - buf; in rng_pool_get()
168 available = available - len; in rng_pool_get()
169 if (available <= rngp->threshold) { in rng_pool_get()
176 static int rng_pool_put(struct rng_pool *rngp, uint8_t byte) in rng_pool_put() argument
178 uint8_t first = rngp->first_read; in rng_pool_put()
179 uint8_t last = rngp->last; in rng_pool_put()
180 uint8_t mask = rngp->mask; in rng_pool_put()
183 if (((last - first) & mask) == mask) { in rng_pool_put()
184 return -ENOBUFS; in rng_pool_put()
187 rngp->buffer[last] = byte; in rng_pool_put()
188 rngp->last = (last + 1) & mask; in rng_pool_put()
195 rngp->first_alloc = 0U; in rng_pool_init()
196 rngp->first_read = 0U; in rng_pool_init()
197 rngp->last = 0U; in rng_pool_init()
198 rngp->mask = size - 1; in rng_pool_init()
199 rngp->threshold = threshold; in rng_pool_init()
204 int byte, ret; in isr() local
208 byte = random_byte_get(); in isr()
209 if (byte < 0) { in isr()
213 ret = rng_pool_put((struct rng_pool *)(entropy_nrf5_data.isr), byte); in isr()
216 byte); in isr()
229 __ASSERT_NO_MSG(&entropy_nrf5_data == dev->data); in entropy_nrf5_get_entropy()
245 len -= bytes; in entropy_nrf5_get_entropy()
259 __ASSERT_NO_MSG(&entropy_nrf5_data == dev->data); in entropy_nrf5_get_entropy_isr()
279 * RNG event will set the Cortex-M single-bit event register in entropy_nrf5_get_entropy_isr()
286 int byte; in entropy_nrf5_get_entropy_isr() local
293 byte = random_byte_get(); in entropy_nrf5_get_entropy_isr()
296 if (byte < 0) { in entropy_nrf5_get_entropy_isr()
300 buf[--len] = byte; in entropy_nrf5_get_entropy_isr()
327 __ASSERT_NO_MSG(&entropy_nrf5_data == dev->data); in entropy_nrf5_init()