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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [hp300ux-nat.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* HP/UX native interface for HP 300's, for GDB when running under Unix.
2
   Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
3
 
4
   This file is part of GDB.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 2 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 59 Temple Place - Suite 330,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
#include "defs.h"
22
#include "frame.h"
23
#include "inferior.h"
24
 
25
/* Defining this means some system include files define some extra stuff.  */
26
#define WOPR
27
#include <sys/param.h>
28
#include <signal.h>
29
#include <sys/user.h>
30
#include <fcntl.h>
31
 
32
#include <sys/ptrace.h>
33
#include <sys/reg.h>
34
#include <sys/trap.h>
35
 
36
#include <sys/file.h>
37
 
38
static void
39
fetch_inferior_register PARAMS ((int, unsigned int));
40
 
41
static void
42
store_inferior_register_1 PARAMS ((int, unsigned int, int));
43
 
44
static void
45
store_inferior_register PARAMS ((int, unsigned int));
46
 
47
/* Get kernel_u_addr using HPUX-style nlist().  */
48
CORE_ADDR kernel_u_addr;
49
 
50
struct hpnlist
51
  {
52
    char *n_name;
53
    long n_value;
54
    unsigned char n_type;
55
    unsigned char n_length;
56
    short n_almod;
57
    short n_unused;
58
  };
59
static struct hpnlist nl[] =
60
{
61
  {"_u", -1,},
62
  {(char *) 0,}};
63
 
64
/* read the value of the u area from the hp-ux kernel */
65
void
66
_initialize_hp300ux_nat ()
67
{
68
#ifndef HPUX_VERSION_5
69
  nlist ("/hp-ux", nl);
70
  kernel_u_addr = nl[0].n_value;
71
#else /* HPUX version 5.  */
72
  kernel_u_addr = (CORE_ADDR) 0x0097900;
73
#endif
74
}
75
 
76
#define INFERIOR_AR0(u)                                                 \
77
  ((ptrace                                                              \
78
    (PT_RUAREA, inferior_pid,                                           \
79
     (PTRACE_ARG3_TYPE) ((char *) &u.u_ar0 - (char *) &u), 0, 0))         \
80
   - kernel_u_addr)
81
 
82
static void
83
fetch_inferior_register (regno, regaddr)
84
     register int regno;
85
     register unsigned int regaddr;
86
{
87
#ifndef HPUX_VERSION_5
88
  if (regno == PS_REGNUM)
89
    {
90
      union
91
        {
92
          int i;
93
          short s[2];
94
        }
95
      ps_val;
96
      int regval;
97
 
98
      ps_val.i = (ptrace (PT_RUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
99
                          0, 0));
100
      regval = ps_val.s[0];
101
      supply_register (regno, (char *) &regval);
102
    }
103
  else
104
#endif /* not HPUX_VERSION_5 */
105
    {
106
      char buf[MAX_REGISTER_RAW_SIZE];
107
      register int i;
108
 
109
      for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
110
        {
111
          *(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid,
112
                                     (PTRACE_ARG3_TYPE) regaddr, 0, 0);
113
          regaddr += sizeof (int);
114
        }
115
      supply_register (regno, buf);
116
    }
117
  return;
118
}
119
 
120
static void
121
store_inferior_register_1 (regno, regaddr, val)
122
     int regno;
123
     unsigned int regaddr;
124
     int val;
125
{
126
  errno = 0;
127
  ptrace (PT_WUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, val, 0);
128
#if 0
129
  /* HP-UX randomly sets errno to non-zero for regno == 25.
130
     However, the value is correctly written, so ignore errno. */
131
  if (errno != 0)
132
    {
133
      char string_buf[64];
134
 
135
      sprintf (string_buf, "writing register number %d", regno);
136
      perror_with_name (string_buf);
137
    }
138
#endif
139
  return;
140
}
141
 
142
static void
143
store_inferior_register (regno, regaddr)
144
     register int regno;
145
     register unsigned int regaddr;
146
{
147
#ifndef HPUX_VERSION_5
148
  if (regno == PS_REGNUM)
149
    {
150
      union
151
        {
152
          int i;
153
          short s[2];
154
        }
155
      ps_val;
156
 
157
      ps_val.i = (ptrace (PT_RUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
158
                          0, 0));
159
      ps_val.s[0] = (read_register (regno));
160
      store_inferior_register_1 (regno, regaddr, ps_val.i);
161
    }
162
  else
163
#endif /* not HPUX_VERSION_5 */
164
    {
165
      register int i;
166
 
167
      for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
168
        {
169
          store_inferior_register_1
170
            (regno, regaddr,
171
             (*(int *) &registers[(REGISTER_BYTE (regno)) + i]));
172
          regaddr += sizeof (int);
173
        }
174
    }
175
  return;
176
}
177
 
178
void
179
fetch_inferior_registers (regno)
180
     int regno;
181
{
182
  struct user u;
183
  register unsigned int ar0_offset;
184
 
185
  ar0_offset = (INFERIOR_AR0 (u));
186
  if (regno == -1)
187
    {
188
      for (regno = 0; (regno < FP0_REGNUM); regno++)
189
        fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
190
      for (; (regno < NUM_REGS); regno++)
191
        fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
192
    }
193
  else
194
    fetch_inferior_register (regno,
195
                             (regno < FP0_REGNUM
196
                              ? REGISTER_ADDR (ar0_offset, regno)
197
                              : FP_REGISTER_ADDR (u, regno)));
198
}
199
 
200
/* Store our register values back into the inferior.
201
   If REGNO is -1, do this for all registers.
202
   Otherwise, REGNO specifies which register (so we can save time).  */
203
 
204
void
205
store_inferior_registers (regno)
206
     register int regno;
207
{
208
  struct user u;
209
  register unsigned int ar0_offset;
210
 
211
  if (regno >= FP0_REGNUM)
212
    {
213
      store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
214
      return;
215
    }
216
 
217
  ar0_offset = (INFERIOR_AR0 (u));
218
  if (regno >= 0)
219
    {
220
      store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
221
      return;
222
    }
223
 
224
  for (regno = 0; (regno < FP0_REGNUM); regno++)
225
    store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
226
  for (; (regno < NUM_REGS); regno++)
227
    store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
228
  return;
229
}
230
 
231
int
232
getpagesize ()
233
{
234
  return 4096;
235
}

powered by: WebSVN 2.1.0

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