From patchwork Wed Jul 1 14:06:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 490157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 59918140187 for ; Thu, 2 Jul 2015 00:08:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=VF97kJOM; dkim-atps=neutral Received: from localhost ([::1]:58984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAIgC-0007jD-En for incoming@patchwork.ozlabs.org; Wed, 01 Jul 2015 10:08:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAIfe-0006qI-Lq for qemu-devel@nongnu.org; Wed, 01 Jul 2015 10:07:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAIfb-0000tl-Bk for qemu-devel@nongnu.org; Wed, 01 Jul 2015 10:07:26 -0400 Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]:34345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAIfa-0000tT-Us for qemu-devel@nongnu.org; Wed, 01 Jul 2015 10:07:23 -0400 Received: by lbnk3 with SMTP id k3so13632474lbn.1 for ; Wed, 01 Jul 2015 07:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=y8Isu0m/tpRMjUJ8VgsJtmmP1vyMcrg6xkcPY6+dOeM=; b=VF97kJOMZpUGVWWdz+K815af6Xqir3rk6HpwaRgwK/lpoF7Eu1CHX6LvZyf1/PEFfW JImg++/PSpewcccUh0oJ0O5Ba3V2OwSn+3jhkQDfYDVk8Fx6SkUXnSvxPkrWLNnISCMv fQ7zftsDXCVQ1l9TKKUYudi4fhqqhBrtPXZD9jzCm2GZU2MRjB3seFobs4DVO77cyksz c34A9r8TlUlaFFqGJTU6j3d89XRLzSsGZes1oaQ4p4xPdH1jeZeM7Ipngzp8d/6Xvijx 4SoXz9mM6yz+cItCWXeS+jSveJLj1HDEnb3HvCoJQKCJ0qhA0dIh1cL9YNnd8q4fAuNv 9MMQ== X-Received: by 10.152.5.2 with SMTP id o2mr25635303lao.79.1435759641219; Wed, 01 Jul 2015 07:07:21 -0700 (PDT) Received: from octofox.metropolis ([5.19.183.212]) by mx.google.com with ESMTPSA id bd7sm541520lbc.26.2015.07.01.07.07.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2015 07:07:20 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 1 Jul 2015 17:06:58 +0300 Message-Id: <1435759618-16504-1-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 1.8.1.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22e Cc: Max Filippov Subject: [Qemu-devel] [PATCH] target-xtensa: fix gdb register map construction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Due to different gdb overlay organization between windowed/call0 configurations core import script doesn't always work correctly. Simplify the script: always copy complete gdb register map from overlay, count registers at core registerstion time. Update existing cores. Signed-off-by: Max Filippov --- target-xtensa/core-dc232b.c | 2 +- target-xtensa/core-dc233c.c | 2 +- target-xtensa/core-fsf.c | 7 ++++++- target-xtensa/cpu.h | 1 + target-xtensa/helper.c | 14 ++++++++++++++ target-xtensa/import_core.sh | 6 ++---- target-xtensa/overlay_tool.h | 2 ++ 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index a3b914b..06826c0 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -33,7 +33,7 @@ #include "core-dc232b/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig dc232b __attribute__((unused)) = { +static XtensaConfig dc232b __attribute__((unused)) = { .name = "dc232b", .gdb_regmap = { .num_regs = 120, diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index ac745d1..8daf7d9 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -34,7 +34,7 @@ #include "core-dc233c/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig dc233c __attribute__((unused)) = { +static XtensaConfig dc233c __attribute__((unused)) = { .name = "dc233c", .gdb_regmap = { .num_regs = 121, diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index cfcc840..f6ea6b9 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -33,9 +33,14 @@ #include "core-fsf/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig fsf __attribute__((unused)) = { +static XtensaConfig fsf __attribute__((unused)) = { .name = "fsf", + .gdb_regmap = { /* GDB for this core is not supported currently */ + .reg = { + XTREG_END + }, + }, .clock_freq_khz = 10000, DEFAULT_SECTIONS }; diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h index b592efb..b89c602 100644 --- a/target-xtensa/cpu.h +++ b/target-xtensa/cpu.h @@ -400,6 +400,7 @@ XtensaCPU *cpu_xtensa_init(const char *cpu_model); void xtensa_translate_init(void); void xtensa_breakpoint_handler(CPUState *cs); int cpu_xtensa_exec(CPUXtensaState *s); +void xtensa_finalize_config(XtensaConfig *config); void xtensa_register_core(XtensaConfigList *node); void check_interrupts(CPUXtensaState *s); void xtensa_irq_init(CPUXtensaState *env); diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index d84d259..76be50d 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -51,6 +51,20 @@ static void xtensa_core_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs = config->gdb_regmap.num_regs; } +void xtensa_finalize_config(XtensaConfig *config) +{ + unsigned i, n = 0; + + if (config->gdb_regmap.num_regs) { + return; + } + + for (i = 0; config->gdb_regmap.reg[i].targno >= 0; ++i) { + n += (config->gdb_regmap.reg[i].type != 6); + } + config->gdb_regmap.num_regs = n; +} + void xtensa_register_core(XtensaConfigList *node) { TypeInfo type = { diff --git a/target-xtensa/import_core.sh b/target-xtensa/import_core.sh index 73791ec..351bee4 100755 --- a/target-xtensa/import_core.sh +++ b/target-xtensa/import_core.sh @@ -22,8 +22,7 @@ mkdir -p "$TARGET" tar -xf "$OVERLAY" -C "$TARGET" --strip-components=1 \ --xform='s/core/core-isa/' config/core.h tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \ - sed -n '1,/*\//p;/pc/,/a15/p' > "$TARGET"/gdb-config.c -NUM_REGS=$(grep XTREG "$TARGET"/gdb-config.c | wc -l) + sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.c cat < "${TARGET}.c" #include "cpu.h" @@ -34,10 +33,9 @@ cat < "${TARGET}.c" #include "core-$NAME/core-isa.h" #include "overlay_tool.h" -static const XtensaConfig $NAME __attribute__((unused)) = { +static XtensaConfig $NAME __attribute__((unused)) = { .name = "$NAME", .gdb_regmap = { - .num_regs = $NUM_REGS, .reg = { #include "core-$NAME/gdb-config.c" } diff --git a/target-xtensa/overlay_tool.h b/target-xtensa/overlay_tool.h index f7b1510..eda03aa 100644 --- a/target-xtensa/overlay_tool.h +++ b/target-xtensa/overlay_tool.h @@ -28,6 +28,7 @@ #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), .size = (sz) }, +#define XTREG_END { .targno = -1 }, #ifndef XCHAL_HAVE_DIV32 #define XCHAL_HAVE_DIV32 0 @@ -316,6 +317,7 @@ static XtensaConfigList node = { \ .config = &core, \ }; \ + xtensa_finalize_config(&core); \ xtensa_register_core(&node); \ } #else