Zephyr Project API 4.2.99
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
15 #ifndef ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
16#define ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
17
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
48typedef int (*entropy_get_entropy_t)(const struct device *dev,
49 uint8_t *buffer,
50 uint16_t length);
57typedef int (*entropy_get_entropy_isr_t)(const struct device *dev,
58 uint8_t *buffer,
59 uint16_t length,
61
71
82__syscall int entropy_get_entropy(const struct device *dev,
83 uint8_t *buffer,
84 uint16_t length);
85
86static inline int z_impl_entropy_get_entropy(const struct device *dev,
87 uint8_t *buffer,
88 uint16_t length)
89{
90 const struct entropy_driver_api *api =
91 (const struct entropy_driver_api *)dev->api;
92
93 __ASSERT(api->get_entropy != NULL,
94 "Callback pointer should not be NULL");
95 return api->get_entropy(dev, buffer, length);
96}
97
108static inline int entropy_get_entropy_isr(const struct device *dev,
109 uint8_t *buffer,
110 uint16_t length,
112{
113 const struct entropy_driver_api *api =
114 (const struct entropy_driver_api *)dev->api;
115
116 if (unlikely(!api->get_entropy_isr)) {
117 return -ENOTSUP;
118 }
119
120 return api->get_entropy_isr(dev, buffer, length, flags);
121}
122
123
124#ifdef __cplusplus
125}
126#endif
127
132#include <zephyr/syscalls/entropy.h>
133
134#endif /* ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_ */
System error numbers.
int entropy_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length)
Fills a buffer with entropy.
int(* entropy_get_entropy_t)(const struct device *dev, uint8_t *buffer, uint16_t length)
Callback API to get entropy.
Definition entropy.h:48
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:108
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:57
#define ENOTSUP
Unsupported value.
Definition errno.h:114
#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:510
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516
Entropy driver API structure.
Definition entropy.h:67
entropy_get_entropy_t get_entropy
Definition entropy.h:68
entropy_get_entropy_isr_t get_entropy_isr
Definition entropy.h:69