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"
82 class IOUserClient
: public IOService
84 OSDeclareAbstractStructors(IOUserClient
)
87 /*! @struct ExpansionData
88 @discussion This structure will be used to expand the capablilties of this class in the future.
90 struct ExpansionData
{ };
93 Reserved for future use. (Internal use only) */
94 ExpansionData
* reserved
;
101 OSMetaClassDeclareReservedUnused(IOUserClient
, 0);
102 OSMetaClassDeclareReservedUnused(IOUserClient
, 1);
103 OSMetaClassDeclareReservedUnused(IOUserClient
, 2);
104 OSMetaClassDeclareReservedUnused(IOUserClient
, 3);
105 OSMetaClassDeclareReservedUnused(IOUserClient
, 4);
106 OSMetaClassDeclareReservedUnused(IOUserClient
, 5);
107 OSMetaClassDeclareReservedUnused(IOUserClient
, 6);
108 OSMetaClassDeclareReservedUnused(IOUserClient
, 7);
109 OSMetaClassDeclareReservedUnused(IOUserClient
, 8);
110 OSMetaClassDeclareReservedUnused(IOUserClient
, 9);
111 OSMetaClassDeclareReservedUnused(IOUserClient
, 10);
112 OSMetaClassDeclareReservedUnused(IOUserClient
, 11);
113 OSMetaClassDeclareReservedUnused(IOUserClient
, 12);
114 OSMetaClassDeclareReservedUnused(IOUserClient
, 13);
115 OSMetaClassDeclareReservedUnused(IOUserClient
, 14);
116 OSMetaClassDeclareReservedUnused(IOUserClient
, 15);
119 static IOReturn
sendAsyncResult(OSAsyncReference reference
,
120 IOReturn result
, void *args
[], UInt32 numArgs
);
121 static void setAsyncReference(OSAsyncReference asyncRef
,
122 mach_port_t wakePort
,
123 void *callback
, void *refcon
);
126 static void initialize( void );
128 static void destroyUserReferences( OSObject
* obj
);
130 static IOReturn
clientHasPrivilege( void * securityToken
,
131 const char * privilegeName
);
133 // Currently ignores the all args, just passes up to IOService::init()
134 virtual bool initWithTask(
135 task_t owningTask
, void * securityToken
, UInt32 type
,
136 OSDictionary
* properties
);
138 virtual bool initWithTask(
139 task_t owningTask
, void * securityToken
, UInt32 type
);
143 virtual IOReturn
clientClose( void );
144 virtual IOReturn
clientDied( void );
146 virtual IOService
* getService( void );
148 virtual IOReturn
registerNotificationPort(
149 mach_port_t port
, UInt32 type
, UInt32 refCon
);
151 virtual IOReturn
getNotificationSemaphore( UInt32 notification_type
,
152 semaphore_t
* semaphore
);
154 virtual IOReturn
connectClient( IOUserClient
* client
);
156 // memory will be released by user client when last map is destroyed
157 virtual IOReturn
clientMemoryForType( UInt32 type
,
158 IOOptionBits
* options
,
159 IOMemoryDescriptor
** memory
);
161 virtual IOMemoryMap
* mapClientMemory( IOOptionBits type
,
163 IOOptionBits mapFlags
= kIOMapAnywhere
,
164 IOVirtualAddress atAddress
= 0 );
167 @function removeMappingForDescriptor
168 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.
169 @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
170 @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.
172 IOMemoryMap
* removeMappingForDescriptor(IOMemoryDescriptor
* memory
);
175 @function exportObjectToClient
176 Make an arbitrary OSObject available to the client task.
178 @param obj The object we want to export to the client
179 @param clientObj returned value is the client's port name.
181 virtual IOReturn
exportObjectToClient(task_t task
,
182 OSObject
*obj
, io_object_t
*clientObj
);
184 // Old methods for accessing method vector backward compatiblility only
185 virtual IOExternalMethod
*
186 getExternalMethodForIndex( UInt32 index
);
187 virtual IOExternalAsyncMethod
*
188 getExternalAsyncMethodForIndex( UInt32 index
);
190 // Methods for accessing method vector.
191 virtual IOExternalMethod
*
192 getTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
193 virtual IOExternalAsyncMethod
*
194 getAsyncTargetAndMethodForIndex( IOService
** targetP
, UInt32 index
);
196 // Methods for accessing trap vector - old and new style
197 virtual IOExternalTrap
*
198 getExternalTrapForIndex( UInt32 index
);
199 virtual IOExternalTrap
*
200 getTargetAndTrapForIndex( IOService
**targetP
, UInt32 index
);
203 #endif /* ! _IOKIT_IOUSERCLIENT_H */