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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [gdb/] [remote-vx29k.c] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* Am29k-dependent portions of the RPC protocol
2
 
3
   Contributed by Wind River Systems.
4
 
5
   This file is part of GDB.
6
 
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.
11
 
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.
16
 
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.  */
21
 
22
#include <stdio.h>
23
#include "defs.h"
24
 
25
#include "vx-share/regPacket.h"
26
#include "frame.h"
27
#include "inferior.h"
28
#include "target.h"
29
#include "gdbcore.h"
30
#include "command.h"
31
#include "symtab.h"
32
#include "symfile.h"            /* for struct complaint */
33
#include "regcache.h"
34
 
35
#include "gdb_string.h"
36
#include <errno.h>
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
#include <sys/time.h>           /* UTek's <rpc/rpc.h> doesn't #incl this */
48
#include <netdb.h>
49
#include "vx-share/ptrace.h"
50
#include "vx-share/xdr_ptrace.h"
51
#include "vx-share/xdr_ld.h"
52
#include "vx-share/xdr_rdb.h"
53
#include "vx-share/dbgRpcLib.h"
54
 
55
/* get rid of value.h if possible */
56
#include <value.h>
57
#include <symtab.h>
58
 
59
/* Flag set if target has fpu */
60
 
61
extern int target_has_fp;
62
 
63
/* Generic register read/write routines in remote-vx.c.  */
64
 
65
extern void net_read_registers ();
66
extern void net_write_registers ();
67
 
68
/* Read a register or registers from the VxWorks target.
69
   REGNO is the register to read, or -1 for all; currently,
70
   it is ignored.  FIXME look at regno to improve efficiency.  */
71
 
72
void
73
vx_read_register (int regno)
74
{
75
  char am29k_greg_packet[AM29K_GREG_PLEN];
76
  char am29k_fpreg_packet[AM29K_FPREG_PLEN];
77
 
78
  /* Get general-purpose registers.  When copying values into
79
     registers [], don't assume that a location in registers []
80
     is properly aligned for the target data type.  */
81
 
82
  net_read_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_GETREGS);
83
 
84
  /* Now copy the register values into registers[].
85
     Note that this code depends on the ordering of the REGNUMs
86
     as defined in "tm-29k.h".  */
87
 
88
  bcopy (&am29k_greg_packet[AM29K_R_GR96],
89
         &registers[REGISTER_BYTE (GR96_REGNUM)], 160 * AM29K_GREG_SIZE);
90
  bcopy (&am29k_greg_packet[AM29K_R_VAB],
91
         &registers[REGISTER_BYTE (VAB_REGNUM)], 15 * AM29K_GREG_SIZE);
92
  registers[REGISTER_BYTE (INTE_REGNUM)] = am29k_greg_packet[AM29K_R_INTE];
93
  bcopy (&am29k_greg_packet[AM29K_R_RSP],
94
         &registers[REGISTER_BYTE (GR1_REGNUM)], 5 * AM29K_GREG_SIZE);
95
 
96
  /* PAD For now, don't care about exop register */
97
 
98
  memset (&registers[REGISTER_BYTE (EXO_REGNUM)], '\0', AM29K_GREG_SIZE);
99
 
100
  /* If the target has floating point registers, fetch them.
101
     Otherwise, zero the floating point register values in
102
     registers[] for good measure, even though we might not
103
     need to.  */
104
 
105
  if (target_has_fp)
106
    {
107
      net_read_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
108
                          PTRACE_GETFPREGS);
109
      registers[REGISTER_BYTE (FPE_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPE];
110
      registers[REGISTER_BYTE (FPS_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPS];
111
 
112
      /* PAD For now, don't care about registers (?) AI0 to q */
113
 
114
      memset (&registers[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE);
115
    }
116
  else
117
    {
118
      memset (&registers[REGISTER_BYTE (FPE_REGNUM)], '\0', AM29K_FPREG_SIZE);
119
      memset (&registers[REGISTER_BYTE (FPS_REGNUM)], '\0', AM29K_FPREG_SIZE);
120
 
121
      /* PAD For now, don't care about registers (?) AI0 to q */
122
 
123
      memset (&registers[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE);
124
    }
125
 
126
  /* Mark the register cache valid.  */
127
 
128
  registers_fetched ();
129
}
130
 
131
/* Store a register or registers into the VxWorks target.
132
   REGNO is the register to store, or -1 for all; currently,
133
   it is ignored.  FIXME look at regno to improve efficiency.  */
134
 
135
void
136
vx_write_register (int regno)
137
{
138
  char am29k_greg_packet[AM29K_GREG_PLEN];
139
  char am29k_fpreg_packet[AM29K_FPREG_PLEN];
140
 
141
  /* Store general purpose registers.  When copying values from
142
     registers [], don't assume that a location in registers []
143
     is properly aligned for the target data type.  */
144
 
145
  bcopy (&registers[REGISTER_BYTE (GR96_REGNUM)],
146
         &am29k_greg_packet[AM29K_R_GR96], 160 * AM29K_GREG_SIZE);
147
  bcopy (&registers[REGISTER_BYTE (VAB_REGNUM)],
148
         &am29k_greg_packet[AM29K_R_VAB], 15 * AM29K_GREG_SIZE);
149
  am29k_greg_packet[AM29K_R_INTE] = registers[REGISTER_BYTE (INTE_REGNUM)];
150
  bcopy (&registers[REGISTER_BYTE (GR1_REGNUM)],
151
         &am29k_greg_packet[AM29K_R_RSP], 5 * AM29K_GREG_SIZE);
152
 
153
  net_write_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_SETREGS);
154
 
155
  /* Store floating point registers if the target has them.  */
156
 
157
  if (target_has_fp)
158
    {
159
      am29k_fpreg_packet[AM29K_R_FPE] = registers[REGISTER_BYTE (FPE_REGNUM)];
160
      am29k_fpreg_packet[AM29K_R_FPS] = registers[REGISTER_BYTE (FPS_REGNUM)];
161
 
162
      net_write_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
163
                           PTRACE_SETFPREGS);
164
    }
165
}
166
 
167
/* VxWorks zeroes fp when the task is initialized; we use this
168
   to terminate the frame chain. Chain means here the nominal address of
169
   a frame, that is, the return address (lr0) address in the stack. To
170
   obtain the frame pointer (lr1) contents, we must add 4 bytes.
171
   Note : may be we should modify init_frame_info() to get the frame pointer
172
   and store it into the frame_info struct rather than reading its
173
   contents when FRAME_CHAIN_VALID is invoked.  THISFRAME is unused.  */
174
 
175
int
176
vx29k_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe)
177
{
178
  int fp_contents;
179
 
180
  read_memory ((CORE_ADDR) (chain + 4), (char *) &fp_contents, 4);
181
  return (fp_contents != 0);
182
}

powered by: WebSVN 2.1.0

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