Commit | Line | Data |
---|---|---|
c877c8e6 | 1 | /* PPC linux native support. |
b6ba6518 KB |
2 | Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001 |
3 | Free Software Foundation, Inc. | |
c877c8e6 KB |
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, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include "defs.h" | |
22 | #include "frame.h" | |
23 | #include "inferior.h" | |
24 | #include "gdbcore.h" | |
4e052eda | 25 | #include "regcache.h" |
c877c8e6 KB |
26 | |
27 | #include <sys/types.h> | |
28 | #include <sys/param.h> | |
29 | #include <signal.h> | |
30 | #include <sys/user.h> | |
31 | #include <sys/ioctl.h> | |
32 | #include <sys/wait.h> | |
33 | #include <fcntl.h> | |
34 | #include <sys/procfs.h> | |
35 | ||
c60c0f5f MS |
36 | /* Prototypes for supply_gregset etc. */ |
37 | #include "gregset.h" | |
38 | ||
c877c8e6 | 39 | int |
fba45db2 | 40 | kernel_u_size (void) |
c877c8e6 KB |
41 | { |
42 | return (sizeof (struct user)); | |
43 | } | |
44 | ||
45 | static int regmap[] = | |
46 | {PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7, | |
47 | PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15, | |
48 | PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23, | |
49 | PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31, | |
50 | PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14, | |
51 | PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30, | |
52 | PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46, | |
53 | PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62, | |
54 | PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ}; | |
55 | ||
56 | int | |
57 | ppc_register_u_addr (int ustart, int regnum) | |
58 | { | |
59 | return (ustart + 4 * regmap[regnum]); | |
60 | } | |
61 | ||
50c9bd31 | 62 | void |
8ae45c11 | 63 | supply_gregset (gdb_gregset_t *gregsetp) |
c877c8e6 KB |
64 | { |
65 | int regi; | |
66 | register greg_t *regp = (greg_t *) gregsetp; | |
67 | ||
68 | for (regi = 0; regi < 32; regi++) | |
69 | supply_register (regi, (char *) (regp + regi)); | |
70 | ||
71 | for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++) | |
72 | supply_register (regi, (char *) (regp + regmap[regi])); | |
73 | } | |
74 | ||
fdb28ac4 | 75 | void |
8ae45c11 | 76 | fill_gregset (gdb_gregset_t *gregsetp, int regno) |
fdb28ac4 KB |
77 | { |
78 | int regi; | |
79 | greg_t *regp = (greg_t *) gregsetp; | |
80 | ||
81 | #define COPY_REG(_idx_,_regi_) \ | |
82 | if ((regno == -1) || regno == _regi_) \ | |
83 | memcpy (regp + _idx_, ®isters[REGISTER_BYTE (_regi_)], \ | |
84 | REGISTER_RAW_SIZE (_regi_)) | |
85 | ||
86 | for (regi = 0; regi < 32; regi++) | |
87 | { | |
88 | COPY_REG (regmap[regi], regi); | |
89 | } | |
90 | ||
91 | for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++) | |
92 | { | |
93 | COPY_REG (regmap[regi], regi); | |
94 | } | |
95 | } | |
96 | ||
50c9bd31 | 97 | void |
8ae45c11 | 98 | supply_fpregset (gdb_fpregset_t * fpregsetp) |
c877c8e6 KB |
99 | { |
100 | int regi; | |
101 | for (regi = 0; regi < 32; regi++) | |
102 | { | |
103 | supply_register (FP0_REGNUM + regi, (char *) (*fpregsetp + regi)); | |
104 | } | |
105 | } | |
fdb28ac4 KB |
106 | |
107 | /* Given a pointer to a floating point register set in /proc format | |
108 | (fpregset_t *), update the register specified by REGNO from gdb's idea | |
109 | of the current floating point register set. If REGNO is -1, update | |
110 | them all. */ | |
111 | ||
112 | void | |
8ae45c11 | 113 | fill_fpregset (gdb_fpregset_t *fpregsetp, int regno) |
fdb28ac4 KB |
114 | { |
115 | int regi; | |
116 | char *to; | |
117 | char *from; | |
118 | ||
119 | for (regi = 0; regi < 32; regi++) | |
120 | { | |
121 | if ((regno == -1) || (regno == FP0_REGNUM + regi)) | |
122 | { | |
123 | from = (char *) ®isters[REGISTER_BYTE (FP0_REGNUM + regi)]; | |
124 | to = (char *) (*fpregsetp + regi); | |
125 | memcpy (to, from, REGISTER_RAW_SIZE (FP0_REGNUM + regi)); | |
126 | } | |
127 | } | |
128 | } |