pc: Don't use QEMUMachine anymore

Now that we have a DEFINE_PC_MACHINE helper macro that just requires an
initialization function, it is trivial to convert them to register a QOM
machine class directly, instead of using QEMUMachine.

Backports commit 865906f7fdadd2732441ab158787f81f6a212bfe from qemu
This commit is contained in:
Eduardo Habkost 2018-03-09 14:12:03 -05:00 committed by Lioncash
parent b65a3ece3b
commit 12acb995fa
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 36 additions and 23 deletions

View file

@ -49,6 +49,16 @@ static int pc_init_pci(struct uc_struct *uc, MachineState *machine)
return pc_init1(uc, machine);
}
static void pc_compat_2_2(struct uc_struct *uc, MachineState *machine)
{
}
static int pc_init_pci_2_2(struct uc_struct *uc, MachineState *machine)
{
pc_compat_2_2(uc, machine);
return pc_init_pci(uc, machine);
}
static QEMUMachine pc_i440fx_machine_v2_2 = {
"pc_piix",
"pc-i440fx-2.2",
@ -59,23 +69,4 @@ static QEMUMachine pc_i440fx_machine_v2_2 = {
UC_ARCH_X86, // X86
};
static void pc_generic_machine_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(uc, oc);
QEMUMachine *qm = data;
mc->family = qm->family;
mc->name = qm->name;
mc->init = qm->init;
mc->reset = qm->reset;
mc->max_cpus = qm->max_cpus;
mc->is_default = qm->is_default;
mc->arch = qm->arch;
}
void pc_machine_init(struct uc_struct *uc);
void pc_machine_init(struct uc_struct *uc)
{
qemu_register_machine(uc, &pc_i440fx_machine_v2_2,
TYPE_PC_MACHINE, pc_generic_machine_class_init);
}
DEFINE_PC_MACHINE(v2_2, "pc-i440fx-2.2", pc_init_pci_2_2);

View file

@ -47,4 +47,26 @@ void x86_cpu_register_types(struct uc_struct *uc);
#define PC_DEFAULT_MACHINE_OPTIONS \
.max_cpus = 255
// Unicorn: Modified to work with Unicorn.
#define DEFINE_PC_MACHINE(suffix, namestr, initfn) \
static void pc_machine_##suffix##_class_init(struct uc_struct *uc, ObjectClass *oc, void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(uc, oc); \
mc->max_cpus = 255; \
mc->is_default = 1; \
mc->name = namestr; \
mc->init = initfn; \
mc->arch = UC_ARCH_X86; \
} \
static const TypeInfo pc_machine_type_##suffix = { \
.name = namestr TYPE_MACHINE_SUFFIX, \
.parent = TYPE_PC_MACHINE, \
.class_init = pc_machine_##suffix##_class_init, \
}; \
void pc_machine_init_##suffix(struct uc_struct *uc); \
void pc_machine_init_##suffix(struct uc_struct *uc) \
{ \
type_register(uc, &pc_machine_type_##suffix); \
}
#endif

View file

@ -1336,8 +1336,6 @@ static bool x86_stop_interrupt(int intno)
}
}
void pc_machine_init(struct uc_struct *uc);
static bool x86_insn_hook_validate(uint32_t insn_enum)
{
//for x86 we can only hook IN, OUT, and SYSCALL
@ -1349,6 +1347,8 @@ static bool x86_insn_hook_validate(uint32_t insn_enum)
return true;
}
void pc_machine_init_v2_2(struct uc_struct *uc);
DEFAULT_VISIBILITY
void x86_uc_init(struct uc_struct* uc)
{
@ -1357,7 +1357,7 @@ void x86_uc_init(struct uc_struct* uc)
register_accel_types(uc);
pc_machine_register_types(uc);
x86_cpu_register_types(uc);
pc_machine_init(uc); // pc_piix
pc_machine_init_v2_2(uc); // pc_piix
uc->reg_read = x86_reg_read;
uc->reg_write = x86_reg_write;
uc->reg_reset = x86_reg_reset;