mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
hw/intc/loongarch_extioi: Get cpu number from possible_cpu_arch_ids
Supported CPU number can be acquired from function possible_cpu_arch_ids(), cpu-num property is not necessary. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Bibo Mao <maobibo@loongson.cn>
This commit is contained in:
parent
38adceb4c3
commit
5a3e068d41
3 changed files with 17 additions and 8 deletions
|
@ -13,11 +13,24 @@
|
|||
static void loongarch_extioi_common_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
LoongArchExtIOICommonState *s = (LoongArchExtIOICommonState *)dev;
|
||||
MachineState *machine = MACHINE(qdev_get_machine());
|
||||
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
||||
const CPUArchIdList *id_list;
|
||||
int i;
|
||||
|
||||
if (s->num_cpu == 0) {
|
||||
error_setg(errp, "num-cpu must be at least 1");
|
||||
assert(mc->possible_cpu_arch_ids);
|
||||
id_list = mc->possible_cpu_arch_ids(machine);
|
||||
s->num_cpu = id_list->len;
|
||||
s->cpu = g_new0(ExtIOICore, s->num_cpu);
|
||||
if (s->cpu == NULL) {
|
||||
error_setg(errp, "Memory allocation for ExtIOICore faile");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < s->num_cpu; i++) {
|
||||
s->cpu[i].arch_id = id_list->cpus[i].arch_id;
|
||||
s->cpu[i].cpu = CPU(id_list->cpus[i].cpu);
|
||||
}
|
||||
}
|
||||
|
||||
static int loongarch_extioi_common_pre_save(void *opaque)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue