Commit fa17dc719ef066dd77edf9dfe30dd30c20ff89eb
authorKonstantin Begun <kostic2000@gmail.com>
Sat, 6 May 2017 22:42:23 +0000 (23:42 +0100)
committerKonstantin Begun <kostic2000@gmail.com>
Sat, 6 May 2017 22:42:23 +0000 (23:42 +0100)
3 files changed:
simavr/cores/sim_core_declare.h
simavr/sim/sim_avr.c
simavr/sim/sim_avr.h

index 5eca3c3a2aeda4b341194efefb1f3a6d9792d074..32aef3846269aebe27c56c7e31a3b7477b8246d1 100644 (file)
 # define _FUSE_HELPER { 0 }
 #endif
 
+#ifdef MCUSR
+# define MCU_STATUS_REG MCUSR
+#else
+# define MCU_STATUS_REG MCUCSR
+#endif
+
 #ifdef SIGNATURE_0
 #define DEFAULT_CORE(_vector_size) \
        .ramend = RAMEND, \
        .vector_size = _vector_size, \
        .fuse = _FUSE_HELPER, \
        .signature = { SIGNATURE_0,SIGNATURE_1,SIGNATURE_2 }, \
-       .lockbits = 0xFF
+       .lockbits = 0xFF, \
+       .reset_flags = {\
+               .porf = AVR_IO_REGBIT(MCU_STATUS_REG, PORF),\
+               .extrf = AVR_IO_REGBIT(MCU_STATUS_REG, EXTRF),\
+               .borf = AVR_IO_REGBIT(MCU_STATUS_REG, BORF),\
+               .wdrf = AVR_IO_REGBIT(MCU_STATUS_REG, WDRF)\
+       }
 #else
 // Disable signature when using an old avr toolchain
 #define DEFAULT_CORE(_vector_size) \
index 25409352a5b9df259d9c2fe25fbf4162caf72e35..63b5a9de0a9e11dc48b01c0ce529afa6a2d5095c 100644 (file)
@@ -102,6 +102,7 @@ avr_init(
        avr->address_size = avr->eind ? 3 : 2;
        avr->log = 1;
        avr_reset(avr);
+       avr_regbit_set(avr, avr->reset_flags.porf);             // by  default set to power-on reset
        return 0;
 }
 
index f4a4eac22f0e4fda8ba51a8a26d4619a9682270a..edbe7a767c51185c7e090ea522f9adf78c0a3dfb 100644 (file)
@@ -159,6 +159,12 @@ typedef struct avr_t {
        avr_io_addr_t           rampz;  // optional, only for ELPM/SPM on >64Kb cores
        avr_io_addr_t           eind;   // optional, only for EIJMP/EICALL on >64Kb cores
        uint8_t                         address_size;   // 2, or 3 for cores >128KB in flash
+       struct {
+               avr_regbit_t            porf;
+               avr_regbit_t            extrf;
+               avr_regbit_t            borf;
+               avr_regbit_t            wdrf;
+       } reset_flags;
 
        // filled by the ELF data, this allow tracking of invalid jumps
        uint32_t                        codeend;