2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
24 * Changes to this API are expected.
27 #ifndef _IOKIT_IOUSERCLIENT_H
28 #define _IOKIT_IOUSERCLIENT_H
30 #include <IOKit/IOTypes.h>
31 #include <IOKit/IOService.h>
32 #include <IOKit/OSMessageNotification.h>
36 kIOUCTypeMask
= 0x0000000f,
37 kIOUCScalarIScalarO
= 0,
38 kIOUCScalarIStructO
= 2,
39 kIOUCStructIStructO
= 3,
40 kIOUCScalarIStructI
= 4
43 typedef IOReturn (IOService::*IOMethod
)(void * p1
, void * p2
, void * p3
,
44 void * p4
, void * p5
, void * p6
);
46 typedef IOReturn (IOService::*IOAsyncMethod
)(OSAsyncReference asyncRef
,
47 void * p1
, void * p2
, void * p3
,
48 void * p4
, void * p5
, void * p6
);
50 typedef IOReturn (IOService::*IOTrap
)(void * p1
, void * p2
, void * p3
,
51 void * p4
, void * p5
, void * p6
);
53 struct IOExternalMethod
{
61 struct IOExternalAsyncMethod
{
69 struct IOExternalTrap
{
75 kIOUserNotifyMaxMessageSize
= 64
78 // keys for clientHasPrivilege
79 #define kIOClientPrivilegeAdministrator "root"
80 #define kIOClientPrivilegeLocalUser "local"
84 @abstract Provides a basis for communication between client applications and I/O Kit objects.
88 class IOUserClient
: public IOService
90 OSDeclareAbstractStructors(IOUserClient
)
93 /*! @struct ExpansionData
94 @discussion This structure will be used to expand the capablilties of this class in the future.
96 struct ExpansionData
{ };
99 Reserved for future use. (Internal use only)
101 ExpansionData
* reserved
;
105 UInt8 sharedInstance
;
107 UInt8 __reservedA
[3];
108 void * __reserved
[7];
111 OSMetaClassDeclareReservedUnused(IOUserClient
, 0);
112 OSMetaClassDeclareReservedUnused(IOUserClient
, 1);
113 OSMetaClassDeclareReservedUnused(IOUserClient
, 2);
114 OSMetaClassDeclareReservedUnused(IOUserClient
, 3);
115 OSMetaClassDeclareReservedUnused(IOUserClient
, 4);
116 OSMetaClassDeclareReservedUnused(IOUserClient
, 5);
117 OSMetaClassDeclareReservedUnused(IOUserClient
, 6);
118 OSMetaClassDeclareReservedUnused(IOUserClient
, 7);
119 OSMetaClassDeclareReservedUnused(IOUserClient
, 8);
120 OSMetaClassDeclareReservedUnused(IOUserClient
, 9);
121 OSMetaClassDeclareReservedUnused(IOUserClient
, 10);
122 OSMetaClassDeclareReservedUnused(IOUserClient
, 11);
123 OSMetaClassDeclareReservedUnused(IOUserClient
, 12);
124 OSMetaClassDeclareReservedUnused(IOUserClient
, 13);
125 OSMetaClassDeclareReservedUnused(IOUserClient
, 14);
126 OSMetaClassDeclareReservedUnused(IOUserClient
, 15);
129 static IOReturn
sendAsyncResult(OSAsyncReference reference
,
130 IOReturn result
, void *args
[], UInt32 numArgs
);
131 static void setAsyncReference(OSAsyncReference asyncRef
,
132 mach_port_t wakePort
,
133 void *callback
, void *refcon
);
136 static void initialize( void );
138 static void destroyUserReferences( OSObject
* obj
);
140 static IOReturn
clientHasPrivilege( void * securityToken
,
141 const char * privilegeName
);
143 #if !(defined(__ppc__) && defined(KPI_10_4_0_PPC_COMPAT))
145 virtual bool init( OSDictionary
* dictionary
);
147 // Currently ignores the all args, just passes up to IOService::init()
148 virtual bool initWithTask(
149 task_t owningTask
, void * securityToken
, UInt32 type
,
150 OSDictionary
* properties
);
152 virtual bool initWithTask(
153 task_t owningTask
, void * securityToken
, UInt32 type
);
157 virtual IOReturn
clientClose( void );
158 virtual IOReturn
clientDied( void );
160 virtual IOService
* getService( void );
162 virtual IOReturn
registerNotificationPort(
163 mach_port_t port
, UInt32 type
, UInt32 refCon
);
165 virtual IOReturn
getNotificationSemaphore( UInt32 notification_type
,
166 semaphore_t
* semaphore
);
168 virtual IOReturn
connectClient( IOUserClient
* client
);
170 // memory will be released by user client when last map is destroyed
171 virtual IOReturn
clientMemoryForType( UInt32 type
,
172 IOOptionBits
* options
,
173 IOMemoryDescriptor
** memory
);
175 virtual IOMemoryMap
* mapClientMemory( IOOptionBits type
,
177 IOOptionBits mapFlags
= kIOMapAnywhere
,
178 IOVirtualAddress atAddress
= 0 );
181 @function removeMappingForDescriptor
182 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.
183 @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
184 @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.
186 IOMemoryMap
* removeMappingForDescriptor(IOMemoryDescriptor
* memory
);
189 @function exportObjectToClient
190 Make an arbitrary OSObject available to the client task.
191 @param task The task.
192 @param obj The object we want to export to the client.
193 @param clientObj Returned value is the client's port name.
195 virtual IOReturn
exportObjectToClient(task_t task
,
196 OSObject
*obj
, io_object_t
*clientObj
);
198 // Old methods for accessing method vector backward compatiblility only
199 virtual IOExternalMethod
*
200 getExternalMethodForIndex( UInt32 index
);
201 virtual IOExternalAsyncMethod
*
202 getExternalAsyncMethodForIndex( UInt32 index
);
204 // Methods for accessing method vector.
205 virtual IOExternalMethod
*
206 getTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
207 virtual IOExternalAsyncMethod
*
208 getAsyncTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
210 // Methods for accessing trap vector - old and new style
211 virtual IOExternalTrap
*
212 getExternalTrapForIndex( UInt32 index
);
213 virtual IOExternalTrap
*
214 getTargetAndTrapForIndex( IOService
**targetP
, UInt32 index
);
217 #endif /* ! _IOKIT_IOUSERCLIENT_H */