1*df4d41c7Srin /* $NetBSD: netbsd32_machdep.h,v 1.25 2019/11/27 09:16:58 rin Exp $ */ 281918bf8Sfvdl 381918bf8Sfvdl #ifndef _MACHINE_NETBSD32_H_ 481918bf8Sfvdl #define _MACHINE_NETBSD32_H_ 581918bf8Sfvdl 60deb20a3Sfvdl #include <sys/ucontext.h> 743070602Schs #include <compat/sys/ucontext.h> 894be8205Schs #include <compat/sys/siginfo.h> 90deb20a3Sfvdl 10*df4d41c7Srin #include <x86/fpu.h> 11*df4d41c7Srin 12b98b74f8Smgorny /* 13b98b74f8Smgorny * i386 ptrace constants 14b98b74f8Smgorny * Please keep in sync with sys/arch/i386/include/ptrace.h. 15b98b74f8Smgorny */ 16b98b74f8Smgorny #define PT32_STEP (PT_FIRSTMACH + 0) 17b98b74f8Smgorny #define PT32_GETREGS (PT_FIRSTMACH + 1) 18b98b74f8Smgorny #define PT32_SETREGS (PT_FIRSTMACH + 2) 19b98b74f8Smgorny #define PT32_GETFPREGS (PT_FIRSTMACH + 3) 20b98b74f8Smgorny #define PT32_SETFPREGS (PT_FIRSTMACH + 4) 21b98b74f8Smgorny #define PT32_GETXMMREGS (PT_FIRSTMACH + 5) 22b98b74f8Smgorny #define PT32_SETXMMREGS (PT_FIRSTMACH + 6) 23b98b74f8Smgorny #define PT32_GETDBREGS (PT_FIRSTMACH + 7) 24b98b74f8Smgorny #define PT32_SETDBREGS (PT_FIRSTMACH + 8) 25b98b74f8Smgorny #define PT32_SETSTEP (PT_FIRSTMACH + 9) 26b98b74f8Smgorny #define PT32_CLEARSTEP (PT_FIRSTMACH + 10) 2738f213f0Smgorny #define PT32_GETXSTATE (PT_FIRSTMACH + 11) 2838f213f0Smgorny #define PT32_SETXSTATE (PT_FIRSTMACH + 12) 29b98b74f8Smgorny 30803fec88Sdsl #define NETBSD32_POINTER_TYPE uint32_t 31803fec88Sdsl typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t; 3281918bf8Sfvdl 3306b0a1bdSdsl /* i386 has 32bit aligned 64bit integers */ 3406b0a1bdSdsl #define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) 3506b0a1bdSdsl 3681918bf8Sfvdl typedef netbsd32_pointer_t netbsd32_sigcontextp_t; 3781918bf8Sfvdl 3881918bf8Sfvdl struct netbsd32_sigcontext13 { 390deb20a3Sfvdl uint32_t sc_gs; 400deb20a3Sfvdl uint32_t sc_fs; 410deb20a3Sfvdl uint32_t sc_es; 420deb20a3Sfvdl uint32_t sc_ds; 430deb20a3Sfvdl uint32_t sc_edi; 440deb20a3Sfvdl uint32_t sc_esi; 450deb20a3Sfvdl uint32_t sc_ebp; 460deb20a3Sfvdl uint32_t sc_ebx; 470deb20a3Sfvdl uint32_t sc_edx; 480deb20a3Sfvdl uint32_t sc_ecx; 490deb20a3Sfvdl uint32_t sc_eax; 5081918bf8Sfvdl /* XXX */ 510deb20a3Sfvdl uint32_t sc_eip; 520deb20a3Sfvdl uint32_t sc_cs; 530deb20a3Sfvdl uint32_t sc_eflags; 540deb20a3Sfvdl uint32_t sc_esp; 550deb20a3Sfvdl uint32_t sc_ss; 5681918bf8Sfvdl 570deb20a3Sfvdl uint32_t sc_onstack; /* sigstack state to restore */ 580deb20a3Sfvdl uint32_t sc_mask; /* signal mask to restore (old style) */ 5981918bf8Sfvdl 600deb20a3Sfvdl uint32_t sc_trapno; /* XXX should be above */ 610deb20a3Sfvdl uint32_t sc_err; 6281918bf8Sfvdl }; 6381918bf8Sfvdl 6481918bf8Sfvdl struct netbsd32_sigcontext { 650deb20a3Sfvdl uint32_t sc_gs; 660deb20a3Sfvdl uint32_t sc_fs; 670deb20a3Sfvdl uint32_t sc_es; 680deb20a3Sfvdl uint32_t sc_ds; 690deb20a3Sfvdl uint32_t sc_edi; 700deb20a3Sfvdl uint32_t sc_esi; 710deb20a3Sfvdl uint32_t sc_ebp; 720deb20a3Sfvdl uint32_t sc_ebx; 730deb20a3Sfvdl uint32_t sc_edx; 740deb20a3Sfvdl uint32_t sc_ecx; 750deb20a3Sfvdl uint32_t sc_eax; 7681918bf8Sfvdl /* XXX */ 770deb20a3Sfvdl uint32_t sc_eip; 780deb20a3Sfvdl uint32_t sc_cs; 790deb20a3Sfvdl uint32_t sc_eflags; 800deb20a3Sfvdl uint32_t sc_esp; 810deb20a3Sfvdl uint32_t sc_ss; 8281918bf8Sfvdl 830deb20a3Sfvdl uint32_t sc_onstack; /* sigstack state to restore */ 840deb20a3Sfvdl uint32_t __sc_mask13; /* signal mask to restore (old style) */ 8581918bf8Sfvdl 860deb20a3Sfvdl uint32_t sc_trapno; /* XXX should be above */ 870deb20a3Sfvdl uint32_t sc_err; 8881918bf8Sfvdl 8981918bf8Sfvdl sigset_t sc_mask; /* signal mask to restore (new style) */ 9081918bf8Sfvdl }; 9181918bf8Sfvdl 9281918bf8Sfvdl #define sc_sp sc_esp 9381918bf8Sfvdl #define sc_fp sc_ebp 9481918bf8Sfvdl #define sc_pc sc_eip 9581918bf8Sfvdl #define sc_ps sc_eflags 9681918bf8Sfvdl 970deb20a3Sfvdl struct netbsd32_sigframe_sigcontext { 9881918bf8Sfvdl uint32_t sf_ra; 990deb20a3Sfvdl int32_t sf_signum; 1000deb20a3Sfvdl int32_t sf_code; 10181918bf8Sfvdl uint32_t sf_scp; 10281918bf8Sfvdl struct netbsd32_sigcontext sf_sc; 10381918bf8Sfvdl }; 10481918bf8Sfvdl 1050deb20a3Sfvdl struct netbsd32_sigframe_siginfo { 1060deb20a3Sfvdl uint32_t sf_ra; 1070deb20a3Sfvdl int32_t sf_signum; 1080deb20a3Sfvdl uint32_t sf_sip; 1090deb20a3Sfvdl uint32_t sf_ucp; 1100deb20a3Sfvdl siginfo32_t sf_si; 1110deb20a3Sfvdl ucontext32_t sf_uc; 1120deb20a3Sfvdl }; 1130deb20a3Sfvdl 11481918bf8Sfvdl struct reg32 { 11581918bf8Sfvdl int r_eax; 11681918bf8Sfvdl int r_ecx; 11781918bf8Sfvdl int r_edx; 11881918bf8Sfvdl int r_ebx; 11981918bf8Sfvdl int r_esp; 12081918bf8Sfvdl int r_ebp; 12181918bf8Sfvdl int r_esi; 12281918bf8Sfvdl int r_edi; 12381918bf8Sfvdl int r_eip; 12481918bf8Sfvdl int r_eflags; 12581918bf8Sfvdl int r_cs; 12681918bf8Sfvdl int r_ss; 12781918bf8Sfvdl int r_ds; 12881918bf8Sfvdl int r_es; 12981918bf8Sfvdl int r_fs; 13081918bf8Sfvdl int r_gs; 13181918bf8Sfvdl }; 13281918bf8Sfvdl 13381918bf8Sfvdl struct fpreg32 { 13481918bf8Sfvdl char __data[108]; 13581918bf8Sfvdl }; 13681918bf8Sfvdl 1373039c775Skamil struct dbreg32 { 1383039c775Skamil int dr[8]; 1393039c775Skamil }; 1403039c775Skamil 141*df4d41c7Srin struct xmmregs32 { 142*df4d41c7Srin struct fxsave fxstate; 143*df4d41c7Srin }; 144*df4d41c7Srin __CTASSERT(sizeof(struct xmmregs32) == 512); 145*df4d41c7Srin 146747f1de1Smaxv struct x86_get_ldt_args32 { 147747f1de1Smaxv int32_t start; 148747f1de1Smaxv uint32_t desc; 149747f1de1Smaxv int32_t num; 150747f1de1Smaxv }; 151747f1de1Smaxv 152747f1de1Smaxv struct x86_set_ldt_args32 { 153747f1de1Smaxv int32_t start; 154747f1de1Smaxv uint32_t desc; 155747f1de1Smaxv int32_t num; 156747f1de1Smaxv }; 157747f1de1Smaxv 15881918bf8Sfvdl struct mtrr32 { 15981918bf8Sfvdl uint64_t base; 16081918bf8Sfvdl uint64_t len; 16181918bf8Sfvdl uint8_t type; 16281918bf8Sfvdl uint8_t __pad0[3]; 16381918bf8Sfvdl int flags; 16481918bf8Sfvdl uint32_t owner; 165b6a2ef75Sperry } __packed; 16681918bf8Sfvdl 16781918bf8Sfvdl struct x86_64_get_mtrr_args32 { 16881918bf8Sfvdl uint32_t mtrrp; 16981918bf8Sfvdl uint32_t n; 17081918bf8Sfvdl }; 17181918bf8Sfvdl 17281918bf8Sfvdl struct x86_64_set_mtrr_args32 { 17381918bf8Sfvdl uint32_t mtrrp; 17481918bf8Sfvdl uint32_t n; 17581918bf8Sfvdl }; 17681918bf8Sfvdl 177289fa680Sdrochner #define NETBSD32_MID_MACHINE MID_I386 178289fa680Sdrochner 179b98b74f8Smgorny /* Translate ptrace() PT_* request from 32-bit userland to kernel. */ 180b98b74f8Smgorny int netbsd32_ptrace_translate_request(int); 181b98b74f8Smgorny 182209be910Scube int netbsd32_process_read_regs(struct lwp *, struct reg32 *); 1836dafc154Sdsl int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *); 1843039c775Skamil int netbsd32_process_read_dbregs(struct lwp *, struct dbreg32 *, size_t *); 185209be910Scube 186c77e59e2Sskrll int netbsd32_process_write_regs(struct lwp *, const struct reg32 *); 187c77e59e2Sskrll int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t); 1883039c775Skamil int netbsd32_process_write_dbregs(struct lwp *, const struct dbreg32 *, size_t); 189c77e59e2Sskrll 19081918bf8Sfvdl #endif /* _MACHINE_NETBSD32_H_ */ 191