All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Sarah Harris" <S.E.Harris@kent.ac.uk>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Thomas Huth" <huth@tuxfamily.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Michael Rolnik" <mrolnik@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Aleksandar Markovic" <aleksandar.m.mail@gmail.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [PULL 08/32] target/avr: Add definitions of AVR core types
Date: Tue,  7 Jul 2020 20:16:46 +0200	[thread overview]
Message-ID: <20200707181710.30950-9-f4bug@amsat.org> (raw)
In-Reply-To: <20200707181710.30950-1-f4bug@amsat.org>

From: Michael Rolnik <mrolnik@gmail.com>

AVR core types are:

  - avr5
  - avr51
  - avr6

Each core type covers multiple AVR MCUs, mentioned in the comments
before definition of particular AVR core type (part of this patch).

AVR core type defines shared features that are valid for all AVR
MCUs belonging in that type.

[AM: Split a larger AVR introduction patch into logical units]
Suggested-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Co-developed-by: Michael Rolnik <mrolnik@gmail.com>
Co-developed-by: Sarah Harris <S.E.Harris@kent.ac.uk>
Signed-off-by: Michael Rolnik <mrolnik@gmail.com>
Signed-off-by: Sarah Harris <S.E.Harris@kent.ac.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <huth@tuxfamily.org>
Message-Id: <20200705140315.260514-9-huth@tuxfamily.org>
[PMD: Only include reviewed cores: avr5/avr51/avr6]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/avr/cpu.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)

diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index ac496b8f03..7178e86f69 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -215,3 +215,155 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_num_core_regs = 35;
     cc->gdb_core_xml_file = "avr-cpu.xml";
 }
+
+/*
+ * Setting features of AVR core type avr5
+ * --------------------------------------
+ *
+ * This type of AVR core is present in the following AVR MCUs:
+ *
+ * ata5702m322, ata5782, ata5790, ata5790n, ata5791, ata5795, ata5831, ata6613c,
+ * ata6614q, ata8210, ata8510, atmega16, atmega16a, atmega161, atmega162,
+ * atmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a,
+ * atmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa,
+ * atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa, atmega16hvb,
+ * atmega16hvbrevb, atmega16m1, atmega16u4, atmega32a, atmega32, atmega323,
+ * atmega324a, atmega324p, atmega324pa, atmega325, atmega325a, atmega325p,
+ * atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, atmega328,
+ * atmega328p, atmega328pb, atmega329, atmega329a, atmega329p, atmega329pa,
+ * atmega3290, atmega3290a, atmega3290p, atmega3290pa, atmega32c1, atmega32m1,
+ * atmega32u4, atmega32u6, atmega406, atmega64, atmega64a, atmega640, atmega644,
+ * atmega644a, atmega644p, atmega644pa, atmega645, atmega645a, atmega645p,
+ * atmega6450, atmega6450a, atmega6450p, atmega649, atmega649a, atmega649p,
+ * atmega6490, atmega16hva, atmega16hva2, atmega32hvb, atmega6490a, atmega6490p,
+ * atmega64c1, atmega64m1, atmega64hve, atmega64hve2, atmega64rfr2,
+ * atmega644rfr2, atmega32hvbrevb, at90can32, at90can64, at90pwm161, at90pwm216,
+ * at90pwm316, at90scr100, at90usb646, at90usb647, at94k, m3000
+ */
+static void avr_avr5_initfn(Object *obj)
+{
+    AVRCPU *cpu = AVR_CPU(obj);
+    CPUAVRState *env = &cpu->env;
+
+    set_avr_feature(env, AVR_FEATURE_LPM);
+    set_avr_feature(env, AVR_FEATURE_IJMP_ICALL);
+    set_avr_feature(env, AVR_FEATURE_ADIW_SBIW);
+    set_avr_feature(env, AVR_FEATURE_SRAM);
+    set_avr_feature(env, AVR_FEATURE_BREAK);
+
+    set_avr_feature(env, AVR_FEATURE_2_BYTE_PC);
+    set_avr_feature(env, AVR_FEATURE_2_BYTE_SP);
+    set_avr_feature(env, AVR_FEATURE_JMP_CALL);
+    set_avr_feature(env, AVR_FEATURE_LPMX);
+    set_avr_feature(env, AVR_FEATURE_MOVW);
+    set_avr_feature(env, AVR_FEATURE_MUL);
+}
+
+/*
+ * Setting features of AVR core type avr51
+ * --------------------------------------
+ *
+ * This type of AVR core is present in the following AVR MCUs:
+ *
+ * atmega128, atmega128a, atmega1280, atmega1281, atmega1284, atmega1284p,
+ * atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128, at90usb1286,
+ * at90usb1287
+ */
+static void avr_avr51_initfn(Object *obj)
+{
+    AVRCPU *cpu = AVR_CPU(obj);
+    CPUAVRState *env = &cpu->env;
+
+    set_avr_feature(env, AVR_FEATURE_LPM);
+    set_avr_feature(env, AVR_FEATURE_IJMP_ICALL);
+    set_avr_feature(env, AVR_FEATURE_ADIW_SBIW);
+    set_avr_feature(env, AVR_FEATURE_SRAM);
+    set_avr_feature(env, AVR_FEATURE_BREAK);
+
+    set_avr_feature(env, AVR_FEATURE_2_BYTE_PC);
+    set_avr_feature(env, AVR_FEATURE_2_BYTE_SP);
+    set_avr_feature(env, AVR_FEATURE_RAMPZ);
+    set_avr_feature(env, AVR_FEATURE_ELPMX);
+    set_avr_feature(env, AVR_FEATURE_ELPM);
+    set_avr_feature(env, AVR_FEATURE_JMP_CALL);
+    set_avr_feature(env, AVR_FEATURE_LPMX);
+    set_avr_feature(env, AVR_FEATURE_MOVW);
+    set_avr_feature(env, AVR_FEATURE_MUL);
+}
+
+/*
+ * Setting features of AVR core type avr6
+ * --------------------------------------
+ *
+ * This type of AVR core is present in the following AVR MCUs:
+ *
+ * atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2
+ */
+static void avr_avr6_initfn(Object *obj)
+{
+    AVRCPU *cpu = AVR_CPU(obj);
+    CPUAVRState *env = &cpu->env;
+
+    set_avr_feature(env, AVR_FEATURE_LPM);
+    set_avr_feature(env, AVR_FEATURE_IJMP_ICALL);
+    set_avr_feature(env, AVR_FEATURE_ADIW_SBIW);
+    set_avr_feature(env, AVR_FEATURE_SRAM);
+    set_avr_feature(env, AVR_FEATURE_BREAK);
+
+    set_avr_feature(env, AVR_FEATURE_3_BYTE_PC);
+    set_avr_feature(env, AVR_FEATURE_2_BYTE_SP);
+    set_avr_feature(env, AVR_FEATURE_RAMPZ);
+    set_avr_feature(env, AVR_FEATURE_EIJMP_EICALL);
+    set_avr_feature(env, AVR_FEATURE_ELPMX);
+    set_avr_feature(env, AVR_FEATURE_ELPM);
+    set_avr_feature(env, AVR_FEATURE_JMP_CALL);
+    set_avr_feature(env, AVR_FEATURE_LPMX);
+    set_avr_feature(env, AVR_FEATURE_MOVW);
+    set_avr_feature(env, AVR_FEATURE_MUL);
+}
+
+typedef struct AVRCPUInfo {
+    const char *name;
+    void (*initfn)(Object *obj);
+} AVRCPUInfo;
+
+
+static void avr_cpu_list_entry(gpointer data, gpointer user_data)
+{
+    const char *typename = object_class_get_name(OBJECT_CLASS(data));
+
+    qemu_printf("%s\n", typename);
+}
+
+void avr_cpu_list(void)
+{
+    GSList *list;
+    list = object_class_get_list_sorted(TYPE_AVR_CPU, false);
+    g_slist_foreach(list, avr_cpu_list_entry, NULL);
+    g_slist_free(list);
+}
+
+#define DEFINE_AVR_CPU_TYPE(model, initfn) \
+    { \
+        .parent = TYPE_AVR_CPU, \
+        .instance_init = initfn, \
+        .name = AVR_CPU_TYPE_NAME(model), \
+    }
+
+static const TypeInfo avr_cpu_type_info[] = {
+    {
+        .name = TYPE_AVR_CPU,
+        .parent = TYPE_CPU,
+        .instance_size = sizeof(AVRCPU),
+        .instance_init = avr_cpu_initfn,
+        .class_size = sizeof(AVRCPUClass),
+        .class_init = avr_cpu_class_init,
+        .abstract = true,
+    },
+    DEFINE_AVR_CPU_TYPE("avr5", avr_avr5_initfn),
+    DEFINE_AVR_CPU_TYPE("avr51", avr_avr51_initfn),
+    DEFINE_AVR_CPU_TYPE("avr6", avr_avr6_initfn),
+};
+
+
+DEFINE_TYPES(avr_cpu_type_info)
-- 
2.21.3



  parent reply	other threads:[~2020-07-07 18:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 18:16 [PULL 00/32] AVR port Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 01/32] target/avr: Add basic parameters of the new platform Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 02/32] target/avr: Introduce basic CPU class object Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 03/32] target/avr: CPU class: Add interrupt handling support Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 04/32] target/avr: CPU class: Add memory menagement support Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 05/32] target/avr: CPU class: Add migration support Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 06/32] target/avr: CPU class: Add GDB support Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 07/32] target/avr: Introduce enumeration AVRFeature Philippe Mathieu-Daudé
2020-07-07 18:16 ` Philippe Mathieu-Daudé [this message]
2020-07-07 18:16 ` [PULL 09/32] target/avr: Add instruction helpers Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 10/32] target/avr: Add instruction translation - Register definitions Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 11/32] target/avr: Add instruction translation - Arithmetic and Logic Instructions Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 12/32] target/avr: Add instruction translation - Branch Instructions Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 13/32] target/avr: Add instruction translation - Data Transfer Instructions Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 14/32] target/avr: Add instruction translation - Bit and Bit-test Instructions Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 15/32] target/avr: Add instruction translation - MCU Control Instructions Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 16/32] target/avr: Add instruction translation - CPU main translation function Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 17/32] target/avr: Initialize TCG register variables Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 18/32] target/avr: Add support for disassembling via option '-d in_asm' Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 19/32] target/avr: Register AVR support with the rest of QEMU Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 20/32] tests/machine-none: Add AVR support Philippe Mathieu-Daudé
2020-07-07 18:16 ` [PULL 21/32] hw/char: avr: Add limited support for USART peripheral Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 22/32] hw/timer: avr: Add limited support for 16-bit timer peripheral Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 23/32] hw/misc: avr: Add limited support for power reduction device Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 24/32] hw/avr: Add support for loading ELF/raw binaries Philippe Mathieu-Daudé
2020-07-13 12:40   ` Peter Maydell
2020-07-14 15:09     ` Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 25/32] hw/avr: Add some ATmega microcontrollers Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 26/32] hw/avr: Add limited support for some Arduino boards Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 27/32] tests/boot-serial: Test some Arduino boards (AVR based) Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 28/32] tests/acceptance: Test the Arduino MEGA2560 board Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 29/32] target/avr: Add section into QEMU documentation Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 30/32] target/avr/cpu: Drop tlb_flush() in avr_cpu_reset() Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 31/32] target/avr/cpu: Fix $PC displayed address Philippe Mathieu-Daudé
2020-07-07 18:17 ` [PULL 32/32] target/avr/disas: Fix store instructions display order Philippe Mathieu-Daudé
2020-07-10 11:41 ` [PULL 00/32] AVR port Peter Maydell
2020-07-10 15:02   ` Thomas Huth
2020-07-10 15:12     ` Peter Maydell
2020-07-10 15:17       ` Philippe Mathieu-Daudé
2020-07-10 15:32         ` Philippe Mathieu-Daudé
2020-07-10 15:45           ` Thomas Huth
2020-07-10 15:54           ` Richard Henderson
2020-07-10 16:00             ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707181710.30950-9-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=S.E.Harris@kent.ac.uk \
    --cc=aleksandar.m.mail@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=huth@tuxfamily.org \
    --cc=imammedo@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mrolnik@gmail.com \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.