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>
48 lines
971 B
C
48 lines
971 B
C
#ifndef __CONTEXT_H__
|
|
#define __CONTEXT_H__
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "ptQueue/inc/ptQueue.h"
|
|
#include "wsServer/include/ws.h"
|
|
|
|
#include "linkedlist.h"
|
|
#include "sized_ptr.h"
|
|
|
|
#include "streamed.h"
|
|
#include "flatcc/flatcc_builder.h"
|
|
|
|
typedef struct {
|
|
SizedPtr* bufs;
|
|
uint8_t buffersCount;
|
|
_Atomic (uint8_t) readRequestIdx;
|
|
_Atomic (uint8_t) currWritingIdx;
|
|
} OutgoingBuffers;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
uint8_t* emulState;
|
|
uint64_t* clockCounter;
|
|
LinkedListEntry** clientsHead;
|
|
uint8_t* utilizedFlag;
|
|
OutgoingBuffers* outBufs;
|
|
DeviceSegStreamReg** deviceStreamRegs;
|
|
uint8_t** devicesMem;
|
|
size_t devicesCount;
|
|
void** deviceHandles; // device_handle_t** — dynamically loaded devices
|
|
flatcc_builder_t stream_builder;
|
|
} EmulContext;
|
|
|
|
|
|
typedef struct {
|
|
pthread_mutex_t registerMutex;
|
|
ptQueue* regQueue;
|
|
uint8_t* accessToken;
|
|
EmulContext* emulContext;
|
|
} ServerContext;
|
|
|
|
|
|
|
|
#endif //ifndef __CONTEXT_H__
|