]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOADBBus/IOADBControllerUserClient.cpp
2fbaac9dd6bbf7610d6fae2eea72db7f82560598
[apple/xnu.git] / iokit / Families / IOADBBus / IOADBControllerUserClient.cpp
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 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
27 *
28 */
29
30 #include <IOKit/assert.h>
31 #include <IOKit/IOLib.h>
32 #include <IOKit/IOBufferMemoryDescriptor.h>
33 #include "IOADBControllerUserClient.h"
34
35 #define super IOUserClient
36
37 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38
39 OSDefineMetaClassAndStructors(IOADBControllerUserClient, IOUserClient)
40
41 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
42
43 IOADBControllerUserClient *IOADBControllerUserClient::withTask(task_t owningTask)
44 {
45 IOADBControllerUserClient * me;
46
47 me = new IOADBControllerUserClient;
48 if ( me ) {
49 if (! me->init() ) {
50 me->release();
51 return NULL;
52 }
53 me->fTask = owningTask;
54 }
55 return me;
56 }
57
58 bool IOADBControllerUserClient::start( IOService * provider )
59 {
60 assert(OSDynamicCast(IOADBController, provider));
61 if(!super::start(provider))
62 return false;
63 fOwner = (IOADBController *)provider;
64
65 // Got the owner, so initialize the call structures
66 fMethods[kADBReadDevice].object = provider;
67 fMethods[kADBReadDevice].func = (IOMethod)&IOADBController::readDeviceForUser;
68 fMethods[kADBReadDevice].count0 = 2;
69 fMethods[kADBReadDevice].count1 = 8;
70 fMethods[kADBReadDevice].flags = kIOUCScalarIStructO;
71
72 fMethods[kADBWriteDevice].object = provider;
73 fMethods[kADBWriteDevice].func = (IOMethod)&IOADBController::writeDeviceForUser;
74 fMethods[kADBWriteDevice].count0 = 4;
75 fMethods[kADBWriteDevice].count1 = 0;
76 fMethods[kADBWriteDevice].flags = kIOUCScalarIScalarO;
77
78 fMethods[kADBClaimDevice].object = provider;
79 fMethods[kADBClaimDevice].func = (IOMethod)&IOADBController::claimDevice;
80 fMethods[kADBClaimDevice].count0 = 1;
81 fMethods[kADBClaimDevice].count1 = 0;
82 fMethods[kADBClaimDevice].flags = kIOUCScalarIScalarO;
83
84 fMethods[kADBReleaseDevice].object = provider;
85 fMethods[kADBReleaseDevice].func = (IOMethod)&IOADBController::releaseDevice;
86 fMethods[kADBReleaseDevice].count0 = 1;
87 fMethods[kADBReleaseDevice].count1 = 0;
88 fMethods[kADBReleaseDevice].flags = kIOUCScalarIScalarO;
89
90 return true;
91 }
92
93 IOReturn IOADBControllerUserClient::clientMemoryForType( UInt32 type,
94 UInt32 * flags, IOLogicalAddress * address, IOByteCount * size )
95 {
96 return kIOReturnUnsupported;
97 }
98
99 IOReturn IOADBControllerUserClient::clientClose( void )
100 {
101 detach( fOwner);
102
103 return kIOReturnSuccess;
104 }
105
106 IOReturn IOADBControllerUserClient::clientDied( void )
107 {
108 return( clientClose());
109 }
110
111 IOReturn IOADBControllerUserClient::connectClient( IOUserClient * client )
112 {
113 return kIOReturnSuccess;
114 }
115
116 IOExternalMethod * IOADBControllerUserClient::getExternalMethodForIndex( UInt32 index )
117 {
118 if(index >= kNumADBMethods)
119 return NULL;
120 else
121 return &fMethods[index];
122 }
123
124 IOReturn IOADBControllerUserClient::registerNotificationPort ( mach_port_t port, UInt32 type )
125 {
126 return kIOReturnUnsupported;
127 }
128