mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
lib: More improvements to sbi_fifo
This patch does following improvements to sbi_fifo: 1. Use valid SBI_Exxxx error codes instead of -1 2. The sbi_fifo_is_full() and sbi_fifo_is_empty() did not acquire qlock before accessing head and tail hence fixed it 3. Added avail member for ease in debugging and simplifying head/tail updates. Due to above changes size of sbi_fifo changes from 48 bytes to 56 bytes. Signed-off-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
@@ -21,5 +21,6 @@
|
||||
#define SBI_ETIMEDOUT -8
|
||||
#define SBI_EIO -9
|
||||
#define SBI_EILL -10
|
||||
#define SBI_ENOSPC -11
|
||||
|
||||
#endif
|
||||
|
@@ -15,18 +15,22 @@
|
||||
#include <sbi/sbi_types.h>
|
||||
|
||||
struct sbi_fifo {
|
||||
int head;
|
||||
int tail;
|
||||
spinlock_t qlock;
|
||||
unsigned long entrysize;
|
||||
unsigned long num_entries;
|
||||
/* Static members of struct */
|
||||
void *queue;
|
||||
unsigned long entry_size;
|
||||
unsigned long num_entries;
|
||||
/* Dynamic members of struct protected by lock */
|
||||
spinlock_t qlock;
|
||||
unsigned long avail;
|
||||
unsigned long head;
|
||||
unsigned long tail;
|
||||
};
|
||||
|
||||
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);
|
||||
void sbi_fifo_init(struct sbi_fifo *fifo, void *queue_mem,
|
||||
unsigned long entries, unsigned long entry_size);
|
||||
bool sbi_fifo_is_empty(struct sbi_fifo *fifo);
|
||||
bool sbi_fifo_is_full(struct sbi_fifo *fifo);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user