2 * Copyright (c) 1998-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@
23 #ifndef _IOATAPIDVDDRIVE_H
24 #define _IOATAPIDVDDRIVE_H
26 #include <IOKit/IOTypes.h>
27 #include <IOKit/storage/ata/IOATAPICDDrive.h>
28 #include <IOKit/storage/IODVDTypes.h>
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
63 // DVD specific command codes.
66 kIOATAPICommandGetConfiguration
= 0x46,
67 kIOATAPICommandSendKey
= 0xa3,
68 kIOATAPICommandReportKey
= 0xa4,
69 kIOATAPICommandReadDVDStructure
= 0xad
72 // Format code definitions for READ DVD STRUCTURE command.
75 kIODVDReadStructurePhysical
= 0x00,
76 kIODVDReadStructureCopyright
= 0x01,
77 kIODVDReadStructureWriteProtection
= 0xC0
80 #define IODVDGetDataLength16(ptr) OSReadBigInt16((void *) ptr, 0)
81 #define IODVDGetDataLength32(ptr) OSReadBigInt32((void *) ptr, 0)
83 #if defined(__BIG_ENDIAN__)
85 // Big Endian DVD structure definitions.
87 struct IODVDStructurePhysical
95 #define kIODVDBookTypeDVDROM 0
96 #define kIODVDBookTypeDVDRAM 1
97 #define kIODVDBookTypeDVDR 2
98 #define kIODVDBookTypeDVDRW 3
99 #define kIODVDBookTypeDVDPlusRW 9
109 UInt8 linearDensity
: 4,
113 UInt8 dataAreaPSNStart
[3];
115 UInt8 dataAreaPSNEnd
[3];
117 UInt8 layerZeroEndSectorNumber
;
123 struct IODVDStructureWriteProtection
137 #elif defined(__LITTLE_ENDIAN__)
139 // Little Endian DVD structure definitions.
141 struct IODVDStructurePhysical
146 UInt8 partVersion
: 4,
149 #define kIODVDBookTypeDVDROM 0
150 #define kIODVDBookTypeDVDRAM 1
151 #define kIODVDBookTypeDVDR 2
152 #define kIODVDBookTypeDVDRW 3
153 #define kIODVDBookTypeDVDPlusRW 9
155 UInt8 maximumRate
: 4,
163 UInt8 trackDensity
: 4,
167 UInt8 dataAreaPSNStart
[3];
169 UInt8 dataAreaPSNEnd
[3];
171 UInt8 layerZeroEndSectorNumber
;
177 struct IODVDStructureWriteProtectionStatus
192 #error Unknown endianess.
195 //===========================================================================
197 //===========================================================================
199 class IOATAPIDVDDrive
: public IOATAPICDDrive
201 OSDeclareDefaultStructors(IOATAPIDVDDrive
)
204 virtual IOReturn
determineMediaType(UInt32
* mediaType
);
206 virtual IOReturn
getConfiguration(UInt8
* buffer
,
208 UInt32
* actualLength
,
211 virtual IOReturn
classifyDrive(bool * isDVDDrive
);
213 virtual bool matchATAPIDeviceType(UInt8 type
, SInt32
* score
);
215 virtual IOService
* instantiateNub();
217 virtual IOATACommand
* atapiCommandGetConfiguration(
218 IOMemoryDescriptor
* buffer
,
222 virtual IOATACommand
* atapiCommandSendKey(
223 IOMemoryDescriptor
* buffer
,
224 const DVDKeyClass keyClass
,
226 const DVDKeyFormat keyFormat
);
228 virtual IOATACommand
* atapiCommandReportKey(
229 IOMemoryDescriptor
* buffer
,
230 const DVDKeyClass keyClass
,
233 const DVDKeyFormat keyFormat
);
235 virtual IOATACommand
* atapiCommandReadDVDStructure(
236 IOMemoryDescriptor
* buffer
,
243 virtual bool init(OSDictionary
* properties
);
245 virtual const char * getDeviceTypeName();
247 virtual UInt32
getMediaType();
249 virtual IOReturn
reportWriteProtection(bool * isWriteProtected
);
251 virtual IOReturn
reportMediaState(bool * mediaPresent
, bool * changed
);
253 virtual IOReturn
reportKey(IOMemoryDescriptor
* buffer
,
254 const DVDKeyClass keyClass
,
257 const DVDKeyFormat keyFormat
);
259 virtual IOReturn
sendKey(IOMemoryDescriptor
* buffer
,
260 const DVDKeyClass keyClass
,
262 const DVDKeyFormat keyFormat
);
265 #endif /* ! _IOATAPIDVDDRIVE_H */