1 /* PPC linux native support.
2 Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
27 #include <sys/types.h>
28 #include <sys/param.h>
31 #include <sys/ioctl.h>
34 #include <sys/procfs.h>
36 /* Prototypes for supply_gregset etc. */
43 return (sizeof (struct user
));
47 /* registers layout, as presented by the ptrace interface:
48 PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
49 PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
50 PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
51 PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
52 PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
53 PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
54 PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
55 PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
56 PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
60 ppc_register_u_addr (int ustart
, int regno
)
64 /* General purpose registers occupy 1 slot each in the buffer */
65 if (regno
>= PPC_GP0_REGNUM
&& regno
<= PPC_GPLAST_REGNUM
)
66 u_addr
= (ustart
+ (PT_R0
+ regno
) * 4);
68 /* Floating point regs: 2 slots each */
69 if (regno
>= FP0_REGNUM
&& regno
<= FPLAST_REGNUM
)
70 u_addr
= (ustart
+ (PT_FPR0
+ (regno
- FP0_REGNUM
) * 2) * 4);
72 /* UISA special purpose registers: 1 slot each */
73 if (regno
== PC_REGNUM
)
74 u_addr
= ustart
+ PT_NIP
* 4;
75 if (regno
== PPC_LR_REGNUM
)
76 u_addr
= ustart
+ PT_LNK
* 4;
77 if (regno
== PPC_CR_REGNUM
)
78 u_addr
= ustart
+ PT_CCR
* 4;
79 if (regno
== PPC_XER_REGNUM
)
80 u_addr
= ustart
+ PT_XER
* 4;
81 if (regno
== PPC_CTR_REGNUM
)
82 u_addr
= ustart
+ PT_CTR
* 4;
83 if (regno
== PPC_MQ_REGNUM
)
84 u_addr
= ustart
+ PT_MQ
* 4;
85 if (regno
== PPC_PS_REGNUM
)
86 u_addr
= ustart
+ PT_MSR
* 4;
92 supply_gregset (gdb_gregset_t
*gregsetp
)
95 register elf_greg_t
*regp
= (elf_greg_t
*) gregsetp
;
97 for (regi
= 0; regi
< 32; regi
++)
98 supply_register (regi
, (char *) (regp
+ regi
));
100 supply_register (PC_REGNUM
, (char *) (regp
+ PT_NIP
));
101 supply_register (PPC_LR_REGNUM
, (char *) (regp
+ PT_LNK
));
102 supply_register (PPC_CR_REGNUM
, (char *) (regp
+ PT_CCR
));
103 supply_register (PPC_XER_REGNUM
, (char *) (regp
+ PT_XER
));
104 supply_register (PPC_CTR_REGNUM
, (char *) (regp
+ PT_CTR
));
105 supply_register (PPC_MQ_REGNUM
, (char *) (regp
+ PT_MQ
));
106 supply_register (PPC_PS_REGNUM
, (char *) (regp
+ PT_MSR
));
110 fill_gregset (gdb_gregset_t
*gregsetp
, int regno
)
113 elf_greg_t
*regp
= (elf_greg_t
*) gregsetp
;
115 for (regi
= 0; regi
< 32; regi
++)
117 if ((regno
== -1) || regno
== regi
)
118 regcache_collect (regi
, regp
+ PT_R0
+ regi
);
121 if ((regno
== -1) || regno
== PC_REGNUM
)
122 regcache_collect (PC_REGNUM
, regp
+ PT_NIP
);
123 if ((regno
== -1) || regno
== PPC_LR_REGNUM
)
124 regcache_collect (PPC_LR_REGNUM
, regp
+ PT_LNK
);
125 if ((regno
== -1) || regno
== PPC_CR_REGNUM
)
126 regcache_collect (PPC_CR_REGNUM
, regp
+ PT_CCR
);
127 if ((regno
== -1) || regno
== PPC_XER_REGNUM
)
128 regcache_collect (PPC_XER_REGNUM
, regp
+ PT_XER
);
129 if ((regno
== -1) || regno
== PPC_CTR_REGNUM
)
130 regcache_collect (PPC_CTR_REGNUM
, regp
+ PT_CTR
);
131 if ((regno
== -1) || regno
== PPC_MQ_REGNUM
)
132 regcache_collect (PPC_MQ_REGNUM
, regp
+ PT_MQ
);
133 if ((regno
== -1) || regno
== PPC_PS_REGNUM
)
134 regcache_collect (PPC_PS_REGNUM
, regp
+ PT_MSR
);
138 supply_fpregset (gdb_fpregset_t
* fpregsetp
)
141 for (regi
= 0; regi
< 32; regi
++)
143 supply_register (FP0_REGNUM
+ regi
, (char *) (*fpregsetp
+ regi
));
147 /* Given a pointer to a floating point register set in /proc format
148 (fpregset_t *), update the register specified by REGNO from gdb's idea
149 of the current floating point register set. If REGNO is -1, update
153 fill_fpregset (gdb_fpregset_t
*fpregsetp
, int regno
)
157 for (regi
= 0; regi
< 32; regi
++)
159 if ((regno
== -1) || (regno
== FP0_REGNUM
+ regi
))
160 regcache_collect (FP0_REGNUM
+ regi
, (char *) (*fpregsetp
+ regi
));
This page took 0.034178 seconds and 4 git commands to generate.