From 7c5ff52457b8eb4678609772456621ba2408cdbb Mon Sep 17 00:00:00 2001 From: Milo-D Date: Mon, 6 Sep 2021 19:27:15 +0200 Subject: [PATCH] v.0.8.13 Now supporting the SREC format. --- CHANGELOG.md | 20 ++ README.md | 14 +- TODO.txt | 4 + driver/cfg/cfg.c | 4 +- driver/disasm/disasm.c | 4 +- driver/endloop/endloop.c | 4 +- driver/findgroup/findgroup.c | 4 +- driver/findisr/findisr.c | 4 +- driver/graph/graph.c | 4 +- driver/labels/labels.c | 4 +- driver/led/ledtest.c | 2 +- driver/occurence/occurence.c | 4 +- driver/rwaccess/rwaccess.c | 4 +- driver/sca/sca.c | 4 +- driver/sfr/sfr.c | 4 +- driver/skeleton/skeleton.c | 4 +- driver/speed/speed.c | 4 +- driver/stepper/stepper.c | 4 +- driver/strings/strings.c | 4 +- driver/vcdump/vcdump.c | 4 +- driver/vector/vector.c | 4 +- engine/include/analyzer/analyzer.h | 2 +- engine/include/annotator/annotator.h | 2 +- engine/include/decoder/decoder.h | 2 +- engine/include/decomposer/decomposer.h | 2 +- engine/include/disassembler/disassembler.h | 2 +- engine/include/libvmcu/libvmcu_analyzer.h | 48 ++-- engine/include/reader/fmt.h | 12 - engine/include/reader/format/ihex.h | 2 +- engine/include/reader/format/srec.h | 4 +- engine/include/reader/reader.h | 5 +- engine/include/reader/util/fmt.h | 17 ++ engine/src/analyzer/analyzer.c | 4 +- engine/src/annotator/annotator.c | 4 +- engine/src/decoder/decoder.c | 4 +- engine/src/decomposer/decomposer.c | 4 +- engine/src/disassembler/disassembler.c | 4 +- engine/src/reader/format/ihex.c | 4 +- engine/src/reader/format/srec.c | 253 +++++++++++++-------- engine/src/reader/reader.c | 10 +- engine/src/reader/util/fmt.c | 80 +++++++ test/integration/system/system_test.c | 10 +- 42 files changed, 375 insertions(+), 208 deletions(-) delete mode 100644 engine/include/reader/fmt.h create mode 100644 engine/include/reader/util/fmt.h create mode 100644 engine/src/reader/util/fmt.c diff --git a/CHANGELOG.md b/CHANGELOG.md index fb46272..b97bd8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ # Unreleased +- nothing to log + +# v.0.8.13 - 2021-09-06 + +- Now supporting Motorola SRecord + +- merged pull-request (#68) from pointbazaar (Alexander Hansen) + - added format reader for motorola hex (SRecord) + - thanks for that :) + +- refactored srec format reader (PR #68) + - adjusted style + - fixed some minor bugs + +- connected srec format reader to pipeline + +- Important: file extension decides which reader will be invoked + - *.hex ==> invokes intel hex reader + - *.srec ==> invokes srec reader + - added format reader interface (reader/reader.c) - reader for different file formats can be now added to reader/format/ - for example reader/format/ihex.c to read the intel hex format diff --git a/README.md b/README.md index 29d5804..819a971 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ int main(const int argc, const char **argv) { /* ignoring checks for this example */ vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p); + vmcu_report_t *report = vmcu_analyze_file("file.hex", m328p); for(uint32_t i = 0; i < report->cfg->used; i++) { @@ -127,7 +127,7 @@ int main(const int argc, const char **argv) { /* ignoring checks for this example */ vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p); + vmcu_report_t *report = vmcu_analyze_file("file.srec", m328p); for(uint32_t i = 0; i < report->progsize; i++) { @@ -161,7 +161,7 @@ int main(const int argc, const char **argv) { /* ignoring checks for this example */ vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p); + vmcu_report_t *report = vmcu_analyze_file("file.hex", m328p); for(uint32_t i = 0; i < report->progsize; i++) { @@ -195,7 +195,7 @@ int main(const int argc, const char **argv) { /* ignoring checks for this example */ vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p); + vmcu_report_t *report = vmcu_analyze_file("file.hex", m328p); for(uint32_t i = 0; i < report->n_vector; i++) { @@ -237,7 +237,7 @@ int main(const int argc, const char **argv) { /* ignoring checks for this example */ vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p); + vmcu_report_t *report = vmcu_analyze_file("file.hex", m328p); for(uint32_t i = 0; i < report->n_label; i++) { @@ -287,7 +287,7 @@ int main(const int argc, const char **argv) { /* ignoring checks for this example */ vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p); + vmcu_report_t *report = vmcu_analyze_file("file.hex", m328p); for(uint32_t i = 0; i < report->n_sfr; i++) { @@ -510,7 +510,7 @@ take a look at engine/*/arch/ - [ ] format reader - [x] intel hex - - [ ] motorola hex + - [x] motorola hex - [ ] bin - [ ] elf diff --git a/TODO.txt b/TODO.txt index d1eef59..fc240cf 100644 --- a/TODO.txt +++ b/TODO.txt @@ -32,6 +32,8 @@ These are a some of my ideas for the future of libvmcu [10] a python binding would be really great. [10.1] requires external contributors :( see CONTRIBUTING.txt +[11] make libvmcu thread safe + /********************************* Internal / Cleanup *****************************/ [12] remove usage of basic integers (int) in libvmcu (nearly done) @@ -41,3 +43,5 @@ These are a some of my ideas for the future of libvmcu [14] speed up controlflow analysis by adding a lookup table for the cfg nodes [15] fix inconsistency of xref-to + +[16] a consistent way to return readable error codes (not just -1 and 0) \ No newline at end of file diff --git a/driver/cfg/cfg.c b/driver/cfg/cfg.c index 3d87e48..e32a721 100644 --- a/driver/cfg/cfg.c +++ b/driver/cfg/cfg.c @@ -43,14 +43,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./skeleton \n"); + printf("Usage: ./skeleton \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/disasm/disasm.c b/driver/disasm/disasm.c index e893b6b..4985abc 100644 --- a/driver/disasm/disasm.c +++ b/driver/disasm/disasm.c @@ -64,7 +64,7 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./skeleton \n"); + printf("Usage: ./skeleton \n"); return EXIT_FAILURE; } @@ -72,7 +72,7 @@ int main(const int argc, const char **argv) { m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); uint32_t progsize = 0; - vmcu_instr_t *prog = vmcu_disassemble_ihex(argv[1], &progsize, m328p); + vmcu_instr_t *prog = vmcu_disassemble_file(argv[1], &progsize, m328p); if(prog == NULL || progsize == 0) return EXIT_FAILURE; diff --git a/driver/endloop/endloop.c b/driver/endloop/endloop.c index f307fc3..03ac628 100644 --- a/driver/endloop/endloop.c +++ b/driver/endloop/endloop.c @@ -41,12 +41,12 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./endloop \n"); + printf("Usage: ./endloop \n"); return EXIT_FAILURE; } vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex(argv[1], m328p); + vmcu_report_t *report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) { diff --git a/driver/findgroup/findgroup.c b/driver/findgroup/findgroup.c index b0f62ef..a57eae2 100644 --- a/driver/findgroup/findgroup.c +++ b/driver/findgroup/findgroup.c @@ -41,14 +41,14 @@ int main(const int argc, const char **argv) { if(argc != 3) { - printf("Usage: ./findgroup \n"); + printf("Usage: ./findgroup \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/findisr/findisr.c b/driver/findisr/findisr.c index 120fd83..fc44ca1 100644 --- a/driver/findisr/findisr.c +++ b/driver/findisr/findisr.c @@ -56,7 +56,7 @@ int main(const int argc, const char **argv) { if(argc < 2) { - printf("Usage: ./findisr \n"); + printf("Usage: ./findisr \n"); return EXIT_FAILURE; } @@ -76,7 +76,7 @@ int main(const int argc, const char **argv) { const char* filename = argv[argc-1]; m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - if((report = vmcu_analyze_ihex(filename, m328p)) == NULL) + if((report = vmcu_analyze_file(filename, m328p)) == NULL) return EXIT_FAILURE; uint32_t start_index = 0; diff --git a/driver/graph/graph.c b/driver/graph/graph.c index ee42f41..e7da7b0 100644 --- a/driver/graph/graph.c +++ b/driver/graph/graph.c @@ -65,12 +65,12 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./cfg \n"); + printf("Usage: ./cfg \n"); return EXIT_FAILURE; } vmcu_model_t* m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t* report = vmcu_analyze_ihex(argv[1], m328p); + vmcu_report_t* report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/labels/labels.c b/driver/labels/labels.c index 6988378..5d0fbb8 100644 --- a/driver/labels/labels.c +++ b/driver/labels/labels.c @@ -18,12 +18,12 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./labels \n"); + printf("Usage: ./labels \n"); return EXIT_FAILURE; } vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex(argv[1], m328p); + vmcu_report_t *report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) { diff --git a/driver/led/ledtest.c b/driver/led/ledtest.c index 6ea96e8..566b919 100644 --- a/driver/led/ledtest.c +++ b/driver/led/ledtest.c @@ -40,7 +40,7 @@ int main(const int argc, const char **argv) { if((m328p = vmcu_model_ctor(VMCU_DEVICE_M328P)) == NULL) return EXIT_FAILURE; - if((report = vmcu_analyze_ihex(TESTFILE, m328p)) == NULL) + if((report = vmcu_analyze_file(TESTFILE, m328p)) == NULL) return EXIT_FAILURE; if((sys = vmcu_system_ctor(report)) == NULL) diff --git a/driver/occurence/occurence.c b/driver/occurence/occurence.c index 1c47446..21dc421 100644 --- a/driver/occurence/occurence.c +++ b/driver/occurence/occurence.c @@ -64,7 +64,7 @@ void bubblesort(void **array, int length, int (*compar)(const void *, const void int main(int argc, char* argv[]) { if(argc != 2) { - printf("Expected hex file argument. exiting.\n"); + printf("Expected binary file as argument. exiting.\n"); return 1; } @@ -73,7 +73,7 @@ int main(int argc, char* argv[]) { const char* fname = argv[argc-1]; vmcu_model_t* m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t* report = vmcu_analyze_ihex(fname, m328p); + vmcu_report_t* report = vmcu_analyze_file(fname, m328p); if(report == NULL) { diff --git a/driver/rwaccess/rwaccess.c b/driver/rwaccess/rwaccess.c index b57665e..735188c 100644 --- a/driver/rwaccess/rwaccess.c +++ b/driver/rwaccess/rwaccess.c @@ -26,14 +26,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./rwaccess \n"); + printf("Usage: ./rwaccess \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/sca/sca.c b/driver/sca/sca.c index 667f05f..5370610 100644 --- a/driver/sca/sca.c +++ b/driver/sca/sca.c @@ -94,13 +94,13 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./sca \n"); + printf("Usage: ./sca \n"); return EXIT_FAILURE; } vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex(FILE, m328p); + vmcu_report_t *report = vmcu_analyze_file(FILE, m328p); vmcu_system_t *sys = vmcu_system_ctor(report); char cracked[LENGTH] = ""; diff --git a/driver/sfr/sfr.c b/driver/sfr/sfr.c index 592137b..2ba4ce6 100644 --- a/driver/sfr/sfr.c +++ b/driver/sfr/sfr.c @@ -21,12 +21,12 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./sfr \n"); + printf("Usage: ./sfr \n"); return EXIT_FAILURE; } vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - vmcu_report_t *report = vmcu_analyze_ihex(argv[1], m328p); + vmcu_report_t *report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) { diff --git a/driver/skeleton/skeleton.c b/driver/skeleton/skeleton.c index 00f8010..d3a08a3 100644 --- a/driver/skeleton/skeleton.c +++ b/driver/skeleton/skeleton.c @@ -27,14 +27,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./skeleton \n"); + printf("Usage: ./skeleton \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/speed/speed.c b/driver/speed/speed.c index 31001dd..d8505f4 100644 --- a/driver/speed/speed.c +++ b/driver/speed/speed.c @@ -33,14 +33,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./speed \n"); + printf("Usage: ./speed \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/stepper/stepper.c b/driver/stepper/stepper.c index 22ac0ef..38b045e 100644 --- a/driver/stepper/stepper.c +++ b/driver/stepper/stepper.c @@ -49,14 +49,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./skeleton \n"); + printf("Usage: ./skeleton \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/strings/strings.c b/driver/strings/strings.c index 3c7d960..c23dfa2 100644 --- a/driver/strings/strings.c +++ b/driver/strings/strings.c @@ -27,14 +27,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./strings \n"); + printf("Usage: ./strings \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/driver/vcdump/vcdump.c b/driver/vcdump/vcdump.c index 22e2eee..a947a4c 100644 --- a/driver/vcdump/vcdump.c +++ b/driver/vcdump/vcdump.c @@ -33,7 +33,7 @@ int main(const int argc, const char **argv) { if(argc < 4) { - printf("Usage: ./vcdump +\n"); + printf("Usage: ./vcdump +\n"); return EXIT_FAILURE; } @@ -53,7 +53,7 @@ int main(const int argc, const char **argv) { m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - if((report = vmcu_analyze_ihex(filename, m328p)) == NULL) + if((report = vmcu_analyze_file(filename, m328p)) == NULL) return EXIT_FAILURE; sys = vmcu_system_ctor(report); diff --git a/driver/vector/vector.c b/driver/vector/vector.c index 613d746..0ed9c2b 100644 --- a/driver/vector/vector.c +++ b/driver/vector/vector.c @@ -25,14 +25,14 @@ int main(const int argc, const char **argv) { if(argc != 2) { - printf("Usage: ./vector \n"); + printf("Usage: ./vector \n"); return EXIT_FAILURE; } atexit(cleanup); m328p = vmcu_model_ctor(VMCU_DEVICE_M328P); - report = vmcu_analyze_ihex(argv[1], m328p); + report = vmcu_analyze_file(argv[1], m328p); if(report == NULL) return EXIT_FAILURE; diff --git a/engine/include/analyzer/analyzer.h b/engine/include/analyzer/analyzer.h index d5cda6b..8dd95f9 100644 --- a/engine/include/analyzer/analyzer.h +++ b/engine/include/analyzer/analyzer.h @@ -6,6 +6,6 @@ typedef struct vmcu_report vmcu_report_t; typedef struct vmcu_model vmcu_model_t; -extern vmcu_report_t* vmcu_analyze_ihex(const char *hex_file, vmcu_model_t *mcu); +extern vmcu_report_t* vmcu_analyze_file(const char *file, vmcu_model_t *mcu); #endif diff --git a/engine/include/annotator/annotator.h b/engine/include/annotator/annotator.h index e89b94f..5561349 100644 --- a/engine/include/annotator/annotator.h +++ b/engine/include/annotator/annotator.h @@ -10,6 +10,6 @@ typedef struct vmcu_instr vmcu_instr_t; typedef struct vmcu_model vmcu_model_t; extern int vmcu_annotate_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); -extern vmcu_instr_t* vmcu_annotate_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_annotate_file(const char *file, uint32_t *size, vmcu_model_t *mcu); #endif diff --git a/engine/include/decoder/decoder.h b/engine/include/decoder/decoder.h index 8d66e00..6255911 100644 --- a/engine/include/decoder/decoder.h +++ b/engine/include/decoder/decoder.h @@ -11,6 +11,6 @@ typedef struct vmcu_instr vmcu_instr_t; typedef struct vmcu_model vmcu_model_t; extern int vmcu_decode_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); -extern vmcu_instr_t* vmcu_decode_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_decode_file(const char *file, uint32_t *size, vmcu_model_t *mcu); #endif \ No newline at end of file diff --git a/engine/include/decomposer/decomposer.h b/engine/include/decomposer/decomposer.h index 3d232aa..129536a 100644 --- a/engine/include/decomposer/decomposer.h +++ b/engine/include/decomposer/decomposer.h @@ -10,6 +10,6 @@ typedef struct vmcu_instr vmcu_instr_t; typedef struct vmcu_model vmcu_model_t; extern int vmcu_decompose_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); -extern vmcu_instr_t* vmcu_decompose_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_decompose_file(const char *file, uint32_t *size, vmcu_model_t *mcu); #endif diff --git a/engine/include/disassembler/disassembler.h b/engine/include/disassembler/disassembler.h index 4e1b85f..5947a3f 100644 --- a/engine/include/disassembler/disassembler.h +++ b/engine/include/disassembler/disassembler.h @@ -10,6 +10,6 @@ typedef struct vmcu_instr vmcu_instr_t; typedef struct vmcu_model vmcu_model_t; extern int vmcu_disassemble_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); -extern vmcu_instr_t* vmcu_disassemble_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_disassemble_file(const char *file, uint32_t *size, vmcu_model_t *mcu); #endif \ No newline at end of file diff --git a/engine/include/libvmcu/libvmcu_analyzer.h b/engine/include/libvmcu/libvmcu_analyzer.h index de4ab5f..f2e877c 100644 --- a/engine/include/libvmcu/libvmcu_analyzer.h +++ b/engine/include/libvmcu/libvmcu_analyzer.h @@ -572,11 +572,11 @@ extern void vmcu_model_dtor(vmcu_model_t *this); /* <---------------------------------- Functions - Analyzer Stage -------------------------------------> */ /* - * vmcu_analyze_ihex - analyze an intel hex file - * @hex_file: intel hex file to analyze - * @mcu: analyze for this device model + * vmcu_analyze_file - analyze a binary file + * @file: file to analyze (currently srec or ihex) + * @mcu: analyze for this device model * */ -extern vmcu_report_t* vmcu_analyze_ihex(const char *hex_file, vmcu_model_t *mcu); +extern vmcu_report_t* vmcu_analyze_file(const char *file, vmcu_model_t *mcu); /* * vmcu_report_dtor - destructor of vmcu_report_t @@ -595,12 +595,12 @@ extern void vmcu_report_dtor(vmcu_report_t *this); extern int vmcu_disassemble_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); /* - * vmcu_disassemble_ihex - disassemble an intel hex file - * @hex_file: intel hex file to disassemble - * @size: size of vmcu_instr_t* after disassembling - * @mcu: disassemble for this device model + * vmcu_disassemble_file - disassemble a binary file + * @file: file to disassemble (currently srec or ihex) + * @size: size of vmcu_instr_t* after disassembling + * @mcu: disassemble for this device model * */ -extern vmcu_instr_t* vmcu_disassemble_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_disassemble_file(const char *file, uint32_t *size, vmcu_model_t *mcu); /* <--------------------------------- Functions - Decomposer Stage ------------------------------------> */ @@ -613,12 +613,12 @@ extern vmcu_instr_t* vmcu_disassemble_ihex(const char *hex_file, uint32_t *size, extern int vmcu_decompose_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); /* - * vmcu_decompose_ihex - decompose an intel hex file - * @hex_file: intel hex file to decompose - * @size: size of vmcu_instr_t* after decomposing - * @mcu: decompose for this device model + * vmcu_decompose_file - decompose a binary file + * @file: file to decompose (currently srec or ihex) + * @size: size of vmcu_instr_t* after decomposing + * @mcu: decompose for this device model * */ -extern vmcu_instr_t* vmcu_decompose_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_decompose_file(const char *file, uint32_t *size, vmcu_model_t *mcu); /* <--------------------------------- Functions - Annotator Stage -------------------------------------> */ @@ -631,12 +631,12 @@ extern vmcu_instr_t* vmcu_decompose_ihex(const char *hex_file, uint32_t *size, v extern int vmcu_annotate_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); /* - * vmcu_annotate_ihex - annotate an intel hex file - * @hex_file: intel hex file to annotate - * @size: size of vmcu_instr_t* after annotating - * @mcu: annotate for this device model + * vmcu_annotate_file - annotate a binary file + * @file: file to annotate (currently srec or ihex) + * @size: size of vmcu_instr_t* after annotating + * @mcu: annotate for this device model * */ -extern vmcu_instr_t* vmcu_annotate_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_annotate_file(const char *file, uint32_t *size, vmcu_model_t *mcu); /* <---------------------------------- Functions - Decoder Stage --------------------------------------> */ @@ -649,11 +649,11 @@ extern vmcu_instr_t* vmcu_annotate_ihex(const char *hex_file, uint32_t *size, vm extern int vmcu_decode_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *mcu); /* - * vmcu_decode_ihex - decode an intel hex file - * @hex_file: intel hex file to decode - * @size: size of vmcu_instr_t* after decoding - * @mcu: decode for this device model + * vmcu_decode_file - decode a binary file + * @file: file to decode (currently srec or ihex) + * @size: size of vmcu_instr_t* after decoding + * @mcu: decode for this device model * */ -extern vmcu_instr_t* vmcu_decode_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu); +extern vmcu_instr_t* vmcu_decode_file(const char *file, uint32_t *size, vmcu_model_t *mcu); #endif diff --git a/engine/include/reader/fmt.h b/engine/include/reader/fmt.h deleted file mode 100644 index 89d1435..0000000 --- a/engine/include/reader/fmt.h +++ /dev/null @@ -1,12 +0,0 @@ -/* File Format Enumeration Header */ - -#ifndef VMCU_FMT_H -#define VMCU_FMT_H - -typedef enum { - - VMCU_FMT_IHEX - -} VMCU_FMT; - -#endif \ No newline at end of file diff --git a/engine/include/reader/format/ihex.h b/engine/include/reader/format/ihex.h index f09084d..7e9f81d 100644 --- a/engine/include/reader/format/ihex.h +++ b/engine/include/reader/format/ihex.h @@ -8,6 +8,6 @@ typedef struct vmcu_binary_buffer vmcu_binary_buffer_t; -extern vmcu_binary_buffer_t * vmcu_read_ihex(const char *hex_file, uint32_t *size); +extern vmcu_binary_buffer_t* vmcu_read_ihex(const char *hex_file, uint32_t *size); #endif diff --git a/engine/include/reader/format/srec.h b/engine/include/reader/format/srec.h index 64d9b0b..795dc47 100644 --- a/engine/include/reader/format/srec.h +++ b/engine/include/reader/format/srec.h @@ -8,6 +8,6 @@ typedef struct vmcu_binary_buffer vmcu_binary_buffer_t; -extern vmcu_binary_buffer_t * vmcu_read_srec(const char *srec_file, uint32_t *size); +extern vmcu_binary_buffer_t* vmcu_read_srec(const char *srec_file, uint32_t *size); -#endif +#endif \ No newline at end of file diff --git a/engine/include/reader/reader.h b/engine/include/reader/reader.h index 64ed185..7937ccb 100644 --- a/engine/include/reader/reader.h +++ b/engine/include/reader/reader.h @@ -6,11 +6,8 @@ // C Headers #include -// Project Headers -#include "engine/include/reader/fmt.h" - typedef struct vmcu_binary_buffer vmcu_binary_buffer_t; -extern vmcu_binary_buffer_t* vmcu_read_format(const VMCU_FMT fmt, const char *file, uint32_t *size); +extern vmcu_binary_buffer_t* vmcu_read_format(const char *file, uint32_t *size); #endif \ No newline at end of file diff --git a/engine/include/reader/util/fmt.h b/engine/include/reader/util/fmt.h new file mode 100644 index 0000000..45a907e --- /dev/null +++ b/engine/include/reader/util/fmt.h @@ -0,0 +1,17 @@ +/* File Format Recognition Header */ + +#ifndef VMCU_FMT_H +#define VMCU_FMT_H + +typedef enum { + + VMCU_FMT_UNKNOWN = -1, + + VMCU_FMT_IHEX, + VMCU_FMT_SREC + +} VMCU_FMT; + +VMCU_FMT vmcu_format_of(const char *path); + +#endif \ No newline at end of file diff --git a/engine/src/analyzer/analyzer.c b/engine/src/analyzer/analyzer.c index 148a631..fda10a3 100644 --- a/engine/src/analyzer/analyzer.c +++ b/engine/src/analyzer/analyzer.c @@ -18,10 +18,10 @@ /* --- Extern --- */ -vmcu_report_t* vmcu_analyze_ihex(const char *hex_file, vmcu_model_t *mcu) { +vmcu_report_t* vmcu_analyze_file(const char *file, vmcu_model_t *mcu) { vmcu_report_t *report = vmcu_report_ctor(); - report->disassembly = vmcu_disassemble_ihex(hex_file, &report->progsize, mcu); + report->disassembly = vmcu_disassemble_file(file, &report->progsize, mcu); if(report->disassembly == NULL) { diff --git a/engine/src/annotator/annotator.c b/engine/src/annotator/annotator.c index f09e80b..0b5339b 100644 --- a/engine/src/annotator/annotator.c +++ b/engine/src/annotator/annotator.c @@ -34,11 +34,11 @@ int vmcu_annotate_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t return 0; } -vmcu_instr_t* vmcu_annotate_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu) { +vmcu_instr_t* vmcu_annotate_file(const char *file, uint32_t *size, vmcu_model_t *mcu) { vmcu_instr_t *instr_list; - if((instr_list = vmcu_decode_ihex(hex_file, size, mcu)) == NULL) + if((instr_list = vmcu_decode_file(file, size, mcu)) == NULL) return NULL; for(uint32_t i = 0; i < *size; i++) { diff --git a/engine/src/decoder/decoder.c b/engine/src/decoder/decoder.c index 537eee0..6b07925 100644 --- a/engine/src/decoder/decoder.c +++ b/engine/src/decoder/decoder.c @@ -57,12 +57,12 @@ int vmcu_decode_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t *m return ((instr->dword == false) && (bytes > 0xffff)) ? -1 : 0; } -vmcu_instr_t* vmcu_decode_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu) { +vmcu_instr_t* vmcu_decode_file(const char *file, uint32_t *size, vmcu_model_t *mcu) { vmcu_instr_t *result; vmcu_binary_buffer_t *bb; - if((bb = vmcu_read_format(VMCU_FMT_IHEX, hex_file, size)) == NULL) + if((bb = vmcu_read_format(file, size)) == NULL) return NULL; if((result = decode_binary_buffer(bb, size)) == NULL) diff --git a/engine/src/decomposer/decomposer.c b/engine/src/decomposer/decomposer.c index 7488269..70637c4 100644 --- a/engine/src/decomposer/decomposer.c +++ b/engine/src/decomposer/decomposer.c @@ -37,11 +37,11 @@ int vmcu_decompose_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model_t return 0; } -vmcu_instr_t* vmcu_decompose_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu) { +vmcu_instr_t* vmcu_decompose_file(const char *file, uint32_t *size, vmcu_model_t *mcu) { vmcu_instr_t *instr_list; - if((instr_list = vmcu_annotate_ihex(hex_file, size, mcu)) == NULL) + if((instr_list = vmcu_annotate_file(file, size, mcu)) == NULL) return NULL; for(uint32_t i = 0; i < *size; i++) { diff --git a/engine/src/disassembler/disassembler.c b/engine/src/disassembler/disassembler.c index 0492415..751eacb 100644 --- a/engine/src/disassembler/disassembler.c +++ b/engine/src/disassembler/disassembler.c @@ -40,11 +40,11 @@ int vmcu_disassemble_bytes(const uint32_t bytes, vmcu_instr_t *instr, vmcu_model return 0; } -vmcu_instr_t* vmcu_disassemble_ihex(const char *hex_file, uint32_t *size, vmcu_model_t *mcu) { +vmcu_instr_t* vmcu_disassemble_file(const char *file, uint32_t *size, vmcu_model_t *mcu) { vmcu_instr_t *instr_list; - if((instr_list = vmcu_decompose_ihex(hex_file, size, mcu)) == NULL) + if((instr_list = vmcu_decompose_file(file, size, mcu)) == NULL) return NULL; for(uint32_t i = 0; i < *size; i++) { diff --git a/engine/src/reader/format/ihex.c b/engine/src/reader/format/ihex.c index ffd28a5..8e77839 100644 --- a/engine/src/reader/format/ihex.c +++ b/engine/src/reader/format/ihex.c @@ -1,4 +1,4 @@ -/* Intel Hex Reader Header */ +/* Intel Hex Reader Implementation */ // C Headers #include @@ -44,7 +44,7 @@ static int32_t get_ihex_properties(char *line, ihex_properties_t *prop); /* --- Extern --- */ -vmcu_binary_buffer_t * vmcu_read_ihex(const char *hex_file, uint32_t *size) { +vmcu_binary_buffer_t* vmcu_read_ihex(const char *hex_file, uint32_t *size) { uint32_t n; vmcu_binary_buffer_t *bb; diff --git a/engine/src/reader/format/srec.c b/engine/src/reader/format/srec.c index ee462e0..bfc3afc 100644 --- a/engine/src/reader/format/srec.c +++ b/engine/src/reader/format/srec.c @@ -1,4 +1,4 @@ -/* Intel Hex Reader Header */ +/* Motorola SREC Reader Implementation */ // C Headers #include @@ -14,109 +14,152 @@ #include "engine/include/misc/filemanip.h" #include "engine/include/misc/stringmanip.h" -#define RECORD_MAX_LENGTH_BYTES (1+1+2+255) +#define SREC_MIN_LENGTH 10 #define SREC_MAX_BYTE_COUNT 249 -#define ERR_RECORD_NOT_SUPPORTED -2 -#define ERR_FATAL -1 - /* Forward Declaration of static Members */ -typedef enum srec_record_type { +typedef enum { + + SREC_RECORD_S0, + SREC_RECORD_S1, + SREC_RECORD_S2, + SREC_RECORD_S3, + SREC_RECORD_S4, + SREC_RECORD_S5, + SREC_RECORD_S6, + SREC_RECORD_S7, + SREC_RECORD_S8, + SREC_RECORD_S9 + +} SREC_RECORD; + +typedef enum { - S0_HEADER = 0, - S1_DATA, - S2_DATA, - S3_DATA, - S4_RESERVED, - S5_COUNT, - S6_COUNT, - S7_START_ADDR, - S8_START_ADDR, - S9_START_ADDR + SREC_ERROR_OK, + SREC_ERROR_FATAL, + SREC_ERROR_NOT_SUPPORTED -} srec_record_type_t; +} SREC_ERROR; typedef struct srec_properties { - srec_record_type_t record_type; uint32_t address; + SREC_RECORD record_type; uint8_t data_count; uint8_t data[SREC_MAX_BYTE_COUNT]; } srec_properties_t; -/* --- static --- */ -static uint32_t estimate_buffer_size(const char* srec_file); +/* Forward Declaration of static Functions */ -static int8_t read_srec_line(const char* line, vmcu_binary_buffer_t* buffer, uint32_t* size); +static bool verify_srec_line(const char *line); +static uint32_t estimate_buffer_size(const char *srec_file); + +static int32_t read_srec_file(const char *srec_file, vmcu_binary_buffer_t *bb, uint32_t *size); +static int32_t read_srec_line(const char *line, vmcu_binary_buffer_t *bb, uint32_t *size); + +static SREC_ERROR get_srec_properties(const char *line, srec_properties_t *prop); +static SREC_ERROR collect_data(const char *line, uint32_t index, srec_properties_t *prop); -static int8_t get_srec_properties(const char* line, srec_properties_t* prop); /* --- Extern --- */ -vmcu_binary_buffer_t * vmcu_read_srec(const char *srec_file, uint32_t *size) { +vmcu_binary_buffer_t* vmcu_read_srec(const char *srec_file, uint32_t *size) { - FILE* file = fopen(srec_file, "r"); + uint32_t n; + vmcu_binary_buffer_t *bb; - if(file == NULL) + if((n = estimate_buffer_size(srec_file)) == 0) return NULL; - uint32_t n = estimate_buffer_size(srec_file); + if((bb = malloc(n * sizeof(vmcu_binary_buffer_t))) == NULL) + return NULL; - vmcu_binary_buffer_t* buffer = malloc(sizeof(vmcu_binary_buffer_t)*n); + if(read_srec_file(srec_file, bb, size) < 0) { - char* line = NULL; - size_t len; + free(bb); + return NULL; + } - while(getline(&line, &len, file) != -1){ + if(*size == 0) { - int8_t status = read_srec_line(line, buffer, size); + free(bb); + return NULL; + } - if(status == ERR_FATAL){ + return bb; +} - *size = 0; +/* --- Static --- */ - free(line); - fclose(file); +static uint32_t estimate_buffer_size(const char *srec_file) { - return NULL; - } - } + long bytes; - free(line); - fclose(file); - return buffer; + if((bytes = vmcu_fbytes(srec_file)) < 4) + return 0; + + return (bytes / 4); } -static uint32_t estimate_buffer_size(const char* srec_file){ +static bool verify_srec_line(const char *line) { + + if(strlen(line) < SREC_MIN_LENGTH) + return false; - FILE* file = fopen(srec_file, "r"); + if(line[0] != 'S') + return false; + + return true; +} - long bytes = vmcu_fbytes(srec_file); +static int32_t read_srec_file(const char *srec_file, vmcu_binary_buffer_t *bb, uint32_t *size) { - fclose(file); + FILE *f = NULL; + size_t len; char *line = NULL; - return (bytes / 4); + if((f = fopen(srec_file, "r")) == NULL) + return -1; + + while(getline(&line, &len, f) != -1) { + + if(read_srec_line(line, bb, size) < 0) { + + *size = 0; + + free(line); + fclose(f); + + return -1; + } + } + + free(line); + fclose(f); + + return 0; } -static int8_t read_srec_line(const char* line, vmcu_binary_buffer_t* buffer, uint32_t* size){ +static int32_t read_srec_line(const char *line, vmcu_binary_buffer_t *bb, uint32_t *size) { - srec_properties_t prop; + srec_properties_t prop; SREC_ERROR err; - int8_t status = get_srec_properties(line, &prop); + if((err = get_srec_properties(line, &prop)) == SREC_ERROR_FATAL) + return -1; - if(status < 0) - return status; + if(err == SREC_ERROR_NOT_SUPPORTED) + return 0; for(uint32_t i = 0; i < (prop.data_count / 2); i++) { - uint16_t srec_bytes = (prop.data[i*2 + 0] << 8)| prop.data[i*2 + 1]; + const uint8_t high = prop.data[ (i * 2) + 0 ]; + const uint8_t low = prop.data[ (i * 2) + 1 ]; - buffer[*size] = (vmcu_binary_buffer_t) { + bb[*size] = (vmcu_binary_buffer_t) { - .bytes = srec_bytes, - .addr = (prop.address/2) + i + .bytes = (high << 8) | low, + .addr = (prop.address / 2) + i }; *size += 1; @@ -125,76 +168,88 @@ static int8_t read_srec_line(const char* line, vmcu_binary_buffer_t* buffer, uin return 0; } -static int8_t get_srec_properties(const char* line, srec_properties_t* prop){ - - uint32_t len = strlen(line); - - if(len < 10) - return ERR_FATAL; +static SREC_ERROR get_srec_properties(const char *line, srec_properties_t *prop) { - if(line[0] != 'S') - return ERR_FATAL; + uint32_t index_data; + uint8_t byte_count, address_nbytes; - prop->record_type = line[1] - '0'; + if(verify_srec_line(line) == false) + return SREC_ERROR_FATAL; char byte_count_str[3] = { line[2], line[3], '\0' }; + prop->record_type = line[1] - '0'; - uint8_t byte_count = vmcu_htoi(byte_count_str); - - if(byte_count > SREC_MAX_BYTE_COUNT) - return ERR_FATAL; + if((byte_count = vmcu_htoi(byte_count_str)) > SREC_MAX_BYTE_COUNT) + return SREC_ERROR_FATAL; - char addr_str[9] = {}; + char addr_str[9]; memset(addr_str, 0, 9); - uint32_t index_data; - uint8_t address_nbytes; + switch(prop->record_type) { - switch (prop->record_type) { - case S0_HEADER: - return ERR_RECORD_NOT_SUPPORTED; + case SREC_RECORD_S1: - case S1_DATA: - memcpy(addr_str, line+4, 4); + memcpy(addr_str, line + 4, 4); address_nbytes = 2; index_data = 8; - break; - case S2_DATA: - memcpy(addr_str, line+4, 6); + + break; + + case SREC_RECORD_S2: + + memcpy(addr_str, line + 4, 6); address_nbytes = 3; index_data = 10; - break; - case S3_DATA: - memcpy(addr_str, line+4, 8); + + break; + + case SREC_RECORD_S3: + + memcpy(addr_str, line + 4, 8); address_nbytes = 4; index_data = 12; - break; - case S4_RESERVED: - return ERR_FATAL; + break; + + case SREC_RECORD_S0: + case SREC_RECORD_S4: + case SREC_RECORD_S5: + case SREC_RECORD_S6: + case SREC_RECORD_S7: + case SREC_RECORD_S8: + case SREC_RECORD_S9: - case S5_COUNT: - case S6_COUNT: - case S7_START_ADDR: - case S8_START_ADDR: - case S9_START_ADDR: - return ERR_RECORD_NOT_SUPPORTED; + /* not supported, skip line */ + return SREC_ERROR_NOT_SUPPORTED; + + default: return SREC_ERROR_FATAL; } prop->data_count = byte_count - (address_nbytes + 1); + prop->address = vmcu_htoi(addr_str); - prop->address = vmcu_htoi(addr_str); + return collect_data(line, index_data, prop); +} - for(uint32_t i = 0; i < prop->data_count; i++){ +static SREC_ERROR collect_data(const char *line, uint32_t index, srec_properties_t *prop) { + + const size_t len = strlen(line); + + for(uint32_t i = 0; i < prop->data_count; i++) { + + if((index + 1) >= len) + return SREC_ERROR_FATAL; char data_str[3] = { - line[index_data], - line[index_data + 1], - '\0' + + line[index], + line[index + 1], + '\0' }; - index_data += 2; + prop->data[i] = vmcu_htoi(data_str); + index += 2; } - return 0; -} + return SREC_ERROR_OK; +} \ No newline at end of file diff --git a/engine/src/reader/reader.c b/engine/src/reader/reader.c index 2a8c143..168b3ff 100644 --- a/engine/src/reader/reader.c +++ b/engine/src/reader/reader.c @@ -8,14 +8,20 @@ // Project Headers (engine, formats) #include "engine/include/reader/format/ihex.h" +#include "engine/include/reader/format/srec.h" -vmcu_binary_buffer_t* vmcu_read_format(const VMCU_FMT fmt, const char *file, uint32_t *size) { +// Project Headers (engine, reader utils) +#include "engine/include/reader/util/fmt.h" + +vmcu_binary_buffer_t* vmcu_read_format(const char *file, uint32_t *size) { vmcu_binary_buffer_t *bb; - switch(fmt) { + switch( vmcu_format_of(file) ) { case VMCU_FMT_IHEX: bb = vmcu_read_ihex(file, size); break; + case VMCU_FMT_SREC: bb = vmcu_read_srec(file, size); break; + default: bb = NULL; break; } diff --git a/engine/src/reader/util/fmt.c b/engine/src/reader/util/fmt.c new file mode 100644 index 0000000..3a860c0 --- /dev/null +++ b/engine/src/reader/util/fmt.c @@ -0,0 +1,80 @@ +/* File Format Recognition Implementation */ + +// C Headers +#include +#include + +// Project Headers (engine, reader util) +#include "engine/include/reader/util/fmt.h" + +#define MIN_EXT_LENGTH 4 +#define MAX_EXT_LENGTH 5 + +#define IHEX_EXTENSION ".hex" +#define SREC_EXTENSION ".srec" + +/* + * We have following valid file extensions + * + * [0] .hex (Intel Hex, VMCU_FMT_IHEX) + * [1] .srec (Motorola Hex, VMCU_FMT_SREC) + * [2] .bin (currently not supported) + * [3] .elf (currently not supported) + * + * */ + +/* Forward Declaration of static Functions */ + +static int32_t get_file_extension(const char *path, char *buffer); + +/* --- Extern --- */ + +VMCU_FMT vmcu_format_of(const char *path) { + + char extension[MAX_EXT_LENGTH + 1]; + + if(path == NULL) + return VMCU_FMT_UNKNOWN; + + if(get_file_extension(path, extension) < 0) + return VMCU_FMT_UNKNOWN; + + if(strcmp(extension, IHEX_EXTENSION) == 0) + return VMCU_FMT_IHEX; + + if(strcmp(extension, SREC_EXTENSION) == 0) + return VMCU_FMT_SREC; + + return VMCU_FMT_UNKNOWN; +} + +/* --- Static --- */ + +static int32_t get_file_extension(const char *path, char *buffer) { + + size_t len = 0; + + if((len = strlen(path)) < MIN_EXT_LENGTH + 1) + return -1; + + if(path[len - MIN_EXT_LENGTH] == '.') { + + strncpy(buffer, path + len - MIN_EXT_LENGTH, MIN_EXT_LENGTH); + buffer[MIN_EXT_LENGTH] = '\0'; + + return 0; + } + + if(len < MAX_EXT_LENGTH + 1) + return -1; + + if(path[len - MAX_EXT_LENGTH] == '.') { + + strncpy(buffer, path + len - MAX_EXT_LENGTH, MAX_EXT_LENGTH); + buffer[MAX_EXT_LENGTH] = '\0'; + + return 0; + } + + return -1; +} \ No newline at end of file diff --git a/test/integration/system/system_test.c b/test/integration/system/system_test.c index cbfcce8..94a9a3a 100644 --- a/test/integration/system/system_test.c +++ b/test/integration/system/system_test.c @@ -85,7 +85,7 @@ static void test_ihex_kmp(vmcu_model_t *mcu) { printf("Simulating kmp.hex"); - vmcu_report_t *report = vmcu_analyze_ihex(IHEX_KMP, mcu); + vmcu_report_t *report = vmcu_analyze_file(IHEX_KMP, mcu); vmcu_system_t *sys = vmcu_system_ctor(report); while(vmcu_system_get_pc(sys) != 0x0141) @@ -109,7 +109,7 @@ static void test_ihex_erdy(vmcu_model_t *mcu) { printf("Simulating erdy.hex"); - vmcu_report_t *report = vmcu_analyze_ihex(IHEX_ERDY, mcu); + vmcu_report_t *report = vmcu_analyze_file(IHEX_ERDY, mcu); vmcu_system_t *sys = vmcu_system_ctor(report); while(sys->cycles < 33007) @@ -136,7 +136,7 @@ static void test_ihex_eonly(vmcu_model_t *mcu) { printf("Simulating eonly.hex"); - vmcu_report_t *report = vmcu_analyze_ihex(IHEX_EONLY, mcu); + vmcu_report_t *report = vmcu_analyze_file(IHEX_EONLY, mcu); vmcu_system_t *sys = vmcu_system_ctor(report); while(vmcu_system_get_pc(sys) != 0x001e) @@ -168,7 +168,7 @@ static void test_ihex_dfs(vmcu_model_t *mcu) { printf("Simulating dfs.hex"); - vmcu_report_t *report = vmcu_analyze_ihex(IHEX_DFS, mcu); + vmcu_report_t *report = vmcu_analyze_file(IHEX_DFS, mcu); vmcu_system_t *sys = vmcu_system_ctor(report); while(vmcu_system_get_pc(sys) != 0x01c0) @@ -187,7 +187,7 @@ static void test_ihex_tov(vmcu_model_t *mcu) { printf("Simulating tov.hex"); - vmcu_report_t *report = vmcu_analyze_ihex(IHEX_TOV, mcu); + vmcu_report_t *report = vmcu_analyze_file(IHEX_TOV, mcu); vmcu_system_t *sys = vmcu_system_ctor(report); uint8_t irqc = 0;