]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOATAPICDDrive/IOATAPICDDriveNub.cpp
a70f6aa3d4171e273e9a4df445d4936f1873d57d
[apple/xnu.git] / iokit / Families / IOATAPICDDrive / IOATAPICDDriveNub.cpp
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 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
24 *
25 * IOATAPICDDriveNub.cpp
26 *
27 * This subclass implements a relay to a protocol and device-specific
28 * provider.
29 *
30 * HISTORY
31 * 2-Sep-1999 Joe Liu (jliu) created.
32 */
33
34 #include <IOKit/IOLib.h>
35 #include <IOKit/storage/ata/IOATAPICDDriveNub.h>
36 #include <IOKit/storage/ata/IOATAPICDDrive.h>
37
38 #define super IOCDBlockStorageDevice
39 OSDefineMetaClassAndStructors( IOATAPICDDriveNub, IOCDBlockStorageDevice )
40
41 //---------------------------------------------------------------------------
42 // attach to provider.
43
44 bool IOATAPICDDriveNub::attach(IOService * provider)
45 {
46 if (!super::attach(provider))
47 return false;
48
49 _provider = OSDynamicCast(IOATAPICDDrive, provider);
50 if (_provider == 0) {
51 IOLog("IOATAPICDDriveNub: attach; wrong provider type!\n");
52 return false;
53 }
54
55 return true;
56 }
57
58 //---------------------------------------------------------------------------
59 // detach from provider.
60
61 void IOATAPICDDriveNub::detach(IOService * provider)
62 {
63 if (_provider == provider)
64 _provider = 0;
65
66 super::detach(provider);
67 }
68
69
70 //---------------------------------------------------------------------------
71 // doAsyncReadCD
72
73 IOReturn IOATAPICDDriveNub::doAsyncReadCD(IOMemoryDescriptor * buffer,
74 UInt32 block,
75 UInt32 nblks,
76 CDSectorArea sectorArea,
77 CDSectorType sectorType,
78 IOStorageCompletion completion)
79 {
80 return _provider->doAsyncReadCD(buffer,
81 block,
82 nblks,
83 sectorArea,
84 sectorType,
85 completion);
86 }
87
88 //---------------------------------------------------------------------------
89 // doAsyncReadWrite
90
91 IOReturn IOATAPICDDriveNub::doAsyncReadWrite(IOMemoryDescriptor * buffer,
92 UInt32 block,
93 UInt32 nblks,
94 IOStorageCompletion completion)
95 {
96 if (buffer->getDirection() == kIODirectionOut)
97 return kIOReturnNotWritable;
98
99 return _provider->doAsyncReadWrite(buffer, block, nblks, completion);
100 }
101
102 //---------------------------------------------------------------------------
103 // doSyncReadWrite
104
105 IOReturn
106 IOATAPICDDriveNub::doSyncReadWrite(IOMemoryDescriptor * buffer,
107 UInt32 block,
108 UInt32 nblks)
109 {
110 if (buffer->getDirection() == kIODirectionOut)
111 return kIOReturnNotWritable;
112
113 return _provider->doSyncReadWrite(buffer, block, nblks);
114 }
115
116 //---------------------------------------------------------------------------
117 // doFormatMedia
118
119 IOReturn
120 IOATAPICDDriveNub::doFormatMedia(UInt64 byteCapacity)
121 {
122 return kIOReturnUnsupported;
123 }
124
125 //---------------------------------------------------------------------------
126 // doGetFormatCapacities
127
128 UInt32
129 IOATAPICDDriveNub::doGetFormatCapacities(UInt64 * capacities,
130 UInt32 capacitiesMaxCount) const
131 {
132 return _provider->doGetFormatCapacities(capacities, capacitiesMaxCount);
133 }
134
135 //---------------------------------------------------------------------------
136 // doEjectMedia
137
138 IOReturn IOATAPICDDriveNub::doEjectMedia()
139 {
140 return _provider->doEjectMedia();
141 }
142
143 //---------------------------------------------------------------------------
144 // doLockUnlockMedia
145
146 IOReturn IOATAPICDDriveNub::doLockUnlockMedia(bool doLock)
147 {
148 return _provider->doLockUnlockMedia(doLock);
149 }
150
151 //---------------------------------------------------------------------------
152 // getMediaType
153
154 UInt32 IOATAPICDDriveNub::getMediaType()
155 {
156 return kCDMediaTypeROM;
157 }
158
159 //---------------------------------------------------------------------------
160 // getVendorString
161
162 char * IOATAPICDDriveNub::getVendorString()
163 {
164 return _provider->getVendorString();
165 }
166
167 //---------------------------------------------------------------------------
168 // getProductString
169
170 char * IOATAPICDDriveNub::getProductString()
171 {
172 return _provider->getProductString();
173 }
174
175 //---------------------------------------------------------------------------
176 // getRevisionString
177
178 char * IOATAPICDDriveNub::getRevisionString()
179 {
180 return _provider->getRevisionString();
181 }
182
183 //---------------------------------------------------------------------------
184 // getAdditionalDeviceInfoString
185
186 char * IOATAPICDDriveNub::getAdditionalDeviceInfoString()
187 {
188 return _provider->getAdditionalDeviceInfoString();
189 }
190
191 //---------------------------------------------------------------------------
192 // reportBlockSize
193
194 IOReturn IOATAPICDDriveNub::reportBlockSize(UInt64 * blockSize)
195 {
196 return _provider->reportBlockSize(blockSize);
197 }
198
199 //---------------------------------------------------------------------------
200 // reportEjectability
201
202 IOReturn IOATAPICDDriveNub::reportEjectability(bool * isEjectable)
203 {
204 return _provider->reportEjectability(isEjectable);
205 }
206
207 //---------------------------------------------------------------------------
208 // reportLockability
209
210 IOReturn IOATAPICDDriveNub::reportLockability(bool * isLockable)
211 {
212 return _provider->reportLockability(isLockable);
213 }
214
215 //---------------------------------------------------------------------------
216 // reportMediaState
217
218 IOReturn IOATAPICDDriveNub::reportMediaState(bool * mediaPresent,
219 bool * changed)
220 {
221 return _provider->reportMediaState(mediaPresent, changed);
222 }
223
224 //---------------------------------------------------------------------------
225 // reportPollRequirements
226
227 IOReturn IOATAPICDDriveNub::reportPollRequirements(bool * pollIsRequired,
228 bool * pollIsExpensive)
229 {
230 return _provider->reportPollRequirements(pollIsRequired, pollIsExpensive);
231 }
232
233 //---------------------------------------------------------------------------
234 // reportMaxReadTransfer
235
236 IOReturn IOATAPICDDriveNub::reportMaxReadTransfer(UInt64 blockSize,
237 UInt64 * max)
238 {
239 return _provider->reportMaxReadTransfer(blockSize, max);
240 }
241
242 //---------------------------------------------------------------------------
243 // reportMaxValidBlock
244
245 IOReturn IOATAPICDDriveNub::reportMaxValidBlock(UInt64 * maxBlock)
246 {
247 return _provider->reportMaxValidBlock(maxBlock);
248 }
249
250 //---------------------------------------------------------------------------
251 // reportRemovability
252
253 IOReturn IOATAPICDDriveNub::reportRemovability(bool * isRemovable)
254 {
255 return _provider->reportRemovability(isRemovable);
256 }
257
258 //---------------------------------------------------------------------------
259 // readISRC
260
261 IOReturn IOATAPICDDriveNub::readISRC(UInt8 track, CDISRC isrc)
262 {
263 return _provider->readISRC(track, isrc);
264 }
265
266 //---------------------------------------------------------------------------
267 // readMCN
268
269 IOReturn IOATAPICDDriveNub::readMCN(CDMCN mcn)
270 {
271 return _provider->readMCN(mcn);
272 }
273
274 //---------------------------------------------------------------------------
275 // readTOC
276
277 IOReturn IOATAPICDDriveNub::readTOC(IOMemoryDescriptor * buffer)
278 {
279 return _provider->readTOC(buffer);
280 }
281
282 //---------------------------------------------------------------------------
283 // audioPause
284
285 IOReturn IOATAPICDDriveNub::audioPause(bool pause)
286 {
287 return _provider->audioPause(pause);
288 }
289
290 //---------------------------------------------------------------------------
291 // audioPlay
292
293 IOReturn IOATAPICDDriveNub::audioPlay(CDMSF timeStart, CDMSF timeStop)
294 {
295 return _provider->audioPlay(timeStart, timeStop);
296 }
297
298 //---------------------------------------------------------------------------
299 // audioScan
300
301 IOReturn IOATAPICDDriveNub::audioScan(CDMSF timeStart, bool reverse)
302 {
303 return _provider->audioScan(timeStart, reverse);
304 }
305
306 //---------------------------------------------------------------------------
307 // audioStop
308
309 IOReturn IOATAPICDDriveNub::audioStop()
310 {
311 return _provider->audioStop();
312 }
313
314 //---------------------------------------------------------------------------
315 // getAudioStatus
316
317 IOReturn IOATAPICDDriveNub::getAudioStatus(CDAudioStatus * status)
318 {
319 return _provider->getAudioStatus(status);
320 }
321
322 //---------------------------------------------------------------------------
323 // getAudioVolume
324
325 IOReturn IOATAPICDDriveNub::getAudioVolume(UInt8 * leftVolume,
326 UInt8 * rightVolume)
327 {
328 return _provider->getAudioVolume(leftVolume, rightVolume);
329 }
330
331 //---------------------------------------------------------------------------
332 // setVolume
333
334 IOReturn IOATAPICDDriveNub::setAudioVolume(UInt8 leftVolume, UInt8 rightVolume)
335 {
336 return _provider->setAudioVolume(leftVolume, rightVolume);
337 }
338
339 //---------------------------------------------------------------------------
340 // doSynchronizeCache
341
342 IOReturn IOATAPICDDriveNub::doSynchronizeCache()
343 {
344 return kIOReturnUnsupported;
345 }
346
347 //---------------------------------------------------------------------------
348 // reportMaxWriteTransfer
349
350 IOReturn IOATAPICDDriveNub::reportMaxWriteTransfer(UInt64 blockSize,
351 UInt64 * max)
352 {
353 return _provider->reportMaxWriteTransfer(blockSize, max);
354 }
355
356 //---------------------------------------------------------------------------
357 // reportMaxWriteTransfer
358
359 IOReturn IOATAPICDDriveNub::reportWriteProtection(bool * isWriteProtected)
360 {
361 return _provider->reportWriteProtection(isWriteProtected);
362 }