qemu-sparc queue

-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEzGIauY6CIA2RXMnEW8LFb64PMh8FAlsn7zweHG1hcmsuY2F2
 ZS1heWxhbmRAaWxhbmRlLmNvLnVrAAoJEFvCxW+uDzIfwZwH/2Rq5qG+OHdY13wv
 vanFNbRRsBSXhxO7+E9zggGAtCbFpWq54GhbNUDppK0z3JKlLE6T0gtNBTSGVrew
 LiXicYAAzTJSqOYq10Ke8frKYqW6Ap+ANR87v1ab0q3nofeOmRVDguMLF7iD8FYP
 6yNiSOHdOp4WB7oZl6MuxzFYLDqxc499WZbRJOqUx+K4W1B95B4l2z1y8II/CRVB
 uhIkBo3oivYmZV8aLG+uIeRJUmFFSDU5c6bdNeQ35rDgijfBetWfj5rHV7PxbNIw
 h6vysuUIoDMX3rygKeAtETGpFMF9hGdK0CHse9CfT0kZGA2ZrauEWRwGismX9qcj
 rYxRGFM=
 =Z3ee
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/mcayland/tags/qemu-sparc-20180618' into staging

qemu-sparc queue

# gpg: Signature made Mon 18 Jun 2018 18:43:24 BST
# gpg:                using RSA key 5BC2C56FAE0F321F
# gpg: Good signature from "Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>"
# Primary key fingerprint: CC62 1AB9 8E82 200D 915C  C9C4 5BC2 C56F AE0F 321F

* remotes/mcayland/tags/qemu-sparc-20180618:
  SPARC64: add icount support
  hw/sparc/sun4m: Fix problems with device introspection
  hw/sparc64/sun4u: Fix introspection by converting prom instance_init to realize

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-06-19 17:42:50 +01:00
commit 79449bc311
3 changed files with 172 additions and 24 deletions

View File

@ -572,23 +572,36 @@ typedef struct IDRegState {
MemoryRegion mem; MemoryRegion mem;
} IDRegState; } IDRegState;
static void idreg_init1(Object *obj) static void idreg_realize(DeviceState *ds, Error **errp)
{ {
IDRegState *s = MACIO_ID_REGISTER(obj); IDRegState *s = MACIO_ID_REGISTER(ds);
SysBusDevice *dev = SYS_BUS_DEVICE(obj); SysBusDevice *dev = SYS_BUS_DEVICE(ds);
Error *local_err = NULL;
memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idreg",
sizeof(idreg_data), &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
memory_region_init_ram_nomigrate(&s->mem, obj,
"sun4m.idreg", sizeof(idreg_data), &error_fatal);
vmstate_register_ram_global(&s->mem); vmstate_register_ram_global(&s->mem);
memory_region_set_readonly(&s->mem, true); memory_region_set_readonly(&s->mem, true);
sysbus_init_mmio(dev, &s->mem); sysbus_init_mmio(dev, &s->mem);
} }
static void idreg_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = idreg_realize;
}
static const TypeInfo idreg_info = { static const TypeInfo idreg_info = {
.name = TYPE_MACIO_ID_REGISTER, .name = TYPE_MACIO_ID_REGISTER,
.parent = TYPE_SYS_BUS_DEVICE, .parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(IDRegState), .instance_size = sizeof(IDRegState),
.instance_init = idreg_init1, .class_init = idreg_class_init,
}; };
#define TYPE_TCX_AFX "tcx_afx" #define TYPE_TCX_AFX "tcx_afx"
@ -613,21 +626,35 @@ static void afx_init(hwaddr addr)
sysbus_mmio_map(s, 0, addr); sysbus_mmio_map(s, 0, addr);
} }
static void afx_init1(Object *obj) static void afx_realize(DeviceState *ds, Error **errp)
{ {
AFXState *s = TCX_AFX(obj); AFXState *s = TCX_AFX(ds);
SysBusDevice *dev = SYS_BUS_DEVICE(obj); SysBusDevice *dev = SYS_BUS_DEVICE(ds);
Error *local_err = NULL;
memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx", 4,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
memory_region_init_ram_nomigrate(&s->mem, obj, "sun4m.afx", 4, &error_fatal);
vmstate_register_ram_global(&s->mem); vmstate_register_ram_global(&s->mem);
sysbus_init_mmio(dev, &s->mem); sysbus_init_mmio(dev, &s->mem);
} }
static void afx_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = afx_realize;
}
static const TypeInfo afx_info = { static const TypeInfo afx_info = {
.name = TYPE_TCX_AFX, .name = TYPE_TCX_AFX,
.parent = TYPE_SYS_BUS_DEVICE, .parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(AFXState), .instance_size = sizeof(AFXState),
.instance_init = afx_init1, .class_init = afx_class_init,
}; };
#define TYPE_OPENPROM "openprom" #define TYPE_OPENPROM "openprom"
@ -680,13 +707,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
} }
} }
static void prom_init1(Object *obj) static void prom_realize(DeviceState *ds, Error **errp)
{ {
PROMState *s = OPENPROM(obj); PROMState *s = OPENPROM(ds);
SysBusDevice *dev = SYS_BUS_DEVICE(obj); SysBusDevice *dev = SYS_BUS_DEVICE(ds);
Error *local_err = NULL;
memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.prom",
PROM_SIZE_MAX, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
memory_region_init_ram_nomigrate(&s->prom, obj, "sun4m.prom", PROM_SIZE_MAX,
&error_fatal);
vmstate_register_ram_global(&s->prom); vmstate_register_ram_global(&s->prom);
memory_region_set_readonly(&s->prom, true); memory_region_set_readonly(&s->prom, true);
sysbus_init_mmio(dev, &s->prom); sysbus_init_mmio(dev, &s->prom);
@ -701,6 +734,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
dc->props = prom_properties; dc->props = prom_properties;
dc->realize = prom_realize;
} }
static const TypeInfo prom_info = { static const TypeInfo prom_info = {
@ -708,7 +742,6 @@ static const TypeInfo prom_info = {
.parent = TYPE_SYS_BUS_DEVICE, .parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(PROMState), .instance_size = sizeof(PROMState),
.class_init = prom_class_init, .class_init = prom_class_init,
.instance_init = prom_init1,
}; };
#define TYPE_SUN4M_MEMORY "memory" #define TYPE_SUN4M_MEMORY "memory"

View File

@ -425,13 +425,19 @@ static void prom_init(hwaddr addr, const char *bios_name)
} }
} }
static void prom_init1(Object *obj) static void prom_realize(DeviceState *ds, Error **errp)
{ {
PROMState *s = OPENPROM(obj); PROMState *s = OPENPROM(ds);
SysBusDevice *dev = SYS_BUS_DEVICE(obj); SysBusDevice *dev = SYS_BUS_DEVICE(ds);
Error *local_err = NULL;
memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
PROM_SIZE_MAX, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
memory_region_init_ram_nomigrate(&s->prom, obj, "sun4u.prom", PROM_SIZE_MAX,
&error_fatal);
vmstate_register_ram_global(&s->prom); vmstate_register_ram_global(&s->prom);
memory_region_set_readonly(&s->prom, true); memory_region_set_readonly(&s->prom, true);
sysbus_init_mmio(dev, &s->prom); sysbus_init_mmio(dev, &s->prom);
@ -446,6 +452,7 @@ static void prom_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
dc->props = prom_properties; dc->props = prom_properties;
dc->realize = prom_realize;
} }
static const TypeInfo prom_info = { static const TypeInfo prom_info = {
@ -453,7 +460,6 @@ static const TypeInfo prom_info = {
.parent = TYPE_SYS_BUS_DEVICE, .parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(PROMState), .instance_size = sizeof(PROMState),
.class_init = prom_class_init, .class_init = prom_class_init,
.instance_init = prom_init1,
}; };

View File

@ -41,6 +41,8 @@
#define JUMP_PC 2 /* dynamic pc value which takes only two values #define JUMP_PC 2 /* dynamic pc value which takes only two values
according to jump_pc[T2] */ according to jump_pc[T2] */
#define DISAS_EXIT DISAS_TARGET_0
/* global register indexes */ /* global register indexes */
static TCGv_ptr cpu_regwptr; static TCGv_ptr cpu_regwptr;
static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst; static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst;
@ -3400,11 +3402,17 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_const = tcg_const_i32(dc->mem_idx); r_const = tcg_const_i32(dc->mem_idx);
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, tick)); offsetof(CPUSPARCState, tick));
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr, gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr,
r_const); r_const);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
tcg_temp_free_i32(r_const); tcg_temp_free_i32(r_const);
gen_store_gpr(dc, rd, cpu_dst); gen_store_gpr(dc, rd, cpu_dst);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
} }
break; break;
case 0x5: /* V9 rdpc */ case 0x5: /* V9 rdpc */
@ -3447,11 +3455,17 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_const = tcg_const_i32(dc->mem_idx); r_const = tcg_const_i32(dc->mem_idx);
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, stick)); offsetof(CPUSPARCState, stick));
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr, gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr,
r_const); r_const);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
tcg_temp_free_i32(r_const); tcg_temp_free_i32(r_const);
gen_store_gpr(dc, rd, cpu_dst); gen_store_gpr(dc, rd, cpu_dst);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
} }
break; break;
case 0x19: /* System tick compare */ case 0x19: /* System tick compare */
@ -3576,10 +3590,16 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_const = tcg_const_i32(dc->mem_idx); r_const = tcg_const_i32(dc->mem_idx);
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, tick)); offsetof(CPUSPARCState, tick));
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_get_count(cpu_tmp0, cpu_env, gen_helper_tick_get_count(cpu_tmp0, cpu_env,
r_tickptr, r_const); r_tickptr, r_const);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
tcg_temp_free_i32(r_const); tcg_temp_free_i32(r_const);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
} }
break; break;
case 5: // tba case 5: // tba
@ -4385,9 +4405,19 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_tickptr = tcg_temp_new_ptr(); r_tickptr = tcg_temp_new_ptr();
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, tick)); offsetof(CPUSPARCState, tick));
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_set_limit(r_tickptr, gen_helper_tick_set_limit(r_tickptr,
cpu_tick_cmpr); cpu_tick_cmpr);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_end();
}
/* End TB to handle timer interrupt */
dc->base.is_jmp = DISAS_EXIT;
} }
break; break;
case 0x18: /* System tick */ case 0x18: /* System tick */
@ -4403,9 +4433,19 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_tickptr = tcg_temp_new_ptr(); r_tickptr = tcg_temp_new_ptr();
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, stick)); offsetof(CPUSPARCState, stick));
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_set_count(r_tickptr, gen_helper_tick_set_count(r_tickptr,
cpu_tmp0); cpu_tmp0);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_end();
}
/* End TB to handle timer interrupt */
dc->base.is_jmp = DISAS_EXIT;
} }
break; break;
case 0x19: /* System tick compare */ case 0x19: /* System tick compare */
@ -4421,9 +4461,19 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_tickptr = tcg_temp_new_ptr(); r_tickptr = tcg_temp_new_ptr();
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, stick)); offsetof(CPUSPARCState, stick));
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_set_limit(r_tickptr, gen_helper_tick_set_limit(r_tickptr,
cpu_stick_cmpr); cpu_stick_cmpr);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_end();
}
/* End TB to handle timer interrupt */
dc->base.is_jmp = DISAS_EXIT;
} }
break; break;
@ -4531,9 +4581,19 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_tickptr = tcg_temp_new_ptr(); r_tickptr = tcg_temp_new_ptr();
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, tick)); offsetof(CPUSPARCState, tick));
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_set_count(r_tickptr, gen_helper_tick_set_count(r_tickptr,
cpu_tmp0); cpu_tmp0);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_end();
}
/* End TB to handle timer interrupt */
dc->base.is_jmp = DISAS_EXIT;
} }
break; break;
case 5: // tba case 5: // tba
@ -4541,7 +4601,13 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
break; break;
case 6: // pstate case 6: // pstate
save_state(dc); save_state(dc);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_wrpstate(cpu_env, cpu_tmp0); gen_helper_wrpstate(cpu_env, cpu_tmp0);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
break; break;
case 7: // tl case 7: // tl
@ -4551,7 +4617,13 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
break; break;
case 8: // pil case 8: // pil
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_wrpil(cpu_env, cpu_tmp0); gen_helper_wrpil(cpu_env, cpu_tmp0);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
break; break;
case 9: // cwp case 9: // cwp
gen_helper_wrcwp(cpu_env, cpu_tmp0); gen_helper_wrcwp(cpu_env, cpu_tmp0);
@ -4642,9 +4714,19 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
r_tickptr = tcg_temp_new_ptr(); r_tickptr = tcg_temp_new_ptr();
tcg_gen_ld_ptr(r_tickptr, cpu_env, tcg_gen_ld_ptr(r_tickptr, cpu_env,
offsetof(CPUSPARCState, hstick)); offsetof(CPUSPARCState, hstick));
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_tick_set_limit(r_tickptr, gen_helper_tick_set_limit(r_tickptr,
cpu_hstick_cmpr); cpu_hstick_cmpr);
tcg_temp_free_ptr(r_tickptr); tcg_temp_free_ptr(r_tickptr);
if (tb_cflags(dc->base.tb) &
CF_USE_ICOUNT) {
gen_io_end();
}
/* End TB to handle timer interrupt */
dc->base.is_jmp = DISAS_EXIT;
} }
break; break;
case 6: // hver readonly case 6: // hver readonly
@ -5265,14 +5347,26 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
goto priv_insn; goto priv_insn;
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
dc->pc = DYNAMIC_PC; dc->pc = DYNAMIC_PC;
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_done(cpu_env); gen_helper_done(cpu_env);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
goto jmp_insn; goto jmp_insn;
case 1: case 1:
if (!supervisor(dc)) if (!supervisor(dc))
goto priv_insn; goto priv_insn;
dc->npc = DYNAMIC_PC; dc->npc = DYNAMIC_PC;
dc->pc = DYNAMIC_PC; dc->pc = DYNAMIC_PC;
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_retry(cpu_env); gen_helper_retry(cpu_env);
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
gen_io_end();
}
goto jmp_insn; goto jmp_insn;
default: default:
goto illegal_insn; goto illegal_insn;
@ -5822,7 +5916,9 @@ static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
{ {
DisasContext *dc = container_of(dcbase, DisasContext, base); DisasContext *dc = container_of(dcbase, DisasContext, base);
if (dc->base.is_jmp != DISAS_NORETURN) { switch (dc->base.is_jmp) {
case DISAS_NEXT:
case DISAS_TOO_MANY:
if (dc->pc != DYNAMIC_PC && if (dc->pc != DYNAMIC_PC &&
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) { (dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
/* static PC and NPC: we can use direct chaining */ /* static PC and NPC: we can use direct chaining */
@ -5834,6 +5930,19 @@ static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
save_npc(dc); save_npc(dc);
tcg_gen_exit_tb(NULL, 0); tcg_gen_exit_tb(NULL, 0);
} }
break;
case DISAS_NORETURN:
break;
case DISAS_EXIT:
/* Exit TB */
save_state(dc);
tcg_gen_exit_tb(NULL, 0);
break;
default:
g_assert_not_reached();
} }
} }