2003-06-08 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / remote-vxsparc.c
CommitLineData
c906108c
SS
1/* sparc-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"
72367fb4 33#include "symfile.h"
4e052eda 34#include "regcache.h"
c906108c
SS
35
36#include "gdb_string.h"
37#include <errno.h>
c906108c
SS
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
62extern int target_has_fp;
63
64/* sparc floating point format descriptor, from "sparc-tdep.c." */
65
66extern struct ext_format ext_format_sparc;
67
68/* Generic register read/write routines in remote-vx.c. */
69
70extern void net_read_registers ();
71extern void net_write_registers ();
72
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. */
76
77void
fba45db2 78vx_read_register (int regno)
c906108c
SS
79{
80 char sparc_greg_packet[SPARC_GREG_PLEN];
81 char sparc_fpreg_packet[SPARC_FPREG_PLEN];
82 CORE_ADDR sp;
83
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. */
87
88 net_read_registers (sparc_greg_packet, SPARC_GREG_PLEN, PTRACE_GETREGS);
89
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". */
93
94 bcopy (&sparc_greg_packet[SPARC_R_G0],
524d7c18
AC
95 &deprecated_registers[REGISTER_BYTE (G0_REGNUM)],
96 32 * SPARC_GREG_SIZE);
c906108c 97 bcopy (&sparc_greg_packet[SPARC_R_Y],
524d7c18 98 &deprecated_registers[REGISTER_BYTE (Y_REGNUM)], 6 * SPARC_GREG_SIZE);
c906108c 99
43bd9a9e
AC
100 /* Now write the local and in registers to the register window spill
101 area in the frame. VxWorks does not do this for the active frame
102 automatically; it greatly simplifies debugging. */
c906108c 103
7c0b4a20
AC
104 sp = extract_unsigned_integer (&deprecated_registers[REGISTER_BYTE (SP_REGNUM)],
105 REGISTER_RAW_SIZE (SP_REGNUM));
524d7c18 106 write_memory (sp, &deprecated_registers[REGISTER_BYTE (L0_REGNUM)],
c906108c
SS
107 16 * REGISTER_RAW_SIZE (L0_REGNUM));
108
109 /* If the target has floating point registers, fetch them.
110 Otherwise, zero the floating point register values in
111 registers[] for good measure, even though we might not
112 need to. */
113
114 if (target_has_fp)
115 {
116 net_read_registers (sparc_fpreg_packet, SPARC_FPREG_PLEN,
c5aa993b
JM
117 PTRACE_GETFPREGS);
118 bcopy (&sparc_fpreg_packet[SPARC_R_FP0],
524d7c18
AC
119 &deprecated_registers[REGISTER_BYTE (FP0_REGNUM)],
120 32 * SPARC_FPREG_SIZE);
c906108c 121 bcopy (&sparc_fpreg_packet[SPARC_R_FSR],
524d7c18
AC
122 &deprecated_registers[REGISTER_BYTE (FPS_REGNUM)],
123 1 * SPARC_FPREG_SIZE);
c906108c
SS
124 }
125 else
c5aa993b 126 {
524d7c18
AC
127 bzero (&deprecated_registers[REGISTER_BYTE (FP0_REGNUM)],
128 32 * SPARC_FPREG_SIZE);
129 bzero (&deprecated_registers[REGISTER_BYTE (FPS_REGNUM)],
130 1 * SPARC_FPREG_SIZE);
c906108c
SS
131 }
132
133 /* Mark the register cache valid. */
134
2b9e5f3f 135 deprecated_registers_fetched ();
c906108c
SS
136}
137
138/* Store a register or registers into the VxWorks target.
139 REGNO is the register to store, or -1 for all; currently,
140 it is ignored. FIXME look at regno to improve efficiency. */
141
142void
fba45db2 143vx_write_register (int regno)
c906108c
SS
144{
145 char sparc_greg_packet[SPARC_GREG_PLEN];
146 char sparc_fpreg_packet[SPARC_FPREG_PLEN];
147 int in_gp_regs;
148 int in_fp_regs;
149 CORE_ADDR sp;
150
151 /* Store general purpose registers. When copying values from
152 registers [], don't assume that a location in registers []
153 is properly aligned for the target data type. */
154
155 in_gp_regs = 1;
156 in_fp_regs = 1;
157 if (regno >= 0)
158 {
159 if ((G0_REGNUM <= regno && regno <= I7_REGNUM)
c5aa993b 160 || (Y_REGNUM <= regno && regno <= NPC_REGNUM))
c906108c
SS
161 in_fp_regs = 0;
162 else
163 in_gp_regs = 0;
164 }
165 if (in_gp_regs)
166 {
524d7c18 167 bcopy (&deprecated_registers[REGISTER_BYTE (G0_REGNUM)],
c906108c 168 &sparc_greg_packet[SPARC_R_G0], 32 * SPARC_GREG_SIZE);
524d7c18 169 bcopy (&deprecated_registers[REGISTER_BYTE (Y_REGNUM)],
c906108c
SS
170 &sparc_greg_packet[SPARC_R_Y], 6 * SPARC_GREG_SIZE);
171
172 net_write_registers (sparc_greg_packet, SPARC_GREG_PLEN, PTRACE_SETREGS);
173
174 /* If this is a local or in register, or we're storing all
175 registers, update the register window spill area. */
176
177 if (regno < 0 || (L0_REGNUM <= regno && regno <= I7_REGNUM))
c5aa993b 178 {
7c0b4a20
AC
179 sp = extract_unsigned_integer (&deprecated_registers[REGISTER_BYTE (SP_REGNUM)],
180 REGISTER_RAW_SIZE (SP_REGNUM));
524d7c18 181 write_memory (sp, &deprecated_registers[REGISTER_BYTE (L0_REGNUM)],
c906108c
SS
182 16 * REGISTER_RAW_SIZE (L0_REGNUM));
183 }
184 }
185
186 /* Store floating point registers if the target has them. */
187
188 if (in_fp_regs && target_has_fp)
189 {
524d7c18 190 bcopy (&deprecated_registers[REGISTER_BYTE (FP0_REGNUM)],
c906108c 191 &sparc_fpreg_packet[SPARC_R_FP0], 32 * SPARC_FPREG_SIZE);
524d7c18 192 bcopy (&deprecated_registers[REGISTER_BYTE (FPS_REGNUM)],
c906108c
SS
193 &sparc_fpreg_packet[SPARC_R_FSR], 1 * SPARC_FPREG_SIZE);
194
195 net_write_registers (sparc_fpreg_packet, SPARC_FPREG_PLEN,
c5aa993b 196 PTRACE_SETFPREGS);
c906108c
SS
197 }
198}
This page took 0.312804 seconds and 4 git commands to generate.