VSF Documented
vsf_template_rng.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TEMPLATE_RNG_H__
19#define __VSF_TEMPLATE_RNG_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31
38#ifndef VSF_RNG_CFG_MULTI_CLASS
39# define VSF_RNG_CFG_MULTI_CLASS ENABLED
40#endif
41
48#if defined(VSF_HW_RNG_COUNT) && !defined(VSF_HW_RNG_MASK)
49# define VSF_HW_RNG_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_RNG_COUNT)
50#endif
51
58#if defined(VSF_HW_RNG_MASK) && !defined(VSF_HW_RNG_COUNT)
59# define VSF_HW_RNG_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_RNG_MASK)
60#endif
61
70#ifndef VSF_RNG_CFG_PREFIX
71# if VSF_RNG_CFG_MULTI_CLASS == ENABLED
72# define VSF_RNG_CFG_PREFIX vsf
73# elif defined(VSF_HW_RNG_COUNT) && (VSF_HW_RNG_COUNT != 0)
74# define VSF_RNG_CFG_PREFIX vsf_hw
75# else
76# define VSF_RNG_CFG_PREFIX vsf
77# endif
78#endif
79
88#ifndef VSF_RNG_CFG_FUNCTION_RENAME
89# define VSF_RNG_CFG_FUNCTION_RENAME ENABLED
90#endif
91
103#if VSF_RNG_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
104# define VSF_RNG_CFG_REIMPLEMENT_TYPE_CFG DISABLED
105#endif
106
117#if VSF_RNG_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
118# define VSF_RNG_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
119#endif
120
129#ifndef VSF_RNG_CFG_INHERIT_HAL_CAPABILITY
130# define VSF_RNG_CFG_INHERIT_HAL_CAPABILITY ENABLED
131#endif
132
133/*============================ MACROFIED FUNCTIONS ===========================*/
134
144#define VSF_RNG_APIS(__prefix_name) \
145 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rng, init, VSF_MCONNECT(__prefix_name, _rng_t) *rng_ptr) \
146 __VSF_HAL_TEMPLATE_API(__prefix_name, void, rng, fini, VSF_MCONNECT(__prefix_name, _rng_t) *rng_ptr) \
147 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_rng_capability_t, rng, capability, VSF_MCONNECT(__prefix_name, _rng_t) *rng_ptr) \
148 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rng, generate_request, VSF_MCONNECT(__prefix_name, _rng_t) *rng_ptr, \
149 uint32_t *buffer, uint32_t num, void *param, vsf_rng_on_ready_callback_t * on_ready_cb)
150
151/*============================ TYPES =========================================*/
152
153typedef struct vsf_rng_t vsf_rng_t;
154typedef void vsf_rng_on_ready_callback_t(void *param, uint32_t *buffer, uint32_t num);
155
156typedef struct vsf_rng_capability_t {
157#if VSF_RNG_CFG_INHERIT_HAL_CAPABILITY == ENABLED
159#endif
161
162typedef struct vsf_rng_op_t {
164#undef __VSF_HAL_TEMPLATE_API
165#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
167
168 VSF_RNG_APIS(vsf)
170
171#if VSF_RNG_CFG_MULTI_CLASS == ENABLED
172struct vsf_rng_t {
174};
175#endif
176
177/*============================ PROTOTYPES ====================================*/
178
196extern vsf_err_t vsf_rng_init(vsf_rng_t *rng_ptr);
197
209extern void vsf_rng_fini(vsf_rng_t *rng_ptr);
210
223
243extern vsf_err_t vsf_rng_generate_request(vsf_rng_t *rng_ptr, uint32_t *buffer, uint32_t num,
244 void *param, vsf_rng_on_ready_callback_t * on_ready_cb);
245
246/*============================ INCLUDES ======================================*/
247
248/*============================ MACROFIED FUNCTIONS ===========================*/
249
251#if VSF_RNG_CFG_FUNCTION_RENAME == ENABLED
252# define __vsf_rng_t VSF_MCONNECT(VSF_RNG_CFG_PREFIX, _rng_t)
253# define vsf_rng_init(__RNG, ...) VSF_MCONNECT(VSF_RNG_CFG_PREFIX, _rng_init) ((__vsf_rng_t *)(__RNG), ##__VA_ARGS__)
254# define vsf_rng_fini(__RNG) VSF_MCONNECT(VSF_RNG_CFG_PREFIX, _rng_fini) ((__vsf_rng_t *)(__RNG))
255# define vsf_rng_capability(__RNG) VSF_MCONNECT(VSF_RNG_CFG_PREFIX, _rng_capability) ((__vsf_rng_t *)(__RNG))
256# define vsf_rng_generate_request(__RNG, ...) VSF_MCONNECT(VSF_RNG_CFG_PREFIX, _rng_generate_request) ((__vsf_rng_t *)(__RNG), ##__VA_ARGS__)
257#endif
259
260#ifdef __cplusplus
261}
262#endif
263
264#endif /*__VSF_TEMPLATE_RNG_H__*/
vsf_err_t
Definition __type.h:42
unsigned uint32_t
Definition stdint.h:9
Definition vsf_template_hal_driver.h:203
Definition vsf_template_rng.h:156
Definition vsf_template_rng.h:162
Definition vsf_template_rng.h:172
const vsf_rng_op_t * op
Definition vsf_template_rng.h:173
vsf_err_t vsf_rng_init(vsf_rng_t *rng_ptr)
Initialize a RNG instance.
Definition rng_common.c:37
void vsf_rng_on_ready_callback_t(void *param, uint32_t *buffer, uint32_t num)
Definition vsf_template_rng.h:154
vsf_rng_capability_t vsf_rng_capability(vsf_rng_t *rng_ptr)
Get the capability of RNG instance.
Definition rng_common.c:65
#define VSF_RNG_APIS(__prefix_name)
RNG API template, used to generate RNG type, specific prefix function declarations,...
Definition vsf_template_rng.h:144
vsf_err_t vsf_rng_generate_request(vsf_rng_t *rng_ptr, uint32_t *buffer, uint32_t num, void *param, vsf_rng_on_ready_callback_t *on_ready_cb)
RNG generate request.
Definition rng_common.c:55
void vsf_rng_fini(vsf_rng_t *rng_ptr)
Finalize a RNG instance.
Definition rng_common.c:46
Generated from commit: vsfteam/vsf@2b286be