target-microblaze: Drop unused cpu_mb_close() prototype
[qemu/opensuse.git] / hw / fifo.h
blobf23890abf45e4614e1e1f14ddba5214a5141af3a
1 #ifndef FIFO_H
2 #define FIFO_H
4 #include "hw.h"
6 typedef struct {
7 /* All fields are private */
8 uint8_t *data;
9 uint32_t capacity;
10 uint32_t head;
11 uint32_t num;
12 } Fifo8;
14 /**
15 * fifo8_create:
16 * @fifo: struct Fifo8 to initialise with new FIFO
17 * @capacity: capacity of the newly created FIFO
19 * Create a FIFO of the specified size. Clients should call fifo8_destroy()
20 * when finished using the fifo. The FIFO is initially empty.
23 void fifo8_create(Fifo8 *fifo, uint32_t capacity);
25 /**
26 * fifo8_destroy:
27 * @fifo: FIFO to cleanup
29 * Cleanup a FIFO created with fifo8_create(). Frees memory created for FIFO
30 *storage. The FIFO is no longer usable after this has been called.
33 void fifo8_destroy(Fifo8 *fifo);
35 /**
36 * fifo8_push:
37 * @fifo: FIFO to push to
38 * @data: data byte to push
40 * Push a data byte to the FIFO. Behaviour is undefined if the FIFO is full.
41 * Clients are responsible for checking for fullness using fifo8_is_full().
44 void fifo8_push(Fifo8 *fifo, uint8_t data);
46 /**
47 * fifo8_pop:
48 * @fifo: fifo to pop from
50 * Pop a data byte from the FIFO. Behaviour is undefined if the FIFO is empty.
51 * Clients are responsible for checking for emptyness using fifo8_is_empty().
53 * Returns: The popped data byte.
56 uint8_t fifo8_pop(Fifo8 *fifo);
58 /**
59 * fifo8_reset:
60 * @fifo: FIFO to reset
62 * Reset a FIFO. All data is discarded and the FIFO is emptied.
65 void fifo8_reset(Fifo8 *fifo);
67 /**
68 * fifo8_is_empty:
69 * @fifo: FIFO to check
71 * Check if a FIFO is empty.
73 * Returns: True if the fifo is empty, false otherwise.
76 bool fifo8_is_empty(Fifo8 *fifo);
78 /**
79 * fifo8_is_full:
80 * @fifo: FIFO to check
82 * Check if a FIFO is full.
84 * Returns: True if the fifo is full, false otherwise.
87 bool fifo8_is_full(Fifo8 *fifo);
89 extern const VMStateDescription vmstate_fifo8;
91 #define VMSTATE_FIFO8(_field, _state) { \
92 .name = (stringify(_field)), \
93 .size = sizeof(Fifo8), \
94 .vmsd = &vmstate_fifo8, \
95 .flags = VMS_STRUCT, \
96 .offset = vmstate_offset_value(_state, _field, Fifo8), \
99 #endif /* FIFO_H */