60 lines
2.0 KiB
C
60 lines
2.0 KiB
C
#ifndef __DEVICE_H__
|
|
#define __DEVICE_H__
|
|
|
|
#include <stdint.h>
|
|
#include "runner.h"
|
|
#include "addrs.h"
|
|
#include "mem.h"
|
|
#include "instr.h"
|
|
#include <libhmmmm/config.h>
|
|
#include <libhmmmm/device.h>
|
|
#include <libhmmmm/mem.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
|
|
{
|
|
prog_counter_t* pc;
|
|
instr_h_func* instr;
|
|
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);
|
|
|
|
size_t pubExtractPcounter(device_public_context_t* devContext);
|
|
size_t pubExtractOpcode(device_mem_t* devMem, size_t _programCounter);
|
|
void* pubExtractPcounterPtr(device_public_context_t* devContext);
|
|
uint8_t pubExtractPcounterSizeWords();
|
|
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__
|
|
|