1 /* Copyright (C) 2009-2017 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include <sys/ptrace.h>
23 /* The following two typedefs are defined in a .h file which is not
24 in the standard include path (/sys/include/family/ppc/ucontext.h),
25 so we just duplicate them here. */
27 /* General register context */
28 typedef struct usr_econtext_s
30 uint32_t uec_iregs[32];
41 uint32_t uec_sregs[16];
42 uint32_t uec_ss_count;
43 uint32_t uec_ss_addr1;
44 uint32_t uec_ss_addr2;
45 uint32_t uec_ss_code1;
46 uint32_t uec_ss_code2;
49 /* Floating point register context */
50 typedef struct usr_fcontext_s
52 uint64_t ufc_freg[32];
53 uint32_t ufc_fpscr[2];
56 /* Index of for various registers inside the regcache. */
65 #define FPSCR_REGNUM 70
67 /* Defined in auto-generated file powerpc-32.c. */
68 extern void init_registers_powerpc_32 (void);
69 extern const struct target_desc *tdesc_powerpc_32;
71 /* The fill_function for the general-purpose register set. */
74 lynx_ppc_fill_gregset (struct regcache *regcache, char *buf)
79 for (i = 0; i < 32; i++)
80 collect_register (regcache, R0_REGNUM + i,
81 buf + offsetof (usr_econtext_t, uec_iregs[i]));
83 /* The other registers provided in the GP register context. */
84 collect_register (regcache, PC_REGNUM,
85 buf + offsetof (usr_econtext_t, uec_srr0));
86 collect_register (regcache, MSR_REGNUM,
87 buf + offsetof (usr_econtext_t, uec_srr1));
88 collect_register (regcache, CR_REGNUM,
89 buf + offsetof (usr_econtext_t, uec_cr));
90 collect_register (regcache, LR_REGNUM,
91 buf + offsetof (usr_econtext_t, uec_lr));
92 collect_register (regcache, CTR_REGNUM,
93 buf + offsetof (usr_econtext_t, uec_ctr));
94 collect_register (regcache, XER_REGNUM,
95 buf + offsetof (usr_econtext_t, uec_xer));
98 /* The store_function for the general-purpose register set. */
101 lynx_ppc_store_gregset (struct regcache *regcache, const char *buf)
106 for (i = 0; i < 32; i++)
107 supply_register (regcache, R0_REGNUM + i,
108 buf + offsetof (usr_econtext_t, uec_iregs[i]));
110 /* The other registers provided in the GP register context. */
111 supply_register (regcache, PC_REGNUM,
112 buf + offsetof (usr_econtext_t, uec_srr0));
113 supply_register (regcache, MSR_REGNUM,
114 buf + offsetof (usr_econtext_t, uec_srr1));
115 supply_register (regcache, CR_REGNUM,
116 buf + offsetof (usr_econtext_t, uec_cr));
117 supply_register (regcache, LR_REGNUM,
118 buf + offsetof (usr_econtext_t, uec_lr));
119 supply_register (regcache, CTR_REGNUM,
120 buf + offsetof (usr_econtext_t, uec_ctr));
121 supply_register (regcache, XER_REGNUM,
122 buf + offsetof (usr_econtext_t, uec_xer));
125 /* The fill_function for the floating-point register set. */
128 lynx_ppc_fill_fpregset (struct regcache *regcache, char *buf)
133 for (i = 0; i < 32; i++)
134 collect_register (regcache, F0_REGNUM + i,
135 buf + offsetof (usr_fcontext_t, ufc_freg[i]));
138 collect_register (regcache, FPSCR_REGNUM,
139 buf + offsetof (usr_fcontext_t, ufc_fpscr));
142 /* The store_function for the floating-point register set. */
145 lynx_ppc_store_fpregset (struct regcache *regcache, const char *buf)
150 for (i = 0; i < 32; i++)
151 supply_register (regcache, F0_REGNUM + i,
152 buf + offsetof (usr_fcontext_t, ufc_freg[i]));
155 supply_register (regcache, FPSCR_REGNUM,
156 buf + offsetof (usr_fcontext_t, ufc_fpscr));
159 /* Implements the lynx_target_ops.arch_setup routine. */
162 lynx_ppc_arch_setup (void)
164 init_registers_powerpc_32 ();
165 lynx_tdesc = tdesc_powerpc_32;
168 /* Description of all the powerpc-lynx register sets. */
170 struct lynx_regset_info lynx_target_regsets[] = {
171 /* General Purpose Registers. */
172 {PTRACE_GETREGS, PTRACE_SETREGS, sizeof(usr_econtext_t),
173 lynx_ppc_fill_gregset, lynx_ppc_store_gregset},
174 /* Floating Point Registers. */
175 { PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof(usr_fcontext_t),
176 lynx_ppc_fill_fpregset, lynx_ppc_store_fpregset },
177 /* End of list marker. */
178 {0, 0, -1, NULL, NULL }
181 /* The lynx_target_ops vector for powerpc-lynxos. */
183 struct lynx_target_ops the_low_target = {