2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
25 * This class implements SCSI DVD functionality.
27 * Subclasses may modify the operations to handle device-specific variations.
30 #ifndef _IOSCSIDVDDRIVE_H
31 #define _IOSCSIDVDDRIVE_H
33 #include <IOKit/IOTypes.h>
34 #include <IOKit/scsi/IOSCSIDeviceInterface.h>
35 #include <IOKit/storage/scsi/IOSCSICDDrive.h>
36 #include <IOKit/storage/IODVDTypes.h>
41 UInt8 startFeature_hi
;
42 UInt8 startFeature_lo
;
75 kIOSCSICommandGetConfiguration
= 0x46,
76 kIOSCSICommandSendKey
= 0xa3,
77 kIOSCSICommandReportKey
= 0xa4
80 const int kMaxConfigLength
= 1024;
81 class IOMemoryDescriptor
;
83 /*------------------------------------------------*/
84 class IOSCSIDVDDrive
: public IOSCSICDDrive
{
86 OSDeclareDefaultStructors(IOSCSIDVDDrive
)
90 /* Overrides from IOService: */
92 virtual bool init(OSDictionary
* properties
);
94 /* Overrides from IOBasicSCSI: */
96 virtual bool deviceTypeMatches(UInt8 inqBuf
[],UInt32 inqLen
,SInt32
*score
);
99 * @function reportWriteProtection
101 * Report whether the media is write-protected or not.
103 * This override allows us to return the cached write-protection status
104 * without interrogating the drive.
106 virtual IOReturn
reportWriteProtection(bool *isWriteProtected
);
108 /* End of IOBasicSCSI overrides */
110 /* IOSCSIHDDrive overrides: */
113 * @function doAsyncReadWrite
115 * Start an asynchronous read or write operation.
117 * This override allows us to accept writes, which our superclass, IOSCSICDDrive,
118 * unconditionally rejects.
120 virtual IOReturn
doAsyncReadWrite(IOMemoryDescriptor
*buffer
,
121 UInt32 block
,UInt32 nblks
,
122 IOStorageCompletion completion
);
125 * @function doSyncReadWrite
127 * Perform a synchronous read or write operation.
129 * See IOBlockStorageDevice for details.
131 virtual IOReturn
doSyncReadWrite(IOMemoryDescriptor
*buffer
,UInt32 block
,UInt32 nblks
);
134 * @function doFormatMedia
136 * Attempt to format the media.
138 * This override allows us to handle formatting for DVD-RAM.
140 virtual IOReturn
doFormatMedia(UInt64 byteCapacity
);
143 * @function doGetFormatCapacities
145 * Report available formatting capacities for the device/media.
147 * This override allows us to handle formatting for DVD.
149 virtual UInt32
doGetFormatCapacities(UInt64
* capacities
,
150 UInt32 capacitiesMaxCount
) const;
153 * @function doSynchronizeCache
155 * Force data blocks in the drive's buffer to be flushed to the media.
157 * This override allows us to issue a standard Synchronize-Cache command for DVD-RAM.
159 virtual IOReturn
doSynchronizeCache(void);
161 virtual const char * getDeviceTypeName(void);
164 * @function getGetConfigurationPowerState
166 * Return the required device power level to execute a Get Configuration command.
168 * The default implementation of this method returns kElectronicsOn.
170 * The return value must be a valid power state value.
172 virtual UInt32
getGetConfigurationPowerState(void); /* default = kElectronicsOn */
175 * @function getReportKeyPowerState
177 * Return the required device power level to execute a Report Key command.
179 * The default implementation of this method returns kElectronicsOn.
181 * The return value must be a valid power state value.
183 virtual UInt32
getReportKeyPowerState(void); /* default = kElectronicsOn */
186 * @function getSendKeyPowerState
188 * Return the required device power level to execute a Send Key command.
190 * The default implementation of this method returns kElectronicsOn.
192 * The return value must be a valid power state value.
194 virtual UInt32
getSendKeyPowerState(void); /* default = kElectronicsOn */
197 * @function instantiateNub
199 * Instantiate the desired nub.
201 * This override allows us to instantiate an IOSCSIDVDDriveNub.
203 virtual IOService
* instantiateNub(void);
206 * @function reportMediaState
208 * Report the device's media state.
210 * This override allows us to determine the media type after something is inserted.
212 virtual IOReturn
reportMediaState(bool *mediaPresent
,bool *changed
);
214 /* end of IOSCSIHDDrive overrides */
218 virtual UInt32
getMediaType(void);
219 virtual IOReturn
reportKey(IOMemoryDescriptor
*buffer
,const DVDKeyClass DVDKeyClass
,
220 const UInt32 lba
,const UInt8 agid
,const DVDKeyFormat keyFormat
);
221 virtual IOReturn
sendKey(IOMemoryDescriptor
*buffer
,const DVDKeyClass DVDKeyClass
,
222 const UInt8 agid
,const DVDKeyFormat keyFormat
);
226 virtual void checkConfig(UInt8
*buf
,UInt32 actual
);
227 virtual IOReturn
determineMediaType(void);
228 virtual IOReturn
getConfiguration(UInt8
*buffer
,UInt32 length
,UInt32
*actualLength
,bool current
);
230 UInt8 _configBuf
[kMaxConfigLength
];
236 bool _isWriteProtected
;