Fix bug in sh_elf_reloc_loop
[deliverable/binutils-gdb.git] / gdb / remote-vx68.c
CommitLineData
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"
03f2053f 29#include "gdb_wait.h"
c906108c
SS
30#include "target.h"
31#include "gdbcore.h"
32#include "command.h"
33#include "symtab.h"
34#include "symfile.h" /* for struct complaint */
35
36#include "gdb_string.h"
37#include <errno.h>
38#include <signal.h>
39#include <fcntl.h>
40#include <sys/types.h>
41#include <sys/time.h>
42#include <sys/socket.h>
43
44#ifdef _AIX /* IBM claims "void *malloc()" not char * */
45#define malloc bogon_malloc
46#endif
47
48#include <rpc/rpc.h>
49
50#ifdef _AIX
51#undef malloc
52#endif
53
54#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
55#include <netdb.h>
56#include "vx-share/ptrace.h"
57#include "vx-share/xdr_ptrace.h"
58#include "vx-share/xdr_ld.h"
59#include "vx-share/xdr_rdb.h"
60#include "vx-share/dbgRpcLib.h"
61
62/* get rid of value.h if possible */
63#include <value.h>
64#include <symtab.h>
65
66/* Flag set if target has fpu */
67
68extern int target_has_fp;
69
70/* Generic register read/write routines in remote-vx.c. */
71
72extern void net_read_registers ();
73extern void net_write_registers ();
74
75/* Read a register or registers from the VxWorks target.
76 REGNO is the register to read, or -1 for all; currently,
77 it is ignored. FIXME look at regno to improve efficiency. */
78
79void
fba45db2 80vx_read_register (int regno)
c906108c
SS
81{
82 char mc68k_greg_packet[MC68K_GREG_PLEN];
83 char mc68k_fpreg_packet[MC68K_FPREG_PLEN];
84
85 /* Get general-purpose registers. */
86
87 net_read_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_GETREGS);
88
89 bcopy (&mc68k_greg_packet[MC68K_R_D0], registers, 16 * MC68K_GREG_SIZE);
90 bcopy (&mc68k_greg_packet[MC68K_R_SR], &registers[REGISTER_BYTE (PS_REGNUM)],
91 MC68K_GREG_SIZE);
92 bcopy (&mc68k_greg_packet[MC68K_R_PC], &registers[REGISTER_BYTE (PC_REGNUM)],
93 MC68K_GREG_SIZE);
94
95 /* Get floating-point registers, if the target system has them.
96 Otherwise, zero them. */
97
98 if (target_has_fp)
99 {
100 net_read_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN,
101 PTRACE_GETFPREGS);
102
103 bcopy (&mc68k_fpreg_packet[MC68K_R_FP0],
104 &registers[REGISTER_BYTE (FP0_REGNUM)],
105 MC68K_FPREG_SIZE * 8);
106 bcopy (&mc68k_fpreg_packet[MC68K_R_FPCR],
107 &registers[REGISTER_BYTE (FPC_REGNUM)],
108 MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8));
109 }
110 else
111 {
112 bzero (&registers[REGISTER_BYTE (FP0_REGNUM)],
113 MC68K_FPREG_SIZE * 8);
114 bzero (&registers[REGISTER_BYTE (FPC_REGNUM)],
115 MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8));
116 }
117
118 /* Mark the register cache valid. */
119
120 registers_fetched ();
121}
122
123/* Store a register or registers into the VxWorks target.
124 REGNO is the register to store, or -1 for all; currently,
125 it is ignored. FIXME look at regno to improve efficiency. */
126
127void
fba45db2 128vx_write_register (int regno)
c906108c
SS
129{
130 char mc68k_greg_packet[MC68K_GREG_PLEN];
131 char mc68k_fpreg_packet[MC68K_FPREG_PLEN];
132
133 /* Store general-purpose registers. */
134
135 bcopy (registers, &mc68k_greg_packet[MC68K_R_D0], 16 * MC68K_GREG_SIZE);
136 bcopy (&registers[REGISTER_BYTE (PS_REGNUM)],
137 &mc68k_greg_packet[MC68K_R_SR], MC68K_GREG_SIZE);
138 bcopy (&registers[REGISTER_BYTE (PC_REGNUM)],
139 &mc68k_greg_packet[MC68K_R_PC], MC68K_GREG_SIZE);
140
141 net_write_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_SETREGS);
142
143 /* Store floating point registers if the target has them. */
144
145 if (target_has_fp)
146 {
147 bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
148 &mc68k_fpreg_packet[MC68K_R_FP0],
149 MC68K_FPREG_SIZE * 8);
150 bcopy (&registers[REGISTER_BYTE (FPC_REGNUM)],
151 &mc68k_fpreg_packet[MC68K_R_FPCR],
152 MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8));
153
154 net_write_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN,
155 PTRACE_SETFPREGS);
156 }
157}
This page took 0.073195 seconds and 4 git commands to generate.