]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOServicePrivate.h
xnu-6153.61.1.tar.gz
[apple/xnu.git] / iokit / Kernel / IOServicePrivate.h
CommitLineData
1c79356b 1/*
cb323159 2 * Copyright (c) 1998-2019 Apple 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/*
0a7de745 29 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
1c79356b
A
30 *
31 * HISTORY
32 *
33 */
34
35
36#ifndef _IOKIT_IOSERVICEPRIVATE_H
37#define _IOKIT_IOSERVICEPRIVATE_H
38
39// options for getExistingServices()
40enum {
0a7de745
A
41 kIONotifyOnce = 0x00000001,
42 kIOServiceExistingSet = 0x00000002,
43 kIOServiceChangesOK = 0x00000004,
44 kIOServiceInternalDone = 0x00000008,
45 kIOServiceClassDone = 0x00000010,
1c79356b
A
46};
47
48// masks for __state[1]
49enum {
0a7de745
A
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,
1c79356b
A
69};
70
1c79356b
A
71// notify state
72enum {
0a7de745
A
73 kIOServiceNotifyEnable = 0x00000001,
74 kIOServiceNotifyWaiter = 0x00000002,
75 kIOServiceNotifyBlock = 0x00000004
1c79356b
A
76};
77
0a7de745
A
78struct _IOServiceNotifierInvocation {
79 IOThread thread;
80 queue_chain_t link;
1c79356b
A
81};
82
83class _IOServiceNotifier : public IONotifier
84{
0a7de745 85 friend class IOService;
1c79356b 86
cb323159 87 OSDeclareDefaultStructors(_IOServiceNotifier);
1c79356b
A
88
89public:
0a7de745
A
90 OSOrderedSet * whence;
91
92 OSDictionary * matching;
93 const OSSymbol * type;
94 IOServiceMatchingNotificationHandler handler;
95 IOServiceNotificationHandler compatHandler;
96 void * target;
97 void * ref;
98 SInt32 priority;
99 queue_head_t handlerInvocations;
100 IOOptionBits state;
101
102 virtual void free() APPLE_KEXT_OVERRIDE;
103 virtual void remove() APPLE_KEXT_OVERRIDE;
104 virtual bool disable() APPLE_KEXT_OVERRIDE;
105 virtual void enable( bool was ) APPLE_KEXT_OVERRIDE;
106 virtual void wait();
1c79356b
A
107};
108
109class _IOServiceInterestNotifier : public IONotifier
110{
0a7de745 111 friend class IOService;
1c79356b 112
cb323159 113 OSDeclareDefaultStructors(_IOServiceInterestNotifier);
1c79356b
A
114
115public:
0a7de745
A
116 queue_chain_t chain;
117
118 IOServiceInterestHandler handler;
119 void * target;
120 void * ref;
121 queue_head_t handlerInvocations;
122 IOOptionBits state;
123
124 virtual void free() APPLE_KEXT_OVERRIDE;
125 virtual void remove() APPLE_KEXT_OVERRIDE;
126 virtual bool disable() APPLE_KEXT_OVERRIDE;
127 virtual void enable( bool was ) APPLE_KEXT_OVERRIDE;
128 virtual void wait();
129 virtual bool init() APPLE_KEXT_OVERRIDE;
1c79356b
A
130};
131
39037602
A
132class _IOServiceNullNotifier : public IONotifier
133{
cb323159 134 OSDeclareDefaultStructors(_IOServiceNullNotifier);
39037602
A
135
136public:
0a7de745
A
137 virtual void taggedRetain(const void *tag) const APPLE_KEXT_OVERRIDE;
138 virtual void taggedRelease(const void *tag, const int when) const APPLE_KEXT_OVERRIDE;
139 virtual void free() APPLE_KEXT_OVERRIDE;
140 virtual void remove() APPLE_KEXT_OVERRIDE;
141 virtual bool disable() APPLE_KEXT_OVERRIDE;
142 virtual void enable( bool was ) APPLE_KEXT_OVERRIDE;
143 virtual void wait();
39037602
A
144};
145
1c79356b
A
146class _IOConfigThread : public OSObject
147{
0a7de745 148 friend class IOService;
1c79356b 149
cb323159 150 OSDeclareDefaultStructors(_IOConfigThread);
1c79356b
A
151
152public:
cb323159 153 static void configThread( int configThreadId );
0a7de745 154 static void main( void * arg, wait_result_t result );
1c79356b
A
155};
156
157enum {
0a7de745 158 kMaxConfigThreads = CONFIG_MAX_THREADS,
1c79356b
A
159};
160
161enum {
0a7de745 162 kMatchNubJob = 10,
1c79356b
A
163};
164
165class _IOServiceJob : public OSObject
166{
0a7de745 167 friend class IOService;
1c79356b 168
cb323159 169 OSDeclareDefaultStructors(_IOServiceJob);
1c79356b
A
170
171public:
0a7de745
A
172 int type;
173 IOService * nub;
174 IOOptionBits options;
1c79356b 175
0a7de745
A
176 static _IOServiceJob * startJob( IOService * nub, int type,
177 IOOptionBits options = 0 );
178 static void pingConfig( class _IOServiceJob * job );
1c79356b
A
179};
180
181class IOResources : public IOService
182{
0a7de745 183 friend class IOService;
1c79356b 184
cb323159 185 OSDeclareDefaultStructors(IOResources);
1c79356b
A
186
187public:
0a7de745 188 static IOService * resources( void );
cb323159 189 virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
0a7de745
A
190 virtual IOReturn newUserClient(task_t owningTask, void * securityID,
191 UInt32 type, OSDictionary * properties,
192 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
193 virtual IOWorkLoop * getWorkLoop() const APPLE_KEXT_OVERRIDE;
194 virtual bool matchPropertyTable( OSDictionary * table ) APPLE_KEXT_OVERRIDE;
195 virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
1c79356b
A
196};
197
cb323159
A
198class IOUserResources : public IOService
199{
200 friend class IOService;
201
202 OSDeclareDefaultStructors(IOUserResources);
203
204public:
205 static IOService * resources( void );
206 virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
207 virtual IOReturn newUserClient(task_t owningTask, void * securityID,
208 UInt32 type, OSDictionary * properties,
209 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
210 virtual IOWorkLoop * getWorkLoop() const APPLE_KEXT_OVERRIDE;
211 virtual bool matchPropertyTable( OSDictionary * table ) APPLE_KEXT_OVERRIDE;
212};
213
1c79356b
A
214class _IOOpenServiceIterator : public OSIterator
215{
0a7de745 216 friend class IOService;
1c79356b 217
cb323159 218 OSDeclareDefaultStructors(_IOOpenServiceIterator);
1c79356b 219
0a7de745
A
220 OSIterator * iter;
221 const IOService * client;
222 const IOService * provider;
223 IOService * last;
1c79356b
A
224
225public:
0a7de745
A
226 static OSIterator * iterator(LIBKERN_CONSUMED OSIterator * _iter,
227 const IOService * client,
228 const IOService * provider );
229 virtual void free() APPLE_KEXT_OVERRIDE;
230 virtual void reset() APPLE_KEXT_OVERRIDE;
231 virtual bool isValid() APPLE_KEXT_OVERRIDE;
232 virtual OSObject * getNextObject() APPLE_KEXT_OVERRIDE;
1c79356b
A
233};
234
55e303ae
A
235extern const OSSymbol * gIOConsoleUsersKey;
236extern const OSSymbol * gIOConsoleSessionUIDKey;
0a7de745 237extern const OSSymbol * gIOConsoleSessionAuditIDKey;
8f6c56a5
A
238extern const OSSymbol * gIOConsoleSessionOnConsoleKey;
239extern const OSSymbol * gIOConsoleSessionSecureInputPIDKey;
55e303ae 240
d9a64523
A
241
242#define _interruptSourcesPrivate(service) \
243 ((IOInterruptSourcePrivate *)(&(service)->_interruptSources[(service)->_numInterruptSources]))
244
245#define sizeofAllIOInterruptSource \
246 (sizeof(IOInterruptSourcePrivate) + sizeof(IOInterruptSource))
247
1c79356b 248#endif /* ! _IOKIT_IOSERVICEPRIVATE_H */