Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* MIPS-dependent portions of the RPC protocol |
2 | used with a VxWorks target | |
3 | ||
c5aa993b | 4 | Contributed by Wind River Systems. |
c906108c | 5 | |
c5aa993b | 6 | This file is part of GDB. |
c906108c | 7 | |
c5aa993b JM |
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. | |
c906108c | 12 | |
c5aa993b JM |
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. | |
c906108c | 17 | |
c5aa993b JM |
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. */ | |
c906108c SS |
22 | |
23 | #include <stdio.h> | |
24 | #include "defs.h" | |
25 | ||
c5aa993b | 26 | #include "vx-share/regPacket.h" |
c906108c SS |
27 | #include "frame.h" |
28 | #include "inferior.h" | |
c906108c SS |
29 | #include "target.h" |
30 | #include "gdbcore.h" | |
31 | #include "command.h" | |
32 | #include "symtab.h" | |
72367fb4 | 33 | #include "symfile.h" |
4e052eda | 34 | #include "regcache.h" |
c906108c SS |
35 | |
36 | #include "gdb_string.h" | |
37 | #include <errno.h> | |
c906108c SS |
38 | #include <fcntl.h> |
39 | #include <sys/types.h> | |
40 | #include <sys/time.h> | |
41 | #include <sys/socket.h> | |
42 | #include <rpc/rpc.h> | |
43 | #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */ | |
44 | #include <netdb.h> | |
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" | |
50 | ||
51 | /* get rid of value.h if possible */ | |
52 | #include <value.h> | |
53 | #include <symtab.h> | |
54 | ||
55 | /* Flag set if target has fpu */ | |
56 | ||
57 | extern int target_has_fp; | |
58 | ||
59 | /* Generic register read/write routines in remote-vx.c. */ | |
60 | ||
61 | extern void net_read_registers (); | |
62 | extern void net_write_registers (); | |
63 | ||
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. */ | |
67 | ||
68 | void | |
fba45db2 | 69 | vx_read_register (int regno) |
c906108c SS |
70 | { |
71 | char mips_greg_packet[MIPS_GREG_PLEN]; | |
72 | char mips_fpreg_packet[MIPS_FPREG_PLEN]; | |
73 | ||
74 | /* Get general-purpose registers. */ | |
75 | ||
76 | net_read_registers (mips_greg_packet, MIPS_GREG_PLEN, PTRACE_GETREGS); | |
77 | ||
78 | /* this code copies the registers obtained by RPC | |
79 | stored in a structure(s) like this : | |
c5aa993b JM |
80 | |
81 | Register(s) Offset(s) | |
82 | gp 0-31 0x00 | |
83 | hi 0x80 | |
84 | lo 0x84 | |
85 | sr 0x88 | |
86 | pc 0x8c | |
87 | ||
c906108c | 88 | into a stucture like this: |
c5aa993b JM |
89 | |
90 | 0x00 GP 0-31 | |
91 | 0x80 SR | |
92 | 0x84 LO | |
93 | 0x88 HI | |
94 | 0x8C BAD --- Not available currently | |
95 | 0x90 CAUSE --- Not available currently | |
96 | 0x94 PC | |
97 | 0x98 FP 0-31 | |
98 | 0x118 FCSR | |
99 | 0x11C FIR --- Not available currently | |
100 | 0x120 FP --- Not available currently | |
101 | ||
c906108c | 102 | structure is 0x124 (292) bytes in length */ |
c5aa993b | 103 | |
c906108c | 104 | /* Copy the general registers. */ |
c5aa993b | 105 | |
98d346c3 AC |
106 | memcpy (&deprecated_registers[0], &mips_greg_packet[MIPS_R_GP0], |
107 | 32 * MIPS_GREG_SIZE); | |
c5aa993b | 108 | |
c906108c | 109 | /* Copy SR, LO, HI, and PC. */ |
c5aa993b | 110 | |
98d346c3 AC |
111 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)], |
112 | &mips_greg_packet[MIPS_R_SR], | |
113 | MIPS_GREG_SIZE); | |
114 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->lo)], | |
115 | &mips_greg_packet[MIPS_R_LO], | |
116 | MIPS_GREG_SIZE); | |
117 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->hi)], | |
118 | &mips_greg_packet[MIPS_R_HI], | |
119 | MIPS_GREG_SIZE); | |
120 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->pc)], | |
121 | &mips_greg_packet[MIPS_R_PC], | |
122 | MIPS_GREG_SIZE); | |
c5aa993b | 123 | |
c906108c SS |
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 | |
127 | need to. */ | |
c5aa993b | 128 | |
c906108c SS |
129 | if (target_has_fp) |
130 | { | |
131 | net_read_registers (mips_fpreg_packet, MIPS_FPREG_PLEN, | |
132 | PTRACE_GETFPREGS); | |
133 | ||
134 | /* Copy the floating point registers. */ | |
135 | ||
98d346c3 AC |
136 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], |
137 | &mips_fpreg_packet[MIPS_R_FP0], | |
3acba339 | 138 | register_size (current_gdbarch, FP0_REGNUM) * 32); |
c906108c SS |
139 | |
140 | /* Copy the floating point control/status register (fpcsr). */ | |
141 | ||
98d346c3 AC |
142 | memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)], |
143 | &mips_fpreg_packet[MIPS_R_FPCSR], | |
3acba339 | 144 | register_size (current_gdbarch, mips_regnum (current_gdbarch)->fp_control_status)); |
c5aa993b | 145 | } |
c906108c | 146 | else |
c5aa993b | 147 | { |
4deab737 | 148 | memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], |
3acba339 | 149 | 0, register_size (current_gdbarch, FP0_REGNUM) * 32); |
56cea623 | 150 | memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)], |
3acba339 | 151 | 0, register_size (current_gdbarch, mips_regnum (current_gdbarch)->fp_control_status)); |
c5aa993b | 152 | } |
c906108c SS |
153 | |
154 | /* Mark the register cache valid. */ | |
155 | ||
2b9e5f3f | 156 | deprecated_registers_fetched (); |
c906108c SS |
157 | } |
158 | ||
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. */ | |
162 | ||
fba45db2 | 163 | vx_write_register (int regno) |
c906108c SS |
164 | { |
165 | char mips_greg_packet[MIPS_GREG_PLEN]; | |
166 | char mips_fpreg_packet[MIPS_FPREG_PLEN]; | |
167 | ||
168 | /* Store general registers. */ | |
169 | ||
98d346c3 AC |
170 | memcpy (&mips_greg_packet[MIPS_R_GP0], &deprecated_registers[0], |
171 | 32 * MIPS_GREG_SIZE); | |
c5aa993b | 172 | |
c906108c | 173 | /* Copy SR, LO, HI, and PC. */ |
c5aa993b | 174 | |
98d346c3 AC |
175 | memcpy (&mips_greg_packet[MIPS_R_SR], |
176 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)], | |
177 | MIPS_GREG_SIZE); | |
178 | memcpy (&mips_greg_packet[MIPS_R_LO], | |
179 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->lo)], | |
180 | MIPS_GREG_SIZE); | |
181 | memcpy (&mips_greg_packet[MIPS_R_HI], | |
182 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->hi)], | |
183 | MIPS_GREG_SIZE); | |
184 | memcpy (&mips_greg_packet[MIPS_R_PC], | |
185 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->pc)], | |
186 | MIPS_GREG_SIZE); | |
c5aa993b | 187 | |
c906108c SS |
188 | net_write_registers (mips_greg_packet, MIPS_GREG_PLEN, PTRACE_SETREGS); |
189 | ||
190 | /* Store floating point registers if the target has them. */ | |
191 | ||
192 | if (target_has_fp) | |
193 | { | |
194 | /* Copy the floating point data registers. */ | |
195 | ||
98d346c3 AC |
196 | memcpy (&mips_fpreg_packet[MIPS_R_FP0], |
197 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], | |
3acba339 | 198 | register_size (current_gdbarch, FP0_REGNUM) * 32); |
c906108c SS |
199 | |
200 | /* Copy the floating point control/status register (fpcsr). */ | |
201 | ||
98d346c3 AC |
202 | memcpy (&mips_fpreg_packet[MIPS_R_FPCSR], |
203 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (mips_regnum (current_gdbarch)->fp_control_status)], | |
3acba339 | 204 | register_size (current_gdbarch, mips_regnum (current_gdbarch)->fp_control_status)); |
c906108c SS |
205 | |
206 | net_write_registers (mips_fpreg_packet, MIPS_FPREG_PLEN, | |
207 | PTRACE_SETFPREGS); | |
208 | } | |
209 | } |