2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * Changes to this API are expected.
28 #ifndef _IOKIT_IOUSERCLIENT_H
29 #define _IOKIT_IOUSERCLIENT_H
31 #include <IOKit/IOTypes.h>
32 #include <IOKit/IOService.h>
33 #include <IOKit/OSMessageNotification.h>
37 kIOUCTypeMask
= 0x0000000f,
38 kIOUCScalarIScalarO
= 0,
39 kIOUCScalarIStructO
= 2,
40 kIOUCStructIStructO
= 3,
41 kIOUCScalarIStructI
= 4
44 typedef IOReturn (IOService::*IOMethod
)(void * p1
, void * p2
, void * p3
,
45 void * p4
, void * p5
, void * p6
);
47 typedef IOReturn (IOService::*IOAsyncMethod
)(OSAsyncReference asyncRef
,
48 void * p1
, void * p2
, void * p3
,
49 void * p4
, void * p5
, void * p6
);
51 typedef IOReturn (IOService::*IOTrap
)(void * p1
, void * p2
, void * p3
,
52 void * p4
, void * p5
, void * p6
);
54 struct IOExternalMethod
{
62 struct IOExternalAsyncMethod
{
70 struct IOExternalTrap
{
76 kIOUserNotifyMaxMessageSize
= 64
79 // keys for clientHasPrivilege
80 #define kIOClientPrivilegeAdministrator "root"
81 #define kIOClientPrivilegeLocalUser "local"
85 @abstract Provides a basis for communication between client applications and I/O Kit objects.
89 class IOUserClient
: public IOService
91 OSDeclareAbstractStructors(IOUserClient
)
94 /*! @struct ExpansionData
95 @discussion This structure will be used to expand the capablilties of this class in the future.
97 struct ExpansionData
{ };
100 Reserved for future use. (Internal use only)
102 ExpansionData
* reserved
;
106 void * __reserved
[8];
109 OSMetaClassDeclareReservedUnused(IOUserClient
, 0);
110 OSMetaClassDeclareReservedUnused(IOUserClient
, 1);
111 OSMetaClassDeclareReservedUnused(IOUserClient
, 2);
112 OSMetaClassDeclareReservedUnused(IOUserClient
, 3);
113 OSMetaClassDeclareReservedUnused(IOUserClient
, 4);
114 OSMetaClassDeclareReservedUnused(IOUserClient
, 5);
115 OSMetaClassDeclareReservedUnused(IOUserClient
, 6);
116 OSMetaClassDeclareReservedUnused(IOUserClient
, 7);
117 OSMetaClassDeclareReservedUnused(IOUserClient
, 8);
118 OSMetaClassDeclareReservedUnused(IOUserClient
, 9);
119 OSMetaClassDeclareReservedUnused(IOUserClient
, 10);
120 OSMetaClassDeclareReservedUnused(IOUserClient
, 11);
121 OSMetaClassDeclareReservedUnused(IOUserClient
, 12);
122 OSMetaClassDeclareReservedUnused(IOUserClient
, 13);
123 OSMetaClassDeclareReservedUnused(IOUserClient
, 14);
124 OSMetaClassDeclareReservedUnused(IOUserClient
, 15);
127 static IOReturn
sendAsyncResult(OSAsyncReference reference
,
128 IOReturn result
, void *args
[], UInt32 numArgs
);
129 static void setAsyncReference(OSAsyncReference asyncRef
,
130 mach_port_t wakePort
,
131 void *callback
, void *refcon
);
134 static void initialize( void );
136 static void destroyUserReferences( OSObject
* obj
);
138 static IOReturn
clientHasPrivilege( void * securityToken
,
139 const char * privilegeName
);
141 // Currently ignores the all args, just passes up to IOService::init()
142 virtual bool initWithTask(
143 task_t owningTask
, void * securityToken
, UInt32 type
,
144 OSDictionary
* properties
);
146 virtual bool initWithTask(
147 task_t owningTask
, void * securityToken
, UInt32 type
);
151 virtual IOReturn
clientClose( void );
152 virtual IOReturn
clientDied( void );
154 virtual IOService
* getService( void );
156 virtual IOReturn
registerNotificationPort(
157 mach_port_t port
, UInt32 type
, UInt32 refCon
);
159 virtual IOReturn
getNotificationSemaphore( UInt32 notification_type
,
160 semaphore_t
* semaphore
);
162 virtual IOReturn
connectClient( IOUserClient
* client
);
164 // memory will be released by user client when last map is destroyed
165 virtual IOReturn
clientMemoryForType( UInt32 type
,
166 IOOptionBits
* options
,
167 IOMemoryDescriptor
** memory
);
169 virtual IOMemoryMap
* mapClientMemory( IOOptionBits type
,
171 IOOptionBits mapFlags
= kIOMapAnywhere
,
172 IOVirtualAddress atAddress
= 0 );
175 @function removeMappingForDescriptor
176 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.
177 @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
178 @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.
180 IOMemoryMap
* removeMappingForDescriptor(IOMemoryDescriptor
* memory
);
183 @function exportObjectToClient
184 Make an arbitrary OSObject available to the client task.
185 @param task The task.
186 @param obj The object we want to export to the client.
187 @param clientObj Returned value is the client's port name.
189 virtual IOReturn
exportObjectToClient(task_t task
,
190 OSObject
*obj
, io_object_t
*clientObj
);
192 // Old methods for accessing method vector backward compatiblility only
193 virtual IOExternalMethod
*
194 getExternalMethodForIndex( UInt32 index
);
195 virtual IOExternalAsyncMethod
*
196 getExternalAsyncMethodForIndex( UInt32 index
);
198 // Methods for accessing method vector.
199 virtual IOExternalMethod
*
200 getTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
201 virtual IOExternalAsyncMethod
*
202 getAsyncTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
204 // Methods for accessing trap vector - old and new style
205 virtual IOExternalTrap
*
206 getExternalTrapForIndex( UInt32 index
);
207 virtual IOExternalTrap
*
208 getTargetAndTrapForIndex( IOService
**targetP
, UInt32 index
);
211 #endif /* ! _IOKIT_IOUSERCLIENT_H */