From a865759ce131dd4829e77416a9f08c008f85aa0c Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Tue, 16 Jun 2015 19:05:21 +0100 Subject: [PATCH] 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 --- simavr/sim/sim_avr.c | 2 +- simavr/sim/sim_avr.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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. -- 2.39.5