Skip to contentSkip to conversation

target-xtensa: add overlay parsing header and convert hand-written core definitions to use overlays

PATCH Applied Max Filippov 2 participants 9 messages Oct 15, 2011 – Oct 16, 2011 Kbuild

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/7 target-xtensa: increase xtensa options accuracy

In reply to Max Filippov

- add separate options for each operation in the MISC_OP;
- add an option for MULSH/MULUH;
- put S32C1I under conditional store option.

---
 target-xtensa/cpu.h       |    6 +++++-
 target-xtensa/translate.c |   14 +++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)
target-xtensa/cpu.h +5 -1
index b43e565..df168d5 100644
@@ -52,9 +52,13 @@ enum {
     XTENSA_OPTION_EXTENDED_L32R,
     XTENSA_OPTION_16_BIT_IMUL,
     XTENSA_OPTION_32_BIT_IMUL,
+    XTENSA_OPTION_32_BIT_IMUL_HIGH,
     XTENSA_OPTION_32_BIT_IDIV,
     XTENSA_OPTION_MAC16,
-    XTENSA_OPTION_MISC_OP,
+    XTENSA_OPTION_MISC_OP_NSA,
+    XTENSA_OPTION_MISC_OP_MINMAX,
+    XTENSA_OPTION_MISC_OP_SEXT,
+    XTENSA_OPTION_MISC_OP_CLAMPS,
     XTENSA_OPTION_COPROCESSOR,
     XTENSA_OPTION_BOOLEAN,
     XTENSA_OPTION_FP_COPROCESSOR,
target-xtensa/translate.c +7 -7
index 70bea62..1688bb2 100644
@@ -1116,13 +1116,13 @@ static void disas_xtensa_insn(DisasContext *dc)
                     break;
 
                 case 14: /*NSAu*/
-                    HAS_OPTION(XTENSA_OPTION_MISC_OP);
+                    HAS_OPTION(XTENSA_OPTION_MISC_OP_NSA);
                     gen_window_check2(dc, RRR_S, RRR_T);
                     gen_helper_nsa(cpu_R[RRR_T], cpu_R[RRR_S]);
                     break;
 
                 case 15: /*NSAUu*/
-                    HAS_OPTION(XTENSA_OPTION_MISC_OP);
+                    HAS_OPTION(XTENSA_OPTION_MISC_OP_NSA);
                     gen_window_check2(dc, RRR_S, RRR_T);
                     gen_helper_nsau(cpu_R[RRR_T], cpu_R[RRR_S]);
                     break;
@@ -1434,7 +1434,7 @@ static void disas_xtensa_insn(DisasContext *dc)
 
             case 10: /*MULUHi*/
             case 11: /*MULSHi*/
-                HAS_OPTION(XTENSA_OPTION_32_BIT_IMUL);
+                HAS_OPTION(XTENSA_OPTION_32_BIT_IMUL_HIGH);
                 {
                     TCGv_i64 r = tcg_temp_new_i64();
                     TCGv_i64 s = tcg_temp_new_i64();
@@ -1521,7 +1521,7 @@ static void disas_xtensa_insn(DisasContext *dc)
                 break;
 
             case 2: /*SEXTu*/
-                HAS_OPTION(XTENSA_OPTION_MISC_OP);
+                HAS_OPTION(XTENSA_OPTION_MISC_OP_SEXT);
                 gen_window_check2(dc, RRR_R, RRR_S);
                 {
                     int shift = 24 - RRR_T;
@@ -1540,7 +1540,7 @@ static void disas_xtensa_insn(DisasContext *dc)
                 break;
 
             case 3: /*CLAMPSu*/
-                HAS_OPTION(XTENSA_OPTION_MISC_OP);
+                HAS_OPTION(XTENSA_OPTION_MISC_OP_CLAMPS);
                 gen_window_check2(dc, RRR_R, RRR_S);
                 {
                     TCGv_i32 tmp1 = tcg_temp_new_i32();
@@ -1568,7 +1568,7 @@ static void disas_xtensa_insn(DisasContext *dc)
             case 5: /*MAXu*/
             case 6: /*MINUu*/
             case 7: /*MAXUu*/
-                HAS_OPTION(XTENSA_OPTION_MISC_OP);
+                HAS_OPTION(XTENSA_OPTION_MISC_OP_MINMAX);
                 gen_window_check3(dc, RRR_R, RRR_S, RRR_T);
                 {
                     static const TCGCond cond[] = {
@@ -1921,7 +1921,7 @@ static void disas_xtensa_insn(DisasContext *dc)
             break;
 
         case 14: /*S32C1Iy*/
-            HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO);
+            HAS_OPTION(XTENSA_OPTION_CONDITIONAL_STORE);
             gen_window_check2(dc, RRI8_S, RRI8_T);
             {
                 int label = gen_new_label();
Signature · 1 line
1.7.6.4
#0 lore raw

v2 cover target-xtensa: add overlay parsing header and convert hand-written core definitions to use overlays

Max Filippov (7):
target-xtensa: increase xtensa options accuracy
target-xtensa: remove hand-written xtensa cores implementations
target-xtensa: implement external interrupt mapping
target-xtensa: extract core configuration from overlay
target-xtensa: add dc232b core
target-xtensa: add fsf core
target-xtensa: rename dc232b board to sim

 Makefile.target                               |    5 +-
 hw/xtensa_dc232b.c                            |  116 ------
 hw/xtensa_pic.c                               |   12 +
 hw/xtensa_sample.c                            |  107 -----
 hw/xtensa_sim.c                               |  116 ++++++
 target-xtensa/core-dc232b.c                   |   28 ++
 target-xtensa/core-dc232b/core-isa.h          |  424 ++++++++++++++++++++
 target-xtensa/core-dc232b/gdb-config.c        |  261 ++++++++++++
 target-xtensa/core-fsf.c                      |   22 +
 target-xtensa/core-fsf/core-isa.h             |  362 +++++++++++++++++
 target-xtensa/cpu.h                           |   15 +-
 target-xtensa/gdb-config-dc232b.c             |  261 ------------
 target-xtensa/gdb-config-sample-xtensa-core.c |  375 -----------------
 target-xtensa/helper.c                        |  249 +-----------
 target-xtensa/overlay_tool.h                  |  534 +++++++++++++++++++++++++
 target-xtensa/translate.c                     |   14 +-
 tests/xtensa/Makefile                         |    2 +-
 17 files changed, 1798 insertions(+), 1105 deletions(-)
 delete mode 100644 hw/xtensa_dc232b.c
 delete mode 100644 hw/xtensa_sample.c
 create mode 100644 hw/xtensa_sim.c
 create mode 100644 target-xtensa/core-dc232b.c
 create mode 100644 target-xtensa/core-dc232b/core-isa.h
 create mode 100644 target-xtensa/core-dc232b/gdb-config.c
 create mode 100644 target-xtensa/core-fsf.c
 create mode 100644 target-xtensa/core-fsf/core-isa.h
 delete mode 100644 target-xtensa/gdb-config-dc232b.c
 delete mode 100644 target-xtensa/gdb-config-sample-xtensa-core.c
 create mode 100644 target-xtensa/overlay_tool.h
Signature · 1 line
1.7.6.4
#3 lore raw

PATCH v2 3/7 target-xtensa: implement external interrupt mapping

Xtensa cores may have different mapping of external interrupt pins to internal IRQ numers. Implement API to acquire core IRQ by its external interrupt number.

---
 hw/xtensa_pic.c     |   12 ++++++++++++
 target-xtensa/cpu.h |    3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)
hw/xtensa_pic.c +12 -0
index e5085ea..93e28fd 100644
@@ -157,3 +157,15 @@ void xtensa_irq_init(CPUState *env)
             qemu_new_timer_ns(vm_clock, &xtensa_ccompare_cb, env);
     }
 }
+
+void *xtensa_get_extint(CPUState *env, unsigned extint)
+{
+    if (extint < env->config->nextint) {
+        unsigned irq = env->config->extint[extint];
+        return env->irq_inputs[irq];
+    } else {
+        qemu_log("%s: trying to acquire invalid external interrupt %d\n",
+                __func__, extint);
+        return NULL;
+    }
+}
target-xtensa/cpu.h +3 -0
index df168d5..9d36c1b 100644
@@ -277,6 +277,8 @@ typedef struct XtensaConfig {
     } interrupt[MAX_NINTERRUPT];
     unsigned nccompare;
     uint32_t timerint[MAX_NCCOMPARE];
+    unsigned nextint;
+    unsigned extint[MAX_NINTERRUPT];
     uint32_t clock_freq_khz;
 
     xtensa_tlb itlb;
@@ -318,6 +320,7 @@ int cpu_xtensa_exec(CPUXtensaState *s);
 void do_interrupt(CPUXtensaState *s);
 void check_interrupts(CPUXtensaState *s);
 void xtensa_irq_init(CPUState *env);
+void *xtensa_get_extint(CPUState *env, unsigned extint);
 void xtensa_advance_ccount(CPUState *env, uint32_t d);
 void xtensa_timer_irq(CPUState *env, uint32_t id, uint32_t active);
 void xtensa_rearm_ccompare_timer(CPUState *env);
Signature · 1 line
1.7.6.4
#7 lore raw

PATCH v2 7/7 target-xtensa: rename dc232b board to sim

In reply to Max Filippov

This is to get aligned with the linux name for this machine.

---
 Makefile.target       |    2 +-
 hw/xtensa_dc232b.c    |  116 -------------------------------------------------
 hw/xtensa_sim.c       |  116 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xtensa/Makefile |    2 +-
 4 files changed, 118 insertions(+), 118 deletions(-)
 delete mode 100644 hw/xtensa_dc232b.c
 create mode 100644 hw/xtensa_sim.c
Makefile.target +1 -1
index 9991d88..752221c 100644
@@ -370,7 +370,7 @@ obj-alpha-y += vga.o cirrus_vga.o
 obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o
 
 obj-xtensa-y += xtensa_pic.o
-obj-xtensa-y += xtensa_dc232b.o
+obj-xtensa-y += xtensa_sim.o
 obj-xtensa-y += xtensa-semi.o
 obj-xtensa-y += core-dc232b.o
 obj-xtensa-y += core-fsf.o
hw/xtensa_dc232b.c deleted +0 -116

116 lines not on this page · raw message

hw/xtensa_sim.c new file +116 -0

116 lines not on this page · raw message

tests/xtensa/Makefile +1 -1
index 15d39da..8713af1 100644
@@ -4,7 +4,7 @@ CROSS=xtensa-dc232b-elf-
 
 ifndef XT
 SIM = qemu-system-xtensa
-SIMFLAGS = -M dc232b -nographic -semihosting $(EXTFLAGS) -kernel
+SIMFLAGS = -M sim -cpu dc232b -nographic -semihosting $(EXTFLAGS) -kernel
 SIMDEBUG = -s -S
 else
 SIM = xt-run
Signature · 1 line
1.7.6.4
#4 lore raw

PATCH v2 4/7 target-xtensa: extract core configuration from overlay

In reply to Max Filippov

Introduce overlay_tool.h that defines core configuration blocks from data available in the linux architecture variant overlay.

Overlay data is automatically generated in the core configuration process by Tensilica tools and can be directly converted to qemu xtensa core description by overlay_tool.h

---
v1 -> v2 changes:
- fix trailing newline in overlay_tool.h;
- only register cores that match current build target endianness.

---
 target-xtensa/cpu.h          |    6 +
 target-xtensa/helper.c       |   27 ++-
 target-xtensa/overlay_tool.h |  534 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 554 insertions(+), 13 deletions(-)
 create mode 100644 target-xtensa/overlay_tool.h
target-xtensa/cpu.h +6 -0
index 9d36c1b..0db83a6 100644
@@ -285,6 +285,11 @@ typedef struct XtensaConfig {
     xtensa_tlb dtlb;
 } XtensaConfig;
 
+typedef struct XtensaConfigList {
+    const XtensaConfig *config;
+    struct XtensaConfigList *next;
+} XtensaConfigList;
+
 typedef struct CPUXtensaState {
     const XtensaConfig *config;
     uint32_t regs[16];
@@ -317,6 +322,7 @@ typedef struct CPUXtensaState {
 CPUXtensaState *cpu_xtensa_init(const char *cpu_model);
 void xtensa_translate_init(void);
 int cpu_xtensa_exec(CPUXtensaState *s);
+void xtensa_register_core(XtensaConfigList *node);
 void do_interrupt(CPUXtensaState *s);
 void check_interrupts(CPUXtensaState *s);
 void xtensa_irq_init(CPUState *env);
target-xtensa/helper.c +14 -13
index f8b2b78..fc85815 100644
@@ -34,12 +34,6 @@
 #include "hw/loader.h"
 #endif
 
-#define XTREG(idx, ofs, bi, sz, al, no, flags, cp, typ, grp, name, \
-        a1, a2, a3, a4, a5, a6) \
-    { .targno = (no), .type = (typ), .group = (grp) },
-
-static const XtensaConfig core_config[0];
-
 static void reset_mmu(CPUState *env);
 
 void cpu_reset(CPUXtensaState *env)
@@ -55,17 +49,24 @@ void cpu_reset(CPUXtensaState *env)
     reset_mmu(env);
 }
 
+static struct XtensaConfigList *xtensa_cores;
+
+void xtensa_register_core(XtensaConfigList *node)
+{
+    node->next = xtensa_cores;
+    xtensa_cores = node;
+}
 
 CPUXtensaState *cpu_xtensa_init(const char *cpu_model)
 {
     static int tcg_inited;
     CPUXtensaState *env;
     const XtensaConfig *config = NULL;
-    int i;
+    XtensaConfigList *core = xtensa_cores;
 
-    for (i = 0; i < ARRAY_SIZE(core_config); ++i)
-        if (strcmp(core_config[i].name, cpu_model) == 0) {
-            config = core_config + i;
+    for (; core; core = core->next)
+        if (strcmp(core->config->name, cpu_model) == 0) {
+            config = core->config;
             break;
         }
 
@@ -90,10 +91,10 @@ CPUXtensaState *cpu_xtensa_init(const char *cpu_model)
 
 void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
-    int i;
+    XtensaConfigList *core = xtensa_cores;
     cpu_fprintf(f, "Available CPUs:\n");
-    for (i = 0; i < ARRAY_SIZE(core_config); ++i) {
-        cpu_fprintf(f, "  %s\n", core_config[i].name);
+    for (; core; core = core->next) {
+        cpu_fprintf(f, "  %s\n", core->config->name);
     }
 }
 
target-xtensa/overlay_tool.h new file +534 -0

534 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#6 lore raw

PATCH v2 6/7 target-xtensa: add fsf core

In reply to Max Filippov

This is FSF big endian core implemented through linux overlay.

---
v1 -> v2 changes:
- remove GDB register definitions due to their GPL3 license;
- fix stylistical issues in core-isa.h

---
 Makefile.target                   |    1 +
 target-xtensa/core-fsf.c          |   22 +++
 target-xtensa/core-fsf/core-isa.h |  362 +++++++++++++++++++++++++++++++++++++
 3 files changed, 385 insertions(+), 0 deletions(-)
 create mode 100644 target-xtensa/core-fsf.c
 create mode 100644 target-xtensa/core-fsf/core-isa.h
Makefile.target +1 -0
index 95d51ae..9991d88 100644
@@ -373,6 +373,7 @@ obj-xtensa-y += xtensa_pic.o
 obj-xtensa-y += xtensa_dc232b.o
 obj-xtensa-y += xtensa-semi.o
 obj-xtensa-y += core-dc232b.o
+obj-xtensa-y += core-fsf.o
 
 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
target-xtensa/core-fsf.c new file +22 -0
new file mode 100644
index 0000000..7650462
@@ -0,0 +1,22 @@
+#include "cpu.h"
+#include "exec-all.h"
+#include "gdbstub.h"
+#include "qemu-common.h"
+#include "host-utils.h"
+
+#include "core-fsf/core-isa.h"
+#include "overlay_tool.h"
+
+static const XtensaConfig fsf = {
+    .name = "fsf",
+    .options = XTENSA_OPTIONS,
+    /* GDB for this core is not supported currently */
+    .nareg = XCHAL_NUM_AREGS,
+    .ndepc = 1,
+    EXCEPTIONS_SECTION,
+    INTERRUPTS_SECTION,
+    TLB_SECTION,
+    .clock_freq_khz = 10000,
+};
+
+REGISTER_CORE(fsf)
target-xtensa/core-fsf/core-isa.h new file +362 -0

362 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#2 lore raw

PATCH v2 2/7 target-xtensa: remove hand-written xtensa cores implementations

In reply to Max Filippov
---
 Makefile.target                               |    1 -
 hw/xtensa_sample.c                            |  107 -------
 target-xtensa/gdb-config-dc232b.c             |  261 -----------------
 target-xtensa/gdb-config-sample-xtensa-core.c |  375 -------------------------
 target-xtensa/helper.c                        |  226 +---------------
 5 files changed, 2 insertions(+), 968 deletions(-)
 delete mode 100644 hw/xtensa_sample.c
 delete mode 100644 target-xtensa/gdb-config-dc232b.c
 delete mode 100644 target-xtensa/gdb-config-sample-xtensa-core.c
Makefile.target +0 -1
index c22b3cb..04369b1 100644
@@ -370,7 +370,6 @@ obj-alpha-y += vga.o cirrus_vga.o
 obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o
 
 obj-xtensa-y += xtensa_pic.o
-obj-xtensa-y += xtensa_sample.o
 obj-xtensa-y += xtensa_dc232b.o
 obj-xtensa-y += xtensa-semi.o
 
hw/xtensa_sample.c deleted +0 -107

107 lines not on this page · raw message

target-xtensa/gdb-config-dc232b.c deleted +0 -261

261 lines not on this page · raw message

target-xtensa/gdb-config-sample-xtensa-core.c deleted +0 -375

375 lines not on this page · raw message

target-xtensa/helper.c +2 -224

238 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#5 lore raw

PATCH v2 5/7 target-xtensa: add dc232b core

In reply to Max Filippov

This is Diamond 232L Standard Core Rev.B (LE), implemented through linux/gdb overlay.

---
v1 -> v2 changes: fix stylistical issues in core-isa.h

---
 Makefile.target                        |    1 +
 target-xtensa/core-dc232b.c            |   28 ++
 target-xtensa/core-dc232b/core-isa.h   |  424 ++++++++++++++++++++++++++++++++
 target-xtensa/core-dc232b/gdb-config.c |  261 ++++++++++++++++++++
 4 files changed, 714 insertions(+), 0 deletions(-)
 create mode 100644 target-xtensa/core-dc232b.c
 create mode 100644 target-xtensa/core-dc232b/core-isa.h
 create mode 100644 target-xtensa/core-dc232b/gdb-config.c
Makefile.target +1 -0
index 04369b1..95d51ae 100644
@@ -372,6 +372,7 @@ obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o
 obj-xtensa-y += xtensa_pic.o
 obj-xtensa-y += xtensa_dc232b.o
 obj-xtensa-y += xtensa-semi.o
+obj-xtensa-y += core-dc232b.o
 
 main.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
target-xtensa/core-dc232b.c new file +28 -0
new file mode 100644
index 0000000..4d9bd55
@@ -0,0 +1,28 @@
+#include "cpu.h"
+#include "exec-all.h"
+#include "gdbstub.h"
+#include "qemu-common.h"
+#include "host-utils.h"
+
+#include "core-dc232b/core-isa.h"
+#include "overlay_tool.h"
+
+static const XtensaConfig dc232b = {
+    .name = "dc232b",
+    .options = XTENSA_OPTIONS,
+    .gdb_regmap = {
+        .num_regs = 120,
+        .num_core_regs = 52,
+        .reg = {
+#include "core-dc232b/gdb-config.c"
+        }
+    },
+    .nareg = XCHAL_NUM_AREGS,
+    .ndepc = 1,
+    EXCEPTIONS_SECTION,
+    INTERRUPTS_SECTION,
+    TLB_SECTION,
+    .clock_freq_khz = 10000,
+};
+
+REGISTER_CORE(dc232b)
target-xtensa/core-dc232b/core-isa.h new file +424 -0

424 lines not on this page · raw message

target-xtensa/core-dc232b/gdb-config.c new file +261 -0

261 lines not on this page · raw message

Signature · 1 line
1.7.6.4
Applied
#8 lore raw
In reply to Max Filippov

Thanks, applied all.

Quoted 44 lines · Max Filippov

Max Filippov (7):
 target-xtensa: increase xtensa options accuracy
 target-xtensa: remove hand-written xtensa cores implementations
 target-xtensa: implement external interrupt mapping
 target-xtensa: extract core configuration from overlay
 target-xtensa: add dc232b core
 target-xtensa: add fsf core
 target-xtensa: rename dc232b board to sim

 Makefile.target                               |    5 +- hw/xtensa_dc232b.c                            |  116 ------ hw/xtensa_pic.c                               |   12 + hw/xtensa_sample.c                            |  107 ----- hw/xtensa_sim.c                               |  116 ++++++ target-xtensa/core-dc232b.c                   |   28 ++ target-xtensa/core-dc232b/core-isa.h          |  424 ++++++++++++++++++++ target-xtensa/core-dc232b/gdb-config.c        |  261 ++++++++++++ target-xtensa/core-fsf.c                      |   22 + target-xtensa/core-fsf/core-isa.h             |  362 +++++++++++++++++ target-xtensa/cpu.h                           |   15 +- target-xtensa/gdb-config-dc232b.c             |  261 ------------ target-xtensa/gdb-config-sample-xtensa-core.c |  375 ----------------- target-xtensa/helper.c                        |  249 +----------- target-xtensa/overlay_tool.h                  |  534 +++++++++++++++++++++++++ target-xtensa/translate.c                     |   14 +- tests/xtensa/Makefile                         |    2 +-

 17 files changed, 1798 insertions(+), 1105 deletions(-)

 delete mode 100644 hw/xtensa_dc232b.c
 delete mode 100644 hw/xtensa_sample.c
 create mode 100644 hw/xtensa_sim.c
 create mode 100644 target-xtensa/core-dc232b.c
 create mode 100644 target-xtensa/core-dc232b/core-isa.h create mode 100644 target-xtensa/core-dc232b/gdb-config.c create mode 100644 target-xtensa/core-fsf.c
 create mode 100644 target-xtensa/core-fsf/core-isa.h delete mode 100644 target-xtensa/gdb-config-dc232b.c delete mode 100644 target-xtensa/gdb-config-sample-xtensa-core.c create mode 100644 target-xtensa/overlay_tool.h

--
1.7.6.4