20#ifndef ICARUS_TABLES_H
21#define ICARUS_TABLES_H
32#define TBL_MAX_REGISTERED 8
33#define TBL_MAX_SIZE 512
34#define TBL_NAME_LEN 12
131 uint16_t len, uint16_t schema_crc);
Static descriptor registered by a table producer.
uint16_t size
Expected table size in bytes
tbl_activate_fn activate
Callback on tbl_activate()
tbl_id_t id
Unique table identifier
uint16_t schema_crc
Expected schema CRC
#define TBL_NAME_LEN
Maximum name length (incl.
const tbl_descriptor_t * tbl_get_descriptor(tbl_id_t id)
Look up a registered descriptor by id.
bool tbl_activate(tbl_id_t id)
Activate a staged table after CRC validation.
bool __tbl_load(tbl_id_t id, const uint8_t *data, uint16_t len, uint16_t schema_crc)
uint8_t tbl_id_t
Generic table identifier.
uint8_t __tbl_count(void)
void tbl_init(void)
Initialise the table registry.
bool tbl_register(const tbl_descriptor_t *desc)
Register a table descriptor.
bool __tbl_register(const tbl_descriptor_t *desc)
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.
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.
int16_t __tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max)
bool(* tbl_activate_fn)(const void *data, uint16_t len)
Callback invoked when a staged table passes all CRC checks.
bool __tbl_activate_commit(tbl_id_t id, const uint8_t *data, uint16_t len)
Commit a previously prepared table into the active buffer.
const tbl_descriptor_t * __tbl_get_descriptor(tbl_id_t id)
uint8_t tbl_count(void)
Return the number of registered tables.
int16_t tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max)
Copy the active table bytes into out.