]> git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IODVDStorage/IODVDBlockStorageDriver.cpp
a6a56c453323501da41b278a979ee9de17b3ce69
[apple/xnu.git] / iokit / Families / IODVDStorage / IODVDBlockStorageDriver.cpp
1 /*
2 * Copyright (c) 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 #include <IOKit/IOLib.h>
23 #include <IOKit/storage/IODVDBlockStorageDevice.h>
24 #include <IOKit/storage/IODVDBlockStorageDriver.h>
25 #include <IOKit/storage/IODVDMedia.h>
26
27 #define super IOCDBlockStorageDriver
28 OSDefineMetaClassAndStructors(IODVDBlockStorageDriver,IOCDBlockStorageDriver)
29
30 IODVDBlockStorageDevice *
31 IODVDBlockStorageDriver::getProvider() const
32 {
33 return (IODVDBlockStorageDevice *) IOService::getProvider();
34 }
35
36 /* Accept a new piece of media, doing whatever's necessary to make it
37 * show up properly to the system.
38 */
39 IOReturn
40 IODVDBlockStorageDriver::acceptNewMedia(void)
41 {
42 UInt32 mediaType = getMediaType();
43
44 if (mediaType >= kCDMediaTypeMin && mediaType <= kCDMediaTypeMax) {
45 return IOCDBlockStorageDriver::acceptNewMedia();
46 } else {
47 return IOBlockStorageDriver::acceptNewMedia();
48 }
49 }
50
51 const char *
52 IODVDBlockStorageDriver::getDeviceTypeName(void)
53 {
54 return(kIOBlockStorageDeviceTypeDVD);
55 }
56
57 IOMedia *
58 IODVDBlockStorageDriver::instantiateDesiredMediaObject(void)
59 {
60 UInt32 mediaType = getMediaType();
61
62 if (mediaType >= kCDMediaTypeMin && mediaType <= kCDMediaTypeMax) {
63 return IOCDBlockStorageDriver::instantiateDesiredMediaObject();
64 } else {
65 return(new IODVDMedia);
66 }
67 }
68
69 IOMedia *
70 IODVDBlockStorageDriver::instantiateMediaObject(UInt64 base,UInt64 byteSize,
71 UInt32 blockSize,char *mediaName)
72 {
73 IOMedia *media = NULL;
74 UInt32 mediaType = getMediaType();
75
76 if (mediaType >= kCDMediaTypeMin && mediaType <= kCDMediaTypeMax) {
77 return IOCDBlockStorageDriver::instantiateMediaObject(
78 base,byteSize,blockSize,mediaName);
79 } else {
80 media = IOBlockStorageDriver::instantiateMediaObject(
81 base,byteSize,blockSize,mediaName);
82 }
83
84 if (media) {
85 char *description = NULL;
86
87 switch (mediaType) {
88 case kDVDMediaTypeROM:
89 description = kIODVDMediaTypeROM;
90 break;
91 case kDVDMediaTypeRAM:
92 description = kIODVDMediaTypeRAM;
93 break;
94 case kDVDMediaTypeR:
95 description = kIODVDMediaTypeR;
96 break;
97 case kDVDMediaTypeRW:
98 description = kIODVDMediaTypeRW;
99 break;
100 case kDVDMediaTypePlusRW:
101 description = kIODVDMediaTypePlusRW;
102 break;
103 }
104
105 if (description) {
106 media->setProperty(kIODVDMediaTypeKey, description);
107 }
108 }
109
110 return media;
111 }
112
113 IOReturn
114 IODVDBlockStorageDriver::reportKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass,
115 const UInt32 lba,const UInt8 agid,const DVDKeyFormat keyFormat)
116 {
117 return(getProvider()->reportKey(buffer,keyClass,lba,agid,keyFormat));
118 }
119
120 IOReturn
121 IODVDBlockStorageDriver::sendKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass,
122 const UInt8 agid,const DVDKeyFormat keyFormat)
123 {
124 return(getProvider()->sendKey(buffer,keyClass,agid,keyFormat));
125 }
126
127 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 0);
128 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 1);
129 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 2);
130 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 3);
131 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 4);
132 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 5);
133 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 6);
134 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 7);
135 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 8);
136 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 9);
137 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 10);
138 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 11);
139 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 12);
140 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 13);
141 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 14);
142 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 15);
143 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 16);
144 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 17);
145 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 18);
146 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 19);
147 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 20);
148 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 21);
149 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 22);
150 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 23);
151 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 24);
152 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 25);
153 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 26);
154 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 27);
155 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 28);
156 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 29);
157 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 30);
158 OSMetaClassDefineReservedUnused(IODVDBlockStorageDriver, 31);