1 /* sparc-dependent portions of the RPC protocol
2 used with a VxWorks target
4 Contributed by Wind River Systems.
6 This file is part of GDB.
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.
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.
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. */
26 #include "vx-share/regPacket.h"
36 #include "gdb_string.h"
39 #include <sys/types.h>
41 #include <sys/socket.h>
43 #ifdef _AIX /* IBM claims "void *malloc()" not char * */
44 #define malloc bogon_malloc
48 #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
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"
56 /* get rid of value.h if possible */
60 /* Flag set if target has fpu */
62 extern int target_has_fp
;
64 /* sparc floating point format descriptor, from "sparc-tdep.c." */
66 extern struct ext_format ext_format_sparc
;
68 /* Generic register read/write routines in remote-vx.c. */
70 extern void net_read_registers ();
71 extern void net_write_registers ();
73 /* Read a register or registers from the VxWorks target.
74 REGNO is the register to read, or -1 for all; currently,
75 it is ignored. FIXME look at regno to improve efficiency. */
78 vx_read_register (int regno
)
80 char sparc_greg_packet
[SPARC_GREG_PLEN
];
81 char sparc_fpreg_packet
[SPARC_FPREG_PLEN
];
84 /* Get general-purpose registers. When copying values into
85 registers [], don't assume that a location in registers []
86 is properly aligned for the target data type. */
88 net_read_registers (sparc_greg_packet
, SPARC_GREG_PLEN
, PTRACE_GETREGS
);
90 /* Now copy the register values into registers[].
91 Note that this code depends on the ordering of the REGNUMs
92 as defined in "tm-sparc.h". */
94 bcopy (&sparc_greg_packet
[SPARC_R_G0
],
95 &deprecated_registers
[REGISTER_BYTE (G0_REGNUM
)],
96 32 * SPARC_GREG_SIZE
);
97 bcopy (&sparc_greg_packet
[SPARC_R_Y
],
98 &deprecated_registers
[REGISTER_BYTE (Y_REGNUM
)], 6 * SPARC_GREG_SIZE
);
100 /* Now write the local and in registers to the register window
101 spill area in the frame. VxWorks does not do this for the
102 active frame automatically; it greatly simplifies debugging
103 (FRAME_FIND_SAVED_REGS, in particular, depends on this). */
105 sp
= extract_address (&deprecated_registers
[REGISTER_BYTE (SP_REGNUM
)],
106 REGISTER_RAW_SIZE (SP_REGNUM
));
107 write_memory (sp
, &deprecated_registers
[REGISTER_BYTE (L0_REGNUM
)],
108 16 * REGISTER_RAW_SIZE (L0_REGNUM
));
110 /* If the target has floating point registers, fetch them.
111 Otherwise, zero the floating point register values in
112 registers[] for good measure, even though we might not
117 net_read_registers (sparc_fpreg_packet
, SPARC_FPREG_PLEN
,
119 bcopy (&sparc_fpreg_packet
[SPARC_R_FP0
],
120 &deprecated_registers
[REGISTER_BYTE (FP0_REGNUM
)],
121 32 * SPARC_FPREG_SIZE
);
122 bcopy (&sparc_fpreg_packet
[SPARC_R_FSR
],
123 &deprecated_registers
[REGISTER_BYTE (FPS_REGNUM
)],
124 1 * SPARC_FPREG_SIZE
);
128 bzero (&deprecated_registers
[REGISTER_BYTE (FP0_REGNUM
)],
129 32 * SPARC_FPREG_SIZE
);
130 bzero (&deprecated_registers
[REGISTER_BYTE (FPS_REGNUM
)],
131 1 * SPARC_FPREG_SIZE
);
134 /* Mark the register cache valid. */
136 deprecated_registers_fetched ();
139 /* Store a register or registers into the VxWorks target.
140 REGNO is the register to store, or -1 for all; currently,
141 it is ignored. FIXME look at regno to improve efficiency. */
144 vx_write_register (int regno
)
146 char sparc_greg_packet
[SPARC_GREG_PLEN
];
147 char sparc_fpreg_packet
[SPARC_FPREG_PLEN
];
152 /* Store general purpose registers. When copying values from
153 registers [], don't assume that a location in registers []
154 is properly aligned for the target data type. */
160 if ((G0_REGNUM
<= regno
&& regno
<= I7_REGNUM
)
161 || (Y_REGNUM
<= regno
&& regno
<= NPC_REGNUM
))
168 bcopy (&deprecated_registers
[REGISTER_BYTE (G0_REGNUM
)],
169 &sparc_greg_packet
[SPARC_R_G0
], 32 * SPARC_GREG_SIZE
);
170 bcopy (&deprecated_registers
[REGISTER_BYTE (Y_REGNUM
)],
171 &sparc_greg_packet
[SPARC_R_Y
], 6 * SPARC_GREG_SIZE
);
173 net_write_registers (sparc_greg_packet
, SPARC_GREG_PLEN
, PTRACE_SETREGS
);
175 /* If this is a local or in register, or we're storing all
176 registers, update the register window spill area. */
178 if (regno
< 0 || (L0_REGNUM
<= regno
&& regno
<= I7_REGNUM
))
180 sp
= extract_address (&deprecated_registers
[REGISTER_BYTE (SP_REGNUM
)],
181 REGISTER_RAW_SIZE (SP_REGNUM
));
182 write_memory (sp
, &deprecated_registers
[REGISTER_BYTE (L0_REGNUM
)],
183 16 * REGISTER_RAW_SIZE (L0_REGNUM
));
187 /* Store floating point registers if the target has them. */
189 if (in_fp_regs
&& target_has_fp
)
191 bcopy (&deprecated_registers
[REGISTER_BYTE (FP0_REGNUM
)],
192 &sparc_fpreg_packet
[SPARC_R_FP0
], 32 * SPARC_FPREG_SIZE
);
193 bcopy (&deprecated_registers
[REGISTER_BYTE (FPS_REGNUM
)],
194 &sparc_fpreg_packet
[SPARC_R_FSR
], 1 * SPARC_FPREG_SIZE
);
196 net_write_registers (sparc_fpreg_packet
, SPARC_FPREG_PLEN
,