From nobody Mon Feb 9 02:12:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1546632138948941.1748233898737; Fri, 4 Jan 2019 12:02:18 -0800 (PST) Received: from localhost ([127.0.0.1]:38575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gfVfd-0006dm-Ud for importer@patchew.org; Fri, 04 Jan 2019 15:02:17 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gfVam-0000lM-1a for qemu-devel@nongnu.org; Fri, 04 Jan 2019 14:57:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gfVai-0000dy-06 for qemu-devel@nongnu.org; Fri, 04 Jan 2019 14:57:15 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36364 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gfVaf-0000bN-Tu for qemu-devel@nongnu.org; Fri, 04 Jan 2019 14:57:11 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x04JsXts127612 for ; Fri, 4 Jan 2019 14:57:09 -0500 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ptd492mrf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 04 Jan 2019 14:57:09 -0500 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 Jan 2019 19:57:08 -0000 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 4 Jan 2019 19:57:05 -0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x04Jv4Dt25165828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 4 Jan 2019 19:57:04 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A282AE07A; Fri, 4 Jan 2019 19:57:04 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7273AAE06F; Fri, 4 Jan 2019 19:57:03 +0000 (GMT) Received: from farosas.linux.ibm.com.ibmmodules.com (unknown [9.80.232.60]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 4 Jan 2019 19:57:03 +0000 (GMT) From: Fabiano Rosas To: qemu-devel@nongnu.org Date: Fri, 4 Jan 2019 17:56:53 -0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190104195654.19976-1-farosas@linux.ibm.com> References: <20190104195654.19976-1-farosas@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19010419-0068-0000-0000-0000037D2CC1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010345; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000272; SDB=6.01141746; UDB=6.00594252; IPR=6.00921976; MB=3.00024980; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-04 19:57:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19010419-0069-0000-0000-0000470121A8 Message-Id: <20190104195654.19976-3-farosas@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-04_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=996 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901040169 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 2/3] target/ppc: Add GDB callbacks for SPRs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These will be used to let GDB know about PPC's Special Purpose Registers (SPR). They take an index based on the order the registers appear in the XML file sent by QEMU to GDB. This index does not match the actual location of the registers in the env->spr array so the gdb_find_spr_idx function does that conversion. Signed-off-by: Fabiano Rosas --- target/ppc/translate_init.inc.c | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 03f1d34a97..f10a3637d9 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -9483,6 +9483,56 @@ static bool avr_need_swap(CPUPPCState *env) #endif } =20 +#if !defined(CONFIG_USER_ONLY) +static int gdb_find_spr_idx(CPUPPCState *env, int n) +{ + int idx =3D -1; + int i; + + for (i =3D 0; i < ARRAY_SIZE(env->spr_cb); i++) { + ppc_spr_t *spr =3D &env->spr_cb[i]; + + if (spr->name && ++idx =3D=3D n) { + break; + } + } + return i; +} + +static int gdb_get_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +{ + int reg; + int len; + + reg =3D gdb_find_spr_idx(env, n); + if (!reg) { + return 0; + } + + len =3D TARGET_LONG_SIZE; + stn_p(mem_buf, len, env->spr[reg]); + ppc_maybe_bswap_register(env, mem_buf, len); + return len; +} + +static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +{ + int reg; + int len; + + reg =3D gdb_find_spr_idx(env, n); + if (!reg) { + return 0; + } + + len =3D TARGET_LONG_SIZE; + ppc_maybe_bswap_register(env, mem_buf, len); + env->spr[reg] =3D ldn_p(mem_buf, len); + + return len; +} +#endif + static int gdb_get_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) { if (n < 32) { --=20 2.17.1