Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Am29k-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" | |
33 | #include "symfile.h" /* for struct complaint */ | |
34 | ||
35 | #include "gdb_string.h" | |
36 | #include <errno.h> | |
37 | #include <signal.h> | |
38 | #include <fcntl.h> | |
39 | #include <sys/types.h> | |
40 | #include <sys/time.h> | |
41 | #include <sys/socket.h> | |
42 | ||
c5aa993b | 43 | #ifdef _AIX /* IBM claims "void *malloc()" not char * */ |
c906108c SS |
44 | #define malloc bogon_malloc |
45 | #endif | |
46 | ||
47 | #include <rpc/rpc.h> | |
48 | #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */ | |
49 | #include <netdb.h> | |
50 | #include "vx-share/ptrace.h" | |
51 | #include "vx-share/xdr_ptrace.h" | |
52 | #include "vx-share/xdr_ld.h" | |
53 | #include "vx-share/xdr_rdb.h" | |
54 | #include "vx-share/dbgRpcLib.h" | |
55 | ||
56 | /* get rid of value.h if possible */ | |
57 | #include <value.h> | |
58 | #include <symtab.h> | |
59 | ||
60 | /* Flag set if target has fpu */ | |
61 | ||
62 | extern int target_has_fp; | |
63 | ||
64 | /* Generic register read/write routines in remote-vx.c. */ | |
65 | ||
66 | extern void net_read_registers (); | |
67 | extern void net_write_registers (); | |
68 | ||
69 | /* Read a register or registers from the VxWorks target. | |
70 | REGNO is the register to read, or -1 for all; currently, | |
71 | it is ignored. FIXME look at regno to improve efficiency. */ | |
72 | ||
73 | void | |
fba45db2 | 74 | vx_read_register (int regno) |
c906108c SS |
75 | { |
76 | char am29k_greg_packet[AM29K_GREG_PLEN]; | |
77 | char am29k_fpreg_packet[AM29K_FPREG_PLEN]; | |
78 | ||
79 | /* Get general-purpose registers. When copying values into | |
80 | registers [], don't assume that a location in registers [] | |
81 | is properly aligned for the target data type. */ | |
82 | ||
83 | net_read_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_GETREGS); | |
84 | ||
85 | /* Now copy the register values into registers[]. | |
86 | Note that this code depends on the ordering of the REGNUMs | |
87 | as defined in "tm-29k.h". */ | |
88 | ||
89 | bcopy (&am29k_greg_packet[AM29K_R_GR96], | |
90 | ®isters[REGISTER_BYTE (GR96_REGNUM)], 160 * AM29K_GREG_SIZE); | |
91 | bcopy (&am29k_greg_packet[AM29K_R_VAB], | |
92 | ®isters[REGISTER_BYTE (VAB_REGNUM)], 15 * AM29K_GREG_SIZE); | |
93 | registers[REGISTER_BYTE (INTE_REGNUM)] = am29k_greg_packet[AM29K_R_INTE]; | |
94 | bcopy (&am29k_greg_packet[AM29K_R_RSP], | |
95 | ®isters[REGISTER_BYTE (GR1_REGNUM)], 5 * AM29K_GREG_SIZE); | |
96 | ||
97 | /* PAD For now, don't care about exop register */ | |
98 | ||
99 | memset (®isters[REGISTER_BYTE (EXO_REGNUM)], '\0', AM29K_GREG_SIZE); | |
100 | ||
101 | /* If the target has floating point registers, fetch them. | |
102 | Otherwise, zero the floating point register values in | |
103 | registers[] for good measure, even though we might not | |
104 | need to. */ | |
105 | ||
106 | if (target_has_fp) | |
107 | { | |
108 | net_read_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN, | |
c5aa993b | 109 | PTRACE_GETFPREGS); |
c906108c SS |
110 | registers[REGISTER_BYTE (FPE_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPE]; |
111 | registers[REGISTER_BYTE (FPS_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPS]; | |
112 | ||
113 | /* PAD For now, don't care about registers (?) AI0 to q */ | |
114 | ||
115 | memset (®isters[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE); | |
116 | } | |
117 | else | |
c5aa993b | 118 | { |
c906108c SS |
119 | memset (®isters[REGISTER_BYTE (FPE_REGNUM)], '\0', AM29K_FPREG_SIZE); |
120 | memset (®isters[REGISTER_BYTE (FPS_REGNUM)], '\0', AM29K_FPREG_SIZE); | |
121 | ||
122 | /* PAD For now, don't care about registers (?) AI0 to q */ | |
123 | ||
124 | memset (®isters[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE); | |
125 | } | |
126 | ||
127 | /* Mark the register cache valid. */ | |
128 | ||
129 | registers_fetched (); | |
130 | } | |
131 | ||
132 | /* Store a register or registers into the VxWorks target. | |
133 | REGNO is the register to store, or -1 for all; currently, | |
134 | it is ignored. FIXME look at regno to improve efficiency. */ | |
135 | ||
136 | void | |
fba45db2 | 137 | vx_write_register (int regno) |
c906108c SS |
138 | { |
139 | char am29k_greg_packet[AM29K_GREG_PLEN]; | |
140 | char am29k_fpreg_packet[AM29K_FPREG_PLEN]; | |
141 | ||
142 | /* Store general purpose registers. When copying values from | |
143 | registers [], don't assume that a location in registers [] | |
144 | is properly aligned for the target data type. */ | |
145 | ||
146 | bcopy (®isters[REGISTER_BYTE (GR96_REGNUM)], | |
147 | &am29k_greg_packet[AM29K_R_GR96], 160 * AM29K_GREG_SIZE); | |
148 | bcopy (®isters[REGISTER_BYTE (VAB_REGNUM)], | |
149 | &am29k_greg_packet[AM29K_R_VAB], 15 * AM29K_GREG_SIZE); | |
150 | am29k_greg_packet[AM29K_R_INTE] = registers[REGISTER_BYTE (INTE_REGNUM)]; | |
151 | bcopy (®isters[REGISTER_BYTE (GR1_REGNUM)], | |
152 | &am29k_greg_packet[AM29K_R_RSP], 5 * AM29K_GREG_SIZE); | |
153 | ||
154 | net_write_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_SETREGS); | |
155 | ||
156 | /* Store floating point registers if the target has them. */ | |
157 | ||
158 | if (target_has_fp) | |
159 | { | |
160 | am29k_fpreg_packet[AM29K_R_FPE] = registers[REGISTER_BYTE (FPE_REGNUM)]; | |
161 | am29k_fpreg_packet[AM29K_R_FPS] = registers[REGISTER_BYTE (FPS_REGNUM)]; | |
162 | ||
163 | net_write_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN, | |
c5aa993b | 164 | PTRACE_SETFPREGS); |
c906108c SS |
165 | } |
166 | } | |
167 | ||
168 | /* VxWorks zeroes fp when the task is initialized; we use this | |
169 | to terminate the frame chain. Chain means here the nominal address of | |
170 | a frame, that is, the return address (lr0) address in the stack. To | |
171 | obtain the frame pointer (lr1) contents, we must add 4 bytes. | |
172 | Note : may be we should modify init_frame_info() to get the frame pointer | |
c5aa993b | 173 | and store it into the frame_info struct rather than reading its |
c338868a | 174 | contents when FRAME_CHAIN_VALID is invoked. THISFRAME is unused. */ |
c906108c SS |
175 | |
176 | int | |
c338868a | 177 | vx29k_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe) |
c906108c | 178 | { |
c5aa993b | 179 | int fp_contents; |
c906108c | 180 | |
c5aa993b JM |
181 | read_memory ((CORE_ADDR) (chain + 4), (char *) &fp_contents, 4); |
182 | return (fp_contents != 0); | |
c906108c | 183 | } |