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