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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [i386v4-nat.c] - Blame information for rev 860

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

Line No. Rev Author Line
1 24 jeremybenn
/* Native-dependent code for Unix SVR4 running on i386's.
2
 
3
   Copyright (C) 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001,
4
   2002, 2004, 2007, 2008 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.  */
20
 
21
#include "defs.h"
22
#include "value.h"
23
#include "inferior.h"
24
#include "regcache.h"
25
 
26
#ifdef HAVE_SYS_REG_H
27
#include <sys/reg.h>
28
#endif
29
 
30
#include "i386-tdep.h"
31
#include "i387-tdep.h"
32
 
33
#ifdef HAVE_SYS_PROCFS_H
34
 
35
#include <sys/procfs.h>
36
 
37
/* We must not compile this code for 64-bit Solaris x86.  */
38
#if !defined (PR_MODEL_NATIVE) || (PR_MODEL_NATIVE == PR_MODEL_ILP32)
39
 
40
#include "gregset.h"
41
 
42
/* The `/proc' interface divides the target machine's register set up
43
   into two different sets, the general purpose register set (gregset)
44
   and the floating-point register set (fpregset).  For each set,
45
   there is an ioctl to get the current register set and another ioctl
46
   to set the current values.
47
 
48
   The actual structure passed through the ioctl interface is, of
49
   course, naturally machine dependent, and is different for each set
50
   of registers.  For the i386 for example, the general-purpose
51
   register set is typically defined by:
52
 
53
   typedef int gregset_t[19];           (in <sys/regset.h>)
54
 
55
   #define GS   0                       (in <sys/reg.h>)
56
   #define FS   1
57
   ...
58
   #define UESP 17
59
   #define SS   18
60
 
61
   and the floating-point set by:
62
 
63
   typedef struct fpregset   {
64
           union {
65
                   struct fpchip_state            // fp extension state //
66
                   {
67
                           int     state[27];     // 287/387 saved state //
68
                           int     status;        // status word saved at //
69
                                                  // exception //
70
                   } fpchip_state;
71
                   struct fp_emul_space           // for emulators //
72
                   {
73
                           char    fp_emul[246];
74
                           char    fp_epad[2];
75
                   } fp_emul_space;
76
                   int     f_fpregs[62];          // union of the above //
77
           } fp_reg_set;
78
           long            f_wregs[33];           // saved weitek state //
79
   } fpregset_t;
80
 
81
   Incidentally fpchip_state contains the FPU state in the same format
82
   as used by the "fsave" instruction, and that's the only thing we
83
   support here.  I don't know how the emulator stores it state.  The
84
   Weitek stuff definitely isn't supported.
85
 
86
   The routines defined here, provide the packing and unpacking of
87
   gregset_t and fpregset_t formatted data.  */
88
 
89
#ifdef HAVE_GREGSET_T
90
 
91
/* Mapping between the general-purpose registers in `/proc'
92
   format and GDB's register array layout.  */
93
static int regmap[] =
94
{
95
  EAX, ECX, EDX, EBX,
96
  UESP, EBP, ESI, EDI,
97
  EIP, EFL, CS, SS,
98
  DS, ES, FS, GS
99
};
100
 
101
/* Fill GDB's register array with the general-purpose register values
102
   in *GREGSETP.  */
103
 
104
void
105
supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
106
{
107
  const greg_t *regp = (const greg_t *) gregsetp;
108
  int regnum;
109
 
110
  for (regnum = 0; regnum < I386_NUM_GREGS; regnum++)
111
    regcache_raw_supply (regcache, regnum, regp + regmap[regnum]);
112
}
113
 
114
/* Fill register REGNUM (if it is a general-purpose register) in
115
   *GREGSETPS with the value in GDB's register array.  If REGNUM is -1,
116
   do this for all registers.  */
117
 
118
void
119
fill_gregset (const struct regcache *regcache,
120
              gregset_t *gregsetp, int regnum)
121
{
122
  greg_t *regp = (greg_t *) gregsetp;
123
  int i;
124
 
125
  for (i = 0; i < I386_NUM_GREGS; i++)
126
    if (regnum == -1 || regnum == i)
127
      regcache_raw_collect (regcache, i, regp + regmap[i]);
128
}
129
 
130
#endif /* HAVE_GREGSET_T */
131
 
132
#ifdef HAVE_FPREGSET_T
133
 
134
/* Fill GDB's register array with the floating-point register values in
135
   *FPREGSETP.  */
136
 
137
void
138
supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
139
{
140
  if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) == 0)
141
    return;
142
 
143
  i387_supply_fsave (regcache, -1, fpregsetp);
144
}
145
 
146
/* Fill register REGNO (if it is a floating-point register) in
147
   *FPREGSETP with the value in GDB's register array.  If REGNO is -1,
148
   do this for all registers.  */
149
 
150
void
151
fill_fpregset (const struct regcache *regcache,
152
               fpregset_t *fpregsetp, int regno)
153
{
154
  if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) == 0)
155
    return;
156
 
157
  i387_collect_fsave (regcache, regno, fpregsetp);
158
}
159
 
160
#endif /* HAVE_FPREGSET_T */
161
 
162
#endif /* not 64-bit.  */
163
 
164
#endif /* HAVE_SYS_PROCFS_H */

powered by: WebSVN 2.1.0

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