summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/msgq.h
blob: 3a4084c08c984e32fba15357811a4241ac35873d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdint.h>

#ifndef _EOS_MSGQ_H_
#define _EOS_MSGQ_H_

typedef struct EOSMessage {
    unsigned char *buffer;
    uint16_t size;
} EOSMessage;

void eos_msg_init(EOSMessage *msg, unsigned char *buffer, uint16_t size);

typedef struct EOSMsgItem {
    unsigned char type;
    unsigned char *buffer;
    uint16_t size;
    uint16_t len;
} EOSMsgItem;

typedef struct EOSMsgQ {
    uint8_t idx_r;
    uint8_t idx_w;
    uint8_t size;
    EOSMsgItem *array;
} EOSMsgQ;

void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size);
uint8_t eos_msgq_len(EOSMsgQ *msgq);
int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, EOSMessage *msg, uint16_t len);
int eos_msgq_push_widx(EOSMsgQ *msgq, unsigned char type, EOSMessage *msg, uint16_t len, uint8_t *_idx);
void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, EOSMessage *msg, uint16_t *len);
void eos_msgq_pop_widx(EOSMsgQ *msgq, unsigned char *type, EOSMessage *msg, uint16_t *len, uint8_t *_idx);

typedef struct EOSBufQ {
    uint8_t idx_r;
    uint8_t idx_w;
    uint8_t size;
    unsigned char **array;
} EOSBufQ;

void eos_bufq_init(EOSBufQ *bufq, unsigned char **array, uint8_t size);
uint8_t eos_bufq_len(EOSBufQ *bufq);
int eos_bufq_push(EOSBufQ *bufq, unsigned char *buffer);
unsigned char *eos_bufq_pop(EOSBufQ *bufq);

#endif  /* _EOS_MSGQ_H_ */