63 lines
1.6 KiB
C
63 lines
1.6 KiB
C
#ifndef __CONTEXT_H__
|
|
#define __CONTEXT_H__
|
|
|
|
#include <pthread.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "ptQueue/inc/spsc.h"
|
|
#include "wsServer/include/ws.h"
|
|
#include "ptQueue/inc/mpsc.h"
|
|
|
|
#include "linkedlist.h"
|
|
#include "sized_ptr.h"
|
|
|
|
#include "streamed.h"
|
|
#include "flatcc/flatcc_builder.h"
|
|
|
|
typedef struct {
|
|
SizedPtr* bufs;
|
|
uint8_t buffersCount;
|
|
CACHE_ALIGN _Atomic (uint8_t) readRequestIdx;
|
|
CACHE_ALIGN _Atomic (uint8_t) currWritingIdx;
|
|
} OutgoingBuffers;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
uint8_t* resetRequest;
|
|
uint8_t* emulState;
|
|
uint64_t* clockCounter;
|
|
uint64_t* tickTarget; // 0 = run indefinitely, >0 = auto-pause at this tick
|
|
LinkedListEntry** clientsHead;
|
|
uint8_t* utilizedFlag;
|
|
OutgoingBuffers* outBufs;
|
|
DeviceSegStreamReg** deviceStreamRegs;
|
|
uint8_t** devicesMem;
|
|
size_t** devicesMemSegAddrs;
|
|
size_t devicesCount;
|
|
void** deviceHandles; // device_handle_t** — dynamically loaded devices
|
|
void* interceptCtxs; // contiguous intercept_ctx_t array (freed as single block)
|
|
size_t interceptCtxCount;
|
|
flatcc_builder_t stream_builder;
|
|
uint64_t simRateLimit;
|
|
// Cached DeviceIdMappingNotif broadcast message (sent to newly authed clients)
|
|
uint8_t* deviceIdMappingMsg;
|
|
size_t deviceIdMappingMsgLen;
|
|
queue_mpsc_t* inMsgQueue;
|
|
queue_spsc_t* outMsgQueue;
|
|
} EmulContext;
|
|
|
|
|
|
typedef struct {
|
|
pthread_mutex_t registerMutex;
|
|
queue_spsc_t* regQueue;
|
|
queue_mpsc_t* inMsgQueue;
|
|
uint8_t* accessToken;
|
|
EmulContext* emulContext;
|
|
} ServerContext;
|
|
|
|
|
|
|
|
#endif //ifndef __CONTEXT_H__
|