forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.h
72 lines (61 loc) · 1.32 KB
/
random.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* @file random.h
*
* @brief Public APIs for the random driver.
*/
/*
* Copyright (c) 2016 ARM Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __RANDOM_H__
#define __RANDOM_H__
/**
* @brief Random Interface
* @defgroup random_interface Random Interface
* @ingroup io_interfaces
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h>
#include <device.h>
/**
* @typedef random_get_entropy_t
* @brief Callback API to get entropy.
*
* See random_get_entropy() for argument description
*/
typedef int (*random_get_entropy_t)(struct device *dev,
u8_t *buffer,
u16_t length);
struct random_driver_api {
random_get_entropy_t get_entropy;
};
/**
* @brief Get entropy from the random driver.
*
* Fill a buffer with entropy from the random driver.
*
* @param dev Pointer to the random device.
* @param buffer Buffer to fill with entropy.
* @param length Buffer length.
* @retval 0 on success.
* @retval -ERRNO errno code on error.
*/
static inline int random_get_entropy(struct device *dev,
u8_t *buffer,
u16_t length)
{
const struct random_driver_api *api = dev->driver_api;
__ASSERT(api->get_entropy, "Callback pointer should not be NULL");
return api->get_entropy(dev, buffer, length);
}
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* __RANDOM_H__ */