|
ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
|
Software Bus — publish/subscribe message router implementation. More...
Go to the source code of this file.
Data Structures | |
| struct | sb_route_t |
| Single route entry: one msg_id → up to SB_MAX_SUBS_PER_MSG pipes. More... | |
Functions | |
| static sb_route_t * | find_route (sb_msg_id_t msg_id) |
Find the route entry for msg_id. | |
| static sb_route_t * | alloc_route (void) |
| Allocate a fresh route slot. | |
| void | __sb_init (void) |
| Privileged implementation of sb_init(). | |
| bool | __sb_subscribe (sb_msg_id_t msg_id, uint8_t pipe_idx) |
| Privileged implementation of sb_subscribe(). | |
| bool | __sb_unsubscribe (sb_msg_id_t msg_id, uint8_t pipe_idx) |
| Privileged implementation of sb_unsubscribe(). | |
| uint8_t | __sb_publish (sb_msg_id_t msg_id, const uint8_t *data, uint8_t len) |
| Privileged implementation of sb_publish(). | |
| uint8_t | __sb_subscriber_count (sb_msg_id_t msg_id) |
| Privileged implementation of sb_subscriber_count(). | |
| uint8_t | __sb_route_count (void) |
| Privileged implementation of sb_route_count(). | |
| void | sb_init (void) |
| Initialize the software bus via SVC gate. | |
| bool | sb_subscribe (sb_msg_id_t msg_id, uint8_t pipe_idx) |
| Subscribe a pipe to a message ID via SVC gate. | |
| bool | sb_unsubscribe (sb_msg_id_t msg_id, uint8_t pipe_idx) |
| Remove a subscription via SVC gate. | |
| uint8_t | sb_publish (sb_msg_id_t msg_id, const uint8_t *data, uint8_t len) |
| Publish a message to all subscribers via SVC gate. | |
| uint8_t | sb_subscriber_count (sb_msg_id_t msg_id) |
| Return the subscriber count for a message ID via SVC gate. | |
| uint8_t | sb_route_count (void) |
| Return the total route count via SVC gate. | |
Variables | |
| static sb_route_t | routes [32] |
| Route table — privileged DTCM, zero wait-state. | |
| static uint8_t | route_used |
| Number of route slots in use. | |
Software Bus — publish/subscribe message router implementation.
Static routing table mapping msg_id → pipe_idx[]. Publishing iterates subscribers and enqueues into each pipe that has space.
All mutable state lives in DTCM_DATA_PRIV (privileged-only, zero wait-state on Cortex-M7). All functions are placed in ITCM_FUNC for zero wait-state instruction fetch. Public access goes through SVC call gates; the __-prefixed functions are the privileged implementations.
Definition in file sb.c.
| void __sb_init | ( | void | ) |
Privileged implementation of sb_init().
Zeroes the entire route table and resets the used counter.
Definition at line 93 of file sb.c.
References route_used, and routes.
Referenced by sb_init(), and SVC_Handler_C().
| uint8_t __sb_publish | ( | sb_msg_id_t | msg_id, |
| const uint8_t * | data, | ||
| uint8_t | len | ||
| ) |
Privileged implementation of sb_publish().
| [in] | msg_id | Message identifier. |
| [in] | data | Payload bytes. |
| [in] | len | Payload length. |
Iterates all subscribers for msg_id. For each pipe, checks capacity via pipe_can_enqueue() before writing. Pipes that are full are silently skipped (best-effort).
Definition at line 173 of file sb.c.
References __pipe_can_enqueue(), __pipe_write_bytes(), sb_route_t::count, find_route(), and sb_route_t::pipes.
Referenced by sb_publish(), and SVC_Handler_C().
| uint8_t __sb_route_count | ( | void | ) |
Privileged implementation of sb_route_count().
Definition at line 209 of file sb.c.
References route_used.
Referenced by sb_route_count(), and SVC_Handler_C().
| bool __sb_subscribe | ( | sb_msg_id_t | msg_id, |
| uint8_t | pipe_idx | ||
| ) |
Privileged implementation of sb_subscribe().
| [in] | msg_id | Message identifier. |
| [in] | pipe_idx | Kernel pipe index to bind. |
| true | Subscription added. |
| false | Table full, subscriber limit hit, or duplicate pair. |
If no route exists for msg_id a new slot is allocated. Duplicate (msg_id, pipe_idx) pairs are rejected to prevent double-delivery.
Definition at line 110 of file sb.c.
References alloc_route(), sb_route_t::count, find_route(), sb_route_t::msg_id, sb_route_t::pipes, and SB_MAX_SUBS_PER_MSG.
Referenced by sb_subscribe(), and SVC_Handler_C().
| uint8_t __sb_subscriber_count | ( | sb_msg_id_t | msg_id | ) |
Privileged implementation of sb_subscriber_count().
| [in] | msg_id | Message identifier. |
Definition at line 200 of file sb.c.
References sb_route_t::count, and find_route().
Referenced by sb_subscriber_count(), and SVC_Handler_C().
| bool __sb_unsubscribe | ( | sb_msg_id_t | msg_id, |
| uint8_t | pipe_idx | ||
| ) |
Privileged implementation of sb_unsubscribe().
| [in] | msg_id | Message identifier. |
| [in] | pipe_idx | Pipe to remove. |
| true | Subscription found and removed (last-swap compaction). |
| false | No matching subscription. |
Definition at line 144 of file sb.c.
References sb_route_t::count, find_route(), and sb_route_t::pipes.
Referenced by sb_unsubscribe(), and SVC_Handler_C().
|
static |
Allocate a fresh route slot.
Definition at line 75 of file sb.c.
References route_used, routes, SB_MAX_ROUTES, and sb_route_t::used.
Referenced by __sb_subscribe().
|
static |
Find the route entry for msg_id.
Definition at line 61 of file sb.c.
References route_used, and routes.
Referenced by __sb_publish(), __sb_subscribe(), __sb_subscriber_count(), and __sb_unsubscribe().
| void sb_init | ( | void | ) |
Initialize the software bus via SVC gate.
Initialize the software bus.
Clears all routes in privileged mode.
Definition at line 221 of file sb.c.
References __sb_init(), and SVC_SB_INIT.
| uint8_t sb_publish | ( | sb_msg_id_t | msg_id, |
| const uint8_t * | data, | ||
| uint8_t | len | ||
| ) |
Publish a message to all subscribers via SVC gate.
Publish a message to all subscribers of msg_id.
| [in] | msg_id | Message identifier. |
| [in] | data | Payload bytes. |
| [in] | len | Payload length. |
Definition at line 288 of file sb.c.
References __sb_publish(), and SVC_SB_PUBLISH.
| uint8_t sb_route_count | ( | void | ) |
Return the total route count via SVC gate.
Return the total number of route entries in use.
Definition at line 334 of file sb.c.
References __sb_route_count(), and SVC_SB_ROUTE_COUNT.
| bool sb_subscribe | ( | sb_msg_id_t | msg_id, |
| uint8_t | pipe_idx | ||
| ) |
Subscribe a pipe to a message ID via SVC gate.
Subscribe a pipe to a message ID.
| [in] | msg_id | Message identifier. |
| [in] | pipe_idx | Kernel pipe index. |
| true | Subscription added. |
| false | Table full, limit hit, or duplicate. |
Definition at line 236 of file sb.c.
References __sb_subscribe(), and SVC_SB_SUBSCRIBE.
| uint8_t sb_subscriber_count | ( | sb_msg_id_t | msg_id | ) |
Return the subscriber count for a message ID via SVC gate.
Return the number of active subscriptions for a message ID.
| [in] | msg_id | Message identifier. |
Definition at line 313 of file sb.c.
References __sb_subscriber_count(), and SVC_SB_SUBSCRIBER_COUNT.
| bool sb_unsubscribe | ( | sb_msg_id_t | msg_id, |
| uint8_t | pipe_idx | ||
| ) |
Remove a subscription via SVC gate.
Remove a subscription.
| [in] | msg_id | Message identifier. |
| [in] | pipe_idx | Pipe to unsubscribe. |
| true | Subscription found and removed. |
| false | No matching subscription. |
Definition at line 262 of file sb.c.
References __sb_unsubscribe(), and SVC_SB_UNSUBSCRIBE.
|
static |
Number of route slots in use.
Definition at line 50 of file sb.c.
Referenced by __sb_init(), __sb_route_count(), alloc_route(), and find_route().
|
static |
Route table — privileged DTCM, zero wait-state.
Definition at line 47 of file sb.c.
Referenced by __sb_init(), alloc_route(), and find_route().