From: Michel Pollet Date: Tue, 16 Jun 2015 18:05:21 +0000 (+0100) Subject: avr: Add a 'reset pc' that can be nonzero X-Git-Tag: v1.3~25 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=a865759ce131dd4829e77416a9f08c008f85aa0c;p=sx%2Fsimavr.git avr: Add a 'reset pc' that can be nonzero This allows the AVR to soft reset into the bootloader for example. A watchdog reset will re-run the bootloader with the correct flag. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index 549e36d..6744242 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -125,7 +125,7 @@ void avr_reset(avr_t * avr) for(int i = 0x20; i < noof_ios; i++) avr->data[i] = 0; _avr_sp_set(avr, avr->ramend); - avr->pc = 0; + avr->pc = avr->reset_pc; // Likely to be zero for (int i = 0; i < 8; i++) avr->sreg[i] = 0; avr_interrupt_reset(avr); diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index aad19b5..038b893 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -232,6 +232,11 @@ typedef struct avr_t { * It CAN be a little confusing, so concentrate, young grasshopper. */ avr_flashaddr_t pc; + /* + * Reset PC, this is the value used to jump to at reset time, this + * allow support for bootloaders + */ + avr_flashaddr_t reset_pc; /* * callback when specific IO registers are read/written.