1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef QEMU_RNG_H
14#define QEMU_RNG_H
15
16#include "qom/object.h"
17#include "qemu-common.h"
18
19#define TYPE_RNG_BACKEND "rng-backend"
20#define RNG_BACKEND(obj) \
21 OBJECT_CHECK(RngBackend, (obj), TYPE_RNG_BACKEND)
22#define RNG_BACKEND_GET_CLASS(obj) \
23 OBJECT_GET_CLASS(RngBackendClass, (obj), TYPE_RNG_BACKEND)
24#define RNG_BACKEND_CLASS(klass) \
25 OBJECT_CLASS_CHECK(RngBackendClass, (klass), TYPE_RNG_BACKEND)
26
27typedef struct RngRequest RngRequest;
28typedef struct RngBackendClass RngBackendClass;
29typedef struct RngBackend RngBackend;
30
31typedef void (EntropyReceiveFunc)(void *opaque,
32 const void *data,
33 size_t size);
34
35struct RngRequest
36{
37 EntropyReceiveFunc *receive_entropy;
38 uint8_t *data;
39 void *opaque;
40 size_t offset;
41 size_t size;
42 QSIMPLEQ_ENTRY(RngRequest) next;
43};
44
45struct RngBackendClass
46{
47 ObjectClass parent_class;
48
49 void (*request_entropy)(RngBackend *s, RngRequest *req);
50
51 void (*opened)(RngBackend *s, Error **errp);
52};
53
54struct RngBackend
55{
56 Object parent;
57
58
59 bool opened;
60 QSIMPLEQ_HEAD(requests, RngRequest) requests;
61};
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79void rng_backend_request_entropy(RngBackend *s, size_t size,
80 EntropyReceiveFunc *receive_entropy,
81 void *opaque);
82
83
84
85
86
87
88
89
90
91
92void rng_backend_finalize_request(RngBackend *s, RngRequest *req);
93#endif
94