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