Skip to content

Commit

Permalink
ppc: simplify cpu model lookup by PVR
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Mammedov <[email protected]>
Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
Igor Mammedov authored and dgibson committed Sep 7, 2017
1 parent 03c9141 commit b376db7
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions target/ppc/translate_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "hw/ppc/ppc.h"
#include "mmu-book3s-v3.h"
#include "sysemu/qtest.h"
#include "qemu/cutils.h"

//#define PPC_DUMP_CPU
//#define PPC_DEBUG_SPR
Expand Down Expand Up @@ -10279,22 +10280,16 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
char *cpu_model, *typename;
ObjectClass *oc;
const char *p;
int i, len;

/* Check if the given name is a PVR */
len = strlen(name);
if (len == 10 && name[0] == '0' && name[1] == 'x') {
p = name + 2;
goto check_pvr;
} else if (len == 8) {
p = name;
check_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)));
unsigned long pvr;

/* Lookup by PVR if cpu_model is valid 8 digit hex number
* (excl: 0x prefix if present)
*/
if (!qemu_strtoul(name, &p, 16, &pvr)) {
int len = p - name;
len = (len == 10) && (name[1] == 'x') ? len - 2 : len;
if ((len == 8) && (*p == '\0')) {
return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr));
}
}

Expand Down

0 comments on commit b376db7

Please sign in to comment.