]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | #include <IOKit/assert.h> | |
24 | #include <IOKit/storage/ata/IOATAPIDVDDrive.h> | |
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | // SEND KEY command. | |
28 | ||
29 | IOATACommand * | |
30 | IOATAPIDVDDrive::atapiCommandSendKey(IOMemoryDescriptor * buffer, | |
31 | const DVDKeyClass keyClass, | |
32 | const UInt8 agid, | |
33 | const DVDKeyFormat keyFormat) | |
34 | { | |
35 | ATACDBInfo atapiCmd; | |
36 | ||
37 | assert(buffer); | |
38 | ||
39 | // Create the ATAPI packet. | |
40 | // | |
41 | bzero(&atapiCmd, sizeof(atapiCmd)); | |
42 | ||
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; | |
49 | ||
50 | return atapiCommand(&atapiCmd, buffer); | |
51 | } | |
52 | ||
53 | //--------------------------------------------------------------------------- | |
54 | // REPORT KEY command. | |
55 | ||
56 | IOATACommand * | |
57 | IOATAPIDVDDrive::atapiCommandReportKey(IOMemoryDescriptor * buffer, | |
58 | const DVDKeyClass keyClass, | |
59 | const UInt32 lba, | |
60 | const UInt8 agid, | |
61 | const DVDKeyFormat keyFormat) | |
62 | { | |
63 | ATACDBInfo atapiCmd; | |
64 | ||
65 | assert(buffer); | |
66 | ||
67 | // Create the ATAPI packet. | |
68 | // | |
69 | bzero(&atapiCmd, sizeof(atapiCmd)); | |
70 | ||
71 | atapiCmd.cdbLength = 12; | |
72 | atapiCmd.cdb[0] = kIOATAPICommandReportKey; | |
73 | ||
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); | |
79 | } | |
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; | |
84 | ||
85 | return atapiCommand(&atapiCmd, buffer); | |
86 | } | |
87 | ||
88 | //--------------------------------------------------------------------------- | |
89 | // GET CONFIGURATION command. | |
90 | ||
91 | IOATACommand * | |
92 | IOATAPIDVDDrive::atapiCommandGetConfiguration(IOMemoryDescriptor * buffer, | |
93 | UInt8 rt, | |
94 | UInt16 sfn = 0) | |
95 | { | |
96 | ATACDBInfo atapiCmd; | |
97 | ||
98 | assert(buffer); | |
99 | ||
100 | // Create the ATAPI packet. | |
101 | // | |
102 | bzero(&atapiCmd, sizeof(atapiCmd)); | |
103 | ||
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()); | |
111 | ||
112 | return atapiCommand(&atapiCmd, buffer); | |
113 | } | |
114 | ||
115 | //--------------------------------------------------------------------------- | |
116 | // READ DVD STRUCTURE command. | |
117 | ||
118 | IOATACommand * | |
119 | IOATAPIDVDDrive::atapiCommandReadDVDStructure(IOMemoryDescriptor * buffer, | |
120 | UInt8 format, | |
121 | UInt32 address = 0, | |
122 | UInt8 layer = 0, | |
123 | UInt8 agid = 0) | |
124 | { | |
125 | ATACDBInfo atapiCmd; | |
126 | ||
127 | assert(buffer); | |
128 | ||
129 | // Create the ATAPI packet. | |
130 | // | |
131 | bzero(&atapiCmd, sizeof(atapiCmd)); | |
132 | ||
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; | |
144 | ||
145 | return atapiCommand(&atapiCmd, buffer); | |
146 | } |