From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrgqJ-0002T4-LD for qemu-devel@nongnu.org; Sun, 29 Jan 2012 21:19:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrgqH-0001wG-GB for qemu-devel@nongnu.org; Sun, 29 Jan 2012 21:19:39 -0500 Received: from mail-tul01m020-f173.google.com ([209.85.214.173]:36510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrgqH-0001wC-8j for qemu-devel@nongnu.org; Sun, 29 Jan 2012 21:19:37 -0500 Received: by obbup16 with SMTP id up16so4121520obb.4 for ; Sun, 29 Jan 2012 18:19:36 -0800 (PST) Message-ID: <4F25FE36.90306@codemonkey.ws> Date: Sun, 29 Jan 2012 20:19:34 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1327843531-32403-1-git-send-email-afaerber@suse.de> <1327843531-32403-7-git-send-email-afaerber@suse.de> In-Reply-To: <1327843531-32403-7-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH RFC 6/7] target-arm: Introduce QOM CPU and use for it CPUID lookup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: Peter Maydell , Anthony Liguori , qemu-devel@nongnu.org, Paul Brook On 01/29/2012 07:25 AM, Andreas Färber wrote: > Create a CPU subclass, and register classes matching all CPU models. > Don't name the file target-arm/cpu.c so that the user emulators can > still easily pick up the base class in hw/cpu.c via VPATH. > > Make arm_cpu_list() enumerate CPU subclasses. > > Replace cpu_arm_find_by_name()'s string -> CPUID lookup by storing the > CPUID in the class. > NB: CPUIDs were first introduced by Paul Brook in r1765 (2006). > > Signed-off-by: Andreas Färber > Cc: Anthony Liguori > Cc: Paul Brook > Cc: Peter Maydell > --- > Makefile.target | 1 + > target-arm/cpu-core.c | 268 +++++++++++++++++++++++++++++++++++++++++++++++++ > target-arm/cpu-core.h | 33 ++++++ > target-arm/helper.c | 80 ++++----------- > 4 files changed, 324 insertions(+), 58 deletions(-) > create mode 100644 target-arm/cpu-core.c > create mode 100644 target-arm/cpu-core.h > > diff --git a/Makefile.target b/Makefile.target > index 5d3470e..96043c4 100644 > --- a/Makefile.target > +++ b/Makefile.target > @@ -80,6 +80,7 @@ endif > libobj-$(TARGET_SPARC64) += vis_helper.o > libobj-$(CONFIG_NEED_MMU) += mmu.o > libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o > +libobj-$(TARGET_ARM) += cpu-core.o > ifeq ($(TARGET_BASE_ARCH), sparc) > libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o > libobj-y += cpu_init.o > diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c > new file mode 100644 > index 0000000..9761d8e > --- /dev/null > +++ b/target-arm/cpu-core.c > @@ -0,0 +1,268 @@ > +/* > + * QEMU ARM CPU core > + * > + * Copyright (c) 2012 SUSE LINUX Products GmbH > + * > + * Licensed under the terms of the GNU GPL version 2 > + * or (at your option) any later version. > + */ > + > +#include "cpu-core.h" > +#include "qemu-common.h" > + > +/* CPU models */ > + > +static void arm926_class_init(ObjectClass *klass, void *data) > +{ > + ARMCPUClass *k = ARM_CPU_CLASS(klass); > + > + k->id = 0x41069265; > +} > + > +static void arm946_class_init(ObjectClass *klass, void *data) > +{ > + ARMCPUClass *k = ARM_CPU_CLASS(klass); > + > + k->id = 0x41059461; > +} In a situation like this, you probably want to make use of the class_data field in TypeInfo. You can use that to create a bunch of types based on a table. Take a look at hw/eepro100.c for an example of this (although read the comment for the reference to class_data and why we can't use it until after the next series). Regards, Anthony Liguori