Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
entropy.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2016 ARM Ltd.
9 * Copyright (c) 2017 Intel Corporation
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13#ifndef ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
14#define ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
15
25#include <errno.h>
26
27#include <zephyr/types.h>
28#include <zephyr/device.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
35#define ENTROPY_BUSYWAIT BIT(0)
36
46typedef int (*entropy_get_entropy_t)(const struct device *dev,
47 uint8_t *buffer,
48 uint16_t length);
55typedef int (*entropy_get_entropy_isr_t)(const struct device *dev,
56 uint8_t *buffer,
57 uint16_t length,
59
69
80__syscall int entropy_get_entropy(const struct device *dev,
81 uint8_t *buffer,
82 uint16_t length);
83
84static inline int z_impl_entropy_get_entropy(const struct device *dev,
85 uint8_t *buffer,
86 uint16_t length)
87{
88 const struct entropy_driver_api *api =
89 (const struct entropy_driver_api *)dev->api;
90
91 __ASSERT(api->get_entropy != NULL,
92 "Callback pointer should not be NULL");
93 return api->get_entropy(dev, buffer, length);
94}
95
106static inline int entropy_get_entropy_isr(const struct device *dev,
107 uint8_t *buffer,
108 uint16_t length,
110{
111 const struct entropy_driver_api *api =
112 (const struct entropy_driver_api *)dev->api;
113
114 if (unlikely(!api->get_entropy_isr)) {
115 return -ENOTSUP;
116 }
117
118 return api->get_entropy_isr(dev, buffer, length, flags);
119}
120
121
122#ifdef __cplusplus
123}
124#endif
125
130#include <zephyr/syscalls/entropy.h>
131
132#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:46
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:106
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:55
#define ENOTSUP
Unsupported value.
Definition errno.h:114
flags
Definition parser.h:96
__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:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
Entropy driver API structure.
Definition entropy.h:65
entropy_get_entropy_t get_entropy
Definition entropy.h:66
entropy_get_entropy_isr_t get_entropy_isr
Definition entropy.h:67