Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/include/IOKit/scsi/IOSCSIReducedBlockCommandsDevice.h

Source at commit 1129 created 12 years 11 months ago.
By meklort, Change options.o so that it reloads the system config as well. Also change it so that it uses that config for variables (NOTE: if the calue exists in chameleonConfig, it's used instead.
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_IO_SCSI_REDUCED_BLOCK_COMMANDS_DEVICE_H_
26#define _IOKIT_IO_SCSI_REDUCED_BLOCK_COMMANDS_DEVICE_H_
27
28#if defined(KERNEL) && defined(__cplusplus)
29
30
31//-----------------------------------------------------------------------------
32//Includes
33//-----------------------------------------------------------------------------
34
35// General IOKit headers
36#include <IOKit/IOLib.h>
37#include <IOKit/IOMemoryDescriptor.h>
38
39// Generic IOKit storage related headers
40#include <IOKit/storage/IOStorage.h>
41
42// SCSI Architecture Model Family includes
43#include <IOKit/scsi/IOSCSIPrimaryCommandsDevice.h>
44
45
46//-----------------------------------------------------------------------------
47//Constants
48//-----------------------------------------------------------------------------
49
50
51// RBC power states as defined in T10:1240D SCSI Reduced Block Commands (RBC)
52// Revision 10a, August 18, 1999, page 13.
53enum
54{
55kRBCPowerStateSystemSleep= 0,
56kRBCPowerStateSleep = 1,
57kRBCPowerStateStandby = 2,
58kRBCPowerStateIdle= 3,
59kRBCPowerStateActive= 4,
60kRBCNumPowerStates= 5
61};
62
63enum
64{
65kMediaStateUnlocked= 0,
66kMediaStateLocked = 1
67};
68
69#define kCapacityDataBufferSize8
70
71// Forward declaration for the SCSIReducedBlockCommands that is used internally by the
72// IOSCSIReducedBlockCommandsDevice class.
73class SCSIReducedBlockCommands;
74
75//-----------------------------------------------------------------------------
76//Class Declaration
77//-----------------------------------------------------------------------------
78
79class IOSCSIReducedBlockCommandsDevice : public IOSCSIPrimaryCommandsDevice
80{
81
82OSDeclareAbstractStructors ( IOSCSIReducedBlockCommandsDevice );
83
84private:
85
86#ifndef __LP64__
87
88 SCSIReducedBlockCommands *fSCSIReducedBlockCommandObject;
89 SCSIReducedBlockCommands *GetSCSIReducedBlockCommandObject ( void );
90
91#endif/* !__LP64__ */
92
93static voidAsyncReadWriteComplete ( SCSITaskIdentifier completedTask );
94
95protected:
96
97 // Reserve space for future expansion.
98 struct IOSCSIReducedBlockCommandsDeviceExpansionData
99{
100IONotifier *fPowerDownNotifier;
101 boolfMediumRemovalPrevented;
102 boolfKnownManualEject;
103 UInt32fPollingMode;
104boolfProtocolSpecificPowerControl;
105};
106 IOSCSIReducedBlockCommandsDeviceExpansionData * fIOSCSIReducedBlockCommandsDeviceReserved;
107
108#define fPowerDownNotifierfIOSCSIReducedBlockCommandsDeviceReserved->fPowerDownNotifier
109#define fMediumRemovalPreventedfIOSCSIReducedBlockCommandsDeviceReserved->fMediumRemovalPrevented
110#define fKnownManualEjectfIOSCSIReducedBlockCommandsDeviceReserved->fKnownManualEject
111#define fPollingModefIOSCSIReducedBlockCommandsDeviceReserved->fPollingMode
112#define fProtocolSpecificPowerControlfIOSCSIReducedBlockCommandsDeviceReserved->fProtocolSpecificPowerControl
113
114boolfMediaChanged;
115boolfMediaPresent;
116
117// The byte count of each physical block on the media.
118UInt32fMediaBlockSize;
119
120// The total number of blocks of mediaBlockSize on the media.
121UInt32fMediaBlockCount;
122
123// Flags used to indicate device feature
124boolfMediaIsRemovable;
125boolfMediaIsWriteProtected;
126
127thread_call_tfPollingThread;
128
129enum
130{
131kPollingMode_Suspended= 0,
132kPollingMode_NewMedia = 1,
133kPollingMode_MediaRemoval= 2
134};
135
136virtual void CreateStorageServiceNub ( void );
137virtual boolDetermineDeviceCharacteristics ( void );
138virtual voidPollForMedia ( void );
139virtual voidEnablePolling ( void );
140virtual voidDisablePolling ( void );
141virtual voidCheckWriteProtection ( void );
142virtual voidSetMediaCharacteristics ( UInt32 blockSize, UInt32 blockCount );
143 virtual voidResetMediaCharacteristics ( void );
144virtual boolClearNotReadyStatus ( void );
145
146virtual IOReturnIssueRead ( IOMemoryDescriptor *buffer,
147UInt64startBlock,
148UInt64blockCount );
149
150virtual IOReturnIssueWrite ( IOMemoryDescriptor*buffer,
151 UInt64startBlock,
152 UInt64blockCount );
153
154virtual IOReturnIssueRead ( IOMemoryDescriptor *buffer,
155UInt64startBlock,
156UInt64blockCount,
157void *clientData );
158
159virtual IOReturnIssueWrite ( IOMemoryDescriptor *buffer,
160 UInt64startBlock,
161 UInt64blockCount,
162 void *clientData );
163
164#ifndef __LP64__
165
166// This method will retreive the SCSI Primary Command Set object for
167// the class. For subclasses, this will be overridden using a
168// dynamic cast on the subclasses base command set object.
169virtual SCSIPrimaryCommands *GetSCSIPrimaryCommandObject ( void );
170
171#endif/* !__LP64__ */
172
173// ----- Power Management Support ------
174
175// We override this method to set our power states and register ourselves
176// as a power policy maker.
177virtual void InitializePowerManagement ( IOService * provider );
178
179// We override this method so that when we register for power management,
180// we go to our active power state (which the drive is definitely in
181// at startup time).
182virtual UInt32GetInitialPowerState ( void );
183
184// We override this method in order to provide the number of transitions
185// from Fully active to Sleep state so that the idle timer can be adjusted
186// to the appropriate time period based on the disk spindown time set in
187// the Energy Saver prefs panel.
188virtual UInt32GetNumberOfPowerStateTransitions ( void );
189
190// The TicklePowerManager method is called to tell the power manager that the
191// device needs to be in a certain power state to handle requests.
192virtual voidTicklePowerManager ( void );
193
194// The HandlePowerChange method is the state machine for power management.
195// It is guaranteed to be on its own thread of execution (different from
196// the power manager thread AND the workloop thread. This routine can
197// send sync or async calls to the drive without worrying about threading
198// issues.
199virtual voidHandlePowerChange ( void );
200
201// The HandleCheckPowerState (void) method is on the serialized side of the command
202// gate and can change member variables safely without multi-threading issues.
203// It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState )
204// with the max power state the class registered with.
205virtual voidHandleCheckPowerState ( void );
206
207// The CheckMediaPresence method is called to see if the media which we
208// anticipated being there is still there.
209virtual boolCheckMediaPresence ( void );
210
211virtual boolInitializeDeviceSupport ( void );
212virtual voidStartDeviceSupport ( void );
213virtual voidSuspendDeviceSupport ( void );
214virtual voidResumeDeviceSupport ( void );
215virtual voidStopDeviceSupport ( void );
216virtual voidTerminateDeviceSupport ( void );
217
218virtual void free ( void );
219
220#ifndef __LP64__
221
222virtual boolCreateCommandSetObjects ( void );
223virtual voidFreeCommandSetObjects ( void );
224
225#endif/* !__LP64__ */
226
227public:
228
229virtual IOReturnSyncReadWrite ( IOMemoryDescriptor *buffer,
230UInt64startBlock,
231UInt64blockCount );
232
233virtual IOReturnAsyncReadWrite (IOMemoryDescriptor *buffer,
234UInt64block,
235UInt64nblks,
236void *clientData );
237
238
239virtual IOReturnEjectTheMedia ( void );
240virtual IOReturnFormatMedia ( UInt64 byteCapacity );
241virtual UInt32GetFormatCapacities ( UInt64 * capacities,
242UInt32 capacitiesMaxCount ) const;
243virtual IOReturnLockUnlockMedia ( bool doLock );
244virtual IOReturnSynchronizeCache ( void );
245virtual IOReturnReportBlockSize ( UInt64 * blockSize );
246virtual IOReturnReportEjectability ( bool * isEjectable );
247virtual IOReturnReportLockability ( bool * isLockable );
248virtual IOReturnReportPollRequirements ( bool * pollIsRequired,
249 bool * pollIsExpensive );
250virtual IOReturnReportMaxReadTransfer ( UInt64 blockSize,
251 UInt64 * max );
252virtual IOReturnReportMaxValidBlock ( UInt64 * maxBlock );
253virtual IOReturnReportMaxWriteTransfer ( UInt64blockSize,
254UInt64 * max );
255virtual IOReturnReportMediaState ( bool * mediaPresent,
256bool * changed );
257virtual IOReturnReportRemovability ( bool * isRemovable );
258virtual IOReturnReportWriteProtection ( bool * isWriteProtected );
259
260static voidsPollForMedia ( void * pdtDriver, void * refCon );
261
262
263protected:
264
265
266// The FORMAT_UNIT command as defined in section 5.1
267virtual bool FORMAT_UNIT (
268SCSITaskIdentifierrequest,
269SCSICmdField1BitIMMED,
270 SCSICmdField1BitPROGRESS,
271 SCSICmdField1BitPERCENT_TIME,
272 SCSICmdField1BitINCREMENT );
273
274// The INQUIRY command as defined in SPC-2 w/o CONTROL byte
275virtual bool INQUIRY (
276SCSITaskIdentifierrequest,
277IOMemoryDescriptor *dataBuffer,
278SCSICmdField1BitCMDDT,
279SCSICmdField1BitEVPD,
280SCSICmdField1BytePAGE_OR_OPERATION_CODE,
281SCSICmdField1ByteALLOCATION_LENGTH );
282
283// The MODE_SELECT(6) command as defined in SPC-2 w/o CONTROL byte
284virtual bool MODE_SELECT_6 (
285SCSITaskIdentifierrequest,
286IOMemoryDescriptor *dataBuffer,
287SCSICmdField1Bit PF,
288SCSICmdField1Bit SP,
289SCSICmdField1Byte PARAMETER_LIST_LENGTH );
290
291// The MODE_SENSE(6) command as defined in SPC-2 w/o CONTROL byte
292virtual bool MODE_SENSE_6 (
293SCSITaskIdentifierrequest,
294IOMemoryDescriptor *dataBuffer,
295SCSICmdField1Bit DBD,
296 SCSICmdField2Bit PC,
297 SCSICmdField6Bit PAGE_CODE,
298 SCSICmdField1Byte ALLOCATION_LENGTH );
299
300// The PERSISTENT_RESERVE_IN command as defined in SPC-2 w/o CONTROL byte
301virtual bool PERSISTENT_RESERVE_IN (
302SCSITaskIdentifierrequest,
303IOMemoryDescriptor *dataBuffer,
304 SCSICmdField5Bit SERVICE_ACTION,
305 SCSICmdField2Byte ALLOCATION_LENGTH );
306
307// The PERSISTENT_RESERVE_OUT command as defined in SPC-2 w/o CONTROL byte
308virtual bool PERSISTENT_RESERVE_OUT (
309SCSITaskIdentifierrequest,
310IOMemoryDescriptor *dataBuffer,
311 SCSICmdField5BitSERVICE_ACTION,
312 SCSICmdField4BitSCOPE,
313 SCSICmdField4BitTYPE );
314
315// The PREVENT_ALLOW_MEDIUM_REMOVAL command as defined in SPC-2 w/o CONTROL byte
316virtual bool PREVENT_ALLOW_MEDIUM_REMOVAL (
317SCSITaskIdentifierrequest,
318 SCSICmdField2BitPREVENT );
319
320 // The READ_10 command as defined in section 5.2
321virtual bool READ_10 (
322SCSITaskIdentifierrequest,
323IOMemoryDescriptor *dataBuffer,
324UInt32blockSize,
325SCSICmdField4ByteLOGICAL_BLOCK_ADDRESS,
326SCSICmdField2ByteTRANSFER_LENGTH );
327
328// The READ_CAPACITY command as defined in section 5.3
329virtual bool READ_CAPACITY (
330SCSITaskIdentifierrequest,
331IOMemoryDescriptor *dataBuffer );
332
333// The RELEASE(6) command as defined in SPC-2 w/o CONTROL byte
334virtual bool RELEASE_6 (
335SCSITaskIdentifierrequest );
336
337// The REQUEST_SENSE command as defined in SPC-2 w/o CONTROL byte
338virtual bool REQUEST_SENSE (
339SCSITaskIdentifierrequest,
340IOMemoryDescriptor *dataBuffer,
341SCSICmdField1Byte ALLOCATION_LENGTH );
342
343// The RESERVE(6) command as defined in SPC-2 w/o CONTROL byte
344virtual bool RESERVE_6 (
345SCSITaskIdentifierrequest );
346
347// The START_STOP_UNIT command as defined in section 5.4
348virtual bool START_STOP_UNIT (
349SCSITaskIdentifierrequest,
350SCSICmdField1BitIMMED,
351SCSICmdField4BitPOWER_CONDITIONS,
352SCSICmdField1BitLEOJ,
353SCSICmdField1BitSTART );
354
355// The SYNCRONIZE_CACHE command as defined in section 5.5
356virtual bool SYNCHRONIZE_CACHE (
357SCSITaskIdentifierrequest );
358
359// The TEST_UNIT_READY command as defined in SPC-2 w/o CONTROL byte
360virtual bool TEST_UNIT_READY (
361SCSITaskIdentifierrequest );
362
363// The VERIFY command as defined in section 5.7
364virtual bool VERIFY (
365SCSITaskIdentifierrequest,
366SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
367SCSICmdField2Byte VERIFICATION_LENGTH );
368
369// The WRITE_10 commandas defined in section 5.6
370virtual bool WRITE_10 (
371SCSITaskIdentifierrequest,
372IOMemoryDescriptor *dataBuffer,
373UInt32blockSize,
374SCSICmdField1BitFUA,
375SCSICmdField4Byte LOGICAL_BLOCK_ADDRESS,
376SCSICmdField2Byte TRANSFER_LENGTH );
377
378// The WRITE_BUFFER command as defined in SPC-2 w/o CONTROL byte
379virtual bool WRITE_BUFFER (
380SCSITaskIdentifierrequest,
381IOMemoryDescriptor *dataBuffer,
382SCSICmdField4Bit MODE,
383SCSICmdField1Byte BUFFER_ID,
384SCSICmdField3Byte BUFFER_OFFSET,
385SCSICmdField3Byte PARAMETER_LIST_LENGTH );
386
387
388
389/* Added with 10.2 */
390OSMetaClassDeclareReservedUsed ( IOSCSIReducedBlockCommandsDevice, 1 );
391
392public:
393
394virtual IOReturnPowerDownHandler (void * refCon,
395UInt32 messageType,
396IOService * provider,
397void * messageArgument,
398vm_size_t argSize );
399
400
401/* Added with 10.2 */
402OSMetaClassDeclareReservedUsed ( IOSCSIReducedBlockCommandsDevice, 2 );
403
404protected:
405
406virtualvoidSetMediaIcon ( void );
407
408
409/* Added with 10.3.3 */
410OSMetaClassDeclareReservedUsed ( IOSCSIReducedBlockCommandsDevice, 3 );
411
412protected:
413
414virtualvoid AsyncReadWriteCompletion ( SCSITaskIdentifier completedTask );
415
416
417private:
418
419// Space reserved for future expansion.
420OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 4 );
421OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 5 );
422OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 6 );
423OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 7 );
424OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 8 );
425OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 9 );
426OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 10 );
427OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 11 );
428OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 12 );
429OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 13 );
430OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 14 );
431OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 15 );
432OSMetaClassDeclareReservedUnused ( IOSCSIReducedBlockCommandsDevice, 16 );
433
434};
435
436#endif/* defined(KERNEL) && defined(__cplusplus) */
437
438#endif /* _IOKIT_IO_SCSI_REDUCED_BLOCK_COMMANDS_DEVICE_H_ */
439

Archive Download this file

Revision: 1129