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 #include <IOKit/assert.h>
24 #include <IOKit/storage/ata/IOATAPIDVDDrive.h>
26 //---------------------------------------------------------------------------
30 IOATAPIDVDDrive::atapiCommandSendKey(IOMemoryDescriptor
* buffer
,
31 const DVDKeyClass keyClass
,
33 const DVDKeyFormat keyFormat
)
39 // Create the ATAPI packet.
41 bzero(&atapiCmd
, sizeof(atapiCmd
));
43 atapiCmd
.cdbLength
= 12;
44 atapiCmd
.cdb
[0] = kIOATAPICommandSendKey
;
45 atapiCmd
.cdb
[7] = keyClass
;
46 atapiCmd
.cdb
[8] = (UInt8
)(buffer
->getLength() >> 8);
47 atapiCmd
.cdb
[9] = (UInt8
)(buffer
->getLength());
48 atapiCmd
.cdb
[10] = agid
<< 6 | keyFormat
;
50 return atapiCommand(&atapiCmd
, buffer
);
53 //---------------------------------------------------------------------------
54 // REPORT KEY command.
57 IOATAPIDVDDrive::atapiCommandReportKey(IOMemoryDescriptor
* buffer
,
58 const DVDKeyClass keyClass
,
61 const DVDKeyFormat keyFormat
)
67 // Create the ATAPI packet.
69 bzero(&atapiCmd
, sizeof(atapiCmd
));
71 atapiCmd
.cdbLength
= 12;
72 atapiCmd
.cdb
[0] = kIOATAPICommandReportKey
;
74 if (keyFormat
== kTitleKey
) {
75 atapiCmd
.cdb
[2] = (UInt8
)(lba
>> 24);
76 atapiCmd
.cdb
[3] = (UInt8
)(lba
>> 16);
77 atapiCmd
.cdb
[4] = (UInt8
)(lba
>> 8);
78 atapiCmd
.cdb
[5] = (UInt8
)(lba
);
80 atapiCmd
.cdb
[7] = keyClass
;
81 atapiCmd
.cdb
[8] = (UInt8
)(buffer
->getLength() >> 8);
82 atapiCmd
.cdb
[9] = (UInt8
)(buffer
->getLength());
83 atapiCmd
.cdb
[10] = agid
<< 6 | keyFormat
;
85 return atapiCommand(&atapiCmd
, buffer
);
88 //---------------------------------------------------------------------------
89 // GET CONFIGURATION command.
92 IOATAPIDVDDrive::atapiCommandGetConfiguration(IOMemoryDescriptor
* buffer
,
100 // Create the ATAPI packet.
102 bzero(&atapiCmd
, sizeof(atapiCmd
));
104 atapiCmd
.cdbLength
= 12;
105 atapiCmd
.cdb
[0] = kIOATAPICommandGetConfiguration
;
106 atapiCmd
.cdb
[1] = rt
& 0x03;
107 atapiCmd
.cdb
[2] = (UInt8
)(sfn
>> 8); // starting feature number MSB
108 atapiCmd
.cdb
[3] = (UInt8
)(sfn
); // starting feature number LSB
109 atapiCmd
.cdb
[7] = (UInt8
)(buffer
->getLength() >> 8);
110 atapiCmd
.cdb
[8] = (UInt8
)(buffer
->getLength());
112 return atapiCommand(&atapiCmd
, buffer
);
115 //---------------------------------------------------------------------------
116 // READ DVD STRUCTURE command.
119 IOATAPIDVDDrive::atapiCommandReadDVDStructure(IOMemoryDescriptor
* buffer
,
129 // Create the ATAPI packet.
131 bzero(&atapiCmd
, sizeof(atapiCmd
));
133 atapiCmd
.cdbLength
= 12;
134 atapiCmd
.cdb
[0] = kIOATAPICommandReadDVDStructure
;
135 atapiCmd
.cdb
[2] = (UInt8
)(address
>> 24);
136 atapiCmd
.cdb
[3] = (UInt8
)(address
>> 16);
137 atapiCmd
.cdb
[4] = (UInt8
)(address
>> 8);
138 atapiCmd
.cdb
[5] = (UInt8
)(address
);
139 atapiCmd
.cdb
[6] = layer
;
140 atapiCmd
.cdb
[7] = format
;
141 atapiCmd
.cdb
[8] = (UInt8
)(buffer
->getLength() >> 8);
142 atapiCmd
.cdb
[9] = (UInt8
)(buffer
->getLength());
143 atapiCmd
.cdb
[10] = (agid
& 0x3) << 6;
145 return atapiCommand(&atapiCmd
, buffer
);