From 58d6951de562a3ef2214927006541fc16f0e5bd0 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Tue, 28 Jul 2009 18:26:51 +0000 Subject: * NEWS: Mention ARM VFP support. * target-descriptions.c (tdesc_register_type): Make public. (tdesc_unnumbered_register): New function. (tdesc_register_reggroup_p): Allow missing pseudo_register_reggroup_p. * target-descriptions.h (tdesc_register_type): Declare. (tdesc_unnumbered_register): Declare. * arm-tdep.c (arm_neon_quad_read, arm_neon_quad_write): New functions. (arm_push_dummy_call): Use arm_neon_quad_write. (arm_neon_double_type, arm_neon_quad_type): New functions. (arm_register_type): Handle VFP and NEON registers. Override the types of double-precision registers for NEON. Disable FPA registers if they are not present. (arm_dwarf_reg_to_regnum): Add current VFP and NEON register numbers. (arm_return_value): Use arm_neon_quad_write and arm_neon_quad_read. (arm_register_name): Handle VFP single and NEON quad registers. (arm_pseudo_read, arm_pseudo_write): New functions. (arm_gdbarch_init): Check for VFP and NEON in the target description. Assign numbers to double-precision registers. Register VFP and NEON pseudo registers. Remove a shadowed "i" variable. * arm-tdep.h (enum gdb_regnum): Add ARM_D0_REGNUM and ARM_D31_REGNUM. (struct gdbarch_tdep): Add have_neon_pseudos, have_neon, have_vfp_registers, have_vfp_pseudos, neon_double_type, and neon_quad_type. * features/Makefile: Make expedite settings only architecture specific. (WHICH): Add new ARM descriptions. * features/arm-with-neon.xml, features/arm-with-vfpv2.c, features/arm-with-vfpv3.c, features/arm-vfpv2.xml, features/arm-vfpv3.xml, features/arm-with-vfpv2.xml, features/arm-with-vfpv3.xml, features/arm-with-neon.c: New files. * regformats/arm-with-neon.dat, regformats/arm-with-vfpv2.dat, regformats/arm-with-vfpv3.dat: Generate. doc/ * gdb.texinfo (ARM Features): Document org.gnu.gdb.arm.vfp and org.gnu.gdb.arm.neon. gdbserver/ * linux-low.c (linux_write_memory): Update debugging output. * Makefile.in (clean): Add new descriptions. (arm-with-vfpv2.o, arm-with-vfpv2.c, arm-with-vfpv3.o) (arm-with-vfpv3.c, arm-with-neon.o, arm-with-neon.c): New rules. * configure.srv: Add new files for arm*-*-linux*. * linux-arm-low.c: Add new declarations. (PTRACE_GETVFPREGS, PTRACE_SETVFPREGS): Define if undefined. (arm_hwcap, HWCAP_VFP, HWCAP_IWMMXT, HWCAP_NEON, HWCAP_VFPv3) (HWCAP_VFPv3D16): New. (arm_fill_wmmxregset, arm_store_wmmxregset): Check HWCAP_IWMMXT instead of __IWMMXT__. (arm_fill_vfpregset, arm_store_vfpregset, arm_get_hwcap) (arm_arch_setup): New. (target_regsets): Remove #ifdef. Add VFP regset. (the_low_target): Use arm_arch_setup. testsuite/ * gdb.base/float.exp: Handle VFP registers. --- gdb/gdbserver/linux-arm-low.c | 153 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 141 insertions(+), 12 deletions(-) (limited to 'gdb/gdbserver/linux-arm-low.c') diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index 70597fc2aab..d47ee977311 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -20,14 +20,17 @@ #include "server.h" #include "linux-low.h" +#include #include #include "gdb_proc_service.h" -/* Defined in auto-generated file reg-arm.c. */ +/* Defined in auto-generated files. */ void init_registers_arm (void); -/* Defined in auto-generated file arm-with-iwmmxt.c. */ void init_registers_arm_with_iwmmxt (void); +void init_registers_arm_with_vfpv2 (void); +void init_registers_arm_with_vfpv3 (void); +void init_registers_arm_with_neon (void); #ifndef PTRACE_GET_THREAD_AREA #define PTRACE_GET_THREAD_AREA 22 @@ -38,6 +41,20 @@ void init_registers_arm_with_iwmmxt (void); # define PTRACE_SETWMMXREGS 19 #endif +#ifndef PTRACE_GETVFPREGS +# define PTRACE_GETVFPREGS 27 +# define PTRACE_SETVFPREGS 28 +#endif + +static unsigned long arm_hwcap; + +/* These are in in current kernels. */ +#define HWCAP_VFP 64 +#define HWCAP_IWMMXT 512 +#define HWCAP_NEON 4096 +#define HWCAP_VFPv3 8192 +#define HWCAP_VFPv3D16 16384 + #ifdef HAVE_SYS_REG_H #include #endif @@ -87,13 +104,14 @@ arm_store_gregset (const void *buf) supply_register (i, zerobuf); } -#ifdef __IWMMXT__ - static void arm_fill_wmmxregset (void *buf) { int i; + if (!(arm_hwcap & HWCAP_IWMMXT)) + return; + for (i = 0; i < 16; i++) collect_register (arm_num_regs + i, (char *) buf + i * 8); @@ -107,6 +125,9 @@ arm_store_wmmxregset (const void *buf) { int i; + if (!(arm_hwcap & HWCAP_IWMMXT)) + return; + for (i = 0; i < 16; i++) supply_register (arm_num_regs + i, (char *) buf + i * 8); @@ -115,7 +136,45 @@ arm_store_wmmxregset (const void *buf) supply_register (arm_num_regs + i + 16, (char *) buf + 16 * 8 + i * 4); } -#endif /* __IWMMXT__ */ +static void +arm_fill_vfpregset (void *buf) +{ + int i, num, base; + + if (!(arm_hwcap & HWCAP_VFP)) + return; + + if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) + num = 32; + else + num = 16; + + base = find_regno ("d0"); + for (i = 0; i < num; i++) + collect_register (base + i, (char *) buf + i * 8); + + collect_register_by_name ("fpscr", (char *) buf + 32 * 8); +} + +static void +arm_store_vfpregset (const void *buf) +{ + int i, num, base; + + if (!(arm_hwcap & HWCAP_VFP)) + return; + + if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) + num = 32; + else + num = 16; + + base = find_regno ("d0"); + for (i = 0; i < num; i++) + supply_register (base + i, (char *) buf + i * 8); + + supply_register_by_name ("fpscr", (char *) buf + 32 * 8); +} extern int debug_threads; @@ -208,24 +267,94 @@ ps_get_thread_area (const struct ps_prochandle *ph, return PS_OK; } +static int +arm_get_hwcap (unsigned long *valp) +{ + unsigned char *data = alloca (8); + int offset = 0; + + while ((*the_target->read_auxv) (offset, data, 8) == 8) + { + unsigned int *data_p = (unsigned int *)data; + if (data_p[0] == AT_HWCAP) + { + *valp = data_p[1]; + return 1; + } + + offset += 8; + } + + *valp = 0; + return 0; +} + +static void +arm_arch_setup (void) +{ + arm_hwcap = 0; + if (arm_get_hwcap (&arm_hwcap) == 0) + { + init_registers_arm (); + return; + } + + if (arm_hwcap & HWCAP_IWMMXT) + { + init_registers_arm_with_iwmmxt (); + return; + } + + if (arm_hwcap & HWCAP_VFP) + { + int pid; + char *buf; + + /* NEON implies either no VFP, or VFPv3-D32. We only support + it with VFP. */ + if (arm_hwcap & HWCAP_NEON) + init_registers_arm_with_neon (); + else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) + init_registers_arm_with_vfpv3 (); + else + init_registers_arm_with_vfpv2 (); + + /* Now make sure that the kernel supports reading these + registers. Support was added in 2.6.30. */ + pid = lwpid_of (get_thread_lwp (current_inferior)); + errno = 0; + buf = malloc (32 * 8 + 4); + if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 + && errno == EIO) + { + arm_hwcap = 0; + init_registers_arm (); + } + free (buf); + + return; + } + + /* The default configuration uses legacy FPA registers, probably + simulated. */ + init_registers_arm (); +} + struct regset_info target_regsets[] = { { PTRACE_GETREGS, PTRACE_SETREGS, 18 * 4, GENERAL_REGS, arm_fill_gregset, arm_store_gregset }, -#ifdef __IWMMXT__ { PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS, 16 * 8 + 6 * 4, EXTENDED_REGS, arm_fill_wmmxregset, arm_store_wmmxregset }, -#endif + { PTRACE_GETVFPREGS, PTRACE_SETVFPREGS, 32 * 8 + 4, + EXTENDED_REGS, + arm_fill_vfpregset, arm_store_vfpregset }, { 0, 0, -1, -1, NULL, NULL } }; struct linux_target_ops the_low_target = { -#ifdef __IWMMXT__ - init_registers_arm_with_iwmmxt, -#else - init_registers_arm, -#endif + arm_arch_setup, arm_num_regs, arm_regmap, arm_cannot_fetch_register, -- cgit v1.2.1