]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/task_policy.h
9fd1ea8b533bc683f29e43abffcd53051098792b
[apple/xnu.git] / osfmk / mach / task_policy.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30
31 #ifndef _MACH_TASK_POLICY_H_
32 #define _MACH_TASK_POLICY_H_
33
34 #include <mach/mach_types.h>
35
36 /*
37 * These are the calls for accessing the policy parameters
38 * of a particular task.
39 *
40 * The extra 'get_default' parameter to the second call is
41 * IN/OUT as follows:
42 * 1) if asserted on the way in it indicates that the default
43 * values should be returned, not the ones currently set, in
44 * this case 'get_default' will always be asserted on return;
45 * 2) if unasserted on the way in, the current settings are
46 * desired and if still unasserted on return, then the info
47 * returned reflects the current settings, otherwise if
48 * 'get_default' returns asserted, it means that there are no
49 * current settings due to other parameters taking precedence,
50 * and the default ones are being returned instead.
51 */
52
53 typedef natural_t task_policy_flavor_t;
54 typedef integer_t *task_policy_t;
55
56 /*
57 kern_return_t task_policy_set(
58 task_t task,
59 task_policy_flavor_t flavor,
60 task_policy_t policy_info,
61 mach_msg_type_number_t count);
62
63 kern_return_t task_policy_get(
64 task_t task,
65 task_policy_flavor_t flavor,
66 task_policy_t policy_info,
67 mach_msg_type_number_t *count,
68 boolean_t *get_default);
69 */
70
71 /*
72 * Defined flavors.
73 */
74 /*
75 * TASK_CATEGORY_POLICY:
76 *
77 * This provides information to the kernel about the role
78 * of the task in the system.
79 *
80 * Parameters:
81 *
82 * role: Enumerated as follows:
83 *
84 * TASK_UNSPECIFIED is the default, since the role is not
85 * inherited from the parent.
86 *
87 * TASK_FOREGROUND_APPLICATION should be assigned when the
88 * task is a normal UI application in the foreground from
89 * the HI point of view.
90 * **N.B. There may be more than one of these at a given time.
91 *
92 * TASK_BACKGROUND_APPLICATION should be assigned when the
93 * task is a normal UI application in the background from
94 * the HI point of view.
95 *
96 * TASK_CONTROL_APPLICATION should be assigned to the unique
97 * UI application which implements the pop-up application dialog.
98 * There can only be one task at a time with this designation,
99 * which is assigned FCFS.
100 *
101 * TASK_GRAPHICS_SERVER should be assigned to the graphics
102 * management (window) server. There can only be one task at
103 * a time with this designation, which is assigned FCFS.
104 */
105
106 #define TASK_CATEGORY_POLICY 1
107
108 enum task_role {
109 TASK_RENICED = -1,
110 TASK_UNSPECIFIED = 0,
111 TASK_FOREGROUND_APPLICATION,
112 TASK_BACKGROUND_APPLICATION,
113 TASK_CONTROL_APPLICATION,
114 TASK_GRAPHICS_SERVER
115 };
116
117 typedef enum task_role task_role_t;
118
119 struct task_category_policy {
120 task_role_t role;
121 };
122
123 typedef struct task_category_policy task_category_policy_data_t;
124 typedef struct task_category_policy *task_category_policy_t;
125
126 #define TASK_CATEGORY_POLICY_COUNT ((mach_msg_type_number_t) \
127 (sizeof (task_category_policy_data_t) / sizeof (integer_t)))
128
129 #endif /* _MACH_TASK_POLICY_H_ */