2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * Changes to this API are expected.
30 #ifndef _IOKIT_IOUSERCLIENT_H
31 #define _IOKIT_IOUSERCLIENT_H
33 #include <IOKit/IOTypes.h>
34 #include <IOKit/IOService.h>
35 #include <IOKit/OSMessageNotification.h>
39 kIOUCTypeMask
= 0x0000000f,
40 kIOUCScalarIScalarO
= 0,
41 kIOUCScalarIStructO
= 2,
42 kIOUCStructIStructO
= 3,
43 kIOUCScalarIStructI
= 4,
46 typedef IOReturn (IOService::*IOMethod
)(void * p1
, void * p2
, void * p3
,
47 void * p4
, void * p5
, void * p6
);
49 typedef IOReturn (IOService::*IOAsyncMethod
)(OSAsyncReference asyncRef
,
50 void * p1
, void * p2
, void * p3
,
51 void * p4
, void * p5
, void * p6
);
53 typedef IOReturn (IOService::*IOTrap
)(void * p1
, void * p2
, void * p3
,
54 void * p4
, void * p5
, void * p6
);
56 struct IOExternalMethod
{
64 struct IOExternalAsyncMethod
{
72 struct IOExternalTrap
{
78 kIOUserNotifyMaxMessageSize
= 64
81 // keys for clientHasPrivilege
82 #define kIOClientPrivilegeAdministrator "root"
83 #define kIOClientPrivilegeLocalUser "local"
85 class IOUserClient
: public IOService
87 OSDeclareAbstractStructors(IOUserClient
)
90 /*! @struct ExpansionData
91 @discussion This structure will be used to expand the capablilties of this class in the future.
93 struct ExpansionData
{ };
96 Reserved for future use. (Internal use only) */
97 ExpansionData
* reserved
;
101 void * __reserved
[8];
104 OSMetaClassDeclareReservedUnused(IOUserClient
, 0);
105 OSMetaClassDeclareReservedUnused(IOUserClient
, 1);
106 OSMetaClassDeclareReservedUnused(IOUserClient
, 2);
107 OSMetaClassDeclareReservedUnused(IOUserClient
, 3);
108 OSMetaClassDeclareReservedUnused(IOUserClient
, 4);
109 OSMetaClassDeclareReservedUnused(IOUserClient
, 5);
110 OSMetaClassDeclareReservedUnused(IOUserClient
, 6);
111 OSMetaClassDeclareReservedUnused(IOUserClient
, 7);
112 OSMetaClassDeclareReservedUnused(IOUserClient
, 8);
113 OSMetaClassDeclareReservedUnused(IOUserClient
, 9);
114 OSMetaClassDeclareReservedUnused(IOUserClient
, 10);
115 OSMetaClassDeclareReservedUnused(IOUserClient
, 11);
116 OSMetaClassDeclareReservedUnused(IOUserClient
, 12);
117 OSMetaClassDeclareReservedUnused(IOUserClient
, 13);
118 OSMetaClassDeclareReservedUnused(IOUserClient
, 14);
119 OSMetaClassDeclareReservedUnused(IOUserClient
, 15);
122 static IOReturn
sendAsyncResult(OSAsyncReference reference
,
123 IOReturn result
, void *args
[], UInt32 numArgs
);
124 static void setAsyncReference(OSAsyncReference asyncRef
,
125 mach_port_t wakePort
,
126 void *callback
, void *refcon
);
129 static void initialize( void );
131 static void destroyUserReferences( OSObject
* obj
);
133 static IOReturn
clientHasPrivilege( void * securityToken
,
134 const char * privilegeName
);
136 // Currently ignores the all args, just passes up to IOService::init()
137 virtual bool initWithTask(
138 task_t owningTask
, void * securityToken
, UInt32 type
,
139 OSDictionary
* properties
);
141 virtual bool initWithTask(
142 task_t owningTask
, void * securityToken
, UInt32 type
);
146 virtual IOReturn
clientClose( void );
147 virtual IOReturn
clientDied( void );
149 virtual IOService
* getService( void );
151 virtual IOReturn
registerNotificationPort(
152 mach_port_t port
, UInt32 type
, UInt32 refCon
);
154 virtual IOReturn
getNotificationSemaphore( UInt32 notification_type
,
155 semaphore_t
* semaphore
);
157 virtual IOReturn
connectClient( IOUserClient
* client
);
159 // memory will be released by user client when last map is destroyed
160 virtual IOReturn
clientMemoryForType( UInt32 type
,
161 IOOptionBits
* options
,
162 IOMemoryDescriptor
** memory
);
164 virtual IOMemoryMap
* mapClientMemory( IOOptionBits type
,
166 IOOptionBits mapFlags
= kIOMapAnywhere
,
167 IOVirtualAddress atAddress
= 0 );
169 @function exportObjectToClient
170 Make an arbitrary OSObject available to the client task.
172 @param obj The object we want to export to the client
173 @param clientObj returned value is the client's port name.
175 virtual IOReturn
exportObjectToClient(task_t task
,
176 OSObject
*obj
, io_object_t
*clientObj
);
178 // Old methods for accessing method vector backward compatiblility only
179 virtual IOExternalMethod
*
180 getExternalMethodForIndex( UInt32 index
);
181 virtual IOExternalAsyncMethod
*
182 getExternalAsyncMethodForIndex( UInt32 index
);
184 // Methods for accessing method vector.
185 virtual IOExternalMethod
*
186 getTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
187 virtual IOExternalAsyncMethod
*
188 getAsyncTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
190 // Methods for accessing trap vector - old and new style
191 virtual IOExternalTrap
*
192 getExternalTrapForIndex( UInt32 index
);
193 virtual IOExternalTrap
*
194 getTargetAndTrapForIndex( IOService
**targetP
, UInt32 index
);
197 #endif /* ! _IOKIT_IOUSERCLIENT_H */