@@ -233,6 +233,10 @@ static void atmega_realize(DeviceState *dev, Error **errp)
/* CPU */
object_initialize_child(OBJECT(dev), "cpu", &s->cpu, mc->cpu_type);
+
+ object_property_set_uint(OBJECT(&s->cpu), "init-sp",
+ mc->io_size + mc->sram_size - 1, &error_abort);
+
qdev_realize(DEVICE(&s->cpu), NULL, &error_abort);
cpudev = DEVICE(&s->cpu);
@@ -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;
@@ -154,6 +155,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;
@@ -231,6 +237,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);
@@ -150,6 +150,9 @@ struct ArchCPU {
CPUNegativeOffsetState neg;
CPUAVRState env;
+
+ /* Initial value of stack pointer */
+ uint32_t init_sp;
};
extern const struct VMStateDescription vms_avr_cpu;