riscv: hart: Extract hart realize to a separate routine
Currently riscv_harts_realize() creates all harts based on the same cpu type given in the hart array property. With current implementation it can only create homogeneous harts. Exact the hart realize to a separate routine in preparation for supporting multiple hart arrays. Note the file header says the RISC-V hart array holds the state of a heterogeneous array of RISC-V harts, which is not true. Update the comment to mention homogeneous array of RISC-V harts. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
This commit is contained in:
parent
20f41c8698
commit
91c985851d
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2017 SiFive, Inc.
|
||||
*
|
||||
* Holds the state of a heterogenous array of RISC-V harts
|
||||
* Holds the state of a homogeneous array of RISC-V harts
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@ -39,26 +39,33 @@ static void riscv_harts_cpu_reset(void *opaque)
|
||||
cpu_reset(CPU(cpu));
|
||||
}
|
||||
|
||||
static void riscv_hart_realize(RISCVHartArrayState *s, int idx,
|
||||
char *cpu_type, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
||||
object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx],
|
||||
sizeof(RISCVCPU), cpu_type,
|
||||
&error_abort, NULL);
|
||||
s->harts[idx].env.mhartid = idx;
|
||||
qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]);
|
||||
object_property_set_bool(OBJECT(&s->harts[idx]), true,
|
||||
"realized", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void riscv_harts_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
RISCVHartArrayState *s = RISCV_HART_ARRAY(dev);
|
||||
Error *err = NULL;
|
||||
int n;
|
||||
|
||||
s->harts = g_new0(RISCVCPU, s->num_harts);
|
||||
|
||||
for (n = 0; n < s->num_harts; n++) {
|
||||
object_initialize_child(OBJECT(s), "harts[*]", &s->harts[n],
|
||||
sizeof(RISCVCPU), s->cpu_type,
|
||||
&error_abort, NULL);
|
||||
s->harts[n].env.mhartid = n;
|
||||
qemu_register_reset(riscv_harts_cpu_reset, &s->harts[n]);
|
||||
object_property_set_bool(OBJECT(&s->harts[n]), true,
|
||||
"realized", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
riscv_hart_realize(s, n, s->cpu_type, errp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user