1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright (c) 2018-2019, STMicroelectronics
4  */
5 
6 #ifndef __STM32_RNG_H__
7 #define __STM32_RNG_H__
8 
9 #include <stdint.h>
10 #include <stddef.h>
11 #include <tee_api_types.h>
12 #include <types_ext.h>
13 
14 /*
15  * Fill buffer with bytes from the STM32_RNG
16  * @out: Output buffer
17  * @size: Byte size of the output buffer
18  * Return a TEE_Result compliant sttus
19  */
20 TEE_Result stm32_rng_read(uint8_t *out, size_t size);
21 
22 /*
23  * As stm32_rng_read() but excluding clocks/reset dependencies.
24  *
25  * @rng_base: Caller provides the RNG interface base address
26  * @out: Output buffer
27  * @size: Pointer to input/output byte size of the output buffer
28  * Return a TEE_Result compliant sttus
29  *
30  * When successfully returning, @size stores the number of bytes
31  * effectively generated in the output buffer @out. The input value
32  * of @size gives the size available in buffer @out.
33  */
34 TEE_Result stm32_rng_read_raw(vaddr_t rng_base, uint8_t *out, size_t *size);
35 
36 #endif /*__STM32_RNG_H__*/
37