1/* 2 * Copyright (c) 2006-2012 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#include <IOKit/storage/IOBDBlockStorageDriver.h> 25#include <IOKit/storage/IOBDMedia.h> 26 27#define super IOMedia 28OSDefineMetaClassAndStructors(IOBDMedia, IOMedia) 29 30IOBDBlockStorageDriver * IOBDMedia::getProvider() const 31{ 32 // 33 // Obtain this object's provider. We override the superclass's method to 34 // return a more specific subclass of IOService -- IOBDBlockStorageDriver. 35 // This method serves simply as a convenience to subclass developers. 36 // 37 38 return (IOBDBlockStorageDriver *) IOService::getProvider(); 39} 40 41bool IOBDMedia::matchPropertyTable(OSDictionary * table, SInt32 * score) 42{ 43 // 44 // Compare the properties in the supplied table to this object's properties. 45 // 46 47 // Ask our superclass' opinion. 48 49 if (super::matchPropertyTable(table, score) == false) return false; 50 51 // We return success if the following expression is true -- individual 52 // comparisions evaluate to truth if the named property is not present 53 // in the supplied table. 54 55 return compareProperty(table, kIOBDMediaTypeKey); 56} 57 58IOReturn IOBDMedia::reportKey( IOMemoryDescriptor * buffer, 59 UInt8 keyClass, 60 UInt32 address, 61 UInt8 grantID, 62 UInt8 format ) 63{ 64 if (isInactive()) 65 { 66 return kIOReturnNoMedia; 67 } 68 69 return getProvider()->reportKey( /* buffer */ buffer, 70 /* keyClass */ (DVDKeyClass) keyClass, 71 /* address */ address, 72 /* grantID */ grantID, 73 /* format */ (DVDKeyFormat) format ); 74} 75 76IOReturn IOBDMedia::sendKey( IOMemoryDescriptor * buffer, 77 UInt8 keyClass, 78 UInt8 grantID, 79 UInt8 format ) 80{ 81 if (isInactive()) 82 { 83 return kIOReturnNoMedia; 84 } 85 86 return getProvider()->sendKey( /* buffer */ buffer, 87 /* keyClass */ (DVDKeyClass) keyClass, 88 /* grantID */ grantID, 89 /* format */ (DVDKeyFormat) format ); 90} 91 92IOReturn IOBDMedia::readStructure( IOMemoryDescriptor * buffer, 93 UInt8 format, 94 UInt32 address, 95 UInt8 layer, 96 UInt8 grantID ) 97{ 98 if (isInactive()) 99 { 100 return kIOReturnNoMedia; 101 } 102 103 if (buffer == 0) 104 { 105 return kIOReturnBadArgument; 106 } 107 108 return getProvider()->readStructure( /* buffer */ buffer, 109 /* format */ format, 110 /* address */ address, 111 /* layer */ layer, 112 /* grantID */ grantID ); 113} 114 115IOReturn IOBDMedia::getSpeed(UInt16 * kilobytesPerSecond) 116{ 117 if (isInactive()) 118 { 119 return kIOReturnNoMedia; 120 } 121 122 return getProvider()->getSpeed(kilobytesPerSecond); 123} 124 125IOReturn IOBDMedia::setSpeed(UInt16 kilobytesPerSecond) 126{ 127 if (isInactive()) 128 { 129 return kIOReturnNoMedia; 130 } 131 132 return getProvider()->setSpeed(kilobytesPerSecond); 133} 134 135IOReturn IOBDMedia::readDiscInfo( IOMemoryDescriptor * buffer, 136 UInt8 type, 137 UInt16 * actualByteCount ) 138{ 139 if (isInactive()) 140 { 141 if (actualByteCount) *actualByteCount = 0; 142 143 return kIOReturnNoMedia; 144 } 145 146 if (buffer == 0) 147 { 148 if (actualByteCount) *actualByteCount = 0; 149 150 return kIOReturnBadArgument; 151 } 152 153 return getProvider()->readDiscInfo( /* buffer */ buffer, 154 /* actualByteCount */ actualByteCount ); 155} 156 157IOReturn IOBDMedia::readTrackInfo( IOMemoryDescriptor * buffer, 158 UInt32 address, 159 UInt8 addressType, 160 UInt8 open, 161 UInt16 * actualByteCount ) 162{ 163 if (isInactive()) 164 { 165 if (actualByteCount) *actualByteCount = 0; 166 167 return kIOReturnNoMedia; 168 } 169 170 if (buffer == 0) 171 { 172 if (actualByteCount) *actualByteCount = 0; 173 174 return kIOReturnBadArgument; 175 } 176 177 return getProvider()->readTrackInfo( 178 /* buffer */ buffer, 179 /* address */ address, 180 /* addressType */ addressType, 181 /* actualByteCount */ actualByteCount ); 182} 183 184IOReturn IOBDMedia::splitTrack(UInt32 address) 185{ 186 if (isInactive()) 187 { 188 return kIOReturnNoMedia; 189 } 190 191 return getProvider()->splitTrack(address); 192} 193 194OSMetaClassDefineReservedUnused(IOBDMedia, 0); 195OSMetaClassDefineReservedUnused(IOBDMedia, 1); 196OSMetaClassDefineReservedUnused(IOBDMedia, 2); 197OSMetaClassDefineReservedUnused(IOBDMedia, 3); 198OSMetaClassDefineReservedUnused(IOBDMedia, 4); 199OSMetaClassDefineReservedUnused(IOBDMedia, 5); 200OSMetaClassDefineReservedUnused(IOBDMedia, 6); 201OSMetaClassDefineReservedUnused(IOBDMedia, 7); 202OSMetaClassDefineReservedUnused(IOBDMedia, 8); 203OSMetaClassDefineReservedUnused(IOBDMedia, 9); 204OSMetaClassDefineReservedUnused(IOBDMedia, 10); 205OSMetaClassDefineReservedUnused(IOBDMedia, 11); 206OSMetaClassDefineReservedUnused(IOBDMedia, 12); 207OSMetaClassDefineReservedUnused(IOBDMedia, 13); 208OSMetaClassDefineReservedUnused(IOBDMedia, 14); 209OSMetaClassDefineReservedUnused(IOBDMedia, 15); 210