1/*
2 * Copyright (c) 1998-2019 Apple 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()
40enum {
41 kIONotifyOnce = 0x00000001,
42 kIOServiceExistingSet = 0x00000002,
43 kIOServiceChangesOK = 0x00000004,
44 kIOServiceInternalDone = 0x00000008,
45 kIOServiceClassDone = 0x00000010,
46};
47
48// masks for __state[1]
49enum {
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 kIOServiceRematchOnDetach = 0x00008000,
71 kIOServiceUserUnhidden = 0x00004000,
72// kIOServiceX1 = 0x00004000,
73// kIOServiceX2 = 0x00002000,
74// kIOServiceX3 = 0x00001000,
75// kIOServiceX4 = 0x00000800,
76// kIOServiceX5 = 0x00000400,
77};
78
79extern const OSSymbol * gIOServiceNotificationUserKey;
80
81
82// notify state
83enum {
84 kIOServiceNotifyEnable = 0x00000001,
85 kIOServiceNotifyWaiter = 0x00000002,
86 kIOServiceNotifyBlock = 0x00000004
87};
88
89struct _IOServiceNotifierInvocation {
90 IOThread thread;
91 queue_chain_t link;
92};
93
94class _IOServiceNotifier : public IONotifier
95{
96 friend class IOService;
97
98 OSDeclareDefaultStructors(_IOServiceNotifier);
99
100public:
101 OSOrderedSet * whence;
102
103 OSDictionary * matching;
104 const OSSymbol * type;
105 IOServiceMatchingNotificationHandler handler;
106 IOServiceNotificationHandler compatHandler;
107 void * target;
108 void * ref;
109 SInt32 priority;
110 queue_head_t handlerInvocations;
111 IOOptionBits state;
112
113 virtual void free() APPLE_KEXT_OVERRIDE;
114 virtual void remove() APPLE_KEXT_OVERRIDE;
115 virtual bool disable() APPLE_KEXT_OVERRIDE;
116 virtual void enable( bool was ) APPLE_KEXT_OVERRIDE;
117 virtual void wait();
118};
119
120class _IOServiceInterestNotifier : public IONotifier
121{
122 friend class IOService;
123
124 OSDeclareDefaultStructors(_IOServiceInterestNotifier);
125
126public:
127 queue_chain_t chain;
128
129 IOServiceInterestHandler handler;
130 void * target;
131 void * ref;
132 queue_head_t handlerInvocations;
133 IOOptionBits state;
134
135 virtual void free() APPLE_KEXT_OVERRIDE;
136 virtual void remove() APPLE_KEXT_OVERRIDE;
137 virtual bool disable() APPLE_KEXT_OVERRIDE;
138 virtual void enable( bool was ) APPLE_KEXT_OVERRIDE;
139 virtual void wait();
140 virtual bool init() APPLE_KEXT_OVERRIDE;
141};
142
143class _IOServiceNullNotifier : public IONotifier
144{
145 OSDeclareDefaultStructors(_IOServiceNullNotifier);
146
147public:
148 virtual void taggedRetain(const void *tag) const APPLE_KEXT_OVERRIDE;
149 virtual void taggedRelease(const void *tag, const int when) const APPLE_KEXT_OVERRIDE;
150 virtual void free() APPLE_KEXT_OVERRIDE;
151 virtual void remove() APPLE_KEXT_OVERRIDE;
152 virtual bool disable() APPLE_KEXT_OVERRIDE;
153 virtual void enable( bool was ) APPLE_KEXT_OVERRIDE;
154 virtual void wait();
155};
156
157class _IOConfigThread : public OSObject
158{
159 friend class IOService;
160
161 OSDeclareDefaultStructors(_IOConfigThread);
162
163public:
164 static void configThread( const char * name );
165 static void main( void * arg, wait_result_t result );
166};
167
168enum {
169 kMaxConfigThreads = CONFIG_MAX_THREADS,
170};
171
172enum {
173 kMatchNubJob = 10,
174};
175
176class _IOServiceJob : public OSObject
177{
178 friend class IOService;
179
180 OSDeclareDefaultStructors(_IOServiceJob);
181
182public:
183 int type;
184 IOService * nub;
185 IOOptionBits options;
186
187 static LIBKERN_RETURNS_NOT_RETAINED _IOServiceJob * startJob( IOService * nub, int type,
188 IOOptionBits options = 0 );
189 static void pingConfig( LIBKERN_CONSUMED class _IOServiceJob * job );
190};
191
192class IOResources : public IOService
193{
194 friend class IOService;
195
196 OSDeclareDefaultStructors(IOResources);
197
198public:
199 static IOService * resources( void );
200 virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
201 virtual IOReturn newUserClient(task_t owningTask, void * securityID,
202 UInt32 type, OSDictionary * properties,
203 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
204 virtual IOWorkLoop * getWorkLoop() const APPLE_KEXT_OVERRIDE;
205 virtual bool matchPropertyTable( OSDictionary * table ) APPLE_KEXT_OVERRIDE;
206 virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
207};
208
209class IOUserResources : public IOService
210{
211 friend class IOService;
212
213 OSDeclareDefaultStructors(IOUserResources);
214
215public:
216 static IOService * resources( void );
217 virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
218 virtual IOReturn newUserClient(task_t owningTask, void * securityID,
219 UInt32 type, OSDictionary * properties,
220 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
221 virtual IOWorkLoop * getWorkLoop() const APPLE_KEXT_OVERRIDE;
222 virtual bool matchPropertyTable( OSDictionary * table ) APPLE_KEXT_OVERRIDE;
223};
224
225class _IOOpenServiceIterator : public OSIterator
226{
227 friend class IOService;
228
229 OSDeclareDefaultStructors(_IOOpenServiceIterator);
230
231 OSIterator * iter;
232 const IOService * client;
233 const IOService * provider;
234 IOService * last;
235
236public:
237 static OSIterator * iterator(LIBKERN_CONSUMED OSIterator * _iter,
238 const IOService * client,
239 const IOService * provider );
240 virtual void free() APPLE_KEXT_OVERRIDE;
241 virtual void reset() APPLE_KEXT_OVERRIDE;
242 virtual bool isValid() APPLE_KEXT_OVERRIDE;
243 virtual OSObject * getNextObject() APPLE_KEXT_OVERRIDE;
244};
245
246class IOExclaveProxy : public IOService
247{
248 OSDeclareDefaultStructors(IOExclaveProxy);
249
250 IOExclaveProxyState * exclaveState;
251
252 bool start(IOService * provider) APPLE_KEXT_OVERRIDE;
253};
254
255class _IOServiceStateNotification : public IOService
256{
257 friend class IOService;
258
259 IOLock * fLock;
260 OSDictionary * fItems;
261
262 OSDeclareDefaultStructors(_IOServiceStateNotification);
263
264public:
265};
266
267
268
269extern const OSSymbol * gIOConsoleUsersKey;
270extern const OSSymbol * gIOConsoleSessionUIDKey;
271extern const OSSymbol * gIOConsoleSessionAuditIDKey;
272extern const OSSymbol * gIOConsoleSessionOnConsoleKey;
273extern const OSSymbol * gIOConsoleSessionSecureInputPIDKey;
274
275#endif /* ! _IOKIT_IOSERVICEPRIVATE_H */
276