1 |
104 |
markom |
/* 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 "gdb_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 |
|
|
/* 960 floating point format descriptor, from "i960-tdep.c." */
|
66 |
|
|
|
67 |
|
|
extern struct ext_format ext_format_i960;
|
68 |
|
|
|
69 |
|
|
/* Generic register read/write routines in remote-vx.c. */
|
70 |
|
|
|
71 |
|
|
extern void net_read_registers ();
|
72 |
|
|
extern void net_write_registers ();
|
73 |
|
|
|
74 |
|
|
/* Read a register or registers from the VxWorks target.
|
75 |
|
|
REGNO is the register to read, or -1 for all; currently,
|
76 |
|
|
it is ignored. FIXME look at regno to improve efficiency. */
|
77 |
|
|
|
78 |
|
|
void
|
79 |
|
|
vx_read_register (regno)
|
80 |
|
|
int regno;
|
81 |
|
|
{
|
82 |
|
|
char i960_greg_packet[I960_GREG_PLEN];
|
83 |
|
|
char i960_fpreg_packet[I960_FPREG_PLEN];
|
84 |
|
|
|
85 |
|
|
/* Get general-purpose registers. When copying values into
|
86 |
|
|
registers [], don't assume that a location in registers []
|
87 |
|
|
is properly aligned for the target data type. */
|
88 |
|
|
|
89 |
|
|
net_read_registers (i960_greg_packet, I960_GREG_PLEN, PTRACE_GETREGS);
|
90 |
|
|
|
91 |
|
|
bcopy (&i960_greg_packet[I960_R_R0],
|
92 |
|
|
®isters[REGISTER_BYTE (R0_REGNUM)], 16 * I960_GREG_SIZE);
|
93 |
|
|
bcopy (&i960_greg_packet[I960_R_G0],
|
94 |
|
|
®isters[REGISTER_BYTE (G0_REGNUM)], 16 * I960_GREG_SIZE);
|
95 |
|
|
bcopy (&i960_greg_packet[I960_R_PCW],
|
96 |
|
|
®isters[REGISTER_BYTE (PCW_REGNUM)], sizeof (int));
|
97 |
|
|
bcopy (&i960_greg_packet[I960_R_ACW],
|
98 |
|
|
®isters[REGISTER_BYTE (ACW_REGNUM)], sizeof (int));
|
99 |
|
|
bcopy (&i960_greg_packet[I960_R_TCW],
|
100 |
|
|
®isters[REGISTER_BYTE (TCW_REGNUM)], sizeof (int));
|
101 |
|
|
|
102 |
|
|
/* If the target has floating point registers, fetch them.
|
103 |
|
|
Otherwise, zero the floating point register values in
|
104 |
|
|
registers[] for good measure, even though we might not
|
105 |
|
|
need to. */
|
106 |
|
|
|
107 |
|
|
if (target_has_fp)
|
108 |
|
|
{
|
109 |
|
|
net_read_registers (i960_fpreg_packet, I960_FPREG_PLEN,
|
110 |
|
|
PTRACE_GETFPREGS);
|
111 |
|
|
bcopy (&i960_fpreg_packet[I960_R_FP0],
|
112 |
|
|
®isters[REGISTER_BYTE (FP0_REGNUM)],
|
113 |
|
|
REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
|
114 |
|
|
}
|
115 |
|
|
else
|
116 |
|
|
bzero (®isters[REGISTER_BYTE (FP0_REGNUM)],
|
117 |
|
|
REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
|
118 |
|
|
|
119 |
|
|
/* Mark the register cache valid. */
|
120 |
|
|
|
121 |
|
|
registers_fetched ();
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
/* Store a register or registers into the VxWorks target.
|
125 |
|
|
REGNO is the register to store, or -1 for all; currently,
|
126 |
|
|
it is ignored. FIXME look at regno to improve efficiency. */
|
127 |
|
|
|
128 |
|
|
void
|
129 |
|
|
vx_write_register (regno)
|
130 |
|
|
int regno;
|
131 |
|
|
{
|
132 |
|
|
char i960_greg_packet[I960_GREG_PLEN];
|
133 |
|
|
char i960_fpreg_packet[I960_FPREG_PLEN];
|
134 |
|
|
|
135 |
|
|
/* Store floating-point registers. When copying values from
|
136 |
|
|
registers [], don't assume that a location in registers []
|
137 |
|
|
is properly aligned for the target data type. */
|
138 |
|
|
|
139 |
|
|
bcopy (®isters[REGISTER_BYTE (R0_REGNUM)],
|
140 |
|
|
&i960_greg_packet[I960_R_R0], 16 * I960_GREG_SIZE);
|
141 |
|
|
bcopy (®isters[REGISTER_BYTE (G0_REGNUM)],
|
142 |
|
|
&i960_greg_packet[I960_R_G0], 16 * I960_GREG_SIZE);
|
143 |
|
|
bcopy (®isters[REGISTER_BYTE (PCW_REGNUM)],
|
144 |
|
|
&i960_greg_packet[I960_R_PCW], sizeof (int));
|
145 |
|
|
bcopy (®isters[REGISTER_BYTE (ACW_REGNUM)],
|
146 |
|
|
&i960_greg_packet[I960_R_ACW], sizeof (int));
|
147 |
|
|
bcopy (®isters[REGISTER_BYTE (TCW_REGNUM)],
|
148 |
|
|
&i960_greg_packet[I960_R_TCW], sizeof (int));
|
149 |
|
|
|
150 |
|
|
net_write_registers (i960_greg_packet, I960_GREG_PLEN, PTRACE_SETREGS);
|
151 |
|
|
|
152 |
|
|
/* Store floating point registers if the target has them. */
|
153 |
|
|
|
154 |
|
|
if (target_has_fp)
|
155 |
|
|
{
|
156 |
|
|
bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)],
|
157 |
|
|
&i960_fpreg_packet[I960_R_FP0],
|
158 |
|
|
REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
|
159 |
|
|
|
160 |
|
|
net_write_registers (i960_fpreg_packet, I960_FPREG_PLEN,
|
161 |
|
|
PTRACE_SETFPREGS);
|
162 |
|
|
}
|
163 |
|
|
}
|