123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
- #define ZEPHYR_INCLUDE_DRIVERS_ENTROPY_H_
- #include <zephyr/types.h>
- #include <device.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef int (*entropy_get_entropy_t)(const struct device *dev,
- uint8_t *buffer,
- uint16_t length);
- typedef int (*entropy_get_entropy_isr_t)(const struct device *dev,
- uint8_t *buffer,
- uint16_t length,
- uint32_t flags);
- __subsystem struct entropy_driver_api {
- entropy_get_entropy_t get_entropy;
- entropy_get_entropy_isr_t get_entropy_isr;
- };
- __syscall int entropy_get_entropy(const struct device *dev,
- uint8_t *buffer,
- uint16_t length);
- static inline int z_impl_entropy_get_entropy(const struct device *dev,
- uint8_t *buffer,
- uint16_t length)
- {
- const struct entropy_driver_api *api =
- (const struct entropy_driver_api *)dev->api;
- __ASSERT(api->get_entropy != NULL,
- "Callback pointer should not be NULL");
- return api->get_entropy(dev, buffer, length);
- }
- #define ENTROPY_BUSYWAIT BIT(0)
- static inline int entropy_get_entropy_isr(const struct device *dev,
- uint8_t *buffer,
- uint16_t length,
- uint32_t flags)
- {
- const struct entropy_driver_api *api =
- (const struct entropy_driver_api *)dev->api;
- if (unlikely(!api->get_entropy_isr)) {
- return -ENOTSUP;
- }
- return api->get_entropy_isr(dev, buffer, length, flags);
- }
- #ifdef __cplusplus
- }
- #endif
- #include <syscalls/entropy.h>
- #endif
|