1 /* MIPS-dependent portions of the RPC protocol
2 used with a VxWorks target
4 Contributed by Wind River Systems.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 #include "vx-share/regPacket.h"
36 #include "gdb_string.h"
39 #include <sys/types.h>
41 #include <sys/socket.h>
43 #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
45 #include "vx-share/ptrace.h"
46 #include "vx-share/xdr_ptrace.h"
47 #include "vx-share/xdr_ld.h"
48 #include "vx-share/xdr_rdb.h"
49 #include "vx-share/dbgRpcLib.h"
51 /* get rid of value.h if possible */
55 /* Flag set if target has fpu */
57 extern int target_has_fp;
59 /* Generic register read/write routines in remote-vx.c. */
61 extern void net_read_registers ();
62 extern void net_write_registers ();
64 /* Read a register or registers from the VxWorks target.
65 REGNO is the register to read, or -1 for all; currently,
66 it is ignored. FIXME look at regno to improve efficiency. */
69 vx_read_register (int regno)
71 char mips_greg_packet[MIPS_GREG_PLEN];
72 char mips_fpreg_packet[MIPS_FPREG_PLEN];
74 /* Get general-purpose registers. */
76 net_read_registers (mips_greg_packet, MIPS_GREG_PLEN, PTRACE_GETREGS);
78 /* this code copies the registers obtained by RPC
79 stored in a structure(s) like this :
88 into a stucture like this:
94 0x8C BAD --- Not available currently
95 0x90 CAUSE --- Not available currently
99 0x11C FIR --- Not available currently
100 0x120 FP --- Not available currently
102 structure is 0x124 (292) bytes in length */
104 /* Copy the general registers. */
106 memcpy (&deprecated_registers[0], &mips_greg_packet[MIPS_R_GP0],
107 32 * MIPS_GREG_SIZE);
109 /* Copy SR, LO, HI, and PC. */
111 memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (MIPS_PS_REGNUM)],
112 &mips_greg_packet[MIPS_R_SR],
114 memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->lo)],
115 &mips_greg_packet[MIPS_R_LO],
117 memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->hi)],
118 &mips_greg_packet[MIPS_R_HI],
120 memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->pc)],
121 &mips_greg_packet[MIPS_R_PC],
124 /* If the target has floating point registers, fetch them.
125 Otherwise, zero the floating point register values in
126 registers[] for good measure, even though we might not
131 net_read_registers (mips_fpreg_packet, MIPS_FPREG_PLEN,
134 /* Copy the floating point registers. */
136 memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)],
137 &mips_fpreg_packet[MIPS_R_FP0],
138 register_size (current_gdbarch, FP0_REGNUM) * 32);
140 /* Copy the floating point control/status register (fpcsr). */
142 memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)],
143 &mips_fpreg_packet[MIPS_R_FPCSR],
144 register_size (current_gdbarch, mips_regnum (current_gdbarch)->fp_control_status));
148 memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)],
149 0, register_size (current_gdbarch, FP0_REGNUM) * 32);
150 memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)],
151 0, register_size (current_gdbarch, mips_regnum (current_gdbarch)->fp_control_status));
154 /* Mark the register cache valid. */
156 deprecated_registers_fetched ();
159 /* Store a register or registers into the VxWorks target.
160 REGNO is the register to store, or -1 for all; currently,
161 it is ignored. FIXME look at regno to improve efficiency. */
163 vx_write_register (int regno)
165 char mips_greg_packet[MIPS_GREG_PLEN];
166 char mips_fpreg_packet[MIPS_FPREG_PLEN];
168 /* Store general registers. */
170 memcpy (&mips_greg_packet[MIPS_R_GP0], &deprecated_registers[0],
171 32 * MIPS_GREG_SIZE);
173 /* Copy SR, LO, HI, and PC. */
175 memcpy (&mips_greg_packet[MIPS_R_SR],
176 &deprecated_registers[DEPRECATED_REGISTER_BYTE (MIPS_PS_REGNUM)],
178 memcpy (&mips_greg_packet[MIPS_R_LO],
179 &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->lo)],
181 memcpy (&mips_greg_packet[MIPS_R_HI],
182 &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->hi)],
184 memcpy (&mips_greg_packet[MIPS_R_PC],
185 &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->pc)],
188 net_write_registers (mips_greg_packet, MIPS_GREG_PLEN, PTRACE_SETREGS);
190 /* Store floating point registers if the target has them. */
194 /* Copy the floating point data registers. */
196 memcpy (&mips_fpreg_packet[MIPS_R_FP0],
197 &deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)],
198 register_size (current_gdbarch, FP0_REGNUM) * 32);
200 /* Copy the floating point control/status register (fpcsr). */
202 memcpy (&mips_fpreg_packet[MIPS_R_FPCSR],
203 &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)],
204 register_size (current_gdbarch, mips_regnum (current_gdbarch)->fp_control_status));
206 net_write_registers (mips_fpreg_packet, MIPS_FPREG_PLEN,