]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
de355530 A |
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. | |
1c79356b | 11 | * |
de355530 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
de355530 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * 18 June 1998 sdouglas Start IOKit version. | |
24 | * 17 Nov 1998 suurballe Port objc to c++ | |
25 | */ | |
26 | ||
27 | #include <IOKit/adb/IOADBDevice.h> | |
28 | ||
29 | #define super IOService | |
30 | OSDefineMetaClassAndStructors(IOADBDevice,IOService) | |
31 | ||
32 | // ********************************************************************************** | |
33 | // init | |
34 | // | |
35 | // ********************************************************************************** | |
36 | bool IOADBDevice::init ( OSDictionary * regEntry, ADBDeviceControl * us ) | |
37 | { | |
38 | if( !super::init(regEntry)) | |
39 | return false; | |
40 | ||
41 | fBusRef = us; | |
42 | return true; | |
43 | } | |
44 | ||
45 | ||
46 | // ********************************************************************************** | |
47 | // attach | |
48 | // | |
49 | // ********************************************************************************** | |
50 | bool IOADBDevice::attach ( IOADBBus * controller ) | |
51 | { | |
52 | if( !super::attach(controller)) | |
53 | return false; | |
54 | ||
55 | bus = controller; | |
56 | return true; | |
57 | } | |
58 | ||
59 | // ********************************************************************************** | |
60 | // matchPropertyTable | |
61 | // | |
62 | // ********************************************************************************** | |
63 | ||
64 | bool IOADBDevice::matchPropertyTable( OSDictionary * table ) | |
65 | { | |
66 | return( bus->matchNubWithPropertyTable( this, table )); | |
67 | } | |
68 | ||
69 | // ********************************************************************************** | |
70 | // seizeForClient | |
71 | // | |
72 | // ********************************************************************************** | |
73 | bool IOADBDevice::seizeForClient ( IOService * client, ADB_callback_func handler ) | |
74 | { | |
75 | bus->setOwner(fBusRef,client,handler); | |
76 | ||
77 | return true; | |
78 | } | |
79 | ||
80 | ||
81 | // ********************************************************************************** | |
82 | // releaseFromClient | |
83 | // | |
84 | // ********************************************************************************** | |
85 | void IOADBDevice::releaseFromClient ( IORegistryEntry * ) | |
86 | { | |
87 | kprintf("IOADBDevice::releaseFromClient\n"); | |
88 | bus->clearOwner(fBusRef); | |
89 | } | |
90 | ||
91 | ||
92 | // ********************************************************************************** | |
93 | // flush | |
94 | // | |
95 | // ********************************************************************************** | |
96 | IOReturn IOADBDevice::flush ( void ) | |
97 | { | |
0b4e3aa0 A |
98 | if ( isInactive() ) { |
99 | return kIOReturnNotOpen; | |
100 | } | |
1c79356b A |
101 | return( bus->flush(fBusRef) ); |
102 | } | |
103 | ||
104 | ||
105 | // ********************************************************************************** | |
106 | // readRegister | |
107 | // | |
108 | // ********************************************************************************** | |
109 | IOReturn IOADBDevice::readRegister ( IOADBRegister adbRegister, UInt8 * data, | |
110 | IOByteCount * length ) | |
111 | { | |
0b4e3aa0 A |
112 | if ( isInactive() ) { |
113 | return kIOReturnNotOpen; | |
114 | } | |
1c79356b A |
115 | return( bus->readRegister(fBusRef,adbRegister,data,length) ); |
116 | } | |
117 | ||
118 | ||
119 | // ********************************************************************************** | |
120 | // writeRegister | |
121 | // | |
122 | // ********************************************************************************** | |
123 | IOReturn IOADBDevice::writeRegister ( IOADBRegister adbRegister, UInt8 * data, | |
124 | IOByteCount * length ) | |
125 | { | |
0b4e3aa0 A |
126 | if ( isInactive() ) { |
127 | return kIOReturnNotOpen; | |
128 | } | |
1c79356b A |
129 | return( bus->writeRegister(fBusRef,adbRegister,data,length) ); |
130 | } | |
131 | ||
132 | ||
133 | // ********************************************************************************** | |
134 | // address | |
135 | // | |
136 | // ********************************************************************************** | |
137 | IOADBAddress IOADBDevice::address ( void ) | |
138 | { | |
139 | return( bus->address(fBusRef) ); | |
140 | } | |
141 | ||
142 | ||
143 | // ********************************************************************************** | |
144 | // defaultAddress | |
145 | // | |
146 | // ********************************************************************************** | |
147 | IOADBAddress IOADBDevice::defaultAddress ( void ) | |
148 | { | |
149 | return( bus->defaultAddress(fBusRef) ); | |
150 | } | |
151 | ||
152 | ||
153 | // ********************************************************************************** | |
154 | // handlerID | |
155 | // | |
156 | // ********************************************************************************** | |
157 | UInt8 IOADBDevice::handlerID ( void ) | |
158 | { | |
159 | return( bus->handlerID(fBusRef) ); | |
160 | } | |
161 | ||
162 | ||
163 | // ********************************************************************************** | |
164 | // defaultHandlerID | |
165 | // | |
166 | // ********************************************************************************** | |
167 | UInt8 IOADBDevice::defaultHandlerID ( void ) | |
168 | { | |
169 | return( bus->defaultHandlerID(fBusRef) ); | |
170 | } | |
171 | ||
172 | ||
173 | // ********************************************************************************** | |
174 | // setHandlerID | |
175 | // | |
176 | // ********************************************************************************** | |
177 | IOReturn IOADBDevice::setHandlerID ( UInt8 handlerID ) | |
178 | { | |
179 | return( bus->setHandlerID(fBusRef,handlerID) ); | |
180 | } | |
181 | ||
182 | ||
183 | // ********************************************************************************** | |
184 | // busRef | |
185 | // | |
186 | // ********************************************************************************** | |
187 | void * IOADBDevice::busRef ( void ) | |
188 | { | |
189 | return fBusRef; | |
190 | } |