]> git.saurik.com Git - apple/xnu.git/blame - iokit/Families/IOADBBus/IOADBControllerUserClient.cpp
xnu-344.49.tar.gz
[apple/xnu.git] / iokit / Families / IOADBBus / IOADBControllerUserClient.cpp
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
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
39OSDefineMetaClassAndStructors(IOADBControllerUserClient, IOUserClient)
40
41/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
42
43IOADBControllerUserClient *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
58bool 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
93IOReturn IOADBControllerUserClient::clientMemoryForType( UInt32 type,
94 UInt32 * flags, IOLogicalAddress * address, IOByteCount * size )
95{
96 return kIOReturnUnsupported;
97}
98
99IOReturn IOADBControllerUserClient::clientClose( void )
100{
101 detach( fOwner);
102
103 return kIOReturnSuccess;
104}
105
106IOReturn IOADBControllerUserClient::clientDied( void )
107{
108 return( clientClose());
109}
110
111IOReturn IOADBControllerUserClient::connectClient( IOUserClient * client )
112{
113 return kIOReturnSuccess;
114}
115
116IOExternalMethod * IOADBControllerUserClient::getExternalMethodForIndex( UInt32 index )
117{
118 if(index >= kNumADBMethods)
119 return NULL;
120 else
121 return &fMethods[index];
122}
123
124IOReturn IOADBControllerUserClient::registerNotificationPort ( mach_port_t port, UInt32 type )
125{
126 return kIOReturnUnsupported;
127}
128