2 * Copyright (c) 2014 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _MACH_COALITION_H_
30 #define _MACH_COALITION_H_
32 /* code shared by userspace and xnu */
34 #define COALITION_CREATE_FLAGS_MASK ((uint32_t)0xF1)
35 #define COALITION_CREATE_FLAGS_PRIVILEGED ((uint32_t)0x01)
37 #define COALITION_CREATE_FLAGS_TYPE_MASK ((uint32_t)0xF0)
38 #define COALITION_CREATE_FLAGS_TYPE_SHIFT (4)
40 #define COALITION_CREATE_FLAGS_GET_TYPE(flags) \
41 (((flags) & COALITION_CREATE_FLAGS_TYPE_MASK) >> COALITION_CREATE_FLAGS_TYPE_SHIFT)
43 #define COALITION_CREATE_FLAGS_SET_TYPE(flags, type) \
45 flags &= ~COALITION_CREATE_FLAGS_TYPE_MASK; \
46 flags |= (((type) << COALITION_CREATE_FLAGS_TYPE_SHIFT) \
47 & COALITION_CREATE_FLAGS_TYPE_MASK); \
51 #define COALITION_TYPE_RESOURCE (0)
52 #define COALITION_TYPE_JETSAM (1)
53 #define COALITION_TYPE_MAX (1)
55 #define COALITION_NUM_TYPES (COALITION_TYPE_MAX + 1)
57 #define COALITION_TASKROLE_UNDEF (0)
58 #define COALITION_TASKROLE_LEADER (1)
59 #define COALITION_TASKROLE_XPC (2)
60 #define COALITION_TASKROLE_EXT (3)
62 #define COALITION_NUM_TASKROLES (4)
64 #define COALITION_ROLEMASK_ALLROLES ((1 << COALITION_NUM_TASKROLES) - 1)
65 #define COALITION_ROLEMASK_UNDEF (1 << COALITION_TASKROLE_UNDEF)
66 #define COALITION_ROLEMASK_LEADER (1 << COALITION_TASKROLE_LEADER)
67 #define COALITION_ROLEMASK_XPC (1 << COALITION_TASKROLE_XPC)
68 #define COALITION_ROLEMASK_EXT (1 << COALITION_TASKROLE_EXT)
70 #define COALITION_SORT_NOSORT (0)
71 #define COALITION_SORT_DEFAULT (1)
72 #define COALITION_SORT_MEM_ASC (2)
73 #define COALITION_SORT_MEM_DEC (3)
74 #define COALITION_SORT_USER_ASC (4)
75 #define COALITION_SORT_USER_DEC (5)
77 #define COALITION_NUM_SORT (6)
79 struct coalition_resource_usage
{
80 uint64_t tasks_started
;
81 uint64_t tasks_exited
;
82 uint64_t time_nonempty
;
84 uint64_t interrupt_wakeups
;
85 uint64_t platform_idle_wakeups
;
87 uint64_t byteswritten
;
89 uint64_t cpu_time_billed_to_me
;
90 uint64_t cpu_time_billed_to_others
;
94 /* definitions shared by only xnu + Libsyscall */
97 #define COALITION_OP_CREATE 1
98 #define COALITION_OP_TERMINATE 2
99 #define COALITION_OP_REAP 3
101 /* coalition_info flavors */
102 #define COALITION_INFO_RESOURCE_USAGE 1
104 /* structure returned from libproc coalition listing interface */
105 struct procinfo_coalinfo
{
106 uint64_t coalition_id
;
107 uint32_t coalition_type
;
108 uint32_t coalition_tasks
;
113 #ifdef XNU_KERNEL_PRIVATE
115 #define coal_dbg(fmt, ...) \
116 printf("%s: " fmt "\n", __func__, ## __VA_ARGS__)
118 #define coal_dbg(fmt, ...)
123 #endif /* _MACH_COALITION_H_ */