Received: from eggs.gnu.org ([2001:4830:134:3::10]:37553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwgKs-0002NU-C4 for qemu-devel@nongnu.org; Tue, 09 Jul 2013 18:24:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwgKo-0002PE-Nq for qemu-devel@nongnu.org; Tue, 09 Jul 2013 18:24:38 -0400 Received: from cantor2.suse.de ([195.135.220.15]:33012 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwgKo-0002Og-9Y for qemu-devel@nongnu.org; Tue, 09 Jul 2013 18:24:34 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 10 Jul 2013 00:23:46 +0200 Message-Id: <1373408640-6046-28-git-send-email-afaerber@suse.de> In-Reply-To: <1373408640-6046-1-git-send-email-afaerber@suse.de> References: <1373408640-6046-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v3 27/41] target-arm: Move cpu_gdb_{read, write}_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Paul Brook Signed-off-by: Andreas F=C3=A4rber --- gdbstub.c | 74 +---------------------------------------- target-arm/gdbstub.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++= ++++++ 2 files changed, 95 insertions(+), 73 deletions(-) create mode 100644 target-arm/gdbstub.c diff --git a/gdbstub.c b/gdbstub.c index bf98eb0..73e6411 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -538,81 +538,9 @@ static int put_packet(GDBState *s, const char *buf) =20 #elif defined (TARGET_ARM) =20 -/* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expe= ct - whatever the target description contains. Due to a historical mishap - the FPA registers appear in between core integer regs and the CPSR. - We hack round this by giving the FPA regs zero size when talking to a - newer gdb. */ #define GDB_CORE_XML "arm-core.xml" =20 -static int cpu_gdb_read_register(CPUARMState *env, uint8_t *mem_buf, int= n) -{ - if (n < 16) { - /* Core integer register. */ - GET_REG32(env->regs[n]); - } - if (n < 24) { - /* FPA registers. */ - if (gdb_has_xml) { - return 0; - } - memset(mem_buf, 0, 12); - return 12; - } - switch (n) { - case 24: - /* FPA status register. */ - if (gdb_has_xml) { - return 0; - } - GET_REG32(0); - case 25: - /* CPSR */ - GET_REG32(cpsr_read(env)); - } - /* Unknown register. */ - return 0; -} - -static int cpu_gdb_write_register(CPUARMState *env, uint8_t *mem_buf, in= t n) -{ - uint32_t tmp; - - tmp =3D ldl_p(mem_buf); - - /* Mask out low bit of PC to workaround gdb bugs. This will probabl= y - cause problems if we ever implement the Jazelle DBX extensions. = */ - if (n =3D=3D 15) { - tmp &=3D ~1; - } - - if (n < 16) { - /* Core integer register. */ - env->regs[n] =3D tmp; - return 4; - } - if (n < 24) { /* 16-23 */ - /* FPA registers (ignored). */ - if (gdb_has_xml) { - return 0; - } - return 12; - } - switch (n) { - case 24: - /* FPA status register (ignored). */ - if (gdb_has_xml) { - return 0; - } - return 4; - case 25: - /* CPSR */ - cpsr_write(env, tmp, 0xffffffff); - return 4; - } - /* Unknown register. */ - return 0; -} +#include "target-arm/gdbstub.c" =20 #elif defined (TARGET_M68K) =20 diff --git a/target-arm/gdbstub.c b/target-arm/gdbstub.c new file mode 100644 index 0000000..74903a3 --- /dev/null +++ b/target-arm/gdbstub.c @@ -0,0 +1,94 @@ +/* + * ARM gdb server stub + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2013 SUSE LINUX Products GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expe= ct + whatever the target description contains. Due to a historical mishap + the FPA registers appear in between core integer regs and the CPSR. + We hack round this by giving the FPA regs zero size when talking to a + newer gdb. */ + +static int cpu_gdb_read_register(CPUARMState *env, uint8_t *mem_buf, int= n) +{ + if (n < 16) { + /* Core integer register. */ + GET_REG32(env->regs[n]); + } + if (n < 24) { + /* FPA registers. */ + if (gdb_has_xml) { + return 0; + } + memset(mem_buf, 0, 12); + return 12; + } + switch (n) { + case 24: + /* FPA status register. */ + if (gdb_has_xml) { + return 0; + } + GET_REG32(0); + case 25: + /* CPSR */ + GET_REG32(cpsr_read(env)); + } + /* Unknown register. */ + return 0; +} + +static int cpu_gdb_write_register(CPUARMState *env, uint8_t *mem_buf, in= t n) +{ + uint32_t tmp; + + tmp =3D ldl_p(mem_buf); + + /* Mask out low bit of PC to workaround gdb bugs. This will probabl= y + cause problems if we ever implement the Jazelle DBX extensions. = */ + if (n =3D=3D 15) { + tmp &=3D ~1; + } + + if (n < 16) { + /* Core integer register. */ + env->regs[n] =3D tmp; + return 4; + } + if (n < 24) { /* 16-23 */ + /* FPA registers (ignored). */ + if (gdb_has_xml) { + return 0; + } + return 12; + } + switch (n) { + case 24: + /* FPA status register (ignored). */ + if (gdb_has_xml) { + return 0; + } + return 4; + case 25: + /* CPSR */ + cpsr_write(env, tmp, 0xffffffff); + return 4; + } + /* Unknown register. */ + return 0; +} --=20 1.8.1.4