]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOADBBus/IOADBDevice.cpp
6a5855e1550fdb57c8f1d97ae72c45fbb124f112
[apple/xnu.git] / iokit / Families / IOADBBus / IOADBDevice.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 * 18 June 1998 sdouglas Start IOKit version.
27 * 17 Nov 1998 suurballe Port objc to c++
28 */
29
30 #include <IOKit/adb/IOADBDevice.h>
31
32 #define super IOService
33 OSDefineMetaClassAndStructors(IOADBDevice,IOService)
34
35 // **********************************************************************************
36 // init
37 //
38 // **********************************************************************************
39 bool IOADBDevice::init ( OSDictionary * regEntry, ADBDeviceControl * us )
40 {
41 if( !super::init(regEntry))
42 return false;
43
44 fBusRef = us;
45 return true;
46 }
47
48
49 // **********************************************************************************
50 // attach
51 //
52 // **********************************************************************************
53 bool IOADBDevice::attach ( IOADBBus * controller )
54 {
55 if( !super::attach(controller))
56 return false;
57
58 bus = controller;
59 return true;
60 }
61
62 // **********************************************************************************
63 // matchPropertyTable
64 //
65 // **********************************************************************************
66
67 bool IOADBDevice::matchPropertyTable( OSDictionary * table )
68 {
69 return( bus->matchNubWithPropertyTable( this, table ));
70 }
71
72 // **********************************************************************************
73 // seizeForClient
74 //
75 // **********************************************************************************
76 bool IOADBDevice::seizeForClient ( IOService * client, ADB_callback_func handler )
77 {
78 bus->setOwner(fBusRef,client,handler);
79
80 return true;
81 }
82
83
84 // **********************************************************************************
85 // releaseFromClient
86 //
87 // **********************************************************************************
88 void IOADBDevice::releaseFromClient ( IORegistryEntry * )
89 {
90 kprintf("IOADBDevice::releaseFromClient\n");
91 bus->clearOwner(fBusRef);
92 }
93
94
95 // **********************************************************************************
96 // flush
97 //
98 // **********************************************************************************
99 IOReturn IOADBDevice::flush ( void )
100 {
101 if ( isInactive() ) {
102 return kIOReturnNotOpen;
103 }
104 return( bus->flush(fBusRef) );
105 }
106
107
108 // **********************************************************************************
109 // readRegister
110 //
111 // **********************************************************************************
112 IOReturn IOADBDevice::readRegister ( IOADBRegister adbRegister, UInt8 * data,
113 IOByteCount * length )
114 {
115 if ( isInactive() ) {
116 return kIOReturnNotOpen;
117 }
118 return( bus->readRegister(fBusRef,adbRegister,data,length) );
119 }
120
121
122 // **********************************************************************************
123 // writeRegister
124 //
125 // **********************************************************************************
126 IOReturn IOADBDevice::writeRegister ( IOADBRegister adbRegister, UInt8 * data,
127 IOByteCount * length )
128 {
129 if ( isInactive() ) {
130 return kIOReturnNotOpen;
131 }
132 return( bus->writeRegister(fBusRef,adbRegister,data,length) );
133 }
134
135
136 // **********************************************************************************
137 // address
138 //
139 // **********************************************************************************
140 IOADBAddress IOADBDevice::address ( void )
141 {
142 return( bus->address(fBusRef) );
143 }
144
145
146 // **********************************************************************************
147 // defaultAddress
148 //
149 // **********************************************************************************
150 IOADBAddress IOADBDevice::defaultAddress ( void )
151 {
152 return( bus->defaultAddress(fBusRef) );
153 }
154
155
156 // **********************************************************************************
157 // handlerID
158 //
159 // **********************************************************************************
160 UInt8 IOADBDevice::handlerID ( void )
161 {
162 return( bus->handlerID(fBusRef) );
163 }
164
165
166 // **********************************************************************************
167 // defaultHandlerID
168 //
169 // **********************************************************************************
170 UInt8 IOADBDevice::defaultHandlerID ( void )
171 {
172 return( bus->defaultHandlerID(fBusRef) );
173 }
174
175
176 // **********************************************************************************
177 // setHandlerID
178 //
179 // **********************************************************************************
180 IOReturn IOADBDevice::setHandlerID ( UInt8 handlerID )
181 {
182 return( bus->setHandlerID(fBusRef,handlerID) );
183 }
184
185
186 // **********************************************************************************
187 // busRef
188 //
189 // **********************************************************************************
190 void * IOADBDevice::busRef ( void )
191 {
192 return fBusRef;
193 }