|
|
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: * ! 24: * IOATACommand.cpp ! 25: * ! 26: */ ! 27: ! 28: #include <IOKit/ata/IOATA.h> ! 29: #include <IOKit/ata/IOATAController.h> ! 30: ! 31: #undef super ! 32: #define super OSObject ! 33: ! 34: OSDefineMetaClassAndStructors( IOATACommand, OSObject ) ! 35: ! 36: IOATADevice *IOATACommand::getDevice() ! 37: { ! 38: return device; ! 39: } ! 40: ! 41: IOCommandQueue *IOATACommand::getDeviceQueue() ! 42: { ! 43: return deviceQueue; ! 44: } ! 45: ! 46: IOATAController *IOATACommand::getController() ! 47: { ! 48: return controller; ! 49: } ! 50: ! 51: void *IOATACommand::getClientData() ! 52: { ! 53: return clientData; ! 54: } ! 55: ! 56: void *IOATACommand::getControllerData() ! 57: { ! 58: return controllerData; ! 59: } ! 60: ! 61: void IOATACommand::setTaskfile( ATATaskfile *srcTaskfile ) ! 62: { ! 63: taskfile = *srcTaskfile; ! 64: flags |= atacmdTaskfileValid; ! 65: } ! 66: ! 67: void IOATACommand::getTaskfile( ATATaskfile *dstTaskfile ) ! 68: { ! 69: *dstTaskfile = taskfile; ! 70: } ! 71: ! 72: ATAProtocol IOATACommand::getProtocol() ! 73: { ! 74: return taskfile.protocol; ! 75: } ! 76: ! 77: UInt32 IOATACommand::getResultMask() ! 78: { ! 79: return taskfile.resultmask; ! 80: } ! 81: ! 82: void IOATACommand::setTimeout( UInt32 timeoutMS ) ! 83: { ! 84: timeout = timeoutMS; ! 85: } ! 86: ! 87: UInt32 IOATACommand::getTimeout() ! 88: { ! 89: return timeout; ! 90: } ! 91: ! 92: ! 93: void IOATACommand::setResults( ATAResults *srcResults ) ! 94: { ! 95: results = *srcResults; ! 96: ! 97: flags |= atacmdResultsValid; ! 98: } ! 99: ! 100: ATAReturnCode IOATACommand::getResults( ATAResults *dstResults ) ! 101: { ! 102: *dstResults = results; ! 103: return results.returnCode; ! 104: } ! 105: ! 106: void IOATACommand::setPointers( IOMemoryDescriptor *clientDesc, UInt32 transferCount, bool isWrite ) ! 107: { ! 108: xferDesc = clientDesc; ! 109: xferCount = transferCount; ! 110: xferDirection = isWrite; ! 111: ! 112: flags |= atacmdPointersValid; ! 113: } ! 114: ! 115: void IOATACommand::getPointers( IOMemoryDescriptor **clientDesc, UInt32 *transferCount, bool *isWrite ) ! 116: { ! 117: if ( clientDesc != NULL ) ! 118: { ! 119: *clientDesc = xferDesc; ! 120: } ! 121: ! 122: if ( transferCount != NULL ) ! 123: { ! 124: *transferCount = xferCount; ! 125: } ! 126: ! 127: if ( isWrite != NULL ) ! 128: { ! 129: *isWrite = xferDirection; ! 130: } ! 131: } ! 132: ! 133: void IOATACommand::setATAPICmd( ATAPICmd *clientATAPICmd, IOMemoryDescriptor *clientSenseData, UInt32 clientSenseLength ) ! 134: { ! 135: atapiCmd = *clientATAPICmd; ! 136: senseLength = clientSenseLength; ! 137: senseData = clientSenseData; ! 138: ! 139: flags |= atacmdATAPIInfoValid; ! 140: } ! 141: ! 142: void IOATACommand::getATAPICmd( ATAPICmd *clientATAPICmd, IOMemoryDescriptor **clientSenseData, UInt32 *clientSenseLength ) ! 143: { ! 144: if ( clientATAPICmd != NULL ) ! 145: { ! 146: *clientATAPICmd = atapiCmd; ! 147: } ! 148: ! 149: if ( clientSenseLength != NULL ) ! 150: { ! 151: *clientSenseLength = senseLength; ! 152: } ! 153: ! 154: if ( clientSenseData != NULL ) ! 155: { ! 156: *clientSenseData = senseData; ! 157: } ! 158: } ! 159: ! 160: void IOATACommand::setCallback( void *clientTarget, ATACallback clientATADoneFn, void *clientRefcon ) ! 161: { ! 162: if ( clientATADoneFn == NULL ) ! 163: { ! 164: flags &= ~atacmdCallbackValid; ! 165: } ! 166: else ! 167: { ! 168: completionInfo.async.target = clientTarget; ! 169: completionInfo.async.ataDoneFn = clientATADoneFn; ! 170: completionInfo.async.refcon = clientRefcon; ! 171: ! 172: flags |= atacmdCallbackValid; ! 173: } ! 174: } ! 175: ! 176: bool IOATACommand::execute() ! 177: { ! 178: return device->executeCommand( this ); ! 179: } ! 180: ! 181: void IOATACommand::complete() ! 182: { ! 183: device->completeCommand( this ); ! 184: } ! 185: ! 186: void IOATACommand::clear() ! 187: { ! 188: if ( dataSize ) ! 189: { ! 190: bzero( dataArea, dataSize ); ! 191: } ! 192: ! 193: flags = 0; ! 194: } ! 195: ! 196: void IOATACommand::setController( IOATAController *ctlr ) ! 197: { ! 198: controller = ctlr; ! 199: } ! 200: ! 201: void IOATACommand::setDevice( IOATADevice *dev ) ! 202: { ! 203: device = dev; ! 204: } ! 205:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.