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.c File Reference

ICARUS Message Pipe Implementation. More...

#include "icarus/pipe.h"
#include "icarus/kernel.h"
#include "icarus/scheduler.h"

Go to the source code of this file.

Functions

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 Message Pipe Implementation.

Version
0.1.0

Byte-stream message pipes for inter-task communication.

Author
Souham Biswas
Date
2025

Definition in file pipe.c.

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().