Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* 68k-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" | |
33 | #include "symfile.h" /* for struct complaint */ | |
34 | ||
35 | #include "gdb_string.h" | |
36 | #include <errno.h> | |
c906108c SS |
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 | ||
48 | #ifdef _AIX | |
49 | #undef malloc | |
50 | #endif | |
51 | ||
52 | #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */ | |
53 | #include <netdb.h> | |
54 | #include "vx-share/ptrace.h" | |
55 | #include "vx-share/xdr_ptrace.h" | |
56 | #include "vx-share/xdr_ld.h" | |
57 | #include "vx-share/xdr_rdb.h" | |
58 | #include "vx-share/dbgRpcLib.h" | |
59 | ||
60 | /* get rid of value.h if possible */ | |
61 | #include <value.h> | |
62 | #include <symtab.h> | |
63 | ||
64 | /* Flag set if target has fpu */ | |
65 | ||
66 | extern int target_has_fp; | |
67 | ||
68 | /* Generic register read/write routines in remote-vx.c. */ | |
69 | ||
70 | extern void net_read_registers (); | |
71 | extern 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 | ||
77 | void | |
fba45db2 | 78 | vx_read_register (int regno) |
c906108c SS |
79 | { |
80 | char mc68k_greg_packet[MC68K_GREG_PLEN]; | |
81 | char mc68k_fpreg_packet[MC68K_FPREG_PLEN]; | |
82 | ||
83 | /* Get general-purpose registers. */ | |
84 | ||
85 | net_read_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_GETREGS); | |
86 | ||
87 | bcopy (&mc68k_greg_packet[MC68K_R_D0], registers, 16 * MC68K_GREG_SIZE); | |
88 | bcopy (&mc68k_greg_packet[MC68K_R_SR], ®isters[REGISTER_BYTE (PS_REGNUM)], | |
89 | MC68K_GREG_SIZE); | |
90 | bcopy (&mc68k_greg_packet[MC68K_R_PC], ®isters[REGISTER_BYTE (PC_REGNUM)], | |
91 | MC68K_GREG_SIZE); | |
92 | ||
93 | /* Get floating-point registers, if the target system has them. | |
94 | Otherwise, zero them. */ | |
95 | ||
96 | if (target_has_fp) | |
97 | { | |
98 | net_read_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN, | |
99 | PTRACE_GETFPREGS); | |
100 | ||
101 | bcopy (&mc68k_fpreg_packet[MC68K_R_FP0], | |
102 | ®isters[REGISTER_BYTE (FP0_REGNUM)], | |
103 | MC68K_FPREG_SIZE * 8); | |
104 | bcopy (&mc68k_fpreg_packet[MC68K_R_FPCR], | |
105 | ®isters[REGISTER_BYTE (FPC_REGNUM)], | |
106 | MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); | |
107 | } | |
108 | else | |
109 | { | |
110 | bzero (®isters[REGISTER_BYTE (FP0_REGNUM)], | |
111 | MC68K_FPREG_SIZE * 8); | |
112 | bzero (®isters[REGISTER_BYTE (FPC_REGNUM)], | |
113 | MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); | |
114 | } | |
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 | |
fba45db2 | 126 | vx_write_register (int regno) |
c906108c SS |
127 | { |
128 | char mc68k_greg_packet[MC68K_GREG_PLEN]; | |
129 | char mc68k_fpreg_packet[MC68K_FPREG_PLEN]; | |
130 | ||
131 | /* Store general-purpose registers. */ | |
132 | ||
133 | bcopy (registers, &mc68k_greg_packet[MC68K_R_D0], 16 * MC68K_GREG_SIZE); | |
134 | bcopy (®isters[REGISTER_BYTE (PS_REGNUM)], | |
135 | &mc68k_greg_packet[MC68K_R_SR], MC68K_GREG_SIZE); | |
136 | bcopy (®isters[REGISTER_BYTE (PC_REGNUM)], | |
137 | &mc68k_greg_packet[MC68K_R_PC], MC68K_GREG_SIZE); | |
138 | ||
139 | net_write_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_SETREGS); | |
140 | ||
141 | /* Store floating point registers if the target has them. */ | |
142 | ||
143 | if (target_has_fp) | |
144 | { | |
145 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], | |
146 | &mc68k_fpreg_packet[MC68K_R_FP0], | |
147 | MC68K_FPREG_SIZE * 8); | |
148 | bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], | |
149 | &mc68k_fpreg_packet[MC68K_R_FPCR], | |
150 | MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); | |
151 | ||
152 | net_write_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN, | |
153 | PTRACE_SETFPREGS); | |
154 | } | |
155 | } |