diff options
author | Atish Patra <atish.patra@wdc.com> | 2019-04-01 17:04:05 -0700 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-04-03 09:57:42 +0530 |
commit | 8334a88c632b5bd3abd33fa8c9b9b4c04f0b12c8 (patch) | |
tree | 7ddcc59943bd9a718945057ec202fee91bf016c8 /include/sbi/sbi_fifo.h | |
parent | 14dadeab09654b8ccde0f95a5283874bd43ea711 (diff) |
lib: Add a fifo implementation.
Implement a fifo to accomodate outstanding IPIs for a specific hart
at the same time.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include/sbi/sbi_fifo.h')
-rw-r--r-- | include/sbi/sbi_fifo.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/sbi/sbi_fifo.h b/include/sbi/sbi_fifo.h new file mode 100644 index 0000000..ba9769b --- /dev/null +++ b/include/sbi/sbi_fifo.h @@ -0,0 +1,32 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * + * Authors: + * Atish Patra<atish.patra@wdc.com> + * + */ + +#ifndef __SBI_FIFO_H__ +#define __SBI_FIFO_H__ + +#include <sbi/riscv_locks.h> +#include <sbi/sbi_types.h> + +struct sbi_fifo { + int head; + int tail; + spinlock_t qlock; + unsigned long entrysize; + unsigned long num_entries; + void *queue; +}; + +int sbi_fifo_dequeue(struct sbi_fifo *fifo, void *data); +int sbi_fifo_enqueue(struct sbi_fifo *fifo, void *data); +void sbi_fifo_init(struct sbi_fifo *fifo, unsigned long entries, + unsigned long entrysize); +bool sbi_fifo_is_empty(struct sbi_fifo *fifo); +bool sbi_fifo_is_full(struct sbi_fifo *fifo); +#endif |