2004-01-03 13:09:48 +01:00
|
|
|
/* SPARC-specific portions of the RPC protocol for VxWorks.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
Contributed by Wind River Systems.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This file is part of GDB.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This program 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 General Public License for more details.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
2001-03-01 02:39:22 +01:00
|
|
|
#include "regcache.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include "gdb_string.h"
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
#include "sparc-tdep.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
#include "vx-share/ptrace.h"
|
|
|
|
#include "vx-share/regPacket.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
#define SPARC_R_G1 (SPARC_R_G0 + SPARC_GREG_SIZE)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
const struct sparc_gregset vxsparc_gregset =
|
|
|
|
{
|
|
|
|
SPARC_R_PSR, /* %psr */
|
|
|
|
SPARC_R_PC, /* %pc */
|
|
|
|
SPARC_R_NPC, /* %npc */
|
|
|
|
SPARC_R_Y, /* %y */
|
|
|
|
SPARC_R_WIM, /* %wim */
|
|
|
|
SPARC_R_TBR, /* %tbr */
|
|
|
|
SPARC_R_G1, /* %g1 */
|
|
|
|
SPARC_R_I0 /* %l0 */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Flag set if target has an FPU. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
extern int target_has_fp;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
/* Generic register read/write routines in remote-vx.c. */
|
|
|
|
|
|
|
|
extern void net_read_registers ();
|
|
|
|
extern void net_write_registers ();
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* Read a register or registers from the VxWorks target. REGNUM is
|
|
|
|
the register to read, or -1 for all; currently, it is ignored.
|
|
|
|
FIXME: Look at REGNUM to improve efficiency. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
void
|
2004-01-03 13:09:48 +01:00
|
|
|
vx_read_register (int regnum)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2004-01-03 13:09:48 +01:00
|
|
|
struct regcache *regcache = current_regcache;
|
|
|
|
char gregs[SPARC_GREG_PLEN];
|
|
|
|
char fpregs[SPARC_FPREG_PLEN];
|
1999-04-16 03:35:26 +02:00
|
|
|
CORE_ADDR sp;
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* Get the general-purpose registers. */
|
|
|
|
net_read_registers (gregs, SPARC_GREG_PLEN, PTRACE_GETREGS);
|
|
|
|
sparc32_supply_gregset (&vxsparc_gregset, regcache, -1, gregs);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* If the target has floating-point registers, fetch them.
|
|
|
|
Otherwise, zero the floating-point register values in GDB's
|
|
|
|
register cache for good measure, even though we might not need
|
|
|
|
to. */
|
1999-04-16 03:35:26 +02:00
|
|
|
if (target_has_fp)
|
2004-01-03 13:09:48 +01:00
|
|
|
net_read_registers (fpregs, SPARC_FPREG_PLEN, PTRACE_GETFPREGS);
|
1999-04-16 03:35:26 +02:00
|
|
|
else
|
2004-01-03 13:09:48 +01:00
|
|
|
memset (fpregs, 0, SPARC_FPREG_PLEN);
|
|
|
|
sparc32_supply_fpregset (regcache, -1, fpregs);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* Store a register or registers into the VxWorks target. REGNUM is
|
|
|
|
the register to store, or -1 for all; currently, it is ignored.
|
|
|
|
FIXME: Look at REGNUM to improve efficiency. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
void
|
2004-01-03 13:09:48 +01:00
|
|
|
vx_write_register (int regnum)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2004-01-03 13:09:48 +01:00
|
|
|
struct regcache *regcache = current_regcache;
|
|
|
|
char gregs[SPARC_GREG_PLEN];
|
|
|
|
char fpregs[SPARC_FPREG_PLEN];
|
|
|
|
int gregs_p = 1;
|
|
|
|
int fpregs_p = 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
CORE_ADDR sp;
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
if (regnum != -1)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2004-01-03 13:09:48 +01:00
|
|
|
if ((SPARC_G0_REGNUM <= regnum && regnum <= SPARC_I7_REGNUM)
|
|
|
|
|| (SPARC32_Y_REGNUM <= regnum && regnum <= SPARC32_NPC_REGNUM))
|
|
|
|
fpregs_p = 0;
|
1999-04-16 03:35:26 +02:00
|
|
|
else
|
2004-01-03 13:09:48 +01:00
|
|
|
gregs_p = 0;
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* Store the general-purpose registers. */
|
|
|
|
if (gregs_p)
|
|
|
|
{
|
|
|
|
sparc32_collect_gregset (&vxsparc_gregset, regcache, -1, gregs);
|
|
|
|
net_write_registers (gregs, SPARC_GREG_PLEN, PTRACE_SETREGS);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* Deal with the stack regs. */
|
|
|
|
if (regnum == -1 || regnum == SPARC_SP_REGNUM
|
|
|
|
|| (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM))
|
1999-07-07 22:19:36 +02:00
|
|
|
{
|
2004-01-03 13:09:48 +01:00
|
|
|
ULONGEST sp;
|
|
|
|
|
|
|
|
regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp);
|
|
|
|
sparc_collect_rwindow (regcache, sp, regnum);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-03 13:09:48 +01:00
|
|
|
/* Store the floating-point registers if the target has them. */
|
|
|
|
if (fpregs_p && target_has_fp)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2004-01-03 13:09:48 +01:00
|
|
|
sparc32_collect_fpregset (regcache, -1, fpregs);
|
|
|
|
net_write_registers (fpregs, SPARC_FPREG_PLEN, PTRACE_SETFPREGS);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
}
|