Fix the year on the following lines:
[deliverable/binutils-gdb.git] / gdb / remote-vx29k.c
CommitLineData
c906108c 1/* Am29k-dependent portions of the RPC protocol
c906108c 2
c5aa993b 3 Contributed by Wind River Systems.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
c906108c 11
c5aa993b
JM
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
c906108c 16
c5aa993b
JM
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
c906108c
SS
21
22#include <stdio.h>
23#include "defs.h"
24
c5aa993b 25#include "vx-share/regPacket.h"
c906108c
SS
26#include "frame.h"
27#include "inferior.h"
c906108c
SS
28#include "target.h"
29#include "gdbcore.h"
30#include "command.h"
31#include "symtab.h"
32#include "symfile.h" /* for struct complaint */
33
34#include "gdb_string.h"
35#include <errno.h>
c906108c
SS
36#include <fcntl.h>
37#include <sys/types.h>
38#include <sys/time.h>
39#include <sys/socket.h>
40
c5aa993b 41#ifdef _AIX /* IBM claims "void *malloc()" not char * */
c906108c
SS
42#define malloc bogon_malloc
43#endif
44
45#include <rpc/rpc.h>
46#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
47#include <netdb.h>
48#include "vx-share/ptrace.h"
49#include "vx-share/xdr_ptrace.h"
50#include "vx-share/xdr_ld.h"
51#include "vx-share/xdr_rdb.h"
52#include "vx-share/dbgRpcLib.h"
53
54/* get rid of value.h if possible */
55#include <value.h>
56#include <symtab.h>
57
58/* Flag set if target has fpu */
59
60extern int target_has_fp;
61
62/* Generic register read/write routines in remote-vx.c. */
63
64extern void net_read_registers ();
65extern void net_write_registers ();
66
67/* Read a register or registers from the VxWorks target.
68 REGNO is the register to read, or -1 for all; currently,
69 it is ignored. FIXME look at regno to improve efficiency. */
70
71void
fba45db2 72vx_read_register (int regno)
c906108c
SS
73{
74 char am29k_greg_packet[AM29K_GREG_PLEN];
75 char am29k_fpreg_packet[AM29K_FPREG_PLEN];
76
77 /* Get general-purpose registers. When copying values into
78 registers [], don't assume that a location in registers []
79 is properly aligned for the target data type. */
80
81 net_read_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_GETREGS);
82
83 /* Now copy the register values into registers[].
84 Note that this code depends on the ordering of the REGNUMs
85 as defined in "tm-29k.h". */
86
87 bcopy (&am29k_greg_packet[AM29K_R_GR96],
88 &registers[REGISTER_BYTE (GR96_REGNUM)], 160 * AM29K_GREG_SIZE);
89 bcopy (&am29k_greg_packet[AM29K_R_VAB],
90 &registers[REGISTER_BYTE (VAB_REGNUM)], 15 * AM29K_GREG_SIZE);
91 registers[REGISTER_BYTE (INTE_REGNUM)] = am29k_greg_packet[AM29K_R_INTE];
92 bcopy (&am29k_greg_packet[AM29K_R_RSP],
93 &registers[REGISTER_BYTE (GR1_REGNUM)], 5 * AM29K_GREG_SIZE);
94
95 /* PAD For now, don't care about exop register */
96
97 memset (&registers[REGISTER_BYTE (EXO_REGNUM)], '\0', AM29K_GREG_SIZE);
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 (am29k_fpreg_packet, AM29K_FPREG_PLEN,
c5aa993b 107 PTRACE_GETFPREGS);
c906108c
SS
108 registers[REGISTER_BYTE (FPE_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPE];
109 registers[REGISTER_BYTE (FPS_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPS];
110
111 /* PAD For now, don't care about registers (?) AI0 to q */
112
113 memset (&registers[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE);
114 }
115 else
c5aa993b 116 {
c906108c
SS
117 memset (&registers[REGISTER_BYTE (FPE_REGNUM)], '\0', AM29K_FPREG_SIZE);
118 memset (&registers[REGISTER_BYTE (FPS_REGNUM)], '\0', AM29K_FPREG_SIZE);
119
120 /* PAD For now, don't care about registers (?) AI0 to q */
121
122 memset (&registers[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE);
123 }
124
125 /* Mark the register cache valid. */
126
127 registers_fetched ();
128}
129
130/* Store a register or registers into the VxWorks target.
131 REGNO is the register to store, or -1 for all; currently,
132 it is ignored. FIXME look at regno to improve efficiency. */
133
134void
fba45db2 135vx_write_register (int regno)
c906108c
SS
136{
137 char am29k_greg_packet[AM29K_GREG_PLEN];
138 char am29k_fpreg_packet[AM29K_FPREG_PLEN];
139
140 /* Store general purpose registers. When copying values from
141 registers [], don't assume that a location in registers []
142 is properly aligned for the target data type. */
143
144 bcopy (&registers[REGISTER_BYTE (GR96_REGNUM)],
145 &am29k_greg_packet[AM29K_R_GR96], 160 * AM29K_GREG_SIZE);
146 bcopy (&registers[REGISTER_BYTE (VAB_REGNUM)],
147 &am29k_greg_packet[AM29K_R_VAB], 15 * AM29K_GREG_SIZE);
148 am29k_greg_packet[AM29K_R_INTE] = registers[REGISTER_BYTE (INTE_REGNUM)];
149 bcopy (&registers[REGISTER_BYTE (GR1_REGNUM)],
150 &am29k_greg_packet[AM29K_R_RSP], 5 * AM29K_GREG_SIZE);
151
152 net_write_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_SETREGS);
153
154 /* Store floating point registers if the target has them. */
155
156 if (target_has_fp)
157 {
158 am29k_fpreg_packet[AM29K_R_FPE] = registers[REGISTER_BYTE (FPE_REGNUM)];
159 am29k_fpreg_packet[AM29K_R_FPS] = registers[REGISTER_BYTE (FPS_REGNUM)];
160
161 net_write_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
c5aa993b 162 PTRACE_SETFPREGS);
c906108c
SS
163 }
164}
165
166/* VxWorks zeroes fp when the task is initialized; we use this
167 to terminate the frame chain. Chain means here the nominal address of
168 a frame, that is, the return address (lr0) address in the stack. To
169 obtain the frame pointer (lr1) contents, we must add 4 bytes.
170 Note : may be we should modify init_frame_info() to get the frame pointer
c5aa993b 171 and store it into the frame_info struct rather than reading its
c338868a 172 contents when FRAME_CHAIN_VALID is invoked. THISFRAME is unused. */
c906108c
SS
173
174int
c338868a 175vx29k_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe)
c906108c 176{
c5aa993b 177 int fp_contents;
c906108c 178
c5aa993b
JM
179 read_memory ((CORE_ADDR) (chain + 4), (char *) &fp_contents, 4);
180 return (fp_contents != 0);
c906108c 181}
This page took 0.094885 seconds and 4 git commands to generate.