mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 05:41:04 +00:00
pc: use generic cpu_model parsing
define default CPU type in generic way in pc_machine_class_init() and let common machine code to handle cpu_model parsing Patch also introduces TARGET_DEFAULT_CPU_TYPE define for 2 purposes: * make foo_machine_class_init() look uniform on every target * use define in [bsd|linux]-user targets to pick default cpu type Backports commit 311ca98d16bbb6a2a38b38ba898baa4a4d4ab9a7 from qemu
This commit is contained in:
parent
733d60e6d7
commit
20f67e8f9a
|
@ -119,41 +119,12 @@ static X86CPU *pc_new_cpu(struct uc_struct *uc, const char *typename, int64_t ap
|
|||
int pc_cpus_init(struct uc_struct *uc, PCMachineState *pcms)
|
||||
{
|
||||
int i;
|
||||
CPUClass *cc;
|
||||
ObjectClass *oc;
|
||||
const char *typename;
|
||||
gchar **model_pieces;
|
||||
Error *error = NULL;
|
||||
MachineState *machine = MACHINE(uc, pcms);
|
||||
MachineState *ms = MACHINE(uc, pcms);
|
||||
|
||||
/* init CPUs */
|
||||
if (machine->cpu_model == NULL) {
|
||||
#ifdef TARGET_X86_64
|
||||
machine->cpu_model = "qemu64";
|
||||
#else
|
||||
machine->cpu_model = "qemu32";
|
||||
#endif
|
||||
}
|
||||
|
||||
model_pieces = g_strsplit(machine->cpu_model, ",", 2);
|
||||
if (!model_pieces[0]) {
|
||||
fprintf(stderr, "Invalid/empty CPU model name");
|
||||
return -1;
|
||||
}
|
||||
|
||||
oc = cpu_class_by_name(uc, TYPE_X86_CPU, model_pieces[0]);
|
||||
if (oc == NULL) {
|
||||
fprintf(stderr, "Unable to find CPU definition: %s", model_pieces[0]);
|
||||
return -1;
|
||||
}
|
||||
typename = object_class_get_name(oc);
|
||||
cc = CPU_CLASS(uc, oc);
|
||||
cc->parse_features(uc, typename, model_pieces[1], &error_fatal);
|
||||
g_strfreev(model_pieces);
|
||||
for (i = 0; i < smp_cpus; i++) {
|
||||
uc->cpu = (CPUState *)pc_new_cpu(uc, typename, x86_cpu_apic_id_from_index(i), &error);
|
||||
uc->cpu = (CPUState *)pc_new_cpu(uc, ms->cpu_type, x86_cpu_apic_id_from_index(i), &error);
|
||||
if (error) {
|
||||
//error_report("%s", error_get_pretty(error));
|
||||
error_free(error);
|
||||
return -1;
|
||||
}
|
||||
|
@ -168,6 +139,8 @@ static void pc_machine_initfn(struct uc_struct *uc, Object *obj, void *opaque)
|
|||
|
||||
static void pc_machine_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)
|
||||
{
|
||||
MachineClass *mc = MACHINE_CLASS(uc, oc);
|
||||
mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
|
||||
}
|
||||
|
||||
static const TypeInfo pc_machine_info = {
|
||||
|
|
|
@ -910,12 +910,6 @@ void host_vendor_fms(char *vendor, int *family, int *model, int *stepping)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* CPU class name definitions: */
|
||||
|
||||
#define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
|
||||
#define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
|
||||
|
||||
/* Return type name for a given CPU model name
|
||||
* Caller is responsible for freeing the returned string.
|
||||
*/
|
||||
|
|
|
@ -1529,6 +1529,12 @@ uint64_t cpu_get_tsc(CPUX86State *env);
|
|||
#define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
|
||||
#define CPU_RESOLVING_TYPE TYPE_X86_CPU
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64")
|
||||
#else
|
||||
#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32")
|
||||
#endif
|
||||
|
||||
#define cpu_signal_handler cpu_x86_signal_handler
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue