1 /* SPARC-specific portions of the RPC protocol for VxWorks.
3 Contributed by Wind River Systems.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
27 #include "sparc-tdep.h"
29 #include "vx-share/ptrace.h"
30 #include "vx-share/regPacket.h"
32 #define SPARC_R_G1 (SPARC_R_G0 + SPARC_GREG_SIZE)
34 const struct sparc_gregset vxsparc_gregset
=
36 SPARC_R_PSR
, /* %psr */
38 SPARC_R_NPC
, /* %npc */
40 SPARC_R_WIM
, /* %wim */
41 SPARC_R_TBR
, /* %tbr */
46 /* Flag set if target has an FPU. */
48 extern int target_has_fp
;
50 /* Generic register read/write routines in remote-vx.c. */
52 extern void net_read_registers ();
53 extern void net_write_registers ();
55 /* Read a register or registers from the VxWorks target. REGNUM is
56 the register to read, or -1 for all; currently, it is ignored.
57 FIXME: Look at REGNUM to improve efficiency. */
60 vx_read_register (int regnum
)
62 struct regcache
*regcache
= current_regcache
;
63 char gregs
[SPARC_GREG_PLEN
];
64 char fpregs
[SPARC_FPREG_PLEN
];
67 /* Get the general-purpose registers. */
68 net_read_registers (gregs
, SPARC_GREG_PLEN
, PTRACE_GETREGS
);
69 sparc32_supply_gregset (&vxsparc_gregset
, regcache
, -1, gregs
);
71 /* If the target has floating-point registers, fetch them.
72 Otherwise, zero the floating-point register values in GDB's
73 register cache for good measure, even though we might not need
76 net_read_registers (fpregs
, SPARC_FPREG_PLEN
, PTRACE_GETFPREGS
);
78 memset (fpregs
, 0, SPARC_FPREG_PLEN
);
79 sparc32_supply_fpregset (regcache
, -1, fpregs
);
82 /* Store a register or registers into the VxWorks target. REGNUM is
83 the register to store, or -1 for all; currently, it is ignored.
84 FIXME: Look at REGNUM to improve efficiency. */
87 vx_write_register (int regnum
)
89 struct regcache
*regcache
= current_regcache
;
90 char gregs
[SPARC_GREG_PLEN
];
91 char fpregs
[SPARC_FPREG_PLEN
];
98 if ((SPARC_G0_REGNUM
<= regnum
&& regnum
<= SPARC_I7_REGNUM
)
99 || (SPARC32_Y_REGNUM
<= regnum
&& regnum
<= SPARC32_NPC_REGNUM
))
105 /* Store the general-purpose registers. */
108 sparc32_collect_gregset (&vxsparc_gregset
, regcache
, -1, gregs
);
109 net_write_registers (gregs
, SPARC_GREG_PLEN
, PTRACE_SETREGS
);
111 /* Deal with the stack regs. */
112 if (regnum
== -1 || regnum
== SPARC_SP_REGNUM
113 || (regnum
>= SPARC_L0_REGNUM
&& regnum
<= SPARC_I7_REGNUM
))
117 regcache_cooked_read_unsigned (regcache
, SPARC_SP_REGNUM
, &sp
);
118 sparc_collect_rwindow (regcache
, sp
, regnum
);
122 /* Store the floating-point registers if the target has them. */
123 if (fpregs_p
&& target_has_fp
)
125 sparc32_collect_fpregset (regcache
, -1, fpregs
);
126 net_write_registers (fpregs
, SPARC_FPREG_PLEN
, PTRACE_SETFPREGS
);