2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * IOCDBlockStorageDriver.h
25 * This class implements CD functionality, independent of
26 * the physical connection protocol (e.g. SCSI, ATA, USB).
28 * A protocol-specific provider implements the functionality using an appropriate
29 * protocol and commands.
32 #ifndef _IOCDBLOCKSTORAGEDRIVER_H
33 #define _IOCDBLOCKSTORAGEDRIVER_H
35 #include <IOKit/IOTypes.h>
36 #include <IOKit/storage/IOCDBlockStorageDevice.h>
37 #include <IOKit/storage/IOCDTypes.h>
38 #include <IOKit/storage/IOBlockStorageDriver.h>
41 * @defined kIOCDBlockStorageDriverClass
43 * kIOCDBlockStorageDriverClass is the name of the IOCDBlockStorageDriver class.
45 * kIOCDBlockStorageDriverClass is the name of the IOCDBlockStorageDriver class.
48 #define kIOCDBlockStorageDriverClass "IOCDBlockStorageDriver"
50 class IOCDAudioControl
;
52 class IOCDBlockStorageDevice
;
54 class IOCDBlockStorageDriver
: public IOBlockStorageDriver
{
56 OSDeclareDefaultStructors(IOCDBlockStorageDriver
)
60 static const UInt64 kBlockSizeCD
= 2352;
61 static const UInt8 kBlockTypeCD
= 0x01;
63 /* Overrides of IORegistryEntry */
65 virtual bool init(OSDictionary
* properties
);
67 /* Overrides of IOBlockStorageDriver: */
69 virtual IOReturn
ejectMedia(void);
70 virtual void executeRequest(UInt64 byteStart
,
71 IOMemoryDescriptor
*buffer
,
72 IOStorageCompletion completion
,
74 virtual const char * getDeviceTypeName(void);
75 virtual IOMedia
* instantiateDesiredMediaObject(void);
76 virtual IOMedia
* instantiateMediaObject(UInt64 base
,UInt64 byteSize
,
77 UInt32 blockSize
,char *mediaName
);
79 /* End of IOBlockStorageDriver overrides. */
82 * @function getMediaType
84 * Get the current type of media inserted in the CD drive.
86 * Certain I/O operations may not be allowed depending on the type of
87 * media currently inserted. For example, one cannot issue write operations
88 * if CD-ROM media is inserted.
90 * See the kCDMediaType constants in IOCDTypes.h.
92 virtual UInt32
getMediaType(void);
94 /* -------------------------------------------------*/
95 /* APIs implemented here, exported by IOCDMedia: */
96 /* -------------------------------------------------*/
98 virtual CDTOC
* getTOC(void);
99 virtual void readCD(IOService
*client
,
101 IOMemoryDescriptor
*buffer
,
102 CDSectorArea sectorArea
,
103 CDSectorType sectorType
,
104 IOStorageCompletion completion
);
105 virtual IOReturn
readISRC(UInt8 track
,CDISRC isrc
);
106 virtual IOReturn
readMCN(CDMCN mcn
);
108 /* end of IOCDMedia APIs */
110 /* --------------------------------------------------------*/
111 /* APIs implemented here, exported by IOCDAudioControl: */
112 /* --------------------------------------------------------*/
114 virtual IOReturn
audioPause(bool pause
);
115 virtual IOReturn
audioPlay(CDMSF timeStart
,CDMSF timeStop
);
116 virtual IOReturn
audioScan(CDMSF timeStart
,bool reverse
);
117 virtual IOReturn
audioStop();
118 virtual IOReturn
getAudioStatus(CDAudioStatus
*status
);
119 virtual IOReturn
getAudioVolume(UInt8
*leftVolume
,UInt8
*rightVolume
);
120 virtual IOReturn
setAudioVolume(UInt8 leftVolume
,UInt8 rightVolume
);
122 /* end of IOCDAudioControl APIs */
125 * Obtain this object's provider. We override the superclass's method to
126 * return a more specific subclass of IOService -- IOCDBlockStorageDevice.
127 * This method serves simply as a convenience to subclass developers.
130 virtual IOCDBlockStorageDevice
* getProvider() const;
134 /* Overrides of IOBlockStorageDriver behavior. */
136 /* When CD media is inserted, we want to create multiple nubs for the data and
137 * audio tracks, for sessions, and the entire media. We override the methods
140 virtual IOReturn
acceptNewMedia(void);
141 virtual IOReturn
decommissionMedia(bool forcible
);
143 /* End of IOBlockStorageDriver overrides. */
145 /* Internally used methods: */
147 virtual IOReturn
cacheTocInfo(void);
148 virtual UInt64
getMediaBlockSize(CDSectorArea area
,CDSectorType type
);
149 virtual void prepareRequest(UInt64 byteStart
,
150 IOMemoryDescriptor
*buffer
,
151 CDSectorArea sectorArea
,
152 CDSectorType sectorType
,
153 IOStorageCompletion completion
);
157 struct ExpansionData
{ /* */ };
158 ExpansionData
* _expansionData
;
160 IOCDAudioControl
* _acNub
;
162 /* We keep the TOC here because we'll always need it, so what the heck.
164 * There are possible "point" track entries for 0xa0..a2, 0xb0..b4, and 0xc0..0xc1.
165 * Tracks need not start at 1, as long as they're between 1 and 99, and have contiguous
172 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 0);
173 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 1);
174 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 2);
175 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 3);
176 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 4);
177 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 5);
178 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 6);
179 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 7);
180 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 8);
181 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 9);
182 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 10);
183 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 11);
184 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 12);
185 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 13);
186 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 14);
187 OSMetaClassDeclareReservedUnused(IOCDBlockStorageDriver
, 15);