]>
Commit | Line | Data |
---|---|---|
25fb5d38 WL |
1 | /* |
2 | * sys/user.h definitions | |
3 | * | |
4 | * Copyright (c) 2015 Stacey D. Son (sson at FreeBSD) | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
9c092804 MA |
20 | #ifndef TARGET_OS_USER_H |
21 | #define TARGET_OS_USER_H | |
25fb5d38 WL |
22 | |
23 | /* | |
24 | * from sys/priority.h | |
25 | */ | |
26 | struct target_priority { | |
27 | uint8_t pri_class; /* Scheduling class. */ | |
28 | uint8_t pri_level; /* Normal priority level. */ | |
29 | uint8_t pri_native; /* Priority before propogation. */ | |
30 | uint8_t pri_user; /* User priority based on p_cpu and p_nice. */ | |
31 | }; | |
32 | ||
33 | /* | |
34 | * sys/caprights.h | |
35 | */ | |
36 | #define TARGET_CAP_RIGHTS_VERSION 0 | |
37 | ||
38 | typedef struct target_cap_rights { | |
39 | uint64_t cr_rights[TARGET_CAP_RIGHTS_VERSION + 2]; | |
40 | } target_cap_rights_t; | |
41 | ||
42 | /* | |
43 | * From sys/_socketaddr_storage.h | |
44 | * | |
45 | */ | |
46 | #define TARGET_SS_MAXSIZE 128U | |
47 | #define TARGET_SS_ALIGNSIZE (sizeof(__int64_t)) | |
48 | #define TARGET_SS_PAD1SIZE (TARGET_SS_ALIGNSIZE - sizeof(unsigned char) - \ | |
49 | sizeof(uint8_t)) | |
50 | #define TARGET_SS_PAD2SIZE (TARGET_SS_MAXSIZE - sizeof(unsigned char) - \ | |
51 | sizeof(uint8_t) - TARGET_SS_PAD1SIZE - TARGET_SS_ALIGNSIZE) | |
52 | ||
53 | struct target_sockaddr_storage { | |
54 | unsigned char ss_len; /* address length */ | |
55 | uint8_t ss_family; /* address family */ | |
56 | char __ss_pad1[TARGET_SS_PAD1SIZE]; | |
57 | __int64_t __ss_align; /* force desired struct alignment */ | |
58 | char __ss_pad2[TARGET_SS_PAD2SIZE]; | |
59 | }; | |
60 | ||
61 | /* | |
62 | * from sys/user.h | |
63 | */ | |
25fb5d38 | 64 | #define TARGET_KI_NSPARE_INT 2 |
25fb5d38 WL |
65 | #define TARGET_KI_NSPARE_LONG 12 |
66 | #define TARGET_KI_NSPARE_PTR 6 | |
67 | ||
68 | #define TARGET_WMESGLEN 8 | |
69 | #define TARGET_LOCKNAMELEN 8 | |
70 | #define TARGET_TDNAMLEN 16 | |
71 | #define TARGET_COMMLEN 19 | |
72 | #define TARGET_KI_EMULNAMELEN 16 | |
73 | #define TARGET_KI_NGROUPS 16 | |
74 | #define TARGET_LOGNAMELEN 17 | |
75 | #define TARGET_LOGINCLASSLEN 17 | |
76 | ||
77 | #define TARGET_KF_TYPE_NONE 0 | |
78 | #define TARGET_KF_TYPE_VNODE 1 | |
79 | #define TARGET_KF_TYPE_SOCKET 2 | |
80 | #define TARGET_KF_TYPE_PIPE 3 | |
81 | #define TARGET_KF_TYPE_FIFO 4 | |
82 | #define TARGET_KF_TYPE_KQUEUE 5 | |
83 | #define TARGET_KF_TYPE_CRYPTO 6 | |
84 | #define TARGET_KF_TYPE_MQUEUE 7 | |
85 | #define TARGET_KF_TYPE_SHM 8 | |
86 | #define TARGET_KF_TYPE_SEM 9 | |
87 | #define TARGET_KF_TYPE_PTS 10 | |
88 | #define TARGET_KF_TYPE_PROCDESC 11 | |
89 | #define TARGET_KF_TYPE_DEV 12 | |
90 | #define TARGET_KF_TYPE_UNKNOWN 255 | |
91 | ||
92 | struct target_kinfo_proc { | |
93 | int32_t ki_structsize; /* size of this structure */ | |
94 | int32_t ki_layout; /* reserved: layout identifier */ | |
95 | abi_ulong ki_args; /* address of command arguments */ | |
96 | abi_ulong ki_paddr; /* address of proc */ | |
97 | abi_ulong ki_addr; /* kernel virtual addr of u-area */ | |
98 | abi_ulong ki_tracep; /* pointer to trace file */ | |
99 | abi_ulong ki_textvp; /* pointer to executable file */ | |
100 | abi_ulong ki_fd; /* pointer to open file info */ | |
101 | abi_ulong ki_vmspace; /* pointer to kernel vmspace struct */ | |
102 | abi_ulong ki_wchan; /* sleep address */ | |
103 | int32_t ki_pid; /* Process identifier */ | |
104 | int32_t ki_ppid; /* parent process id */ | |
105 | int32_t ki_pgid; /* process group id */ | |
106 | int32_t ki_tpgid; /* tty process group id */ | |
107 | int32_t ki_sid; /* Process session ID */ | |
108 | int32_t ki_tsid; /* Terminal session ID */ | |
109 | int16_t ki_jobc; /* job control counter */ | |
110 | int16_t ki_spare_short1; /* unused (just here for alignment) */ | |
25fb5d38 | 111 | int32_t ki_tdev__freebsd11; /* controlling tty dev */ |
25fb5d38 WL |
112 | target_sigset_t ki_siglist; /* Signals arrived but not delivered */ |
113 | target_sigset_t ki_sigmask; /* Current signal mask */ | |
114 | target_sigset_t ki_sigignore; /* Signals being ignored */ | |
115 | target_sigset_t ki_sigcatch; /* Signals being caught by user */ | |
116 | ||
117 | int32_t ki_uid; /* effective user id */ | |
118 | int32_t ki_ruid; /* Real user id */ | |
119 | int32_t ki_svuid; /* Saved effective user id */ | |
120 | int32_t ki_rgid; /* Real group id */ | |
121 | int32_t ki_svgid; /* Saved effective group id */ | |
122 | int16_t ki_ngroups; /* number of groups */ | |
123 | int16_t ki_spare_short2; /* unused (just here for alignment) */ | |
124 | int32_t ki_groups[TARGET_KI_NGROUPS]; /* groups */ | |
125 | ||
126 | abi_long ki_size; /* virtual size */ | |
127 | ||
128 | abi_long ki_rssize; /* current resident set size in pages */ | |
129 | abi_long ki_swrss; /* resident set size before last swap */ | |
130 | abi_long ki_tsize; /* text size (pages) XXX */ | |
131 | abi_long ki_dsize; /* data size (pages) XXX */ | |
132 | abi_long ki_ssize; /* stack size (pages) */ | |
133 | ||
134 | uint16_t ki_xstat; /* Exit status for wait & stop signal */ | |
135 | uint16_t ki_acflag; /* Accounting flags */ | |
136 | ||
137 | uint32_t ki_pctcpu; /* %cpu for process during ki_swtime */ | |
138 | ||
139 | uint32_t ki_estcpu; /* Time averaged value of ki_cpticks */ | |
140 | uint32_t ki_slptime; /* Time since last blocked */ | |
141 | uint32_t ki_swtime; /* Time swapped in or out */ | |
142 | uint32_t ki_cow; /* number of copy-on-write faults */ | |
143 | uint64_t ki_runtime; /* Real time in microsec */ | |
144 | ||
145 | struct target_freebsd_timeval ki_start; /* starting time */ | |
146 | struct target_freebsd_timeval ki_childtime; /* time used by process children */ | |
147 | ||
148 | abi_long ki_flag; /* P_* flags */ | |
149 | abi_long ki_kiflag; /* KI_* flags (below) */ | |
150 | int32_t ki_traceflag; /* Kernel trace points */ | |
151 | char ki_stat; /* S* process status */ | |
152 | int8_t ki_nice; /* Process "nice" value */ | |
153 | char ki_lock; /* Process lock (prevent swap) count */ | |
154 | char ki_rqindex; /* Run queue index */ | |
25fb5d38 WL |
155 | u_char ki_oncpu_old; /* Which cpu we are on (legacy) */ |
156 | u_char ki_lastcpu_old; /* Last cpu we were on (legacy) */ | |
25fb5d38 | 157 | char ki_tdname[TARGET_TDNAMLEN + 1]; /* thread name */ |
25fb5d38 WL |
158 | char ki_wmesg[TARGET_WMESGLEN + 1]; /* wchan message */ |
159 | char ki_login[TARGET_LOGNAMELEN + 1]; /* setlogin name */ | |
160 | char ki_lockname[TARGET_LOCKNAMELEN + 1]; /* lock name */ | |
161 | char ki_comm[TARGET_COMMLEN + 1]; /* command name */ | |
162 | char ki_emul[TARGET_KI_EMULNAMELEN + 1]; /* emulation name */ | |
25fb5d38 | 163 | char ki_loginclass[TARGET_LOGINCLASSLEN + 1]; /* login class */ |
25fb5d38 | 164 | |
25fb5d38 | 165 | char ki_sparestrings[50]; /* spare string space */ |
25fb5d38 | 166 | int32_t ki_spareints[TARGET_KI_NSPARE_INT]; /* spare room for growth */ |
1fecb605 | 167 | uint64_t ki_tdev; /* controlling tty dev */ |
25fb5d38 WL |
168 | int32_t ki_oncpu; /* Which cpu we are on */ |
169 | int32_t ki_lastcpu; /* Last cpu we were on */ | |
170 | int32_t ki_tracer; /* Pid of tracing process */ | |
25fb5d38 WL |
171 | int32_t ki_flag2; /* P2_* flags */ |
172 | int32_t ki_fibnum; /* Default FIB number */ | |
25fb5d38 WL |
173 | uint32_t ki_cr_flags; /* Credential flags */ |
174 | int32_t ki_jid; /* Process jail ID */ | |
175 | int32_t ki_numthreads; /* XXXKSE number of threads in total */ | |
176 | ||
177 | int32_t ki_tid; /* XXXKSE thread id */ | |
178 | ||
179 | struct target_priority ki_pri; /* process priority */ | |
180 | struct target_freebsd_rusage ki_rusage; /* process rusage statistics */ | |
181 | /* XXX - most fields in ki_rusage_ch are not (yet) filled in */ | |
182 | struct target_freebsd_rusage ki_rusage_ch; /* rusage of children processes */ | |
183 | ||
184 | ||
185 | abi_ulong ki_pcb; /* kernel virtual addr of pcb */ | |
186 | abi_ulong ki_kstack; /* kernel virtual addr of stack */ | |
187 | abi_ulong ki_udata; /* User convenience pointer */ | |
188 | abi_ulong ki_tdaddr; /* address of thread */ | |
189 | ||
190 | abi_ulong ki_spareptrs[TARGET_KI_NSPARE_PTR]; /* spare room for growth */ | |
191 | abi_long ki_sparelongs[TARGET_KI_NSPARE_LONG];/* spare room for growth */ | |
192 | abi_long ki_sflag; /* PS_* flags */ | |
193 | abi_long ki_tdflags; /* XXXKSE kthread flag */ | |
194 | }; | |
195 | ||
196 | struct target_kinfo_file { | |
197 | int32_t kf_structsize; /* Variable size of record. */ | |
198 | int32_t kf_type; /* Descriptor type. */ | |
199 | int32_t kf_fd; /* Array index. */ | |
200 | int32_t kf_ref_count; /* Reference count. */ | |
201 | int32_t kf_flags; /* Flags. */ | |
202 | int32_t kf_pad0; /* Round to 64 bit alignment. */ | |
203 | int64_t kf_offset; /* Seek location. */ | |
25fb5d38 WL |
204 | union { |
205 | struct { | |
25fb5d38 WL |
206 | uint32_t kf_spareint; |
207 | /* Socket domain. */ | |
208 | int kf_sock_domain0; | |
209 | /* Socket type. */ | |
210 | int kf_sock_type0; | |
211 | /* Socket protocol. */ | |
212 | int kf_sock_protocol0; | |
213 | /* Socket address. */ | |
214 | struct sockaddr_storage kf_sa_local; | |
215 | /* Peer address. */ | |
216 | struct sockaddr_storage kf_sa_peer; | |
25fb5d38 WL |
217 | /* Address of so_pcb. */ |
218 | uint64_t kf_sock_pcb; | |
219 | /* Address of inp_ppcb. */ | |
220 | uint64_t kf_sock_inpcb; | |
221 | /* Address of unp_conn. */ | |
222 | uint64_t kf_sock_unpconn; | |
223 | /* Send buffer state. */ | |
224 | uint16_t kf_sock_snd_sb_state; | |
225 | /* Receive buffer state. */ | |
226 | uint16_t kf_sock_rcv_sb_state; | |
227 | /* Round to 64 bit alignment. */ | |
228 | uint32_t kf_sock_pad0; | |
229 | } kf_sock; | |
230 | struct { | |
25fb5d38 WL |
231 | /* Vnode type. */ |
232 | int kf_file_type; | |
233 | /* Space for future use */ | |
234 | int kf_spareint[3]; | |
235 | uint64_t kf_spareint64[30]; | |
236 | /* Vnode filesystem id. */ | |
237 | uint64_t kf_file_fsid; | |
238 | /* File device. */ | |
239 | uint64_t kf_file_rdev; | |
240 | /* Global file id. */ | |
241 | uint64_t kf_file_fileid; | |
242 | /* File size. */ | |
243 | uint64_t kf_file_size; | |
244 | /* Vnode filesystem id, FreeBSD 11 compat. */ | |
245 | uint32_t kf_file_fsid_freebsd11; | |
246 | /* File device, FreeBSD 11 compat. */ | |
247 | uint32_t kf_file_rdev_freebsd11; | |
25fb5d38 WL |
248 | /* File mode. */ |
249 | uint16_t kf_file_mode; | |
250 | /* Round to 64 bit alignment. */ | |
251 | uint16_t kf_file_pad0; | |
252 | uint32_t kf_file_pad1; | |
253 | } kf_file; | |
254 | struct { | |
25fb5d38 WL |
255 | uint32_t kf_spareint[4]; |
256 | uint64_t kf_spareint64[32]; | |
25fb5d38 WL |
257 | uint32_t kf_sem_value; |
258 | uint16_t kf_sem_mode; | |
259 | } kf_sem; | |
260 | struct { | |
25fb5d38 WL |
261 | uint32_t kf_spareint[4]; |
262 | uint64_t kf_spareint64[32]; | |
25fb5d38 WL |
263 | uint64_t kf_pipe_addr; |
264 | uint64_t kf_pipe_peer; | |
265 | uint32_t kf_pipe_buffer_cnt; | |
266 | /* Round to 64 bit alignment. */ | |
267 | uint32_t kf_pipe_pad0[3]; | |
268 | } kf_pipe; | |
269 | struct { | |
25fb5d38 WL |
270 | uint32_t kf_spareint[4]; |
271 | uint64_t kf_spareint64[32]; | |
272 | uint32_t kf_pts_dev_freebsd11; | |
273 | uint32_t kf_pts_pad0; | |
274 | uint64_t kf_pts_dev; | |
275 | /* Round to 64 bit alignment. */ | |
276 | uint32_t kf_pts_pad1[4]; | |
25fb5d38 WL |
277 | } kf_pts; |
278 | struct { | |
25fb5d38 WL |
279 | uint32_t kf_spareint[4]; |
280 | uint64_t kf_spareint64[32]; | |
25fb5d38 WL |
281 | int32_t kf_pid; |
282 | } kf_proc; | |
283 | } kf_un; | |
284 | uint16_t kf_status; /* Status flags. */ | |
285 | uint16_t kf_pad1; /* Round to 32 bit alignment. */ | |
286 | int32_t _kf_ispare0; /* Space for more stuff. */ | |
25fb5d38 WL |
287 | target_cap_rights_t kf_cap_rights; /* Capability rights. */ |
288 | uint64_t _kf_cap_spare; /* Space for future cap_rights_t. */ | |
25fb5d38 WL |
289 | /* Truncated before copyout in sysctl */ |
290 | char kf_path[PATH_MAX]; /* Path to file, if any. */ | |
291 | }; | |
292 | ||
293 | struct target_kinfo_vmentry { | |
294 | int32_t kve_structsize; /* Variable size of record. */ | |
295 | int32_t kve_type; /* Type of map entry. */ | |
296 | uint64_t kve_start; /* Starting address. */ | |
297 | uint64_t kve_end; /* Finishing address. */ | |
298 | uint64_t kve_offset; /* Mapping offset in object */ | |
25fb5d38 | 299 | uint64_t kve_vn_fileid; /* inode number if vnode */ |
25fb5d38 | 300 | uint32_t kve_vn_fsid_freebsd11; /* dev_t of vnode location */ |
25fb5d38 WL |
301 | int32_t kve_flags; /* Flags on map entry. */ |
302 | int32_t kve_resident; /* Number of resident pages. */ | |
303 | int32_t kve_private_resident; /* Number of private pages. */ | |
304 | int32_t kve_protection; /* Protection bitmask. */ | |
305 | int32_t kve_ref_count; /* VM obj ref count. */ | |
306 | int32_t kve_shadow_count; /* VM obj shadow count. */ | |
25fb5d38 WL |
307 | int32_t kve_vn_type; /* Vnode type. */ |
308 | uint64_t kve_vn_size; /* File size. */ | |
25fb5d38 | 309 | uint32_t kve_vn_rdev_freebsd11; /* Device id if device. */ |
25fb5d38 WL |
310 | uint16_t kve_vn_mode; /* File mode. */ |
311 | uint16_t kve_status; /* Status flags. */ | |
25fb5d38 WL |
312 | #if (__FreeBSD_version >= 1300501 && __FreeBSD_version < 1400000) || \ |
313 | __FreeBSD_version >= 1400009 | |
314 | union { | |
315 | uint64_t _kve_vn_fsid; /* dev_t of vnode location */ | |
316 | uint64_t _kve_obj; /* handle of anon obj */ | |
317 | } kve_type_spec; | |
318 | #define kve_vn_fsid kve_type_spec._kve_vn_fsid | |
319 | #define kve_obj kve_type_spec._kve_obj | |
320 | #else | |
321 | uint64_t kve_vn_fsid; /* dev_t of vnode location */ | |
322 | #endif | |
323 | uint64_t kve_vn_rdev; /* Device id if device. */ | |
324 | int _kve_ispare[8]; /* Space for more stuff. */ | |
25fb5d38 WL |
325 | /* Truncated before copyout in sysctl */ |
326 | char kve_path[PATH_MAX]; /* Path to VM obj, if any. */ | |
327 | }; | |
328 | ||
9c092804 | 329 | #endif /* TARGET_OS_USER_H */ |