24 #include "elf/common.h"
26 #include <asm/ptrace.h>
27 #include <sys/ptrace.h>
31 #ifndef HWCAP_S390_HIGH_GPRS
32 #define HWCAP_S390_HIGH_GPRS 512
36 #define HWCAP_S390_TE 1024
40 #define HWCAP_S390_VX 2048
103 #define s390_num_regs 52
106 PT_PSWMASK, PT_PSWADDR,
108 PT_GPR0, PT_GPR1, PT_GPR2, PT_GPR3,
109 PT_GPR4, PT_GPR5, PT_GPR6, PT_GPR7,
110 PT_GPR8, PT_GPR9, PT_GPR10, PT_GPR11,
111 PT_GPR12, PT_GPR13, PT_GPR14, PT_GPR15,
113 PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
114 PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
115 PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
116 PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
121 PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI,
122 PT_FPR4_HI, PT_FPR5_HI, PT_FPR6_HI, PT_FPR7_HI,
123 PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
124 PT_FPR12_HI, PT_FPR13_HI, PT_FPR14_HI, PT_FPR15_HI,
126 PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3,
127 PT_FPR4, PT_FPR5, PT_FPR6, PT_FPR7,
128 PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
129 PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
136 #define s390_num_regs_3264 68
138 static int s390_regmap_3264[] = {
139 PT_PSWMASK, PT_PSWADDR,
141 PT_GPR0, PT_GPR0, PT_GPR1, PT_GPR1,
142 PT_GPR2, PT_GPR2, PT_GPR3, PT_GPR3,
143 PT_GPR4, PT_GPR4, PT_GPR5, PT_GPR5,
144 PT_GPR6, PT_GPR6, PT_GPR7, PT_GPR7,
145 PT_GPR8, PT_GPR8, PT_GPR9, PT_GPR9,
146 PT_GPR10, PT_GPR10, PT_GPR11, PT_GPR11,
147 PT_GPR12, PT_GPR12, PT_GPR13, PT_GPR13,
148 PT_GPR14, PT_GPR14, PT_GPR15, PT_GPR15,
150 PT_ACR0, PT_ACR1, PT_ACR2, PT_ACR3,
151 PT_ACR4, PT_ACR5, PT_ACR6, PT_ACR7,
152 PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
153 PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
157 PT_FPR0, PT_FPR1, PT_FPR2, PT_FPR3,
158 PT_FPR4, PT_FPR5, PT_FPR6, PT_FPR7,
159 PT_FPR8, PT_FPR9, PT_FPR10, PT_FPR11,
160 PT_FPR12, PT_FPR13, PT_FPR14, PT_FPR15,
183 if (size <
sizeof (
long))
185 const struct regs_info *regs_info = (*the_low_target.
regs_info) ();
187 int regaddr = usr->
regmap[regno];
189 memset (buf, 0,
sizeof (
long));
192 && usr->
regmap[regno ^ 1] == regaddr)
196 buf +
sizeof (
long) - size);
198 else if (regaddr == PT_PSWMASK)
206 buf[size] |= (addr[0] & 0x80);
208 else if (regaddr == PT_PSWADDR)
213 buf[
sizeof (long) - size] &= ~0x80;
215 else if ((regaddr >= PT_GPR0 && regaddr <= PT_GPR15)
216 || regaddr == PT_ORIGGPR2)
227 int regno,
const char *buf)
230 if (size <
sizeof (
long))
232 const struct regs_info *regs_info = (*the_low_target.
regs_info) ();
234 int regaddr = usr->
regmap[regno];
237 && usr->
regmap[regno ^ 1] == regaddr)
241 buf +
sizeof (
long) - size);
243 else if (regaddr == PT_PSWMASK)
247 char *mask =
alloca (size);
249 memcpy (mask, buf, size);
255 addr[0] |= (buf[size] & 0x80);
258 else if (regaddr == PT_PSWADDR)
262 char *addr =
alloca (size);
265 amode = addr[0] & 0x80;
266 memcpy (addr, buf +
sizeof (
long) - size, size);
271 else if ((regaddr >= PT_GPR0 && regaddr <= PT_GPR15)
272 || regaddr == PT_ORIGGPR2)
288 const struct regs_info *regs_info = (*the_low_target.
regs_info) ();
293 if (usr->
regmap[i] < PT_PSWMASK
294 || usr->
regmap[i] > PT_ACR15)
298 (
char *) buf + usr->
regmap[i]);
332 for (i = 0; i < 4; i++)
335 for (i = 0; i < 16; i++)
336 supply_register (regcache, tr0 + i, (
const char *) buf + 8 * (16 + i));
345 for (i = 0; i < 16; i++)
355 for (i = 0; i < 16; i++)
365 for (i = 0; i < 16; i++)
375 for (i = 0; i < 16; i++)
393 { 0, 0, 0, -1, -1, NULL, NULL }
398 #define s390_breakpoint_len 2
407 return pswa & 0x7fffffff;
424 pswa = (pswa & 0x80000000) | (newpc & 0x7fffffff);
429 unsigned long pc = newpc;
439 unsigned char *data =
alloca (2 * wordsize);
446 unsigned int *data_p = (
unsigned int *)data;
447 if (data_p[0] == AT_HWCAP)
452 unsigned long *data_p = (
unsigned long *)data;
453 if (data_p[0] == AT_HWCAP)
457 offset += 2 * wordsize;
471 iov.iov_len = regsize;
482 static int have_hwcap_s390_high_gprs = 0;
489 struct regset_info *regset;
493 int have_regset_last_break
495 int have_regset_system_call
502 if (have_regset_system_call)
504 else if (have_regset_last_break)
524 (s390_get_hwcap (tdesc_s390x_linux64v2) &
HWCAP_S390_TE) != 0;
525 if (have_regset_vxrs)
527 (s390_get_hwcap (tdesc_s390x_linux64v2) &
HWCAP_S390_VX) != 0;
529 if (have_regset_vxrs)
530 tdesc = (have_regset_tdb ? tdesc_s390x_tevx_linux64 :
532 else if (have_regset_tdb)
534 else if (have_regset_system_call)
536 else if (have_regset_last_break)
546 have_hwcap_s390_high_gprs = 1;
548 have_regset_tdb = (s390_get_hwcap (tdesc) &
HWCAP_S390_TE) != 0;
549 if (have_regset_vxrs)
550 have_regset_vxrs = (s390_get_hwcap (tdesc) &
HWCAP_S390_VX) != 0;
552 if (have_regset_vxrs)
553 tdesc = (have_regset_tdb ? tdesc_s390_tevx_linux64 :
555 else if (have_regset_tdb)
557 else if (have_regset_system_call)
559 else if (have_regset_last_break)
568 for (regset = s390_regsets; regset->size >= 0; regset++)
570 switch (regset->nt_type)
572 case NT_S390_LAST_BREAK:
573 regset->size = have_regset_last_break? 8 : 0;
575 case NT_S390_SYSTEM_CALL:
576 regset->size = have_regset_system_call? 4 : 0;
579 regset->size = have_regset_tdb ? 256 : 0;
581 case NT_S390_VXRS_LOW:
582 regset->size = have_regset_vxrs ? 128 : 0;
584 case NT_S390_VXRS_HIGH:
585 regset->size = have_regset_vxrs ? 256 : 0;
609 static struct regsets_info s390_regsets_info =
616 static struct regs_info regs_info =
630 static struct regsets_info s390_regsets_info_3264 =
637 static struct regs_info regs_info_3264 =
640 &s390_usrregs_info_3264,
641 &s390_regsets_info_3264
645 static const struct regs_info *
649 if (have_hwcap_s390_high_gprs)
654 return ®s_info_3264;
703 initialize_regsets_info (&s390_regsets_info);
705 initialize_regsets_info (&s390_regsets_info_3264);
const struct target_desc * tdesc
const struct target_desc * tdesc_s390x_te_linux64
struct thread_info * current_thread
void collect_register(struct regcache *regcache, int n, void *buf)
const struct target_desc * tdesc_s390x_vx_linux64
static void s390_store_system_call(struct regcache *regcache, const void *buf)
void init_registers_s390_linux32(void)
struct usrregs_info * usrregs
struct regcache * new_register_cache(const struct target_desc *tdesc)
void supply_register_by_name(struct regcache *regcache, const char *name, const void *buf)
const struct target_desc * tdesc_s390x_linux64
const struct target_desc * tdesc_s390_tevx_linux64
const struct target_desc * tdesc_s390x_linux64v2
const struct target_desc * tdesc_s390_linux64v2
void init_registers_s390_linux64(void)
static CORE_ADDR s390_get_pc(struct regcache *regcache)
void init_registers_s390x_tevx_linux64(void)
static int s390_check_regset(int pid, int regset, int regsize)
static void s390_store_tdb(struct regcache *regcache, const void *buf)
void init_registers_s390x_linux64v1(void)
static void s390_fill_vxrs_high(struct regcache *regcache, void *buf)
const struct regs_info *(* regs_info)(void)
void init_registers_s390x_linux64(void)
static void s390_fill_system_call(struct regcache *regcache, void *buf)
struct target_ops * the_target
const struct target_desc * tdesc
const struct target_desc * tdesc_s390_linux64
void init_registers_s390x_te_linux64(void)
void init_registers_s390_vx_linux64(void)
void collect_register_by_name(struct regcache *regcache, const char *name, void *buf)
static void s390_arch_setup(void)
void init_registers_s390_linux64v2(void)
const struct target_desc * tdesc_s390_linux64v1
int read_inferior_memory(CORE_ADDR memaddr, unsigned char *myaddr, int len)
static void s390_store_vxrs_high(struct regcache *regcache, const void *buf)
const struct target_desc * tdesc_s390_te_linux64
void initialize_low_arch(void)
int register_size(const struct target_desc *tdesc, int n)
void init_registers_s390x_linux64v2(void)
const struct target_desc * tdesc_s390x_tevx_linux64
static int s390_cannot_fetch_register(int regno)
struct process_info * current_process(void)
void init_registers_s390x_vx_linux64(void)
static void s390_supply_ptrace_register(struct regcache *regcache, int regno, const char *buf)
static struct regs_info regs_info
const struct target_desc * tdesc_s390_linux32v2
static void s390_store_last_break(struct regcache *regcache, const void *buf)
const struct target_desc * tdesc_s390x_linux64v1
static const unsigned char s390_breakpoint[]
static struct usrregs_info s390_usrregs_info
static void s390_set_pc(struct regcache *regcache, CORE_ADDR newpc)
static int s390_breakpoint_at(CORE_ADDR pc)
int find_regno(const struct target_desc *tdesc, const char *name)
const struct target_desc * tdesc_s390_vx_linux64
#define fetch_inferior_registers(regcache, regno)
int(* read_auxv)(CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
static void s390_store_vxrs_low(struct regcache *regcache, const void *buf)
const struct target_desc * tdesc_s390_linux32v1
static struct regset_info s390_regsets[]
static void s390_fill_vxrs_low(struct regcache *regcache, void *buf)
void init_registers_s390_linux64v1(void)
void free_register_cache(struct regcache *regcache)
static void s390_fill_gregset(struct regcache *regcache, void *buf)
#define HWCAP_S390_HIGH_GPRS
static const struct regs_info * s390_regs_info(void)
void init_registers_s390_tevx_linux64(void)
#define s390_breakpoint_len
const struct target_desc * tdesc_s390_linux32
void init_registers_s390_linux32v2(void)
void supply_register(struct regcache *regcache, int n, const void *buf)
void init_registers_s390_linux32v1(void)
static void s390_collect_ptrace_register(struct regcache *regcache, int regno, char *buf)
void init_registers_s390_te_linux64(void)
static int s390_cannot_store_register(int regno)