Lines Matching refs:rngp
137 static uint16_t rng_pool_get(struct rng_pool *rngp, uint8_t *buf, uint16_t len) in rng_pool_get() argument
139 uint32_t last = rngp->last; in rng_pool_get()
140 uint32_t mask = rngp->mask; in rng_pool_get()
147 first = rngp->first_alloc; in rng_pool_get()
154 other_read_in_progress = (rngp->first_read ^ first); in rng_pool_get()
165 rngp->first_alloc = (first + len) & mask; in rng_pool_get()
169 *dst++ = rngp->buffer[first]; in rng_pool_get()
180 rngp->first_read = rngp->first_alloc; in rng_pool_get()
186 if (available <= rngp->threshold) { in rng_pool_get()
193 static int rng_pool_put(struct rng_pool *rngp, uint8_t byte) in rng_pool_put() argument
195 uint8_t first = rngp->first_read; in rng_pool_put()
196 uint8_t last = rngp->last; in rng_pool_put()
197 uint8_t mask = rngp->mask; in rng_pool_put()
204 rngp->buffer[last] = byte; in rng_pool_put()
205 rngp->last = (last + 1) & mask; in rng_pool_put()
210 static const uint8_t *rng_pool_put_bytes(struct rng_pool *rngp, const uint8_t *bytes, in rng_pool_put_bytes() argument
217 if (rng_pool_put(rngp, *bytes) < 0) { in rng_pool_put_bytes()
226 static void rng_pool_init(struct rng_pool *rngp, uint16_t size, uint8_t threshold) in rng_pool_init() argument
228 rngp->first_alloc = 0U; in rng_pool_init()
229 rngp->first_read = 0U; in rng_pool_init()
230 rngp->last = 0U; in rng_pool_init()
231 rngp->mask = size - 1; in rng_pool_init()
232 rngp->threshold = threshold; in rng_pool_init()