]>
Commit | Line | Data |
---|---|---|
9abe5450 | 1 | /* PPC GNU/Linux native support. |
2555fe1a | 2 | |
197e01b6 | 3 | Copyright (C) 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002, |
10d6c8cd | 4 | 2003, 2004, 2005 Free Software Foundation, Inc. |
c877c8e6 KB |
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 | |
197e01b6 EZ |
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | Boston, MA 02110-1301, USA. */ | |
c877c8e6 KB |
22 | |
23 | #include "defs.h" | |
e162d11b | 24 | #include "gdb_string.h" |
c877c8e6 KB |
25 | #include "frame.h" |
26 | #include "inferior.h" | |
27 | #include "gdbcore.h" | |
4e052eda | 28 | #include "regcache.h" |
383f0f5b | 29 | #include "gdb_assert.h" |
10d6c8cd DJ |
30 | #include "target.h" |
31 | #include "linux-nat.h" | |
c877c8e6 KB |
32 | |
33 | #include <sys/types.h> | |
34 | #include <sys/param.h> | |
35 | #include <signal.h> | |
36 | #include <sys/user.h> | |
37 | #include <sys/ioctl.h> | |
2555fe1a | 38 | #include "gdb_wait.h" |
c877c8e6 KB |
39 | #include <fcntl.h> |
40 | #include <sys/procfs.h> | |
45229ea4 | 41 | #include <sys/ptrace.h> |
c877c8e6 | 42 | |
c60c0f5f MS |
43 | /* Prototypes for supply_gregset etc. */ |
44 | #include "gregset.h" | |
16333c4f | 45 | #include "ppc-tdep.h" |
c60c0f5f | 46 | |
45229ea4 EZ |
47 | #ifndef PT_READ_U |
48 | #define PT_READ_U PTRACE_PEEKUSR | |
49 | #endif | |
50 | #ifndef PT_WRITE_U | |
51 | #define PT_WRITE_U PTRACE_POKEUSR | |
52 | #endif | |
53 | ||
54 | /* Default the type of the ptrace transfer to int. */ | |
55 | #ifndef PTRACE_XFER_TYPE | |
56 | #define PTRACE_XFER_TYPE int | |
57 | #endif | |
58 | ||
9abe5450 EZ |
59 | /* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a |
60 | configure time check. Some older glibc's (for instance 2.2.1) | |
61 | don't have a specific powerpc version of ptrace.h, and fall back on | |
62 | a generic one. In such cases, sys/ptrace.h defines | |
63 | PTRACE_GETFPXREGS and PTRACE_SETFPXREGS to the same numbers that | |
64 | ppc kernel's asm/ptrace.h defines PTRACE_GETVRREGS and | |
65 | PTRACE_SETVRREGS to be. This also makes a configury check pretty | |
66 | much useless. */ | |
67 | ||
68 | /* These definitions should really come from the glibc header files, | |
69 | but Glibc doesn't know about the vrregs yet. */ | |
70 | #ifndef PTRACE_GETVRREGS | |
71 | #define PTRACE_GETVRREGS 18 | |
72 | #define PTRACE_SETVRREGS 19 | |
73 | #endif | |
74 | ||
01904826 JB |
75 | |
76 | /* Similarly for the ptrace requests for getting / setting the SPE | |
77 | registers (ev0 -- ev31, acc, and spefscr). See the description of | |
78 | gdb_evrregset_t for details. */ | |
79 | #ifndef PTRACE_GETEVRREGS | |
80 | #define PTRACE_GETEVRREGS 20 | |
81 | #define PTRACE_SETEVRREGS 21 | |
82 | #endif | |
83 | ||
84 | ||
9abe5450 EZ |
85 | /* This oddity is because the Linux kernel defines elf_vrregset_t as |
86 | an array of 33 16 bytes long elements. I.e. it leaves out vrsave. | |
87 | However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return | |
88 | the vrsave as an extra 4 bytes at the end. I opted for creating a | |
89 | flat array of chars, so that it is easier to manipulate for gdb. | |
90 | ||
91 | There are 32 vector registers 16 bytes longs, plus a VSCR register | |
92 | which is only 4 bytes long, but is fetched as a 16 bytes | |
93 | quantity. Up to here we have the elf_vrregset_t structure. | |
94 | Appended to this there is space for the VRSAVE register: 4 bytes. | |
95 | Even though this vrsave register is not included in the regset | |
96 | typedef, it is handled by the ptrace requests. | |
97 | ||
98 | Note that GNU/Linux doesn't support little endian PPC hardware, | |
99 | therefore the offset at which the real value of the VSCR register | |
100 | is located will be always 12 bytes. | |
101 | ||
102 | The layout is like this (where x is the actual value of the vscr reg): */ | |
103 | ||
104 | /* *INDENT-OFF* */ | |
105 | /* | |
106 | |.|.|.|.|.....|.|.|.|.||.|.|.|x||.| | |
107 | <-------> <-------><-------><-> | |
108 | VR0 VR31 VSCR VRSAVE | |
109 | */ | |
110 | /* *INDENT-ON* */ | |
111 | ||
112 | #define SIZEOF_VRREGS 33*16+4 | |
113 | ||
114 | typedef char gdb_vrregset_t[SIZEOF_VRREGS]; | |
115 | ||
01904826 JB |
116 | |
117 | /* On PPC processors that support the the Signal Processing Extension | |
118 | (SPE) APU, the general-purpose registers are 64 bits long. | |
9cbc6ef0 AC |
119 | However, the ordinary Linux kernel PTRACE_PEEKUSR / PTRACE_POKEUSR |
120 | / PT_READ_U / PT_WRITE_U ptrace calls only access the lower half of | |
01904826 JB |
121 | each register, to allow them to behave the same way they do on |
122 | non-SPE systems. There's a separate pair of calls, | |
123 | PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that read and write the top | |
124 | halves of all the general-purpose registers at once, along with | |
125 | some SPE-specific registers. | |
126 | ||
127 | GDB itself continues to claim the general-purpose registers are 32 | |
6ced10dd JB |
128 | bits long. It has unnamed raw registers that hold the upper halves |
129 | of the gprs, and the the full 64-bit SIMD views of the registers, | |
130 | 'ev0' -- 'ev31', are pseudo-registers that splice the top and | |
131 | bottom halves together. | |
01904826 JB |
132 | |
133 | This is the structure filled in by PTRACE_GETEVRREGS and written to | |
134 | the inferior's registers by PTRACE_SETEVRREGS. */ | |
135 | struct gdb_evrregset_t | |
136 | { | |
137 | unsigned long evr[32]; | |
138 | unsigned long long acc; | |
139 | unsigned long spefscr; | |
140 | }; | |
141 | ||
142 | ||
143 | /* Non-zero if our kernel may support the PTRACE_GETVRREGS and | |
144 | PTRACE_SETVRREGS requests, for reading and writing the Altivec | |
145 | registers. Zero if we've tried one of them and gotten an | |
146 | error. */ | |
9abe5450 EZ |
147 | int have_ptrace_getvrregs = 1; |
148 | ||
01904826 JB |
149 | |
150 | /* Non-zero if our kernel may support the PTRACE_GETEVRREGS and | |
151 | PTRACE_SETEVRREGS requests, for reading and writing the SPE | |
152 | registers. Zero if we've tried one of them and gotten an | |
153 | error. */ | |
154 | int have_ptrace_getsetevrregs = 1; | |
155 | ||
156 | ||
c877c8e6 | 157 | int |
fba45db2 | 158 | kernel_u_size (void) |
c877c8e6 KB |
159 | { |
160 | return (sizeof (struct user)); | |
161 | } | |
162 | ||
16333c4f EZ |
163 | /* *INDENT-OFF* */ |
164 | /* registers layout, as presented by the ptrace interface: | |
165 | PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7, | |
166 | PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15, | |
167 | PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23, | |
168 | PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31, | |
169 | PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14, | |
170 | PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30, | |
171 | PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46, | |
172 | PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62, | |
173 | PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */ | |
174 | /* *INDENT_ON * */ | |
c877c8e6 | 175 | |
45229ea4 EZ |
176 | static int |
177 | ppc_register_u_addr (int regno) | |
c877c8e6 | 178 | { |
16333c4f | 179 | int u_addr = -1; |
dc5cfeb6 | 180 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
56d0d96a AC |
181 | /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace |
182 | interface, and not the wordsize of the program's ABI. */ | |
183 | int wordsize = sizeof (PTRACE_XFER_TYPE); | |
16333c4f EZ |
184 | |
185 | /* General purpose registers occupy 1 slot each in the buffer */ | |
8bf659e8 JB |
186 | if (regno >= tdep->ppc_gp0_regnum |
187 | && regno < tdep->ppc_gp0_regnum + ppc_num_gprs) | |
26e75e5c | 188 | u_addr = ((regno - tdep->ppc_gp0_regnum + PT_R0) * wordsize); |
16333c4f | 189 | |
49ff75ad JB |
190 | /* Floating point regs: eight bytes each in both 32- and 64-bit |
191 | ptrace interfaces. Thus, two slots each in 32-bit interface, one | |
192 | slot each in 64-bit interface. */ | |
383f0f5b JB |
193 | if (tdep->ppc_fp0_regnum >= 0 |
194 | && regno >= tdep->ppc_fp0_regnum | |
366f009f JB |
195 | && regno < tdep->ppc_fp0_regnum + ppc_num_fprs) |
196 | u_addr = (PT_FPR0 * wordsize) + ((regno - tdep->ppc_fp0_regnum) * 8); | |
16333c4f EZ |
197 | |
198 | /* UISA special purpose registers: 1 slot each */ | |
199 | if (regno == PC_REGNUM) | |
49ff75ad | 200 | u_addr = PT_NIP * wordsize; |
dc5cfeb6 | 201 | if (regno == tdep->ppc_lr_regnum) |
49ff75ad | 202 | u_addr = PT_LNK * wordsize; |
dc5cfeb6 | 203 | if (regno == tdep->ppc_cr_regnum) |
49ff75ad | 204 | u_addr = PT_CCR * wordsize; |
dc5cfeb6 | 205 | if (regno == tdep->ppc_xer_regnum) |
49ff75ad | 206 | u_addr = PT_XER * wordsize; |
dc5cfeb6 | 207 | if (regno == tdep->ppc_ctr_regnum) |
49ff75ad | 208 | u_addr = PT_CTR * wordsize; |
f8c59253 | 209 | #ifdef PT_MQ |
dc5cfeb6 | 210 | if (regno == tdep->ppc_mq_regnum) |
49ff75ad | 211 | u_addr = PT_MQ * wordsize; |
f8c59253 | 212 | #endif |
dc5cfeb6 | 213 | if (regno == tdep->ppc_ps_regnum) |
49ff75ad | 214 | u_addr = PT_MSR * wordsize; |
383f0f5b JB |
215 | if (tdep->ppc_fpscr_regnum >= 0 |
216 | && regno == tdep->ppc_fpscr_regnum) | |
8f135812 AC |
217 | { |
218 | /* NOTE: cagney/2005-02-08: On some 64-bit GNU/Linux systems the | |
219 | kernel headers incorrectly contained the 32-bit definition of | |
220 | PT_FPSCR. For the 32-bit definition, floating-point | |
221 | registers occupy two 32-bit "slots", and the FPSCR lives in | |
222 | the secondhalf of such a slot-pair (hence +1). For 64-bit, | |
223 | the FPSCR instead occupies the full 64-bit 2-word-slot and | |
224 | hence no adjustment is necessary. Hack around this. */ | |
225 | if (wordsize == 8 && PT_FPSCR == (48 + 32 + 1)) | |
226 | u_addr = (48 + 32) * wordsize; | |
227 | else | |
228 | u_addr = PT_FPSCR * wordsize; | |
229 | } | |
16333c4f | 230 | return u_addr; |
c877c8e6 KB |
231 | } |
232 | ||
9abe5450 EZ |
233 | /* The Linux kernel ptrace interface for AltiVec registers uses the |
234 | registers set mechanism, as opposed to the interface for all the | |
235 | other registers, that stores/fetches each register individually. */ | |
236 | static void | |
237 | fetch_altivec_register (int tid, int regno) | |
238 | { | |
239 | int ret; | |
240 | int offset = 0; | |
241 | gdb_vrregset_t regs; | |
242 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
3acba339 | 243 | int vrregsize = register_size (current_gdbarch, tdep->ppc_vr0_regnum); |
9abe5450 EZ |
244 | |
245 | ret = ptrace (PTRACE_GETVRREGS, tid, 0, ®s); | |
246 | if (ret < 0) | |
247 | { | |
248 | if (errno == EIO) | |
249 | { | |
250 | have_ptrace_getvrregs = 0; | |
251 | return; | |
252 | } | |
e2e0b3e5 | 253 | perror_with_name (_("Unable to fetch AltiVec register")); |
9abe5450 EZ |
254 | } |
255 | ||
256 | /* VSCR is fetched as a 16 bytes quantity, but it is really 4 bytes | |
257 | long on the hardware. We deal only with the lower 4 bytes of the | |
258 | vector. VRSAVE is at the end of the array in a 4 bytes slot, so | |
259 | there is no need to define an offset for it. */ | |
260 | if (regno == (tdep->ppc_vrsave_regnum - 1)) | |
3acba339 | 261 | offset = vrregsize - register_size (current_gdbarch, tdep->ppc_vrsave_regnum); |
9abe5450 | 262 | |
23a6d369 AC |
263 | regcache_raw_supply (current_regcache, regno, |
264 | regs + (regno - tdep->ppc_vr0_regnum) * vrregsize + offset); | |
9abe5450 EZ |
265 | } |
266 | ||
01904826 JB |
267 | /* Fetch the top 32 bits of TID's general-purpose registers and the |
268 | SPE-specific registers, and place the results in EVRREGSET. If we | |
269 | don't support PTRACE_GETEVRREGS, then just fill EVRREGSET with | |
270 | zeros. | |
271 | ||
272 | All the logic to deal with whether or not the PTRACE_GETEVRREGS and | |
273 | PTRACE_SETEVRREGS requests are supported is isolated here, and in | |
274 | set_spe_registers. */ | |
275 | static void | |
276 | get_spe_registers (int tid, struct gdb_evrregset_t *evrregset) | |
277 | { | |
278 | if (have_ptrace_getsetevrregs) | |
279 | { | |
280 | if (ptrace (PTRACE_GETEVRREGS, tid, 0, evrregset) >= 0) | |
281 | return; | |
282 | else | |
283 | { | |
284 | /* EIO means that the PTRACE_GETEVRREGS request isn't supported; | |
285 | we just return zeros. */ | |
286 | if (errno == EIO) | |
287 | have_ptrace_getsetevrregs = 0; | |
288 | else | |
289 | /* Anything else needs to be reported. */ | |
e2e0b3e5 | 290 | perror_with_name (_("Unable to fetch SPE registers")); |
01904826 JB |
291 | } |
292 | } | |
293 | ||
294 | memset (evrregset, 0, sizeof (*evrregset)); | |
295 | } | |
296 | ||
6ced10dd JB |
297 | /* Supply values from TID for SPE-specific raw registers: the upper |
298 | halves of the GPRs, the accumulator, and the spefscr. REGNO must | |
299 | be the number of an upper half register, acc, spefscr, or -1 to | |
300 | supply the values of all registers. */ | |
01904826 JB |
301 | static void |
302 | fetch_spe_register (int tid, int regno) | |
303 | { | |
304 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
305 | struct gdb_evrregset_t evrregs; | |
306 | ||
6ced10dd JB |
307 | gdb_assert (sizeof (evrregs.evr[0]) |
308 | == register_size (current_gdbarch, tdep->ppc_ev0_upper_regnum)); | |
309 | gdb_assert (sizeof (evrregs.acc) | |
310 | == register_size (current_gdbarch, tdep->ppc_acc_regnum)); | |
311 | gdb_assert (sizeof (evrregs.spefscr) | |
312 | == register_size (current_gdbarch, tdep->ppc_spefscr_regnum)); | |
313 | ||
01904826 JB |
314 | get_spe_registers (tid, &evrregs); |
315 | ||
6ced10dd | 316 | if (regno == -1) |
01904826 | 317 | { |
6ced10dd JB |
318 | int i; |
319 | ||
320 | for (i = 0; i < ppc_num_gprs; i++) | |
321 | regcache_raw_supply (current_regcache, tdep->ppc_ev0_upper_regnum + i, | |
322 | &evrregs.evr[i]); | |
01904826 | 323 | } |
6ced10dd JB |
324 | else if (tdep->ppc_ev0_upper_regnum <= regno |
325 | && regno < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) | |
326 | regcache_raw_supply (current_regcache, regno, | |
327 | &evrregs.evr[regno - tdep->ppc_ev0_upper_regnum]); | |
328 | ||
329 | if (regno == -1 | |
330 | || regno == tdep->ppc_acc_regnum) | |
331 | regcache_raw_supply (current_regcache, tdep->ppc_acc_regnum, &evrregs.acc); | |
332 | ||
333 | if (regno == -1 | |
334 | || regno == tdep->ppc_spefscr_regnum) | |
335 | regcache_raw_supply (current_regcache, tdep->ppc_spefscr_regnum, | |
336 | &evrregs.spefscr); | |
01904826 JB |
337 | } |
338 | ||
45229ea4 | 339 | static void |
05f13b9c | 340 | fetch_register (int tid, int regno) |
45229ea4 | 341 | { |
366f009f | 342 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
45229ea4 | 343 | /* This isn't really an address. But ptrace thinks of it as one. */ |
0397dee1 | 344 | CORE_ADDR regaddr = ppc_register_u_addr (regno); |
4a19ea35 | 345 | int bytes_transferred; |
45229ea4 | 346 | unsigned int offset; /* Offset of registers within the u area. */ |
d9d9c31f | 347 | char buf[MAX_REGISTER_SIZE]; |
45229ea4 | 348 | |
9abe5450 EZ |
349 | if (altivec_register_p (regno)) |
350 | { | |
351 | /* If this is the first time through, or if it is not the first | |
352 | time through, and we have comfirmed that there is kernel | |
353 | support for such a ptrace request, then go and fetch the | |
354 | register. */ | |
355 | if (have_ptrace_getvrregs) | |
356 | { | |
357 | fetch_altivec_register (tid, regno); | |
358 | return; | |
359 | } | |
360 | /* If we have discovered that there is no ptrace support for | |
361 | AltiVec registers, fall through and return zeroes, because | |
362 | regaddr will be -1 in this case. */ | |
363 | } | |
01904826 JB |
364 | else if (spe_register_p (regno)) |
365 | { | |
366 | fetch_spe_register (tid, regno); | |
367 | return; | |
368 | } | |
9abe5450 | 369 | |
45229ea4 EZ |
370 | if (regaddr == -1) |
371 | { | |
3acba339 | 372 | memset (buf, '\0', register_size (current_gdbarch, regno)); /* Supply zeroes */ |
23a6d369 | 373 | regcache_raw_supply (current_regcache, regno, buf); |
45229ea4 EZ |
374 | return; |
375 | } | |
376 | ||
56d0d96a AC |
377 | /* Read the raw register using PTRACE_XFER_TYPE sized chunks. On a |
378 | 32-bit platform, 64-bit floating-point registers will require two | |
379 | transfers. */ | |
4a19ea35 | 380 | for (bytes_transferred = 0; |
8327ccee | 381 | bytes_transferred < register_size (current_gdbarch, regno); |
4a19ea35 | 382 | bytes_transferred += sizeof (PTRACE_XFER_TYPE)) |
45229ea4 EZ |
383 | { |
384 | errno = 0; | |
4a19ea35 JB |
385 | *(PTRACE_XFER_TYPE *) & buf[bytes_transferred] |
386 | = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0); | |
45229ea4 EZ |
387 | regaddr += sizeof (PTRACE_XFER_TYPE); |
388 | if (errno != 0) | |
389 | { | |
bc97b3ba JB |
390 | char message[128]; |
391 | sprintf (message, "reading register %s (#%d)", | |
45229ea4 | 392 | REGISTER_NAME (regno), regno); |
bc97b3ba | 393 | perror_with_name (message); |
45229ea4 EZ |
394 | } |
395 | } | |
56d0d96a | 396 | |
4a19ea35 JB |
397 | /* Now supply the register. Keep in mind that the regcache's idea |
398 | of the register's size may not be a multiple of sizeof | |
399 | (PTRACE_XFER_TYPE). */ | |
400 | if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) | |
401 | { | |
402 | /* Little-endian values are always found at the left end of the | |
403 | bytes transferred. */ | |
404 | regcache_raw_supply (current_regcache, regno, buf); | |
405 | } | |
406 | else if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) | |
407 | { | |
408 | /* Big-endian values are found at the right end of the bytes | |
409 | transferred. */ | |
410 | size_t padding = (bytes_transferred | |
411 | - register_size (current_gdbarch, regno)); | |
412 | regcache_raw_supply (current_regcache, regno, buf + padding); | |
413 | } | |
414 | else | |
a44bddec | 415 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 | 416 | _("fetch_register: unexpected byte order: %d"), |
a44bddec | 417 | gdbarch_byte_order (current_gdbarch)); |
45229ea4 EZ |
418 | } |
419 | ||
9abe5450 EZ |
420 | static void |
421 | supply_vrregset (gdb_vrregset_t *vrregsetp) | |
422 | { | |
423 | int i; | |
424 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
425 | int num_of_vrregs = tdep->ppc_vrsave_regnum - tdep->ppc_vr0_regnum + 1; | |
3acba339 AC |
426 | int vrregsize = register_size (current_gdbarch, tdep->ppc_vr0_regnum); |
427 | int offset = vrregsize - register_size (current_gdbarch, tdep->ppc_vrsave_regnum); | |
9abe5450 EZ |
428 | |
429 | for (i = 0; i < num_of_vrregs; i++) | |
430 | { | |
431 | /* The last 2 registers of this set are only 32 bit long, not | |
432 | 128. However an offset is necessary only for VSCR because it | |
433 | occupies a whole vector, while VRSAVE occupies a full 4 bytes | |
434 | slot. */ | |
435 | if (i == (num_of_vrregs - 2)) | |
23a6d369 AC |
436 | regcache_raw_supply (current_regcache, tdep->ppc_vr0_regnum + i, |
437 | *vrregsetp + i * vrregsize + offset); | |
9abe5450 | 438 | else |
23a6d369 AC |
439 | regcache_raw_supply (current_regcache, tdep->ppc_vr0_regnum + i, |
440 | *vrregsetp + i * vrregsize); | |
9abe5450 EZ |
441 | } |
442 | } | |
443 | ||
444 | static void | |
445 | fetch_altivec_registers (int tid) | |
446 | { | |
447 | int ret; | |
448 | gdb_vrregset_t regs; | |
449 | ||
450 | ret = ptrace (PTRACE_GETVRREGS, tid, 0, ®s); | |
451 | if (ret < 0) | |
452 | { | |
453 | if (errno == EIO) | |
454 | { | |
455 | have_ptrace_getvrregs = 0; | |
456 | return; | |
457 | } | |
e2e0b3e5 | 458 | perror_with_name (_("Unable to fetch AltiVec registers")); |
9abe5450 EZ |
459 | } |
460 | supply_vrregset (®s); | |
461 | } | |
462 | ||
45229ea4 | 463 | static void |
05f13b9c | 464 | fetch_ppc_registers (int tid) |
45229ea4 EZ |
465 | { |
466 | int i; | |
9abe5450 EZ |
467 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
468 | ||
6ced10dd JB |
469 | for (i = 0; i < ppc_num_gprs; i++) |
470 | fetch_register (tid, tdep->ppc_gp0_regnum + i); | |
32b99774 JB |
471 | if (tdep->ppc_fp0_regnum >= 0) |
472 | for (i = 0; i < ppc_num_fprs; i++) | |
473 | fetch_register (tid, tdep->ppc_fp0_regnum + i); | |
474 | fetch_register (tid, PC_REGNUM); | |
475 | if (tdep->ppc_ps_regnum != -1) | |
476 | fetch_register (tid, tdep->ppc_ps_regnum); | |
477 | if (tdep->ppc_cr_regnum != -1) | |
478 | fetch_register (tid, tdep->ppc_cr_regnum); | |
479 | if (tdep->ppc_lr_regnum != -1) | |
480 | fetch_register (tid, tdep->ppc_lr_regnum); | |
481 | if (tdep->ppc_ctr_regnum != -1) | |
482 | fetch_register (tid, tdep->ppc_ctr_regnum); | |
483 | if (tdep->ppc_xer_regnum != -1) | |
484 | fetch_register (tid, tdep->ppc_xer_regnum); | |
e3f36dbd KB |
485 | if (tdep->ppc_mq_regnum != -1) |
486 | fetch_register (tid, tdep->ppc_mq_regnum); | |
32b99774 JB |
487 | if (tdep->ppc_fpscr_regnum != -1) |
488 | fetch_register (tid, tdep->ppc_fpscr_regnum); | |
9abe5450 EZ |
489 | if (have_ptrace_getvrregs) |
490 | if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1) | |
491 | fetch_altivec_registers (tid); | |
6ced10dd JB |
492 | if (tdep->ppc_ev0_upper_regnum >= 0) |
493 | fetch_spe_register (tid, -1); | |
45229ea4 EZ |
494 | } |
495 | ||
496 | /* Fetch registers from the child process. Fetch all registers if | |
497 | regno == -1, otherwise fetch all general registers or all floating | |
498 | point registers depending upon the value of regno. */ | |
10d6c8cd DJ |
499 | static void |
500 | ppc_linux_fetch_inferior_registers (int regno) | |
45229ea4 | 501 | { |
9abe5450 | 502 | /* Overload thread id onto process id */ |
05f13b9c EZ |
503 | int tid = TIDGET (inferior_ptid); |
504 | ||
505 | /* No thread id, just use process id */ | |
506 | if (tid == 0) | |
507 | tid = PIDGET (inferior_ptid); | |
508 | ||
9abe5450 | 509 | if (regno == -1) |
05f13b9c | 510 | fetch_ppc_registers (tid); |
45229ea4 | 511 | else |
05f13b9c | 512 | fetch_register (tid, regno); |
45229ea4 EZ |
513 | } |
514 | ||
515 | /* Store one register. */ | |
9abe5450 EZ |
516 | static void |
517 | store_altivec_register (int tid, int regno) | |
518 | { | |
519 | int ret; | |
520 | int offset = 0; | |
521 | gdb_vrregset_t regs; | |
522 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
3acba339 | 523 | int vrregsize = register_size (current_gdbarch, tdep->ppc_vr0_regnum); |
9abe5450 EZ |
524 | |
525 | ret = ptrace (PTRACE_GETVRREGS, tid, 0, ®s); | |
526 | if (ret < 0) | |
527 | { | |
528 | if (errno == EIO) | |
529 | { | |
530 | have_ptrace_getvrregs = 0; | |
531 | return; | |
532 | } | |
e2e0b3e5 | 533 | perror_with_name (_("Unable to fetch AltiVec register")); |
9abe5450 EZ |
534 | } |
535 | ||
536 | /* VSCR is fetched as a 16 bytes quantity, but it is really 4 bytes | |
537 | long on the hardware. */ | |
538 | if (regno == (tdep->ppc_vrsave_regnum - 1)) | |
3acba339 | 539 | offset = vrregsize - register_size (current_gdbarch, tdep->ppc_vrsave_regnum); |
9abe5450 | 540 | |
822c9732 AC |
541 | regcache_raw_collect (current_regcache, regno, |
542 | regs + (regno - tdep->ppc_vr0_regnum) * vrregsize + offset); | |
9abe5450 EZ |
543 | |
544 | ret = ptrace (PTRACE_SETVRREGS, tid, 0, ®s); | |
545 | if (ret < 0) | |
e2e0b3e5 | 546 | perror_with_name (_("Unable to store AltiVec register")); |
9abe5450 EZ |
547 | } |
548 | ||
01904826 JB |
549 | /* Assuming TID referrs to an SPE process, set the top halves of TID's |
550 | general-purpose registers and its SPE-specific registers to the | |
551 | values in EVRREGSET. If we don't support PTRACE_SETEVRREGS, do | |
552 | nothing. | |
553 | ||
554 | All the logic to deal with whether or not the PTRACE_GETEVRREGS and | |
555 | PTRACE_SETEVRREGS requests are supported is isolated here, and in | |
556 | get_spe_registers. */ | |
557 | static void | |
558 | set_spe_registers (int tid, struct gdb_evrregset_t *evrregset) | |
559 | { | |
560 | if (have_ptrace_getsetevrregs) | |
561 | { | |
562 | if (ptrace (PTRACE_SETEVRREGS, tid, 0, evrregset) >= 0) | |
563 | return; | |
564 | else | |
565 | { | |
566 | /* EIO means that the PTRACE_SETEVRREGS request isn't | |
567 | supported; we fail silently, and don't try the call | |
568 | again. */ | |
569 | if (errno == EIO) | |
570 | have_ptrace_getsetevrregs = 0; | |
571 | else | |
572 | /* Anything else needs to be reported. */ | |
e2e0b3e5 | 573 | perror_with_name (_("Unable to set SPE registers")); |
01904826 JB |
574 | } |
575 | } | |
576 | } | |
577 | ||
6ced10dd JB |
578 | /* Write GDB's value for the SPE-specific raw register REGNO to TID. |
579 | If REGNO is -1, write the values of all the SPE-specific | |
580 | registers. */ | |
01904826 JB |
581 | static void |
582 | store_spe_register (int tid, int regno) | |
583 | { | |
584 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
585 | struct gdb_evrregset_t evrregs; | |
586 | ||
6ced10dd JB |
587 | gdb_assert (sizeof (evrregs.evr[0]) |
588 | == register_size (current_gdbarch, tdep->ppc_ev0_upper_regnum)); | |
589 | gdb_assert (sizeof (evrregs.acc) | |
590 | == register_size (current_gdbarch, tdep->ppc_acc_regnum)); | |
591 | gdb_assert (sizeof (evrregs.spefscr) | |
592 | == register_size (current_gdbarch, tdep->ppc_spefscr_regnum)); | |
01904826 | 593 | |
6ced10dd JB |
594 | if (regno == -1) |
595 | /* Since we're going to write out every register, the code below | |
596 | should store to every field of evrregs; if that doesn't happen, | |
597 | make it obvious by initializing it with suspicious values. */ | |
598 | memset (&evrregs, 42, sizeof (evrregs)); | |
599 | else | |
600 | /* We can only read and write the entire EVR register set at a | |
601 | time, so to write just a single register, we do a | |
602 | read-modify-write maneuver. */ | |
603 | get_spe_registers (tid, &evrregs); | |
604 | ||
605 | if (regno == -1) | |
01904826 | 606 | { |
6ced10dd JB |
607 | int i; |
608 | ||
609 | for (i = 0; i < ppc_num_gprs; i++) | |
610 | regcache_raw_collect (current_regcache, | |
611 | tdep->ppc_ev0_upper_regnum + i, | |
612 | &evrregs.evr[i]); | |
01904826 | 613 | } |
6ced10dd JB |
614 | else if (tdep->ppc_ev0_upper_regnum <= regno |
615 | && regno < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) | |
616 | regcache_raw_collect (current_regcache, regno, | |
617 | &evrregs.evr[regno - tdep->ppc_ev0_upper_regnum]); | |
618 | ||
619 | if (regno == -1 | |
620 | || regno == tdep->ppc_acc_regnum) | |
621 | regcache_raw_collect (current_regcache, | |
622 | tdep->ppc_acc_regnum, | |
623 | &evrregs.acc); | |
624 | ||
625 | if (regno == -1 | |
626 | || regno == tdep->ppc_spefscr_regnum) | |
627 | regcache_raw_collect (current_regcache, | |
628 | tdep->ppc_spefscr_regnum, | |
629 | &evrregs.spefscr); | |
01904826 JB |
630 | |
631 | /* Write back the modified register set. */ | |
632 | set_spe_registers (tid, &evrregs); | |
633 | } | |
634 | ||
45229ea4 | 635 | static void |
05f13b9c | 636 | store_register (int tid, int regno) |
45229ea4 | 637 | { |
366f009f | 638 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
45229ea4 EZ |
639 | /* This isn't really an address. But ptrace thinks of it as one. */ |
640 | CORE_ADDR regaddr = ppc_register_u_addr (regno); | |
52f0bd74 | 641 | int i; |
4a19ea35 | 642 | size_t bytes_to_transfer; |
d9d9c31f | 643 | char buf[MAX_REGISTER_SIZE]; |
45229ea4 | 644 | |
9abe5450 | 645 | if (altivec_register_p (regno)) |
45229ea4 | 646 | { |
9abe5450 | 647 | store_altivec_register (tid, regno); |
45229ea4 EZ |
648 | return; |
649 | } | |
01904826 JB |
650 | else if (spe_register_p (regno)) |
651 | { | |
652 | store_spe_register (tid, regno); | |
653 | return; | |
654 | } | |
45229ea4 | 655 | |
9abe5450 EZ |
656 | if (regaddr == -1) |
657 | return; | |
658 | ||
4a19ea35 JB |
659 | /* First collect the register. Keep in mind that the regcache's |
660 | idea of the register's size may not be a multiple of sizeof | |
661 | (PTRACE_XFER_TYPE). */ | |
56d0d96a | 662 | memset (buf, 0, sizeof buf); |
4a19ea35 JB |
663 | bytes_to_transfer = align_up (register_size (current_gdbarch, regno), |
664 | sizeof (PTRACE_XFER_TYPE)); | |
665 | if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE) | |
666 | { | |
667 | /* Little-endian values always sit at the left end of the buffer. */ | |
668 | regcache_raw_collect (current_regcache, regno, buf); | |
669 | } | |
670 | else if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) | |
671 | { | |
672 | /* Big-endian values sit at the right end of the buffer. */ | |
673 | size_t padding = (bytes_to_transfer | |
674 | - register_size (current_gdbarch, regno)); | |
675 | regcache_raw_collect (current_regcache, regno, buf + padding); | |
676 | } | |
677 | ||
678 | for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE)) | |
45229ea4 EZ |
679 | { |
680 | errno = 0; | |
681 | ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr, | |
682 | *(PTRACE_XFER_TYPE *) & buf[i]); | |
683 | regaddr += sizeof (PTRACE_XFER_TYPE); | |
e3f36dbd KB |
684 | |
685 | if (errno == EIO | |
383f0f5b | 686 | && regno == tdep->ppc_fpscr_regnum) |
e3f36dbd KB |
687 | { |
688 | /* Some older kernel versions don't allow fpscr to be written. */ | |
689 | continue; | |
690 | } | |
691 | ||
45229ea4 EZ |
692 | if (errno != 0) |
693 | { | |
bc97b3ba JB |
694 | char message[128]; |
695 | sprintf (message, "writing register %s (#%d)", | |
45229ea4 | 696 | REGISTER_NAME (regno), regno); |
bc97b3ba | 697 | perror_with_name (message); |
45229ea4 EZ |
698 | } |
699 | } | |
700 | } | |
701 | ||
9abe5450 EZ |
702 | static void |
703 | fill_vrregset (gdb_vrregset_t *vrregsetp) | |
704 | { | |
705 | int i; | |
706 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
707 | int num_of_vrregs = tdep->ppc_vrsave_regnum - tdep->ppc_vr0_regnum + 1; | |
3acba339 AC |
708 | int vrregsize = register_size (current_gdbarch, tdep->ppc_vr0_regnum); |
709 | int offset = vrregsize - register_size (current_gdbarch, tdep->ppc_vrsave_regnum); | |
9abe5450 EZ |
710 | |
711 | for (i = 0; i < num_of_vrregs; i++) | |
712 | { | |
713 | /* The last 2 registers of this set are only 32 bit long, not | |
714 | 128, but only VSCR is fetched as a 16 bytes quantity. */ | |
715 | if (i == (num_of_vrregs - 2)) | |
822c9732 AC |
716 | regcache_raw_collect (current_regcache, tdep->ppc_vr0_regnum + i, |
717 | *vrregsetp + i * vrregsize + offset); | |
9abe5450 | 718 | else |
822c9732 AC |
719 | regcache_raw_collect (current_regcache, tdep->ppc_vr0_regnum + i, |
720 | *vrregsetp + i * vrregsize); | |
9abe5450 EZ |
721 | } |
722 | } | |
723 | ||
724 | static void | |
725 | store_altivec_registers (int tid) | |
726 | { | |
727 | int ret; | |
728 | gdb_vrregset_t regs; | |
729 | ||
0897f59b | 730 | ret = ptrace (PTRACE_GETVRREGS, tid, 0, ®s); |
9abe5450 EZ |
731 | if (ret < 0) |
732 | { | |
733 | if (errno == EIO) | |
734 | { | |
735 | have_ptrace_getvrregs = 0; | |
736 | return; | |
737 | } | |
e2e0b3e5 | 738 | perror_with_name (_("Couldn't get AltiVec registers")); |
9abe5450 EZ |
739 | } |
740 | ||
741 | fill_vrregset (®s); | |
742 | ||
0897f59b | 743 | if (ptrace (PTRACE_SETVRREGS, tid, 0, ®s) < 0) |
e2e0b3e5 | 744 | perror_with_name (_("Couldn't write AltiVec registers")); |
9abe5450 EZ |
745 | } |
746 | ||
45229ea4 | 747 | static void |
05f13b9c | 748 | store_ppc_registers (int tid) |
45229ea4 EZ |
749 | { |
750 | int i; | |
9abe5450 | 751 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
45229ea4 | 752 | |
6ced10dd JB |
753 | for (i = 0; i < ppc_num_gprs; i++) |
754 | store_register (tid, tdep->ppc_gp0_regnum + i); | |
32b99774 JB |
755 | if (tdep->ppc_fp0_regnum >= 0) |
756 | for (i = 0; i < ppc_num_fprs; i++) | |
757 | store_register (tid, tdep->ppc_fp0_regnum + i); | |
758 | store_register (tid, PC_REGNUM); | |
759 | if (tdep->ppc_ps_regnum != -1) | |
760 | store_register (tid, tdep->ppc_ps_regnum); | |
761 | if (tdep->ppc_cr_regnum != -1) | |
762 | store_register (tid, tdep->ppc_cr_regnum); | |
763 | if (tdep->ppc_lr_regnum != -1) | |
764 | store_register (tid, tdep->ppc_lr_regnum); | |
765 | if (tdep->ppc_ctr_regnum != -1) | |
766 | store_register (tid, tdep->ppc_ctr_regnum); | |
767 | if (tdep->ppc_xer_regnum != -1) | |
768 | store_register (tid, tdep->ppc_xer_regnum); | |
e3f36dbd KB |
769 | if (tdep->ppc_mq_regnum != -1) |
770 | store_register (tid, tdep->ppc_mq_regnum); | |
32b99774 JB |
771 | if (tdep->ppc_fpscr_regnum != -1) |
772 | store_register (tid, tdep->ppc_fpscr_regnum); | |
9abe5450 EZ |
773 | if (have_ptrace_getvrregs) |
774 | if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1) | |
775 | store_altivec_registers (tid); | |
6ced10dd JB |
776 | if (tdep->ppc_ev0_upper_regnum >= 0) |
777 | store_spe_register (tid, -1); | |
45229ea4 EZ |
778 | } |
779 | ||
10d6c8cd DJ |
780 | static void |
781 | ppc_linux_store_inferior_registers (int regno) | |
45229ea4 | 782 | { |
05f13b9c EZ |
783 | /* Overload thread id onto process id */ |
784 | int tid = TIDGET (inferior_ptid); | |
785 | ||
786 | /* No thread id, just use process id */ | |
787 | if (tid == 0) | |
788 | tid = PIDGET (inferior_ptid); | |
789 | ||
45229ea4 | 790 | if (regno >= 0) |
05f13b9c | 791 | store_register (tid, regno); |
45229ea4 | 792 | else |
05f13b9c | 793 | store_ppc_registers (tid); |
45229ea4 EZ |
794 | } |
795 | ||
50c9bd31 | 796 | void |
8ae45c11 | 797 | supply_gregset (gdb_gregset_t *gregsetp) |
c877c8e6 | 798 | { |
f9be684a AC |
799 | /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace |
800 | interface, and not the wordsize of the program's ABI. */ | |
801 | int wordsize = sizeof (PTRACE_XFER_TYPE); | |
802 | ppc_linux_supply_gregset (current_regcache, -1, gregsetp, | |
803 | sizeof (gdb_gregset_t), wordsize); | |
804 | } | |
805 | ||
806 | static void | |
807 | right_fill_reg (int regnum, void *reg) | |
808 | { | |
809 | /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace | |
810 | interface, and not the wordsize of the program's ABI. */ | |
811 | int wordsize = sizeof (PTRACE_XFER_TYPE); | |
812 | /* Right fill the register. */ | |
813 | regcache_raw_collect (current_regcache, regnum, | |
814 | ((bfd_byte *) reg | |
815 | + wordsize | |
816 | - register_size (current_gdbarch, regnum))); | |
c877c8e6 KB |
817 | } |
818 | ||
fdb28ac4 | 819 | void |
8ae45c11 | 820 | fill_gregset (gdb_gregset_t *gregsetp, int regno) |
fdb28ac4 KB |
821 | { |
822 | int regi; | |
2ac44c70 | 823 | elf_greg_t *regp = (elf_greg_t *) gregsetp; |
dc5cfeb6 | 824 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
f9be684a AC |
825 | const int elf_ngreg = 48; |
826 | ||
827 | ||
828 | /* Start with zeros. */ | |
829 | memset (regp, 0, elf_ngreg * sizeof (*regp)); | |
fdb28ac4 | 830 | |
063715bf | 831 | for (regi = 0; regi < ppc_num_gprs; regi++) |
fdb28ac4 | 832 | { |
cdf2c5f5 JB |
833 | if ((regno == -1) || regno == tdep->ppc_gp0_regnum + regi) |
834 | right_fill_reg (tdep->ppc_gp0_regnum + regi, (regp + PT_R0 + regi)); | |
fdb28ac4 KB |
835 | } |
836 | ||
16333c4f | 837 | if ((regno == -1) || regno == PC_REGNUM) |
f9be684a | 838 | right_fill_reg (PC_REGNUM, regp + PT_NIP); |
05f13b9c | 839 | if ((regno == -1) || regno == tdep->ppc_lr_regnum) |
f9be684a | 840 | right_fill_reg (tdep->ppc_lr_regnum, regp + PT_LNK); |
05f13b9c | 841 | if ((regno == -1) || regno == tdep->ppc_cr_regnum) |
822c9732 AC |
842 | regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, |
843 | regp + PT_CCR); | |
05f13b9c | 844 | if ((regno == -1) || regno == tdep->ppc_xer_regnum) |
822c9732 AC |
845 | regcache_raw_collect (current_regcache, tdep->ppc_xer_regnum, |
846 | regp + PT_XER); | |
05f13b9c | 847 | if ((regno == -1) || regno == tdep->ppc_ctr_regnum) |
f9be684a | 848 | right_fill_reg (tdep->ppc_ctr_regnum, regp + PT_CTR); |
f8c59253 | 849 | #ifdef PT_MQ |
e3f36dbd KB |
850 | if (((regno == -1) || regno == tdep->ppc_mq_regnum) |
851 | && (tdep->ppc_mq_regnum != -1)) | |
f9be684a | 852 | right_fill_reg (tdep->ppc_mq_regnum, regp + PT_MQ); |
f8c59253 | 853 | #endif |
05f13b9c | 854 | if ((regno == -1) || regno == tdep->ppc_ps_regnum) |
f9be684a | 855 | right_fill_reg (tdep->ppc_ps_regnum, regp + PT_MSR); |
fdb28ac4 KB |
856 | } |
857 | ||
50c9bd31 | 858 | void |
8ae45c11 | 859 | supply_fpregset (gdb_fpregset_t * fpregsetp) |
c877c8e6 | 860 | { |
f9be684a AC |
861 | ppc_linux_supply_fpregset (NULL, current_regcache, -1, fpregsetp, |
862 | sizeof (gdb_fpregset_t)); | |
c877c8e6 | 863 | } |
fdb28ac4 | 864 | |
9abe5450 EZ |
865 | /* Given a pointer to a floating point register set in /proc format |
866 | (fpregset_t *), update the register specified by REGNO from gdb's | |
867 | idea of the current floating point register set. If REGNO is -1, | |
868 | update them all. */ | |
fdb28ac4 | 869 | void |
8ae45c11 | 870 | fill_fpregset (gdb_fpregset_t *fpregsetp, int regno) |
fdb28ac4 KB |
871 | { |
872 | int regi; | |
e3f36dbd | 873 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); |
f9be684a | 874 | bfd_byte *fpp = (void *) fpregsetp; |
fdb28ac4 | 875 | |
383f0f5b | 876 | if (ppc_floating_point_unit_p (current_gdbarch)) |
fdb28ac4 | 877 | { |
383f0f5b JB |
878 | for (regi = 0; regi < ppc_num_fprs; regi++) |
879 | { | |
880 | if ((regno == -1) || (regno == tdep->ppc_fp0_regnum + regi)) | |
822c9732 AC |
881 | regcache_raw_collect (current_regcache, tdep->ppc_fp0_regnum + regi, |
882 | fpp + 8 * regi); | |
383f0f5b JB |
883 | } |
884 | if (regno == -1 || regno == tdep->ppc_fpscr_regnum) | |
885 | right_fill_reg (tdep->ppc_fpscr_regnum, (fpp + 8 * 32)); | |
fdb28ac4 KB |
886 | } |
887 | } | |
10d6c8cd DJ |
888 | |
889 | void _initialize_ppc_linux_nat (void); | |
890 | ||
891 | void | |
892 | _initialize_ppc_linux_nat (void) | |
893 | { | |
894 | struct target_ops *t; | |
895 | ||
896 | /* Fill in the generic GNU/Linux methods. */ | |
897 | t = linux_target (); | |
898 | ||
899 | /* Add our register access methods. */ | |
900 | t->to_fetch_registers = ppc_linux_fetch_inferior_registers; | |
901 | t->to_store_registers = ppc_linux_store_inferior_registers; | |
902 | ||
903 | /* Register the target. */ | |
904 | add_target (t); | |
905 | } |