2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 * Changes to this API are expected.
35 #ifndef _IOKIT_IOUSERCLIENT_H
36 #define _IOKIT_IOUSERCLIENT_H
38 #include <IOKit/IOTypes.h>
39 #include <IOKit/IOService.h>
40 #include <IOKit/OSMessageNotification.h>
44 kIOUCTypeMask
= 0x0000000f,
45 kIOUCScalarIScalarO
= 0,
46 kIOUCScalarIStructO
= 2,
47 kIOUCStructIStructO
= 3,
48 kIOUCScalarIStructI
= 4
51 typedef IOReturn (IOService::*IOMethod
)(void * p1
, void * p2
, void * p3
,
52 void * p4
, void * p5
, void * p6
);
54 typedef IOReturn (IOService::*IOAsyncMethod
)(OSAsyncReference asyncRef
,
55 void * p1
, void * p2
, void * p3
,
56 void * p4
, void * p5
, void * p6
);
58 typedef IOReturn (IOService::*IOTrap
)(void * p1
, void * p2
, void * p3
,
59 void * p4
, void * p5
, void * p6
);
61 struct IOExternalMethod
{
69 struct IOExternalAsyncMethod
{
77 struct IOExternalTrap
{
83 kIOUserNotifyMaxMessageSize
= 64
86 // keys for clientHasPrivilege
87 #define kIOClientPrivilegeAdministrator "root"
88 #define kIOClientPrivilegeLocalUser "local"
92 @abstract Provides a basis for communication between client applications and I/O Kit objects.
96 class IOUserClient
: public IOService
98 OSDeclareAbstractStructors(IOUserClient
)
101 /*! @struct ExpansionData
102 @discussion This structure will be used to expand the capablilties of this class in the future.
104 struct ExpansionData
{ };
107 Reserved for future use. (Internal use only)
109 ExpansionData
* reserved
;
113 UInt8 sharedInstance
;
115 UInt8 __reservedA
[3];
116 void * __reserved
[7];
119 OSMetaClassDeclareReservedUnused(IOUserClient
, 0);
120 OSMetaClassDeclareReservedUnused(IOUserClient
, 1);
121 OSMetaClassDeclareReservedUnused(IOUserClient
, 2);
122 OSMetaClassDeclareReservedUnused(IOUserClient
, 3);
123 OSMetaClassDeclareReservedUnused(IOUserClient
, 4);
124 OSMetaClassDeclareReservedUnused(IOUserClient
, 5);
125 OSMetaClassDeclareReservedUnused(IOUserClient
, 6);
126 OSMetaClassDeclareReservedUnused(IOUserClient
, 7);
127 OSMetaClassDeclareReservedUnused(IOUserClient
, 8);
128 OSMetaClassDeclareReservedUnused(IOUserClient
, 9);
129 OSMetaClassDeclareReservedUnused(IOUserClient
, 10);
130 OSMetaClassDeclareReservedUnused(IOUserClient
, 11);
131 OSMetaClassDeclareReservedUnused(IOUserClient
, 12);
132 OSMetaClassDeclareReservedUnused(IOUserClient
, 13);
133 OSMetaClassDeclareReservedUnused(IOUserClient
, 14);
134 OSMetaClassDeclareReservedUnused(IOUserClient
, 15);
137 static IOReturn
sendAsyncResult(OSAsyncReference reference
,
138 IOReturn result
, void *args
[], UInt32 numArgs
);
139 static void setAsyncReference(OSAsyncReference asyncRef
,
140 mach_port_t wakePort
,
141 void *callback
, void *refcon
);
144 static void initialize( void );
146 static void destroyUserReferences( OSObject
* obj
);
148 static IOReturn
clientHasPrivilege( void * securityToken
,
149 const char * privilegeName
);
151 #if !(defined(__ppc__) && defined(KPI_10_4_0_PPC_COMPAT))
153 virtual bool init( OSDictionary
* dictionary
);
155 // Currently ignores the all args, just passes up to IOService::init()
156 virtual bool initWithTask(
157 task_t owningTask
, void * securityToken
, UInt32 type
,
158 OSDictionary
* properties
);
160 virtual bool initWithTask(
161 task_t owningTask
, void * securityToken
, UInt32 type
);
165 virtual IOReturn
clientClose( void );
166 virtual IOReturn
clientDied( void );
168 virtual IOService
* getService( void );
170 virtual IOReturn
registerNotificationPort(
171 mach_port_t port
, UInt32 type
, UInt32 refCon
);
173 virtual IOReturn
getNotificationSemaphore( UInt32 notification_type
,
174 semaphore_t
* semaphore
);
176 virtual IOReturn
connectClient( IOUserClient
* client
);
178 // memory will be released by user client when last map is destroyed
179 virtual IOReturn
clientMemoryForType( UInt32 type
,
180 IOOptionBits
* options
,
181 IOMemoryDescriptor
** memory
);
183 virtual IOMemoryMap
* mapClientMemory( IOOptionBits type
,
185 IOOptionBits mapFlags
= kIOMapAnywhere
,
186 IOVirtualAddress atAddress
= 0 );
189 @function removeMappingForDescriptor
190 Remove the first mapping created from the memory descriptor returned by clientMemoryForType() from IOUserClient's list of mappings. If such a mapping exists, it is retained and the reference currently held by IOUserClient is returned to the caller.
191 @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
192 @result A reference to the first IOMemoryMap instance found in the list of mappings created by IOUserClient from that passed memory descriptor is returned, or zero if none exist. The caller should release this reference.
194 IOMemoryMap
* removeMappingForDescriptor(IOMemoryDescriptor
* memory
);
197 @function exportObjectToClient
198 Make an arbitrary OSObject available to the client task.
199 @param task The task.
200 @param obj The object we want to export to the client.
201 @param clientObj Returned value is the client's port name.
203 virtual IOReturn
exportObjectToClient(task_t task
,
204 OSObject
*obj
, io_object_t
*clientObj
);
206 // Old methods for accessing method vector backward compatiblility only
207 virtual IOExternalMethod
*
208 getExternalMethodForIndex( UInt32 index
);
209 virtual IOExternalAsyncMethod
*
210 getExternalAsyncMethodForIndex( UInt32 index
);
212 // Methods for accessing method vector.
213 virtual IOExternalMethod
*
214 getTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
215 virtual IOExternalAsyncMethod
*
216 getAsyncTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
218 // Methods for accessing trap vector - old and new style
219 virtual IOExternalTrap
*
220 getExternalTrapForIndex( UInt32 index
);
221 virtual IOExternalTrap
*
222 getTargetAndTrapForIndex( IOService
**targetP
, UInt32 index
);
225 #endif /* ! _IOKIT_IOUSERCLIENT_H */