]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOUserClient.h
117db52591059ca320df7e5af79765b7c7f08201
[apple/xnu.git] / iokit / IOKit / IOUserClient.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 /*
27 * Changes to this API are expected.
28 */
29
30 #ifndef _IOKIT_IOUSERCLIENT_H
31 #define _IOKIT_IOUSERCLIENT_H
32
33 #include <IOKit/IOTypes.h>
34 #include <IOKit/IOService.h>
35 #include <IOKit/OSMessageNotification.h>
36
37
38 enum {
39 kIOUCTypeMask = 0x0000000f,
40 kIOUCScalarIScalarO = 0,
41 kIOUCScalarIStructO = 2,
42 kIOUCStructIStructO = 3,
43 kIOUCScalarIStructI = 4,
44 };
45
46 typedef IOReturn (IOService::*IOMethod)(void * p1, void * p2, void * p3,
47 void * p4, void * p5, void * p6 );
48
49 typedef IOReturn (IOService::*IOAsyncMethod)(OSAsyncReference asyncRef,
50 void * p1, void * p2, void * p3,
51 void * p4, void * p5, void * p6 );
52
53 typedef IOReturn (IOService::*IOTrap)(void * p1, void * p2, void * p3,
54 void * p4, void * p5, void * p6 );
55
56 struct IOExternalMethod {
57 IOService * object;
58 IOMethod func;
59 IOOptionBits flags;
60 IOByteCount count0;
61 IOByteCount count1;
62 };
63
64 struct IOExternalAsyncMethod {
65 IOService * object;
66 IOAsyncMethod func;
67 IOOptionBits flags;
68 IOByteCount count0;
69 IOByteCount count1;
70 };
71
72 struct IOExternalTrap {
73 IOService * object;
74 IOTrap func;
75 };
76
77 enum {
78 kIOUserNotifyMaxMessageSize = 64
79 };
80
81 // keys for clientHasPrivilege
82 #define kIOClientPrivilegeAdministrator "root"
83 #define kIOClientPrivilegeLocalUser "local"
84
85 class IOUserClient : public IOService
86 {
87 OSDeclareAbstractStructors(IOUserClient)
88
89 protected:
90 /*! @struct ExpansionData
91 @discussion This structure will be used to expand the capablilties of this class in the future.
92 */
93 struct ExpansionData { };
94
95 /*! @var reserved
96 Reserved for future use. (Internal use only) */
97 ExpansionData * reserved;
98
99 public:
100 OSSet * mappings;
101 void * __reserved[8];
102
103 private:
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);
120
121 protected:
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);
127 public:
128
129 static void initialize( void );
130
131 static void destroyUserReferences( OSObject * obj );
132
133 static IOReturn clientHasPrivilege( void * securityToken,
134 const char * privilegeName );
135
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);
140
141 virtual bool initWithTask(
142 task_t owningTask, void * securityToken, UInt32 type);
143
144 virtual void free();
145
146 virtual IOReturn clientClose( void );
147 virtual IOReturn clientDied( void );
148
149 virtual IOService * getService( void );
150
151 virtual IOReturn registerNotificationPort(
152 mach_port_t port, UInt32 type, UInt32 refCon );
153
154 virtual IOReturn getNotificationSemaphore( UInt32 notification_type,
155 semaphore_t * semaphore );
156
157 virtual IOReturn connectClient( IOUserClient * client );
158
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 );
163
164 virtual IOMemoryMap * mapClientMemory( IOOptionBits type,
165 task_t task,
166 IOOptionBits mapFlags = kIOMapAnywhere,
167 IOVirtualAddress atAddress = 0 );
168 /*!
169 @function exportObjectToClient
170 Make an arbitrary OSObject available to the client task.
171 @param task The task
172 @param obj The object we want to export to the client
173 @param clientObj returned value is the client's port name.
174 */
175 virtual IOReturn exportObjectToClient(task_t task,
176 OSObject *obj, io_object_t *clientObj);
177
178 // Old methods for accessing method vector backward compatiblility only
179 virtual IOExternalMethod *
180 getExternalMethodForIndex( UInt32 index );
181 virtual IOExternalAsyncMethod *
182 getExternalAsyncMethodForIndex( UInt32 index );
183
184 // Methods for accessing method vector.
185 virtual IOExternalMethod *
186 getTargetAndMethodForIndex( IOService ** targetP, UInt32 index );
187 virtual IOExternalAsyncMethod *
188 getAsyncTargetAndMethodForIndex( IOService ** targetP, UInt32 index );
189
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 );
195 };
196
197 #endif /* ! _IOKIT_IOUSERCLIENT_H */
198