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