mirror of https://gitee.com/openkylin/qemu.git
ppc: simplify cpu model lookup by PVR
Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
03c9141d75
commit
b376db7775
|
@ -34,6 +34,7 @@
|
||||||
#include "hw/ppc/ppc.h"
|
#include "hw/ppc/ppc.h"
|
||||||
#include "mmu-book3s-v3.h"
|
#include "mmu-book3s-v3.h"
|
||||||
#include "sysemu/qtest.h"
|
#include "sysemu/qtest.h"
|
||||||
|
#include "qemu/cutils.h"
|
||||||
|
|
||||||
//#define PPC_DUMP_CPU
|
//#define PPC_DUMP_CPU
|
||||||
//#define PPC_DEBUG_SPR
|
//#define PPC_DEBUG_SPR
|
||||||
|
@ -10279,22 +10280,16 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
|
||||||
char *cpu_model, *typename;
|
char *cpu_model, *typename;
|
||||||
ObjectClass *oc;
|
ObjectClass *oc;
|
||||||
const char *p;
|
const char *p;
|
||||||
int i, len;
|
unsigned long pvr;
|
||||||
|
|
||||||
/* Check if the given name is a PVR */
|
/* Lookup by PVR if cpu_model is valid 8 digit hex number
|
||||||
len = strlen(name);
|
* (excl: 0x prefix if present)
|
||||||
if (len == 10 && name[0] == '0' && name[1] == 'x') {
|
*/
|
||||||
p = name + 2;
|
if (!qemu_strtoul(name, &p, 16, &pvr)) {
|
||||||
goto check_pvr;
|
int len = p - name;
|
||||||
} else if (len == 8) {
|
len = (len == 10) && (name[1] == 'x') ? len - 2 : len;
|
||||||
p = name;
|
if ((len == 8) && (*p == '\0')) {
|
||||||
check_pvr:
|
return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr));
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
if (!qemu_isxdigit(*p++))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == 8) {
|
|
||||||
return OBJECT_CLASS(ppc_cpu_class_by_pvr(strtoul(name, NULL, 16)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue