From 9ad0d2655a71a0292f0c92e3060ddc5e4f327af1 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Sun, 14 Jun 2015 11:48:54 +0100 Subject: [PATCH] avr: Renamed special_* core fields Added a 'custom' sub struct Signed-off-by: Michel Pollet --- simavr/sim/sim_avr.c | 8 ++++---- simavr/sim/sim_avr.h | 16 ++++++++++------ tests/tests.c | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index fc03d28..549e36d 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -83,8 +83,8 @@ int avr_init(avr_t * avr) avr->state = cpu_Limbo; avr->frequency = 1000000; // can be overridden via avr_mcu_section avr_interrupt_init(avr); - if (avr->special_init) - avr->special_init(avr, avr->special_data); + if (avr->custom.init) + avr->custom.init(avr, avr->custom.data); if (avr->init) avr->init(avr); // set default (non gdb) fast callbacks @@ -99,8 +99,8 @@ int avr_init(avr_t * avr) void avr_terminate(avr_t * avr) { - if (avr->special_deinit) - avr->special_deinit(avr, avr->special_data); + if (avr->custom.deinit) + avr->custom.deinit(avr, avr->custom.data); if (avr->gdb) { avr_deinit_gdb(avr); avr->gdb = NULL; diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index f71b575..aad19b5 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -179,15 +179,19 @@ typedef struct avr_t { // called at init time void (*init)(struct avr_t * avr); - // called at init time (for special purposes like using a memory mapped file as flash see: simduino) - void (*special_init)(struct avr_t * avr, void * data); - // called at termination time ( to clean special initializations) - void (*special_deinit)(struct avr_t * avr, void * data); - // value passed to special_init() and special_deinit() - void *special_data; // called at reset time void (*reset)(struct avr_t * avr); + struct { + // called at init time (for special purposes like using a + // memory mapped file as flash see: simduino) + void (*init)(struct avr_t * avr, void * data); + // called at termination time ( to clean special initializations) + void (*deinit)(struct avr_t * avr, void * data); + // value passed to init() and deinit() + void *data; + } custom; + /*! * Default AVR core run function. * Two modes are available, a "raw" run that goes as fast as diff --git a/tests/tests.c b/tests/tests.c index a6a504e..579b562 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -121,7 +121,7 @@ int tests_run_test(avr_t *avr, unsigned long run_usec) { // assert that the simulation has not finished before that. jmp_buf jmp; special_deinit_jmpbuf = &jmp; - avr->special_deinit = special_deinit_longjmp_cb; + avr->custom.deinit = special_deinit_longjmp_cb; avr_cycle_timer_register_usec(avr, run_usec, cycle_timer_longjmp_cb, &jmp); int reason = setjmp(jmp); -- 2.39.5