Skip to content

Commit

Permalink
Enum naming convention in order to prevent internal name clashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Milo-D committed Mar 17, 2021
1 parent 4d4ae36 commit 80290cc
Show file tree
Hide file tree
Showing 37 changed files with 1,265 additions and 1,257 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- nothing to log

# v.0.8.3 - 2021-03-18

- Naming Convention of enums (preventing future internal name clashes)
- VMCU_ENUMNAME and its members VMCU_ENUMNAME_*

# v.0.8.2 - 2021-03-17

- Added: interrupt vector analysis
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ VMCU comes with no further dependencies, thus allowing easy setup and easy usage
int main(const int argc, const char **argv) {

/* initialize a device model */
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);

vmcu_instr_t instr;
vmcu_disassemble_bytes(0xd8e0, &instr, m328p);

const VMCU_IKEY key = instr.key; // VMCU_LDI
const VMCU_IKEY key = instr.key; // VMCU_IKEY_LDI
const VMCU_GROUP grp = instr.group; // VMCU_GROUP_TRANSFER

const uint32_t opcode = instr.opcode; // 0xe0d8 (big endian)
Expand All @@ -104,8 +104,8 @@ int main(const int argc, const char **argv) {
vmcu_operand_t *src = &instr.src; // source operand
vmcu_operand_t *dest = &instr.dest; // destination operand

VMCU_OPTYPE src_type = src->type; // VMCU_IMM8
VMCU_OPTYPE dest_type = dest->type; // VMCU_REGISTER
VMCU_OP src_type = src->type; // VMCU_OP_IMM8
VMCU_OP dest_type = dest->type; // VMCU_OP_REGISTER

const uint8_t src_val = src->value; // 0x08
const uint8_t dest_val = dest->value; // (R)29
Expand All @@ -123,7 +123,7 @@ int main(const int argc, const char **argv) {
int main(const int argc, const char **argv) {
/* ignoring checks for this example */
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p);
for(int32_t i = 0; i < report->progsize; i++)
Expand Down Expand Up @@ -151,7 +151,7 @@ ldi r25, 0x00 ; R25 <- 0x00
int main(const int argc, const char **argv) {

/* ignoring checks for this example */
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p);

for(int32_t i = 0; i < report->n_vector; i++) {
Expand Down Expand Up @@ -191,7 +191,7 @@ Vector ID 19 @ 0x0026
int main(const int argc, const char **argv) {

/* ignoring checks for this example */
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p);

for(int32_t i = 0; i < report->n_label; i++) {
Expand Down Expand Up @@ -224,7 +224,7 @@ Label ID: 5, Address: 0x0162
int main(const int argc, const char **argv) {

/* ignoring checks for this example */
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p);

for(int32_t i = 0; i < report->n_label; i++) {
Expand Down Expand Up @@ -272,7 +272,7 @@ int main(const int argc, const char **argv) {
int main(const int argc, const char **argv) {

/* ignoring checks for this example */
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex("file.hex", m328p);

for(int32_t i = 0; i < report->n_sfr; i++) {
Expand Down
2 changes: 1 addition & 1 deletion driver/details/details.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(const int argc, const char **argv) {
const uint32_t opc = htoi(argv[1]);

vmcu_instr_t instr;
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);

if(vmcu_disassemble_bytes(opc, &instr, m328p) < 0) {

Expand Down
2 changes: 1 addition & 1 deletion driver/endloop/endloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main(const int argc, const char **argv) {
return EXIT_FAILURE;
}

vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion driver/findgroup/findgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(const int argc, const char **argv) {

atexit(cleanup);

m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL)
Expand Down
6 changes: 3 additions & 3 deletions driver/findisr/findisr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void analyze_isr(vmcu_instr_t* instr, vmcu_report_t* report) {

int absolute_address = op->value;

if(instr->key == VMCU_RJMP)
if(instr->key == VMCU_IKEY_RJMP)
absolute_address += instr->addr + 1;

vmcu_label_t* label = find_label(absolute_address, report);
Expand Down Expand Up @@ -74,7 +74,7 @@ int main(const int argc, const char **argv) {
/* Initialize libvmcu */

const char* filename = argv[argc-1];
m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);

if((report = vmcu_analyze_ihex(filename, m328p)) == NULL)
return EXIT_FAILURE;
Expand All @@ -86,7 +86,7 @@ int main(const int argc, const char **argv) {

int key = instr->key;

if(key == VMCU_JMP || key == VMCU_RJMP) {
if(key == VMCU_IKEY_JMP || key == VMCU_IKEY_RJMP) {

if(start_index == -1)
start_index = i;
Expand Down
2 changes: 1 addition & 1 deletion driver/labels/labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(const int argc, const char **argv) {
return EXIT_FAILURE;
}

vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL)
Expand Down
2 changes: 1 addition & 1 deletion driver/led/ledtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(const int argc, const char **argv) {
uint8_t led;
atexit(cleanup);

if((m328p = vmcu_model_ctor(VMCU_M328P)) == NULL)
if((m328p = vmcu_model_ctor(VMCU_DEVICE_M328P)) == NULL)
return EXIT_FAILURE;

if((report = vmcu_analyze_ihex(TESTFILE, m328p)) == NULL)
Expand Down
6 changes: 3 additions & 3 deletions driver/occurence/occurence.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int main(int argc, char* argv[]) {
int countFilters = argc-2;
const char* fname = argv[argc-1];

vmcu_model_t* m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t* m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t* report = vmcu_analyze_ihex(fname, m328p);

if(report == NULL) {
Expand All @@ -93,8 +93,8 @@ int main(int argc, char* argv[]) {

vmcu_instr_t* instr = &report->disassembly[i];

//because VMCU_DATA is -1
if(instr->key == VMCU_DATA) {
//because VMCU_IKEY_DATA is -1
if(instr->key == VMCU_IKEY_DATA) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion driver/sfr/sfr.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(const int argc, const char **argv) {
return EXIT_FAILURE;
}

vmcu_model_t *m328p = vmcu_model_ctor(VMCU_M328P);
vmcu_model_t *m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
vmcu_report_t *report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion driver/skeleton/skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(const int argc, const char **argv) {

atexit(cleanup);

m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL)
Expand Down
2 changes: 1 addition & 1 deletion driver/speed/speed.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(const int argc, const char **argv) {

atexit(cleanup);

m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL)
Expand Down
2 changes: 1 addition & 1 deletion driver/stepper/stepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(const int argc, const char **argv) {

atexit(cleanup);

m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL)
Expand Down
2 changes: 1 addition & 1 deletion driver/vcdump/vcdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(const int argc, const char **argv) {
sscanf(str, "%hx", &addresses[i-3]);
}

m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);

if((report = vmcu_analyze_ihex(filename, m328p)) == NULL)
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion driver/vector/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(const int argc, const char **argv) {

atexit(cleanup);

m328p = vmcu_model_ctor(VMCU_M328P);
m328p = vmcu_model_ctor(VMCU_DEVICE_M328P);
report = vmcu_analyze_ihex(argv[1], m328p);

if(report == NULL)
Expand Down
4 changes: 2 additions & 2 deletions engine/include/analyzer/report/operand.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <inttypes.h>

// Project Headers (engine utilities)
#include "engine/include/arch/enum/optype.h"
#include "engine/include/arch/enum/op.h"

typedef struct vmcu_operand {

int32_t value;
VMCU_OPTYPE type;
VMCU_OP type;

} vmcu_operand_t;

Expand Down
4 changes: 2 additions & 2 deletions engine/include/analyzer/report/sfr.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "engine/include/analyzer/report/xref.h"

// Project Headers (engine utilities)
#include "engine/include/arch/enum/sfregister.h"
#include "engine/include/arch/enum/sfr_enum.h"

typedef struct vmcu_sfr {

VMCU_SFREGISTER id;
VMCU_SFR id;

int32_t n_xref;
vmcu_xref_t *xref;
Expand Down
17 changes: 17 additions & 0 deletions engine/include/arch/enum/core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Enumeration of Device Cores - Header */

#ifndef VMCU_CORE_H
#define VMCU_CORE_H

typedef enum {

VMCU_CORE_AVR,
VMCU_CORE_AVRe,
VMCU_CORE_AVRep,
VMCU_CORE_AVRxm,
VMCU_CORE_AVRxt,
VMCU_CORE_AVRrc

} VMCU_CORE;

#endif
2 changes: 1 addition & 1 deletion engine/include/arch/enum/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

typedef enum {

VMCU_M328P
VMCU_DEVICE_M328P

} VMCU_DEVICE;

Expand Down
17 changes: 0 additions & 17 deletions engine/include/arch/enum/device_core.h

This file was deleted.

Loading

0 comments on commit 80290cc

Please sign in to comment.