diff --git a/inc/mem_seg.h b/inc/mem_seg.h index 27112e3..ffc8b47 100644 --- a/inc/mem_seg.h +++ b/inc/mem_seg.h @@ -1,6 +1,9 @@ #ifndef __MEM_SEG_H__ #define __MEM_SEG_H__ +#ifndef DEVICE_TYPE +#define DEVICE_TYPE EXTENDED_DEVICE_TYPE_DUMMY +#endif // #define MEMSEG_PC_SEG_NUM 0 // #define MEMSEG_PC_ADDR 0 diff --git a/manifest_src/gen_manifest_json.py b/manifest_src/gen_manifest_json.py index 1eda334..a1baf99 100644 --- a/manifest_src/gen_manifest_json.py +++ b/manifest_src/gen_manifest_json.py @@ -8,9 +8,14 @@ def main(): return manifest_dir = sys.argv[1] + with open(manifest_dir + '/dev_type', 'r') as f: + dev_type = f.read() + + mem_segments = [] out_manifest = { - 'mem_segments': mem_segments + 'mem_segments': mem_segments, + 'dev_type': dev_type } with open(manifest_dir + '/seg_data.csv', 'r', newline='') as csvfile: diff --git a/manifest_src/generate_dev_type.c b/manifest_src/generate_dev_type.c new file mode 100644 index 0000000..1eeca5d --- /dev/null +++ b/manifest_src/generate_dev_type.c @@ -0,0 +1,65 @@ +#include "mem.h" +#include "mem_seg.h" +#include +#include +#include +#include + + +int main(int argc, char** argv) +{ + if(argc != 2) + { + printf("provide target directory\n"); + return 1; + } + + const char *dirpath = argv[1]; + const char *filename = "dev_type"; + + char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 1, sizeof(char)); + if(tgtpath == NULL) + { + return 1; + } + + sprintf(tgtpath, "%s/%s", dirpath, filename); + + FILE *fptr; + + fptr = fopen(tgtpath, "w"); + + if(fptr == NULL) + { + printf("errof opening file\n"); + return 1; + } + + int dev_type = DEVICE_TYPE; + int exitcode = 0; + + switch (dev_type) + { + case EXTENDED_DEVICE_TYPE_DUMMY: + { + fprintf(fptr, "dummy"); + break; + } + case EXTENDED_DEVICE_TYPE_INSTR_SIMUL: + { + fprintf(fptr, "instr_simul"); + break; + } + default: + { + printf("invalid device type: %d\n", dev_type); + exitcode = 1; + } + + } + + + fclose(fptr); + free(tgtpath); + return exitcode; +} \ No newline at end of file diff --git a/src/device.c b/src/device.c index c73b29a..2e77893 100644 --- a/src/device.c +++ b/src/device.c @@ -646,6 +646,6 @@ device_public_context_t* init(device_specs_t* specs, char* errbuf) uint8_t pubDeviceType() { - return EXTENDED_DEVICE_TYPE_DUMMY; + return DEVICE_TYPE; }