From 4614f0f8bd2e40cbc27ab6b9a1fd6244259ade8d Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Mon, 19 Nov 2018 18:02:32 -0800 Subject: [PATCH 1/4] target/xtensa: gdbstub fix register counting In order to communicate correctly with gdb xtensa gdbstub must provide expected number of registers in 'g' packet response. xtensa-elf-gdb expects both nonprivileged and privileged registers. xtensa-linux-gdb only expects nonprivileged registers. gdb only counts one contiguous stretch of registers, do the same for the core registers in the xtensa_count_regs. With this change qemu-system-xtensa is able to communicate with all xtensa-elf-gdb versions (versions prior to 8.2 require overlay fixup), and qemu-xtensa is able to communicate with all xtensa-linux-gdb versions, except 8.2. Signed-off-by: Max Filippov --- target/xtensa/gdbstub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index c9450914c7..d43bb190c6 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -45,15 +45,20 @@ void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs) { unsigned i; + bool count_core_regs = true; for (i = 0; config->gdb_regmap.reg[i].targno >= 0; ++i) { if (config->gdb_regmap.reg[i].type != xtRegisterTypeTieState && config->gdb_regmap.reg[i].type != xtRegisterTypeMapped && config->gdb_regmap.reg[i].type != xtRegisterTypeUnmapped) { ++*n_regs; - if ((config->gdb_regmap.reg[i].flags & - XTENSA_REGISTER_FLAGS_PRIVILEGED) == 0) { - ++*n_core_regs; + if (count_core_regs) { + if ((config->gdb_regmap.reg[i].flags & + XTENSA_REGISTER_FLAGS_PRIVILEGED) == 0) { + ++*n_core_regs; + } else { + count_core_regs = false; + } } } } From 7da9111e77b9cdb3a927dcd47642b7ffff9de636 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Wed, 31 Oct 2018 14:21:49 -0700 Subject: [PATCH 2/4] target/xtensa: drop num_[core_]regs from dc232b/dc233c configs Now that xtensa_count_regs does the right thing, remove manual initialization of these fields from the affected configurations and let xtensa_finalize_config initialize them. Add XTREG_END to terminate register lists. Signed-off-by: Max Filippov --- target/xtensa/core-dc232b.c | 2 -- target/xtensa/core-dc232b/gdb-config.inc.c | 1 + target/xtensa/core-dc233c.c | 2 -- target/xtensa/core-dc233c/gdb-config.inc.c | 1 + 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/target/xtensa/core-dc232b.c b/target/xtensa/core-dc232b.c index 7131337840..7851bcb636 100644 --- a/target/xtensa/core-dc232b.c +++ b/target/xtensa/core-dc232b.c @@ -40,8 +40,6 @@ static XtensaConfig dc232b __attribute__((unused)) = { .name = "dc232b", .gdb_regmap = { - .num_regs = 120, - .num_core_regs = 52, .reg = { #include "core-dc232b/gdb-config.inc.c" } diff --git a/target/xtensa/core-dc232b/gdb-config.inc.c b/target/xtensa/core-dc232b/gdb-config.inc.c index 13aba5edec..d87168628b 100644 --- a/target/xtensa/core-dc232b/gdb-config.inc.c +++ b/target/xtensa/core-dc232b/gdb-config.inc.c @@ -259,3 +259,4 @@ 0, 0, 0, 0, 0, 0) XTREG(119, 476, 32, 4, 4, 0x000f, 0x0006, -2, 8, 0x0100, a15, 0, 0, 0, 0, 0, 0) + XTREG_END diff --git a/target/xtensa/core-dc233c.c b/target/xtensa/core-dc233c.c index d701e3f5de..8853bfd4d0 100644 --- a/target/xtensa/core-dc233c.c +++ b/target/xtensa/core-dc233c.c @@ -40,8 +40,6 @@ static XtensaConfig dc233c __attribute__((unused)) = { .name = "dc233c", .gdb_regmap = { - .num_regs = 121, - .num_core_regs = 52, .reg = { #include "core-dc233c/gdb-config.inc.c" } diff --git a/target/xtensa/core-dc233c/gdb-config.inc.c b/target/xtensa/core-dc233c/gdb-config.inc.c index b632341b28..7e8963227f 100644 --- a/target/xtensa/core-dc233c/gdb-config.inc.c +++ b/target/xtensa/core-dc233c/gdb-config.inc.c @@ -143,3 +143,4 @@ XTREG(117, 468, 32, 4, 4, 0x000c, 0x0006, -2, 8, 0x0100, a12, 0, 0, 0, 0 XTREG(118, 472, 32, 4, 4, 0x000d, 0x0006, -2, 8, 0x0100, a13, 0, 0, 0, 0, 0, 0) XTREG(119, 476, 32, 4, 4, 0x000e, 0x0006, -2, 8, 0x0100, a14, 0, 0, 0, 0, 0, 0) XTREG(120, 480, 32, 4, 4, 0x000f, 0x0006, -2, 8, 0x0100, a15, 0, 0, 0, 0, 0, 0) +XTREG_END From 59b5e9bbea89fa454674b77d365015d2578dfbcf Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Tue, 20 Nov 2018 12:31:24 -0800 Subject: [PATCH 3/4] target/xtensa: xtfpga: provide default memory sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide default RAM sizes for all XTFPGA boards, so that when started without -m option they do the right thing. Signed-off-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé --- hw/xtensa/xtfpga.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index b3161de320..21094319a6 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -446,6 +446,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) } } +#define XTFPGA_MMU_RESERVED_MEMORY_SIZE (128 * MiB) + static const hwaddr xtfpga_mmu_io[2] = { 0xf0000000, }; @@ -568,6 +570,7 @@ static void xtfpga_lx60_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_lx60_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; + mc->default_ram_size = 64 * MiB; } static const TypeInfo xtfpga_lx60_type = { @@ -584,6 +587,7 @@ static void xtfpga_lx60_nommu_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_lx60_nommu_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; + mc->default_ram_size = 64 * MiB; } static const TypeInfo xtfpga_lx60_nommu_type = { @@ -600,6 +604,7 @@ static void xtfpga_lx200_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_lx200_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; + mc->default_ram_size = 96 * MiB; } static const TypeInfo xtfpga_lx200_type = { @@ -616,6 +621,7 @@ static void xtfpga_lx200_nommu_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_lx200_nommu_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; + mc->default_ram_size = 96 * MiB; } static const TypeInfo xtfpga_lx200_nommu_type = { @@ -632,6 +638,7 @@ static void xtfpga_ml605_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_ml605_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; + mc->default_ram_size = 512 * MiB - XTFPGA_MMU_RESERVED_MEMORY_SIZE; } static const TypeInfo xtfpga_ml605_type = { @@ -648,6 +655,7 @@ static void xtfpga_ml605_nommu_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_ml605_nommu_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; + mc->default_ram_size = 256 * MiB; } static const TypeInfo xtfpga_ml605_nommu_type = { @@ -664,6 +672,7 @@ static void xtfpga_kc705_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_kc705_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; + mc->default_ram_size = 1 * GiB - XTFPGA_MMU_RESERVED_MEMORY_SIZE; } static const TypeInfo xtfpga_kc705_type = { @@ -680,6 +689,7 @@ static void xtfpga_kc705_nommu_class_init(ObjectClass *oc, void *data) mc->init = xtfpga_kc705_nommu_init; mc->max_cpus = 4; mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; + mc->default_ram_size = 256 * MiB; } static const TypeInfo xtfpga_kc705_nommu_type = { From 895e4897e278572e5265e0333f5e9864be2704a6 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Thu, 22 Nov 2018 15:06:21 -0800 Subject: [PATCH 4/4] MAINTAINERS: add missing xtensa patterns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1032406c56..f4a7e453c0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -311,6 +311,8 @@ F: target/xtensa/ F: hw/xtensa/ F: tests/tcg/xtensa/ F: disas/xtensa.c +F: include/hw/xtensa/xtensa-isa.h +F: default-configs/xtensa*.mak TriCore M: Bastian Koppelmann