- make-uefi-iso.sh: UEFI ISO image builder - test_boot.S, test_boot.ld: test boot assembly and linker script - eim_config.toml: EIM (External Interface Module) configuration - edk2-ovmf RPM for UEFI firmware - GAP_ANALYSIS_PIKEOS_PARITY.md: PikeOS parity gap analysis
66 lines
2.3 KiB
C
66 lines
2.3 KiB
C
/*
|
|
* UniversalisOS Microkernel — Message Queue
|
|
*
|
|
* Bounded FIFO with copy semantics. Each item is a fixed-size copy.
|
|
* Blocking on full queue (send) or empty queue (receive).
|
|
*/
|
|
#ifndef UOS_MQUEUE_H
|
|
#define UOS_MQUEUE_H
|
|
|
|
#include "uos_types.h"
|
|
#include "uos_object.h"
|
|
#include "uos_api.h"
|
|
|
|
typedef struct uos_mqueue {
|
|
uos_object_t obj;
|
|
uint8_t* buffer; /* Ring buffer */
|
|
uint32_t item_size; /* Size of each item in bytes */
|
|
uint32_t max_items; /* Maximum number of items */
|
|
uint32_t count; /* Current number of items */
|
|
uint32_t head; /* Write index */
|
|
uint32_t tail; /* Read index */
|
|
uos_task_t* send_wait; /* Senders blocked on full queue */
|
|
uos_task_t* recv_wait; /* Receivers blocked on empty queue */
|
|
} uos_mqueue_t;
|
|
|
|
/* Initialize with static buffer.
|
|
* buf must be at least item_size * max_items bytes. */
|
|
UOS_INLINE void uos_mqueue_init(uos_mqueue_t* q, const char* name,
|
|
void* buf, uint32_t item_size, uint32_t max_items) {
|
|
uos_obj_init(&q->obj, UOS_OBJ_QUEUE, name, UOS_OBJ_FLAG_STATIC);
|
|
q->buffer = (uint8_t*)buf;
|
|
q->item_size = item_size;
|
|
q->max_items = max_items;
|
|
q->count = 0;
|
|
q->head = 0;
|
|
q->tail = 0;
|
|
q->send_wait = NULL;
|
|
q->recv_wait = NULL;
|
|
}
|
|
|
|
/* Send item (blocking if full). Returns UOS_OK or UOS_ERR_WOULDBLOCK. */
|
|
uos_status_t uos_mqueue_send(uos_mqueue_t* q, const void* item, uos_tick_t timeout);
|
|
|
|
/* Send item from ISR (non-blocking, returns UOS_ERR_WOULDBLOCK if full). */
|
|
uos_status_t uos_mqueue_send_isr(uos_mqueue_t* q, const void* item);
|
|
|
|
/* Receive item (blocking if empty). Returns UOS_OK or UOS_ERR_WOULDBLOCK. */
|
|
uos_status_t uos_mqueue_receive(uos_mqueue_t* q, void* item, uos_tick_t timeout);
|
|
|
|
/* Receive item from ISR (non-blocking, returns UOS_ERR_WOULDBLOCK if empty). */
|
|
uos_status_t uos_mqueue_receive_isr(uos_mqueue_t* q, void* item);
|
|
|
|
/* Get current count. */
|
|
UOS_INLINE uint32_t uos_mqueue_count(uos_mqueue_t* q) {
|
|
return q->count;
|
|
}
|
|
|
|
/* Get remaining space. */
|
|
UOS_INLINE uint32_t uos_mqueue_space(uos_mqueue_t* q) {
|
|
return q->max_items - q->count;
|
|
}
|
|
|
|
/* Destroy, waking all waiters. */
|
|
uos_status_t uos_mqueue_destroy(uos_mqueue_t* q);
|
|
|
|
#endif /* UOS_MQUEUE_H */
|