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
event.h File Reference

Generic structured event ring buffer for ICARUS OS. More...

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

Go to the source code of this file.

Data Structures

struct  event_entry_t
 

Macros

#define EVENT_MOD_MAX   16
 
#define EVENT_RING_SIZE   32
 

Enumerations

enum  event_severity_t { EVENT_DEBUG = 0 , EVENT_INFO = 1 , EVENT_WARN = 2 , EVENT_CRITICAL = 3 }
 

Functions

void event_init (void)
 Initialize the event system.
 
void os_event (uint8_t module_id, event_severity_t severity, uint16_t event_id, const void *payload, uint8_t payload_len)
 Emit a structured event into the ring buffer.
 
void event_set_squelch (uint8_t module_id, event_severity_t min_severity)
 Set the minimum severity accepted for a given module.
 
event_severity_t event_get_squelch (uint8_t module_id)
 Get the current squelch level for a given module.
 
bool event_drain (event_entry_t *out_buf, uint8_t max_entries, uint8_t *num_drained)
 Drain queued events into a caller-provided buffer.
 
uint32_t event_get_count (void)
 Number of events currently buffered.
 
void __event_init (void)
 
void __os_event (uint8_t module_id, event_severity_t severity, uint16_t event_id, const void *payload, uint8_t payload_len)
 
void __event_set_squelch (uint8_t module_id, event_severity_t min_severity)
 
event_severity_t __event_get_squelch (uint8_t module_id)
 
bool __event_drain (event_entry_t *out_buf, uint8_t max_entries, uint8_t *num_drained)
 
uint32_t __event_get_count (void)
 

Detailed Description

Generic structured event ring buffer for ICARUS OS.

Lock-protected ring of fixed-size 16-byte event entries with per-module severity squelch filtering. Transport-agnostic: drains into a caller-provided buffer; downstream consumers decide how to ship the entries (e.g. CCSDS TM, file logging).

Author
Souham Biswas
Date
2026

Definition in file event.h.

Macro Definition Documentation

◆ EVENT_MOD_MAX

#define EVENT_MOD_MAX   16

Definition at line 40 of file event.h.

◆ EVENT_RING_SIZE

#define EVENT_RING_SIZE   32

Definition at line 44 of file event.h.

Enumeration Type Documentation

◆ event_severity_t

Enumerator
EVENT_DEBUG 
EVENT_INFO 
EVENT_WARN 
EVENT_CRITICAL 

Definition at line 30 of file event.h.

Function Documentation

◆ __event_drain()

bool __event_drain ( event_entry_t out_buf,
uint8_t  max_entries,
uint8_t *  num_drained 
)

Definition at line 88 of file event.c.

References EVENT_RING_SIZE, ring, ring_count, and ring_head.

Referenced by event_drain(), and SVC_Handler_C().

◆ __event_get_count()

uint32_t __event_get_count ( void  )

Definition at line 133 of file event.c.

References ring_count.

Referenced by event_get_count(), and SVC_Handler_C().

◆ __event_get_squelch()

event_severity_t __event_get_squelch ( uint8_t  module_id)

Definition at line 81 of file event.c.

References EVENT_DEBUG, EVENT_MOD_MAX, and squelch.

Referenced by event_get_squelch(), and SVC_Handler_C().

◆ __event_init()

void __event_init ( void  )

Definition at line 34 of file event.c.

References EVENT_DEBUG, EVENT_MOD_MAX, ring, ring_count, ring_head, and squelch.

Referenced by event_init(), and SVC_Handler_C().

◆ __event_set_squelch()

void __event_set_squelch ( uint8_t  module_id,
event_severity_t  min_severity 
)

Definition at line 73 of file event.c.

References EVENT_MOD_MAX, and squelch.

Referenced by event_set_squelch(), and SVC_Handler_C().

◆ __os_event()

void __os_event ( uint8_t  module_id,
event_severity_t  severity,
uint16_t  event_id,
const void *  payload,
uint8_t  payload_len 
)

◆ event_drain()

bool event_drain ( event_entry_t out_buf,
uint8_t  max_entries,
uint8_t *  num_drained 
)

Drain queued events into a caller-provided buffer.

Parameters
out_bufDestination array of event_entry_t.
max_entriesMaximum number of entries to copy.
num_drained[out] Number of entries actually copied.
Returns
true if at least one entry was copied; false if the ring was empty or out_buf was NULL.

Definition at line 1385 of file svc.c.

References __event_drain(), and SVC_EVENT_DRAIN.

◆ event_get_count()

uint32_t event_get_count ( void  )

Number of events currently buffered.

Definition at line 1408 of file svc.c.

References __event_get_count(), and SVC_EVENT_GET_COUNT.

◆ event_get_squelch()

event_severity_t event_get_squelch ( uint8_t  module_id)

Get the current squelch level for a given module.

Definition at line 1368 of file svc.c.

References __event_get_squelch(), and SVC_EVENT_GET_SQUELCH.

◆ event_init()

void event_init ( void  )

Initialize the event system.

Clears the ring buffer and resets every module's squelch level to EVENT_DEBUG (accept all).

Definition at line 1316 of file svc.c.

References __event_init(), and SVC_EVENT_INIT.

◆ event_set_squelch()

void event_set_squelch ( uint8_t  module_id,
event_severity_t  min_severity 
)

Set the minimum severity accepted for a given module.

Events below the threshold are silently dropped at emission time.

Definition at line 1352 of file svc.c.

References __event_set_squelch(), and SVC_EVENT_SET_SQUELCH.

◆ os_event()

void os_event ( uint8_t  module_id,
event_severity_t  severity,
uint16_t  event_id,
const void *  payload,
uint8_t  payload_len 
)

Emit a structured event into the ring buffer.

Parameters
module_idSource module identifier (0..EVENT_MOD_MAX-1).
severityEvent severity level.
event_idApplication-defined event identifier.
payloadOptional payload bytes (may be NULL).
payload_lenPayload length in bytes (truncated to 12).
Note
Never blocks. When the ring is full the oldest entry is implicitly overwritten.

Definition at line 1331 of file svc.c.

References __os_event(), and SVC_OS_EVENT.