[PATCH 5/6] include: sbi: Add macros to create FIFO as local or global variable
Anup Patel
apatel at ventanamicro.com
Fri Jul 5 00:15:03 PDT 2024
The FIFO data structure is quite handy of variety of use-case so add
SBI_FIFO_INITIALIZER() and SBI_FIFO_DEFINE() helper macros to create
FIFO as local or global variable.
Signed-off-by: Anup Patel <apatel at ventanamicro.com>
---
include/sbi/sbi_fifo.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/sbi/sbi_fifo.h b/include/sbi/sbi_fifo.h
index af1632a..89a2ea2 100644
--- a/include/sbi/sbi_fifo.h
+++ b/include/sbi/sbi_fifo.h
@@ -23,6 +23,18 @@ struct sbi_fifo {
u16 tail;
};
+#define SBI_FIFO_INITIALIZER(__queue_mem, __entries, __entry_size) \
+{ .queue = __queue_mem, \
+ .qlock = SPIN_LOCK_INITIALIZER, \
+ .num_entries = __entries, \
+ .entry_size = __entry_size, \
+ .avail = 0, \
+ .tail = 0, \
+}
+
+#define SBI_FIFO_DEFINE(__name, __queue_mem, __entries, __entry_size) \
+struct sbi_fifo __name = SBI_FIFO_INITIALIZER(__queue_mem, __entries, __entry_size)
+
enum sbi_fifo_inplace_update_types {
SBI_FIFO_SKIP,
SBI_FIFO_UPDATED,
--
2.34.1
More information about the opensbi
mailing list