93 (void)memset(slot, 0,
sizeof(*slot));
101 uint16_t schema_crc) {
102 if ((data == NULL) || (len == 0u)) {
142 if ((out_data == NULL) || (out_len == NULL) || (out_activate == NULL)) {
178 if ((data == NULL) || (len == 0u) || (len > (uint16_t)
TBL_MAX_SIZE)) {
185 (void)memcpy(slot->
active, data, len);
191 if ((out == NULL) || (max == 0u)) {
207 (void)memcpy(out, slot->
active, len);
213 return slot ? &slot->
desc : NULL;
uint16_t crc16_ccitt(const uint8_t *data, uint16_t len)
Compute CRC16-CCITT (poly 0x1021, init 0xFFFF) over a byte buffer.
ICARUS OS - Main API Header.
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
char name[12]
Human-readable name
uint16_t schema_crc
Expected schema CRC
uint16_t staged_len
Bytes written to staging so far
uint16_t active_len
Bytes in active buffer (0 = none)
uint16_t staged_schema_crc
schema_crc supplied with last tbl_load()
uint16_t staged_data_crc
CRC16 computed over the full staged data.
bool staged_valid
True once a full-size load completed
bool __tbl_load(tbl_id_t id, const uint8_t *data, uint16_t len, uint16_t schema_crc)
uint8_t __tbl_count(void)
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.
int16_t __tbl_dump(tbl_id_t id, uint8_t *out, uint16_t max)
static tbl_slot_t registry[8]
bool __tbl_activate_commit(tbl_id_t id, const uint8_t *data, uint16_t len)
Commit a previously prepared table into the active buffer.
static tbl_slot_t * find_slot(tbl_id_t id)
const tbl_descriptor_t * __tbl_get_descriptor(tbl_id_t id)
#define TBL_NAME_LEN
Maximum name length (incl.
uint8_t tbl_id_t
Generic table identifier.
#define TBL_MAX_REGISTERED
Maximum number of registered tables
#define TBL_MAX_SIZE
Maximum bytes per table buffer
bool(* tbl_activate_fn)(const void *data, uint16_t len)
Callback invoked when a staged table passes all CRC checks.