1/* 2 * Copyright (c) 1998-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/IODVDBlockStorageDriver.h> 25#include <IOKit/storage/IODVDMedia.h> 26 27#define super IOMedia 28OSDefineMetaClassAndStructors(IODVDMedia, IOMedia) 29 30IODVDBlockStorageDriver * IODVDMedia::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 -- IODVDBlockStorageDriver. 35 // This method serves simply as a convenience to subclass developers. 36 // 37 38 return (IODVDBlockStorageDriver *) IOService::getProvider(); 39} 40 41bool IODVDMedia::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, kIODVDMediaTypeKey); 56} 57 58IOReturn IODVDMedia::reportKey( IOMemoryDescriptor * buffer, 59 const DVDKeyClass keyClass, 60 const UInt32 address, 61 const UInt8 grantID, 62 const DVDKeyFormat format ) 63{ 64 if (isInactive()) 65 { 66 return kIOReturnNoMedia; 67 } 68 69 if (buffer == 0 && format != kDVDKeyFormatAGID_Invalidate) 70 { 71 return kIOReturnBadArgument; 72 } 73 74 return getProvider()->reportKey( /* buffer */ buffer, 75 /* keyClass */ keyClass, 76 /* address */ address, 77 /* grantID */ grantID, 78 /* format */ format ); 79} 80 81IOReturn IODVDMedia::sendKey( IOMemoryDescriptor * buffer, 82 const DVDKeyClass keyClass, 83 const UInt8 grantID, 84 const DVDKeyFormat format ) 85{ 86 if (isInactive()) 87 { 88 return kIOReturnNoMedia; 89 } 90 91 if (buffer == 0 && format != kDVDKeyFormatAGID_Invalidate) 92 { 93 return kIOReturnBadArgument; 94 } 95 96 return getProvider()->sendKey( /* buffer */ buffer, 97 /* keyClass */ keyClass, 98 /* grantID */ grantID, 99 /* format */ format ); 100} 101 102IOReturn IODVDMedia::readStructure( IOMemoryDescriptor * buffer, 103 const DVDStructureFormat format, 104 const UInt32 address, 105 const UInt8 layer, 106 const UInt8 grantID ) 107{ 108 if (isInactive()) 109 { 110 return kIOReturnNoMedia; 111 } 112 113 if (buffer == 0) 114 { 115 return kIOReturnBadArgument; 116 } 117 118 return getProvider()->readStructure( /* buffer */ buffer, 119 /* format */ format, 120 /* address */ address, 121 /* layer */ layer, 122 /* grantID */ grantID ); 123} 124 125IOReturn IODVDMedia::getSpeed(UInt16 * kilobytesPerSecond) 126{ 127 if (isInactive()) 128 { 129 return kIOReturnNoMedia; 130 } 131 132 return getProvider()->getSpeed(kilobytesPerSecond); 133} 134 135IOReturn IODVDMedia::setSpeed(UInt16 kilobytesPerSecond) 136{ 137 if (isInactive()) 138 { 139 return kIOReturnNoMedia; 140 } 141 142 return getProvider()->setSpeed(kilobytesPerSecond); 143} 144 145IOReturn IODVDMedia::readDiscInfo( IOMemoryDescriptor * buffer, 146 UInt16 * actualByteCount ) 147{ 148 if (isInactive()) 149 { 150 if (actualByteCount) *actualByteCount = 0; 151 152 return kIOReturnNoMedia; 153 } 154 155 if (buffer == 0) 156 { 157 if (actualByteCount) *actualByteCount = 0; 158 159 return kIOReturnBadArgument; 160 } 161 162 return getProvider()->readDiscInfo( /* buffer */ buffer, 163 /* actualByteCount */ actualByteCount ); 164} 165 166IOReturn IODVDMedia::readRZoneInfo( IOMemoryDescriptor * buffer, 167 UInt32 address, 168 DVDRZoneInfoAddressType addressType, 169 UInt16 * actualByteCount ) 170{ 171 if (isInactive()) 172 { 173 if (actualByteCount) *actualByteCount = 0; 174 175 return kIOReturnNoMedia; 176 } 177 178 if (buffer == 0) 179 { 180 if (actualByteCount) *actualByteCount = 0; 181 182 return kIOReturnBadArgument; 183 } 184 185 return getProvider()->readTrackInfo( 186 /* buffer */ buffer, 187 /* address */ address, 188 /* addressType */ addressType, 189 /* actualByteCount */ actualByteCount ); 190} 191 192#ifdef __LP64__ 193OSMetaClassDefineReservedUnused(IODVDMedia, 0); 194OSMetaClassDefineReservedUnused(IODVDMedia, 1); 195OSMetaClassDefineReservedUnused(IODVDMedia, 2); 196OSMetaClassDefineReservedUnused(IODVDMedia, 3); 197OSMetaClassDefineReservedUnused(IODVDMedia, 4); 198OSMetaClassDefineReservedUnused(IODVDMedia, 5); 199OSMetaClassDefineReservedUnused(IODVDMedia, 6); 200#else /* !__LP64__ */ 201OSMetaClassDefineReservedUsed(IODVDMedia, 0); 202OSMetaClassDefineReservedUsed(IODVDMedia, 1); 203OSMetaClassDefineReservedUsed(IODVDMedia, 2); 204OSMetaClassDefineReservedUsed(IODVDMedia, 3); 205OSMetaClassDefineReservedUsed(IODVDMedia, 4); 206OSMetaClassDefineReservedUsed(IODVDMedia, 5); 207OSMetaClassDefineReservedUsed(IODVDMedia, 6); 208#endif /* !__LP64__ */ 209OSMetaClassDefineReservedUnused(IODVDMedia, 7); 210OSMetaClassDefineReservedUnused(IODVDMedia, 8); 211OSMetaClassDefineReservedUnused(IODVDMedia, 9); 212OSMetaClassDefineReservedUnused(IODVDMedia, 10); 213OSMetaClassDefineReservedUnused(IODVDMedia, 11); 214OSMetaClassDefineReservedUnused(IODVDMedia, 12); 215OSMetaClassDefineReservedUnused(IODVDMedia, 13); 216OSMetaClassDefineReservedUnused(IODVDMedia, 14); 217OSMetaClassDefineReservedUnused(IODVDMedia, 15); 218OSMetaClassDefineReservedUnused(IODVDMedia, 16); 219OSMetaClassDefineReservedUnused(IODVDMedia, 17); 220OSMetaClassDefineReservedUnused(IODVDMedia, 18); 221OSMetaClassDefineReservedUnused(IODVDMedia, 19); 222OSMetaClassDefineReservedUnused(IODVDMedia, 20); 223OSMetaClassDefineReservedUnused(IODVDMedia, 21); 224OSMetaClassDefineReservedUnused(IODVDMedia, 22); 225OSMetaClassDefineReservedUnused(IODVDMedia, 23); 226OSMetaClassDefineReservedUnused(IODVDMedia, 24); 227OSMetaClassDefineReservedUnused(IODVDMedia, 25); 228OSMetaClassDefineReservedUnused(IODVDMedia, 26); 229OSMetaClassDefineReservedUnused(IODVDMedia, 27); 230OSMetaClassDefineReservedUnused(IODVDMedia, 28); 231OSMetaClassDefineReservedUnused(IODVDMedia, 29); 232OSMetaClassDefineReservedUnused(IODVDMedia, 30); 233OSMetaClassDefineReservedUnused(IODVDMedia, 31); 234