|
|
1.1 ! root 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: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 24: * ! 25: * IOATAPIHDDrive.h - Generic ATAPI Direct-Access driver. ! 26: * ! 27: * HISTORY ! 28: * Sep 2, 1999 jliu - Ported from AppleATAPIDrive. ! 29: */ ! 30: ! 31: #ifndef _IOATAPIHDDRIVE_H ! 32: #define _IOATAPIHDDRIVE_H ! 33: ! 34: #include <IOKit/IOTypes.h> ! 35: #include <IOKit/storage/ata/IOATAHDDrive.h> ! 36: #include <IOKit/storage/IOCDTypes.h> ! 37: ! 38: // ATAPI (inquiry) device type. ! 39: // ! 40: enum IOATAPIDeviceType ! 41: { ! 42: kIOATAPIDeviceTypeDirectAccess = 0x00, ! 43: kIOATAPIDeviceTypeCDROM = 0x05, ! 44: }; ! 45: ! 46: // ATAPI packet commands. ! 47: // ! 48: enum { ! 49: kIOATAPICommandTestUnitReady = 0x00, ! 50: kIOATAPICommandFormatUnit = 0x04, ! 51: kIOATAPICommandWrite = 0xaa, ! 52: kIOATAPICommandRead = 0xa8, ! 53: kIOATAPICommandStartStopUnit = 0x1b, ! 54: kIOATAPICommandPreventAllow = 0x1e, ! 55: kIOATAPICommandReadTOC = 0x43, ! 56: ! 57: // for audio support ! 58: kIOATAPICommandPlayAudio = 0x45, ! 59: kIOATAPICommandPlayAudioMSF = 0x47, ! 60: kIOATAPICommandPauseResume = 0x4b, ! 61: kIOATAPICommandModeSense = 0x5a, ! 62: kIOATAPICommandModeSelect = 0x55, ! 63: kIOATAPICommandReadSubChannel = 0x42, ! 64: kIOATAPICommandReadHeader = 0x44, ! 65: kIOATAPICommandReadCD = 0xbe, ! 66: }; ! 67: ! 68: // ATAPI feature register flags. ! 69: // ! 70: enum { ! 71: kIOATAPIFeaturesDMA = 0x01, ! 72: kIOATAPIFeaturesOverlay = 0x02, ! 73: }; ! 74: ! 75: #define kIOATAPIMaxTransfer 65534 ! 76: ! 77: ! 78: // ========================================================================== ! 79: // IOATAPIHDDrive ! 80: // ========================================================================== ! 81: ! 82: class IOATAPIHDDrive : public IOATAHDDrive ! 83: { ! 84: OSDeclareDefaultStructors(IOATAPIHDDrive) ! 85: ! 86: protected: ! 87: char _vendor[9]; ! 88: char _product[17]; ! 89: bool _mediaPresent; ! 90: bool _isRemovable; ! 91: ATAProtocol _atapiProtocol; ! 92: ! 93: //----------------------------------------------------------------------- ! 94: // Selects a command protocol to use. The argument specifies whether ! 95: // the device supports DMA mode. ! 96: ! 97: virtual void selectCommandProtocol(bool useDMA); ! 98: ! 99: //----------------------------------------------------------------------- ! 100: // Issues an ATAPI Start/Stop Unit command. ! 101: ! 102: virtual IOReturn doStartStop(bool doStart); ! 103: ! 104: //----------------------------------------------------------------------- ! 105: // Given the device type from the ATAPI Inquiry data, returns true if ! 106: // the device type is supported by this driver. ! 107: ! 108: virtual bool matchATAPIDeviceType(UInt8 type); ! 109: ! 110: //----------------------------------------------------------------------- ! 111: // Setup a ATATaskFile for an ATAPI packet command from the parameters ! 112: // given. ! 113: ! 114: virtual void setupPacketTaskFile(ATATaskfile * taskfile, ! 115: ATAProtocol protocol, ! 116: UInt16 byteCount); ! 117: ! 118: //----------------------------------------------------------------------- ! 119: // Create a generic ATAPI command object. ! 120: ! 121: virtual IOATACommand * atapiCommand(ATAPICmd * packetCommand, ! 122: IOMemoryDescriptor * transferBuffer = 0, ! 123: IOMemoryDescriptor * senseData = 0); ! 124: ! 125: //----------------------------------------------------------------------- ! 126: // Allocates and return an IOATACommand to perform a read/write operation. ! 127: ! 128: virtual IOATACommand * atapiCommandReadWrite(IOMemoryDescriptor * buffer, ! 129: UInt32 block, ! 130: UInt32 nblks); ! 131: ! 132: //----------------------------------------------------------------------- ! 133: // ATAPI Start/Stop Unit command (1B). ! 134: ! 135: virtual IOATACommand * atapiCommandStartStopUnit( ! 136: IOMemoryDescriptor * senseData, ! 137: bool doStart, ! 138: bool doLoadEject, ! 139: bool immediate); ! 140: ! 141: //----------------------------------------------------------------------- ! 142: // ATAPI Prevent/Allow medium removal command (1E). ! 143: ! 144: virtual IOATACommand * atapiCommandPreventAllowRemoval(bool doLock); ! 145: ! 146: //----------------------------------------------------------------------- ! 147: // ATAPI Test Unit Ready command (00). ! 148: ! 149: virtual IOATACommand * atapiCommandTestUnitReady( ! 150: IOMemoryDescriptor * senseData); ! 151: ! 152: //----------------------------------------------------------------------- ! 153: // ATAPI Read TOC command (43). ! 154: ! 155: virtual IOATACommand * atapiCommandReadTOC( ! 156: IOMemoryDescriptor * buffer, ! 157: tocFormat format, ! 158: UInt8 startTrackSession); ! 159: ! 160: //---------------------------------------------------------------------- ! 161: // ATAPI Play Audio command (45). ! 162: ! 163: virtual IOATACommand * atapiCommandPlayAudio( ! 164: UInt32 start_lba, ! 165: UInt32 len_lba); ! 166: ! 167: //---------------------------------------------------------------------- ! 168: // ATAPI Play Audio command (47). ! 169: ! 170: virtual IOATACommand * atapiCommandPlayAudioMSF( ! 171: UInt32 start_msf, ! 172: UInt32 end_msf); ! 173: ! 174: //---------------------------------------------------------------------- ! 175: // ATAPI Pause/Resume command (4b). ! 176: ! 177: virtual IOATACommand * atapiCommandPauseResume( ! 178: bool resume); ! 179: ! 180: //---------------------------------------------------------------------- ! 181: // ATAPI Mode Sense command (5a). ! 182: ! 183: virtual IOATACommand * atapiCommandModeSense( ! 184: IOMemoryDescriptor * buffer, ! 185: UInt8 pageCode); ! 186: ! 187: //---------------------------------------------------------------------- ! 188: // ATAPI Mode Select command (55). ! 189: ! 190: virtual IOATACommand * atapiCommandModeSelect( ! 191: IOMemoryDescriptor * buffer, ! 192: UInt8 pageCode); ! 193: ! 194: //---------------------------------------------------------------------- ! 195: // ATAPI Read Subchannel command (42). ! 196: ! 197: virtual IOATACommand * atapiCommandReadSubChannel( ! 198: IOMemoryDescriptor * buffer, ! 199: UInt8 dataFormat, ! 200: UInt8 trackNumber, ! 201: bool subQ); ! 202: ! 203: //---------------------------------------------------------------------- ! 204: // ATAPI Read Header command (44). ! 205: ! 206: virtual IOATACommand * atapiCommandReadHeader( ! 207: IOMemoryDescriptor * buffer, ! 208: UInt32 address); ! 209: ! 210: //---------------------------------------------------------------------- ! 211: // ATAPI Read CD command (be). ! 212: ! 213: virtual IOATACommand * atapiCommandReadCD( ! 214: IOMemoryDescriptor * buffer, ! 215: UInt32 address, ! 216: UInt32 length, ! 217: UInt8 sector, ! 218: UInt8 header, ! 219: UInt8 error, ! 220: UInt8 data); ! 221: ! 222: //----------------------------------------------------------------------- ! 223: // Overrides the method in IOATAHDDrive and returns an IOATAPIHDDriveNub ! 224: // instance. ! 225: ! 226: virtual IOService * instantiateNub(); ! 227: ! 228: //----------------------------------------------------------------------- ! 229: // Overrides the method in IOATAHDDrive. Inspect the ATAPI device. ! 230: ! 231: virtual void inspectDevice(IOService * provider); ! 232: ! 233: public: ! 234: /* ! 235: * IOATAHDDrive overrides. ! 236: */ ! 237: virtual bool init(OSDictionary * properties); ! 238: virtual IOService * probe(IOService * provider, SInt32 * score); ! 239: ! 240: virtual ATADeviceType reportATADeviceType() const; ! 241: ! 242: virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor * buffer, ! 243: UInt32 block, ! 244: UInt32 nblks, ! 245: gdCompletionFunction action, ! 246: IOService * target, ! 247: void * param); ! 248: ! 249: virtual IOReturn doEjectMedia(); ! 250: ! 251: virtual IOReturn doFormatMedia(UInt64 byteCapacity); ! 252: ! 253: virtual IOReturn doLockUnlockMedia(bool doLock); ! 254: ! 255: virtual IOReturn doSynchronizeCache(); ! 256: ! 257: virtual IOReturn doStart(); ! 258: virtual IOReturn doStop(); ! 259: ! 260: virtual char * getVendorString(); ! 261: virtual char * getProductString(); ! 262: virtual char * getRevisionString(); ! 263: virtual char * getAdditionalDeviceInfoString(); ! 264: ! 265: virtual IOReturn reportEjectability(bool * isEjectable); ! 266: virtual IOReturn reportLockability(bool * isLockable); ! 267: virtual IOReturn reportPollRequirements(bool * pollRequired, ! 268: bool * pollIsExpensive); ! 269: ! 270: virtual IOReturn reportMediaState(bool * mediaPresent, ! 271: bool * changed); ! 272: ! 273: virtual IOReturn reportRemovability(bool * isRemovable); ! 274: ! 275: virtual IOReturn reportWriteProtection(bool * isWriteProtected); ! 276: }; ! 277: ! 278: #endif /* !_IOATAPIHDDRIVE_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.