]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/task.h
xnu-1699.24.23.tar.gz
[apple/xnu.git] / osfmk / kern / task.h
CommitLineData
1c79356b 1/*
b0d623f7 2 * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_FREE_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988 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 */
58/*
59 * File: task.h
60 * Author: Avadis Tevanian, Jr.
61 *
62 * This file contains the structure definitions for tasks.
63 *
64 */
65/*
66 * Copyright (c) 1993 The University of Utah and
67 * the Computer Systems Laboratory (CSL). All rights reserved.
68 *
69 * Permission to use, copy, modify and distribute this software and its
70 * documentation is hereby granted, provided that both the copyright
71 * notice and this permission notice appear in all copies of the
72 * software, derivative works or modified versions, and any portions
73 * thereof, and that both notices appear in supporting documentation.
74 *
75 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
76 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
77 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
78 *
79 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
80 * improvements that they make and grant CSL redistribution rights.
81 *
82 */
2d21ac55
A
83/*
84 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
85 * support for mandatory and extensible security protections. This notice
86 * is included in support of clause 2.2 (b) of the Apple Public License,
87 * Version 2.0.
88 * Copyright (c) 2005 SPARTA, Inc.
89 */
1c79356b
A
90
91#ifndef _KERN_TASK_H_
92#define _KERN_TASK_H_
93
94#include <kern/kern_types.h>
95#include <mach/mach_types.h>
91447636 96#include <sys/cdefs.h>
9bccf70c
A
97
98#ifdef MACH_KERNEL_PRIVATE
99
1c79356b
A
100#include <mach/boolean.h>
101#include <mach/port.h>
102#include <mach/time_value.h>
103#include <mach/message.h>
104#include <mach/mach_param.h>
105#include <mach/task_info.h>
106#include <mach/exception_types.h>
6d2010ae 107#include <mach/vm_statistics.h>
0c530ab8 108#include <machine/task.h>
91447636
A
109
110#include <kern/cpu_data.h>
1c79356b
A
111#include <kern/queue.h>
112#include <kern/exception.h>
113#include <kern/lock.h>
2d21ac55
A
114#include <security/_label.h>
115#include <ipc/ipc_labelh.h>
6d2010ae
A
116#endif /* MACH_KERNEL_PRIVATE */
117
118#ifdef XNU_KERNEL_PRIVATE
119
120/* defns for task->rsu_controldata */
121#define TASK_POLICY_CPU_RESOURCE_USAGE 0
122#define TASK_POLICY_WIREDMEM_RESOURCE_USAGE 1
123#define TASK_POLICY_VIRTUALMEM_RESOURCE_USAGE 2
124#define TASK_POLICY_DISK_RESOURCE_USAGE 3
125#define TASK_POLICY_NETWORK_RESOURCE_USAGE 4
126#define TASK_POLICY_POWER_RESOURCE_USAGE 5
127
128#define TASK_POLICY_RESOURCE_USAGE_COUNT 6
129
130/*
131 * Process Action and Policy bit definitions
132
133The bit defns of the policy states
13464 60 56 52 48 44 40 36 32 28 24 20 16 12 8 0
135|----|-----|----|----|----|----|----|----|----|----|----|----|----|----|--------|
136|RFU | RFU | PWR| NET| DSK| CPU| VM | WM | LVM| RFU| CPU| NET| GPU| DSK| BGRND |
137|----|-----|----|----|----|----|----|----|----|----|----|----|----|----|--------|
138|<----------- RESOURCE USAGE -------->|< LOWSRC>|<-HARDWARE ACCESS->|BackGrnd|
139|----|-----|----|----|----|----|----|----|----|----|----|----|----|----|--------|
140
141*
142*/
143
144#define TASK_POLICY_BACKGROUND_ATTRIBUTE_NONE 0x00
145#define TASK_POLICY_BACKGROUND_ATTRIBUTE_LOWPRI 0x01
146#define TASK_POLICY_BACKGROUND_ATTRIBUTE_DISKTHROTTLE 0x02
147#define TASK_POLICY_BACKGROUND_ATTRIBUTE_NETTHROTTLE 0x04
148#define TASK_POLICY_BACKGROUND_ATTRIBUTE_NOGPU 0x08
149#if CONFIG_EMBEDDED
150#define TASK_POLICY_BACKGROUND_ATTRIBUTE_ALL 0x0F
151#else /* CONFIG_EMBEDDED */
152#define TASK_POLICY_BACKGROUND_ATTRIBUTE_ALL 0x07
153#endif /* CONFIG_EMBEDDED */
154#define TASK_POLICY_BACKGROUND_ATTRIBUTE_DEFAULT TASK_POLICY_BACKGROUND_ATTRIBUTE_ALL
155
156/* Hardware disk access attributes, bit different as it should reflect IOPOL_XXX */
157#define TASK_POLICY_HWACCESS_DISK_ATTRIBUTE_NONE 0x00
158#define TASK_POLICY_HWACCESS_DISK_ATTRIBUTE_NORMAL 0x01
159#define TASK_POLICY_HWACCESS_DISK_ATTRIBUTE_PASSIVE 0x02
160#define TASK_POLICY_HWACCESS_DISK_ATTRIBUTE_THROTTLE 0x03
161#define TASK_POLICY_HWACCESS_DISK_ATTRIBUTE_DEFAULT TASK_POLICY_HWACCESS_DISK_ATTRIBUTE_NORMAL
162
163/* Hardware disk access attributes */
164#define TASK_POLICY_HWACCESS_GPU_ATTRIBUTE_NONE 0x00
165#define TASK_POLICY_HWACCESS_GPU_ATTRIBUTE_NORMAL 0x00
166#define TASK_POLICY_HWACCESS_GPU_ATTRIBUTE_FULLACCESS 0x00
167#define TASK_POLICY_HWACCESS_GPU_ATTRIBUTE_NOACCESS 0x01
168#define TASK_POLICY_HWACCESS_GPU_ATTRIBUTE_DEFAULT 0x00
169
170/* Hardware Network access attributes */
171#define TASK_POLICY_HWACCESS_NET_ATTRIBUTE_NONE 0x00
172#define TASK_POLICY_HWACCESS_NET_ATTRIBUTE_NORMAL 0x00
173#define TASK_POLICY_HWACCESS_NET_ATTRIBUTE_THROTTLE 0x01
174#define TASK_POLICY_HWACCESS_NET_ATTRIBUTE_DEFAULT 0x00
175
176/* Hardware CPU access attributes */
177#define TASK_POLICY_HWACCESS_CPU_ATTRIBUTE_NONE 0x00
178#define TASK_POLICY_HWACCESS_CPU_ATTRIBUTE_NORMAL 0x00
179#define TASK_POLICY_HWACCESS_CPU_ATTRIBUTE_ALL 0x00
180#define TASK_POLICY_HWACCESS_CPU_ATTRIBUTE_ONE 0x01
181#define TASK_POLICY_HWACCESS_CPU_ATTRIBUTE_LLCACHE 0x02
182#define TASK_POLICY_HWACCESS_CPU_ATTRIBUTE_DEFAULT 0x00
183
184/* Resource usage/low resource attributes */
185#define TASK_POLICY_RESOURCE_ATTRIBUTE_NONE 0x00
186#define TASK_POLICY_RESOURCE_ATTRIBUTE_THROTTLE 0x01
187#define TASK_POLICY_RESOURCE_ATTRIBUTE_SUSPEND 0x02
188#define TASK_POLICY_RESOURCE_ATTRIBUTE_TERMINATE 0x03
189#define TASK_POLICY_RESOURCE_ATTRIBUTE_NOTIFY 0x04
190#define TASK_POLICY_RESOURCE_ATTRIBUTE_DEFAULT 0x00
191
192#endif /* XNU_KERNEL_PRIVATE */
193
194#ifdef MACH_KERNEL_PRIVATE
195
196typedef struct process_policy {
197 uint64_t apptype:4,
198 rfu1:4,
199 ru_power:4, /* Resource Usage Power */
200 ru_net:4, /* Resource Usage Network */
201 ru_disk:4, /* Resource Usage Disk */
202 ru_cpu:4, /* Resource Usage CPU */
203 ru_virtmem:4, /* Resource Usage VM */
204 ru_wiredmem:4,/* Resource Usage Wired Memory */
205 low_vm:4, /* Low Virtual Memory */
206 rfu2:4,
207 hw_cpu:4, /* HW Access to CPU */
208 hw_net:4, /* HW Access to Network */
209 hw_gpu:4, /* HW Access to GPU */
210 hw_disk:4, /* HW Access to Disk */
211 hw_bg:8; /* Darwin Background Policy */
212} process_policy_t;
213
214#include <kern/thread.h>
215
216extern process_policy_t default_task_proc_policy; /* init value for the process policy attributes */
217extern process_policy_t default_task_null_policy; /* none as the value for the process policy attributes */
1c79356b 218
91447636 219struct task {
1c79356b 220 /* Synchronization/destruction information */
b0d623f7 221 decl_lck_mtx_data(,lock) /* Task's lock */
2d21ac55 222 uint32_t ref_count; /* Number of references to me */
1c79356b 223 boolean_t active; /* Task has not been terminated */
b0d623f7 224 boolean_t halting; /* Task is being halted */
1c79356b
A
225
226 /* Miscellaneous */
227 vm_map_t map; /* Address space description */
2d21ac55 228 queue_chain_t tasks; /* global list of tasks */
1c79356b 229 void *user_data; /* Arbitrary data settable via IPC */
1c79356b 230
55e303ae 231 /* Threads in this task */
2d21ac55 232 queue_head_t threads;
b0d623f7
A
233
234 processor_set_t pset_hint;
235 struct affinity_space *affinity_space;
236
2d21ac55
A
237 int thread_count;
238 uint32_t active_thread_count;
b0d623f7 239 int suspend_count; /* Internal scheduling only */
1c79356b
A
240
241 /* User-visible scheduling information */
242 integer_t user_stop_count; /* outstanding stops */
243
0b4e3aa0 244 task_role_t role;
1c79356b 245
0b4e3aa0
A
246 integer_t priority; /* base priority for threads */
247 integer_t max_priority; /* maximum priority for threads */
1c79356b 248
55e303ae 249 /* Task security and audit tokens */
1c79356b 250 security_token_t sec_token;
55e303ae 251 audit_token_t audit_token;
1c79356b
A
252
253 /* Statistics */
91447636
A
254 uint64_t total_user_time; /* terminated threads only */
255 uint64_t total_system_time;
1c79356b 256
2d21ac55
A
257 /* Virtual timers */
258 uint32_t vtimers;
1c79356b
A
259
260 /* IPC structures */
b0d623f7 261 decl_lck_mtx_data(,itk_lock_data)
1c79356b 262 struct ipc_port *itk_self; /* not a right, doesn't hold ref */
0c530ab8 263 struct ipc_port *itk_nself; /* not a right, doesn't hold ref */
1c79356b
A
264 struct ipc_port *itk_sself; /* a send right */
265 struct exception_action exc_actions[EXC_TYPES_COUNT];
266 /* a send right each valid element */
267 struct ipc_port *itk_host; /* a send right */
268 struct ipc_port *itk_bootstrap; /* a send right */
2d21ac55
A
269 struct ipc_port *itk_seatbelt; /* a send right */
270 struct ipc_port *itk_gssd; /* yet another send right */
271 struct ipc_port *itk_task_access; /* and another send right */
1c79356b
A
272 struct ipc_port *itk_registered[TASK_PORT_REGISTER_MAX];
273 /* all send rights */
274
275 struct ipc_space *itk_space;
276
1c79356b
A
277 /* Synchronizer ownership information */
278 queue_head_t semaphore_list; /* list of owned semaphores */
279 queue_head_t lock_set_list; /* list of owned lock sets */
280 int semaphores_owned; /* number of semaphores owned */
281 int lock_sets_owned; /* number of lock sets owned */
282
91447636 283 /* Ledgers */
1c79356b
A
284 struct ipc_port *wired_ledger_port;
285 struct ipc_port *paged_ledger_port;
91447636
A
286 unsigned int priv_flags; /* privilege resource flags */
287#define VM_BACKING_STORE_PRIV 0x1
0c530ab8
A
288
289 MACHINE_TASK
1c79356b 290
1c79356b
A
291 integer_t faults; /* faults counter */
292 integer_t pageins; /* pageins counter */
293 integer_t cow_faults; /* copy on write fault counter */
294 integer_t messages_sent; /* messages sent counter */
295 integer_t messages_received; /* messages received counter */
296 integer_t syscalls_mach; /* mach system call counter */
297 integer_t syscalls_unix; /* unix system call counter */
6d2010ae
A
298 uint32_t c_switch; /* total context switches */
299 uint32_t p_switch; /* total processor switches */
300 uint32_t ps_switch; /* total pset switches */
301
302 zinfo_usage_store_t tkm_private;/* private kmem alloc/free stats (reaped threads) */
303 zinfo_usage_store_t tkm_shared; /* shared kmem alloc/free stats (reaped threads) */
304 zinfo_usage_t tkm_zinfo; /* per-task, per-zone usage statistics */
305
1c79356b
A
306#ifdef MACH_BSD
307 void *bsd_info;
308#endif
2d21ac55 309 struct vm_shared_region *shared_region;
55e303ae
A
310 uint32_t taskFeatures[2]; /* Special feature for this task */
311#define tf64BitAddr 0x80000000 /* Task has 64-bit addressing */
312#define tf64BitData 0x40000000 /* Task has 64-bit data registers */
91447636
A
313#define task_has_64BitAddr(task) \
314 (((task)->taskFeatures[0] & tf64BitAddr) != 0)
315#define task_set_64BitAddr(task) \
316 ((task)->taskFeatures[0] |= tf64BitAddr)
317#define task_clear_64BitAddr(task) \
318 ((task)->taskFeatures[0] &= ~tf64BitAddr)
319
b0d623f7
A
320 mach_vm_address_t all_image_info_addr; /* dyld __all_image_info */
321 mach_vm_size_t all_image_info_size; /* section location and size */
2d21ac55
A
322#if CONFIG_MACF_MACH
323 ipc_labelh_t label;
324#endif
325
b0d623f7
A
326#if CONFIG_COUNTERS
327#define TASK_PMC_FLAG 0x1 /* Bit in "t_chud" signifying PMC interest */
328 uint32_t t_chud; /* CHUD flags, used for Shark */
329#endif
330
6d2010ae
A
331 process_policy_t ext_actionstate; /* externally applied actions */
332 process_policy_t ext_policystate; /* externally defined process policy states*/
333 process_policy_t actionstate; /* self applied acions */
334 process_policy_t policystate; /* process wide policy states */
335
336 uint64_t rsu_controldata[TASK_POLICY_RESOURCE_USAGE_COUNT];
337
338 vm_extmod_statistics_data_t extmod_statistics;
91447636 339};
1c79356b 340
b0d623f7
A
341#define task_lock(task) lck_mtx_lock(&(task)->lock)
342#define task_lock_try(task) lck_mtx_try_lock(&(task)->lock)
343#define task_unlock(task) lck_mtx_unlock(&(task)->lock)
1c79356b 344
2d21ac55
A
345#if CONFIG_MACF_MACH
346#define maclabel label->lh_label
347
348#define tasklabel_lock(task) lh_lock((task)->label)
349#define tasklabel_unlock(task) lh_unlock((task)->label)
350
351extern void tasklabel_lock2(task_t a, task_t b);
352extern void tasklabel_unlock2(task_t a, task_t b);
353#endif /* MAC_MACH */
354
b0d623f7
A
355#define itk_lock_init(task) lck_mtx_init(&(task)->itk_lock_data, &ipc_lck_grp, &ipc_lck_attr)
356#define itk_lock_destroy(task) lck_mtx_destroy(&(task)->itk_lock_data, &ipc_lck_grp)
357#define itk_lock(task) lck_mtx_lock(&(task)->itk_lock_data)
358#define itk_unlock(task) lck_mtx_unlock(&(task)->itk_lock_data)
1c79356b 359
91447636 360#define task_reference_internal(task) \
2d21ac55 361 (void)hw_atomic_add(&(task)->ref_count, 1)
9bccf70c 362
91447636
A
363#define task_deallocate_internal(task) \
364 hw_atomic_sub(&(task)->ref_count, 1)
55e303ae 365
91447636
A
366#define task_reference(task) \
367MACRO_BEGIN \
368 if ((task) != TASK_NULL) \
369 task_reference_internal(task); \
370MACRO_END
1c79356b 371
91447636
A
372extern kern_return_t kernel_task_create(
373 task_t task,
374 vm_offset_t map_base,
375 vm_size_t map_size,
376 task_t *child);
55e303ae 377
1c79356b 378/* Initialize task module */
2d21ac55 379extern void task_init(void) __attribute__((section("__TEXT, initcode")));
1c79356b 380
91447636
A
381#define current_task_fast() (current_thread()->task)
382#define current_task() current_task_fast()
1c79356b 383
b0d623f7
A
384extern lck_attr_t task_lck_attr;
385extern lck_grp_t task_lck_grp;
386
91447636 387#else /* MACH_KERNEL_PRIVATE */
1c79356b 388
91447636
A
389__BEGIN_DECLS
390
391extern task_t current_task(void);
392
393extern void task_reference(task_t task);
394
395__END_DECLS
1c79356b 396
9bccf70c 397#endif /* MACH_KERNEL_PRIVATE */
1c79356b 398
91447636 399__BEGIN_DECLS
1c79356b 400
91447636
A
401#ifdef XNU_KERNEL_PRIVATE
402
403/* Hold all threads in a task */
1c79356b 404extern kern_return_t task_hold(
91447636 405 task_t task);
1c79356b 406
91447636 407/* Release hold on all threads in a task */
1c79356b 408extern kern_return_t task_release(
91447636 409 task_t task);
1c79356b 410
6d2010ae
A
411#if CONFIG_FREEZE
412
413/* Freeze a task's resident pages */
414extern kern_return_t task_freeze(
415 task_t task,
416 uint32_t *purgeable_count,
417 uint32_t *wired_count,
418 uint32_t *clean_count,
419 uint32_t *dirty_count,
420 boolean_t *shared,
421 boolean_t walk_only);
422
423/* Thaw a currently frozen task */
424extern kern_return_t task_thaw(
425 task_t task);
426
427#endif /* CONFIG_FREEZE */
428
91447636 429/* Halt all other threads in the current task */
b0d623f7
A
430extern kern_return_t task_start_halt(
431 task_t task);
432
433/* Wait for other threads to halt and free halting task resources */
434extern void task_complete_halt(
91447636
A
435 task_t task);
436
437extern kern_return_t task_terminate_internal(
438 task_t task);
439
440extern kern_return_t task_create_internal(
441 task_t parent_task,
442 boolean_t inherit_memory,
0c530ab8 443 boolean_t is_64bit,
91447636 444 task_t *child_task); /* OUT */
1c79356b 445
0b4e3aa0
A
446extern kern_return_t task_importance(
447 task_t task,
448 integer_t importance);
91447636 449
2d21ac55
A
450extern void task_vtimer_set(
451 task_t task,
452 integer_t which);
453
454extern void task_vtimer_clear(
455 task_t task,
456 integer_t which);
457
458extern void task_vtimer_update(
459 task_t task,
460 integer_t which,
461 uint32_t *microsecs);
462
463#define TASK_VTIMER_USER 0x01
464#define TASK_VTIMER_PROF 0x02
465#define TASK_VTIMER_RLIM 0x04
466
91447636
A
467extern void task_set_64bit(
468 task_t task,
469 boolean_t is64bit);
470
471extern void task_backing_store_privileged(
472 task_t task);
473
b0d623f7
A
474extern void task_set_dyld_info(
475 task_t task,
476 mach_vm_address_t addr,
477 mach_vm_size_t size);
478
91447636
A
479/* Get number of activations in a task */
480extern int get_task_numacts(
481 task_t task);
482
b0d623f7 483extern int get_task_numactivethreads(task_t task);
0b4e3aa0 484
1c79356b 485/* JMM - should just be temporary (implementation in bsd_kern still) */
1c79356b 486extern void set_bsdtask_info(task_t,void *);
91447636 487extern vm_map_t get_task_map_reference(task_t);
6d2010ae 488extern vm_map_t swap_task_map(task_t, thread_t, vm_map_t, boolean_t);
1c79356b 489extern pmap_t get_task_pmap(task_t);
b0d623f7 490extern uint64_t get_task_resident_size(task_t);
9bccf70c 491
91447636 492extern boolean_t is_kerneltask(task_t task);
9bccf70c 493
2d21ac55
A
494extern kern_return_t check_actforsig(task_t task, thread_t thread, int setast);
495
b0d623f7
A
496extern kern_return_t machine_task_get_state(
497 task_t task,
498 int flavor,
499 thread_state_t state,
500 mach_msg_type_number_t *state_count);
501
502extern kern_return_t machine_task_set_state(
503 task_t task,
504 int flavor,
505 thread_state_t state,
506 mach_msg_type_number_t state_count);
507
508
6d2010ae
A
509int proc_get_task_bg_policy(task_t task);
510int proc_get_thread_bg_policy(task_t task, uint64_t tid);
511int proc_get_self_isbackground(void);
512int proc_get_selfthread_isbackground(void);
513
514int proc_get_darwinbgstate(task_t, uint32_t *);
515int proc_set_bgtaskpolicy(task_t task, int intval);
516int proc_set1_bgtaskpolicy(task_t task, int intval);
517int proc_set_bgthreadpolicy(task_t task, uint64_t tid, int val);
518int proc_set1_bgthreadpolicy(task_t task, uint64_t tid, int val);
519
520int proc_add_bgtaskpolicy(task_t task, int val);
521int proc_add_bgthreadpolicy(task_t task, uint64_t tid, int val);
522int proc_remove_bgtaskpolicy(task_t task, int policy);
523int proc_remove_bgthreadpolicy(task_t task, uint64_t tid, int val);
524
525int proc_apply_bgtaskpolicy(task_t task);
526int proc_apply_bgtaskpolicy_external(task_t task);
527int proc_apply_bgtaskpolicy_internal(task_t task);
528int proc_apply_bgthreadpolicy(task_t task, uint64_t tid);
529int proc_apply_bgtask_selfpolicy(void);
530int proc_apply_bgthread_selfpolicy(void);
531int proc_apply_workq_bgthreadpolicy(thread_t);
532
533int proc_restore_bgtaskpolicy(task_t task);
534int proc_restore_bgthreadpolicy(task_t task, uint64_t tid);
535int proc_restore_bgthread_selfpolicy(void);
536int proc_restore_workq_bgthreadpolicy(thread_t);
537
538/* hw access routines */
539int proc_apply_task_diskacc(task_t task, int policy);
540int proc_apply_thread_diskacc(task_t task, uint64_t tid, int policy);
541int proc_apply_thread_selfdiskacc(int policy);
542int proc_get_task_disacc(task_t task);
543int proc_get_task_selfdiskacc(void);
544int proc_get_thread_selfdiskacc(void);
545int proc_denyinherit_policy(task_t task);
546int proc_denyselfset_policy(task_t task);
547
548int proc_get_task_selfgpuacc_deny(void);
549int proc_apply_task_gpuacc(task_t task, int prio);
550
551int proc_get_task_ruse_cpu(task_t task, uint32_t * policyp, uint32_t * percentagep, uint64_t * intervalp, uint64_t * deadlinep);
552int proc_set_task_ruse_cpu(task_t task, uint32_t policy, uint32_t percentage, uint64_t interval, uint64_t deadline);
553thread_t task_findtid(task_t, uint64_t);
554
555#define PROC_POLICY_OSX_APPTYPE_NONE 0
556#define PROC_POLICY_OSX_APPTYPE_TAL 1
557#define PROC_POLICY_OSX_APPTYPE_WIDGET 2
558#define PROC_POLICY_OSX_APPTYPE_DBCLIENT 2 /* Not a bug, just rename of widget */
559#define PROC_POLICY_IOS_APPTYPE 3
560#define PROC_POLICY_IOS_NONUITYPE 4
561
562void proc_set_task_apptype(task_t, int);
563int proc_disable_task_apptype(task_t task, int policy_subtype);
564int proc_enable_task_apptype(task_t task, int policy_subtype);
565
566/* resource handle callback */
567int task_action_cpuusage(task_t);
568
569/* BSD call back functions */
570extern int proc_apply_resource_actions(void * p, int type, int action);
571extern int proc_restore_resource_actions(void * p, int type, int action);
572extern int task_restore_resource_actions(task_t task, int type);
573
574extern void proc_apply_task_networkbg(void * bsd_info);
575extern void proc_restore_task_networkbg(void * bsd_info);
576extern void proc_set_task_networkbg(void * bsd_info, int setbg);
91447636 577#endif /* XNU_KERNEL_PRIVATE */
9bccf70c 578
91447636 579#ifdef KERNEL_PRIVATE
9bccf70c 580
91447636 581extern void *get_bsdtask_info(task_t);
2d21ac55 582extern void *get_bsdthreadtask_info(thread_t);
91447636 583extern vm_map_t get_task_map(task_t);
9bccf70c 584
91447636 585#endif /* KERNEL_PRIVATE */
9bccf70c 586
91447636
A
587extern task_t kernel_task;
588
589extern void task_deallocate(
590 task_t task);
9bccf70c 591
0c530ab8
A
592extern void task_name_deallocate(
593 task_name_t task_name);
91447636 594__END_DECLS
9bccf70c 595
1c79356b 596#endif /* _KERN_TASK_H_ */