Home | History | Annotate | Line # | Download | only in include
netbsd32_machdep.h revision 1.22.14.1
      1 /*	$NetBSD: netbsd32_machdep.h,v 1.22.14.1 2019/06/10 22:05:47 christos Exp $	*/
      2 
      3 #ifndef _MACHINE_NETBSD32_H_
      4 #define _MACHINE_NETBSD32_H_
      5 
      6 #include <sys/ucontext.h>
      7 #include <compat/sys/ucontext.h>
      8 #include <compat/sys/siginfo.h>
      9 
     10 /*
     11  * i386 ptrace constants
     12  * Please keep in sync with sys/arch/i386/include/ptrace.h.
     13  */
     14 #define	PT32_STEP		(PT_FIRSTMACH + 0)
     15 #define	PT32_GETREGS		(PT_FIRSTMACH + 1)
     16 #define	PT32_SETREGS		(PT_FIRSTMACH + 2)
     17 #define	PT32_GETFPREGS		(PT_FIRSTMACH + 3)
     18 #define	PT32_SETFPREGS		(PT_FIRSTMACH + 4)
     19 #define	PT32_GETXMMREGS		(PT_FIRSTMACH + 5)
     20 #define	PT32_SETXMMREGS		(PT_FIRSTMACH + 6)
     21 #define	PT32_GETDBREGS		(PT_FIRSTMACH + 7)
     22 #define	PT32_SETDBREGS		(PT_FIRSTMACH + 8)
     23 #define	PT32_SETSTEP		(PT_FIRSTMACH + 9)
     24 #define	PT32_CLEARSTEP		(PT_FIRSTMACH + 10)
     25 
     26 #define NETBSD32_POINTER_TYPE uint32_t
     27 typedef	struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t;
     28 
     29 /* i386 has 32bit aligned 64bit integers */
     30 #define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4)))
     31 
     32 typedef netbsd32_pointer_t netbsd32_sigcontextp_t;
     33 
     34 struct netbsd32_sigcontext13 {
     35 	uint32_t	sc_gs;
     36 	uint32_t	sc_fs;
     37 	uint32_t	sc_es;
     38 	uint32_t	sc_ds;
     39 	uint32_t	sc_edi;
     40 	uint32_t	sc_esi;
     41 	uint32_t	sc_ebp;
     42 	uint32_t	sc_ebx;
     43 	uint32_t	sc_edx;
     44 	uint32_t	sc_ecx;
     45 	uint32_t	sc_eax;
     46 	/* XXX */
     47 	uint32_t	sc_eip;
     48 	uint32_t	sc_cs;
     49 	uint32_t	sc_eflags;
     50 	uint32_t	sc_esp;
     51 	uint32_t	sc_ss;
     52 
     53 	uint32_t	sc_onstack;	/* sigstack state to restore */
     54 	uint32_t	sc_mask;	/* signal mask to restore (old style) */
     55 
     56 	uint32_t	sc_trapno;	/* XXX should be above */
     57 	uint32_t	sc_err;
     58 };
     59 
     60 struct netbsd32_sigcontext {
     61 	uint32_t	sc_gs;
     62 	uint32_t	sc_fs;
     63 	uint32_t	sc_es;
     64 	uint32_t	sc_ds;
     65 	uint32_t	sc_edi;
     66 	uint32_t	sc_esi;
     67 	uint32_t	sc_ebp;
     68 	uint32_t	sc_ebx;
     69 	uint32_t	sc_edx;
     70 	uint32_t	sc_ecx;
     71 	uint32_t	sc_eax;
     72 	/* XXX */
     73 	uint32_t	sc_eip;
     74 	uint32_t	sc_cs;
     75 	uint32_t	sc_eflags;
     76 	uint32_t	sc_esp;
     77 	uint32_t	sc_ss;
     78 
     79 	uint32_t	sc_onstack;	/* sigstack state to restore */
     80 	uint32_t	__sc_mask13;	/* signal mask to restore (old style) */
     81 
     82 	uint32_t	sc_trapno;	/* XXX should be above */
     83 	uint32_t	sc_err;
     84 
     85 	sigset_t sc_mask;		/* signal mask to restore (new style) */
     86 };
     87 
     88 #define sc_sp sc_esp
     89 #define sc_fp sc_ebp
     90 #define sc_pc sc_eip
     91 #define sc_ps sc_eflags
     92 
     93 struct netbsd32_sigframe_sigcontext {
     94 	uint32_t	sf_ra;
     95 	int32_t		sf_signum;
     96 	int32_t		sf_code;
     97 	uint32_t	sf_scp;
     98 	struct netbsd32_sigcontext sf_sc;
     99 };
    100 
    101 struct netbsd32_sigframe_siginfo {
    102 	uint32_t	sf_ra;
    103 	int32_t		sf_signum;
    104 	uint32_t	sf_sip;
    105 	uint32_t	sf_ucp;
    106 	siginfo32_t	sf_si;
    107 	ucontext32_t	sf_uc;
    108 };
    109 
    110 struct reg32 {
    111 	int	r_eax;
    112 	int	r_ecx;
    113 	int	r_edx;
    114 	int	r_ebx;
    115 	int	r_esp;
    116 	int	r_ebp;
    117 	int	r_esi;
    118 	int	r_edi;
    119 	int	r_eip;
    120 	int	r_eflags;
    121 	int	r_cs;
    122 	int	r_ss;
    123 	int	r_ds;
    124 	int	r_es;
    125 	int	r_fs;
    126 	int	r_gs;
    127 };
    128 
    129 struct fpreg32 {
    130 	char	__data[108];
    131 };
    132 
    133 struct dbreg32 {
    134 	int	dr[8];
    135 };
    136 
    137 struct x86_get_ldt_args32 {
    138 	int32_t start;
    139 	uint32_t desc;
    140 	int32_t num;
    141 };
    142 
    143 struct x86_set_ldt_args32 {
    144 	int32_t start;
    145 	uint32_t desc;
    146 	int32_t num;
    147 };
    148 
    149 struct mtrr32 {
    150 	uint64_t base;
    151 	uint64_t len;
    152 	uint8_t type;
    153 	uint8_t __pad0[3];
    154 	int flags;
    155 	uint32_t owner;
    156 } __packed;
    157 
    158 struct x86_64_get_mtrr_args32 {
    159 	uint32_t mtrrp;
    160 	uint32_t n;
    161 };
    162 
    163 struct x86_64_set_mtrr_args32 {
    164 	uint32_t mtrrp;
    165 	uint32_t n;
    166 };
    167 
    168 #define NETBSD32_MID_MACHINE MID_I386
    169 
    170 /* Translate ptrace() PT_* request from 32-bit userland to kernel. */
    171 int netbsd32_ptrace_translate_request(int);
    172 
    173 int netbsd32_process_read_regs(struct lwp *, struct reg32 *);
    174 int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *);
    175 int netbsd32_process_read_dbregs(struct lwp *, struct dbreg32 *, size_t *);
    176 
    177 int netbsd32_process_write_regs(struct lwp *, const struct reg32 *);
    178 int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t);
    179 int netbsd32_process_write_dbregs(struct lwp *, const struct dbreg32 *, size_t);
    180 
    181 #endif /* _MACHINE_NETBSD32_H_ */
    182