diff options
author | Gihun Nam <gihun.nam@outlook.com> | 2023-11-27 11:54:20 +0900 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-11-28 14:27:12 +0100 |
commit | 235948bf53860a1e2df5134eae7b0a30a971a124 (patch) | |
tree | abc0a352dbd85063b3a0abae1b99b1198e513949 /target/avr | |
parent | 0ed083a1bcdbdfe77ded69b3524ad22d120fae03 (diff) | |
download | qemu-235948bf53860a1e2df5134eae7b0a30a971a124.zip qemu-235948bf53860a1e2df5134eae7b0a30a971a124.tar.gz qemu-235948bf53860a1e2df5134eae7b0a30a971a124.tar.bz2 |
hw/avr/atmega: Fix wrong initial value of stack pointer
The current implementation initializes the stack pointer of AVR devices
to 0. Although older AVR devices used to be like that, newer ones set
it to RAMEND.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1525
Signed-off-by: Gihun Nam <gihun.nam@outlook.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <PH0P222MB0010877445B594724D40C924DEBDA@PH0P222MB0010.NAMP222.PROD.OUTLOOK.COM>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'target/avr')
-rw-r--r-- | target/avr/cpu.c | 10 | ||||
-rw-r--r-- | target/avr/cpu.h | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 44de1e1..999c010 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -25,6 +25,7 @@ #include "cpu.h" #include "disas/dis-asm.h" #include "tcg/debug-assert.h" +#include "hw/qdev-properties.h" static void avr_cpu_set_pc(CPUState *cs, vaddr value) { @@ -95,7 +96,7 @@ static void avr_cpu_reset_hold(Object *obj) env->rampY = 0; env->rampZ = 0; env->eind = 0; - env->sp = 0; + env->sp = cpu->init_sp; env->skip = 0; @@ -152,6 +153,11 @@ static void avr_cpu_initfn(Object *obj) sizeof(cpu->env.intsrc) * 8); } +static Property avr_cpu_properties[] = { + DEFINE_PROP_UINT32("init-sp", AVRCPU, init_sp, 0), + DEFINE_PROP_END_OF_LIST() +}; + static ObjectClass *avr_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; @@ -228,6 +234,8 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) device_class_set_parent_realize(dc, avr_cpu_realizefn, &mcc->parent_realize); + device_class_set_props(dc, avr_cpu_properties); + resettable_class_set_parent_phases(rc, NULL, avr_cpu_reset_hold, NULL, &mcc->parent_phases); diff --git a/target/avr/cpu.h b/target/avr/cpu.h index 8a17862..7960c5c 100644 --- a/target/avr/cpu.h +++ b/target/avr/cpu.h @@ -145,6 +145,9 @@ struct ArchCPU { CPUState parent_obj; CPUAVRState env; + + /* Initial value of stack pointer */ + uint32_t init_sp; }; /** |