| 1 | /* |
| 2 | * Copyright (c) 1998-2000 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) 1999 Apple Computer, Inc. All rights reserved. |
| 30 | * |
| 31 | * HISTORY |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | |
| 36 | #ifndef _IOKIT_IOSERVICEPRIVATE_H |
| 37 | #define _IOKIT_IOSERVICEPRIVATE_H |
| 38 | |
| 39 | // options for getExistingServices() |
| 40 | enum { |
| 41 | kIONotifyOnce = 0x00000001, |
| 42 | kIOServiceExistingSet = 0x00000002, |
| 43 | kIOServiceChangesOK = 0x00000004, |
| 44 | kIOServiceInternalDone = 0x00000008, |
| 45 | kIOServiceClassDone = 0x00000010, |
| 46 | }; |
| 47 | |
| 48 | // masks for __state[1] |
| 49 | enum { |
| 50 | kIOServiceBusyStateMask = 0x000003ff, |
| 51 | kIOServiceBusyMax = 1023, |
| 52 | kIOServiceNeedConfigState = 0x80000000, |
| 53 | kIOServiceSynchronousState = 0x40000000, |
| 54 | kIOServiceModuleStallState = 0x20000000, |
| 55 | kIOServiceBusyWaiterState = 0x10000000, |
| 56 | |
| 57 | kIOServiceSyncPubState = 0x08000000, |
| 58 | kIOServiceConfigState = 0x04000000, |
| 59 | kIOServiceStartState = 0x02000000, |
| 60 | kIOServiceTermPhase2State = 0x01000000, |
| 61 | kIOServiceTermPhase3State = 0x00800000, |
| 62 | kIOServiceTermPhase1State = 0x00400000, |
| 63 | kIOServiceTerm1WaiterState = 0x00200000, |
| 64 | kIOServiceRecursing = 0x00100000, |
| 65 | kIOServiceNeedWillTerminate = 0x00080000, |
| 66 | kIOServiceWaitDetachState = 0x00040000, |
| 67 | kIOServiceConfigRunning = 0x00020000, |
| 68 | kIOServiceFinalized = 0x00010000, |
| 69 | }; |
| 70 | |
| 71 | // notify state |
| 72 | enum { |
| 73 | kIOServiceNotifyEnable = 0x00000001, |
| 74 | kIOServiceNotifyWaiter = 0x00000002, |
| 75 | kIOServiceNotifyBlock = 0x00000004 |
| 76 | }; |
| 77 | |
| 78 | struct _IOServiceNotifierInvocation |
| 79 | { |
| 80 | IOThread thread; |
| 81 | queue_chain_t link; |
| 82 | }; |
| 83 | |
| 84 | class _IOServiceNotifier : public IONotifier |
| 85 | { |
| 86 | friend class IOService; |
| 87 | |
| 88 | OSDeclareDefaultStructors(_IOServiceNotifier) |
| 89 | |
| 90 | public: |
| 91 | OSOrderedSet * whence; |
| 92 | |
| 93 | OSDictionary * matching; |
| 94 | const OSSymbol * type; |
| 95 | IOServiceMatchingNotificationHandler handler; |
| 96 | IOServiceNotificationHandler compatHandler; |
| 97 | void * target; |
| 98 | void * ref; |
| 99 | SInt32 priority; |
| 100 | queue_head_t handlerInvocations; |
| 101 | IOOptionBits state; |
| 102 | |
| 103 | virtual void free() APPLE_KEXT_OVERRIDE; |
| 104 | virtual void remove() APPLE_KEXT_OVERRIDE; |
| 105 | virtual bool disable() APPLE_KEXT_OVERRIDE; |
| 106 | virtual void enable( bool was ) APPLE_KEXT_OVERRIDE; |
| 107 | virtual void wait(); |
| 108 | }; |
| 109 | |
| 110 | class _IOServiceInterestNotifier : public IONotifier |
| 111 | { |
| 112 | friend class IOService; |
| 113 | |
| 114 | OSDeclareDefaultStructors(_IOServiceInterestNotifier) |
| 115 | |
| 116 | public: |
| 117 | queue_chain_t chain; |
| 118 | |
| 119 | IOServiceInterestHandler handler; |
| 120 | void * target; |
| 121 | void * ref; |
| 122 | queue_head_t handlerInvocations; |
| 123 | IOOptionBits state; |
| 124 | |
| 125 | virtual void free() APPLE_KEXT_OVERRIDE; |
| 126 | virtual void remove() APPLE_KEXT_OVERRIDE; |
| 127 | virtual bool disable() APPLE_KEXT_OVERRIDE; |
| 128 | virtual void enable( bool was ) APPLE_KEXT_OVERRIDE; |
| 129 | virtual void wait(); |
| 130 | virtual bool init() APPLE_KEXT_OVERRIDE; |
| 131 | }; |
| 132 | |
| 133 | class _IOServiceNullNotifier : public IONotifier |
| 134 | { |
| 135 | OSDeclareDefaultStructors(_IOServiceNullNotifier) |
| 136 | |
| 137 | public: |
| 138 | virtual void taggedRetain(const void *tag) const APPLE_KEXT_OVERRIDE; |
| 139 | virtual void taggedRelease(const void *tag, const int when) const APPLE_KEXT_OVERRIDE; |
| 140 | virtual void free() APPLE_KEXT_OVERRIDE; |
| 141 | virtual void remove() APPLE_KEXT_OVERRIDE; |
| 142 | virtual bool disable() APPLE_KEXT_OVERRIDE; |
| 143 | virtual void enable( bool was ) APPLE_KEXT_OVERRIDE; |
| 144 | virtual void wait(); |
| 145 | }; |
| 146 | |
| 147 | class _IOConfigThread : public OSObject |
| 148 | { |
| 149 | friend class IOService; |
| 150 | |
| 151 | OSDeclareDefaultStructors(_IOConfigThread) |
| 152 | |
| 153 | public: |
| 154 | virtual void free() APPLE_KEXT_OVERRIDE; |
| 155 | |
| 156 | static void configThread( void ); |
| 157 | static void main( void * arg, wait_result_t result ); |
| 158 | }; |
| 159 | |
| 160 | enum { |
| 161 | kMaxConfigThreads = CONFIG_MAX_THREADS, |
| 162 | }; |
| 163 | |
| 164 | enum { |
| 165 | kMatchNubJob = 10, |
| 166 | }; |
| 167 | |
| 168 | class _IOServiceJob : public OSObject |
| 169 | { |
| 170 | friend class IOService; |
| 171 | |
| 172 | OSDeclareDefaultStructors(_IOServiceJob) |
| 173 | |
| 174 | public: |
| 175 | int type; |
| 176 | IOService * nub; |
| 177 | IOOptionBits options; |
| 178 | |
| 179 | static _IOServiceJob * startJob( IOService * nub, int type, |
| 180 | IOOptionBits options = 0 ); |
| 181 | static void pingConfig( class _IOServiceJob * job ); |
| 182 | |
| 183 | }; |
| 184 | |
| 185 | class IOResources : public IOService |
| 186 | { |
| 187 | friend class IOService; |
| 188 | |
| 189 | OSDeclareDefaultStructors(IOResources) |
| 190 | |
| 191 | public: |
| 192 | static IOService * resources( void ); |
| 193 | virtual bool init( OSDictionary * dictionary = 0 ) APPLE_KEXT_OVERRIDE; |
| 194 | virtual IOReturn newUserClient(task_t owningTask, void * securityID, |
| 195 | UInt32 type, OSDictionary * properties, |
| 196 | IOUserClient ** handler) APPLE_KEXT_OVERRIDE; |
| 197 | virtual IOWorkLoop * getWorkLoop( ) const APPLE_KEXT_OVERRIDE; |
| 198 | virtual bool matchPropertyTable( OSDictionary * table ) APPLE_KEXT_OVERRIDE; |
| 199 | virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE; |
| 200 | }; |
| 201 | |
| 202 | class _IOOpenServiceIterator : public OSIterator |
| 203 | { |
| 204 | friend class IOService; |
| 205 | |
| 206 | OSDeclareDefaultStructors(_IOOpenServiceIterator) |
| 207 | |
| 208 | OSIterator * iter; |
| 209 | const IOService * client; |
| 210 | const IOService * provider; |
| 211 | IOService * last; |
| 212 | |
| 213 | public: |
| 214 | static OSIterator * iterator( OSIterator * _iter, |
| 215 | const IOService * client, |
| 216 | const IOService * provider ); |
| 217 | virtual void free() APPLE_KEXT_OVERRIDE; |
| 218 | virtual void reset() APPLE_KEXT_OVERRIDE; |
| 219 | virtual bool isValid() APPLE_KEXT_OVERRIDE; |
| 220 | virtual OSObject * getNextObject() APPLE_KEXT_OVERRIDE; |
| 221 | }; |
| 222 | |
| 223 | extern const OSSymbol * gIOConsoleUsersKey; |
| 224 | extern const OSSymbol * gIOConsoleSessionUIDKey; |
| 225 | extern const OSSymbol * gIOConsoleSessionAuditIDKey; |
| 226 | extern const OSSymbol * gIOConsoleSessionOnConsoleKey; |
| 227 | extern const OSSymbol * gIOConsoleSessionSecureInputPIDKey; |
| 228 | |
| 229 | |
| 230 | #define _interruptSourcesPrivate(service) \ |
| 231 | ((IOInterruptSourcePrivate *)(&(service)->_interruptSources[(service)->_numInterruptSources])) |
| 232 | |
| 233 | #define sizeofAllIOInterruptSource \ |
| 234 | (sizeof(IOInterruptSourcePrivate) + sizeof(IOInterruptSource)) |
| 235 | |
| 236 | #endif /* ! _IOKIT_IOSERVICEPRIVATE_H */ |
| 237 | |
| 238 | |