blob: 9c24581c49f01ec58927490af7b10919142c5291 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef TS_PLATFORM_INTERFACE_TRNG_H
#define TS_PLATFORM_INTERFACE_TRNG_H
/*
* Interface definintion for a platform trng driver. A platform provider will
* provide concrete implementations of this interface for each alternative
* implementation supported.
*/
#include <stddef.h>
#include "device_region.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Virtual interface for a platform trng driver. A platform will provide
* one or more concrete implementations of this interface.
*/
struct platform_trng_iface
{
/**
* \brief Poll for bytes of entropy from a platform trng
*
* \param context Platform driver context
* \param output Buffer for output
* \param nbyte Desired number of bytes
* \param len The number of bytes returned (could be zero)
*
* \return 0 if successful.
*/
int (*poll)(void *context, unsigned char *output, size_t nbyte, size_t *len);
};
/*
* A platform trng driver instance.
*/
struct platform_trng_driver
{
void *context; /**< Opaque driver context */
const struct platform_trng_iface *iface; /**< Interface methods */
};
/**
* \brief Factory method to construct a platform specific trng driver
*
* \param driver Pointer to driver structure to initialize on construction.
* \param device_region Pointer a device region object or NULL if none.
*
* \return 0 if successful.
*/
int platform_trng_create(struct platform_trng_driver *driver,
const struct device_region *device_region);
/**
* \brief Destroy a driver constructed using the factory method
*
* \param driver Pointer to driver structure for constructed driver.
*/
void platform_trng_destroy(struct platform_trng_driver *driver);
#ifdef __cplusplus
}
#endif
#endif /* TS_PLATFORM_INTERFACE_TRNG_H */
|