From nobody Mon Feb 9 15:30:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=xilinx.com) ARC-Seal: i=2; a=rsa-sha256; t=1589217856; cv=pass; d=zohomail.com; s=zohoarc; b=k2bbSZP9Eb0KF4Qxjnp5CopZoPPJ6Y/yc/pNHkvk8FqlT521CMemZKyvVoSYTF7q2dmgAa80/5REw5nCJL01ZwRxgWf8+tlKbzsriRe0qz7JroVwjbu8lddD79iLqsp6ibDaNYgU/rT8JTqU9ar8jddRMqKhS9L4gfH9KkhVxsw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589217856; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hUeNmFjAPFyqGor4e03Zece3+ySpxSOYPpwOHZIGd5c=; b=JiVRVDD4NXUQf7QR6Md0kHJnYJQENIW/VQcOOyHGGBxgBl/V2jFBeyb7LMwLWA0FfCsADDvZPHKdlBOyI2z78SdyvGA8I6Zz3E0zyWWyV6SXKrwcdA7/FJVyNdycGyOENCpU+KtoW4x0ODLxaKoIGpGqJPsNFCFpyLTx1JCunYs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=xilinx.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589217856913380.8833642001614; Mon, 11 May 2020 10:24:16 -0700 (PDT) Received: from localhost ([::1]:55662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYCA3-000277-Kw for importer@patchew.org; Mon, 11 May 2020 13:24:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYC6z-00059P-Jz for qemu-devel@nongnu.org; Mon, 11 May 2020 13:21:05 -0400 Received: from mail-mw2nam10on2073.outbound.protection.outlook.com ([40.107.94.73]:37344 helo=NAM10-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYC6w-0003uV-2I for qemu-devel@nongnu.org; Mon, 11 May 2020 13:21:05 -0400 Received: from SN4PR0401CA0034.namprd04.prod.outlook.com (2603:10b6:803:2a::20) by CH2PR02MB7047.namprd02.prod.outlook.com (2603:10b6:610:85::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.30; Mon, 11 May 2020 17:05:56 +0000 Received: from SN1NAM02FT060.eop-nam02.prod.protection.outlook.com (2603:10b6:803:2a:cafe::57) by SN4PR0401CA0034.outlook.office365.com (2603:10b6:803:2a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.30 via Frontend Transport; Mon, 11 May 2020 17:05:56 +0000 Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT060.mail.protection.outlook.com (10.152.72.192) with Microsoft SMTP Server id 15.20.2979.29 via Frontend Transport; Mon, 11 May 2020 17:05:56 +0000 Received: from [149.199.38.66] (port=35077 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1jYBs4-0007nB-TO for qemu-devel@nongnu.org; Mon, 11 May 2020 10:05:40 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1jYBsK-0004Py-1j for qemu-devel@nongnu.org; Mon, 11 May 2020 10:05:56 -0700 Received: from xsj-pvapsmtp01 (xsj-pvapsmtp01.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 04BH5psI000793; Mon, 11 May 2020 10:05:52 -0700 Received: from [172.19.2.32] (helo=xsjkomlodi50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1jYBsF-0004PW-P7; Mon, 11 May 2020 10:05:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OrkbXmEL4JkUe0KsYMnkTfgjuWZsIZS5oBR01Y3crM2y8MjEziKPC3k2+bvMA3uAE6SpIG88g5Saxjw/HZqWFBQXGSndsTo7QDMD0fSdbJ41/lOVeUTezwYi6fygn57C9rTbmgFvtGHxpxMoBSjoDBqljCuqDrIy+9IfSo+Oq2t4SBIdv3L/VOsRvrz32hzqP+5TqWIrpHaWrr6QwW0s1SzKDkptWbCammtQHJIjFpFsLe3Jh8nqxeBCjwNGeSmai6OSesH57ZybVAAfRUcs/KvgAL+C+2AMzz8fM6EKWQ0IkBaBpSUun+6hyvX/2GNIysFblR0jzZlSonwEtip6Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hUeNmFjAPFyqGor4e03Zece3+ySpxSOYPpwOHZIGd5c=; b=aVKZNONn4dMnRfOc/UlHAJh6m2Im94roRMVX8F/xoMOZPBVpl2dp7OtGEk0xZ+joIDBfXFqWuILJcnj06xwr1vBV3rRTsChdbiqQN+nLAx0mRRhBK5HU7KPwbSzonK0tbueZ2RcWOzFcjTrsZBM9MQ3cLIg2Vwq8VaYgzIB66fb+6/irgKz/qpcaMuuhQ1tTLaZBEdYDBrUjdKdlOo7V1i+wmEUhPfXJClRb4m3OVjQVlSNe4BkEpLfH3Qo9bRcRODRCYKnYBVZM7d5kYsAKMWhGtO2UMxl1geCjMgtx2+pDBXhXIXwRvPSdBugX1RqRBAGhvQzFxDuY2wuDP8LL2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=nongnu.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hUeNmFjAPFyqGor4e03Zece3+ySpxSOYPpwOHZIGd5c=; b=Bs6a3C6h51vrqWjVt3u75H3BiqeHBUrBX6L0uqNhRHslWJe0VNraruebiVtF1y/vjZ21/nDDblIjKdmzQSovdSkU9u3bSpvjkx6pOstNg59Kqqm2w5Pf9g9vBbfppur9ftvH9VdTHXS9aWFN6vhO7XIFk6hIOG6sDd7EQQYN8wg= Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; From: Joe Komlodi To: qemu-devel@nongnu.org Subject: [PATCH v1 1/4] target/microblaze: gdb: Add dynamic GDB XML register support Date: Mon, 11 May 2020 10:05:48 -0700 Message-Id: <1589216751-106038-2-git-send-email-komlodi@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589216751-106038-1-git-send-email-komlodi@xilinx.com> References: <1589216751-106038-1-git-send-email-komlodi@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapsmtpgw01; PTR:unknown-60-83.xilinx.com; CAT:NONE; SFTY:; SFS:(376002)(136003)(396003)(346002)(39860400002)(46966005)(33430700001)(6666004)(336012)(44832011)(316002)(36756003)(33440700001)(82310400002)(2906002)(2616005)(426003)(86362001)(356005)(107886003)(478600001)(70206006)(81166007)(70586007)(6916009)(7696005)(82740400003)(8676002)(8936002)(186003)(9786002)(47076004)(26005)(5660300002)(4326008); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da4eb191-8113-421e-beef-08d7f5cd9212 X-MS-TrafficTypeDiagnostic: CH2PR02MB7047: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9rlePO0zG5nYjIx8Y3CPiDETq+G6OONthpvB7S6Pd9SGg5SVjgTcvPZ6Wxcjbws1qQ6EsMNjDIKZmeDPOaDvbFfJzF7+3+RIZRTBKf7E3eIWPpdOV4gKOZwAytCh80Rr1gxBVMMLETbPNReHUY7GC9UUjsHvu5SmH0occojLgCtpagImRU7jRkwZp4kpOR6cv/NUJleCV0wOkcC0KUePJq4QhXgturVHpxKm3r+X6rtAwtGivl/wWVX81H5Ypv6t0Cjgg0dBKp/lhVOCMQe5YJlJnbF/UAYani1lwA0gatbYhmNiKWkqYISrbwGilOzessWwaRIxbSQTc597fuGuKHVCtQ3yYFJYJXVq0WW3SJ83cmMbKPV58HftQiynhNAh2xi7cZV4EsggsXHz3QbKalsJepjW2e0HRdWE1n9P4vdnEJ0VXeuema8WxTpBPyAM13rLp/Nl4st3NqYVRRpmR6PTL78B4vrzxSaBgs+cR0Km+EUxaNcjRdJYCcMToXw/BvVVSiiaMmbVCv82oALgAjMbh0OS8H1p2opZtlfBdKnzgPdI+z7kdAyAhE3iEYov1zg01ZvEceop0nNeKXJHtQ== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 17:05:56.3987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da4eb191-8113-421e-beef-08d7f5cd9212 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR02MB7047 Received-SPF: pass client-ip=40.107.94.73; envelope-from=komlodi@xilinx.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/11 13:20:59 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edgar.iglesias@xilinx.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add dynamic GDB register XML for Microblaze, and modify the config file to use XML when building for Microblaze. For the dynamic XML to be read, there still needs to be a core XML file. Signed-off-by: Joe Komlodi --- configure | 1 + target/microblaze/cpu.c | 4 ++ target/microblaze/cpu.h | 9 ++++ target/microblaze/gdbstub.c | 123 ++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 137 insertions(+) diff --git a/configure b/configure index 0d69c36..5a099b6 100755 --- a/configure +++ b/configure @@ -7832,6 +7832,7 @@ case "$target_name" in TARGET_ARCH=3Dmicroblaze TARGET_SYSTBL_ABI=3Dcommon bflt=3D"yes" + gdb_xml_files=3D"microblaze-core.xml" echo "TARGET_ABI32=3Dy" >> $config_target_mak ;; mips|mipsel) diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index aa99830..41cac1b 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -226,6 +226,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **= errp) env->pvr.regs[11] =3D (cpu->cfg.use_mmu ? PVR11_USE_MMU : 0) | 16 << 17; =20 + mb_gen_dynamic_xml(cpu); + mcc->parent_realize(dev, errp); } =20 @@ -330,6 +332,8 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) dc->vmsd =3D &vmstate_mb_cpu; device_class_set_props(dc, mb_properties); cc->gdb_num_core_regs =3D 32 + 5; + cc->gdb_get_dynamic_xml =3D mb_gdb_get_dynamic_xml; + cc->gdb_core_xml_file =3D "microblaze-core.xml"; =20 cc->disas_set_info =3D mb_disas_set_info; cc->tcg_initialize =3D mb_tcg_init; diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index a31134b..074a18e 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -25,6 +25,8 @@ #include "fpu/softfloat-types.h" =20 typedef struct CPUMBState CPUMBState; +typedef struct DynamicMBGDBXMLInfo DynamicMBGDBXMLInfo; + #if !defined(CONFIG_USER_ONLY) #include "mmu.h" #endif @@ -272,6 +274,10 @@ struct CPUMBState { } pvr; }; =20 +struct DynamicMBGDBXMLInfo { + char *xml; +}; + /** * MicroBlazeCPU: * @env: #CPUMBState @@ -286,6 +292,7 @@ struct MicroBlazeCPU { =20 CPUNegativeOffsetState neg; CPUMBState env; + DynamicMBGDBXMLInfo dyn_xml; =20 /* Microblaze Configuration Settings */ struct { @@ -321,6 +328,8 @@ void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flag= s); hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +void mb_gen_dynamic_xml(MicroBlazeCPU *cpu); +const char *mb_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname); =20 void mb_tcg_init(void); /* you can call this signal handler from your SIGBUS and SIGSEGV diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index f41ebf1..cdca434 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -54,3 +54,126 @@ int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *me= m_buf, int n) } return 4; } + +static void mb_gen_xml_reg_tag(const MicroBlazeCPU *cpu, GString *s, + const char *name, uint8_t bitsize, + const char *type) +{ + g_string_append_printf(s, "\n"); +} + +static uint8_t mb_cpu_sreg_size(const MicroBlazeCPU *cpu, uint8_t index) +{ + /* + * NOTE: mb-gdb will refuse to connect if we say registers are + * larger then 32-bits. + * For now, say none of our registers are dynamically sized, and are + * therefore only 32-bits. + */ + + return 32; +} + +static void mb_gen_xml_reg_tags(const MicroBlazeCPU *cpu, GString *s) +{ + uint8_t i; + const char *type; + char reg_name[4]; + bool has_hw_exception =3D cpu->cfg.dopb_bus_exception || + cpu->cfg.iopb_bus_exception || + cpu->cfg.illegal_opcode_exception || + cpu->cfg.opcode_0_illegal || + cpu->cfg.div_zero_exception || + cpu->cfg.unaligned_exceptions; + + static const char *reg_types[32] =3D { + [1] =3D "data_ptr", + [14] =3D "code_ptr", + [15] =3D "code_ptr", + [16] =3D "code_ptr", + [17] =3D "code_ptr" + }; + + for (i =3D 0; i < 32; ++i) { + type =3D reg_types[i]; + /* r17 only has a code_ptr tag if we have HW exceptions */ + if (i =3D=3D 17 && !has_hw_exception) { + type =3D NULL; + } + + sprintf(reg_name, "r%d", i); + mb_gen_xml_reg_tag(cpu, s, reg_name, 32, type); + } +} + +static void mb_gen_xml_sreg_tags(const MicroBlazeCPU *cpu, GString *s) +{ + uint8_t i; + + static const char *sreg_names[] =3D { + "rpc", + "rmsr", + "rear", + "resr", + "rfsr", + "rbtr", + "rpvr0", + "rpvr1", + "rpvr2", + "rpvr3", + "rpvr4", + "rpvr5", + "rpvr6", + "rpvr7", + "rpvr8", + "rpvr9", + "rpvr10", + "rpvr11", + "redr", + "rpid", + "rzpr", + "rtlblo", + "rtlbhi", + "rtlbx", + "rtlbsx", + "rslr", + "rshr" + }; + + static const char *sreg_types[ARRAY_SIZE(sreg_names)] =3D { + [SR_PC] =3D "code_ptr" + }; + + for (i =3D 0; i < ARRAY_SIZE(sreg_names); ++i) { + mb_gen_xml_reg_tag(cpu, s, sreg_names[i], mb_cpu_sreg_size(cpu, i), + sreg_types[i]); + } +} + +void mb_gen_dynamic_xml(MicroBlazeCPU *cpu) +{ + GString *s =3D g_string_new(NULL); + + g_string_printf(s, "\n" + "\n" + "\n= "); + + mb_gen_xml_reg_tags(cpu, s); + mb_gen_xml_sreg_tags(cpu, s); + + g_string_append_printf(s, ""); + + cpu->dyn_xml.xml =3D g_string_free(s, false); +} + +const char *mb_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) +{ + MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); + + return cpu->dyn_xml.xml; +} --=20 2.7.4