ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
Loading...
Searching...
No Matches
pipe.h File Reference

ICARUS Pipe - Message Pipes (Circular Buffer Queues) More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

bool pipe_init (uint8_t pipe_idx, uint16_t pipe_capacity_bytes)
 Initialize a message pipe.
 
bool pipe_enqueue (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Enqueue bytes to pipe.
 
bool pipe_dequeue (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Dequeue bytes from pipe.
 
uint16_t pipe_get_count (uint8_t pipe_idx)
 Get current byte count in pipe.
 
uint16_t pipe_get_max_count (uint8_t pipe_idx)
 Get pipe capacity.
 
bool pipe_can_enqueue (uint8_t pipe_idx, uint8_t message_bytes)
 Check if pipe can accept data (SVC call gate)
 
bool pipe_can_dequeue (uint8_t pipe_idx, uint8_t message_bytes)
 Check if pipe has data available (SVC call gate)
 
void pipe_write_bytes (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Write bytes to pipe (SVC call gate)
 
void pipe_read_bytes (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Read bytes from pipe (SVC call gate)
 
bool __pipe_init (uint8_t pipe_idx, uint16_t pipe_capacity_bytes)
 Privileged implementation of pipe_init.
 
bool __pipe_enqueue (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Privileged implementation of pipe_enqueue.
 
bool __pipe_dequeue (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Privileged implementation of pipe_dequeue.
 
uint16_t __pipe_get_count (uint8_t pipe_idx)
 Privileged implementation of pipe_get_count.
 
uint16_t __pipe_get_max_count (uint8_t pipe_idx)
 Privileged implementation of pipe_get_max_count.
 
bool __pipe_can_enqueue (uint8_t pipe_idx, uint8_t message_bytes)
 Privileged call gate: can pipe accept message_bytes bytes?
 
bool __pipe_can_dequeue (uint8_t pipe_idx, uint8_t message_bytes)
 Privileged call gate: can pipe deliver message_bytes bytes?
 
void __pipe_write_bytes (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Privileged write gate: write bytes to pipe buffer.
 
void __pipe_read_bytes (uint8_t pipe_idx, uint8_t *message, uint8_t message_bytes)
 Privileged write gate: read bytes from pipe buffer.
 

Detailed Description

ICARUS Pipe - Message Pipes (Circular Buffer Queues)

Version
0.1.0

Byte-stream message pipes for inter-task communication.

Author
Souham Biswas
Date
2025

Definition in file pipe.h.

Function Documentation

◆ __pipe_can_dequeue()

bool __pipe_can_dequeue ( uint8_t  pipe_idx,
uint8_t  message_bytes 
)

Privileged call gate: can pipe deliver message_bytes bytes?

Note
Returns true if engaged and count >= message_bytes Used by __pipe_dequeue spin loop.

Definition at line 163 of file pipe.c.

References icarus_pipe_t::count, ICARUS_MAX_MESSAGE_QUEUES, and message_pipe_list.

Referenced by pipe_can_dequeue(), and SVC_Handler_C().

◆ __pipe_can_enqueue()

bool __pipe_can_enqueue ( uint8_t  pipe_idx,
uint8_t  message_bytes 
)

Privileged call gate: can pipe accept message_bytes bytes?

Note
Returns true if engaged and free space >= message_bytes Used by __pipe_enqueue spin loop to avoid direct DTCM reads from unprivileged thread mode once DTCM is priv-only.

Definition at line 149 of file pipe.c.

References ICARUS_MAX_MESSAGE_QUEUES, and message_pipe_list.

Referenced by __sb_publish(), pipe_can_enqueue(), and SVC_Handler_C().

◆ __pipe_dequeue()

bool __pipe_dequeue ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Privileged implementation of pipe_dequeue.

Note
Internal function - use pipe_dequeue() wrapper
Spin-wait uses pipe_can_dequeue() SVC gate — safe with DTCM priv-only

Definition at line 94 of file pipe.c.

References ICARUS_MAX_MESSAGE_QUEUES, message_pipe_list, pipe_can_dequeue(), pipe_read_bytes(), and task_active_sleep().

Referenced by pipe_dequeue().

◆ __pipe_enqueue()

bool __pipe_enqueue ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Privileged implementation of pipe_enqueue.

Note
Internal function - use pipe_enqueue() wrapper
Spin-wait uses pipe_can_enqueue() SVC gate — safe with DTCM priv-only

Definition at line 64 of file pipe.c.

References ICARUS_MAX_MESSAGE_QUEUES, message_pipe_list, pipe_can_enqueue(), pipe_write_bytes(), and task_active_sleep().

Referenced by pipe_enqueue().

◆ __pipe_get_count()

uint16_t __pipe_get_count ( uint8_t  pipe_idx)

Privileged implementation of pipe_get_count.

Note
Internal function - use pipe_get_count() wrapper

Definition at line 123 of file pipe.c.

References icarus_pipe_t::count, ICARUS_MAX_MESSAGE_QUEUES, and message_pipe_list.

Referenced by pipe_get_count(), and SVC_Handler_C().

◆ __pipe_get_max_count()

uint16_t __pipe_get_max_count ( uint8_t  pipe_idx)

Privileged implementation of pipe_get_max_count.

Note
Internal function - use pipe_get_max_count() wrapper

Definition at line 135 of file pipe.c.

References ICARUS_MAX_MESSAGE_QUEUES, icarus_pipe_t::max_count, and message_pipe_list.

Referenced by pipe_get_max_count(), and SVC_Handler_C().

◆ __pipe_init()

bool __pipe_init ( uint8_t  pipe_idx,
uint16_t  pipe_capacity_bytes 
)

Privileged implementation of pipe_init.

Note
Internal function - use pipe_init() wrapper
Runs in SVC handler — already atomic, no critical section needed

Definition at line 35 of file pipe.c.

References icarus_pipe_t::buffer, icarus_pipe_t::count, icarus_pipe_t::dequeue_idx, icarus_pipe_t::engaged, icarus_pipe_t::enqueue_idx, ICARUS_MAX_MESSAGE_BYTES, ICARUS_MAX_MESSAGE_QUEUES, icarus_pipe_t::max_count, message_pipe_list, os_tick_count, and icarus_pipe_t::tick_updated_at.

Referenced by pipe_init(), and SVC_Handler_C().

◆ __pipe_read_bytes()

void __pipe_read_bytes ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Privileged write gate: read bytes from pipe buffer.

Note
Called after pipe_can_dequeue() spin loop exits Runs in privileged SVC handler — already atomic, no critical section needed

Definition at line 199 of file pipe.c.

References icarus_pipe_t::buffer, icarus_pipe_t::count, icarus_pipe_t::dequeue_idx, ICARUS_MAX_MESSAGE_QUEUES, icarus_pipe_t::max_count, message_pipe_list, os_tick_count, and icarus_pipe_t::tick_updated_at.

Referenced by pipe_read_bytes(), and SVC_Handler_C().

◆ __pipe_write_bytes()

void __pipe_write_bytes ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Privileged write gate: write bytes to pipe buffer.

Note
Called after pipe_can_enqueue() spin loop exits Runs in privileged SVC handler — already atomic, no critical section needed

Definition at line 176 of file pipe.c.

References icarus_pipe_t::buffer, icarus_pipe_t::count, icarus_pipe_t::enqueue_idx, ICARUS_MAX_MESSAGE_QUEUES, icarus_pipe_t::max_count, message_pipe_list, os_tick_count, and icarus_pipe_t::tick_updated_at.

Referenced by __sb_publish(), pipe_write_bytes(), and SVC_Handler_C().

◆ pipe_can_dequeue()

bool pipe_can_dequeue ( uint8_t  pipe_idx,
uint8_t  message_bytes 
)

Check if pipe has data available (SVC call gate)

Parameters
pipe_idxPipe index
message_bytesNumber of bytes to dequeue
Returns
true if count >= message_bytes and engaged
Note
Uses SVC to read message_pipe_list from DTCM in privileged mode

Check if pipe has data available (SVC call gate)

Note
Runs in privileged mode — safe once DTCM is priv-only

Definition at line 1011 of file svc.c.

References __pipe_can_dequeue(), and SVC_PIPE_CAN_DEQUEUE.

Referenced by __pipe_dequeue().

◆ pipe_can_enqueue()

bool pipe_can_enqueue ( uint8_t  pipe_idx,
uint8_t  message_bytes 
)

Check if pipe can accept data (SVC call gate)

Parameters
pipe_idxPipe index
message_bytesNumber of bytes to enqueue
Returns
true if free space >= message_bytes and engaged
Note
Uses SVC to read message_pipe_list from DTCM in privileged mode

Check if pipe can accept data (SVC call gate)

Note
Runs in privileged mode — safe once DTCM is priv-only

Definition at line 988 of file svc.c.

References __pipe_can_enqueue(), and SVC_PIPE_CAN_ENQUEUE.

Referenced by __pipe_enqueue().

◆ pipe_dequeue()

bool pipe_dequeue ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Dequeue bytes from pipe.

Parameters
pipe_idxPipe index
messageBuffer to receive data
message_bytesNumber of bytes to read
Returns
true on success
Note
Blocks if insufficient data
Placed in ITCM for zero wait-state execution

Dequeue bytes from pipe.

Definition at line 894 of file svc.c.

References __pipe_dequeue().

◆ pipe_enqueue()

bool pipe_enqueue ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Enqueue bytes to pipe.

Parameters
pipe_idxPipe index
messageData to enqueue
message_bytesNumber of bytes
Returns
true on success
Note
Blocks if insufficient space
Placed in ITCM for zero wait-state execution

Enqueue bytes to pipe.

Definition at line 887 of file svc.c.

References __pipe_enqueue().

◆ pipe_get_count()

uint16_t pipe_get_count ( uint8_t  pipe_idx)

Get current byte count in pipe.

Parameters
pipe_idxPipe index
Returns
Current count, or 0 if invalid

Definition at line 901 of file svc.c.

References __pipe_get_count(), and SVC_PIPE_GET_COUNT.

◆ pipe_get_max_count()

uint16_t pipe_get_max_count ( uint8_t  pipe_idx)

Get pipe capacity.

Parameters
pipe_idxPipe index
Returns
Maximum capacity, or 0 if invalid

Definition at line 921 of file svc.c.

References __pipe_get_max_count(), and SVC_PIPE_GET_MAX_COUNT.

◆ pipe_init()

bool pipe_init ( uint8_t  pipe_idx,
uint16_t  pipe_capacity_bytes 
)

Initialize a message pipe.

Parameters
pipe_idxPipe index (0 to ICARUS_MAX_MESSAGE_QUEUES-1)
pipe_capacity_bytesMaximum bytes the pipe can hold
Returns
true on success, false on error

Definition at line 865 of file svc.c.

References __pipe_init(), and SVC_PIPE_INIT.

◆ pipe_read_bytes()

void pipe_read_bytes ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Read bytes from pipe (SVC call gate)

Parameters
pipe_idxPipe index
messagePointer to buffer for message data
message_bytesNumber of bytes to read
Note
Uses SVC to read message_pipe_list in DTCM from privileged mode
Called after pipe_can_dequeue() spin loop exits

Read bytes from pipe (SVC call gate)

Note
Called after pipe_can_dequeue() spin loop exits

Definition at line 1095 of file svc.c.

References __pipe_read_bytes(), and SVC_PIPE_READ_BYTES.

Referenced by __pipe_dequeue().

◆ pipe_write_bytes()

void pipe_write_bytes ( uint8_t  pipe_idx,
uint8_t *  message,
uint8_t  message_bytes 
)

Write bytes to pipe (SVC call gate)

Parameters
pipe_idxPipe index
messagePointer to message data
message_bytesNumber of bytes to write
Note
Uses SVC to write message_pipe_list in DTCM from privileged mode
Called after pipe_can_enqueue() spin loop exits

Write bytes to pipe (SVC call gate)

Note
Called after pipe_can_enqueue() spin loop exits

Definition at line 1074 of file svc.c.

References __pipe_write_bytes(), and SVC_PIPE_WRITE_BYTES.

Referenced by __pipe_enqueue().