1/* 2 * Copyright (c) 2000-2008 Apple 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 * 25 * IOATADevice.cpp 26 * 27 */ 28#include <IOKit/IOTypes.h> 29#include "IOATATypes.h" 30#include "IOATADevice.h" 31#include "IOATAController.h" 32 33#ifdef DLOG 34#undef DLOG 35#endif 36 37#ifdef ATA_DEBUG 38#define DLOG(fmt, args...) IOLog(fmt, ## args) 39#else 40#define DLOG(fmt, args...) 41#endif 42 43 44//--------------------------------------------------------------------------- 45 46#define super IOService 47 48OSDefineMetaClass( IOATADevice, IOService ) 49OSDefineAbstractStructors( IOATADevice, IOService ) 50 OSMetaClassDefineReservedUnused(IOATADevice, 0); 51 OSMetaClassDefineReservedUnused(IOATADevice, 1); 52 OSMetaClassDefineReservedUnused(IOATADevice, 2); 53 OSMetaClassDefineReservedUnused(IOATADevice, 3); 54 OSMetaClassDefineReservedUnused(IOATADevice, 4); 55 OSMetaClassDefineReservedUnused(IOATADevice, 5); 56 OSMetaClassDefineReservedUnused(IOATADevice, 6); 57 OSMetaClassDefineReservedUnused(IOATADevice, 7); 58 OSMetaClassDefineReservedUnused(IOATADevice, 8); 59 OSMetaClassDefineReservedUnused(IOATADevice, 9); 60 OSMetaClassDefineReservedUnused(IOATADevice, 10); 61 OSMetaClassDefineReservedUnused(IOATADevice, 11); 62 OSMetaClassDefineReservedUnused(IOATADevice, 12); 63 OSMetaClassDefineReservedUnused(IOATADevice, 13); 64 OSMetaClassDefineReservedUnused(IOATADevice, 14); 65 OSMetaClassDefineReservedUnused(IOATADevice, 15); 66 OSMetaClassDefineReservedUnused(IOATADevice, 16); 67 OSMetaClassDefineReservedUnused(IOATADevice, 17); 68 OSMetaClassDefineReservedUnused(IOATADevice, 18); 69 OSMetaClassDefineReservedUnused(IOATADevice, 19); 70 OSMetaClassDefineReservedUnused(IOATADevice, 20); 71//--------------------------------------------------------------------------- 72 73// Determine whether this device is number 0 or 1 (ie, master/slave) 74ataUnitID 75IOATADevice::getUnitID( void ) 76{ 77 78 return _unitNumber; 79 80} 81 82// Find out what kind of device this nub is (ata or atapi) 83ataDeviceType 84IOATADevice::getDeviceType( void ) 85{ 86 87 return _deviceType; 88 89 90} 91 92// Find out the bus capability so the client can choose the features to set and commands to run. 93IOReturn 94IOATADevice::provideBusInfo( IOATABusInfo* getInfo) 95{ 96 97 if( !_provider ) 98 return -1; 99 100 return _provider->provideBusInfo(getInfo); 101 102} 103 104// Tell the bus what speed to use for your device. 105IOReturn 106IOATADevice::selectConfig( IOATADevConfig* configRequest) 107{ 108 109 return _provider->selectConfig( configRequest, _unitNumber); 110 111} 112 113// Find out what speed the bus has configured for this unit. 114IOReturn 115IOATADevice::provideConfig( IOATADevConfig* configRequest) 116{ 117 118 return _provider->getConfig( configRequest, _unitNumber); 119 120} 121 122// Submit IO requests 123IOReturn 124IOATADevice::executeCommand(IOATACommand* command) 125{ 126 127 // subclass must implement 128 129 return -1; 130 131 132} 133 134// create and destroy IOATACommands 135IOATACommand* 136IOATADevice::allocCommand( void ) 137{ 138 139 // subclass must provide implementation. 140 141 return 0L; 142 143} 144 145 146void 147IOATADevice::freeCommand( IOATACommand* inCommand) 148{ 149 150 // subclass must provide implementation. 151 152} 153 154 155//--------------------------------------------------------------------------- 156 157 158//--------------------------------------------------------------------------- 159void 160IOATADevice::notifyEvent( UInt32 event ) 161{ 162 163 messageClients( event ); 164 165} 166 167 168/// appearantly needed for matching somehow. 169bool 170IOATADevice::matchPropertyTable(OSDictionary * table) 171{ 172 173 bool result; 174 175 result = compareProperty ( table, "IOUnit" ); 176 177 return result; 178 179} 180 181bool 182IOATADevice::matchPropertyTable(OSDictionary * table, SInt32 * score ) 183{ 184 185 bool result; 186 187 result = compareProperty ( table, kATADevPropertyKey ); 188 189 if ( result == false ) 190 { 191 *score = 0; 192 } 193 194 return result; 195 196} 197 198 199IOService * 200IOATADevice::matchLocation(IOService * client) 201{ 202 return this; 203} 204