Received: from eggs.gnu.org ([208.118.235.92]:46196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TY2Ho-00031t-Sa for qemu-devel@nongnu.org; Mon, 12 Nov 2012 17:15:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TY2Hl-0007RN-R1 for qemu-devel@nongnu.org; Mon, 12 Nov 2012 17:15:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TY2Hl-0007R3-IA for qemu-devel@nongnu.org; Mon, 12 Nov 2012 17:15:17 -0500 Date: Mon, 12 Nov 2012 20:16:19 -0200 From: Eduardo Habkost Message-ID: <20121112221619.GH8231@otherpad.lan.raisama.net> References: <1334421743-31146-1-git-send-email-peter.maydell@linaro.org> <1334421743-31146-3-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1334421743-31146-3-git-send-email-peter.maydell@linaro.org> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 01/14] target-arm: Add QOM subclasses for each ARM cpu implementation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Anthony Liguori , patches@linaro.org, qemu-devel@nongnu.org, Andreas =?iso-8859-1?Q?F=E4rber?= , Paul Brook Sorry for replying to a patch 7 months later, but I just have a question related to how we will handle CPU model classes on all targets: On Sat, Apr 14, 2012 at 05:42:10PM +0100, Peter Maydell wrote: > Register subclasses for each ARM CPU implementation (with the > exception of "pxa270", which is an alias for "pxa270-a0"). >=20 > Let arm_cpu_list() enumerate CPU subclasses in alphabetical order, > except for special value "any". >=20 > Replace cpu_arm_find_by_name()'s string -> CPUID lookup by storing the > CPUID (aka MIDR, Main ID Register) value in the class. >=20 > Signed-off-by: Andreas F=E4rber > Signed-off-by: Peter Maydell > --- > target-arm/cpu-qom.h | 12 +++ > target-arm/cpu.c | 226 ++++++++++++++++++++++++++++++++++++++++++= +++++++- > target-arm/helper.c | 109 ++++++++++-------------- > 3 files changed, 282 insertions(+), 65 deletions(-) >=20 > diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h > index 42d2a6b..a4bcb31 100644 > --- a/target-arm/cpu-qom.h > +++ b/target-arm/cpu-qom.h > @@ -58,6 +58,18 @@ typedef struct ARMCPU { [...] > +typedef struct ARMCPUInfo { > + const char *name; > + void (*initfn)(Object *obj); > +} ARMCPUInfo; > + > +static const ARMCPUInfo arm_cpus[] =3D { [...] > + { .name =3D "any", .initfn =3D arm_any_initfn }, > +}; > + Do we really want to use "any" as the class name? Maybe we should use "cpu-" as the namespace for the CPU model class names? Or maybe try "cpu-" first, and then "" as a fallback (making sure that the class we found is a subclass of TYPE__CPU). I guess we will want address this before qdevifying the CPU class, as the qdevification will make the CPU class names visible through the monitor. > static void arm_cpu_class_init(ObjectClass *oc, void *data) > { > ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); > @@ -43,18 +248,37 @@ static void arm_cpu_class_init(ObjectClass *oc, vo= id *data) > cc->reset =3D arm_cpu_reset; > } > =20 > +static void cpu_register(const ARMCPUInfo *info) > +{ > + TypeInfo type_info =3D { > + .name =3D info->name, > + .parent =3D TYPE_ARM_CPU, > + .instance_size =3D sizeof(ARMCPU), > + .instance_init =3D info->initfn, > + .class_size =3D sizeof(ARMCPUClass), > + }; > + > + type_register_static(&type_info); > +} > + > static const TypeInfo arm_cpu_type_info =3D { > .name =3D TYPE_ARM_CPU, > .parent =3D TYPE_CPU, > .instance_size =3D sizeof(ARMCPU), > - .abstract =3D false, > + .instance_init =3D arm_cpu_initfn, > + .abstract =3D true, > .class_size =3D sizeof(ARMCPUClass), > .class_init =3D arm_cpu_class_init, > }; > =20 > static void arm_cpu_register_types(void) > { > + int i; > + > type_register_static(&arm_cpu_type_info); > + for (i =3D 0; i < ARRAY_SIZE(arm_cpus); i++) { > + cpu_register(&arm_cpus[i]); > + } > } > =20 > type_init(arm_cpu_register_types) --=20 Eduardo