S390: Enable re-attaching with native-extended-gdbserver
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-s390-low.c
1 /* GNU/Linux S/390 specific low level interface, for the remote server
2 for GDB.
3 Copyright (C) 2001-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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 3 of the License, or
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* This file is used for both 31-bit and 64-bit S/390 systems. */
21
22 #include "server.h"
23 #include "linux-low.h"
24 #include "elf/common.h"
25 #include "ax.h"
26 #include "tracepoint.h"
27
28 #include <asm/ptrace.h>
29 #include "nat/gdb_ptrace.h"
30 #include <sys/uio.h>
31 #include <elf.h>
32 #include <inttypes.h>
33
34 #include "linux-s390-tdesc.h"
35
36 #ifndef HWCAP_S390_HIGH_GPRS
37 #define HWCAP_S390_HIGH_GPRS 512
38 #endif
39
40 #ifndef HWCAP_S390_TE
41 #define HWCAP_S390_TE 1024
42 #endif
43
44 #ifndef HWCAP_S390_VX
45 #define HWCAP_S390_VX 2048
46 #endif
47
48 #ifndef HWCAP_S390_GS
49 #define HWCAP_S390_GS 16384
50 #endif
51
52 #define s390_num_regs 52
53
54 static int s390_regmap[] = {
55 PT_PSWMASK, PT_PSWADDR,
56
57 PT_GPR0, PT_GPR1, PT_GPR2, PT_GPR3,
58 PT_GPR4, PT_GPR5, PT_GPR6, PT_GPR7,
59 PT_GPR8, PT_GPR9, PT_GPR10, PT_GPR11,
60 PT_GPR12, PT_GPR13, PT_GPR14, PT_GPR15,
61
62 PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
63 PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
64 PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
65 PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
66
67 PT_FPC,
68
69 #ifndef __s390x__
70 PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI,
71 PT_FPR4_HI, PT_FPR5_HI, PT_FPR6_HI, PT_FPR7_HI,
72 PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
73 PT_FPR12_HI, PT_FPR13_HI, PT_FPR14_HI, PT_FPR15_HI,
74 #else
75 PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3,
76 PT_FPR4, PT_FPR5, PT_FPR6, PT_FPR7,
77 PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
78 PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
79 #endif
80
81 PT_ORIGGPR2,
82 };
83
84 #define s390_num_regs_3264 68
85
86 #ifdef __s390x__
87 static int s390_regmap_3264[] = {
88 PT_PSWMASK, PT_PSWADDR,
89
90 PT_GPR0, PT_GPR0, PT_GPR1, PT_GPR1,
91 PT_GPR2, PT_GPR2, PT_GPR3, PT_GPR3,
92 PT_GPR4, PT_GPR4, PT_GPR5, PT_GPR5,
93 PT_GPR6, PT_GPR6, PT_GPR7, PT_GPR7,
94 PT_GPR8, PT_GPR8, PT_GPR9, PT_GPR9,
95 PT_GPR10, PT_GPR10, PT_GPR11, PT_GPR11,
96 PT_GPR12, PT_GPR12, PT_GPR13, PT_GPR13,
97 PT_GPR14, PT_GPR14, PT_GPR15, PT_GPR15,
98
99 PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
100 PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
101 PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
102 PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
103
104 PT_FPC,
105
106 PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3,
107 PT_FPR4, PT_FPR5, PT_FPR6, PT_FPR7,
108 PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
109 PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
110
111 PT_ORIGGPR2,
112 };
113 #else
114 static int s390_regmap_3264[] = {
115 PT_PSWMASK, PT_PSWADDR,
116
117 -1, PT_GPR0, -1, PT_GPR1,
118 -1, PT_GPR2, -1, PT_GPR3,
119 -1, PT_GPR4, -1, PT_GPR5,
120 -1, PT_GPR6, -1, PT_GPR7,
121 -1, PT_GPR8, -1, PT_GPR9,
122 -1, PT_GPR10, -1, PT_GPR11,
123 -1, PT_GPR12, -1, PT_GPR13,
124 -1, PT_GPR14, -1, PT_GPR15,
125
126 PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
127 PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
128 PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
129 PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
130
131 PT_FPC,
132
133 PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI,
134 PT_FPR4_HI, PT_FPR5_HI, PT_FPR6_HI, PT_FPR7_HI,
135 PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
136 PT_FPR12_HI, PT_FPR13_HI, PT_FPR14_HI, PT_FPR15_HI,
137
138 PT_ORIGGPR2,
139 };
140 #endif
141
142
143 static int
144 s390_cannot_fetch_register (int regno)
145 {
146 return 0;
147 }
148
149 static int
150 s390_cannot_store_register (int regno)
151 {
152 return 0;
153 }
154
155 static void
156 s390_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
157 {
158 int size = register_size (regcache->tdesc, regno);
159 const struct regs_info *regs_info = (*the_low_target.regs_info) ();
160 struct usrregs_info *usr = regs_info->usrregs;
161 int regaddr = usr->regmap[regno];
162
163 if (size < sizeof (long))
164 {
165 memset (buf, 0, sizeof (long));
166
167 if ((regno ^ 1) < usr->num_regs
168 && usr->regmap[regno ^ 1] == regaddr)
169 {
170 collect_register (regcache, regno & ~1, buf);
171 collect_register (regcache, (regno & ~1) + 1,
172 buf + sizeof (long) - size);
173 }
174 else if (regaddr == PT_PSWMASK)
175 {
176 /* Convert 4-byte PSW mask to 8 bytes by clearing bit 12 and copying
177 the basic addressing mode bit from the PSW address. */
178 gdb_byte *addr = (gdb_byte *) alloca (register_size (regcache->tdesc, regno ^ 1));
179 collect_register (regcache, regno, buf);
180 collect_register (regcache, regno ^ 1, addr);
181 buf[1] &= ~0x8;
182 buf[size] |= (addr[0] & 0x80);
183 }
184 else if (regaddr == PT_PSWADDR)
185 {
186 /* Convert 4-byte PSW address to 8 bytes by clearing the addressing
187 mode bit (which gets copied to the PSW mask instead). */
188 collect_register (regcache, regno, buf + sizeof (long) - size);
189 buf[sizeof (long) - size] &= ~0x80;
190 }
191 else if ((regaddr >= PT_GPR0 && regaddr <= PT_GPR15)
192 || regaddr == PT_ORIGGPR2)
193 collect_register (regcache, regno, buf + sizeof (long) - size);
194 else
195 collect_register (regcache, regno, buf);
196 }
197 else if (regaddr != -1)
198 collect_register (regcache, regno, buf);
199 }
200
201 static void
202 s390_supply_ptrace_register (struct regcache *regcache,
203 int regno, const char *buf)
204 {
205 int size = register_size (regcache->tdesc, regno);
206 const struct regs_info *regs_info = (*the_low_target.regs_info) ();
207 struct usrregs_info *usr = regs_info->usrregs;
208 int regaddr = usr->regmap[regno];
209
210 if (size < sizeof (long))
211 {
212 if ((regno ^ 1) < usr->num_regs
213 && usr->regmap[regno ^ 1] == regaddr)
214 {
215 supply_register (regcache, regno & ~1, buf);
216 supply_register (regcache, (regno & ~1) + 1,
217 buf + sizeof (long) - size);
218 }
219 else if (regaddr == PT_PSWMASK)
220 {
221 /* Convert 8-byte PSW mask to 4 bytes by setting bit 12 and copying
222 the basic addressing mode into the PSW address. */
223 gdb_byte *mask = (gdb_byte *) alloca (size);
224 gdb_byte *addr = (gdb_byte *) alloca (register_size (regcache->tdesc, regno ^ 1));
225 memcpy (mask, buf, size);
226 mask[1] |= 0x8;
227 supply_register (regcache, regno, mask);
228
229 collect_register (regcache, regno ^ 1, addr);
230 addr[0] &= ~0x80;
231 addr[0] |= (buf[size] & 0x80);
232 supply_register (regcache, regno ^ 1, addr);
233 }
234 else if (regaddr == PT_PSWADDR)
235 {
236 /* Convert 8-byte PSW address to 4 bytes by truncating, but
237 keeping the addressing mode bit (which was set from the mask). */
238 gdb_byte *addr = (gdb_byte *) alloca (size);
239 char amode;
240 collect_register (regcache, regno, addr);
241 amode = addr[0] & 0x80;
242 memcpy (addr, buf + sizeof (long) - size, size);
243 addr[0] &= ~0x80;
244 addr[0] |= amode;
245 supply_register (regcache, regno, addr);
246 }
247 else if ((regaddr >= PT_GPR0 && regaddr <= PT_GPR15)
248 || regaddr == PT_ORIGGPR2)
249 supply_register (regcache, regno, buf + sizeof (long) - size);
250 else
251 supply_register (regcache, regno, buf);
252 }
253 else if (regaddr != -1)
254 supply_register (regcache, regno, buf);
255 }
256
257 /* Provide only a fill function for the general register set. ps_lgetregs
258 will use this for NPTL support. */
259
260 static void
261 s390_fill_gregset (struct regcache *regcache, void *buf)
262 {
263 int i;
264 const struct regs_info *regs_info = (*the_low_target.regs_info) ();
265 struct usrregs_info *usr = regs_info->usrregs;
266
267 for (i = 0; i < usr->num_regs; i++)
268 {
269 if (usr->regmap[i] < PT_PSWMASK
270 || usr->regmap[i] > PT_ACR15)
271 continue;
272
273 s390_collect_ptrace_register (regcache, i,
274 (char *) buf + usr->regmap[i]);
275 }
276 }
277
278 /* Fill and store functions for extended register sets. */
279
280 #ifndef __s390x__
281 static void
282 s390_fill_gprs_high (struct regcache *regcache, void *buf)
283 {
284 int r0h = find_regno (regcache->tdesc, "r0h");
285 int i;
286
287 for (i = 0; i < 16; i++)
288 collect_register (regcache, r0h + 2 * i, (char *) buf + 4 * i);
289 }
290
291 static void
292 s390_store_gprs_high (struct regcache *regcache, const void *buf)
293 {
294 int r0h = find_regno (regcache->tdesc, "r0h");
295 int i;
296
297 for (i = 0; i < 16; i++)
298 supply_register (regcache, r0h + 2 * i, (const char *) buf + 4 * i);
299 }
300 #endif
301
302 static void
303 s390_store_last_break (struct regcache *regcache, const void *buf)
304 {
305 const char *p;
306
307 p = (const char *) buf + 8 - register_size (regcache->tdesc, 0);
308 supply_register_by_name (regcache, "last_break", p);
309 }
310
311 static void
312 s390_fill_system_call (struct regcache *regcache, void *buf)
313 {
314 collect_register_by_name (regcache, "system_call", buf);
315 }
316
317 static void
318 s390_store_system_call (struct regcache *regcache, const void *buf)
319 {
320 supply_register_by_name (regcache, "system_call", buf);
321 }
322
323 static void
324 s390_store_tdb (struct regcache *regcache, const void *buf)
325 {
326 int tdb0 = find_regno (regcache->tdesc, "tdb0");
327 int tr0 = find_regno (regcache->tdesc, "tr0");
328 int i;
329
330 for (i = 0; i < 4; i++)
331 supply_register (regcache, tdb0 + i, (const char *) buf + 8 * i);
332
333 for (i = 0; i < 16; i++)
334 supply_register (regcache, tr0 + i, (const char *) buf + 8 * (16 + i));
335 }
336
337 static void
338 s390_fill_vxrs_low (struct regcache *regcache, void *buf)
339 {
340 int v0 = find_regno (regcache->tdesc, "v0l");
341 int i;
342
343 for (i = 0; i < 16; i++)
344 collect_register (regcache, v0 + i, (char *) buf + 8 * i);
345 }
346
347 static void
348 s390_store_vxrs_low (struct regcache *regcache, const void *buf)
349 {
350 int v0 = find_regno (regcache->tdesc, "v0l");
351 int i;
352
353 for (i = 0; i < 16; i++)
354 supply_register (regcache, v0 + i, (const char *) buf + 8 * i);
355 }
356
357 static void
358 s390_fill_vxrs_high (struct regcache *regcache, void *buf)
359 {
360 int v16 = find_regno (regcache->tdesc, "v16");
361 int i;
362
363 for (i = 0; i < 16; i++)
364 collect_register (regcache, v16 + i, (char *) buf + 16 * i);
365 }
366
367 static void
368 s390_store_vxrs_high (struct regcache *regcache, const void *buf)
369 {
370 int v16 = find_regno (regcache->tdesc, "v16");
371 int i;
372
373 for (i = 0; i < 16; i++)
374 supply_register (regcache, v16 + i, (const char *) buf + 16 * i);
375 }
376
377 static void
378 s390_fill_gs (struct regcache *regcache, void *buf)
379 {
380 int gsd = find_regno (regcache->tdesc, "gsd");
381 int i;
382
383 for (i = 0; i < 3; i++)
384 collect_register (regcache, gsd + i, (char *) buf + 8 * (i + 1));
385 }
386
387 static void
388 s390_store_gs (struct regcache *regcache, const void *buf)
389 {
390 int gsd = find_regno (regcache->tdesc, "gsd");
391 int i;
392
393 for (i = 0; i < 3; i++)
394 supply_register (regcache, gsd + i, (const char *) buf + 8 * (i + 1));
395 }
396
397 static void
398 s390_fill_gsbc (struct regcache *regcache, void *buf)
399 {
400 int bc_gsd = find_regno (regcache->tdesc, "bc_gsd");
401 int i;
402
403 for (i = 0; i < 3; i++)
404 collect_register (regcache, bc_gsd + i, (char *) buf + 8 * (i + 1));
405 }
406
407 static void
408 s390_store_gsbc (struct regcache *regcache, const void *buf)
409 {
410 int bc_gsd = find_regno (regcache->tdesc, "bc_gsd");
411 int i;
412
413 for (i = 0; i < 3; i++)
414 supply_register (regcache, bc_gsd + i, (const char *) buf + 8 * (i + 1));
415 }
416
417 static struct regset_info s390_regsets[] = {
418 { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
419 #ifndef __s390x__
420 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_HIGH_GPRS, 0,
421 EXTENDED_REGS, s390_fill_gprs_high, s390_store_gprs_high },
422 #endif
423 /* Last break address is read-only; no fill function. */
424 { PTRACE_GETREGSET, -1, NT_S390_LAST_BREAK, 0, EXTENDED_REGS,
425 NULL, s390_store_last_break },
426 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0,
427 EXTENDED_REGS, s390_fill_system_call, s390_store_system_call },
428 /* TDB is read-only. */
429 { PTRACE_GETREGSET, -1, NT_S390_TDB, 0, EXTENDED_REGS,
430 NULL, s390_store_tdb },
431 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_LOW, 0,
432 EXTENDED_REGS, s390_fill_vxrs_low, s390_store_vxrs_low },
433 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_HIGH, 0,
434 EXTENDED_REGS, s390_fill_vxrs_high, s390_store_vxrs_high },
435 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_GS_CB, 0,
436 EXTENDED_REGS, s390_fill_gs, s390_store_gs },
437 { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_GS_BC, 0,
438 EXTENDED_REGS, s390_fill_gsbc, s390_store_gsbc },
439 NULL_REGSET
440 };
441
442
443 static const gdb_byte s390_breakpoint[] = { 0, 1 };
444 #define s390_breakpoint_len 2
445
446 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
447
448 static const gdb_byte *
449 s390_sw_breakpoint_from_kind (int kind, int *size)
450 {
451 *size = s390_breakpoint_len;
452 return s390_breakpoint;
453 }
454
455 static CORE_ADDR
456 s390_get_pc (struct regcache *regcache)
457 {
458 if (register_size (regcache->tdesc, 0) == 4)
459 {
460 unsigned int pswa;
461 collect_register_by_name (regcache, "pswa", &pswa);
462 return pswa & 0x7fffffff;
463 }
464 else
465 {
466 unsigned long pc;
467 collect_register_by_name (regcache, "pswa", &pc);
468 return pc;
469 }
470 }
471
472 static void
473 s390_set_pc (struct regcache *regcache, CORE_ADDR newpc)
474 {
475 if (register_size (regcache->tdesc, 0) == 4)
476 {
477 unsigned int pswa;
478 collect_register_by_name (regcache, "pswa", &pswa);
479 pswa = (pswa & 0x80000000) | (newpc & 0x7fffffff);
480 supply_register_by_name (regcache, "pswa", &pswa);
481 }
482 else
483 {
484 unsigned long pc = newpc;
485 supply_register_by_name (regcache, "pswa", &pc);
486 }
487 }
488
489 /* Get HWCAP from AUXV, using the given WORDSIZE. Return the HWCAP, or
490 zero if not found. */
491
492 static unsigned long
493 s390_get_hwcap (int wordsize)
494 {
495 gdb_byte *data = (gdb_byte *) alloca (2 * wordsize);
496 int offset = 0;
497
498 while ((*the_target->read_auxv) (offset, data, 2 * wordsize) == 2 * wordsize)
499 {
500 if (wordsize == 4)
501 {
502 unsigned int *data_p = (unsigned int *)data;
503 if (data_p[0] == AT_HWCAP)
504 return data_p[1];
505 }
506 else
507 {
508 unsigned long *data_p = (unsigned long *)data;
509 if (data_p[0] == AT_HWCAP)
510 return data_p[1];
511 }
512
513 offset += 2 * wordsize;
514 }
515
516 return 0;
517 }
518
519 /* Determine the word size for the given PID, in bytes. */
520
521 #ifdef __s390x__
522 static int
523 s390_get_wordsize (int pid)
524 {
525 errno = 0;
526 PTRACE_XFER_TYPE pswm = ptrace (PTRACE_PEEKUSER, pid,
527 (PTRACE_TYPE_ARG3) 0,
528 (PTRACE_TYPE_ARG4) 0);
529 if (errno != 0) {
530 warning (_("Couldn't determine word size, assuming 64-bit.\n"));
531 return 8;
532 }
533 /* Derive word size from extended addressing mode (PSW bit 31). */
534 return pswm & (1L << 32) ? 8 : 4;
535 }
536 #else
537 #define s390_get_wordsize(pid) 4
538 #endif
539
540 static int
541 s390_check_regset (int pid, int regset, int regsize)
542 {
543 void *buf = alloca (regsize);
544 struct iovec iov;
545
546 iov.iov_base = buf;
547 iov.iov_len = regsize;
548
549 if (ptrace (PTRACE_GETREGSET, pid, (long) regset, (long) &iov) >= 0
550 || errno == ENODATA)
551 return 1;
552 return 0;
553 }
554
555 /* For a 31-bit inferior, whether the kernel supports using the full
556 64-bit GPRs. */
557 static int have_hwcap_s390_high_gprs = 0;
558 static int have_hwcap_s390_vx = 0;
559
560 static void
561 s390_arch_setup (void)
562 {
563 const struct target_desc *tdesc;
564 struct regset_info *regset;
565
566 /* Determine word size and HWCAP. */
567 int pid = pid_of (current_thread);
568 int wordsize = s390_get_wordsize (pid);
569 unsigned long hwcap = s390_get_hwcap (wordsize);
570
571 /* Check whether the kernel supports extra register sets. */
572 int have_regset_last_break
573 = s390_check_regset (pid, NT_S390_LAST_BREAK, 8);
574 int have_regset_system_call
575 = s390_check_regset (pid, NT_S390_SYSTEM_CALL, 4);
576 int have_regset_tdb
577 = (s390_check_regset (pid, NT_S390_TDB, 256)
578 && (hwcap & HWCAP_S390_TE) != 0);
579 int have_regset_vxrs
580 = (s390_check_regset (pid, NT_S390_VXRS_LOW, 128)
581 && s390_check_regset (pid, NT_S390_VXRS_HIGH, 256)
582 && (hwcap & HWCAP_S390_VX) != 0);
583 int have_regset_gs
584 = (s390_check_regset (pid, NT_S390_GS_CB, 32)
585 && s390_check_regset (pid, NT_S390_GS_BC, 32)
586 && (hwcap & HWCAP_S390_GS) != 0);
587
588 {
589 #ifdef __s390x__
590 if (wordsize == 8)
591 {
592 if (have_regset_gs)
593 tdesc = tdesc_s390x_gs_linux64;
594 else if (have_regset_vxrs)
595 tdesc = (have_regset_tdb ? tdesc_s390x_tevx_linux64 :
596 tdesc_s390x_vx_linux64);
597 else if (have_regset_tdb)
598 tdesc = tdesc_s390x_te_linux64;
599 else if (have_regset_system_call)
600 tdesc = tdesc_s390x_linux64v2;
601 else if (have_regset_last_break)
602 tdesc = tdesc_s390x_linux64v1;
603 else
604 tdesc = tdesc_s390x_linux64;
605 }
606
607 /* For a 31-bit inferior, check whether the kernel supports
608 using the full 64-bit GPRs. */
609 else
610 #endif
611 if (hwcap & HWCAP_S390_HIGH_GPRS)
612 {
613 have_hwcap_s390_high_gprs = 1;
614 if (have_regset_gs)
615 tdesc = tdesc_s390_gs_linux64;
616 else if (have_regset_vxrs)
617 tdesc = (have_regset_tdb ? tdesc_s390_tevx_linux64 :
618 tdesc_s390_vx_linux64);
619 else if (have_regset_tdb)
620 tdesc = tdesc_s390_te_linux64;
621 else if (have_regset_system_call)
622 tdesc = tdesc_s390_linux64v2;
623 else if (have_regset_last_break)
624 tdesc = tdesc_s390_linux64v1;
625 else
626 tdesc = tdesc_s390_linux64;
627 }
628 else
629 {
630 /* Assume 31-bit inferior process. */
631 if (have_regset_system_call)
632 tdesc = tdesc_s390_linux32v2;
633 else if (have_regset_last_break)
634 tdesc = tdesc_s390_linux32v1;
635 else
636 tdesc = tdesc_s390_linux32;
637 }
638
639 have_hwcap_s390_vx = have_regset_vxrs;
640 }
641
642 /* Update target_regsets according to available register sets. */
643 for (regset = s390_regsets; regset->size >= 0; regset++)
644 if (regset->get_request == PTRACE_GETREGSET)
645 switch (regset->nt_type)
646 {
647 #ifndef __s390x__
648 case NT_S390_HIGH_GPRS:
649 regset->size = have_hwcap_s390_high_gprs ? 64 : 0;
650 break;
651 #endif
652 case NT_S390_LAST_BREAK:
653 regset->size = have_regset_last_break ? 8 : 0;
654 break;
655 case NT_S390_SYSTEM_CALL:
656 regset->size = have_regset_system_call ? 4 : 0;
657 break;
658 case NT_S390_TDB:
659 regset->size = have_regset_tdb ? 256 : 0;
660 break;
661 case NT_S390_VXRS_LOW:
662 regset->size = have_regset_vxrs ? 128 : 0;
663 break;
664 case NT_S390_VXRS_HIGH:
665 regset->size = have_regset_vxrs ? 256 : 0;
666 break;
667 case NT_S390_GS_CB:
668 case NT_S390_GS_BC:
669 regset->size = have_regset_gs ? 32 : 0;
670 default:
671 break;
672 }
673
674 current_process ()->tdesc = tdesc;
675 }
676
677
678 static int
679 s390_breakpoint_at (CORE_ADDR pc)
680 {
681 unsigned char c[s390_breakpoint_len];
682 read_inferior_memory (pc, c, s390_breakpoint_len);
683 return memcmp (c, s390_breakpoint, s390_breakpoint_len) == 0;
684 }
685
686 /* Breakpoint/Watchpoint support. */
687
688 /* The "supports_z_point_type" linux_target_ops method. */
689
690 static int
691 s390_supports_z_point_type (char z_type)
692 {
693 switch (z_type)
694 {
695 case Z_PACKET_SW_BP:
696 return 1;
697 default:
698 return 0;
699 }
700 }
701
702 /* Support for hardware single step. */
703
704 static int
705 s390_supports_hardware_single_step (void)
706 {
707 return 1;
708 }
709
710 static struct usrregs_info s390_usrregs_info =
711 {
712 s390_num_regs,
713 s390_regmap,
714 };
715
716 static struct regsets_info s390_regsets_info =
717 {
718 s390_regsets, /* regsets */
719 0, /* num_regsets */
720 NULL, /* disabled_regsets */
721 };
722
723 static struct regs_info regs_info =
724 {
725 NULL, /* regset_bitmap */
726 &s390_usrregs_info,
727 &s390_regsets_info
728 };
729
730 static struct usrregs_info s390_usrregs_info_3264 =
731 {
732 s390_num_regs_3264,
733 s390_regmap_3264
734 };
735
736 static struct regsets_info s390_regsets_info_3264 =
737 {
738 s390_regsets, /* regsets */
739 0, /* num_regsets */
740 NULL, /* disabled_regsets */
741 };
742
743 static struct regs_info regs_info_3264 =
744 {
745 NULL, /* regset_bitmap */
746 &s390_usrregs_info_3264,
747 &s390_regsets_info_3264
748 };
749
750 static const struct regs_info *
751 s390_regs_info (void)
752 {
753 if (have_hwcap_s390_high_gprs)
754 {
755 #ifdef __s390x__
756 const struct target_desc *tdesc = current_process ()->tdesc;
757
758 if (register_size (tdesc, 0) == 4)
759 return &regs_info_3264;
760 #else
761 return &regs_info_3264;
762 #endif
763 }
764 return &regs_info;
765 }
766
767 /* The "supports_tracepoints" linux_target_ops method. */
768
769 static int
770 s390_supports_tracepoints (void)
771 {
772 return 1;
773 }
774
775 /* Implementation of linux_target_ops method "get_thread_area". */
776
777 static int
778 s390_get_thread_area (int lwpid, CORE_ADDR *addrp)
779 {
780 CORE_ADDR res = ptrace (PTRACE_PEEKUSER, lwpid, (long) PT_ACR0, (long) 0);
781 #ifdef __s390x__
782 struct regcache *regcache = get_thread_regcache (current_thread, 0);
783
784 if (register_size (regcache->tdesc, 0) == 4)
785 res &= 0xffffffffull;
786 #endif
787 *addrp = res;
788 return 0;
789 }
790
791
792 /* Fast tracepoint support.
793
794 The register save area on stack is identical for all targets:
795
796 0x000+i*0x10: VR0-VR31
797 0x200+i*8: GR0-GR15
798 0x280+i*4: AR0-AR15
799 0x2c0: PSWM [64-bit]
800 0x2c8: PSWA [64-bit]
801 0x2d0: FPC
802
803 If we're on 31-bit linux, we just don't store the high parts of the GPRs.
804 Likewise, if there's no VX support, we just store the FRs into the slots
805 of low VR halves. The agent code is responsible for rearranging that
806 into regcache. */
807
808 /* Code sequence saving GPRs for 31-bit target with no high GPRs. There's
809 one trick used at the very beginning: since there's no way to allocate
810 stack space without destroying CC (lay instruction can do it, but it's
811 only supported on later CPUs), we take 4 different execution paths for
812 every possible value of CC, allocate stack space, save %r0, stuff the
813 CC value in %r0 (shifted to match its position in PSWM high word),
814 then branch to common path. */
815
816 static const unsigned char s390_ft_entry_gpr_esa[] = {
817 0xa7, 0x14, 0x00, 0x1e, /* jo .Lcc3 */
818 0xa7, 0x24, 0x00, 0x14, /* jh .Lcc2 */
819 0xa7, 0x44, 0x00, 0x0a, /* jl .Lcc1 */
820 /* CC = 0 */
821 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
822 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
823 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
824 0xa7, 0xf4, 0x00, 0x18, /* j .Lccdone */
825 /* .Lcc1: */
826 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
827 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
828 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
829 0xa7, 0xf4, 0x00, 0x10, /* j .Lccdone */
830 /* .Lcc2: */
831 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
832 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
833 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
834 0xa7, 0xf4, 0x00, 0x08, /* j .Lccdone */
835 /* .Lcc3: */
836 0xa7, 0xfa, 0xfd, 0x00, /* ahi %r15, -0x300 */
837 0x50, 0x00, 0xf2, 0x04, /* st %r0, 0x204(%r15) */
838 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
839 /* .Lccdone: */
840 0x50, 0x10, 0xf2, 0x0c, /* st %r1, 0x20c(%r15) */
841 0x50, 0x20, 0xf2, 0x14, /* st %r2, 0x214(%r15) */
842 0x50, 0x30, 0xf2, 0x1c, /* st %r3, 0x21c(%r15) */
843 0x50, 0x40, 0xf2, 0x24, /* st %r4, 0x224(%r15) */
844 0x50, 0x50, 0xf2, 0x2c, /* st %r5, 0x22c(%r15) */
845 0x50, 0x60, 0xf2, 0x34, /* st %r6, 0x234(%r15) */
846 0x50, 0x70, 0xf2, 0x3c, /* st %r7, 0x23c(%r15) */
847 0x50, 0x80, 0xf2, 0x44, /* st %r8, 0x244(%r15) */
848 0x50, 0x90, 0xf2, 0x4c, /* st %r9, 0x24c(%r15) */
849 0x50, 0xa0, 0xf2, 0x54, /* st %r10, 0x254(%r15) */
850 0x50, 0xb0, 0xf2, 0x5c, /* st %r11, 0x25c(%r15) */
851 0x50, 0xc0, 0xf2, 0x64, /* st %r12, 0x264(%r15) */
852 0x50, 0xd0, 0xf2, 0x6c, /* st %r13, 0x26c(%r15) */
853 0x50, 0xe0, 0xf2, 0x74, /* st %r14, 0x274(%r15) */
854 /* Compute original value of %r15 and store it. We use ahi instead
855 of la to preserve the whole value, and not just the low 31 bits.
856 This is not particularly important here, but essential in the
857 zarch case where someone might be using the high word of %r15
858 as an extra register. */
859 0x18, 0x1f, /* lr %r1, %r15 */
860 0xa7, 0x1a, 0x03, 0x00, /* ahi %r1, 0x300 */
861 0x50, 0x10, 0xf2, 0x7c, /* st %r1, 0x27c(%r15) */
862 };
863
864 /* Code sequence saving GPRs for 31-bit target with high GPRs and for 64-bit
865 target. Same as above, except this time we can use load/store multiple,
866 since the 64-bit regs are tightly packed. */
867
868 static const unsigned char s390_ft_entry_gpr_zarch[] = {
869 0xa7, 0x14, 0x00, 0x21, /* jo .Lcc3 */
870 0xa7, 0x24, 0x00, 0x16, /* jh .Lcc2 */
871 0xa7, 0x44, 0x00, 0x0b, /* jl .Lcc1 */
872 /* CC = 0 */
873 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
874 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
875 0xa7, 0x08, 0x00, 0x00, /* lhi %r0, 0 */
876 0xa7, 0xf4, 0x00, 0x1b, /* j .Lccdone */
877 /* .Lcc1: */
878 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
879 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
880 0xa7, 0x08, 0x10, 0x00, /* lhi %r0, 0x1000 */
881 0xa7, 0xf4, 0x00, 0x12, /* j .Lccdone */
882 /* .Lcc2: */
883 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
884 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
885 0xa7, 0x08, 0x20, 0x00, /* lhi %r0, 0x2000 */
886 0xa7, 0xf4, 0x00, 0x09, /* j .Lccdone */
887 /* .Lcc3: */
888 0xa7, 0xfb, 0xfd, 0x00, /* aghi %r15, -0x300 */
889 0xeb, 0x0e, 0xf2, 0x00, 0x00, 0x24, /* stmg %r0, %r14, 0x200(%r15) */
890 0xa7, 0x08, 0x30, 0x00, /* lhi %r0, 0x3000 */
891 /* .Lccdone: */
892 0xb9, 0x04, 0x00, 0x1f, /* lgr %r1, %r15 */
893 0xa7, 0x1b, 0x03, 0x00, /* aghi %r1, 0x300 */
894 0xe3, 0x10, 0xf2, 0x78, 0x00, 0x24, /* stg %r1, 0x278(%r15) */
895 };
896
897 /* Code sequence saving ARs, PSWM and FPC. PSWM has to be assembled from
898 current PSWM (read by epsw) and CC from entry (in %r0). */
899
900 static const unsigned char s390_ft_entry_misc[] = {
901 0x9b, 0x0f, 0xf2, 0x80, /* stam %a0, %a15, 0x20(%%r15) */
902 0xb9, 0x8d, 0x00, 0x23, /* epsw %r2, %r3 */
903 0xa7, 0x18, 0xcf, 0xff, /* lhi %r1, ~0x3000 */
904 0x14, 0x21, /* nr %r2, %r1 */
905 0x16, 0x20, /* or %r2, %r0 */
906 0x50, 0x20, 0xf2, 0xc0, /* st %r2, 0x2c0(%r15) */
907 0x50, 0x30, 0xf2, 0xc4, /* st %r3, 0x2c4(%r15) */
908 0xb2, 0x9c, 0xf2, 0xd0, /* stfpc 0x2d0(%r15) */
909 };
910
911 /* Code sequence saving FRs, used if VX not supported. */
912
913 static const unsigned char s390_ft_entry_fr[] = {
914 0x60, 0x00, 0xf0, 0x00, /* std %f0, 0x000(%r15) */
915 0x60, 0x10, 0xf0, 0x10, /* std %f1, 0x010(%r15) */
916 0x60, 0x20, 0xf0, 0x20, /* std %f2, 0x020(%r15) */
917 0x60, 0x30, 0xf0, 0x30, /* std %f3, 0x030(%r15) */
918 0x60, 0x40, 0xf0, 0x40, /* std %f4, 0x040(%r15) */
919 0x60, 0x50, 0xf0, 0x50, /* std %f5, 0x050(%r15) */
920 0x60, 0x60, 0xf0, 0x60, /* std %f6, 0x060(%r15) */
921 0x60, 0x70, 0xf0, 0x70, /* std %f7, 0x070(%r15) */
922 0x60, 0x80, 0xf0, 0x80, /* std %f8, 0x080(%r15) */
923 0x60, 0x90, 0xf0, 0x90, /* std %f9, 0x090(%r15) */
924 0x60, 0xa0, 0xf0, 0xa0, /* std %f10, 0x0a0(%r15) */
925 0x60, 0xb0, 0xf0, 0xb0, /* std %f11, 0x0b0(%r15) */
926 0x60, 0xc0, 0xf0, 0xc0, /* std %f12, 0x0c0(%r15) */
927 0x60, 0xd0, 0xf0, 0xd0, /* std %f13, 0x0d0(%r15) */
928 0x60, 0xe0, 0xf0, 0xe0, /* std %f14, 0x0e0(%r15) */
929 0x60, 0xf0, 0xf0, 0xf0, /* std %f15, 0x0f0(%r15) */
930 };
931
932 /* Code sequence saving VRs, used if VX not supported. */
933
934 static const unsigned char s390_ft_entry_vr[] = {
935 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x3e, /* vstm %v0, %v15, 0x000(%r15) */
936 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x3e, /* vstm %v16, %v31, 0x100(%r15) */
937 };
938
939 /* Code sequence doing the collection call for 31-bit target. %r1 contains
940 the address of the literal pool. */
941
942 static const unsigned char s390_ft_main_31[] = {
943 /* Load the literals into registers. */
944 0x58, 0x50, 0x10, 0x00, /* l %r5, 0x0(%r1) */
945 0x58, 0x20, 0x10, 0x04, /* l %r2, 0x4(%r1) */
946 0x58, 0x40, 0x10, 0x08, /* l %r4, 0x8(%r1) */
947 0x58, 0x60, 0x10, 0x0c, /* l %r6, 0xc(%r1) */
948 /* Save original PSWA (tracepoint address | 0x80000000). */
949 0x50, 0x50, 0xf2, 0xcc, /* st %r5, 0x2cc(%r15) */
950 /* Construct a collecting_t object at %r15+0x2e0. */
951 0x50, 0x20, 0xf2, 0xe0, /* st %r2, 0x2e0(%r15) */
952 0x9b, 0x00, 0xf2, 0xe4, /* stam %a0, %a0, 0x2e4(%r15) */
953 /* Move its address to %r0. */
954 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
955 /* Take the lock. */
956 /* .Lloop: */
957 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
958 0xba, 0x10, 0x60, 0x00, /* cs %r1, %r0, 0(%r6) */
959 0xa7, 0x74, 0xff, 0xfc, /* jne .Lloop */
960 /* Address of the register save block to %r3. */
961 0x18, 0x3f, /* lr %r3, %r15 */
962 /* Make a stack frame, so that we can call the collector. */
963 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
964 /* Call it. */
965 0x0d, 0xe4, /* basr %r14, %r4 */
966 /* And get rid of the stack frame again. */
967 0x41, 0xf0, 0xf0, 0x60, /* la %r15, 0x60(%r15) */
968 /* Leave the lock. */
969 0x07, 0xf0, /* br %r0 */
970 0xa7, 0x18, 0x00, 0x00, /* lhi %r1, 0 */
971 0x50, 0x10, 0x60, 0x00, /* st %t1, 0(%r6) */
972 };
973
974 /* Code sequence doing the collection call for 64-bit target. %r1 contains
975 the address of the literal pool. */
976
977 static const unsigned char s390_ft_main_64[] = {
978 /* Load the literals into registers. */
979 0xe3, 0x50, 0x10, 0x00, 0x00, 0x04, /* lg %r5, 0x00(%r1) */
980 0xe3, 0x20, 0x10, 0x08, 0x00, 0x04, /* lg %r2, 0x08(%r1) */
981 0xe3, 0x40, 0x10, 0x10, 0x00, 0x04, /* lg %r4, 0x10(%r1) */
982 0xe3, 0x60, 0x10, 0x18, 0x00, 0x04, /* lg %r6, 0x18(%r1) */
983 /* Save original PSWA (tracepoint address). */
984 0xe3, 0x50, 0xf2, 0xc8, 0x00, 0x24, /* stg %r5, 0x2c8(%r15) */
985 /* Construct a collecting_t object at %r15+0x2e0. */
986 0xe3, 0x20, 0xf2, 0xe0, 0x00, 0x24, /* stg %r2, 0x2e0(%r15) */
987 0x9b, 0x01, 0xf2, 0xe8, /* stam %a0, %a1, 0x2e8(%r15) */
988 /* Move its address to %r0. */
989 0x41, 0x00, 0xf2, 0xe0, /* la %r0, 0x2e0(%r15) */
990 /* Take the lock. */
991 /* .Lloop: */
992 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
993 0xeb, 0x10, 0x60, 0x00, 0x00, 0x30, /* csg %r1, %r0, 0(%r6) */
994 0xa7, 0x74, 0xff, 0xfb, /* jne .Lloop */
995 /* Address of the register save block to %r3. */
996 0xb9, 0x04, 0x00, 0x3f, /* lgr %r3, %r15 */
997 /* Make a stack frame, so that we can call the collector. */
998 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
999 /* Call it. */
1000 0x0d, 0xe4, /* basr %r14, %r4 */
1001 /* And get rid of the stack frame again. */
1002 0x41, 0xf0, 0xf0, 0xa0, /* la %r15, 0xa0(%r15) */
1003 /* Leave the lock. */
1004 0x07, 0xf0, /* br %r0 */
1005 0xa7, 0x19, 0x00, 0x00, /* lghi %r1, 0 */
1006 0xe3, 0x10, 0x60, 0x00, 0x00, 0x24, /* stg %t1, 0(%r6) */
1007 };
1008
1009 /* Code sequence restoring FRs, for targets with no VX support. */
1010
1011 static const unsigned char s390_ft_exit_fr[] = {
1012 0x68, 0x00, 0xf0, 0x00, /* ld %f0, 0x000(%r15) */
1013 0x68, 0x10, 0xf0, 0x10, /* ld %f1, 0x010(%r15) */
1014 0x68, 0x20, 0xf0, 0x20, /* ld %f2, 0x020(%r15) */
1015 0x68, 0x30, 0xf0, 0x30, /* ld %f3, 0x030(%r15) */
1016 0x68, 0x40, 0xf0, 0x40, /* ld %f4, 0x040(%r15) */
1017 0x68, 0x50, 0xf0, 0x50, /* ld %f5, 0x050(%r15) */
1018 0x68, 0x60, 0xf0, 0x60, /* ld %f6, 0x060(%r15) */
1019 0x68, 0x70, 0xf0, 0x70, /* ld %f7, 0x070(%r15) */
1020 0x68, 0x80, 0xf0, 0x80, /* ld %f8, 0x080(%r15) */
1021 0x68, 0x90, 0xf0, 0x90, /* ld %f9, 0x090(%r15) */
1022 0x68, 0xa0, 0xf0, 0xa0, /* ld %f10, 0x0a0(%r15) */
1023 0x68, 0xb0, 0xf0, 0xb0, /* ld %f11, 0x0b0(%r15) */
1024 0x68, 0xc0, 0xf0, 0xc0, /* ld %f12, 0x0c0(%r15) */
1025 0x68, 0xd0, 0xf0, 0xd0, /* ld %f13, 0x0d0(%r15) */
1026 0x68, 0xe0, 0xf0, 0xe0, /* ld %f14, 0x0e0(%r15) */
1027 0x68, 0xf0, 0xf0, 0xf0, /* ld %f15, 0x0f0(%r15) */
1028 };
1029
1030 /* Code sequence restoring VRs. */
1031
1032 static const unsigned char s390_ft_exit_vr[] = {
1033 0xe7, 0x0f, 0xf0, 0x00, 0x00, 0x36, /* vlm %v0, %v15, 0x000(%r15) */
1034 0xe7, 0x0f, 0xf1, 0x00, 0x0c, 0x36, /* vlm %v16, %v31, 0x100(%r15) */
1035 };
1036
1037 /* Code sequence restoring misc registers. As for PSWM, only CC should be
1038 modified by C code, so we use the alr instruction to restore it by
1039 manufacturing an operand that'll result in the original flags. */
1040
1041 static const unsigned char s390_ft_exit_misc[] = {
1042 0xb2, 0x9d, 0xf2, 0xd0, /* lfpc 0x2d0(%r15) */
1043 0x58, 0x00, 0xf2, 0xc0, /* l %r0, 0x2c0(%r15) */
1044 /* Extract CC to high 2 bits of %r0. */
1045 0x88, 0x00, 0x00, 0x0c, /* srl %r0, 12 */
1046 0x89, 0x00, 0x00, 0x1e, /* sll %r0, 30 */
1047 /* Add %r0 to itself. Result will be nonzero iff CC bit 0 is set, and
1048 will have carry iff CC bit 1 is set - resulting in the same flags
1049 as the original. */
1050 0x1e, 0x00, /* alr %r0, %r0 */
1051 0x9a, 0x0f, 0xf2, 0x80, /* lam %a0, %a15, 0x280(%r15) */
1052 };
1053
1054 /* Code sequence restoring GPRs, for 31-bit targets with no high GPRs. */
1055
1056 static const unsigned char s390_ft_exit_gpr_esa[] = {
1057 0x58, 0x00, 0xf2, 0x04, /* l %r0, 0x204(%r15) */
1058 0x58, 0x10, 0xf2, 0x0c, /* l %r1, 0x20c(%r15) */
1059 0x58, 0x20, 0xf2, 0x14, /* l %r2, 0x214(%r15) */
1060 0x58, 0x30, 0xf2, 0x1c, /* l %r3, 0x21c(%r15) */
1061 0x58, 0x40, 0xf2, 0x24, /* l %r4, 0x224(%r15) */
1062 0x58, 0x50, 0xf2, 0x2c, /* l %r5, 0x22c(%r15) */
1063 0x58, 0x60, 0xf2, 0x34, /* l %r6, 0x234(%r15) */
1064 0x58, 0x70, 0xf2, 0x3c, /* l %r7, 0x23c(%r15) */
1065 0x58, 0x80, 0xf2, 0x44, /* l %r8, 0x244(%r15) */
1066 0x58, 0x90, 0xf2, 0x4c, /* l %r9, 0x24c(%r15) */
1067 0x58, 0xa0, 0xf2, 0x54, /* l %r10, 0x254(%r15) */
1068 0x58, 0xb0, 0xf2, 0x5c, /* l %r11, 0x25c(%r15) */
1069 0x58, 0xc0, 0xf2, 0x64, /* l %r12, 0x264(%r15) */
1070 0x58, 0xd0, 0xf2, 0x6c, /* l %r13, 0x26c(%r15) */
1071 0x58, 0xe0, 0xf2, 0x74, /* l %r14, 0x274(%r15) */
1072 0x58, 0xf0, 0xf2, 0x7c, /* l %r15, 0x27c(%r15) */
1073 };
1074
1075 /* Code sequence restoring GPRs, for 64-bit targets and 31-bit targets
1076 with high GPRs. */
1077
1078 static const unsigned char s390_ft_exit_gpr_zarch[] = {
1079 0xeb, 0x0f, 0xf2, 0x00, 0x00, 0x04, /* lmg %r0, %r15, 0x200(%r15) */
1080 };
1081
1082 /* Writes instructions to target, updating the to pointer. */
1083
1084 static void
1085 append_insns (CORE_ADDR *to, size_t len, const unsigned char *buf)
1086 {
1087 write_inferior_memory (*to, buf, len);
1088 *to += len;
1089 }
1090
1091 /* Relocates an instruction from oldloc to *to, updating to. */
1092
1093 static int
1094 s390_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc, int is_64)
1095 {
1096 gdb_byte buf[6];
1097 int ilen;
1098 int op2;
1099 /* 0: no fixup, 1: PC16DBL fixup, 2: PC32DBL fixup. */
1100 int mode = 0;
1101 int is_bras = 0;
1102 read_inferior_memory (oldloc, buf, sizeof buf);
1103 if (buf[0] < 0x40)
1104 ilen = 2;
1105 else if (buf[0] < 0xc0)
1106 ilen = 4;
1107 else
1108 ilen = 6;
1109 switch (buf[0])
1110 {
1111 case 0x05: /* BALR */
1112 case 0x0c: /* BASSM */
1113 case 0x0d: /* BASR */
1114 case 0x45: /* BAL */
1115 case 0x4d: /* BAS */
1116 /* These save a return address and mess around with registers.
1117 We can't relocate them. */
1118 return 1;
1119 case 0x84: /* BRXH */
1120 case 0x85: /* BRXLE */
1121 mode = 1;
1122 break;
1123 case 0xa7:
1124 op2 = buf[1] & 0xf;
1125 /* BRC, BRAS, BRCT, BRCTG */
1126 if (op2 >= 4 && op2 <= 7)
1127 mode = 1;
1128 /* BRAS */
1129 if (op2 == 5)
1130 is_bras = 1;
1131 break;
1132 case 0xc0:
1133 op2 = buf[1] & 0xf;
1134 /* LARL, BRCL, BRASL */
1135 if (op2 == 0 || op2 == 4 || op2 == 5)
1136 mode = 2;
1137 /* BRASL */
1138 if (op2 == 5)
1139 is_bras = 1;
1140 break;
1141 case 0xc4:
1142 case 0xc6:
1143 /* PC-relative addressing instructions. */
1144 mode = 2;
1145 break;
1146 case 0xc5: /* BPRP */
1147 case 0xc7: /* BPP */
1148 /* Branch prediction - just skip it. */
1149 return 0;
1150 case 0xcc:
1151 op2 = buf[1] & 0xf;
1152 /* BRCTH */
1153 if (op2 == 6)
1154 mode = 2;
1155 break;
1156 case 0xec:
1157 op2 = buf[5];
1158 switch (op2)
1159 {
1160 case 0x44: /* BRXHG */
1161 case 0x45: /* BRXLG */
1162 case 0x64: /* CGRJ */
1163 case 0x65: /* CLGRJ */
1164 case 0x76: /* CRJ */
1165 case 0x77: /* CLRJ */
1166 mode = 1;
1167 break;
1168 }
1169 break;
1170 }
1171
1172 if (mode != 0)
1173 {
1174 /* We'll have to relocate an instruction with a PC-relative field.
1175 First, compute the target. */
1176 int64_t loffset = 0;
1177 CORE_ADDR target;
1178 if (mode == 1)
1179 {
1180 int16_t soffset = 0;
1181 memcpy (&soffset, buf + 2, 2);
1182 loffset = soffset;
1183 }
1184 else if (mode == 2)
1185 {
1186 int32_t soffset = 0;
1187 memcpy (&soffset, buf + 2, 4);
1188 loffset = soffset;
1189 }
1190 target = oldloc + loffset * 2;
1191 if (!is_64)
1192 target &= 0x7fffffff;
1193
1194 if (is_bras)
1195 {
1196 /* BRAS or BRASL was used. We cannot just relocate those, since
1197 they save the return address in a register. We can, however,
1198 replace them with a LARL+JG sequence. */
1199
1200 /* Make the LARL. */
1201 int32_t soffset;
1202 buf[0] = 0xc0;
1203 buf[1] &= 0xf0;
1204 loffset = oldloc + ilen - *to;
1205 loffset >>= 1;
1206 soffset = loffset;
1207 if (soffset != loffset && is_64)
1208 return 1;
1209 memcpy (buf + 2, &soffset, 4);
1210 append_insns (to, 6, buf);
1211
1212 /* Note: this is not fully correct. In 31-bit mode, LARL will write
1213 an address with the top bit 0, while BRAS/BRASL will write it
1214 with top bit 1. It should not matter much, since linux compilers
1215 use BR and not BSM to return from functions, but it could confuse
1216 some poor stack unwinder. */
1217
1218 /* We'll now be writing a JG. */
1219 mode = 2;
1220 buf[0] = 0xc0;
1221 buf[1] = 0xf4;
1222 ilen = 6;
1223 }
1224
1225 /* Compute the new offset and write it to the buffer. */
1226 loffset = target - *to;
1227 loffset >>= 1;
1228
1229 if (mode == 1)
1230 {
1231 int16_t soffset = loffset;
1232 if (soffset != loffset)
1233 return 1;
1234 memcpy (buf + 2, &soffset, 2);
1235 }
1236 else if (mode == 2)
1237 {
1238 int32_t soffset = loffset;
1239 if (soffset != loffset && is_64)
1240 return 1;
1241 memcpy (buf + 2, &soffset, 4);
1242 }
1243 }
1244 append_insns (to, ilen, buf);
1245 return 0;
1246 }
1247
1248 /* Implementation of linux_target_ops method
1249 "install_fast_tracepoint_jump_pad". */
1250
1251 static int
1252 s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
1253 CORE_ADDR tpaddr,
1254 CORE_ADDR collector,
1255 CORE_ADDR lockaddr,
1256 ULONGEST orig_size,
1257 CORE_ADDR *jump_entry,
1258 CORE_ADDR *trampoline,
1259 ULONGEST *trampoline_size,
1260 unsigned char *jjump_pad_insn,
1261 ULONGEST *jjump_pad_insn_size,
1262 CORE_ADDR *adjusted_insn_addr,
1263 CORE_ADDR *adjusted_insn_addr_end,
1264 char *err)
1265 {
1266 int i;
1267 int64_t loffset;
1268 int32_t offset;
1269 unsigned char jbuf[6] = { 0xc0, 0xf4, 0, 0, 0, 0 }; /* jg ... */
1270 CORE_ADDR buildaddr = *jump_entry;
1271 #ifdef __s390x__
1272 struct regcache *regcache = get_thread_regcache (current_thread, 0);
1273 int is_64 = register_size (regcache->tdesc, 0) == 8;
1274 int is_zarch = is_64 || have_hwcap_s390_high_gprs;
1275 int has_vx = have_hwcap_s390_vx;
1276 #else
1277 int is_64 = 0, is_zarch = 0, has_vx = 0;
1278 #endif
1279 CORE_ADDR literals[4] = {
1280 tpaddr,
1281 tpoint,
1282 collector,
1283 lockaddr,
1284 };
1285
1286 /* First, store the GPRs. */
1287 if (is_zarch)
1288 append_insns (&buildaddr, sizeof s390_ft_entry_gpr_zarch,
1289 s390_ft_entry_gpr_zarch);
1290 else
1291 append_insns (&buildaddr, sizeof s390_ft_entry_gpr_esa,
1292 s390_ft_entry_gpr_esa);
1293
1294 /* Second, misc registers (ARs, PSWM, FPC). PSWA will be stored below. */
1295 append_insns (&buildaddr, sizeof s390_ft_entry_misc, s390_ft_entry_misc);
1296
1297 /* Third, FRs or VRs. */
1298 if (has_vx)
1299 append_insns (&buildaddr, sizeof s390_ft_entry_vr, s390_ft_entry_vr);
1300 else
1301 append_insns (&buildaddr, sizeof s390_ft_entry_fr, s390_ft_entry_fr);
1302
1303 /* Now, the main part of code - store PSWA, take lock, call collector,
1304 leave lock. First, we'll need to fetch 4 literals. */
1305 if (is_64) {
1306 unsigned char buf[] = {
1307 0x07, 0x07, /* nopr %r7 */
1308 0x07, 0x07, /* nopr %r7 */
1309 0x07, 0x07, /* nopr %r7 */
1310 0xa7, 0x15, 0x00, 0x12, /* bras %r1, .Lend */
1311 0, 0, 0, 0, 0, 0, 0, 0, /* tpaddr */
1312 0, 0, 0, 0, 0, 0, 0, 0, /* tpoint */
1313 0, 0, 0, 0, 0, 0, 0, 0, /* collector */
1314 0, 0, 0, 0, 0, 0, 0, 0, /* lockaddr */
1315 /* .Lend: */
1316 };
1317 /* Find the proper start place in buf, so that literals will be
1318 aligned. */
1319 int bufpos = (buildaddr + 2) & 7;
1320 /* Stuff the literals into the buffer. */
1321 for (i = 0; i < 4; i++) {
1322 uint64_t lit = literals[i];
1323 memcpy (&buf[sizeof buf - 32 + i * 8], &lit, 8);
1324 }
1325 append_insns (&buildaddr, sizeof buf - bufpos, buf + bufpos);
1326 append_insns (&buildaddr, sizeof s390_ft_main_64, s390_ft_main_64);
1327 } else {
1328 unsigned char buf[] = {
1329 0x07, 0x07, /* nopr %r7 */
1330 0xa7, 0x15, 0x00, 0x0a, /* bras %r1, .Lend */
1331 0, 0, 0, 0, /* tpaddr */
1332 0, 0, 0, 0, /* tpoint */
1333 0, 0, 0, 0, /* collector */
1334 0, 0, 0, 0, /* lockaddr */
1335 /* .Lend: */
1336 };
1337 /* Find the proper start place in buf, so that literals will be
1338 aligned. */
1339 int bufpos = (buildaddr + 2) & 3;
1340 /* First literal will be saved as the PSWA, make sure it has the high bit
1341 set. */
1342 literals[0] |= 0x80000000;
1343 /* Stuff the literals into the buffer. */
1344 for (i = 0; i < 4; i++) {
1345 uint32_t lit = literals[i];
1346 memcpy (&buf[sizeof buf - 16 + i * 4], &lit, 4);
1347 }
1348 append_insns (&buildaddr, sizeof buf - bufpos, buf + bufpos);
1349 append_insns (&buildaddr, sizeof s390_ft_main_31, s390_ft_main_31);
1350 }
1351
1352 /* Restore FRs or VRs. */
1353 if (has_vx)
1354 append_insns (&buildaddr, sizeof s390_ft_exit_vr, s390_ft_exit_vr);
1355 else
1356 append_insns (&buildaddr, sizeof s390_ft_exit_fr, s390_ft_exit_fr);
1357
1358 /* Restore misc registers. */
1359 append_insns (&buildaddr, sizeof s390_ft_exit_misc, s390_ft_exit_misc);
1360
1361 /* Restore the GPRs. */
1362 if (is_zarch)
1363 append_insns (&buildaddr, sizeof s390_ft_exit_gpr_zarch,
1364 s390_ft_exit_gpr_zarch);
1365 else
1366 append_insns (&buildaddr, sizeof s390_ft_exit_gpr_esa,
1367 s390_ft_exit_gpr_esa);
1368
1369 /* Now, adjust the original instruction to execute in the jump
1370 pad. */
1371 *adjusted_insn_addr = buildaddr;
1372 if (s390_relocate_instruction (&buildaddr, tpaddr, is_64))
1373 {
1374 sprintf (err, "E.Could not relocate instruction for tracepoint.");
1375 return 1;
1376 }
1377 *adjusted_insn_addr_end = buildaddr;
1378
1379 /* Finally, write a jump back to the program. */
1380
1381 loffset = (tpaddr + orig_size) - buildaddr;
1382 loffset >>= 1;
1383 offset = loffset;
1384 if (is_64 && offset != loffset)
1385 {
1386 sprintf (err,
1387 "E.Jump back from jump pad too far from tracepoint "
1388 "(offset 0x%" PRIx64 " > int33).", loffset);
1389 return 1;
1390 }
1391 memcpy (jbuf + 2, &offset, 4);
1392 append_insns (&buildaddr, sizeof jbuf, jbuf);
1393
1394 /* The jump pad is now built. Wire in a jump to our jump pad. This
1395 is always done last (by our caller actually), so that we can
1396 install fast tracepoints with threads running. This relies on
1397 the agent's atomic write support. */
1398 loffset = *jump_entry - tpaddr;
1399 loffset >>= 1;
1400 offset = loffset;
1401 if (is_64 && offset != loffset)
1402 {
1403 sprintf (err,
1404 "E.Jump back from jump pad too far from tracepoint "
1405 "(offset 0x%" PRIx64 " > int33).", loffset);
1406 return 1;
1407 }
1408 memcpy (jbuf + 2, &offset, 4);
1409 memcpy (jjump_pad_insn, jbuf, sizeof jbuf);
1410 *jjump_pad_insn_size = sizeof jbuf;
1411
1412 /* Return the end address of our pad. */
1413 *jump_entry = buildaddr;
1414
1415 return 0;
1416 }
1417
1418 /* Implementation of linux_target_ops method
1419 "get_min_fast_tracepoint_insn_len". */
1420
1421 static int
1422 s390_get_min_fast_tracepoint_insn_len (void)
1423 {
1424 /* We only support using 6-byte jumps to reach the tracepoint code.
1425 If the tracepoint buffer were allocated sufficiently close (64kiB)
1426 to the executable code, and the traced instruction itself was close
1427 enough to the beginning, we could use 4-byte jumps, but this doesn't
1428 seem to be worth the effort. */
1429 return 6;
1430 }
1431
1432 /* Implementation of linux_target_ops method "get_ipa_tdesc_idx". */
1433
1434 static int
1435 s390_get_ipa_tdesc_idx (void)
1436 {
1437 struct regcache *regcache = get_thread_regcache (current_thread, 0);
1438 const struct target_desc *tdesc = regcache->tdesc;
1439
1440 #ifdef __s390x__
1441 if (tdesc == tdesc_s390x_linux64)
1442 return S390_TDESC_64;
1443 if (tdesc == tdesc_s390x_linux64v1)
1444 return S390_TDESC_64V1;
1445 if (tdesc == tdesc_s390x_linux64v2)
1446 return S390_TDESC_64V2;
1447 if (tdesc == tdesc_s390x_te_linux64)
1448 return S390_TDESC_TE;
1449 if (tdesc == tdesc_s390x_vx_linux64)
1450 return S390_TDESC_VX;
1451 if (tdesc == tdesc_s390x_tevx_linux64)
1452 return S390_TDESC_TEVX;
1453 #endif
1454
1455 if (tdesc == tdesc_s390_linux32)
1456 return S390_TDESC_32;
1457 if (tdesc == tdesc_s390_linux32v1)
1458 return S390_TDESC_32V1;
1459 if (tdesc == tdesc_s390_linux32v2)
1460 return S390_TDESC_32V2;
1461 if (tdesc == tdesc_s390_linux64)
1462 return S390_TDESC_64;
1463 if (tdesc == tdesc_s390_linux64v1)
1464 return S390_TDESC_64V1;
1465 if (tdesc == tdesc_s390_linux64v2)
1466 return S390_TDESC_64V2;
1467 if (tdesc == tdesc_s390_te_linux64)
1468 return S390_TDESC_TE;
1469 if (tdesc == tdesc_s390_vx_linux64)
1470 return S390_TDESC_VX;
1471 if (tdesc == tdesc_s390_tevx_linux64)
1472 return S390_TDESC_TEVX;
1473
1474 return 0;
1475 }
1476
1477 /* Appends given buffer to current_insn_ptr in the target. */
1478
1479 static void
1480 add_insns (const unsigned char *start, int len)
1481 {
1482 CORE_ADDR buildaddr = current_insn_ptr;
1483
1484 if (debug_threads)
1485 debug_printf ("Adding %d bytes of insn at %s\n",
1486 len, paddress (buildaddr));
1487
1488 append_insns (&buildaddr, len, start);
1489 current_insn_ptr = buildaddr;
1490 }
1491
1492 /* Register usage in emit:
1493
1494 - %r0, %r1: temp
1495 - %r2: top of stack (high word for 31-bit)
1496 - %r3: low word of top of stack (for 31-bit)
1497 - %r4, %r5: temp
1498 - %r6, %r7, %r8: don't use
1499 - %r9: saved arg1
1500 - %r10: saved arg2
1501 - %r11: frame pointer
1502 - %r12: saved top of stack for void_call_2 (high word for 31-bit)
1503 - %r13: low word of saved top of stack (for 31-bit)
1504 - %r14: return address for calls
1505 - %r15: stack pointer
1506
1507 */
1508
1509 /* The "emit_prologue" emit_ops method for s390. */
1510
1511 static void
1512 s390_emit_prologue (void)
1513 {
1514 static const unsigned char buf[] = {
1515 0x90, 0x9f, 0xf0, 0x24, /* stm %r9, %r15, 0x24(%r15) */
1516 0x18, 0x92, /* lr %r9, %r2 */
1517 0x18, 0xa3, /* lr %r10, %r3 */
1518 0x18, 0xbf, /* lr %r11, %r15 */
1519 };
1520 add_insns (buf, sizeof buf);
1521 }
1522
1523 /* The "emit_epilogue" emit_ops method for s390. */
1524
1525 static void
1526 s390_emit_epilogue (void)
1527 {
1528 static const unsigned char buf[] = {
1529 0x90, 0x23, 0xa0, 0x00, /* stm %r2, %r3, 0(%r10) */
1530 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1531 0x98, 0x9f, 0xb0, 0x24, /* lm %r9, %r15, 0x24(%r11) */
1532 0x07, 0xfe, /* br %r14 */
1533 };
1534 add_insns (buf, sizeof buf);
1535 }
1536
1537 /* The "emit_add" emit_ops method for s390. */
1538
1539 static void
1540 s390_emit_add (void)
1541 {
1542 static const unsigned char buf[] = {
1543 0x5e, 0x30, 0xf0, 0x04, /* al %r3, 4(%r15) */
1544 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x98, /* al %r2, 0(%r15) */
1545 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1546 };
1547 add_insns (buf, sizeof buf);
1548 }
1549
1550 /* The "emit_sub" emit_ops method for s390. */
1551
1552 static void
1553 s390_emit_sub (void)
1554 {
1555 static const unsigned char buf[] = {
1556 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
1557 0x1f, 0x53, /* slr %r5, %r3 */
1558 0xb9, 0x99, 0x00, 0x42, /* slbr %r4, %r2 */
1559 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1560 0x18, 0x35, /* lr %r3, %r5 */
1561 0x18, 0x24, /* lr %r2, %r4 */
1562 };
1563 add_insns (buf, sizeof buf);
1564 }
1565
1566 /* The "emit_mul" emit_ops method for s390. */
1567
1568 static void
1569 s390_emit_mul (void)
1570 {
1571 emit_error = 1;
1572 }
1573
1574 /* The "emit_lsh" emit_ops method for s390. */
1575
1576 static void
1577 s390_emit_lsh (void)
1578 {
1579 static const unsigned char buf[] = {
1580 0x18, 0x43, /* lr %r4, %r3 */
1581 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1582 0x8d, 0x20, 0x40, 0x00, /* sldl %r2, 0(%r4) */
1583 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1584 };
1585 add_insns (buf, sizeof buf);
1586 }
1587
1588 /* The "emit_rsh_signed" emit_ops method for s390. */
1589
1590 static void
1591 s390_emit_rsh_signed (void)
1592 {
1593 static const unsigned char buf[] = {
1594 0x18, 0x43, /* lr %r4, %r3 */
1595 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1596 0x8e, 0x20, 0x40, 0x00, /* srda %r2, 0(%r4) */
1597 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1598 };
1599 add_insns (buf, sizeof buf);
1600 }
1601
1602 /* The "emit_rsh_unsigned" emit_ops method for s390. */
1603
1604 static void
1605 s390_emit_rsh_unsigned (void)
1606 {
1607 static const unsigned char buf[] = {
1608 0x18, 0x43, /* lr %r4, %r3 */
1609 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1610 0x8c, 0x20, 0x40, 0x00, /* srdl %r2, 0(%r4) */
1611 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1612 };
1613 add_insns (buf, sizeof buf);
1614 }
1615
1616 /* The "emit_ext" emit_ops method for s390. */
1617
1618 static void
1619 s390_emit_ext (int arg)
1620 {
1621 unsigned char buf[] = {
1622 0x8d, 0x20, 0x00, 64 - arg, /* sldl %r2, <64-arg> */
1623 0x8e, 0x20, 0x00, 64 - arg, /* srda %r2, <64-arg> */
1624 };
1625 add_insns (buf, sizeof buf);
1626 }
1627
1628 /* The "emit_log_not" emit_ops method for s390. */
1629
1630 static void
1631 s390_emit_log_not (void)
1632 {
1633 static const unsigned char buf[] = {
1634 0x16, 0x23, /* or %r2, %r3 */
1635 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1636 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1637 0xa7, 0x74, 0x00, 0x04, /* jne .Lskip */
1638 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1639 /* .Lskip: */
1640 };
1641 add_insns (buf, sizeof buf);
1642 }
1643
1644 /* The "emit_bit_and" emit_ops method for s390. */
1645
1646 static void
1647 s390_emit_bit_and (void)
1648 {
1649 static const unsigned char buf[] = {
1650 0x54, 0x20, 0xf0, 0x00, /* n %r2, 0(%r15) */
1651 0x54, 0x30, 0xf0, 0x04, /* n %r3, 4(%r15) */
1652 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1653 };
1654 add_insns (buf, sizeof buf);
1655 }
1656
1657 /* The "emit_bit_or" emit_ops method for s390. */
1658
1659 static void
1660 s390_emit_bit_or (void)
1661 {
1662 static const unsigned char buf[] = {
1663 0x56, 0x20, 0xf0, 0x00, /* o %r2, 0(%r15) */
1664 0x56, 0x30, 0xf0, 0x04, /* o %r3, 4(%r15) */
1665 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1666 };
1667 add_insns (buf, sizeof buf);
1668 }
1669
1670 /* The "emit_bit_xor" emit_ops method for s390. */
1671
1672 static void
1673 s390_emit_bit_xor (void)
1674 {
1675 static const unsigned char buf[] = {
1676 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
1677 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
1678 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1679 };
1680 add_insns (buf, sizeof buf);
1681 }
1682
1683 /* The "emit_bit_not" emit_ops method for s390. */
1684
1685 static void
1686 s390_emit_bit_not (void)
1687 {
1688 static const unsigned char buf[] = {
1689 0xa7, 0x48, 0xff, 0xff, /* lhi %r4, -1 */
1690 0x17, 0x24, /* xr %r2, %r4 */
1691 0x17, 0x34, /* xr %r3, %r4 */
1692 };
1693 add_insns (buf, sizeof buf);
1694 }
1695
1696 /* The "emit_equal" emit_ops method for s390. */
1697
1698 static void
1699 s390_emit_equal (void)
1700 {
1701 s390_emit_bit_xor ();
1702 s390_emit_log_not ();
1703 }
1704
1705 /* The "emit_less_signed" emit_ops method for s390. */
1706
1707 static void
1708 s390_emit_less_signed (void)
1709 {
1710 static const unsigned char buf[] = {
1711 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
1712 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
1713 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
1714 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
1715 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
1716 /* .Lhigh: */
1717 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1718 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
1719 /* .Lless: */
1720 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1721 /* .Lend: */
1722 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1723 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1724 };
1725 add_insns (buf, sizeof buf);
1726 }
1727
1728 /* The "emit_less_unsigned" emit_ops method for s390. */
1729
1730 static void
1731 s390_emit_less_unsigned (void)
1732 {
1733 static const unsigned char buf[] = {
1734 0x55, 0x20, 0xf0, 0x00, /* cl %r2, 0(%r15) */
1735 0xa7, 0x24, 0x00, 0x0c, /* jh .Lless */
1736 0xa7, 0x44, 0x00, 0x06, /* jl .Lhigh */
1737 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
1738 0xa7, 0x24, 0x00, 0x06, /* jh .Lless */
1739 /* .Lhigh: */
1740 0xa7, 0x38, 0x00, 0x00, /* lhi %r3, 0 */
1741 0xa7, 0xf4, 0x00, 0x04, /* j .Lend */
1742 /* .Lless: */
1743 0xa7, 0x38, 0x00, 0x01, /* lhi %r3, 1 */
1744 /* .Lend: */
1745 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1746 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1747 };
1748 add_insns (buf, sizeof buf);
1749 }
1750
1751 /* The "emit_ref" emit_ops method for s390. */
1752
1753 static void
1754 s390_emit_ref (int size)
1755 {
1756 static const unsigned char buf1[] = {
1757 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1758 0x43, 0x30, 0x30, 0x00, /* ic %r3, 0(%r3) */
1759 };
1760 static const unsigned char buf2[] = {
1761 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1762 0x48, 0x30, 0x30, 0x00, /* lh %r3, 0(%r3) */
1763 };
1764 static const unsigned char buf4[] = {
1765 0xa7, 0x28, 0x00, 0x00, /* lhi %r2, 0 */
1766 0x58, 0x30, 0x30, 0x00, /* l %r3, 0(%r3) */
1767 };
1768 static const unsigned char buf8[] = {
1769 0x98, 0x23, 0x30, 0x00, /* lm %r2, %r3, 0(%r3) */
1770 };
1771 switch (size)
1772 {
1773 case 1:
1774 add_insns (buf1, sizeof buf1);
1775 break;
1776 case 2:
1777 add_insns (buf2, sizeof buf2);
1778 break;
1779 case 4:
1780 add_insns (buf4, sizeof buf4);
1781 break;
1782 case 8:
1783 add_insns (buf8, sizeof buf8);
1784 break;
1785 default:
1786 emit_error = 1;
1787 }
1788 }
1789
1790 /* The "emit_if_goto" emit_ops method for s390. */
1791
1792 static void
1793 s390_emit_if_goto (int *offset_p, int *size_p)
1794 {
1795 static const unsigned char buf[] = {
1796 0x16, 0x23, /* or %r2, %r3 */
1797 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1798 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1799 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00 /* jgne <fillme> */
1800 };
1801 add_insns (buf, sizeof buf);
1802 if (offset_p)
1803 *offset_p = 12;
1804 if (size_p)
1805 *size_p = 4;
1806 }
1807
1808 /* The "emit_goto" emit_ops method for s390 and s390x. */
1809
1810 static void
1811 s390_emit_goto (int *offset_p, int *size_p)
1812 {
1813 static const unsigned char buf[] = {
1814 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
1815 };
1816 add_insns (buf, sizeof buf);
1817 if (offset_p)
1818 *offset_p = 2;
1819 if (size_p)
1820 *size_p = 4;
1821 }
1822
1823 /* The "write_goto_address" emit_ops method for s390 and s390x. */
1824
1825 static void
1826 s390_write_goto_address (CORE_ADDR from, CORE_ADDR to, int size)
1827 {
1828 long diff = ((long) (to - (from - 2))) / 2;
1829 int sdiff = diff;
1830 unsigned char buf[sizeof sdiff];
1831
1832 /* We're only doing 4-byte sizes at the moment. */
1833 if (size != sizeof sdiff || sdiff != diff)
1834 {
1835 emit_error = 1;
1836 return;
1837 }
1838
1839 memcpy (buf, &sdiff, sizeof sdiff);
1840 write_inferior_memory (from, buf, sizeof sdiff);
1841 }
1842
1843 /* Preparation for emitting a literal pool of given size. Loads the address
1844 of the pool into %r1, and jumps over it. Called should emit the pool data
1845 immediately afterwards. Used for both s390 and s390x. */
1846
1847 static void
1848 s390_emit_litpool (int size)
1849 {
1850 static const unsigned char nop[] = {
1851 0x07, 0x07,
1852 };
1853 unsigned char buf[] = {
1854 0xa7, 0x15, 0x00, (size + 4) / 2, /* bras %r1, .Lend+size */
1855 /* .Lend: */
1856 };
1857 if (size == 4)
1858 {
1859 /* buf needs to start at even halfword for litpool to be aligned */
1860 if (current_insn_ptr & 2)
1861 add_insns (nop, sizeof nop);
1862 }
1863 else
1864 {
1865 while ((current_insn_ptr & 6) != 4)
1866 add_insns (nop, sizeof nop);
1867 }
1868 add_insns (buf, sizeof buf);
1869 }
1870
1871 /* The "emit_const" emit_ops method for s390. */
1872
1873 static void
1874 s390_emit_const (LONGEST num)
1875 {
1876 unsigned long long n = num;
1877 unsigned char buf_s[] = {
1878 0xa7, 0x38, num >> 8, num, /* lhi %r3, <num> */
1879 0x17, 0x22, /* xr %r2, %r2 */
1880 };
1881 static const unsigned char buf_l[] = {
1882 0x98, 0x23, 0x10, 0x00, /* lm %r2, %r3, 0(%r1) */
1883 };
1884 if (num < 0x8000 && num >= 0)
1885 {
1886 add_insns (buf_s, sizeof buf_s);
1887 }
1888 else
1889 {
1890 s390_emit_litpool (8);
1891 add_insns ((unsigned char *) &n, sizeof n);
1892 add_insns (buf_l, sizeof buf_l);
1893 }
1894 }
1895
1896 /* The "emit_call" emit_ops method for s390. */
1897
1898 static void
1899 s390_emit_call (CORE_ADDR fn)
1900 {
1901 unsigned int n = fn;
1902 static const unsigned char buf[] = {
1903 0x58, 0x10, 0x10, 0x00, /* l %r1, 0(%r1) */
1904 0xa7, 0xfa, 0xff, 0xa0, /* ahi %r15, -0x60 */
1905 0x0d, 0xe1, /* basr %r14, %r1 */
1906 0xa7, 0xfa, 0x00, 0x60, /* ahi %r15, 0x60 */
1907 };
1908 s390_emit_litpool (4);
1909 add_insns ((unsigned char *) &n, sizeof n);
1910 add_insns (buf, sizeof buf);
1911 }
1912
1913 /* The "emit_reg" emit_ops method for s390. */
1914
1915 static void
1916 s390_emit_reg (int reg)
1917 {
1918 unsigned char bufpre[] = {
1919 0x18, 0x29, /* lr %r2, %r9 */
1920 0xa7, 0x38, reg >> 8, reg, /* lhi %r3, <reg> */
1921 };
1922 add_insns (bufpre, sizeof bufpre);
1923 s390_emit_call (get_raw_reg_func_addr ());
1924 }
1925
1926 /* The "emit_pop" emit_ops method for s390. */
1927
1928 static void
1929 s390_emit_pop (void)
1930 {
1931 static const unsigned char buf[] = {
1932 0x98, 0x23, 0xf0, 0x00, /* lm %r2, %r3, 0(%r15) */
1933 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
1934 };
1935 add_insns (buf, sizeof buf);
1936 }
1937
1938 /* The "emit_stack_flush" emit_ops method for s390. */
1939
1940 static void
1941 s390_emit_stack_flush (void)
1942 {
1943 static const unsigned char buf[] = {
1944 0xa7, 0xfa, 0xff, 0xf8, /* ahi %r15, -8 */
1945 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
1946 };
1947 add_insns (buf, sizeof buf);
1948 }
1949
1950 /* The "emit_zero_ext" emit_ops method for s390. */
1951
1952 static void
1953 s390_emit_zero_ext (int arg)
1954 {
1955 unsigned char buf[] = {
1956 0x8d, 0x20, 0x00, 64 - arg, /* sldl %r2, <64-arg> */
1957 0x8c, 0x20, 0x00, 64 - arg, /* srdl %r2, <64-arg> */
1958 };
1959 add_insns (buf, sizeof buf);
1960 }
1961
1962 /* The "emit_swap" emit_ops method for s390. */
1963
1964 static void
1965 s390_emit_swap (void)
1966 {
1967 static const unsigned char buf[] = {
1968 0x98, 0x45, 0xf0, 0x00, /* lm %r4, %r5, 0(%r15) */
1969 0x90, 0x23, 0xf0, 0x00, /* stm %r2, %r3, 0(%r15) */
1970 0x18, 0x24, /* lr %r2, %r4 */
1971 0x18, 0x35, /* lr %r3, %r5 */
1972 };
1973 add_insns (buf, sizeof buf);
1974 }
1975
1976 /* The "emit_stack_adjust" emit_ops method for s390. */
1977
1978 static void
1979 s390_emit_stack_adjust (int n)
1980 {
1981 unsigned char buf[] = {
1982 0xa7, 0xfa, n * 8 >> 8, n * 8, /* ahi %r15, 8*n */
1983 };
1984 add_insns (buf, sizeof buf);
1985 }
1986
1987 /* Sets %r2 to a 32-bit constant. */
1988
1989 static void
1990 s390_emit_set_r2 (int arg1)
1991 {
1992 unsigned char buf_s[] = {
1993 0xa7, 0x28, arg1 >> 8, arg1, /* lhi %r2, <arg1> */
1994 };
1995 static const unsigned char buf_l[] = {
1996 0x58, 0x20, 0x10, 0x00, /* l %r2, 0(%r1) */
1997 };
1998 if (arg1 < 0x8000 && arg1 >= -0x8000)
1999 {
2000 add_insns (buf_s, sizeof buf_s);
2001 }
2002 else
2003 {
2004 s390_emit_litpool (4);
2005 add_insns ((unsigned char *) &arg1, sizeof arg1);
2006 add_insns (buf_l, sizeof buf_l);
2007 }
2008 }
2009
2010 /* The "emit_int_call_1" emit_ops method for s390. */
2011
2012 static void
2013 s390_emit_int_call_1 (CORE_ADDR fn, int arg1)
2014 {
2015 /* FN's prototype is `LONGEST(*fn)(int)'. */
2016 s390_emit_set_r2 (arg1);
2017 s390_emit_call (fn);
2018 }
2019
2020 /* The "emit_void_call_2" emit_ops method for s390. */
2021
2022 static void
2023 s390_emit_void_call_2 (CORE_ADDR fn, int arg1)
2024 {
2025 /* FN's prototype is `void(*fn)(int,LONGEST)'. */
2026 static const unsigned char buf[] = {
2027 0x18, 0xc2, /* lr %r12, %r2 */
2028 0x18, 0xd3, /* lr %r13, %r3 */
2029 0x18, 0x43, /* lr %r4, %r3 */
2030 0x18, 0x32, /* lr %r3, %r2 */
2031 };
2032 static const unsigned char buf2[] = {
2033 0x18, 0x2c, /* lr %r2, %r12 */
2034 0x18, 0x3d, /* lr %r3, %r13 */
2035 };
2036 add_insns (buf, sizeof buf);
2037 s390_emit_set_r2 (arg1);
2038 s390_emit_call (fn);
2039 add_insns (buf2, sizeof buf2);
2040 }
2041
2042 /* The "emit_eq_goto" emit_ops method for s390. */
2043
2044 static void
2045 s390_emit_eq_goto (int *offset_p, int *size_p)
2046 {
2047 static const unsigned char buf[] = {
2048 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
2049 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
2050 0x16, 0x23, /* or %r2, %r3 */
2051 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2052 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2053 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
2054 };
2055 add_insns (buf, sizeof buf);
2056 if (offset_p)
2057 *offset_p = 20;
2058 if (size_p)
2059 *size_p = 4;
2060 }
2061
2062 /* The "emit_ne_goto" emit_ops method for s390. */
2063
2064 static void
2065 s390_emit_ne_goto (int *offset_p, int *size_p)
2066 {
2067 static const unsigned char buf[] = {
2068 0x57, 0x20, 0xf0, 0x00, /* x %r2, 0(%r15) */
2069 0x57, 0x30, 0xf0, 0x04, /* x %r3, 4(%r15) */
2070 0x16, 0x23, /* or %r2, %r3 */
2071 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2072 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2073 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2074 };
2075 add_insns (buf, sizeof buf);
2076 if (offset_p)
2077 *offset_p = 20;
2078 if (size_p)
2079 *size_p = 4;
2080 }
2081
2082 /* The "emit_lt_goto" emit_ops method for s390. */
2083
2084 static void
2085 s390_emit_lt_goto (int *offset_p, int *size_p)
2086 {
2087 static const unsigned char buf[] = {
2088 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2089 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
2090 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
2091 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2092 0xa7, 0x24, 0x00, 0x08, /* jh .Ltrue */
2093 /* .Lfalse: */
2094 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2095 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2096 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2097 /* .Ltrue: */
2098 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2099 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2100 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2101 /* .Lend: */
2102 };
2103 add_insns (buf, sizeof buf);
2104 if (offset_p)
2105 *offset_p = 42;
2106 if (size_p)
2107 *size_p = 4;
2108 }
2109
2110 /* The "emit_le_goto" emit_ops method for s390. */
2111
2112 static void
2113 s390_emit_le_goto (int *offset_p, int *size_p)
2114 {
2115 static const unsigned char buf[] = {
2116 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2117 0xa7, 0x24, 0x00, 0x0e, /* jh .Ltrue */
2118 0xa7, 0x44, 0x00, 0x06, /* jl .Lfalse */
2119 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2120 0xa7, 0xa4, 0x00, 0x08, /* jhe .Ltrue */
2121 /* .Lfalse: */
2122 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2123 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2124 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2125 /* .Ltrue: */
2126 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2127 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2128 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2129 /* .Lend: */
2130 };
2131 add_insns (buf, sizeof buf);
2132 if (offset_p)
2133 *offset_p = 42;
2134 if (size_p)
2135 *size_p = 4;
2136 }
2137
2138 /* The "emit_gt_goto" emit_ops method for s390. */
2139
2140 static void
2141 s390_emit_gt_goto (int *offset_p, int *size_p)
2142 {
2143 static const unsigned char buf[] = {
2144 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2145 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
2146 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
2147 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2148 0xa7, 0x44, 0x00, 0x08, /* jl .Ltrue */
2149 /* .Lfalse: */
2150 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2151 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2152 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2153 /* .Ltrue: */
2154 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2155 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2156 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2157 /* .Lend: */
2158 };
2159 add_insns (buf, sizeof buf);
2160 if (offset_p)
2161 *offset_p = 42;
2162 if (size_p)
2163 *size_p = 4;
2164 }
2165
2166 /* The "emit_ge_goto" emit_ops method for s390. */
2167
2168 static void
2169 s390_emit_ge_goto (int *offset_p, int *size_p)
2170 {
2171 static const unsigned char buf[] = {
2172 0x59, 0x20, 0xf0, 0x00, /* c %r2, 0(%r15) */
2173 0xa7, 0x44, 0x00, 0x0e, /* jl .Ltrue */
2174 0xa7, 0x24, 0x00, 0x06, /* jh .Lfalse */
2175 0x55, 0x30, 0xf0, 0x04, /* cl %r3, 4(%r15) */
2176 0xa7, 0xc4, 0x00, 0x08, /* jle .Ltrue */
2177 /* .Lfalse: */
2178 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2179 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2180 0xa7, 0xf4, 0x00, 0x09, /* j .Lend */
2181 /* .Ltrue: */
2182 0x98, 0x23, 0xf0, 0x08, /* lm %r2, %r3, 8(%r15) */
2183 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2184 0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00, /* jg <fillme> */
2185 /* .Lend: */
2186 };
2187 add_insns (buf, sizeof buf);
2188 if (offset_p)
2189 *offset_p = 42;
2190 if (size_p)
2191 *size_p = 4;
2192 }
2193
2194 /* The "emit_ops" structure for s390. Named _impl to avoid name
2195 collision with s390_emit_ops function. */
2196
2197 static struct emit_ops s390_emit_ops_impl =
2198 {
2199 s390_emit_prologue,
2200 s390_emit_epilogue,
2201 s390_emit_add,
2202 s390_emit_sub,
2203 s390_emit_mul,
2204 s390_emit_lsh,
2205 s390_emit_rsh_signed,
2206 s390_emit_rsh_unsigned,
2207 s390_emit_ext,
2208 s390_emit_log_not,
2209 s390_emit_bit_and,
2210 s390_emit_bit_or,
2211 s390_emit_bit_xor,
2212 s390_emit_bit_not,
2213 s390_emit_equal,
2214 s390_emit_less_signed,
2215 s390_emit_less_unsigned,
2216 s390_emit_ref,
2217 s390_emit_if_goto,
2218 s390_emit_goto,
2219 s390_write_goto_address,
2220 s390_emit_const,
2221 s390_emit_call,
2222 s390_emit_reg,
2223 s390_emit_pop,
2224 s390_emit_stack_flush,
2225 s390_emit_zero_ext,
2226 s390_emit_swap,
2227 s390_emit_stack_adjust,
2228 s390_emit_int_call_1,
2229 s390_emit_void_call_2,
2230 s390_emit_eq_goto,
2231 s390_emit_ne_goto,
2232 s390_emit_lt_goto,
2233 s390_emit_le_goto,
2234 s390_emit_gt_goto,
2235 s390_emit_ge_goto
2236 };
2237
2238 #ifdef __s390x__
2239
2240 /* The "emit_prologue" emit_ops method for s390x. */
2241
2242 static void
2243 s390x_emit_prologue (void)
2244 {
2245 static const unsigned char buf[] = {
2246 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x24, /* stmg %r9, %r15, 0x48(%r15) */
2247 0xb9, 0x04, 0x00, 0x92, /* lgr %r9, %r2 */
2248 0xb9, 0x04, 0x00, 0xa3, /* lgr %r10, %r3 */
2249 0xb9, 0x04, 0x00, 0xbf, /* lgr %r11, %r15 */
2250 };
2251 add_insns (buf, sizeof buf);
2252 }
2253
2254 /* The "emit_epilogue" emit_ops method for s390x. */
2255
2256 static void
2257 s390x_emit_epilogue (void)
2258 {
2259 static const unsigned char buf[] = {
2260 0xe3, 0x20, 0xa0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r10) */
2261 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2262 0xeb, 0x9f, 0xf0, 0x48, 0x00, 0x04, /* lmg %r9, %r15, 0x48(%r15) */
2263 0x07, 0xfe, /* br %r14 */
2264 };
2265 add_insns (buf, sizeof buf);
2266 }
2267
2268 /* The "emit_add" emit_ops method for s390x. */
2269
2270 static void
2271 s390x_emit_add (void)
2272 {
2273 static const unsigned char buf[] = {
2274 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x0a, /* alg %r2, 0(%r15) */
2275 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2276 };
2277 add_insns (buf, sizeof buf);
2278 }
2279
2280 /* The "emit_sub" emit_ops method for s390x. */
2281
2282 static void
2283 s390x_emit_sub (void)
2284 {
2285 static const unsigned char buf[] = {
2286 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2287 0xb9, 0x0b, 0x00, 0x32, /* slgr %r3, %r2 */
2288 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
2289 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2290 };
2291 add_insns (buf, sizeof buf);
2292 }
2293
2294 /* The "emit_mul" emit_ops method for s390x. */
2295
2296 static void
2297 s390x_emit_mul (void)
2298 {
2299 emit_error = 1;
2300 }
2301
2302 /* The "emit_lsh" emit_ops method for s390x. */
2303
2304 static void
2305 s390x_emit_lsh (void)
2306 {
2307 static const unsigned char buf[] = {
2308 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2309 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0d, /* sllg %r2, %r3, 0(%r2) */
2310 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2311 };
2312 add_insns (buf, sizeof buf);
2313 }
2314
2315 /* The "emit_rsh_signed" emit_ops method for s390x. */
2316
2317 static void
2318 s390x_emit_rsh_signed (void)
2319 {
2320 static const unsigned char buf[] = {
2321 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2322 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0a, /* srag %r2, %r3, 0(%r2) */
2323 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2324 };
2325 add_insns (buf, sizeof buf);
2326 }
2327
2328 /* The "emit_rsh_unsigned" emit_ops method for s390x. */
2329
2330 static void
2331 s390x_emit_rsh_unsigned (void)
2332 {
2333 static const unsigned char buf[] = {
2334 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2335 0xeb, 0x23, 0x20, 0x00, 0x00, 0x0c, /* srlg %r2, %r3, 0(%r2) */
2336 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2337 };
2338 add_insns (buf, sizeof buf);
2339 }
2340
2341 /* The "emit_ext" emit_ops method for s390x. */
2342
2343 static void
2344 s390x_emit_ext (int arg)
2345 {
2346 unsigned char buf[] = {
2347 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0d, /* sllg %r2, %r2, <64-arg> */
2348 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0a, /* srag %r2, %r2, <64-arg> */
2349 };
2350 add_insns (buf, sizeof buf);
2351 }
2352
2353 /* The "emit_log_not" emit_ops method for s390x. */
2354
2355 static void
2356 s390x_emit_log_not (void)
2357 {
2358 static const unsigned char buf[] = {
2359 0xb9, 0x00, 0x00, 0x22, /* lpgr %r2, %r2 */
2360 0xa7, 0x2b, 0xff, 0xff, /* aghi %r2, -1 */
2361 0xeb, 0x22, 0x00, 0x3f, 0x00, 0x0c, /* srlg %r2, %r2, 63 */
2362 };
2363 add_insns (buf, sizeof buf);
2364 }
2365
2366 /* The "emit_bit_and" emit_ops method for s390x. */
2367
2368 static void
2369 s390x_emit_bit_and (void)
2370 {
2371 static const unsigned char buf[] = {
2372 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x80, /* ng %r2, 0(%r15) */
2373 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2374 };
2375 add_insns (buf, sizeof buf);
2376 }
2377
2378 /* The "emit_bit_or" emit_ops method for s390x. */
2379
2380 static void
2381 s390x_emit_bit_or (void)
2382 {
2383 static const unsigned char buf[] = {
2384 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x81, /* og %r2, 0(%r15) */
2385 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2386 };
2387 add_insns (buf, sizeof buf);
2388 }
2389
2390 /* The "emit_bit_xor" emit_ops method for s390x. */
2391
2392 static void
2393 s390x_emit_bit_xor (void)
2394 {
2395 static const unsigned char buf[] = {
2396 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x82, /* xg %r2, 0(%r15) */
2397 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2398 };
2399 add_insns (buf, sizeof buf);
2400 }
2401
2402 /* The "emit_bit_not" emit_ops method for s390x. */
2403
2404 static void
2405 s390x_emit_bit_not (void)
2406 {
2407 static const unsigned char buf[] = {
2408 0xa7, 0x39, 0xff, 0xff, /* lghi %r3, -1 */
2409 0xb9, 0x82, 0x00, 0x23, /* xgr %r2, %r3 */
2410 };
2411 add_insns (buf, sizeof buf);
2412 }
2413
2414 /* The "emit_equal" emit_ops method for s390x. */
2415
2416 static void
2417 s390x_emit_equal (void)
2418 {
2419 s390x_emit_bit_xor ();
2420 s390x_emit_log_not ();
2421 }
2422
2423 /* The "emit_less_signed" emit_ops method for s390x. */
2424
2425 static void
2426 s390x_emit_less_signed (void)
2427 {
2428 static const unsigned char buf[] = {
2429 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2430 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
2431 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
2432 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2433 /* .Lend: */
2434 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2435 };
2436 add_insns (buf, sizeof buf);
2437 }
2438
2439 /* The "emit_less_unsigned" emit_ops method for s390x. */
2440
2441 static void
2442 s390x_emit_less_unsigned (void)
2443 {
2444 static const unsigned char buf[] = {
2445 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x21, /* clg %r2, 0(%r15) */
2446 0xa7, 0x29, 0x00, 0x01, /* lghi %r2, 1 */
2447 0xa7, 0x24, 0x00, 0x04, /* jh .Lend */
2448 0xa7, 0x29, 0x00, 0x00, /* lghi %r2, 0 */
2449 /* .Lend: */
2450 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2451 };
2452 add_insns (buf, sizeof buf);
2453 }
2454
2455 /* The "emit_ref" emit_ops method for s390x. */
2456
2457 static void
2458 s390x_emit_ref (int size)
2459 {
2460 static const unsigned char buf1[] = {
2461 0xe3, 0x20, 0x20, 0x00, 0x00, 0x90, /* llgc %r2, 0(%r2) */
2462 };
2463 static const unsigned char buf2[] = {
2464 0xe3, 0x20, 0x20, 0x00, 0x00, 0x91 /* llgh %r2, 0(%r2) */
2465 };
2466 static const unsigned char buf4[] = {
2467 0xe3, 0x20, 0x20, 0x00, 0x00, 0x16, /* llgf %r2, 0(%r2) */
2468 };
2469 static const unsigned char buf8[] = {
2470 0xe3, 0x20, 0x20, 0x00, 0x00, 0x04, /* lg %r2, 0(%r2) */
2471 };
2472 switch (size)
2473 {
2474 case 1:
2475 add_insns (buf1, sizeof buf1);
2476 break;
2477 case 2:
2478 add_insns (buf2, sizeof buf2);
2479 break;
2480 case 4:
2481 add_insns (buf4, sizeof buf4);
2482 break;
2483 case 8:
2484 add_insns (buf8, sizeof buf8);
2485 break;
2486 default:
2487 emit_error = 1;
2488 }
2489 }
2490
2491 /* The "emit_if_goto" emit_ops method for s390x. */
2492
2493 static void
2494 s390x_emit_if_goto (int *offset_p, int *size_p)
2495 {
2496 static const unsigned char buf[] = {
2497 0xb9, 0x02, 0x00, 0x22, /* ltgr %r2, %r2 */
2498 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
2499 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2500 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2501 };
2502 add_insns (buf, sizeof buf);
2503 if (offset_p)
2504 *offset_p = 16;
2505 if (size_p)
2506 *size_p = 4;
2507 }
2508
2509 /* The "emit_const" emit_ops method for s390x. */
2510
2511 static void
2512 s390x_emit_const (LONGEST num)
2513 {
2514 unsigned long long n = num;
2515 unsigned char buf_s[] = {
2516 0xa7, 0x29, num >> 8, num, /* lghi %r2, <num> */
2517 };
2518 static const unsigned char buf_l[] = {
2519 0xe3, 0x20, 0x10, 0x00, 0x00, 0x04, /* lg %r2, 0(%r1) */
2520 };
2521 if (num < 0x8000 && num >= -0x8000)
2522 {
2523 add_insns (buf_s, sizeof buf_s);
2524 }
2525 else
2526 {
2527 s390_emit_litpool (8);
2528 add_insns ((unsigned char *) &n, sizeof n);
2529 add_insns (buf_l, sizeof buf_l);
2530 }
2531 }
2532
2533 /* The "emit_call" emit_ops method for s390x. */
2534
2535 static void
2536 s390x_emit_call (CORE_ADDR fn)
2537 {
2538 unsigned long n = fn;
2539 static const unsigned char buf[] = {
2540 0xe3, 0x10, 0x10, 0x00, 0x00, 0x04, /* lg %r1, 0(%r1) */
2541 0xa7, 0xfb, 0xff, 0x60, /* aghi %r15, -0xa0 */
2542 0x0d, 0xe1, /* basr %r14, %r1 */
2543 0xa7, 0xfb, 0x00, 0xa0, /* aghi %r15, 0xa0 */
2544 };
2545 s390_emit_litpool (8);
2546 add_insns ((unsigned char *) &n, sizeof n);
2547 add_insns (buf, sizeof buf);
2548 }
2549
2550 /* The "emit_reg" emit_ops method for s390x. */
2551
2552 static void
2553 s390x_emit_reg (int reg)
2554 {
2555 unsigned char buf[] = {
2556 0xb9, 0x04, 0x00, 0x29, /* lgr %r2, %r9 */
2557 0xa7, 0x39, reg >> 8, reg, /* lghi %r3, <reg> */
2558 };
2559 add_insns (buf, sizeof buf);
2560 s390x_emit_call (get_raw_reg_func_addr ());
2561 }
2562
2563 /* The "emit_pop" emit_ops method for s390x. */
2564
2565 static void
2566 s390x_emit_pop (void)
2567 {
2568 static const unsigned char buf[] = {
2569 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x04, /* lg %r2, 0(%r15) */
2570 0x41, 0xf0, 0xf0, 0x08, /* la %r15, 8(%r15) */
2571 };
2572 add_insns (buf, sizeof buf);
2573 }
2574
2575 /* The "emit_stack_flush" emit_ops method for s390x. */
2576
2577 static void
2578 s390x_emit_stack_flush (void)
2579 {
2580 static const unsigned char buf[] = {
2581 0xa7, 0xfb, 0xff, 0xf8, /* aghi %r15, -8 */
2582 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
2583 };
2584 add_insns (buf, sizeof buf);
2585 }
2586
2587 /* The "emit_zero_ext" emit_ops method for s390x. */
2588
2589 static void
2590 s390x_emit_zero_ext (int arg)
2591 {
2592 unsigned char buf[] = {
2593 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0d, /* sllg %r2, %r2, <64-arg> */
2594 0xeb, 0x22, 0x00, 64 - arg, 0x00, 0x0c, /* srlg %r2, %r2, <64-arg> */
2595 };
2596 add_insns (buf, sizeof buf);
2597 }
2598
2599 /* The "emit_swap" emit_ops method for s390x. */
2600
2601 static void
2602 s390x_emit_swap (void)
2603 {
2604 static const unsigned char buf[] = {
2605 0xe3, 0x30, 0xf0, 0x00, 0x00, 0x04, /* lg %r3, 0(%r15) */
2606 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x24, /* stg %r2, 0(%r15) */
2607 0xb9, 0x04, 0x00, 0x23, /* lgr %r2, %r3 */
2608 };
2609 add_insns (buf, sizeof buf);
2610 }
2611
2612 /* The "emit_stack_adjust" emit_ops method for s390x. */
2613
2614 static void
2615 s390x_emit_stack_adjust (int n)
2616 {
2617 unsigned char buf[] = {
2618 0xa7, 0xfb, n * 8 >> 8, n * 8, /* aghi %r15, 8*n */
2619 };
2620 add_insns (buf, sizeof buf);
2621 }
2622
2623 /* The "emit_int_call_1" emit_ops method for s390x. */
2624
2625 static void
2626 s390x_emit_int_call_1 (CORE_ADDR fn, int arg1)
2627 {
2628 /* FN's prototype is `LONGEST(*fn)(int)'. */
2629 s390x_emit_const (arg1);
2630 s390x_emit_call (fn);
2631 }
2632
2633 /* The "emit_void_call_2" emit_ops method for s390x. */
2634
2635 static void
2636 s390x_emit_void_call_2 (CORE_ADDR fn, int arg1)
2637 {
2638 /* FN's prototype is `void(*fn)(int,LONGEST)'. */
2639 static const unsigned char buf[] = {
2640 0xb9, 0x04, 0x00, 0x32, /* lgr %r3, %r2 */
2641 0xb9, 0x04, 0x00, 0xc2, /* lgr %r12, %r2 */
2642 };
2643 static const unsigned char buf2[] = {
2644 0xb9, 0x04, 0x00, 0x2c, /* lgr %r2, %r12 */
2645 };
2646 add_insns (buf, sizeof buf);
2647 s390x_emit_const (arg1);
2648 s390x_emit_call (fn);
2649 add_insns (buf2, sizeof buf2);
2650 }
2651
2652 /* The "emit_eq_goto" emit_ops method for s390x. */
2653
2654 static void
2655 s390x_emit_eq_goto (int *offset_p, int *size_p)
2656 {
2657 static const unsigned char buf[] = {
2658 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2659 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2660 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2661 0xc0, 0x84, 0x00, 0x00, 0x00, 0x00, /* jge <fillme> */
2662 };
2663 add_insns (buf, sizeof buf);
2664 if (offset_p)
2665 *offset_p = 18;
2666 if (size_p)
2667 *size_p = 4;
2668 }
2669
2670 /* The "emit_ne_goto" emit_ops method for s390x. */
2671
2672 static void
2673 s390x_emit_ne_goto (int *offset_p, int *size_p)
2674 {
2675 static const unsigned char buf[] = {
2676 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2677 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2678 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2679 0xc0, 0x74, 0x00, 0x00, 0x00, 0x00, /* jgne <fillme> */
2680 };
2681 add_insns (buf, sizeof buf);
2682 if (offset_p)
2683 *offset_p = 18;
2684 if (size_p)
2685 *size_p = 4;
2686 }
2687
2688 /* The "emit_lt_goto" emit_ops method for s390x. */
2689
2690 static void
2691 s390x_emit_lt_goto (int *offset_p, int *size_p)
2692 {
2693 static const unsigned char buf[] = {
2694 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2695 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2696 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2697 0xc0, 0x24, 0x00, 0x00, 0x00, 0x00, /* jgh <fillme> */
2698 };
2699 add_insns (buf, sizeof buf);
2700 if (offset_p)
2701 *offset_p = 18;
2702 if (size_p)
2703 *size_p = 4;
2704 }
2705
2706 /* The "emit_le_goto" emit_ops method for s390x. */
2707
2708 static void
2709 s390x_emit_le_goto (int *offset_p, int *size_p)
2710 {
2711 static const unsigned char buf[] = {
2712 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2713 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2714 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2715 0xc0, 0xa4, 0x00, 0x00, 0x00, 0x00, /* jghe <fillme> */
2716 };
2717 add_insns (buf, sizeof buf);
2718 if (offset_p)
2719 *offset_p = 18;
2720 if (size_p)
2721 *size_p = 4;
2722 }
2723
2724 /* The "emit_gt_goto" emit_ops method for s390x. */
2725
2726 static void
2727 s390x_emit_gt_goto (int *offset_p, int *size_p)
2728 {
2729 static const unsigned char buf[] = {
2730 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2731 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2732 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2733 0xc0, 0x44, 0x00, 0x00, 0x00, 0x00, /* jgl <fillme> */
2734 };
2735 add_insns (buf, sizeof buf);
2736 if (offset_p)
2737 *offset_p = 18;
2738 if (size_p)
2739 *size_p = 4;
2740 }
2741
2742 /* The "emit_ge_goto" emit_ops method for s390x. */
2743
2744 static void
2745 s390x_emit_ge_goto (int *offset_p, int *size_p)
2746 {
2747 static const unsigned char buf[] = {
2748 0xe3, 0x20, 0xf0, 0x00, 0x00, 0x20, /* cg %r2, 0(%r15) */
2749 0xe3, 0x20, 0xf0, 0x08, 0x00, 0x04, /* lg %r2, 8(%r15) */
2750 0x41, 0xf0, 0xf0, 0x10, /* la %r15, 16(%r15) */
2751 0xc0, 0xc4, 0x00, 0x00, 0x00, 0x00, /* jgle <fillme> */
2752 };
2753 add_insns (buf, sizeof buf);
2754 if (offset_p)
2755 *offset_p = 18;
2756 if (size_p)
2757 *size_p = 4;
2758 }
2759
2760 /* The "emit_ops" structure for s390x. */
2761
2762 static struct emit_ops s390x_emit_ops =
2763 {
2764 s390x_emit_prologue,
2765 s390x_emit_epilogue,
2766 s390x_emit_add,
2767 s390x_emit_sub,
2768 s390x_emit_mul,
2769 s390x_emit_lsh,
2770 s390x_emit_rsh_signed,
2771 s390x_emit_rsh_unsigned,
2772 s390x_emit_ext,
2773 s390x_emit_log_not,
2774 s390x_emit_bit_and,
2775 s390x_emit_bit_or,
2776 s390x_emit_bit_xor,
2777 s390x_emit_bit_not,
2778 s390x_emit_equal,
2779 s390x_emit_less_signed,
2780 s390x_emit_less_unsigned,
2781 s390x_emit_ref,
2782 s390x_emit_if_goto,
2783 s390_emit_goto,
2784 s390_write_goto_address,
2785 s390x_emit_const,
2786 s390x_emit_call,
2787 s390x_emit_reg,
2788 s390x_emit_pop,
2789 s390x_emit_stack_flush,
2790 s390x_emit_zero_ext,
2791 s390x_emit_swap,
2792 s390x_emit_stack_adjust,
2793 s390x_emit_int_call_1,
2794 s390x_emit_void_call_2,
2795 s390x_emit_eq_goto,
2796 s390x_emit_ne_goto,
2797 s390x_emit_lt_goto,
2798 s390x_emit_le_goto,
2799 s390x_emit_gt_goto,
2800 s390x_emit_ge_goto
2801 };
2802 #endif
2803
2804 /* The "emit_ops" linux_target_ops method. */
2805
2806 static struct emit_ops *
2807 s390_emit_ops (void)
2808 {
2809 #ifdef __s390x__
2810 struct regcache *regcache = get_thread_regcache (current_thread, 0);
2811
2812 if (register_size (regcache->tdesc, 0) == 8)
2813 return &s390x_emit_ops;
2814 else
2815 #endif
2816 return &s390_emit_ops_impl;
2817 }
2818
2819 struct linux_target_ops the_low_target = {
2820 s390_arch_setup,
2821 s390_regs_info,
2822 s390_cannot_fetch_register,
2823 s390_cannot_store_register,
2824 NULL, /* fetch_register */
2825 s390_get_pc,
2826 s390_set_pc,
2827 NULL, /* breakpoint_kind_from_pc */
2828 s390_sw_breakpoint_from_kind,
2829 NULL,
2830 s390_breakpoint_len,
2831 s390_breakpoint_at,
2832 s390_supports_z_point_type,
2833 NULL,
2834 NULL,
2835 NULL,
2836 NULL,
2837 s390_collect_ptrace_register,
2838 s390_supply_ptrace_register,
2839 NULL, /* siginfo_fixup */
2840 NULL, /* new_process */
2841 NULL, /* delete_process */
2842 NULL, /* new_thread */
2843 NULL, /* delete_thread */
2844 NULL, /* new_fork */
2845 NULL, /* prepare_to_resume */
2846 NULL, /* process_qsupported */
2847 s390_supports_tracepoints,
2848 s390_get_thread_area,
2849 s390_install_fast_tracepoint_jump_pad,
2850 s390_emit_ops,
2851 s390_get_min_fast_tracepoint_insn_len,
2852 NULL, /* supports_range_stepping */
2853 NULL, /* breakpoint_kind_from_current_state */
2854 s390_supports_hardware_single_step,
2855 NULL, /* get_syscall_trapinfo */
2856 s390_get_ipa_tdesc_idx,
2857 };
2858
2859 void
2860 initialize_low_arch (void)
2861 {
2862 /* Initialize the Linux target descriptions. */
2863
2864 init_registers_s390_linux32 ();
2865 init_registers_s390_linux32v1 ();
2866 init_registers_s390_linux32v2 ();
2867 init_registers_s390_linux64 ();
2868 init_registers_s390_linux64v1 ();
2869 init_registers_s390_linux64v2 ();
2870 init_registers_s390_te_linux64 ();
2871 init_registers_s390_vx_linux64 ();
2872 init_registers_s390_tevx_linux64 ();
2873 init_registers_s390_gs_linux64 ();
2874 #ifdef __s390x__
2875 init_registers_s390x_linux64 ();
2876 init_registers_s390x_linux64v1 ();
2877 init_registers_s390x_linux64v2 ();
2878 init_registers_s390x_te_linux64 ();
2879 init_registers_s390x_vx_linux64 ();
2880 init_registers_s390x_tevx_linux64 ();
2881 init_registers_s390x_gs_linux64 ();
2882 #endif
2883
2884 initialize_regsets_info (&s390_regsets_info);
2885 initialize_regsets_info (&s390_regsets_info_3264);
2886 }
This page took 0.09319 seconds and 5 git commands to generate.