]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/storage/scsi/IOSCSIDVDDrive.h
xnu-124.1.tar.gz
[apple/xnu.git] / iokit / IOKit / storage / scsi / IOSCSIDVDDrive.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 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 * IOSCSIDVDDrive.h
24 *
25 * This class implements SCSI DVD functionality.
26 *
27 * Subclasses may modify the operations to handle device-specific variations.
28 */
29
30#ifndef _IOSCSIDVDDRIVE_H
31#define _IOSCSIDVDDRIVE_H
32
33#include <IOKit/IOTypes.h>
34#include <IOKit/scsi/IOSCSIDeviceInterface.h>
35#include <IOKit/storage/scsi/IOSCSICDDrive.h>
36#include <IOKit/storage/IODVDTypes.h>
37
38struct IOGCCdb {
39 UInt8 opcode;
40 UInt8 lunRT;
41 UInt8 startFeature_hi;
42 UInt8 startFeature_lo;
43 UInt8 reserved[3];
44 UInt8 len_hi;
45 UInt8 len_lo;
46 UInt8 ctlbyte;
47};
48
49struct IORKCdb {
50 UInt8 opcode;
51 UInt8 lba_0; //msb
52 UInt8 lba_1;
53 UInt8 lba_2;
54 UInt8 lba_3;
55 UInt8 reserved;
56 UInt8 keyClass;
57 UInt8 len_hi;
58 UInt8 len_lo;
59 UInt8 agidKeyFormat;
60 UInt8 ctlbyte;
61};
62
63struct IOSKCdb {
64 UInt8 opcode;
65 UInt8 lun;
66 UInt8 reserved[5];
67 UInt8 keyClass;
68 UInt8 len_hi;
69 UInt8 len_lo;
70 UInt8 agidKeyFormat;
71 UInt8 ctlbyte;
72};
73
74enum {
75 kIOSCSICommandGetConfiguration = 0x46,
76 kIOSCSICommandSendKey = 0xa3,
77 kIOSCSICommandReportKey = 0xa4
78};
79
80const int kMaxConfigLength = 1024;
81class IOMemoryDescriptor;
82
83/*------------------------------------------------*/
84class IOSCSIDVDDrive : public IOSCSICDDrive {
85
86 OSDeclareDefaultStructors(IOSCSIDVDDrive)
87
88public:
89
90 /* Overrides from IOService: */
91
92 virtual bool init(OSDictionary * properties);
93
94 /* Overrides from IOBasicSCSI: */
95
96 virtual bool deviceTypeMatches(UInt8 inqBuf[],UInt32 inqLen,SInt32 *score);
97
98 /*!
99 * @function reportWriteProtection
100 * @abstract
101 * Report whether the media is write-protected or not.
102 * @discussion
103 * This override allows us to return the cached write-protection status
104 * without interrogating the drive.
105 */
106 virtual IOReturn reportWriteProtection(bool *isWriteProtected);
107
108 /* End of IOBasicSCSI overrides */
109
110 /* IOSCSIHDDrive overrides: */
111
112 /*!
113 * @function doAsyncReadWrite
114 * @abstract
115 * Start an asynchronous read or write operation.
116 * @discussion
117 * This override allows us to accept writes, which our superclass, IOSCSICDDrive,
118 * unconditionally rejects.
119 */
120 virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer,
121 UInt32 block,UInt32 nblks,
122 IOStorageCompletion completion);
123
124 /*!
125 * @function doSyncReadWrite
126 * @abstract
127 * Perform a synchronous read or write operation.
128 * @discussion
129 * See IOBlockStorageDevice for details.
130 */
131 virtual IOReturn doSyncReadWrite(IOMemoryDescriptor *buffer,UInt32 block,UInt32 nblks);
132
133 /*!
134 * @function doFormatMedia
135 * @abstract
136 * Attempt to format the media.
137 * @discussion
138 * This override allows us to handle formatting for DVD-RAM.
139 */
140 virtual IOReturn doFormatMedia(UInt64 byteCapacity);
141
142 /*!
143 * @function doGetFormatCapacities
144 * @abstract
145 * Report available formatting capacities for the device/media.
146 * @discussion
147 * This override allows us to handle formatting for DVD.
148 */
149 virtual UInt32 doGetFormatCapacities(UInt64 * capacities,
150 UInt32 capacitiesMaxCount) const;
151
152 /*!
153 * @function doSynchronizeCache
154 * @abstract
155 * Force data blocks in the drive's buffer to be flushed to the media.
156 * @discussion
157 * This override allows us to issue a standard Synchronize-Cache command for DVD-RAM.
158 */
159 virtual IOReturn doSynchronizeCache(void);
160
161 virtual const char * getDeviceTypeName(void);
162
163 /*!
164 * @function getGetConfigurationPowerState
165 * @abstract
166 * Return the required device power level to execute a Get Configuration command.
167 * @discussion
168 * The default implementation of this method returns kElectronicsOn.
169 * @result
170 * The return value must be a valid power state value.
171 */
172 virtual UInt32 getGetConfigurationPowerState(void); /* default = kElectronicsOn */
173
174 /*!
175 * @function getReportKeyPowerState
176 * @abstract
177 * Return the required device power level to execute a Report Key command.
178 * @discussion
179 * The default implementation of this method returns kElectronicsOn.
180 * @result
181 * The return value must be a valid power state value.
182 */
183 virtual UInt32 getReportKeyPowerState(void); /* default = kElectronicsOn */
184
185 /*!
186 * @function getSendKeyPowerState
187 * @abstract
188 * Return the required device power level to execute a Send Key command.
189 * @discussion
190 * The default implementation of this method returns kElectronicsOn.
191 * @result
192 * The return value must be a valid power state value.
193 */
194 virtual UInt32 getSendKeyPowerState(void); /* default = kElectronicsOn */
195
196 /*!
197 * @function instantiateNub
198 * @abstract
199 * Instantiate the desired nub.
200 * @discussion
201 * This override allows us to instantiate an IOSCSIDVDDriveNub.
202 */
203 virtual IOService * instantiateNub(void);
204
205 /*!
206 * @function reportMediaState
207 * @abstract
208 * Report the device's media state.
209 * @discussion
210 * This override allows us to determine the media type after something is inserted.
211 */
212 virtual IOReturn reportMediaState(bool *mediaPresent,bool *changed);
213
214 /* end of IOSCSIHDDrive overrides */
215
216 /* DVD APIs: */
217
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);
223
224protected:
225
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);
229
230 UInt8 _configBuf[kMaxConfigLength];
231
232 UInt32 _configSize;
233 bool _isDVDDrive;
234 bool _canDoCSS;
235 UInt32 _mediaType;
236 bool _isWriteProtected;
237
238};
239#endif