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.6~61 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=c14393550404003f0fe248af20617b9a402d6242;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 4b612d6..b2b2cf0 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -124,7 +124,7 @@ void avr_reset(avr_t * avr) for(int i = 0x20; i <= MAX_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.