qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC 6/7] target-arm: Introduce QOM CPU and use f


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH RFC 6/7] target-arm: Introduce QOM CPU and use for it CPUID lookup
Date: Sun, 29 Jan 2012 20:19:34 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

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<address@hidden>
Cc: Anthony Liguori<address@hidden>
Cc: Paul Brook<address@hidden>
Cc: Peter Maydell<address@hidden>
---
  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]