netbsd32_machdep.h revision 1.19.6.2 1 /* $NetBSD: netbsd32_machdep.h,v 1.19.6.2 2017/08/28 17:51:28 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 dbreg32 {
118 int dr[8];
119 };
120
121 struct x86_get_ldt_args32 {
122 int32_t start;
123 uint32_t desc;
124 int32_t num;
125 };
126
127 struct x86_set_ldt_args32 {
128 int32_t start;
129 uint32_t desc;
130 int32_t num;
131 };
132
133 struct mtrr32 {
134 uint64_t base;
135 uint64_t len;
136 uint8_t type;
137 uint8_t __pad0[3];
138 int flags;
139 uint32_t owner;
140 } __packed;
141
142 struct x86_64_get_mtrr_args32 {
143 uint32_t mtrrp;
144 uint32_t n;
145 };
146
147 struct x86_64_set_mtrr_args32 {
148 uint32_t mtrrp;
149 uint32_t n;
150 };
151
152 #define NETBSD32_MID_MACHINE MID_I386
153
154 int netbsd32_process_read_regs(struct lwp *, struct reg32 *);
155 int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *);
156 int netbsd32_process_read_dbregs(struct lwp *, struct dbreg32 *, size_t *);
157
158 int netbsd32_process_write_regs(struct lwp *, const struct reg32 *);
159 int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t);
160 int netbsd32_process_write_dbregs(struct lwp *, const struct dbreg32 *, size_t);
161
162 #endif /* _MACHINE_NETBSD32_H_ */
163