Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | /* Copyright (C) 2009-2014 Free Software Foundation, Inc. |
8ed54b31 JB |
2 | |
3 | This file is part of GDB. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
17 | ||
18 | #include "server.h" | |
19 | #include "lynx-low.h" | |
20 | ||
21 | #include <stdint.h> | |
22 | #include <stddef.h> | |
23 | #include <limits.h> | |
1adfc54d | 24 | #include <sys/ptrace.h> |
8ed54b31 JB |
25 | |
26 | /* The following two typedefs are defined in a .h file which is not | |
27 | in the standard include path (/sys/include/family/ppc/ucontext.h), | |
28 | so we just duplicate them here. */ | |
29 | ||
30 | /* General register context */ | |
31 | typedef struct usr_econtext_s | |
32 | { | |
33 | uint32_t uec_iregs[32]; | |
34 | uint32_t uec_inum; | |
35 | uint32_t uec_srr0; | |
36 | uint32_t uec_srr1; | |
37 | uint32_t uec_lr; | |
38 | uint32_t uec_ctr; | |
39 | uint32_t uec_cr; | |
40 | uint32_t uec_xer; | |
41 | uint32_t uec_dar; | |
42 | uint32_t uec_mq; | |
43 | uint32_t uec_msr; | |
44 | uint32_t uec_sregs[16]; | |
45 | uint32_t uec_ss_count; | |
46 | uint32_t uec_ss_addr1; | |
47 | uint32_t uec_ss_addr2; | |
48 | uint32_t uec_ss_code1; | |
49 | uint32_t uec_ss_code2; | |
50 | } usr_econtext_t; | |
51 | ||
52 | /* Floating point register context */ | |
53 | typedef struct usr_fcontext_s | |
54 | { | |
55 | uint64_t ufc_freg[32]; | |
56 | uint32_t ufc_fpscr[2]; | |
57 | } usr_fcontext_t; | |
58 | ||
59 | /* Index of for various registers inside the regcache. */ | |
60 | #define R0_REGNUM 0 | |
61 | #define F0_REGNUM 32 | |
62 | #define PC_REGNUM 64 | |
63 | #define MSR_REGNUM 65 | |
64 | #define CR_REGNUM 66 | |
65 | #define LR_REGNUM 67 | |
66 | #define CTR_REGNUM 68 | |
67 | #define XER_REGNUM 69 | |
68 | #define FPSCR_REGNUM 70 | |
69 | ||
70 | /* Defined in auto-generated file powerpc-32.c. */ | |
71 | extern void init_registers_powerpc_32 (void); | |
3aee8918 | 72 | extern const struct target_desc *tdesc_powerpc_32; |
8ed54b31 JB |
73 | |
74 | /* The fill_function for the general-purpose register set. */ | |
75 | ||
76 | static void | |
77 | lynx_ppc_fill_gregset (struct regcache *regcache, char *buf) | |
78 | { | |
79 | int i; | |
80 | ||
81 | /* r0 - r31 */ | |
82 | for (i = 0; i < 32; i++) | |
83 | collect_register (regcache, R0_REGNUM + i, | |
84 | buf + offsetof (usr_econtext_t, uec_iregs[i])); | |
85 | ||
86 | /* The other registers provided in the GP register context. */ | |
87 | collect_register (regcache, PC_REGNUM, | |
88 | buf + offsetof (usr_econtext_t, uec_srr0)); | |
89 | collect_register (regcache, MSR_REGNUM, | |
90 | buf + offsetof (usr_econtext_t, uec_srr1)); | |
91 | collect_register (regcache, CR_REGNUM, | |
92 | buf + offsetof (usr_econtext_t, uec_cr)); | |
93 | collect_register (regcache, LR_REGNUM, | |
94 | buf + offsetof (usr_econtext_t, uec_lr)); | |
95 | collect_register (regcache, CTR_REGNUM, | |
96 | buf + offsetof (usr_econtext_t, uec_ctr)); | |
97 | collect_register (regcache, XER_REGNUM, | |
98 | buf + offsetof (usr_econtext_t, uec_xer)); | |
99 | } | |
100 | ||
101 | /* The store_function for the general-purpose register set. */ | |
102 | ||
103 | static void | |
104 | lynx_ppc_store_gregset (struct regcache *regcache, const char *buf) | |
105 | { | |
106 | int i; | |
107 | ||
108 | /* r0 - r31 */ | |
109 | for (i = 0; i < 32; i++) | |
110 | supply_register (regcache, R0_REGNUM + i, | |
111 | buf + offsetof (usr_econtext_t, uec_iregs[i])); | |
112 | ||
113 | /* The other registers provided in the GP register context. */ | |
114 | supply_register (regcache, PC_REGNUM, | |
115 | buf + offsetof (usr_econtext_t, uec_srr0)); | |
116 | supply_register (regcache, MSR_REGNUM, | |
117 | buf + offsetof (usr_econtext_t, uec_srr1)); | |
118 | supply_register (regcache, CR_REGNUM, | |
119 | buf + offsetof (usr_econtext_t, uec_cr)); | |
120 | supply_register (regcache, LR_REGNUM, | |
121 | buf + offsetof (usr_econtext_t, uec_lr)); | |
122 | supply_register (regcache, CTR_REGNUM, | |
123 | buf + offsetof (usr_econtext_t, uec_ctr)); | |
124 | supply_register (regcache, XER_REGNUM, | |
125 | buf + offsetof (usr_econtext_t, uec_xer)); | |
126 | } | |
127 | ||
128 | /* The fill_function for the floating-point register set. */ | |
129 | ||
130 | static void | |
131 | lynx_ppc_fill_fpregset (struct regcache *regcache, char *buf) | |
132 | { | |
133 | int i; | |
134 | ||
135 | /* f0 - f31 */ | |
136 | for (i = 0; i < 32; i++) | |
137 | collect_register (regcache, F0_REGNUM + i, | |
138 | buf + offsetof (usr_fcontext_t, ufc_freg[i])); | |
139 | ||
140 | /* fpscr */ | |
141 | collect_register (regcache, FPSCR_REGNUM, | |
142 | buf + offsetof (usr_fcontext_t, ufc_fpscr)); | |
143 | } | |
144 | ||
145 | /* The store_function for the floating-point register set. */ | |
146 | ||
147 | static void | |
148 | lynx_ppc_store_fpregset (struct regcache *regcache, const char *buf) | |
149 | { | |
150 | int i; | |
151 | ||
152 | /* f0 - f31 */ | |
153 | for (i = 0; i < 32; i++) | |
154 | supply_register (regcache, F0_REGNUM + i, | |
155 | buf + offsetof (usr_fcontext_t, ufc_freg[i])); | |
156 | ||
157 | /* fpscr */ | |
158 | supply_register (regcache, FPSCR_REGNUM, | |
159 | buf + offsetof (usr_fcontext_t, ufc_fpscr)); | |
160 | } | |
161 | ||
162 | /* Implements the lynx_target_ops.arch_setup routine. */ | |
163 | ||
164 | static void | |
165 | lynx_ppc_arch_setup (void) | |
166 | { | |
167 | init_registers_powerpc_32 (); | |
3aee8918 | 168 | lynx_tdesc = tdesc_powerpc_32; |
8ed54b31 JB |
169 | } |
170 | ||
171 | /* Description of all the powerpc-lynx register sets. */ | |
172 | ||
173 | struct lynx_regset_info lynx_target_regsets[] = { | |
174 | /* General Purpose Registers. */ | |
175 | {PTRACE_GETREGS, PTRACE_SETREGS, sizeof(usr_econtext_t), | |
176 | lynx_ppc_fill_gregset, lynx_ppc_store_gregset}, | |
177 | /* Floating Point Registers. */ | |
178 | { PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof(usr_fcontext_t), | |
179 | lynx_ppc_fill_fpregset, lynx_ppc_store_fpregset }, | |
180 | /* End of list marker. */ | |
181 | {0, 0, -1, NULL, NULL } | |
182 | }; | |
183 | ||
184 | /* The lynx_target_ops vector for powerpc-lynxos. */ | |
185 | ||
186 | struct lynx_target_ops the_low_target = { | |
187 | lynx_ppc_arch_setup, | |
188 | }; |