* ppc-bdm.c (#include <signal.h>): Removed.
[binutils-gdb.git] / gdb / remote-vx960.c
1 /* i80960-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 "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 <fcntl.h>
38 #include <sys/types.h>
39 #include <sys/time.h>
40 #include <sys/socket.h>
41
42 #ifdef _AIX /* IBM claims "void *malloc()" not char * */
43 #define malloc bogon_malloc
44 #endif
45
46 #include <rpc/rpc.h>
47 #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
48 #include <netdb.h>
49 #include "vx-share/ptrace.h"
50 #include "vx-share/xdr_ptrace.h"
51 #include "vx-share/xdr_ld.h"
52 #include "vx-share/xdr_rdb.h"
53 #include "vx-share/dbgRpcLib.h"
54
55 /* get rid of value.h if possible */
56 #include <value.h>
57 #include <symtab.h>
58
59 /* Flag set if target has fpu */
60
61 extern int target_has_fp;
62
63 /* 960 floating point format descriptor, from "i960-tdep.c." */
64
65 extern struct ext_format ext_format_i960;
66
67 /* Generic register read/write routines in remote-vx.c. */
68
69 extern void net_read_registers ();
70 extern void net_write_registers ();
71
72 /* Read a register or registers from the VxWorks target.
73 REGNO is the register to read, or -1 for all; currently,
74 it is ignored. FIXME look at regno to improve efficiency. */
75
76 void
77 vx_read_register (int regno)
78 {
79 char i960_greg_packet[I960_GREG_PLEN];
80 char i960_fpreg_packet[I960_FPREG_PLEN];
81
82 /* Get general-purpose registers. When copying values into
83 registers [], don't assume that a location in registers []
84 is properly aligned for the target data type. */
85
86 net_read_registers (i960_greg_packet, I960_GREG_PLEN, PTRACE_GETREGS);
87
88 bcopy (&i960_greg_packet[I960_R_R0],
89 &registers[REGISTER_BYTE (R0_REGNUM)], 16 * I960_GREG_SIZE);
90 bcopy (&i960_greg_packet[I960_R_G0],
91 &registers[REGISTER_BYTE (G0_REGNUM)], 16 * I960_GREG_SIZE);
92 bcopy (&i960_greg_packet[I960_R_PCW],
93 &registers[REGISTER_BYTE (PCW_REGNUM)], sizeof (int));
94 bcopy (&i960_greg_packet[I960_R_ACW],
95 &registers[REGISTER_BYTE (ACW_REGNUM)], sizeof (int));
96 bcopy (&i960_greg_packet[I960_R_TCW],
97 &registers[REGISTER_BYTE (TCW_REGNUM)], sizeof (int));
98
99 /* If the target has floating point registers, fetch them.
100 Otherwise, zero the floating point register values in
101 registers[] for good measure, even though we might not
102 need to. */
103
104 if (target_has_fp)
105 {
106 net_read_registers (i960_fpreg_packet, I960_FPREG_PLEN,
107 PTRACE_GETFPREGS);
108 bcopy (&i960_fpreg_packet[I960_R_FP0],
109 &registers[REGISTER_BYTE (FP0_REGNUM)],
110 REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
111 }
112 else
113 bzero (&registers[REGISTER_BYTE (FP0_REGNUM)],
114 REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
115
116 /* Mark the register cache valid. */
117
118 registers_fetched ();
119 }
120
121 /* Store a register or registers into the VxWorks target.
122 REGNO is the register to store, or -1 for all; currently,
123 it is ignored. FIXME look at regno to improve efficiency. */
124
125 void
126 vx_write_register (int regno)
127 {
128 char i960_greg_packet[I960_GREG_PLEN];
129 char i960_fpreg_packet[I960_FPREG_PLEN];
130
131 /* Store floating-point registers. When copying values from
132 registers [], don't assume that a location in registers []
133 is properly aligned for the target data type. */
134
135 bcopy (&registers[REGISTER_BYTE (R0_REGNUM)],
136 &i960_greg_packet[I960_R_R0], 16 * I960_GREG_SIZE);
137 bcopy (&registers[REGISTER_BYTE (G0_REGNUM)],
138 &i960_greg_packet[I960_R_G0], 16 * I960_GREG_SIZE);
139 bcopy (&registers[REGISTER_BYTE (PCW_REGNUM)],
140 &i960_greg_packet[I960_R_PCW], sizeof (int));
141 bcopy (&registers[REGISTER_BYTE (ACW_REGNUM)],
142 &i960_greg_packet[I960_R_ACW], sizeof (int));
143 bcopy (&registers[REGISTER_BYTE (TCW_REGNUM)],
144 &i960_greg_packet[I960_R_TCW], sizeof (int));
145
146 net_write_registers (i960_greg_packet, I960_GREG_PLEN, PTRACE_SETREGS);
147
148 /* Store floating point registers if the target has them. */
149
150 if (target_has_fp)
151 {
152 bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
153 &i960_fpreg_packet[I960_R_FP0],
154 REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
155
156 net_write_registers (i960_fpreg_packet, I960_FPREG_PLEN,
157 PTRACE_SETFPREGS);
158 }
159 }