Initial commit

This commit is contained in:
2025-01-19 14:31:35 +03:00
commit 216db38825
10 changed files with 947 additions and 0 deletions

52
inc/device.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <stdint.h>
#include "runner.h"
#include "addrs.h"
#include "mem.h"
#include "../../../inc/config.h"
#include "../../../inc/libhmmmm.h"
#include "../../../inc/libdevice.h"
#define SMART_ADDR_TYPE_GLOBAL 1
#define SMART_ADDR_TYPE_SEGMENTED 2
typedef struct
{
memseg_spec_t** memSpecs;
uint8_t memSpecsCount;
uint64_t pcAddr;
uint8_t* executableSegments;
uint8_t executableSegmentsCount;
smart_read_spec_t* smartReadSpecs;
uint64_t smartReadSpecsCount;
smart_write_spec_t* smartWriteSpecs;
uint64_t smartWriteSpecsCount;
} device_specs_t;
typedef struct
{
device_mem_t* deviceMem;
device_specs_t* specs;
} device_info_t;
// device_public_context_t* init(device_specs_t* specs, smart_read_spec_t* smartReadSpecs, uint64_t smartReadSpecsCount, smart_write_spec_t* smartWriteSpecs, uint64_t smartWriteSpecsCount);
device_public_context_t* init(device_specs_t* specs, char* errbuf);
device_public_context_t* initDefault(smart_read_spec_t* smartReadSpecs, uint64_t smartReadSpecsCount, smart_write_spec_t* smartWriteSpecs, uint64_t smartWriteSpecsCount, char* errbuf);
uint8_t makeDeviceTick(device_public_context_t* devContext);
device_mem_t* genDevMem(device_specs_t* devSpec, char* errbuf);
device_specs_t* parseSpecsFromConfig(const conf_dev_t* devConf, char* errbuf);
void fillSmartReadSpecs(device_specs_t* specs, smart_read_spec_t* smartReadSpecs, uint64_t smartReadSpecsCount);
void fillSmartWriteSpecs(device_specs_t* specs, smart_write_spec_t* smartWriteSpecs, uint64_t smartWriteSpecsCount);
void freeDevSpec(void* specs);
void freeDevMem(device_mem_t* devMem);
#endif // ifndef __DEVICE_H__