]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/coalition.h
38bdefd58f449c225a969eeec55c5147dea8c4e3
2 * Copyright (c) 2013 Apple Computer, 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 _KERN_COALITION_H_
30 #define _KERN_COALITION_H_
32 #ifdef XNU_KERNEL_PRIVATE
34 void coalition_init(void);
37 * KERN_ALREADY_IN_SET task is already in a coalition (maybe this one, maybe a different one)
38 * KERN_TERMINATED coalition is already terminated (so it may not adopt any more tasks)
40 kern_return_t
coalition_adopt_task(coalition_t coal
, task_t task
);
41 kern_return_t
coalition_default_adopt_task(task_t task
);
43 /* Currently, no error conditions. If task is not already in a coalition,
44 * KERN_SUCCESS is returned because removing it did not fail.
46 kern_return_t
coalition_remove_task(task_t task
);
48 uint64_t coalition_id(coalition_t coal
);
49 uint64_t task_coalition_id(task_t task
);
51 /* Returns with a reference, or COALITION_NULL.
52 * There is no coalition with id 0.
54 coalition_t
coalition_find_by_id(uint64_t coal_id
);
56 /* Returns with a reference and an activation, or COALITION_NULL.
57 * There is no coalition with id 0.
59 coalition_t
coalition_find_and_activate_by_id(uint64_t coal_id
);
62 * KERN_TERMINATED coalition is terminated
63 * This will panic if the coalition is already reaped, which implies
64 * that it wasn't active.
66 kern_return_t
coalition_extend_active(coalition_t coal
);
68 void coalition_remove_active(coalition_t coal
);
70 void coalition_release(coalition_t coal
);
73 * The following functions are to be used by the syscall wrapper
74 * in bsd/kern/kern_proc.c, after it has verified the caller's privilege.
78 * KERN_DEFAULT_SET The default coalition, which contains the kernel, may
80 * KERN_TERMINATED The coalition was already reaped.
81 * KERN_FAILURE The coalition was not empty or has never been terminated.
83 kern_return_t
coalition_reap_internal(coalition_t coal
);
86 * KERN_DEFAULT_SET The default coalition, which contains the kernel, may
88 * KERN_TERMINATED The coalition was already terminated (or even reaped)
89 * KERN_INVALID_NAME The coalition was already reaped.
91 kern_return_t
coalition_request_terminate_internal(coalition_t coal
);
94 * KERN_RESOURCE_SHORTAGE Unable to allocate kernel resources for a
97 kern_return_t
coalition_create_internal(coalition_t
*out
, boolean_t privileged
);
99 boolean_t
coalition_is_privileged(coalition_t coal
);
100 boolean_t
task_is_in_privileged_coalition(task_t task
);
102 /* This struct is also defined in bsd/sys/coalition.h. Keep in sync. */
103 struct coalition_resource_usage
{
104 uint64_t tasks_started
;
105 uint64_t tasks_exited
;
106 uint64_t time_nonempty
;
108 uint64_t interrupt_wakeups
;
109 uint64_t platform_idle_wakeups
;
111 uint64_t byteswritten
;
115 kern_return_t
coalition_resource_usage_internal(coalition_t coal
, struct coalition_resource_usage
*cru_out
);
117 ledger_t
coalition_get_ledger(coalition_t coal
);
119 #endif /* XNU_KERNEL_PRIVATE */
121 #endif /* _KERN_COALITION_H */