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 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
25 * IOATAPIHDDrive.h - Generic ATAPI Direct-Access driver.
28 * Sep 2, 1999 jliu - Ported from AppleATAPIDrive.
31 #ifndef _IOATAPIHDDRIVE_H
32 #define _IOATAPIHDDRIVE_H
34 #include <IOKit/IOTypes.h>
35 #include <IOKit/storage/ata/IOATAHDDrive.h>
37 // ATAPI (inquiry) device type.
39 enum IOATAPIDeviceType
41 kIOATAPIDeviceTypeDirectAccess
= 0x00
44 // ATAPI packet commands.
47 kIOATAPICommandTestUnitReady
= 0x00,
48 kIOATAPICommandFormatUnit
= 0x04,
49 kIOATAPICommandStartStopUnit
= 0x1b,
50 kIOATAPICommandPreventAllow
= 0x1e,
51 kIOATAPICommandSynchronizeCache
= 0x35,
52 kIOATAPICommandModeSelect
= 0x55,
53 kIOATAPICommandModeSense
= 0x5a,
54 kIOATAPICommandRead
= 0xa8,
55 kIOATAPICommandWrite
= 0xaa
58 // ATAPI feature register flags.
61 kIOATAPIFeaturesDMA
= 0x01,
62 kIOATAPIFeaturesOverlay
= 0x02,
65 #define kIOATAPIMaxTransfer 65534
68 //===========================================================================
70 //===========================================================================
72 class IOATAPIHDDrive
: public IOATAHDDrive
74 OSDeclareDefaultStructors(IOATAPIHDDrive
)
81 ATAProtocol _atapiProtocol
;
84 //-----------------------------------------------------------------------
85 // Selects a command protocol to use. The argument specifies whether
86 // the device supports DMA mode.
88 virtual bool selectCommandProtocol(bool isDMA
);
90 //-----------------------------------------------------------------------
91 // Issues an ATAPI Start/Stop Unit command.
93 virtual IOReturn
doStartStop(bool doStart
);
95 //-----------------------------------------------------------------------
96 // Given the device type from the ATAPI Inquiry data, returns true if
97 // the device type is supported by this driver.
99 virtual bool matchATAPIDeviceType(UInt8 type
, SInt32
* score
);
101 //-----------------------------------------------------------------------
102 // Setup a ATATaskFile for an ATAPI packet command from the parameters
105 virtual void setupPacketTaskFile(ATATaskfile
* taskfile
,
106 ATAProtocol protocol
,
109 //-----------------------------------------------------------------------
110 // Create a generic ATAPI command object.
112 virtual IOATACommand
* atapiCommand(ATACDBInfo
* packetCommand
,
113 IOMemoryDescriptor
* transferBuffer
= 0);
115 //-----------------------------------------------------------------------
116 // Allocates and return an IOATACommand to perform a read/write operation.
118 virtual IOATACommand
* atapiCommandReadWrite(IOMemoryDescriptor
* buffer
,
122 //-----------------------------------------------------------------------
123 // ATAPI Start/Stop Unit command (1B).
125 virtual IOATACommand
* atapiCommandStartStopUnit(bool doStart
,
129 //-----------------------------------------------------------------------
130 // ATAPI Format Unit command (04).
132 virtual IOATACommand
* atapiCommandFormatUnit(
136 IOMemoryDescriptor
* formatData
);
138 //-----------------------------------------------------------------------
139 // ATAPI Synchronize Cache command (35).
141 virtual IOATACommand
* atapiCommandSynchronizeCache();
143 //-----------------------------------------------------------------------
144 // ATAPI Prevent/Allow medium removal command (1E).
146 virtual IOATACommand
* atapiCommandPreventAllowRemoval(bool doLock
);
148 //-----------------------------------------------------------------------
149 // ATAPI Test Unit Ready command (00).
151 virtual IOATACommand
* atapiCommandTestUnitReady();
153 //----------------------------------------------------------------------
154 // ATAPI Mode Sense command (5a).
156 virtual IOATACommand
* atapiCommandModeSense(
157 IOMemoryDescriptor
* buffer
,
161 //----------------------------------------------------------------------
162 // ATAPI Mode Select command (55).
164 virtual IOATACommand
* atapiCommandModeSelect(
165 IOMemoryDescriptor
* buffer
);
167 //-----------------------------------------------------------------------
168 // Overrides the method in IOATAHDDrive and returns an IOATAPIHDDriveNub
171 virtual IOService
* instantiateNub();
173 //-----------------------------------------------------------------------
174 // Overrides the method in IOATAHDDrive. Inspect the ATAPI device.
176 virtual bool inspectDevice(IOATADevice
* device
);
178 //-----------------------------------------------------------------------
179 // Overrides the method in IOATAHDDrive. Add ATAPI wakeup handler.
181 virtual void handleActiveStateTransition( UInt32 stage
,
186 * IOATAHDDrive overrides.
188 virtual bool init(OSDictionary
* properties
);
189 virtual IOService
* probe(IOService
* provider
, SInt32
* score
);
191 virtual ATADeviceType
reportATADeviceType() const;
193 virtual IOReturn
doAsyncReadWrite(IOMemoryDescriptor
* buffer
,
196 IOStorageCompletion completion
);
198 virtual IOReturn
doSyncReadWrite(IOMemoryDescriptor
* buffer
,
202 virtual IOReturn
doEjectMedia();
204 virtual IOReturn
doFormatMedia(UInt64 byteCapacity
,
205 IOMemoryDescriptor
* formatData
= 0);
207 virtual IOReturn
doLockUnlockMedia(bool doLock
);
209 virtual IOReturn
doSynchronizeCache();
211 virtual IOReturn
doStart();
212 virtual IOReturn
doStop();
214 virtual char * getVendorString();
215 virtual char * getProductString();
216 virtual char * getRevisionString();
217 virtual char * getAdditionalDeviceInfoString();
219 virtual IOReturn
reportEjectability(bool * isEjectable
);
220 virtual IOReturn
reportLockability(bool * isLockable
);
221 virtual IOReturn
reportPollRequirements(bool * pollRequired
,
222 bool * pollIsExpensive
);
224 virtual IOReturn
reportMediaState(bool * mediaPresent
,
227 virtual IOReturn
reportRemovability(bool * isRemovable
);
229 virtual IOReturn
reportWriteProtection(bool * isWriteProtected
);
232 #endif /* !_IOATAPIHDDRIVE_H */