Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/i386/include/IOKit/usb/IOUSBMassStorageUFISubclass.h

1/*
2 * Copyright (c) 1998-2009 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
25#ifndef _IOKIT_IOUSBMASSSTORAGEUFISUBCLASS_H
26#define _IOKIT_IOUSBMASSSTORAGEUFISUBCLASS_H
27
28// This class' header file
29#include <IOKit/usb/IOUSBMassStorageClass.h>
30#include <IOKit/scsi/IOSCSIPrimaryCommandsDevice.h>
31
32
33#pragma mark -
34#pragma mark IOUSBMassStorageUFIDevice declaration
35
36class IOUSBMassStorageUFIDevice : public IOSCSIPrimaryCommandsDevice
37{
38 OSDeclareDefaultStructors(IOUSBMassStorageUFIDevice)
39
40private:
41static voidAsyncReadWriteComplete( SCSITaskIdentifiercompletedTask );
42
43protected:
44 // Reserve space for future expansion.
45 struct IOUSBMassStorageUFIDeviceExpansionData
46{
47};
48 IOUSBMassStorageUFIDeviceExpansionData *fIOUSBMassStorageUFIDeviceReserved;
49
50// ---- Medium Characteristics ----
51boolfMediumPresent;
52
53// The byte count of each physical block on the medium.
54UInt32fMediumBlockSize;
55
56// The total number of blocks of fMediumBlockSize on the medium.
57UInt32fMediumBlockCount;
58
59// Whether the installed medium is protected from writes
60boolfMediumIsWriteProtected;
61
62// Polling thread variables
63thread_call_tfPollingThread;
64UInt32fPollingMode;
65enum
66{
67kPollingMode_Suspended= 0,
68kPollingMode_NewMedia = 1,
69kPollingMode_MediaRemoval= 2
70};
71
72// ---- Methods for controlling the current state of device support ----
73virtual boolInitializeDeviceSupport( void );
74virtual void StartDeviceSupport ( void );
75virtual voidSuspendDeviceSupport( void );
76virtual voidResumeDeviceSupport( void );
77virtual void StopDeviceSupport ( void );
78virtual voidTerminateDeviceSupport( void );
79
80// ---- Methods used for misc ----
81virtual boolClearNotReadyStatus( void );
82virtual void CreateStorageServiceNub( void );
83virtual boolDetermineDeviceCharacteristics( void );
84
85// ---- Methods used for controlling the polling thread ----
86virtual voidProcessPoll( void );
87virtual voidEnablePolling( void );
88virtual voidDisablePolling( void );
89
90// ---- Main and support methods for polling for new Media ----
91virtual voidPollForNewMedia( void );
92virtual boolDetermineMediaPresence( void );
93virtual boolDetermineMediumCapacity(
94UInt64 * blockSize,
95UInt64 * blockCount );
96virtual boolDetermineMediumWriteProtectState( void );
97
98// ---- Main and support methods for polling for Media removal ----
99virtual voidPollForMediaRemoval( void );
100
101// ---- Methods used for power managment ----
102virtual UInt32GetInitialPowerState ( void );
103virtual void InitializePowerManagement ( IOService * provider );
104virtual voidHandlePowerChange ( void );
105virtual voidHandleCheckPowerState ( void );
106virtual voidTicklePowerManager ( void );
107virtual UInt32GetNumberOfPowerStateTransitions ( void );
108
109// ---- Methods used for handling medium characteristics ----
110 virtual voidSetMediumCharacteristics(
111 UInt32 blockSize,
112 UInt32 blockCount );
113
114virtual voidResetMediumCharacteristics( void );
115
116virtual IOReturnIssueRead(
117IOMemoryDescriptor *buffer,
118 UInt64startBlock,
119 UInt64blockCount );
120
121virtual IOReturnIssueRead(
122IOMemoryDescriptor *buffer,
123 UInt64startBlock,
124 UInt64blockCount,
125 void * clientData );
126
127
128virtual IOReturnIssueWrite(
129IOMemoryDescriptor *buffer,
130 UInt64startBlock,
131 UInt64blockCount );
132
133virtual IOReturnIssueWrite(
134IOMemoryDescriptor *buffer,
135 UInt64startBlock,
136 UInt64blockCount,
137void * clientData );
138
139public:
140
141static voidsProcessPoll( void * pdtDriver, void * refCon );
142
143// Interface to the UFI Storage Services Driver
144// ---- Methods for controlling the device ----
145virtual IOReturnSyncReadWrite(
146IOMemoryDescriptor *buffer,
147UInt64startBlock,
148UInt64blockCount,
149UInt64blockSize );
150
151virtual IOReturnAsyncReadWrite(
152IOMemoryDescriptor *buffer,
153UInt64startBlock,
154UInt64blockCount,
155UInt64blockSize,
156void * clientData );
157
158// ---- Methods for controlling medium state ----
159virtual IOReturnEjectTheMedium( void );
160
161// ---- Methods for controlling media format ----
162virtual IOReturnFormatMedium(
163UInt64 blockCount,
164UInt64 blockSize );
165virtual UInt32GetFormatCapacities(
166UInt64 * capacities,
167 UInt32 capacitiesMaxCount ) const;
168
169// ---- Query methods to report device characteristics ----
170// Report the maximum number of blocks that the device can handle per
171// read or write. A value of 0 (zero) indicates there is no limit aside
172// from the size of the method's return parameter.
173virtual UInt64ReportDeviceMaxBlocksReadTransfer( void );
174virtual UInt64ReportDeviceMaxBlocksWriteTransfer( void );
175
176// ---- Query methods to report installed medium characteristics ----
177virtual UInt64ReportMediumBlockSize( void );
178virtual UInt64ReportMediumTotalBlockCount( void );
179virtual boolReportMediumWriteProtection( void );
180
181// Methods for getting device information strings
182virtual char *GetVendorString( void );
183virtual char *GetProductString( void );
184virtual char *GetRevisionString( void );
185OSDictionary *GetProtocolCharacteristicsDictionary ( void );
186OSDictionary *GetDeviceCharacteristicsDictionary ( void );
187
188protected:
189// Utility methods used by all SCSI Command Set objects
190
191// isParameterValid methods are used to validate that the parameter passed into
192// the command methods are of the correct value.
193
194// Validate Parameter used for 1 bit to 1 byte paramaters
195 bool IsParameterValid(
196SCSICmdField1Byte param,
197SCSICmdField1Byte mask );
198
199// Validate Parameter used for 9 bit to 2 byte paramaters
200bool IsParameterValid(
201SCSICmdField2Byte param,
202SCSICmdField2Byte mask );
203
204// Validate Parameter used for 17 bit to 4 byte paramaters
205bool IsParameterValid(
206SCSICmdField4Byte param,
207SCSICmdField4Byte mask );
208
209// UFI Required Commands
210virtual bool FORMAT_UNIT(
211SCSITaskIdentifierrequest,
212 IOMemoryDescriptor *dataBuffer,
213 IOByteCountdefectListSize,
214 SCSICmdField1Byte TRACK_NUMBER,
215 SCSICmdField2Byte INTERLEAVE );
216
217virtual boolINQUIRY(
218SCSITaskIdentifierrequest,
219 IOMemoryDescriptor *dataBuffer,
220 SCSICmdField1Byte PAGE_OR_OPERATION_CODE,
221 SCSICmdField1Byte ALLOCATION_LENGTH );
222
223 virtual boolMODE_SELECT_10(
224SCSITaskIdentifierrequest,
225 IOMemoryDescriptor *dataBuffer,
226 SCSICmdField1Bit PF,
227 SCSICmdField1Bit SP,
228 SCSICmdField2Byte PARAMETER_LIST_LENGTH );
229
230 virtual boolMODE_SENSE_10(
231SCSITaskIdentifierrequest,
232 IOMemoryDescriptor *dataBuffer,
233 SCSICmdField1Bit DBD,
234 SCSICmdField2Bit PC,
235 SCSICmdField6Bit PAGE_CODE,
236 SCSICmdField2Byte PARAMETER_LIST_LENGTH );
237
238 virtual boolPREVENT_ALLOW_MEDIUM_REMOVAL(
239SCSITaskIdentifierrequest,
240 SCSICmdField1Bit PREVENT );
241
242virtual bool READ_10(
243SCSITaskIdentifierrequest,
244 IOMemoryDescriptor *dataBuffer,
245 UInt32blockSize,
246 SCSICmdField1Bit DPO,
247 SCSICmdField1Bit FUA,
248SCSICmdField1Bit RELADR,
249SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
250SCSICmdField2Byte TRANSFER_LENGTH );
251
252virtual bool READ_12(
253SCSITaskIdentifierrequest,
254 IOMemoryDescriptor *dataBuffer,
255 UInt32blockSize,
256 SCSICmdField1Bit DPO,
257 SCSICmdField1Bit FUA,
258SCSICmdField1Bit RELADR,
259SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
260SCSICmdField4Byte TRANSFER_LENGTH );
261
262virtual bool READ_CAPACITY(
263SCSITaskIdentifierrequest,
264 IOMemoryDescriptor *dataBuffer,
265 SCSICmdField1Bit RELADR,
266SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
267SCSICmdField1Bit PMI );
268
269virtual bool READ_FORMAT_CAPACITIES(
270SCSITaskIdentifierrequest,
271 IOMemoryDescriptor *dataBuffer,
272 SCSICmdField2Byte ALLOCATION_LENGTH );
273
274virtual bool REQUEST_SENSE(
275SCSITaskIdentifierrequest,
276 IOMemoryDescriptor *dataBuffer,
277 SCSICmdField1Byte ALLOCATION_LENGTH );
278
279virtual bool REZERO_UNIT(
280SCSITaskIdentifierrequest );
281
282virtual bool SEEK(
283SCSITaskIdentifierrequest,
284 SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS );
285
286virtual bool SEND_DIAGNOSTICS(
287SCSITaskIdentifierrequest,
288SCSICmdField1Bit PF,
289SCSICmdField1Bit SELF_TEST,
290SCSICmdField1Bit DEF_OFL,
291SCSICmdField1Bit UNIT_OFL );
292
293virtual bool START_STOP_UNIT(
294SCSITaskIdentifierrequest,
295SCSICmdField1Bit IMMED,
296SCSICmdField1Bit LOEJ,
297SCSICmdField1Bit START );
298
299 virtual bool TEST_UNIT_READY(
300SCSITaskIdentifierrequest );
301
302virtual bool VERIFY(
303SCSITaskIdentifierrequest,
304SCSICmdField1Bit DPO,
305SCSICmdField1Bit BYTCHK,
306SCSICmdField1Bit RELADR,
307SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
308SCSICmdField2Byte VERIFICATION_LENGTH );
309
310virtual bool WRITE_10(
311SCSITaskIdentifierrequest,
312 IOMemoryDescriptor *dataBuffer,
313 UInt32blockSize,
314 SCSICmdField1Bit DPO,
315 SCSICmdField1Bit FUA,
316SCSICmdField1Bit RELADR,
317SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
318SCSICmdField2Byte TRANSFER_LENGTH );
319
320virtual bool WRITE_12(
321SCSITaskIdentifierrequest,
322IOMemoryDescriptor *dataBuffer,
323 UInt32blockSize,
324 SCSICmdField1Bit DPO,
325SCSICmdField1Bit EBP,
326SCSICmdField1Bit RELADR,
327SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
328SCSICmdField4Byte TRANSFER_LENGTH );
329
330virtual bool WRITE_AND_VERIFY(
331SCSITaskIdentifierrequest,
332 IOMemoryDescriptor *dataBuffer,
333 UInt32blockSize,
334 SCSICmdField1Bit DPO,
335 SCSICmdField1Bit BYTCHK,
336 SCSICmdField1Bit RELADR,
337 SCSICmdField4ByteLOGICAL_BLOCK_ADDRESS,
338 SCSICmdField2Byte TRANSFER_LENGTH );
339};
340
341
342#pragma mark -
343#pragma mark IOUSBMassStorageUFISubclass declaration
344
345
346class IOUSBMassStorageUFISubclass : public IOUSBMassStorageClass
347{
348 OSDeclareDefaultStructors(IOUSBMassStorageUFISubclass)
349
350protected:
351virtualboolBeginProvidedServices( void );
352virtualboolEndProvidedServices( void );
353};
354
355#endif _IOKIT_IOUSBMASSSTORAGEUFISUBCLASS_H
356

Archive Download this file

Revision: 2225