cc334c7273
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99 integer types. This handles the remaining includes and kernel, plus touching up various points that we skipped because of include dependancies. We also convert the PRI printf formatters in the arch code over to normal formatters. Jira: ZEP-2051 Change-Id: Iecbb12601a3ee4ea936fd7ddea37788a645b08b0 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,
|
|
u8_t *buffer,
|
|
u16_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,
|
|
u8_t *buffer,
|
|
u16_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__ */
|