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
tables.h
Go to the documentation of this file.
1
20#ifndef ICARUS_TABLES_H
21#define ICARUS_TABLES_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stdint.h>
28#include <stdbool.h>
29
30/* ---- Configuration constants -------------------------------------------- */
31
32#define TBL_MAX_REGISTERED 8
33#define TBL_MAX_SIZE 512
34#define TBL_NAME_LEN 12
36/* ---- Generic table id ---------------------------------------------------- */
37
43typedef uint8_t tbl_id_t;
44
45/* ---- Descriptor --------------------------------------------------------- */
46
54typedef bool (*tbl_activate_fn)(const void *data, uint16_t len);
55
59typedef struct {
61 char name[TBL_NAME_LEN];
62 uint16_t size;
63 uint16_t schema_crc;
66
67/* ---- API ---------------------------------------------------------------- */
68
73void tbl_init(void);
74
79bool tbl_register(const tbl_descriptor_t *desc);
80
91bool tbl_load(tbl_id_t id, const uint8_t *data, uint16_t len,
92 uint16_t schema_crc);
93
107bool tbl_activate(tbl_id_t id);
108
113int16_t tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max);
114
120
124uint8_t tbl_count(void);
125
126/* ---- Privileged implementations (internal — do not call directly) ----- */
127
128void __tbl_init(void);
129bool __tbl_register(const tbl_descriptor_t *desc);
130bool __tbl_load(tbl_id_t id, const uint8_t *data,
131 uint16_t len, uint16_t schema_crc);
143bool __tbl_activate_prepare(tbl_id_t id, uint8_t *out_data,
144 uint16_t *out_len,
145 tbl_activate_fn *out_activate);
150bool __tbl_activate_commit(tbl_id_t id, const uint8_t *data,
151 uint16_t len);
152int16_t __tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max);
154uint8_t __tbl_count(void);
155
156#ifdef __cplusplus
157}
158#endif
159
160#endif /* ICARUS_TABLES_H */
Static descriptor registered by a table producer.
Definition tables.h:59
uint16_t size
Expected table size in bytes
Definition tables.h:62
tbl_activate_fn activate
Callback on tbl_activate()
Definition tables.h:64
tbl_id_t id
Unique table identifier
Definition tables.h:60
uint16_t schema_crc
Expected schema CRC
Definition tables.h:63
#define TBL_NAME_LEN
Maximum name length (incl.
Definition tables.h:34
const tbl_descriptor_t * tbl_get_descriptor(tbl_id_t id)
Look up a registered descriptor by id.
Definition svc.c:1566
bool tbl_activate(tbl_id_t id)
Activate a staged table after CRC validation.
Definition svc.c:1481
bool __tbl_load(tbl_id_t id, const uint8_t *data, uint16_t len, uint16_t schema_crc)
Definition tables.c:100
uint8_t tbl_id_t
Generic table identifier.
Definition tables.h:43
uint8_t __tbl_count(void)
Definition tables.c:216
void tbl_init(void)
Initialise the table registry.
Definition svc.c:1428
bool tbl_register(const tbl_descriptor_t *desc)
Register a table descriptor.
Definition svc.c:1436
bool __tbl_register(const tbl_descriptor_t *desc)
Definition tables.c:76
bool __tbl_activate_prepare(tbl_id_t id, uint8_t *out_data, uint16_t *out_len, tbl_activate_fn *out_activate)
Validate a staged table and copy it into a caller-provided scratch buffer for the activate callback.
Definition tables.c:139
bool tbl_load(tbl_id_t id, const uint8_t *data, uint16_t len, uint16_t schema_crc)
Load raw bytes into the staging buffer for a registered table.
Definition svc.c:1453
int16_t __tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max)
Definition tables.c:190
bool(* tbl_activate_fn)(const void *data, uint16_t len)
Callback invoked when a staged table passes all CRC checks.
Definition tables.h:54
bool __tbl_activate_commit(tbl_id_t id, const uint8_t *data, uint16_t len)
Commit a previously prepared table into the active buffer.
Definition tables.c:176
const tbl_descriptor_t * __tbl_get_descriptor(tbl_id_t id)
Definition tables.c:211
void __tbl_init(void)
Definition tables.c:71
uint8_t tbl_count(void)
Return the number of registered tables.
Definition svc.c:1583
int16_t tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max)
Copy the active table bytes into out.
Definition svc.c:1546