Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
entropy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 ARM Ltd.
3 * Copyright (c) 2017 Intel Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13
14
15 #ifndef ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
16#define ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
17
26
27#include <errno.h>
28
29#include <zephyr/types.h>
30#include <zephyr/device.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
37#define ENTROPY_BUSYWAIT BIT(0)
38
44
54typedef int (*entropy_get_entropy_t)(const struct device *dev,
55 uint8_t *buffer,
56 uint16_t length);
57
64typedef int (*entropy_get_entropy_isr_t)(const struct device *dev,
65 uint8_t *buffer,
66 uint16_t length,
68
78
80
91__syscall int entropy_get_entropy(const struct device *dev,
92 uint8_t *buffer,
93 uint16_t length);
94
95static inline int z_impl_entropy_get_entropy(const struct device *dev,
96 uint8_t *buffer,
97 uint16_t length)
98{
99 const struct entropy_driver_api *api =
100 (const struct entropy_driver_api *)dev->api;
101
102 __ASSERT(api->get_entropy != NULL,
103 "Callback pointer should not be NULL");
104 return api->get_entropy(dev, buffer, length);
105}
106
118static inline int entropy_get_entropy_isr(const struct device *dev,
119 uint8_t *buffer,
120 uint16_t length,
122{
123 const struct entropy_driver_api *api =
124 (const struct entropy_driver_api *)dev->api;
125
126 if (unlikely(api->get_entropy_isr == NULL)) {
127 return -ENOSYS;
128 }
129
130 return api->get_entropy_isr(dev, buffer, length, flags);
131}
132
133
134#ifdef __cplusplus
135}
136#endif
137
141
142#include <zephyr/syscalls/entropy.h>
143
144#endif /* ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_ */
System error numbers.
int(* entropy_get_entropy_t)(const struct device *dev, uint8_t *buffer, uint16_t length)
Callback API to get entropy.
Definition entropy.h:54
int(* entropy_get_entropy_isr_t)(const struct device *dev, uint8_t *buffer, uint16_t length, uint32_t flags)
Callback API to get entropy from an ISR.
Definition entropy.h:64
int entropy_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length)
Fills a buffer with entropy.
static int entropy_get_entropy_isr(const struct device *dev, uint8_t *buffer, uint16_t length, uint32_t flags)
Fills a buffer with entropy in a non-blocking or busy-wait manner.
Definition entropy.h:118
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define NULL
Definition iar_missing_defs.h:20
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
<span class="mlabel">Driver Operations</span> Entropy driver operations
Definition entropy.h:72
entropy_get_entropy_t get_entropy
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition entropy.h:74
entropy_get_entropy_isr_t get_entropy_isr
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition entropy.h:76