OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [remote-vxsparc.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* sparc-dependent portions of the RPC protocol
2
   used with a VxWorks target
3
 
4
   Contributed by Wind River Systems.
5
 
6
   This file is part of GDB.
7
 
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.
12
 
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.
17
 
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.  */
22
 
23
#include <stdio.h>
24
#include "defs.h"
25
 
26
#include "vx-share/regPacket.h"
27
#include "frame.h"
28
#include "inferior.h"
29
#include "target.h"
30
#include "gdbcore.h"
31
#include "command.h"
32
#include "symtab.h"
33
#include "symfile.h"            /* for struct complaint */
34
#include "regcache.h"
35
 
36
#include "gdb_string.h"
37
#include <errno.h>
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
#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
 
62
extern int target_has_fp;
63
 
64
/* sparc floating point format descriptor, from "sparc-tdep.c."  */
65
 
66
extern struct ext_format ext_format_sparc;
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
78
vx_read_register (int regno)
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],
95
         &registers[REGISTER_BYTE (G0_REGNUM)], 32 * SPARC_GREG_SIZE);
96
  bcopy (&sparc_greg_packet[SPARC_R_Y],
97
         &registers[REGISTER_BYTE (Y_REGNUM)], 6 * SPARC_GREG_SIZE);
98
 
99
  /* Now write the local and in registers to the register window
100
     spill area in the frame.  VxWorks does not do this for the
101
     active frame automatically; it greatly simplifies debugging
102
     (FRAME_FIND_SAVED_REGS, in particular, depends on this).  */
103
 
104
  sp = extract_address (&registers[REGISTER_BYTE (SP_REGNUM)],
105
                        REGISTER_RAW_SIZE (CORE_ADDR));
106
  write_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
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,
117
                          PTRACE_GETFPREGS);
118
      bcopy (&sparc_fpreg_packet[SPARC_R_FP0],
119
             &registers[REGISTER_BYTE (FP0_REGNUM)], 32 * SPARC_FPREG_SIZE);
120
      bcopy (&sparc_fpreg_packet[SPARC_R_FSR],
121
             &registers[REGISTER_BYTE (FPS_REGNUM)], 1 * SPARC_FPREG_SIZE);
122
    }
123
  else
124
    {
125
      bzero (&registers[REGISTER_BYTE (FP0_REGNUM)], 32 * SPARC_FPREG_SIZE);
126
      bzero (&registers[REGISTER_BYTE (FPS_REGNUM)], 1 * SPARC_FPREG_SIZE);
127
    }
128
 
129
  /* Mark the register cache valid.  */
130
 
131
  registers_fetched ();
132
}
133
 
134
/* Store a register or registers into the VxWorks target.
135
   REGNO is the register to store, or -1 for all; currently,
136
   it is ignored.  FIXME look at regno to improve efficiency.  */
137
 
138
void
139
vx_write_register (int regno)
140
{
141
  char sparc_greg_packet[SPARC_GREG_PLEN];
142
  char sparc_fpreg_packet[SPARC_FPREG_PLEN];
143
  int in_gp_regs;
144
  int in_fp_regs;
145
  CORE_ADDR sp;
146
 
147
  /* Store general purpose registers.  When copying values from
148
     registers [], don't assume that a location in registers []
149
     is properly aligned for the target data type.  */
150
 
151
  in_gp_regs = 1;
152
  in_fp_regs = 1;
153
  if (regno >= 0)
154
    {
155
      if ((G0_REGNUM <= regno && regno <= I7_REGNUM)
156
          || (Y_REGNUM <= regno && regno <= NPC_REGNUM))
157
        in_fp_regs = 0;
158
      else
159
        in_gp_regs = 0;
160
    }
161
  if (in_gp_regs)
162
    {
163
      bcopy (&registers[REGISTER_BYTE (G0_REGNUM)],
164
             &sparc_greg_packet[SPARC_R_G0], 32 * SPARC_GREG_SIZE);
165
      bcopy (&registers[REGISTER_BYTE (Y_REGNUM)],
166
             &sparc_greg_packet[SPARC_R_Y], 6 * SPARC_GREG_SIZE);
167
 
168
      net_write_registers (sparc_greg_packet, SPARC_GREG_PLEN, PTRACE_SETREGS);
169
 
170
      /* If this is a local or in register, or we're storing all
171
         registers, update the register window spill area.  */
172
 
173
      if (regno < 0 || (L0_REGNUM <= regno && regno <= I7_REGNUM))
174
        {
175
          sp = extract_address (&registers[REGISTER_BYTE (SP_REGNUM)],
176
                                REGISTER_RAW_SIZE (CORE_ADDR));
177
          write_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
178
                        16 * REGISTER_RAW_SIZE (L0_REGNUM));
179
        }
180
    }
181
 
182
  /* Store floating point registers if the target has them.  */
183
 
184
  if (in_fp_regs && target_has_fp)
185
    {
186
      bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
187
             &sparc_fpreg_packet[SPARC_R_FP0], 32 * SPARC_FPREG_SIZE);
188
      bcopy (&registers[REGISTER_BYTE (FPS_REGNUM)],
189
             &sparc_fpreg_packet[SPARC_R_FSR], 1 * SPARC_FPREG_SIZE);
190
 
191
      net_write_registers (sparc_fpreg_packet, SPARC_FPREG_PLEN,
192
                           PTRACE_SETFPREGS);
193
    }
194
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.