picofuse

Modules | Files | Macros | Typedefs | Enumerations | Variables
System

The System module provides the runtime foundation used by higher-level Picofuse components. More...

Collaboration diagram for System:

Modules

 Memory
 Memory allocation primitives: arenas and the default heap wrappers built on them.
 
 Events
 The core event transport abstraction used by runloops and other producer/consumer workflows.
 
 Synchronization
 Mutexes, condition variables, wait groups, and atomic values used to coordinate access to shared state across threads.
 
 Data types and utilities
 Runes and strings, the flag-driven scanner built on them, and the stream I/O they read from.
 
 Execution
 Runtime execution: threads, pausing/stopping the process, and environment/signal integration.
 

Files

file  assert.h
 Defines a custom assertion macro.
 
file  init.h
 System initialization and cleanup hooks.
 
file  panicf.h
 Defines the sys_panicf function for formatted panic messages.
 

Macros

#define sys_assert(condition)
 Asserts that a condition is true. More...
 

Typedefs

typedef enum sys_stdio_t sys_stdio_t
 Standard input/output backend types.
 

Enumerations

enum  sys_stdio_t { sys_stdio_none = 0, sys_stdio_uart, sys_stdio_usb, sys_stdio_rtt }
 Standard input/output backend types. More...
 

Variables

sys_iostream_tsys_stdout
 Standard output stream. More...
 
sys_iostream_tsys_stdin
 Standard input stream. More...
 

Lifecycle

void sys_init (int argc, char *argv[], size_t arena_size, sys_stdio_t stdio)
 Initializes the system on startup. More...
 
void sys_exit (void)
 Cleans up the system on shutdown.
 

Detailed Description

The System module provides the runtime foundation used by higher-level Picofuse components.

It includes cross-platform abstractions for memory, threading, synchronization, timing, event queues, runloops, diagnostics, environment metadata, and process control.

Macro Definition Documentation

◆ sys_assert

#define sys_assert (   condition)
Value:
do { \
if (!(condition)) { \
sys_panicf("[ASSERT] FAIL: %s, file %s, line %d", #condition, __FILE__, \
__LINE__); \
} \
} while (0)

Asserts that a condition is true.

Parameters
conditionThe condition to check.

If the condition is false, it will call panicf with an assertion failure message, including the condition, file name, and line number.

Definition at line 21 of file assert.h.

Enumeration Type Documentation

◆ sys_stdio_t

Standard input/output backend types.

Enumerator
sys_stdio_none 

No standard input/output backend.

sys_stdio_uart 

UART standard input/output backend.

sys_stdio_usb 

USB standard input/output backend.

sys_stdio_rtt 

SEGGER RTT standard input/output backend.

Definition at line 20 of file stdio.h.

20  {
22  sys_stdio_none = 0,
29 } sys_stdio_t;
SEGGER RTT standard input/output backend.
Definition: stdio.h:28
sys_stdio_t
Standard input/output backend types.
Definition: stdio.h:20
USB standard input/output backend.
Definition: stdio.h:26
No standard input/output backend.
Definition: stdio.h:22
UART standard input/output backend.
Definition: stdio.h:24

Function Documentation

◆ sys_init()

void sys_init ( int  argc,
char *  argv[],
size_t  arena_size,
sys_stdio_t  stdio 
)

Initializes the system on startup.

Parameters
argcArgument count, as passed to main().
argvArgument vector, as passed to main(). On platforms with no real command line (such as Pico), pass 0/NULL; nothing reads them.
arena_sizeCapacity in bytes for the default arena backing sys_malloc()/sys_calloc()/sys_realloc()/sys_free() (see sys/mem.h), or 0 to leave them routed straight through to the system allocator instead.
stdioStandard input/output backend to initialize. Pass sys_stdio_none to select the platform default.

Variable Documentation

◆ sys_stdin

sys_iostream_t* sys_stdin

Standard input stream.

Set by sys_init(), or NULL if no input stream is available.

◆ sys_stdout

sys_iostream_t* sys_stdout

Standard output stream.

Set by sys_init(), or NULL if no output stream is available.