]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/storage/ata/IOATAPIDVDDrive.h
xnu-124.13.tar.gz
[apple/xnu.git] / iokit / IOKit / storage / ata / IOATAPIDVDDrive.h
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 #ifndef _IOATAPIDVDDRIVE_H
24 #define _IOATAPIDVDDRIVE_H
25
26 #include <IOKit/IOTypes.h>
27 #include <IOKit/storage/ata/IOATAPICDDrive.h>
28 #include <IOKit/storage/IODVDTypes.h>
29
30 enum {
31 kIOATAPIFeatureProfileList = 0x0000,
32 kIOATAPIFeatureCore = 0x0001,
33 kIOATAPIFeatureMorphing = 0x0002,
34 kIOATAPIFeatureRemovableMedium = 0x0003,
35 kIOATAPIFeatureRandomReadable = 0x0010,
36 kIOATAPIFeatureMultiRead = 0x001d,
37 kIOATAPIFeatureCDRead = 0x001e,
38 kIOATAPIFeatureDVDRead = 0x001f,
39 kIOATAPIFeatureRandomWrite = 0x0020,
40 kIOATAPIFeatureIncrStreamWrite = 0x0021,
41 kIOATAPIFeatureSectorErasable = 0x0022,
42 kIOATAPIFeatureFormattable = 0x0023,
43 kIOATAPIFeatureDefectManagement = 0x0024,
44 kIOATAPIFeatureWriteOnce = 0x0025,
45 kIOATAPIFeatureRestrictedOverwrite = 0x0026,
46 kIOATAPIFeatureDVDRWRestrictedOverwrite = 0x002c,
47 kIOATAPIFeatureCDTrackAtOnce = 0x002d,
48 kIOATAPIFeatureCDMastering = 0x002e,
49 kIOATAPIFeatureDVDR_RWWrite = 0x002f,
50 kIOATAPIFeaturePowerManagement = 0x0100,
51 kIOATAPIFeatureSMART = 0x0101,
52 kIOATAPIFeatureEmbeddedChanger = 0x0102,
53 kIOATAPIFeatureCDAudioAnalogPlay = 0x0103,
54 kIOATAPIFeatureMicrocodeUpgrade = 0x0104,
55 kIOATAPIFeatureTimeout = 0x0105,
56 kIOATAPIFeatureDVDCSS = 0x0106,
57 kIOATAPIFeatureRealTimeStreaming = 0x0107,
58 kIOATAPIFeatureLUNSerialNumber = 0x0108,
59 kIOATAPIFeatureDiskControlBlocks = 0x010a,
60 kIOATAPIFeatureDVDCPRM = 0x010b
61 };
62
63 // DVD specific command codes.
64
65 enum {
66 kIOATAPICommandGetConfiguration = 0x46,
67 kIOATAPICommandSendKey = 0xa3,
68 kIOATAPICommandReportKey = 0xa4,
69 kIOATAPICommandReadDVDStructure = 0xad
70 };
71
72 // Format code definitions for READ DVD STRUCTURE command.
73
74 enum {
75 kIODVDReadStructurePhysical = 0x00,
76 kIODVDReadStructureCopyright = 0x01,
77 kIODVDReadStructureWriteProtection = 0xC0
78 };
79
80 #define IODVDGetDataLength16(ptr) OSReadBigInt16((void *) ptr, 0)
81 #define IODVDGetDataLength32(ptr) OSReadBigInt32((void *) ptr, 0)
82
83 #if defined(__BIG_ENDIAN__)
84
85 // Big Endian DVD structure definitions.
86
87 struct IODVDStructurePhysical
88 {
89 UInt8 length[2];
90 UInt8 rsvd1[2];
91
92 UInt8 bookType : 4,
93 partVersion : 4;
94
95 #define kIODVDBookTypeDVDROM 0
96 #define kIODVDBookTypeDVDRAM 1
97 #define kIODVDBookTypeDVDR 2
98 #define kIODVDBookTypeDVDRW 3
99 #define kIODVDBookTypeDVDPlusRW 9
100
101 UInt8 diskSize : 4,
102 maximumRate : 4;
103
104 UInt8 rsvd2 : 1,
105 layers : 2,
106 trackPath : 1,
107 layerType : 4;
108
109 UInt8 linearDensity : 4,
110 trackDensity : 4;
111
112 UInt8 zero1;
113 UInt8 dataAreaPSNStart[3];
114 UInt8 zero2;
115 UInt8 dataAreaPSNEnd[3];
116 UInt8 zero3;
117 UInt8 layerZeroEndSectorNumber;
118
119 UInt8 bcaFlag : 1,
120 rsvd3 : 7;
121 };
122
123 struct IODVDStructureWriteProtection
124 {
125 UInt8 length[2];
126 UInt8 rsvd1[2];
127
128 UInt8 rsvd2 : 4,
129 mswi : 1,
130 cwp : 1,
131 pwp : 1,
132 swpp : 1;
133
134 UInt8 rsvd3[3];
135 };
136
137 #elif defined(__LITTLE_ENDIAN__)
138
139 // Little Endian DVD structure definitions.
140
141 struct IODVDStructurePhysical
142 {
143 UInt8 length[2];
144 UInt8 rsvd1[2];
145
146 UInt8 partVersion : 4,
147 bookType : 4;
148
149 #define kIODVDBookTypeDVDROM 0
150 #define kIODVDBookTypeDVDRAM 1
151 #define kIODVDBookTypeDVDR 2
152 #define kIODVDBookTypeDVDRW 3
153 #define kIODVDBookTypeDVDPlusRW 9
154
155 UInt8 maximumRate : 4,
156 diskSize : 4;
157
158 UInt8 layerType : 4,
159 trackPath : 1,
160 layers : 2,
161 rsvd2 : 1;
162
163 UInt8 trackDensity : 4,
164 linearDensity : 4;
165
166 UInt8 zero1;
167 UInt8 dataAreaPSNStart[3];
168 UInt8 zero2;
169 UInt8 dataAreaPSNEnd[3];
170 UInt8 zero3;
171 UInt8 layerZeroEndSectorNumber;
172
173 UInt8 rsvd3 : 7,
174 bcaFlag : 1;
175 };
176
177 struct IODVDStructureWriteProtectionStatus
178 {
179 UInt8 length[2];
180 UInt8 rsvd1[2];
181
182 UInt8 swpp : 1,
183 pwp : 1,
184 cwp : 1,
185 mswi : 1,
186 rsvd2 : 4;
187
188 UInt8 rsvd3[3];
189 };
190
191 #else
192 #error Unknown endianess.
193 #endif
194
195 //===========================================================================
196 // IOATAPIDVDDrive
197 //===========================================================================
198
199 class IOATAPIDVDDrive : public IOATAPICDDrive
200 {
201 OSDeclareDefaultStructors(IOATAPIDVDDrive)
202
203 protected:
204 virtual IOReturn determineMediaType(UInt32 * mediaType);
205
206 virtual IOReturn getConfiguration(UInt8 * buffer,
207 UInt32 length,
208 UInt32 * actualLength,
209 bool current);
210
211 virtual IOReturn classifyDrive(bool * isDVDDrive);
212
213 virtual bool matchATAPIDeviceType(UInt8 type, SInt32 * score);
214
215 virtual IOService * instantiateNub();
216
217 virtual IOATACommand * atapiCommandGetConfiguration(
218 IOMemoryDescriptor * buffer,
219 UInt8 rt,
220 UInt16 sfn = 0);
221
222 virtual IOATACommand * atapiCommandSendKey(
223 IOMemoryDescriptor * buffer,
224 const DVDKeyClass keyClass,
225 const UInt8 agid,
226 const DVDKeyFormat keyFormat);
227
228 virtual IOATACommand * atapiCommandReportKey(
229 IOMemoryDescriptor * buffer,
230 const DVDKeyClass keyClass,
231 const UInt32 lba,
232 const UInt8 agid,
233 const DVDKeyFormat keyFormat);
234
235 virtual IOATACommand * atapiCommandReadDVDStructure(
236 IOMemoryDescriptor * buffer,
237 UInt8 format,
238 UInt32 address = 0,
239 UInt8 layer = 0,
240 UInt8 agid = 0);
241
242 public:
243 virtual bool init(OSDictionary * properties);
244
245 virtual const char * getDeviceTypeName();
246
247 virtual UInt32 getMediaType();
248
249 virtual IOReturn reportWriteProtection(bool * isWriteProtected);
250
251 virtual IOReturn reportMediaState(bool * mediaPresent, bool * changed);
252
253 virtual IOReturn reportKey(IOMemoryDescriptor * buffer,
254 const DVDKeyClass keyClass,
255 const UInt32 lba,
256 const UInt8 agid,
257 const DVDKeyFormat keyFormat);
258
259 virtual IOReturn sendKey(IOMemoryDescriptor * buffer,
260 const DVDKeyClass keyClass,
261 const UInt8 agid,
262 const DVDKeyFormat keyFormat);
263 };
264
265 #endif /* ! _IOATAPIDVDDRIVE_H */