| 1 | /* $NetBSD: netbsd32_machdep.h,v 1.20 2016/10/19 09:44:00 skrll 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 | #define NETBSD32_POINTER_TYPE uint32_t |
| 11 | typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t; |
| 12 | |
| 13 | /* i386 has 32bit aligned 64bit integers */ |
| 14 | #define NETBSD32_INT64_ALIGN __attribute__((__aligned__(4))) |
| 15 | |
| 16 | typedef netbsd32_pointer_t netbsd32_sigcontextp_t; |
| 17 | |
| 18 | struct netbsd32_sigcontext13 { |
| 19 | uint32_t sc_gs; |
| 20 | uint32_t sc_fs; |
| 21 | uint32_t sc_es; |
| 22 | uint32_t sc_ds; |
| 23 | uint32_t sc_edi; |
| 24 | uint32_t sc_esi; |
| 25 | uint32_t sc_ebp; |
| 26 | uint32_t sc_ebx; |
| 27 | uint32_t sc_edx; |
| 28 | uint32_t sc_ecx; |
| 29 | uint32_t sc_eax; |
| 30 | /* XXX */ |
| 31 | uint32_t sc_eip; |
| 32 | uint32_t sc_cs; |
| 33 | uint32_t sc_eflags; |
| 34 | uint32_t sc_esp; |
| 35 | uint32_t sc_ss; |
| 36 | |
| 37 | uint32_t sc_onstack; /* sigstack state to restore */ |
| 38 | uint32_t sc_mask; /* signal mask to restore (old style) */ |
| 39 | |
| 40 | uint32_t sc_trapno; /* XXX should be above */ |
| 41 | uint32_t sc_err; |
| 42 | }; |
| 43 | |
| 44 | struct netbsd32_sigcontext { |
| 45 | uint32_t sc_gs; |
| 46 | uint32_t sc_fs; |
| 47 | uint32_t sc_es; |
| 48 | uint32_t sc_ds; |
| 49 | uint32_t sc_edi; |
| 50 | uint32_t sc_esi; |
| 51 | uint32_t sc_ebp; |
| 52 | uint32_t sc_ebx; |
| 53 | uint32_t sc_edx; |
| 54 | uint32_t sc_ecx; |
| 55 | uint32_t sc_eax; |
| 56 | /* XXX */ |
| 57 | uint32_t sc_eip; |
| 58 | uint32_t sc_cs; |
| 59 | uint32_t sc_eflags; |
| 60 | uint32_t sc_esp; |
| 61 | uint32_t sc_ss; |
| 62 | |
| 63 | uint32_t sc_onstack; /* sigstack state to restore */ |
| 64 | uint32_t __sc_mask13; /* signal mask to restore (old style) */ |
| 65 | |
| 66 | uint32_t sc_trapno; /* XXX should be above */ |
| 67 | uint32_t sc_err; |
| 68 | |
| 69 | sigset_t sc_mask; /* signal mask to restore (new style) */ |
| 70 | }; |
| 71 | |
| 72 | #define sc_sp sc_esp |
| 73 | #define sc_fp sc_ebp |
| 74 | #define sc_pc sc_eip |
| 75 | #define sc_ps sc_eflags |
| 76 | |
| 77 | struct netbsd32_sigframe_sigcontext { |
| 78 | uint32_t sf_ra; |
| 79 | int32_t sf_signum; |
| 80 | int32_t sf_code; |
| 81 | uint32_t sf_scp; |
| 82 | struct netbsd32_sigcontext sf_sc; |
| 83 | }; |
| 84 | |
| 85 | struct netbsd32_sigframe_siginfo { |
| 86 | uint32_t sf_ra; |
| 87 | int32_t sf_signum; |
| 88 | uint32_t sf_sip; |
| 89 | uint32_t sf_ucp; |
| 90 | siginfo32_t sf_si; |
| 91 | ucontext32_t sf_uc; |
| 92 | }; |
| 93 | |
| 94 | struct reg32 { |
| 95 | int r_eax; |
| 96 | int r_ecx; |
| 97 | int r_edx; |
| 98 | int r_ebx; |
| 99 | int r_esp; |
| 100 | int r_ebp; |
| 101 | int r_esi; |
| 102 | int r_edi; |
| 103 | int r_eip; |
| 104 | int r_eflags; |
| 105 | int r_cs; |
| 106 | int r_ss; |
| 107 | int r_ds; |
| 108 | int r_es; |
| 109 | int r_fs; |
| 110 | int r_gs; |
| 111 | }; |
| 112 | |
| 113 | struct fpreg32 { |
| 114 | char __data[108]; |
| 115 | }; |
| 116 | |
| 117 | struct mtrr32 { |
| 118 | uint64_t base; |
| 119 | uint64_t len; |
| 120 | uint8_t type; |
| 121 | uint8_t __pad0[3]; |
| 122 | int flags; |
| 123 | uint32_t owner; |
| 124 | } __packed; |
| 125 | |
| 126 | struct x86_64_get_mtrr_args32 { |
| 127 | uint32_t mtrrp; |
| 128 | uint32_t n; |
| 129 | }; |
| 130 | |
| 131 | struct x86_64_set_mtrr_args32 { |
| 132 | uint32_t mtrrp; |
| 133 | uint32_t n; |
| 134 | }; |
| 135 | |
| 136 | #define NETBSD32_MID_MACHINE MID_I386 |
| 137 | |
| 138 | int netbsd32_process_read_regs(struct lwp *, struct reg32 *); |
| 139 | int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *); |
| 140 | |
| 141 | int netbsd32_process_write_regs(struct lwp *, const struct reg32 *); |
| 142 | int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t); |
| 143 | |
| 144 | #endif /* _MACHINE_NETBSD32_H_ */ |
| 145 |