789081673f
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr to define the sized types in a consistent manor across all the architectures we support and not conflict with what various compilers and libc might do with regards to the C99 types. We introduce <zephyr/types.h> as part of this and have it include <stdint.h> for now until we transition all the code away from the C99 types. We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some existing variables defined u8 & u16 as well as to be consistent with Zephyr naming conventions. Jira: ZEP-2051 Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
73 lines
1.3 KiB
C
73 lines
1.3 KiB
C
/**
|
|
* @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,
|
|
uint8_t *buffer,
|
|
uint16_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,
|
|
uint8_t *buffer,
|
|
uint16_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__ */
|