]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/coalition.h
xnu-3247.10.11.tar.gz
[apple/xnu.git] / osfmk / mach / coalition.h
CommitLineData
3e170ce0
A
1/*
2 * Copyright (c) 2014 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#ifndef _MACH_COALITION_H_
30#define _MACH_COALITION_H_
31
32/* code shared by userspace and xnu */
33
34#define COALITION_CREATE_FLAGS_MASK ((uint32_t)0xF1)
35#define COALITION_CREATE_FLAGS_PRIVILEGED ((uint32_t)0x01)
36
37#define COALITION_CREATE_FLAGS_TYPE_MASK ((uint32_t)0xF0)
38#define COALITION_CREATE_FLAGS_TYPE_SHIFT (4)
39
40#define COALITION_CREATE_FLAGS_GET_TYPE(flags) \
41 (((flags) & COALITION_CREATE_FLAGS_TYPE_MASK) >> COALITION_CREATE_FLAGS_TYPE_SHIFT)
42
43#define COALITION_CREATE_FLAGS_SET_TYPE(flags, type) \
44 do { \
45 flags &= ~COALITION_CREATE_FLAGS_TYPE_MASK; \
46 flags |= (((type) << COALITION_CREATE_FLAGS_TYPE_SHIFT) \
47 & COALITION_CREATE_FLAGS_TYPE_MASK); \
48 } while (0)
49
50
51#define COALITION_TYPE_RESOURCE (0)
52#define COALITION_TYPE_JETSAM (1)
53#define COALITION_TYPE_MAX (1)
54
55#define COALITION_NUM_TYPES (COALITION_TYPE_MAX + 1)
56
57#define COALITION_TASKROLE_UNDEF (0)
58#define COALITION_TASKROLE_LEADER (1)
59#define COALITION_TASKROLE_XPC (2)
60#define COALITION_TASKROLE_EXT (3)
61
62#define COALITION_NUM_TASKROLES (4)
63
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)
69
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)
76
77#define COALITION_NUM_SORT (6)
78
79struct coalition_resource_usage {
80 uint64_t tasks_started;
81 uint64_t tasks_exited;
82 uint64_t time_nonempty;
83 uint64_t cpu_time;
84 uint64_t interrupt_wakeups;
85 uint64_t platform_idle_wakeups;
86 uint64_t bytesread;
87 uint64_t byteswritten;
88 uint64_t gpu_time;
89 uint64_t cpu_time_billed_to_me;
90 uint64_t cpu_time_billed_to_others;
91};
92
93#ifdef PRIVATE
94/* definitions shared by only xnu + Libsyscall */
95
96/* Syscall flavors */
97#define COALITION_OP_CREATE 1
98#define COALITION_OP_TERMINATE 2
99#define COALITION_OP_REAP 3
100
101/* coalition_info flavors */
102#define COALITION_INFO_RESOURCE_USAGE 1
103
104/* structure returned from libproc coalition listing interface */
105struct procinfo_coalinfo {
106 uint64_t coalition_id;
107 uint32_t coalition_type;
108 uint32_t coalition_tasks;
109};
110
111#endif /* PRIVATE */
112
113#ifdef XNU_KERNEL_PRIVATE
114#if COALITION_DEBUG
115#define coal_dbg(fmt, ...) \
116 printf("%s: " fmt "\n", __func__, ## __VA_ARGS__)
117#else
118#define coal_dbg(fmt, ...)
119#endif
120
121#endif
122
123#endif /* _MACH_COALITION_H_ */