|
RPV Event driven kernel
|
Kernel core runtime shell with basic commands and stdio included. More...
Data Structures | |
| struct | command_s |
| Command descriptor structure. More... | |
| struct | console_key_s |
| Console key event data. More... | |
| union | evt_data_u |
| Event payload container. More... | |
| struct | service_s |
| Service descriptor structure. More... | |
Macros | |
| #define | _SHELL_COMMAND(name, callback) |
| Declares and registers a shell command. | |
| #define | SIG_SETMASK 0 |
| Replace current signal mask. | |
| #define | SIG_BLOCK 1 |
| Add signals to current mask (block). | |
| #define | SIG_UNBLOCK 2 |
| Remove signals from current mask (unblock). | |
| #define | SIGHUP 1 |
| Signal numeric identifiers. | |
| #define | _SERVICE(name, service_main) |
| Declares and registers a system service. | |
| #define | MAJOR (1) |
| Kernel version major number. | |
| #define | MINOR (0) |
| Kernel version minor number. | |
| #define | PATCH (0) |
| Kernel patch number. | |
| #define | REVISION ("alpha") |
| Kernel revision label. | |
Typedefs | |
| typedef struct command_s | command_t |
| Command descriptor type alias. | |
| typedef __sigset_t | sigset_t |
| Signal set type. | |
| typedef union evt_data_u | evt_data_t |
| Event payload alias. | |
| typedef struct console_key_s | console_key_t |
| Console key event payload alias. | |
| typedef void(* | evt_subscriber_t) (evt_data_t const *evtData) |
| Event subscriber callback prototype. | |
| typedef struct service_s | service_t |
| Service descriptor alias. | |
Enumerations | |
| enum | user_events_e { EVT_USERCON_KEY = 50 , EVT_SYS_USER_EVENTS } |
| User-level event identifiers. More... | |
| enum | kernel_events_e { EVT_ONESHOT_TICK , EVT_PERIODIC_TICK , EVT_KERNEL_DTC , EVT_KERNEL_EVENTS } |
| Kernel-level event identifiers. More... | |
Functions | |
| void | _kernel_pipeline (void) |
| Executes the kernel event pipeline. | |
| void | _kernel_pubEvt (uint8_t id, evt_data_t *data) |
| Publishes an event to the kernel event system. | |
| void | _kernel_subEvt (uint8_t id, evt_subscriber_t subscriber) |
| Registers a subscriber callback for a specific event. | |
| void | _kernel_exec_f (int(*exec_func)(const int argc, const char **argv), const int argc, const char **argv) |
| Executes a function in kernel context with argument forwarding. | |
| void const * | _kernel_service (void const *svc, char const **svc_name) |
| Retrieves next kernel service descriptor. | |
| int | _kernel_raise (int sgl) |
| Sends a signal to the current execution context. | |
| int | _kernel_sigpending (sigset_t *set) |
| Retrieves pending signals. | |
| int | _kernel_sigwait (const sigset_t *set, int *sgl) |
| Waits synchronously for a signal. | |
| int | _kernel_sigprocmask (int what, const sigset_t *set, sigset_t *oldset) |
| Examines or modifies signal mask. | |
| int | _kernel_sigemptyset (sigset_t *set) |
| Initializes a signal set to empty. | |
| int | _kernel_sigaddset (sigset_t *set, const int sgl) |
| Adds a signal to a set. | |
| bool | _kernel_sigismember (sigset_t *set, const int sgl) |
| Tests whether a signal is a member of a set. | |
| void | _kernel_stdio (void) |
| Initializes kernel standard I/O subsystem. | |
| void | _kernel_outLn (void) |
| Outputs a newline sequence. | |
| void | _kernel_outTab (void) |
| Outputs a horizontal tab. | |
| void | _kernel_outChar (const char code) |
| Outputs a single character. | |
| void | _kernel_outString (const char *str) |
| Outputs a null-terminated string. | |
| void | _kernel_outStringFormat (const char *fmt,...) |
| Outputs a formatted string. | |
| void | _kernel_stringFormat (char *s, char const *fmt,...) |
| Formats a string into a buffer. | |
| void | _kernel_vstringFormat (char *s, char const *fmt, va_list args) |
| Formats a string using a va_list argument. | |
| void | _kernel_getKey (console_key_t *key) |
| Retrieves a key event (blocking). | |
| bool | _kernel_tryGetKey (console_key_t *key) |
| Attempts to retrieve a key event (non-blocking). | |
| size_t | text_monitor (char const *s) |
| Outputs a null-terminated text string to the console. | |
| size_t | hex_monitor (void const *mem, const size_t s) |
| Outputs a memory region as hexadecimal values to the console. | |
| void | _shell_start (void) |
| Starts the system shell. | |
Kernel core runtime shell with basic commands and stdio included.
| #define _SERVICE | ( | name, | |
| service_main | |||
| ) |
Declares and registers a system service.
| name | Identifier of the service object. The same identifier string is used as the service name. |
| service_main | Pointer to the service entry function. |
Defines a static constant service_t instance and places it into the ".service_table" linker section.
The linker aggregates all registered services into a contiguous table that can be iterated during system services runtime.
The object is marked with the "used" attribute to prevent removal by linker garbage collection.
| #define _SHELL_COMMAND | ( | name, | |
| callback | |||
| ) |
Declares and registers a shell command.
Defines a static constant command_t instance and places it in the ".cmd_table" linker section.
The linker aggregates all such entries into a contiguous table used by the shell subsystem for command lookup.
| name | Identifier of the command object. The same identifier string is used as the command name. |
| callback | Pointer to the command handler function. |
| #define MAJOR (1) |
Kernel version major number.
Indicates the major version of the kernel. Incremented for incompatible API changes or major feature updates.
| #define MINOR (0) |
Kernel version minor number.
Indicates the minor version of the kernel. Incremented for backward-compatible functionality additions.
| #define PATCH (0) |
Kernel patch number.
Indicates the patch or bugfix level. Incremented for backward-compatible bug fixes or minor improvements.
| #define REVISION ("alpha") |
Kernel revision label.
Provides an optional string indicating the release stage (e.g., "alpha", "beta", "rc1", "stable").
| #define SIG_BLOCK 1 |
Add signals to current mask (block).
Used with _kernel_sigprocmask() to block specified signals.
| #define SIG_SETMASK 0 |
Replace current signal mask.
Used with _kernel_sigprocmask() to set the calling context's signal mask to the provided set.
| #define SIG_UNBLOCK 2 |
Remove signals from current mask (unblock).
Used with _kernel_sigprocmask() to unblock specified signals.
| #define SIGHUP 1 |
Signal numeric identifiers.
Defines supported kernel signal identifiers. Numeric values are implementation-defined but fixed for ABI compatibility. Hangup.
| typedef void(* evt_subscriber_t) (evt_data_t const *evtData) |
Event subscriber callback prototype.
| [in] | evtData | Pointer to event data payload. |
Function type for event subscribers registered with the kernel event dispatcher.
The meaning of evtData depends on the event identifier associated with the callback invocation.
| typedef __sigset_t sigset_t |
Signal set type.
Represents a bitmask of signals. Each bit corresponds to one signal number.
| enum kernel_events_e |
Kernel-level event identifiers.
Defines internal kernel event types generated by the kernel space services.
| enum user_events_e |
User-level event identifiers.
Defines event codes reserved for user-space
| Enumerator | |
|---|---|
| EVT_USERCON_KEY | Console key input event. |
| EVT_SYS_USER_EVENTS | Upper boundary marker for user events. |
| void _kernel_exec_f | ( | int(*)(const int argc, const char **argv) | exec_func, |
| const int | argc, | ||
| const char ** | argv | ||
| ) |
Executes a function in kernel context with argument forwarding.
| [in] | exec_func | Pointer to the function to execute. Must match the signature int func(int argc, const char **argv). |
| [in] | argc | Number of arguments to pass to the function. |
| [in] | argv | Array of null-terminated argument strings. |
This function provides a safe wrapper to execute a user-supplied function within kernel or privileged context, forwarding the specified arguments.
The provided function is expected to:
| void _kernel_getKey | ( | console_key_t * | key | ) |
Retrieves a key event (blocking).
| [out] | key | Structure receiving key information. |
Blocks until a console key event is available. Populates the provided console_key_t structure.
| void _kernel_outChar | ( | const char | code | ) |
Outputs a single character.
| [in] | code | Character to output. |
| void _kernel_outLn | ( | void | ) |
Outputs a newline sequence.
Advances output cursor to the next line.
| void _kernel_outString | ( | const char * | str | ) |
Outputs a null-terminated string.
| [in] | str | String to output. |
| void _kernel_outStringFormat | ( | const char * | fmt, |
| ... | |||
| ) |
Outputs a formatted string.
| [in] | fmt | Format string. |
| [in] | ... | Variable arguments. |
Formats the string according to implementation-defined formatting rules (printf-like) and writes it to output.
| void _kernel_outTab | ( | void | ) |
Outputs a horizontal tab.
Advances output cursor to the next tab stop.
| void _kernel_pipeline | ( | void | ) |
Executes the kernel event pipeline.
Processes all pending events in the kernel event queue, dispatching them to registered subscribers.
This function is typically called in the main kernel loop or from a dedicated event task.
| void _kernel_pubEvt | ( | uint8_t | id, |
| evt_data_t * | data | ||
| ) |
Publishes an event to the kernel event system.
| [in] | id | Event identifier (kernel or user event code). |
| [in] | data | Pointer to event data payload. |
Adds the event to the kernel event queue for later processing by _kernel_pipeline().
| int _kernel_raise | ( | int | sgl | ) |
Sends a signal to the current execution context.
| [in] | sgl | Signal number. |
| void const * _kernel_service | ( | void const * | svc, |
| char const ** | svc_name | ||
| ) |
Retrieves next kernel service descriptor.
| [in] | svc | Opaque pointer used for service table iteration. May be NULL to retrieve the first service. Then passing a service descriptor shall return a next one or NULL |
| [out] | svc_name | Pointer receiving the service name. |
Provides access to statically registered kernel services, typically stored in a dedicated linker section.
This function may be used to:
The iteration mechanism is implementation-defined. Commonly, callers pass NULL to obtain the first service and then pass the previously returned pointer to retrieve the next one.
| int _kernel_sigaddset | ( | sigset_t * | set, |
| const int | sgl | ||
| ) |
Adds a signal to a set.
| [in,out] | set | Signal set. |
| [in] | sgl | Signal number to add. |
| int _kernel_sigemptyset | ( | sigset_t * | set | ) |
Initializes a signal set to empty.
| [out] | set | Signal set to initialize. |
| bool _kernel_sigismember | ( | sigset_t * | set, |
| const int | sgl | ||
| ) |
Tests whether a signal is a member of a set.
| [in] | set | Signal set. |
| [in] | sgl | Signal number. |
| true | Signal is a member. |
| false | Signal is not a member. |
| int _kernel_sigpending | ( | sigset_t * | set | ) |
Retrieves pending signals.
| [out] | set | Signal set receiving pending signals. |
Examines or modifies signal mask.
| [in] | what | Operation type (SIG_SETMASK, SIG_BLOCK, SIG_UNBLOCK). |
| [in] | set | Signal set to apply. |
| [out] | oldset | Previous signal mask (may be NULL to retrieve old mask). |
| int _kernel_sigwait | ( | const sigset_t * | set, |
| int * | sgl | ||
| ) |
Waits synchronously for a signal.
| [in] | set | Signal set to wait for. |
| [out] | sgl | Pointer receiving delivered signal number. |
| void _kernel_stdio | ( | void | ) |
Initializes kernel standard I/O subsystem.
Prepares console output, input handling, and any required internal buffers. Must be invoked before using any _kernel_out* or input-related functions.
| void _kernel_stringFormat | ( | char * | s, |
| char const * | fmt, | ||
| ... | |||
| ) |
Formats a string into a buffer.
| [out] | s | Output buffer. |
| [in] | fmt | Format string. |
| [in] | ... | Variable arguments. |
Writes formatted output into the provided buffer. Buffer size management is implementation-defined.
| void _kernel_subEvt | ( | uint8_t | id, |
| evt_subscriber_t | subscriber | ||
| ) |
Registers a subscriber callback for a specific event.
| [in] | id | Event identifier to subscribe to. |
| [in] | subscriber | Function pointer to callback invoked when the event is published. |
Adds the subscriber to the internal subscription list for the specified event.
| bool _kernel_tryGetKey | ( | console_key_t * | key | ) |
Attempts to retrieve a key event (non-blocking).
| [out] | key | Structure receiving key information. |
| true | A key event was retrieved. |
| false | No key available. |
Non-blocking version of _kernel_getKey().
| void _kernel_vstringFormat | ( | char * | s, |
| char const * | fmt, | ||
| va_list | args | ||
| ) |
Formats a string using a va_list argument.
| [out] | s | Output buffer. |
| [in] | fmt | Format string. |
| [in] | args | Argument list. |
Equivalent to _kernel_stringFormat() but accepts a prebuilt va_list. Intended for internal use or wrapper functions.
| void _shell_start | ( | void | ) |
Starts the system shell.
Initializes and launches the shell or command-line interface subsystem. Typically, this function:
| size_t hex_monitor | ( | void const * | mem, |
| const size_t | s | ||
| ) |
Outputs a memory region as hexadecimal values to the console.
| [in] | mem | Pointer to memory buffer. |
| [in] | s | Size of memory region in bytes. |
| 0 | No output generated (e.g., mem is NULL or s == 0). |
Reads the specified memory region and writes its contents to the console formatted as hexadecimal values.
Output formatting (grouping, spacing, line width) is implementation-defined.
| size_t text_monitor | ( | char const * | s | ) |
Outputs a null-terminated text string to the console.
| [in] | s | Pointer to a null-terminated character string. |
| 0 | No characters written (e.g., s is NULL or empty string). |
Writes the provided string to the console output interface. The output device is implementation-defined (e.g., tty, VGA text mode, debug console).
The function stops writing upon encountering the null terminator.