]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 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. | |
0a7de745 | 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. | |
0a7de745 | 17 | * |
2d21ac55 A |
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. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
0a7de745 | 31 | /* |
1c79356b A |
32 | * Mach Operating System |
33 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |
34 | * All Rights Reserved. | |
0a7de745 | 35 | * |
1c79356b A |
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. | |
0a7de745 | 41 | * |
1c79356b A |
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. | |
0a7de745 | 45 | * |
1c79356b | 46 | * Carnegie Mellon requests users of this software to return to |
0a7de745 | 47 | * |
1c79356b A |
48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
49 | * School of Computer Science | |
50 | * Carnegie Mellon University | |
51 | * Pittsburgh PA 15213-3890 | |
0a7de745 | 52 | * |
1c79356b A |
53 | * any improvements or extensions that they make and grant Carnegie Mellon |
54 | * the rights to redistribute these changes. | |
55 | */ | |
2d21ac55 A |
56 | /* |
57 | * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce | |
58 | * support for mandatory and extensible security protections. This notice | |
59 | * is included in support of clause 2.2 (b) of the Apple Public License, | |
60 | * Version 2.0. | |
61 | */ | |
1c79356b A |
62 | /* |
63 | */ | |
64 | /* | |
65 | * File: kern/ipc_kobject.h | |
66 | * Author: Rich Draves | |
67 | * Date: 1989 | |
68 | * | |
69 | * Declarations for letting a port represent a kernel object. | |
70 | */ | |
71 | ||
a39ff7e2 | 72 | #ifdef MACH_KERNEL_PRIVATE |
1c79356b A |
73 | #include <ipc/ipc_kmsg.h> |
74 | #include <ipc/ipc_port.h> | |
a39ff7e2 | 75 | #endif /* MACH_KERNEL_PRIVATE */ |
1c79356b | 76 | |
0a7de745 | 77 | #ifndef _KERN_IPC_KOBJECT_H_ |
1c79356b A |
78 | #define _KERN_IPC_KOBJECT_H_ |
79 | ||
80 | #ifdef KERNEL_PRIVATE | |
81 | /* | |
82 | * This is the legacy in-kernel ipc-object mechanism. Over the next | |
83 | * several months, this will be phased out in favor of a mechanism that | |
84 | * is less Mach IPC specific, and common across in-mach, in-kernel-component, | |
85 | * and user-level-component (Plugin) models. | |
86 | */ | |
87 | #include <mach/machine/vm_types.h> | |
88 | #include <mach/mach_types.h> | |
89 | ||
0a7de745 A |
90 | typedef natural_t ipc_kobject_type_t; |
91 | ||
f427ee49 A |
92 | #define IKOT_NONE 0 |
93 | #define IKOT_THREAD_CONTROL 1 | |
94 | #define IKOT_TASK_CONTROL 2 | |
95 | #define IKOT_HOST 3 | |
0a7de745 A |
96 | #define IKOT_HOST_PRIV 4 |
97 | #define IKOT_PROCESSOR 5 | |
f427ee49 | 98 | #define IKOT_PSET 6 |
0a7de745 | 99 | #define IKOT_PSET_NAME 7 |
f427ee49 | 100 | #define IKOT_TIMER 8 |
0a7de745 | 101 | #define IKOT_PAGING_REQUEST 9 |
f427ee49 | 102 | #define IKOT_MIG 10 |
0a7de745 A |
103 | #define IKOT_MEMORY_OBJECT 11 |
104 | #define IKOT_XMM_PAGER 12 | |
105 | #define IKOT_XMM_KERNEL 13 | |
106 | #define IKOT_XMM_REPLY 14 | |
107 | #define IKOT_UND_REPLY 15 | |
108 | #define IKOT_HOST_NOTIFY 16 | |
109 | #define IKOT_HOST_SECURITY 17 | |
f427ee49 | 110 | #define IKOT_LEDGER 18 |
0a7de745 A |
111 | #define IKOT_MASTER_DEVICE 19 |
112 | #define IKOT_TASK_NAME 20 | |
113 | #define IKOT_SUBSYSTEM 21 | |
114 | #define IKOT_IO_DONE_QUEUE 22 | |
115 | #define IKOT_SEMAPHORE 23 | |
116 | #define IKOT_LOCK_SET 24 | |
f427ee49 | 117 | #define IKOT_CLOCK 25 |
0a7de745 A |
118 | #define IKOT_CLOCK_CTRL 26 |
119 | #define IKOT_IOKIT_IDENT 27 | |
120 | #define IKOT_NAMED_ENTRY 28 | |
121 | #define IKOT_IOKIT_CONNECT 29 | |
122 | #define IKOT_IOKIT_OBJECT 30 | |
f427ee49 | 123 | #define IKOT_UPL 31 |
0a7de745 A |
124 | #define IKOT_MEM_OBJ_CONTROL 32 |
125 | #define IKOT_AU_SESSIONPORT 33 | |
126 | #define IKOT_FILEPORT 34 | |
127 | #define IKOT_LABELH 35 | |
128 | #define IKOT_TASK_RESUME 36 | |
129 | #define IKOT_VOUCHER 37 | |
130 | #define IKOT_VOUCHER_ATTR_CONTROL 38 | |
5ba3f43e | 131 | #define IKOT_WORK_INTERVAL 39 |
d9a64523 | 132 | #define IKOT_UX_HANDLER 40 |
cb323159 A |
133 | #define IKOT_UEXT_OBJECT 41 |
134 | #define IKOT_ARCADE_REG 42 | |
f427ee49 A |
135 | #define IKOT_EVENTLINK 43 |
136 | #define IKOT_TASK_INSPECT 44 | |
137 | #define IKOT_TASK_READ 45 | |
138 | #define IKOT_THREAD_INSPECT 46 | |
139 | #define IKOT_THREAD_READ 47 | |
ea3f0419 | 140 | #define IKOT_SUID_CRED 48 |
f427ee49 | 141 | #define IKOT_HYPERVISOR 49 |
ea3f0419 | 142 | |
0c530ab8 A |
143 | /* |
144 | * Add new entries here and adjust IKOT_UNKNOWN. | |
145 | * Please keep ipc/ipc_object.c:ikot_print_array up to date. | |
146 | */ | |
f427ee49 | 147 | #define IKOT_UNKNOWN 50 /* magic catchall */ |
0a7de745 | 148 | #define IKOT_MAX_TYPE (IKOT_UNKNOWN+1) /* # of IKOT_ types */ |
1c79356b | 149 | |
f427ee49 A |
150 | /* set the bitstring index for kobject */ |
151 | extern kern_return_t ipc_kobject_set_kobjidx( | |
152 | int msgid, | |
153 | int index); | |
154 | ||
a39ff7e2 A |
155 | #ifdef MACH_KERNEL_PRIVATE |
156 | ||
ea3f0419 A |
157 | struct ipc_kobject_label { |
158 | ipc_label_t ikol_label; /* [private] mandatory access label */ | |
f427ee49 | 159 | ipc_kobject_t XNU_PTRAUTH_SIGNED_PTR("ipc_kobject_label.ikol_kobject") ikol_kobject; /* actual kobject address */ |
ea3f0419 A |
160 | }; |
161 | ||
162 | /* initialization of kobject subsystem */ | |
163 | extern void ipc_kobject_init(void); | |
1c79356b | 164 | |
1c79356b | 165 | /* Dispatch a kernel server function */ |
cb323159 A |
166 | extern ipc_kmsg_t ipc_kobject_server( |
167 | ipc_kmsg_t request, | |
168 | mach_msg_option_t option); | |
1c79356b A |
169 | |
170 | /* Make a port represent a kernel object of the given type */ | |
cb323159 A |
171 | extern void ipc_kobject_set( |
172 | ipc_port_t port, | |
173 | ipc_kobject_t kobject, | |
174 | ipc_kobject_type_t type); | |
175 | ||
176 | extern void ipc_kobject_set_atomically( | |
177 | ipc_port_t port, | |
178 | ipc_kobject_t kobject, | |
179 | ipc_kobject_type_t type); | |
180 | ||
181 | __options_decl(ipc_kobject_alloc_options_t, uint32_t, { | |
182 | /* Just make the naked port */ | |
183 | IPC_KOBJECT_ALLOC_NONE = 0x00000000, | |
184 | /* Make a send right */ | |
185 | IPC_KOBJECT_ALLOC_MAKE_SEND = 0x00000001, | |
186 | /* Register for no-more-senders */ | |
187 | IPC_KOBJECT_ALLOC_NSREQUEST = 0x00000002, | |
188 | /* Make it no grant port */ | |
189 | IPC_KOBJECT_ALLOC_NO_GRANT = 0x00000004, | |
190 | /* Make all the send rights immovable */ | |
191 | IPC_KOBJECT_ALLOC_IMMOVABLE_SEND = 0x00000008, | |
ea3f0419 A |
192 | /* Add a label structure to the port */ |
193 | IPC_KOBJECT_ALLOC_LABEL = 0x00000010, | |
cb323159 A |
194 | }); |
195 | ||
196 | /* Allocates a kobject port, never fails */ | |
197 | extern ipc_port_t ipc_kobject_alloc_port( | |
198 | ipc_kobject_t kobject, | |
199 | ipc_kobject_type_t type, | |
200 | ipc_kobject_alloc_options_t options); | |
201 | ||
ea3f0419 A |
202 | /* Allocates a kobject port, never fails */ |
203 | extern ipc_port_t ipc_kobject_alloc_labeled_port( | |
204 | ipc_kobject_t kobject, | |
205 | ipc_kobject_type_t type, | |
206 | ipc_label_t label, | |
207 | ipc_kobject_alloc_options_t options); | |
208 | ||
cb323159 A |
209 | /* Makes a send right, lazily allocating a kobject port, arming for no-senders, never fails */ |
210 | extern boolean_t ipc_kobject_make_send_lazy_alloc_port( | |
211 | ipc_port_t *port_store, | |
212 | ipc_kobject_t kobject, | |
f427ee49 A |
213 | ipc_kobject_type_t type, |
214 | boolean_t should_ptrauth, | |
215 | uint64_t ptrauth_discriminator) __result_use_check; | |
1c79356b | 216 | |
ea3f0419 A |
217 | /* Makes a send right, lazily allocating a kobject port, arming for no-senders, never fails */ |
218 | extern boolean_t ipc_kobject_make_send_lazy_alloc_labeled_port( | |
219 | ipc_port_t *port_store, | |
220 | ipc_kobject_t kobject, | |
221 | ipc_kobject_type_t type, | |
222 | ipc_label_t label) __result_use_check; | |
223 | ||
224 | /* Get the kobject address associated with a port */ | |
225 | static inline ipc_kobject_t | |
226 | ipc_kobject_get(ipc_port_t port) | |
227 | { | |
228 | if (ip_is_kobject(port)) { | |
229 | if (ip_is_kolabeled(port)) { | |
230 | return port->ip_kolabel->ikol_kobject; | |
231 | } | |
232 | return port->ip_kobject; | |
233 | } | |
234 | return 0; | |
235 | } | |
236 | ||
237 | /* Check if a kobject can be copied out to a given space */ | |
238 | extern boolean_t ipc_kobject_label_check( | |
239 | ipc_space_t space, | |
240 | ipc_port_t port, | |
241 | mach_msg_type_name_t msgt_name); | |
1c79356b A |
242 | |
243 | /* Release any kernel object resources associated with a port */ | |
cb323159 A |
244 | extern void ipc_kobject_destroy( |
245 | ipc_port_t port); | |
1c79356b | 246 | |
0a7de745 | 247 | #define null_conversion(port) (port) |
1c79356b | 248 | |
cb323159 A |
249 | extern kern_return_t |
250 | uext_server(ipc_kmsg_t request, ipc_kmsg_t * reply); | |
251 | ||
a39ff7e2 A |
252 | #endif /* MACH_KERNEL_PRIVATE */ |
253 | ||
1c79356b A |
254 | #endif /* KERNEL_PRIVATE */ |
255 | ||
256 | #endif /* _KERN_IPC_KOBJECT_H_ */ |