feat: migrate config management from TOML to FlatBuffers
Config is now loaded at runtime via WebSocket (ConfigCtrlMessage) instead of from hardcoded TOML files. The emulator starts with no devices and waits for clients to send configuration. - Define FlatBuffers schemas: EmulationConfig, ComposeDeviceConfig, BaseDeviceConfig with recursive DeviceConfig union - Rename MemSegment.start → addr (flatcc builder/reader name collision) - Add ConfigCtrlMessage handler: validates STILL state, walks the device tree depth-first, assigns numeric IDs, responds with DeviceIdMappingNotif or ConfigLoadError - Add fb_build_config_device_id_mapping() and fb_build_config_error() FlatBuffer builders - Remove hardcoded device loading from main.c; iterate dynamically loaded devices in the exec loop - Fix double-free: freeConf() already frees the struct itself, remove redundant free() calls in config.c and base_device.c - Fix heap-buffer-overflow in device parseSpecsFromConfig: malloc for segment name was missing +1 for the null terminator Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,17 +4,22 @@ include "clock.fbs";
|
||||
|
||||
namespace hmmmm.config;
|
||||
|
||||
// Top-level emulator / system configuration.
|
||||
// Equivalent to glob.toml — describes a full composite device tree.
|
||||
//
|
||||
// File use: flatcc -a config/config.fbs → binary system config files
|
||||
// WS use: embed in ConfigCtrlMessage when config-change protocol is ready
|
||||
// Top-level emulation configuration sent by the client via ConfigCtrlMessage.
|
||||
// Contains the root composite device and simulation parameters.
|
||||
table EmulationConfig {
|
||||
sim_rate_limit: uint64; // max virtual-seconds per real-second (0 = unlimited)
|
||||
root_id: string; // ID of the root compose device
|
||||
root: ComposeDeviceConfig; // the root device tree
|
||||
mem_setup: [MemSetup]; // firmware / memory init instructions
|
||||
}
|
||||
|
||||
// Legacy: flat system configuration for standalone config files.
|
||||
table SystemConfig {
|
||||
devices: [DeviceEntry]; // ordered list; id must be unique
|
||||
devices: [DeviceEntry];
|
||||
clock: ClockConfig;
|
||||
projections: [Projection];
|
||||
intercepts: [Intercept];
|
||||
mem_setup: [MemSetup];
|
||||
}
|
||||
|
||||
root_type SystemConfig;
|
||||
root_type EmulationConfig;
|
||||
|
||||
Reference in New Issue
Block a user