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" | |
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 | ||
43 | #ifdef _AIX /* IBM claims "void *malloc()" not char * */ | |
44 | #define malloc bogon_malloc | |
45 | #endif | |
46 | ||
47 | #include <rpc/rpc.h> | |
48 | ||
49 | #ifdef _AIX | |
50 | #undef malloc | |
51 | #endif | |
52 | ||
53 | #include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */ | |
54 | #include <netdb.h> | |
55 | #include "vx-share/ptrace.h" | |
56 | #include "vx-share/xdr_ptrace.h" | |
57 | #include "vx-share/xdr_ld.h" | |
58 | #include "vx-share/xdr_rdb.h" | |
59 | #include "vx-share/dbgRpcLib.h" | |
60 | ||
61 | /* get rid of value.h if possible */ | |
62 | #include <value.h> | |
63 | #include <symtab.h> | |
64 | ||
65 | /* Flag set if target has fpu */ | |
66 | ||
67 | extern int target_has_fp; | |
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 | |
fba45db2 | 79 | vx_read_register (int regno) |
c906108c SS |
80 | { |
81 | char mc68k_greg_packet[MC68K_GREG_PLEN]; | |
82 | char mc68k_fpreg_packet[MC68K_FPREG_PLEN]; | |
83 | ||
84 | /* Get general-purpose registers. */ | |
85 | ||
86 | net_read_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_GETREGS); | |
87 | ||
524d7c18 AC |
88 | bcopy (&mc68k_greg_packet[MC68K_R_D0], deprecated_registers, |
89 | 16 * MC68K_GREG_SIZE); | |
90 | bcopy (&mc68k_greg_packet[MC68K_R_SR], | |
62700349 | 91 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)], |
c906108c | 92 | MC68K_GREG_SIZE); |
524d7c18 | 93 | bcopy (&mc68k_greg_packet[MC68K_R_PC], |
62700349 | 94 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (PC_REGNUM)], |
c906108c SS |
95 | MC68K_GREG_SIZE); |
96 | ||
97 | /* Get floating-point registers, if the target system has them. | |
98 | Otherwise, zero them. */ | |
99 | ||
100 | if (target_has_fp) | |
101 | { | |
102 | net_read_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN, | |
103 | PTRACE_GETFPREGS); | |
104 | ||
105 | bcopy (&mc68k_fpreg_packet[MC68K_R_FP0], | |
62700349 | 106 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], |
c906108c SS |
107 | MC68K_FPREG_SIZE * 8); |
108 | bcopy (&mc68k_fpreg_packet[MC68K_R_FPCR], | |
62700349 | 109 | &deprecated_registers[DEPRECATED_REGISTER_BYTE (FPC_REGNUM)], |
c906108c SS |
110 | MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); |
111 | } | |
112 | else | |
113 | { | |
4deab737 AC |
114 | memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], |
115 | 0, MC68K_FPREG_SIZE * 8); | |
116 | memset (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FPC_REGNUM)], | |
117 | 0, MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); | |
c906108c SS |
118 | } |
119 | ||
120 | /* Mark the register cache valid. */ | |
121 | ||
2b9e5f3f | 122 | deprecated_registers_fetched (); |
c906108c SS |
123 | } |
124 | ||
125 | /* Store a register or registers into the VxWorks target. | |
126 | REGNO is the register to store, or -1 for all; currently, | |
127 | it is ignored. FIXME look at regno to improve efficiency. */ | |
128 | ||
129 | void | |
fba45db2 | 130 | vx_write_register (int regno) |
c906108c SS |
131 | { |
132 | char mc68k_greg_packet[MC68K_GREG_PLEN]; | |
133 | char mc68k_fpreg_packet[MC68K_FPREG_PLEN]; | |
134 | ||
135 | /* Store general-purpose registers. */ | |
136 | ||
524d7c18 AC |
137 | bcopy (deprecated_registers, &mc68k_greg_packet[MC68K_R_D0], |
138 | 16 * MC68K_GREG_SIZE); | |
62700349 | 139 | bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)], |
c906108c | 140 | &mc68k_greg_packet[MC68K_R_SR], MC68K_GREG_SIZE); |
62700349 | 141 | bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (PC_REGNUM)], |
c906108c SS |
142 | &mc68k_greg_packet[MC68K_R_PC], MC68K_GREG_SIZE); |
143 | ||
144 | net_write_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_SETREGS); | |
145 | ||
146 | /* Store floating point registers if the target has them. */ | |
147 | ||
148 | if (target_has_fp) | |
149 | { | |
62700349 | 150 | bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FP0_REGNUM)], |
c906108c SS |
151 | &mc68k_fpreg_packet[MC68K_R_FP0], |
152 | MC68K_FPREG_SIZE * 8); | |
62700349 | 153 | bcopy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (FPC_REGNUM)], |
c906108c SS |
154 | &mc68k_fpreg_packet[MC68K_R_FPCR], |
155 | MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8)); | |
156 | ||
157 | net_write_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN, | |
158 | PTRACE_SETFPREGS); | |
159 | } | |
160 | } |