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 48 extern "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 */ 69 enum { 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 */ 87 enum { 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 */ 99 enum { 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 */ 110 enum { 111 kIOCatalogModuleUnload = 1, 112 kIOCatalogModuleTerminate, 113 kIOCatalogServiceTerminate 114 }; 115 116 117 #ifdef XNU_KERNEL_PRIVATE 118 119 #ifdef __cplusplus 120 extern "C" { 121 #endif /* __cplusplus */ 122 123 #include <kern/ipc_kobject.h> 124 125 /* 126 * Functions in iokit:IOUserClient.cpp 127 */ 128 129 extern void iokit_add_reference( io_object_t obj, ipc_kobject_type_t type ); 130 131 extern ipc_port_t iokit_port_for_object( io_object_t obj, 132 ipc_kobject_type_t type ); 133 134 extern kern_return_t iokit_client_died( io_object_t obj, 135 ipc_port_t port, ipc_kobject_type_t type, mach_port_mscount_t * mscount ); 136 137 extern kern_return_t 138 iokit_client_memory_for_type( 139 io_object_t connect, 140 unsigned int type, 141 unsigned int * flags, 142 vm_address_t * address, 143 vm_size_t * size ); 144 145 /* 146 * Functions in osfmk:iokit_rpc.c 147 */ 148 149 extern ipc_port_t iokit_alloc_object_port( io_object_t obj, 150 ipc_kobject_type_t type ); 151 152 extern kern_return_t iokit_destroy_object_port( ipc_port_t port, 153 ipc_kobject_type_t type ); 154 155 extern mach_port_name_t iokit_make_send_right( task_t task, 156 io_object_t obj, ipc_kobject_type_t type ); 157 158 extern mach_port_t ipc_port_make_send(mach_port_t) __result_use_check; 159 extern mach_port_t ipc_port_copy_send(mach_port_t) __result_use_check; 160 extern void ipc_port_release_send(ipc_port_t port); 161 162 extern io_object_t iokit_lookup_io_object(ipc_port_t port, ipc_kobject_type_t type); 163 164 extern kern_return_t iokit_mod_send_right( task_t task, mach_port_name_t name, mach_port_delta_t delta ); 165 166 extern io_object_t iokit_lookup_object_with_port_name(mach_port_name_t name, ipc_kobject_type_t type, task_t task); 167 168 extern io_object_t iokit_lookup_connect_ref_current_task(mach_port_name_t name); 169 extern io_object_t iokit_lookup_uext_ref_current_task(mach_port_name_t name); 170 171 extern void iokit_retain_port( ipc_port_t port ); 172 extern void iokit_release_port( ipc_port_t port ); 173 extern void iokit_release_port_send( ipc_port_t port ); 174 175 extern void iokit_lock_port(ipc_port_t port); 176 extern void iokit_unlock_port(ipc_port_t port); 177 178 extern kern_return_t iokit_switch_object_port( ipc_port_t port, io_object_t obj, ipc_kobject_type_t type ); 179 180 extern ipc_port_t iokit_lookup_raw_current_task(mach_port_name_t name, ipc_kobject_type_t * type); 181 182 #ifndef MACH_KERNEL_PRIVATE 183 typedef struct ipc_kmsg * ipc_kmsg_t; 184 extern ipc_kmsg_t ipc_kmsg_alloc_uext_reply(size_t); 185 extern mach_msg_header_t * ipc_kmsg_msg_header(ipc_kmsg_t); 186 #endif /* MACH_KERNEL_PRIVATE */ 187 188 extern kern_return_t 189 uext_server(ipc_port_t receiver, ipc_kmsg_t request, ipc_kmsg_t * preply); 190 191 extern kern_return_t 192 iokit_label_dext_task(task_t task); 193 194 /* 195 * Functions imported by iokit:IOMemoryDescriptor.cpp 196 */ 197 198 extern ppnum_t IOGetLastPageNumber(void); 199 200 extern kern_return_t IOMapPages(vm_map_t map, mach_vm_address_t va, mach_vm_address_t pa, 201 mach_vm_size_t length, unsigned int mapFlags); 202 203 extern kern_return_t IOUnmapPages(vm_map_t map, mach_vm_address_t va, mach_vm_size_t length); 204 205 extern kern_return_t IOProtectCacheMode(vm_map_t map, mach_vm_address_t va, 206 mach_vm_size_t length, unsigned int options); 207 208 extern unsigned int IODefaultCacheBits(addr64_t pa); 209 210 #ifdef __cplusplus 211 } /* extern "C" */ 212 #endif /* __cplusplus */ 213 214 #endif /* MACH_KERNEL_PRIVATE */ 215 216 #endif /* ! _IOKIT_IOKITSERVER_H */ 217