]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOUserClient.h
xnu-792.6.22.tar.gz
[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 * 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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 /*
24 * Changes to this API are expected.
25 */
26
27 #ifndef _IOKIT_IOUSERCLIENT_H
28 #define _IOKIT_IOUSERCLIENT_H
29
30 #include <IOKit/IOTypes.h>
31 #include <IOKit/IOService.h>
32 #include <IOKit/OSMessageNotification.h>
33
34
35 enum {
36 kIOUCTypeMask = 0x0000000f,
37 kIOUCScalarIScalarO = 0,
38 kIOUCScalarIStructO = 2,
39 kIOUCStructIStructO = 3,
40 kIOUCScalarIStructI = 4
41 };
42
43 typedef IOReturn (IOService::*IOMethod)(void * p1, void * p2, void * p3,
44 void * p4, void * p5, void * p6 );
45
46 typedef IOReturn (IOService::*IOAsyncMethod)(OSAsyncReference asyncRef,
47 void * p1, void * p2, void * p3,
48 void * p4, void * p5, void * p6 );
49
50 typedef IOReturn (IOService::*IOTrap)(void * p1, void * p2, void * p3,
51 void * p4, void * p5, void * p6 );
52
53 struct IOExternalMethod {
54 IOService * object;
55 IOMethod func;
56 IOOptionBits flags;
57 IOByteCount count0;
58 IOByteCount count1;
59 };
60
61 struct IOExternalAsyncMethod {
62 IOService * object;
63 IOAsyncMethod func;
64 IOOptionBits flags;
65 IOByteCount count0;
66 IOByteCount count1;
67 };
68
69 struct IOExternalTrap {
70 IOService * object;
71 IOTrap func;
72 };
73
74 enum {
75 kIOUserNotifyMaxMessageSize = 64
76 };
77
78 // keys for clientHasPrivilege
79 #define kIOClientPrivilegeAdministrator "root"
80 #define kIOClientPrivilegeLocalUser "local"
81
82 /*!
83 @class IOUserClient
84 @abstract Provides a basis for communication between client applications and I/O Kit objects.
85 */
86
87
88 class IOUserClient : public IOService
89 {
90 OSDeclareAbstractStructors(IOUserClient)
91
92 protected:
93 /*! @struct ExpansionData
94 @discussion This structure will be used to expand the capablilties of this class in the future.
95 */
96 struct ExpansionData { };
97
98 /*! @var reserved
99 Reserved for future use. (Internal use only)
100 */
101 ExpansionData * reserved;
102
103 public:
104 OSSet * mappings;
105 void * __reserved[8];
106
107 private:
108 OSMetaClassDeclareReservedUnused(IOUserClient, 0);
109 OSMetaClassDeclareReservedUnused(IOUserClient, 1);
110 OSMetaClassDeclareReservedUnused(IOUserClient, 2);
111 OSMetaClassDeclareReservedUnused(IOUserClient, 3);
112 OSMetaClassDeclareReservedUnused(IOUserClient, 4);
113 OSMetaClassDeclareReservedUnused(IOUserClient, 5);
114 OSMetaClassDeclareReservedUnused(IOUserClient, 6);
115 OSMetaClassDeclareReservedUnused(IOUserClient, 7);
116 OSMetaClassDeclareReservedUnused(IOUserClient, 8);
117 OSMetaClassDeclareReservedUnused(IOUserClient, 9);
118 OSMetaClassDeclareReservedUnused(IOUserClient, 10);
119 OSMetaClassDeclareReservedUnused(IOUserClient, 11);
120 OSMetaClassDeclareReservedUnused(IOUserClient, 12);
121 OSMetaClassDeclareReservedUnused(IOUserClient, 13);
122 OSMetaClassDeclareReservedUnused(IOUserClient, 14);
123 OSMetaClassDeclareReservedUnused(IOUserClient, 15);
124
125 protected:
126 static IOReturn sendAsyncResult(OSAsyncReference reference,
127 IOReturn result, void *args[], UInt32 numArgs);
128 static void setAsyncReference(OSAsyncReference asyncRef,
129 mach_port_t wakePort,
130 void *callback, void *refcon);
131 public:
132
133 static void initialize( void );
134
135 static void destroyUserReferences( OSObject * obj );
136
137 static IOReturn clientHasPrivilege( void * securityToken,
138 const char * privilegeName );
139
140 // Currently ignores the all args, just passes up to IOService::init()
141 virtual bool initWithTask(
142 task_t owningTask, void * securityToken, UInt32 type,
143 OSDictionary * properties);
144
145 virtual bool initWithTask(
146 task_t owningTask, void * securityToken, UInt32 type);
147
148 virtual void free();
149
150 virtual IOReturn clientClose( void );
151 virtual IOReturn clientDied( void );
152
153 virtual IOService * getService( void );
154
155 virtual IOReturn registerNotificationPort(
156 mach_port_t port, UInt32 type, UInt32 refCon );
157
158 virtual IOReturn getNotificationSemaphore( UInt32 notification_type,
159 semaphore_t * semaphore );
160
161 virtual IOReturn connectClient( IOUserClient * client );
162
163 // memory will be released by user client when last map is destroyed
164 virtual IOReturn clientMemoryForType( UInt32 type,
165 IOOptionBits * options,
166 IOMemoryDescriptor ** memory );
167
168 virtual IOMemoryMap * mapClientMemory( IOOptionBits type,
169 task_t task,
170 IOOptionBits mapFlags = kIOMapAnywhere,
171 IOVirtualAddress atAddress = 0 );
172
173 /*!
174 @function removeMappingForDescriptor
175 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.
176 @param memory The memory descriptor instance previously returned by the implementation of clientMemoryForType().
177 @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.
178 */
179 IOMemoryMap * removeMappingForDescriptor(IOMemoryDescriptor * memory);
180
181 /*!
182 @function exportObjectToClient
183 Make an arbitrary OSObject available to the client task.
184 @param task The task.
185 @param obj The object we want to export to the client.
186 @param clientObj Returned value is the client's port name.
187 */
188 virtual IOReturn exportObjectToClient(task_t task,
189 OSObject *obj, io_object_t *clientObj);
190
191 // Old methods for accessing method vector backward compatiblility only
192 virtual IOExternalMethod *
193 getExternalMethodForIndex( UInt32 index );
194 virtual IOExternalAsyncMethod *
195 getExternalAsyncMethodForIndex( UInt32 index );
196
197 // Methods for accessing method vector.
198 virtual IOExternalMethod *
199 getTargetAndMethodForIndex( IOService ** targetP, UInt32 index );
200 virtual IOExternalAsyncMethod *
201 getAsyncTargetAndMethodForIndex( IOService ** targetP, UInt32 index );
202
203 // Methods for accessing trap vector - old and new style
204 virtual IOExternalTrap *
205 getExternalTrapForIndex( UInt32 index );
206 virtual IOExternalTrap *
207 getTargetAndTrapForIndex( IOService **targetP, UInt32 index );
208 };
209
210 #endif /* ! _IOKIT_IOUSERCLIENT_H */
211