1/*
2 * Copyright (c) 1998-2011 Apple Computer, 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 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
30 *
31 * HISTORY
32 *
33 */
34
35/*
36 * Internal definitions used between the iokit user library and
37 * server routines.
38 */
39
40#ifndef _IOKIT_IOKITSERVER_H
41#define _IOKIT_IOKITSERVER_H
42
43#include <IOKit/IOTypes.h>
44#include <IOKit/IOKitKeys.h>
45#include <IOKit/OSMessageNotification.h>
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50#include <mach/kmod.h>
51#ifdef __cplusplus
52}
53#endif
54
55// IOCatalogueSendData
56/*!
57 * @enum IOCatalogueSendData user-client flags.
58 * @constant kIOCatalogAddDrivers Signals a call to the addDrivers function in IOCatalogue.
59 * @constant kIOCatalogAddDriversNoMatch Signals a call to the addDrivers function in IOCatalogue but does not start a matching thread.
60 * @constant kIOCatalogRemoveDrivers Signals a call to the removeDrivers function in IOCatalogue.
61 * @constant kIOCatalogRemoveDriversNoMatch Signals a call to the removedrivers function in IOCatalogue but does not start a matching thread.
62 * @constant kIOCatalogStartMatching Signals the IOCatalogue to start an IOService matching thread.
63 * @constant kIOCatalogRemoveKernelLinker Deprecated; does nothing.
64 * @constant kIOCatalogKextdActive Signals the kernel that kextd is running.
65 * @constant kIOCatalogKextdFinishedLaunching Signals the IOCatalogue that kextd has finished sending it information at startup.
66 * @constant kIOCatalogResetDrivers Resets the IOCatalogue with a new set of personalities.
67 * @constant kIOCatalogResetDriversNoMatch Resets the IOCatalogue with a new set of personalities but does not start a matching thread.
68 */
69enum {
70 kIOCatalogAddDrivers = 1,
71 kIOCatalogAddDriversNoMatch,
72 kIOCatalogRemoveDrivers,
73 kIOCatalogRemoveDriversNoMatch,
74 kIOCatalogStartMatching__Removed,
75 kIOCatalogRemoveKernelLinker__Removed,
76 kIOCatalogKextdActive,
77 kIOCatalogKextdFinishedLaunching,
78 kIOCatalogResetDrivers,
79 kIOCatalogResetDriversNoMatch
80};
81
82// IOCatalogueGetData
83/*!
84 * @enum IOCatalogueGetData user-client flags
85 * @constant kIOCatalogGetContents Returns a snapshot of the database to the caller.
86 */
87enum {
88 kIOCatalogGetContents = 1,
89 kIOCatalogGetModuleDemandList = 2,
90 kIOCatalogGetCacheMissList = 3,
91 kIOCatalogGetROMMkextList = 4
92};
93
94// IOCatalogueReset
95/*!
96 * @enum IOCatalogueReset user-client flag
97 * @constant kIOCatalogResetDefault Removes all entries from IOCatalogue except those used for booting the system.
98 */
99enum {
100 kIOCatalogResetDefault = 1
101};
102
103// IOCatalogueTerminate
104/*!
105 * @enum IOCatalogueTerminate user-client flags.
106 * @constant kIOCatalogModuleUnload Terminates all services which depend on a particular module and unloads the module.
107 * @constant kIOCatalogModuleTerminate Terminates all services which depend on a particular module but does not unload the module.
108 * @constant kIOCatalogServiceTerminate Terminates a particular service by name.
109 */
110enum {
111 kIOCatalogModuleUnload = 1,
112 kIOCatalogModuleTerminate,
113 kIOCatalogServiceTerminate
114};
115
116
117#ifdef XNU_KERNEL_PRIVATE
118
119#ifdef __cplusplus
120extern "C" {
121#endif /* __cplusplus */
122
123#include <kern/ipc_kobject.h>
124
125/*
126 * Functions in iokit:IOUserClient.cpp
127 */
128
129#ifdef __cplusplus
130class IOMachPort;
131typedef IOMachPort * io_kobject_t;
132#else
133typedef struct IOMachPort * io_kobject_t;
134#endif
135
136extern void iokit_add_reference( io_object_t obj, ipc_kobject_type_t type );
137
138extern ipc_port_t iokit_port_for_object(io_object_t obj,
139 ipc_kobject_type_t type, ipc_kobject_t * kobj);
140
141extern kern_return_t iokit_client_died( io_object_t obj,
142 ipc_port_t port, ipc_kobject_type_t type, mach_port_mscount_t * mscount );
143
144extern kern_return_t
145iokit_client_memory_for_type(
146 io_object_t connect,
147 unsigned int type,
148 unsigned int * flags,
149 vm_address_t * address,
150 vm_size_t * size );
151
152/*
153 * Functions in osfmk:iokit_rpc.c
154 */
155
156extern ipc_port_t iokit_alloc_object_port( io_kobject_t obj,
157 ipc_kobject_type_t type );
158extern void iokit_remove_object_port( ipc_port_t port,
159 ipc_kobject_type_t type );
160extern kern_return_t iokit_destroy_object_port( ipc_port_t port,
161 ipc_kobject_type_t type );
162
163extern ipc_kobject_type_t iokit_port_type(ipc_port_t port);
164
165extern mach_port_name_t iokit_make_send_right( task_t task,
166 io_object_t obj, ipc_kobject_type_t type );
167
168extern mach_port_t ipc_kobject_make_send(mach_port_t, ipc_kobject_t, ipc_kobject_type_t) __result_use_check;
169extern mach_port_t ipc_kobject_copy_send(mach_port_t, ipc_kobject_t, ipc_kobject_type_t) __result_use_check;
170extern mach_port_t ipc_port_make_send_mqueue(mach_port_t) __result_use_check;
171extern mach_port_t ipc_port_copy_send_mqueue(mach_port_t) __result_use_check;
172extern void ipc_port_release_send(ipc_port_t port);
173
174extern io_object_t iokit_lookup_io_object(ipc_port_t port, ipc_kobject_type_t type);
175
176extern kern_return_t iokit_mod_send_right( task_t task, mach_port_name_t name, mach_port_delta_t delta );
177
178extern io_object_t iokit_lookup_object_with_port_name(mach_port_name_t name, ipc_kobject_type_t type, task_t task);
179
180extern io_object_t iokit_lookup_connect_ref_current_task(mach_port_name_t name);
181extern io_object_t iokit_lookup_uext_ref_current_task(mach_port_name_t name);
182
183extern void iokit_retain_port( ipc_port_t port );
184extern void iokit_release_port( ipc_port_t port );
185extern void iokit_release_port_send( ipc_port_t port );
186
187extern void iokit_lock_port(ipc_port_t port);
188extern void iokit_unlock_port(ipc_port_t port);
189
190extern ipc_port_t iokit_lookup_raw_current_task(mach_port_name_t name, ipc_kobject_type_t * type);
191
192#ifndef MACH_KERNEL_PRIVATE
193typedef struct ipc_kmsg * ipc_kmsg_t;
194extern ipc_kmsg_t ipc_kmsg_alloc_uext_reply(size_t);
195extern mach_msg_header_t * ikm_header(ipc_kmsg_t);
196extern void * ikm_udata_from_header(
197 ipc_kmsg_t kmsg);
198#endif /* MACH_KERNEL_PRIVATE */
199
200extern kern_return_t
201uext_server(ipc_port_t receiver, ipc_kmsg_t request, ipc_kmsg_t * preply);
202
203extern kern_return_t
204iokit_label_dext_task(task_t task);
205
206extern void
207iokit_clear_registered_ports(task_t task);
208
209/*
210 * Functions imported by iokit:IOMemoryDescriptor.cpp
211 */
212
213extern ppnum_t IOGetLastPageNumber(void);
214
215extern kern_return_t IOMapPages(vm_map_t map, mach_vm_address_t va, mach_vm_address_t pa,
216 mach_vm_size_t length, unsigned int mapFlags);
217
218extern kern_return_t IOUnmapPages(vm_map_t map, mach_vm_address_t va, mach_vm_size_t length);
219
220extern kern_return_t IOProtectCacheMode(vm_map_t map, mach_vm_address_t va,
221 mach_vm_size_t length, unsigned int options);
222
223extern unsigned int IODefaultCacheBits(addr64_t pa);
224
225#ifdef __cplusplus
226} /* extern "C" */
227#endif /* __cplusplus */
228
229#endif /* MACH_KERNEL_PRIVATE */
230
231#endif /* ! _IOKIT_IOKITSERVER_H */
232