GDBserver

lynx-ppc-low.c
Go to the documentation of this file.
1 /* Copyright (C) 2009-2018 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 #include <limits.h>
21 #include <sys/ptrace.h>
22
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. */
26
27 /* General register context */
28 typedef struct usr_econtext_s
29 {
30 uint32_t uec_iregs[32];
31 uint32_t uec_inum;
32 uint32_t uec_srr0;
33 uint32_t uec_srr1;
34 uint32_t uec_lr;
35 uint32_t uec_ctr;
36 uint32_t uec_cr;
37 uint32_t uec_xer;
38 uint32_t uec_dar;
39 uint32_t uec_mq;
40 uint32_t uec_msr;
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;
47 } usr_econtext_t;
48
49 /* Floating point register context */
50 typedef struct usr_fcontext_s
51 {
52 uint64_t ufc_freg[32];
53 uint32_t ufc_fpscr[2];
54 } usr_fcontext_t;
55
56 /* Index of for various registers inside the regcache. */
57 #define R0_REGNUM 0
58 #define F0_REGNUM 32
59 #define PC_REGNUM 64
60 #define MSR_REGNUM 65
61 #define CR_REGNUM 66
62 #define LR_REGNUM 67
63 #define CTR_REGNUM 68
64 #define XER_REGNUM 69
65 #define FPSCR_REGNUM 70
66
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;
70
71 /* The fill_function for the general-purpose register set. */
72
73 static void
74 lynx_ppc_fill_gregset (struct regcache *regcache, char *buf)
75 {
76 int i;
77
78 /* r0 - r31 */
79 for (i = 0; i < 32; i++)
80 collect_register (regcache, R0_REGNUM + i,
81 buf + offsetof (usr_econtext_t, uec_iregs[i]));
82
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));
96 }
97
98 /* The store_function for the general-purpose register set. */
99
100 static void
101 lynx_ppc_store_gregset (struct regcache *regcache, const char *buf)
102 {
103 int i;
104
105 /* r0 - r31 */
106 for (i = 0; i < 32; i++)
107 supply_register (regcache, R0_REGNUM + i,
108 buf + offsetof (usr_econtext_t, uec_iregs[i]));
109
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));
123 }
124
125 /* The fill_function for the floating-point register set. */
126
127 static void
128 lynx_ppc_fill_fpregset (struct regcache *regcache, char *buf)
129 {
130 int i;
131
132 /* f0 - f31 */
133 for (i = 0; i < 32; i++)
134 collect_register (regcache, F0_REGNUM + i,
135 buf + offsetof (usr_fcontext_t, ufc_freg[i]));
136
137 /* fpscr */
138 collect_register (regcache, FPSCR_REGNUM,
139 buf + offsetof (usr_fcontext_t, ufc_fpscr));
140 }
141
142 /* The store_function for the floating-point register set. */
143
144 static void
145 lynx_ppc_store_fpregset (struct regcache *regcache, const char *buf)
146 {
147 int i;
148
149 /* f0 - f31 */
150 for (i = 0; i < 32; i++)
151 supply_register (regcache, F0_REGNUM + i,
152 buf + offsetof (usr_fcontext_t, ufc_freg[i]));
153
154 /* fpscr */
155 supply_register (regcache, FPSCR_REGNUM,
156 buf + offsetof (usr_fcontext_t, ufc_fpscr));
157 }
158
159 /* Implements the lynx_target_ops.arch_setup routine. */
160
161 static void
162 lynx_ppc_arch_setup (void)
163 {
164 init_registers_powerpc_32 ();
165 lynx_tdesc = tdesc_powerpc_32;
166 }
167
168 /* Description of all the powerpc-lynx register sets. */
169
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 }
179 };
180
181 /* The lynx_target_ops vector for powerpc-lynxos. */
182
183 struct lynx_target_ops the_low_target = {
184 lynx_ppc_arch_setup,
185 };
usr_econtext_s::uec_xer
uint32_t uec_xer
Definition: lynx-ppc-low.c:37
usr_econtext_s::uec_dar
uint32_t uec_dar
Definition: lynx-ppc-low.c:38
collect_register
void collect_register(struct regcache *regcache, int n, void *buf)
Definition: regcache.c:402
usr_econtext_s::uec_cr
uint32_t uec_cr
Definition: lynx-ppc-low.c:36
MSR_REGNUM
#define MSR_REGNUM
Definition: lynx-ppc-low.c:60
usr_econtext_s::uec_msr
uint32_t uec_msr
Definition: lynx-ppc-low.c:40
usr_fcontext_s::ufc_fpscr
uint32_t ufc_fpscr[2]
Definition: lynx-ppc-low.c:53
usr_econtext_s::uec_srr1
uint32_t uec_srr1
Definition: lynx-ppc-low.c:33
usr_econtext_s::uec_ctr
uint32_t uec_ctr
Definition: lynx-ppc-low.c:35
FPSCR_REGNUM
#define FPSCR_REGNUM
Definition: lynx-ppc-low.c:65
CTR_REGNUM
#define CTR_REGNUM
Definition: lynx-ppc-low.c:63
regcache
Definition: regcache.h:31
usr_econtext_s::uec_ss_count
uint32_t uec_ss_count
Definition: lynx-ppc-low.c:42
usr_econtext_s::uec_srr0
uint32_t uec_srr0
Definition: lynx-ppc-low.c:32
PC_REGNUM
#define PC_REGNUM
Definition: lynx-ppc-low.c:59
usr_econtext_s::uec_lr
uint32_t uec_lr
Definition: lynx-ppc-low.c:34
the_low_target
struct lynx_target_ops the_low_target
Definition: lynx-ppc-low.c:183
lynx_target_ops
Definition: lynx-low.h:44
usr_econtext_s::uec_sregs
uint32_t uec_sregs[16]
Definition: lynx-ppc-low.c:41
lynx_ppc_fill_fpregset
static void lynx_ppc_fill_fpregset(struct regcache *regcache, char *buf)
Definition: lynx-ppc-low.c:128
F0_REGNUM
#define F0_REGNUM
Definition: lynx-ppc-low.c:58
LR_REGNUM
#define LR_REGNUM
Definition: lynx-ppc-low.c:62
usr_econtext_s::uec_ss_code2
uint32_t uec_ss_code2
Definition: lynx-ppc-low.c:46
CR_REGNUM
#define CR_REGNUM
Definition: lynx-ppc-low.c:61
lynx_tdesc
const struct target_desc * lynx_tdesc
Definition: lynx-low.c:36
usr_fcontext_s::ufc_freg
uint64_t ufc_freg[32]
Definition: lynx-ppc-low.c:52
tdesc_powerpc_32
const struct target_desc * tdesc_powerpc_32
init_registers_powerpc_32
void init_registers_powerpc_32(void)
server.h
lynx_ppc_fill_gregset
static void lynx_ppc_fill_gregset(struct regcache *regcache, char *buf)
Definition: lynx-ppc-low.c:74
usr_econtext_s::uec_ss_addr2
uint32_t uec_ss_addr2
Definition: lynx-ppc-low.c:44
lynx_target_regsets
struct lynx_regset_info lynx_target_regsets[]
Definition: lynx-ppc-low.c:170
lynx_ppc_store_gregset
static void lynx_ppc_store_gregset(struct regcache *regcache, const char *buf)
Definition: lynx-ppc-low.c:101
lynx_ppc_arch_setup
static void lynx_ppc_arch_setup(void)
Definition: lynx-ppc-low.c:162
usr_econtext_s::uec_ss_code1
uint32_t uec_ss_code1
Definition: lynx-ppc-low.c:45
usr_econtext_s
Definition: lynx-ppc-low.c:28
lynx_ppc_store_fpregset
static void lynx_ppc_store_fpregset(struct regcache *regcache, const char *buf)
Definition: lynx-ppc-low.c:145
usr_econtext_s::uec_iregs
uint32_t uec_iregs[32]
Definition: lynx-ppc-low.c:30
usr_econtext_s::uec_ss_addr1
uint32_t uec_ss_addr1
Definition: lynx-ppc-low.c:43
XER_REGNUM
#define XER_REGNUM
Definition: lynx-ppc-low.c:64
usr_econtext_s::uec_inum
uint32_t uec_inum
Definition: lynx-ppc-low.c:31
target_desc
Definition: tdesc.h:33
usr_fcontext_s
Definition: lynx-ppc-low.c:50
lynx-low.h
usr_fcontext
Definition: lynx-i386-low.c:55
limits.h
lynx_regset_info
Definition: lynx-low.h:23
supply_register
void supply_register(struct regcache *regcache, int n, const void *buf)
Definition: regcache.c:318
usr_econtext_t
struct usr_econtext_s usr_econtext_t
usr_econtext
Definition: lynx-i386-low.c:30
usr_econtext_s::uec_mq
uint32_t uec_mq
Definition: lynx-ppc-low.c:39
R0_REGNUM
#define R0_REGNUM
Definition: lynx-ppc-low.c:57
usr_fcontext_t
struct usr_fcontext_s usr_fcontext_t