xref: /trueos/sys/sys/mach/task_info.h (revision 9c1dde6c551c2fcfdb84a29c80e2a77eff789c59)
1 /*
2  * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /*
29  * @OSF_COPYRIGHT@
30  */
31 /*
32  * Mach Operating System
33  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34  * All Rights Reserved.
35  *
36  * Permission to use, copy, modify and distribute this software and its
37  * documentation is hereby granted, provided that both the copyright
38  * notice and this permission notice appear in all copies of the
39  * software, derivative works or modified versions, and any portions
40  * thereof, and that both notices appear in supporting documentation.
41  *
42  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45  *
46  * Carnegie Mellon requests users of this software to return to
47  *
48  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
49  *  School of Computer Science
50  *  Carnegie Mellon University
51  *  Pittsburgh PA 15213-3890
52  *
53  * any improvements or extensions that they make and grant Carnegie Mellon
54  * the rights to redistribute these changes.
55  */
56 /*
57  *	Machine-independent task information structures and definitions.
58  *
59  *	The definitions in this file are exported to the user.  The kernel
60  *	will translate its internal data structures to these structures
61  *	as appropriate.
62  *
63  */
64 
65 #ifndef	_MACH_TASK_INFO_H_
66 #define	_MACH_TASK_INFO_H_
67 
68 #include <sys/mach/message.h>
69 #include <sys/mach/vm_types.h>
70 #include <sys/mach/time_value.h>
71 #include <sys/mach/policy.h>
72 #include <sys/mach/vm_statistics.h> /* for vm_extmod_statistics_data_t */
73 #ifndef _KERNEL
74 #include <Availability.h>
75 #endif
76 #include <sys/cdefs.h>
77 
78 /*
79  *	Generic information structure to allow for expansion.
80  */
81 typedef	natural_t	task_flavor_t;
82 typedef	integer_t	*task_info_t;		/* varying array of int */
83 
84 /* Deprecated, use per structure _data_t's instead */
85 #define	TASK_INFO_MAX	(1024)		/* maximum array size */
86 typedef	integer_t	task_info_data_t[TASK_INFO_MAX];
87 
88 /*
89  *	Currently defined information structures.
90  */
91 
92 #pragma pack(4)
93 
94 /* Don't use this, use MACH_TASK_BASIC_INFO instead */
95 #define TASK_BASIC_INFO_32      4       /* basic information */
96 #define TASK_BASIC2_INFO_32      6
97 
98 struct task_basic_info_32 {
99         integer_t       suspend_count;  /* suspend count for task */
100         natural_t       virtual_size;   /* virtual memory size (bytes) */
101         natural_t       resident_size;  /* resident memory size (bytes) */
102         time_value_t    user_time;      /* total user run time for
103                                            terminated threads */
104         time_value_t    system_time;    /* total system run time for
105                                            terminated threads */
106 	policy_t	policy;		/* default policy for new threads */
107 };
108 typedef struct task_basic_info_32       task_basic_info_32_data_t;
109 typedef struct task_basic_info_32       *task_basic_info_32_t;
110 #define TASK_BASIC_INFO_32_COUNT   \
111                 (sizeof(task_basic_info_32_data_t) / sizeof(natural_t))
112 
113 /* Don't use this, use MACH_TASK_BASIC_INFO instead */
114 struct task_basic_info_64 {
115         integer_t       suspend_count;  /* suspend count for task */
116         mach_vm_size_t  virtual_size;   /* virtual memory size (bytes) */
117         mach_vm_size_t  resident_size;  /* resident memory size (bytes) */
118         time_value_t    user_time;      /* total user run time for
119                                            terminated threads */
120         time_value_t    system_time;    /* total system run time for
121                                            terminated threads */
122 	policy_t	policy;		/* default policy for new threads */
123 };
124 typedef struct task_basic_info_64       task_basic_info_64_data_t;
125 typedef struct task_basic_info_64       *task_basic_info_64_t;
126 
127 #define TASK_BASIC_INFO_64      5       /* 64-bit capable basic info */
128 #define TASK_BASIC_INFO_64_COUNT   \
129                 (sizeof(task_basic_info_64_data_t) / sizeof(natural_t))
130 
131 
132 /* localized structure - cannot be safely passed between tasks of differing sizes */
133 /* Don't use this, use MACH_TASK_BASIC_INFO instead */
134 struct task_basic_info {
135         integer_t       suspend_count;  /* suspend count for task */
136         vm_size_t       virtual_size;   /* virtual memory size (bytes) */
137         vm_size_t       resident_size;  /* resident memory size (bytes) */
138         time_value_t    user_time;      /* total user run time for
139                                            terminated threads */
140         time_value_t    system_time;    /* total system run time for
141                                            terminated threads */
142 	policy_t	policy;		/* default policy for new threads */
143 };
144 
145 typedef struct task_basic_info          task_basic_info_data_t;
146 typedef struct task_basic_info          *task_basic_info_t;
147 #define TASK_BASIC_INFO_COUNT   \
148                 (sizeof(task_basic_info_data_t) / sizeof(natural_t))
149 #if !defined(__LP64__)
150 #define TASK_BASIC_INFO TASK_BASIC_INFO_32
151 #else
152 #define TASK_BASIC_INFO TASK_BASIC_INFO_64
153 #endif
154 
155 
156 
157 #define	TASK_EVENTS_INFO	2	/* various event counts */
158 
159 struct task_events_info {
160 	integer_t	faults;		/* number of page faults */
161 	integer_t 	pageins;	/* number of actual pageins */
162 	integer_t 	cow_faults;	/* number of copy-on-write faults */
163 	integer_t 	messages_sent;	/* number of messages sent */
164 	integer_t 	messages_received; /* number of messages received */
165         integer_t 	syscalls_mach;  /* number of mach system calls */
166 	integer_t 	syscalls_unix;  /* number of unix system calls */
167 	integer_t 	csw;            /* number of context switches */
168 };
169 typedef struct task_events_info		task_events_info_data_t;
170 typedef struct task_events_info		*task_events_info_t;
171 #define	TASK_EVENTS_INFO_COUNT		((mach_msg_type_number_t) \
172 		(sizeof(task_events_info_data_t) / sizeof(natural_t)))
173 
174 #define	TASK_THREAD_TIMES_INFO	3	/* total times for live threads -
175 					   only accurate if suspended */
176 
177 struct task_thread_times_info {
178 	time_value_t	user_time;	/* total user run time for
179 					   live threads */
180 	time_value_t	system_time;	/* total system run time for
181 					   live threads */
182 };
183 
184 typedef struct task_thread_times_info	task_thread_times_info_data_t;
185 typedef struct task_thread_times_info	*task_thread_times_info_t;
186 #define	TASK_THREAD_TIMES_INFO_COUNT	((mach_msg_type_number_t) \
187 		(sizeof(task_thread_times_info_data_t) / sizeof(natural_t)))
188 
189 #define TASK_ABSOLUTETIME_INFO	1
190 
191 struct task_absolutetime_info {
192 	uint64_t		total_user;
193 	uint64_t		total_system;
194 	uint64_t		threads_user;	/* existing threads only */
195 	uint64_t		threads_system;
196 };
197 
198 typedef struct task_absolutetime_info	task_absolutetime_info_data_t;
199 typedef struct task_absolutetime_info	*task_absolutetime_info_t;
200 #define TASK_ABSOLUTETIME_INFO_COUNT	((mach_msg_type_number_t) \
201 		(sizeof (task_absolutetime_info_data_t) / sizeof (natural_t)))
202 
203 #define TASK_KERNELMEMORY_INFO	7
204 
205 struct task_kernelmemory_info {
206 	uint64_t		total_palloc;	/* private kernel mem alloc'ed */
207 	uint64_t		total_pfree;	/* private kernel mem freed */
208 	uint64_t		total_salloc;	/* shared kernel mem alloc'ed */
209 	uint64_t		total_sfree;	/* shared kernel mem freed */
210 };
211 
212 typedef struct task_kernelmemory_info	task_kernelmemory_info_data_t;
213 typedef struct task_kernelmemory_info	*task_kernelmemory_info_t;
214 #define TASK_KERNELMEMORY_INFO_COUNT	((mach_msg_type_number_t) \
215 		(sizeof (task_kernelmemory_info_data_t) / sizeof (natural_t)))
216 
217 #define TASK_SECURITY_TOKEN		13
218 #define TASK_SECURITY_TOKEN_COUNT	((mach_msg_type_number_t) \
219 		(sizeof(security_token_t) / sizeof(natural_t)))
220 
221 #define TASK_AUDIT_TOKEN		15
222 #define TASK_AUDIT_TOKEN_COUNT	\
223 		(sizeof(audit_token_t) / sizeof(natural_t))
224 
225 
226 #define TASK_AFFINITY_TAG_INFO		16 	/* This is experimental. */
227 
228 struct task_affinity_tag_info {
229 	integer_t		set_count;
230 	integer_t		min;
231 	integer_t		max;
232 	integer_t		task_count;
233 };
234 typedef struct task_affinity_tag_info	task_affinity_tag_info_data_t;
235 typedef struct task_affinity_tag_info	*task_affinity_tag_info_t;
236 #define TASK_AFFINITY_TAG_INFO_COUNT	\
237 		(sizeof(task_affinity_tag_info_data_t) / sizeof(natural_t))
238 
239 #define TASK_DYLD_INFO			17
240 
241 struct task_dyld_info {
242 	mach_vm_address_t	all_image_info_addr;
243 	mach_vm_size_t		all_image_info_size;
244 	integer_t		all_image_info_format;
245 };
246 typedef struct task_dyld_info	task_dyld_info_data_t;
247 typedef struct task_dyld_info	*task_dyld_info_t;
248 #define TASK_DYLD_INFO_COUNT	\
249     		(sizeof(task_dyld_info_data_t) / sizeof(natural_t))
250 #define TASK_DYLD_ALL_IMAGE_INFO_32	0	/* format value */
251 #define TASK_DYLD_ALL_IMAGE_INFO_64	1	/* format value */
252 
253 
254 #define TASK_EXTMOD_INFO			19
255 
256 struct task_extmod_info {
257 	unsigned char	task_uuid[16];
258 	vm_extmod_statistics_data_t		extmod_statistics;
259 };
260 typedef struct task_extmod_info	task_extmod_info_data_t;
261 typedef struct task_extmod_info	*task_extmod_info_t;
262 #define TASK_EXTMOD_INFO_COUNT	\
263     		(sizeof(task_extmod_info_data_t) / sizeof(natural_t))
264 
265 
266 #define MACH_TASK_BASIC_INFO     20         /* always 64-bit basic info */
267 struct mach_task_basic_info {
268         mach_vm_size_t  virtual_size;       /* virtual memory size (bytes) */
269         mach_vm_size_t  resident_size;      /* resident memory size (bytes) */
270         mach_vm_size_t  resident_size_max;  /* maximum resident memory size (bytes) */
271         time_value_t    user_time;          /* total user run time for
272                                                terminated threads */
273         time_value_t    system_time;        /* total system run time for
274                                                terminated threads */
275         policy_t        policy;             /* default policy for new threads */
276         integer_t       suspend_count;      /* suspend count for task */
277 };
278 typedef struct mach_task_basic_info       mach_task_basic_info_data_t;
279 typedef struct mach_task_basic_info       *mach_task_basic_info_t;
280 #define MACH_TASK_BASIC_INFO_COUNT   \
281                 (sizeof(mach_task_basic_info_data_t) / sizeof(natural_t))
282 
283 
284 #define TASK_POWER_INFO	21
285 
286 struct task_power_info {
287 	uint64_t		total_user;
288 	uint64_t		total_system;
289 	uint64_t		task_interrupt_wakeups;
290 	uint64_t		task_platform_idle_wakeups;
291 	uint64_t		task_timer_wakeups_bin_1;
292 	uint64_t		task_timer_wakeups_bin_2;
293 };
294 
295 typedef struct task_power_info	task_power_info_data_t;
296 typedef struct task_power_info	*task_power_info_t;
297 #define TASK_POWER_INFO_COUNT	((mach_msg_type_number_t) \
298 		(sizeof (task_power_info_data_t) / sizeof (natural_t)))
299 
300 
301 
302 #define TASK_VM_INFO		22
303 #define TASK_VM_INFO_PURGEABLE	23
304 struct task_vm_info {
305         mach_vm_size_t  virtual_size;	    /* virtual memory size (bytes) */
306 	integer_t	region_count;	    /* number of memory regions */
307 	integer_t	page_size;
308         mach_vm_size_t  resident_size;	    /* resident memory size (bytes) */
309         mach_vm_size_t  resident_size_peak; /* peak resident size (bytes) */
310 
311 	mach_vm_size_t	device;
312 	mach_vm_size_t	device_peak;
313 	mach_vm_size_t	internal;
314 	mach_vm_size_t	internal_peak;
315 	mach_vm_size_t	external;
316 	mach_vm_size_t	external_peak;
317 	mach_vm_size_t	reusable;
318 	mach_vm_size_t	reusable_peak;
319 	mach_vm_size_t	purgeable_volatile_pmap;
320 	mach_vm_size_t	purgeable_volatile_resident;
321 	mach_vm_size_t	purgeable_volatile_virtual;
322 	mach_vm_size_t	compressed;
323 	mach_vm_size_t	compressed_peak;
324 	mach_vm_size_t	compressed_lifetime;
325 };
326 typedef struct task_vm_info	task_vm_info_data_t;
327 typedef struct task_vm_info	*task_vm_info_t;
328 #define TASK_VM_INFO_COUNT	((mach_msg_type_number_t) \
329 		(sizeof (task_vm_info_data_t) / sizeof (natural_t)))
330 
331 
332 typedef struct vm_purgeable_info	task_purgable_info_t;
333 
334 
335 #define TASK_TRACE_MEMORY_INFO  24
336 struct task_trace_memory_info {
337 	uint64_t  user_memory_address; 	/* address of start of trace memory buffer */
338 	uint64_t  buffer_size;			/* size of buffer in bytes */
339 	uint64_t  mailbox_array_size;	/* size of mailbox area in bytes */
340 };
341 typedef struct task_trace_memory_info task_trace_memory_info_data_t;
342 typedef struct task_trace_memory_info * task_trace_memory_info_t;
343 #define TASK_TRACE_MEMORY_INFO_COUNT  ((mach_msg_type_number_t) \
344 		(sizeof(task_trace_memory_info_data_t) / sizeof(natural_t)))
345 
346 #define TASK_WAIT_STATE_INFO  25    /* deprecated. */
347 struct task_wait_state_info {
348 	uint64_t  total_wait_state_time;	/* Time that all threads past and present have been in a wait state */
349 	uint64_t  total_wait_sfi_state_time;	/* Time that threads have been in SFI wait (should be a subset of total wait state time */
350 	uint32_t  _reserved[4];
351 };
352 typedef struct task_wait_state_info task_wait_state_info_data_t;
353 typedef struct task_wait_state_info * task_wait_state_info_t;
354 #define TASK_WAIT_STATE_INFO_COUNT  ((mach_msg_type_number_t) \
355 		(sizeof(task_wait_state_info_data_t) / sizeof(natural_t)))
356 
357 #define TASK_POWER_INFO_V2	26
358 
359 typedef struct {
360 	uint64_t		task_gpu_utilisation;
361 	uint64_t		task_gpu_stat_reserved0;
362 	uint64_t		task_gpu_stat_reserved1;
363 	uint64_t		task_gpu_stat_reserved2;
364 } gpu_energy_data;
365 
366 typedef gpu_energy_data *gpu_energy_data_t;
367 struct task_power_info_v2 {
368 	task_power_info_data_t	cpu_energy;
369 	gpu_energy_data gpu_energy;
370 };
371 
372 typedef struct task_power_info_v2	task_power_info_v2_data_t;
373 typedef struct task_power_info_v2	*task_power_info_v2_t;
374 #define TASK_POWER_INFO_V2_COUNT	((mach_msg_type_number_t) \
375 		(sizeof (task_power_info_v2_data_t) / sizeof (natural_t)))
376 
377 /*
378  * Obsolete interfaces.
379  */
380 
381 #define TASK_SCHED_TIMESHARE_INFO	10
382 #define TASK_SCHED_RR_INFO		11
383 #define TASK_SCHED_FIFO_INFO		12
384 
385 #define TASK_SCHED_INFO			14
386 
387 #pragma pack()
388 
389 #endif	/* _MACH_TASK_INFO_H_ */
390