Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Modules/i386/include/IOKit/scsi/IOSCSIProtocolInterface.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#ifndef _IOKIT_IO_SCSI_PROTOCOL_INTERFACE_H_
25#define _IOKIT_IO_SCSI_PROTOCOL_INTERFACE_H_
26
27
28/*! @header SCSI Protocol Interface
29@discussion
30This file contains definitions for the IOSCSIProtocolInterface class,
31SCSI Protocol Features used by this interface, and additional constants
32used by this interface.
33*/
34
35
36//-----------------------------------------------------------------------------
37//Includes
38//-----------------------------------------------------------------------------
39
40#include <IOKit/storage/IOStorageDeviceCharacteristics.h>
41
42
43//-----------------------------------------------------------------------------
44//Constants
45//-----------------------------------------------------------------------------
46
47/*
48SCSI Device Characteristics - Defined between SCSI Application Layer and
49 SCSI Protocol Layer only.
50*/
51
52/*!
53@constant kIOPropertySCSIDeviceCharacteristicsKey
54@discussion
55This key is used to define SCSI Device Characteristics for a particular device.
56It is the key for the dictionary containing the keys of characteristics. These keys
57are only defined between the SCSI Protocol Layer and the SCSI Applicaiton Layer. Some
58properties may be copied from this dictionary to the more generic Device Characteristics
59or Protocol Characteristics dictionaries.
60*/
61#define kIOPropertySCSIDeviceCharacteristicsKey"SCSI Device Characteristics"
62
63/*!
64@constant kIOPropertySCSIInquiryLengthKey
65@discussion
66This key is used to define a default INQUIRY length to issue to the device. The
67value is a UInt32 corresponding to the number of bytes to request in the INQUIRY
68command.
69*/
70#define kIOPropertySCSIInquiryLengthKey"Inquiry Length"
71
72/*!
73@constant kIOPropertySCSIManualEjectKey
74@discussion
75This key is used to indicate that the device is known to be a manual ejectable media
76device. This property overrides all of the driver checks for determining this capability.
77This property is a string, although if it exists it should always be true.
78*/
79#define kIOPropertySCSIManualEjectKey"Manual Eject"
80
81/*!
82@constant kIOPropertyReadTimeOutDurationKey
83@discussion
84This key is used to define the Read Time Out for a particular device.
85This property overrides all of the protocol defaults.
86This property is a value, in milliseconds.
87*/
88#define kIOPropertyReadTimeOutDurationKey"Read Time Out Duration"
89
90/*!
91@constant kIOPropertyWriteTimeOutDurationKey
92@discussion
93This key is used to define the Write Time Out for a particular device.
94This property overrides all of the protocol defaults.
95This property is a value, in milliseconds.
96*/
97#define kIOPropertyWriteTimeOutDurationKey"Write Time Out Duration"
98
99/*!
100@constant kIOPropertyRetryCountKey
101@discussion
102This key is used to define the number of Read/Write retries for a particular device.
103This property overrides all of the protocol defaults.
104The value is a UInt32 corresponding to the number of retries.
105*/
106#define kIOPropertyRetryCountKey"Retry Count"
107
108/*!
109 @constant kIOPropertyAutonomousSpinDownKey
110 @discussion
111 This key is used to indicate that the device is known to have its own internal logic
112 for idle disk spin down. This key is used to mark device which respon poorly to our
113 efforts to manually spin down or spin up the device when it is already in the desired
114 state.
115 */
116#define kIOPropertyAutonomousSpinDownKey"Autonomous Spin Down"
117
118/*!
119 @constant kIOPropertyEjectRequireStartStopUnitKey
120 @discussion
121 This key is used to indicate that while the device may have failed PREVENT_ALLOW_MEDIUM
122 REMOVAL it still requires a START_STOP_UNIT to eject/unload media.
123 */
124#define kIOPropertyEjectRequireStartStopUnitKey"Eject Requires START_STOP_UNIT"
125
126#if defined(KERNEL) && defined(__cplusplus)
127
128
129/*!
130@constant kCFBundleIdentifierKey
131@discussion
132Property key for CFBundleIdentifier.
133*/
134#define kCFBundleIdentifierKey"CFBundleIdentifier"
135
136/*!
137@constant kIOSCSIArchitectureBundleIdentifierKey
138@discussion
139IOSCSIArchitectureModelFamily's CFBundle identifier.
140*/
141#define kIOSCSIArchitectureBundleIdentifierKey"com.apple.iokit.IOSCSIArchitectureModelFamily"
142
143
144// General kernel headers
145#include <kern/thread.h>
146
147// General IOKit headers
148#include <IOKit/IOLib.h>
149#include <IOKit/IOService.h>
150#include <IOKit/IOCommandGate.h>
151#include <IOKit/IOWorkLoop.h>
152
153// SCSI Architecture Model Family includes
154#include <IOKit/scsi/SCSITask.h>
155
156
157/*!
158@enum SCSI Protocol Interface Device Notification values
159@discussion
160Message values for SCSI Protocol Interface Device Notifications.
161@constant kSCSIProtocolNotification_DeviceRemoved
162Private message sent between a SCSI protocol service provider and
163SCSI application layer driver to indicate device removal.
164@constant kSCSIProtocolNotification_VerifyDeviceState
165Private message sent between a SCSI protocol service provider and
166SCSI application layer driver to indicate device state may have
167changed and the device state should be re-verified by the SCSI
168Application Layer driver. An example would be a bus reset which clears
169the tray locking state of an ATAPI device.
170@constant kSCSIServicesNotification_ExclusivityChanged
171Message sent when a change in exclusivity state occurs. Usually in
172response to acquiring/releasing exclusive access to a device via a user client.
173*/
174enum
175{
176kSCSIProtocolNotification_DeviceRemoved= 0x69000010,
177kSCSIProtocolNotification_VerifyDeviceState= 0x69000020,
178kSCSIServicesNotification_ExclusivityChanged= 0x69000030
179};
180
181
182/*!
183@typedef SCSIProtocolFeature
184@discussion
185Typedef for SCSIProtocolFeature, a 32-bit quantity.
186*/
187typedef UInt32 SCSIProtocolFeature;
188
189/*!
190@enum SCSI Protocol Features
191@discussion
192The list of SCSI Protocol Features currently supported.
193*/
194enum
195{
196
197/*!
198@constant kSCSIProtocolFeature_ACA Not yet used.
199*/
200kSCSIProtocolFeature_ACA= 1,
201
202/*!
203@constant kSCSIProtocolFeature_CPUInDiskMode Used to determine
204if the SCSI Protocol Services Driver supports a CPU which is in
205target disk mode.
206*/
207kSCSIProtocolFeature_CPUInDiskMode= 2,
208
209/*!
210@constant kSCSIProtocolFeature_ProtocolSpecificPolling Used
211to determine if the SCSI Protocol Services Driver supports
212protocol specific polling for media. This is used for low-power
213polling specifically for ATAPI devices on ATA buses
214*/
215kSCSIProtocolFeature_ProtocolSpecificPolling= 3,
216
217/*!
218@constant kSCSIProtocolFeature_ProtocolSpecificSleepCommand Used
219to determine if the SCSI Protocol Services Driver supports
220protocol specific sleep commands to a drive. This is used for
221sleeping drives specifically ATAPI devices on ATA buses.
222*/
223kSCSIProtocolFeature_ProtocolSpecificSleepCommand= 4,
224
225/*!
226@constant kSCSIProtocolFeature_GetMaximumLogicalUnitNumber If
227the SCSI Protocol Services Driver supports logical units, it will
228report the maximum addressable ID that it supports in the UInt32 pointer
229that is passed in as the serviceValue. If only one unit is supported,
230the driver should return false for this query.
231*/
232kSCSIProtocolFeature_GetMaximumLogicalUnitNumber= 5,
233
234/*!
235@constant kSCSIProtocolFeature_MaximumReadBlockTransferCount If
236the SCSI Protocol Services Driver has a maximum number of
237blocks that can be transfered in a read request, it will return
238true to this query and return the block count in the UInt32 pointer
239that is passed in as the serviceValue.
240*/
241kSCSIProtocolFeature_MaximumReadBlockTransferCount= 6,
242
243/*!
244@constant kSCSIProtocolFeature_MaximumWriteBlockTransferCount If
245the SCSI Protocol Services Driver has a maximum number of
246blocks that can be transferred in a write request, it will return
247true to this query and return the block count in the UInt32 pointer
248that is passed in as the serviceValue.
249*/
250kSCSIProtocolFeature_MaximumWriteBlockTransferCount= 7,
251
252/*!
253@constant kSCSIProtocolFeature_MaximumReadTransferByteCount If
254the SCSI Protocol Services Driver has a maximum byte count
255that can be transferred in a read request, it will return
256true to this query and return the byte count in the UInt64 pointer
257that is passed in as the serviceValue.
258*/
259kSCSIProtocolFeature_MaximumReadTransferByteCount= 8,
260
261/*!
262@constant kSCSIProtocolFeature_MaximumWriteTransferByteCount If
263the SCSI Protocol Services Driver has a maximum byte count
264that can be transferred in a write request, it will return
265true to this query and return the byte count in the UInt64 pointer
266that is passed in as the serviceValue.
267*/
268kSCSIProtocolFeature_MaximumWriteTransferByteCount= 9,
269
270/*!
271@constant kSCSIProtocolFeature_SubmitDefaultInquiryData If
272the SCSI Protocol Services Driver needs any extra information to
273make any negotiation settings from the standard INQUIRY data, this
274will be called to set that appropriately. The serviceValue will
275point to a SCSICmd_INQUIRY_StandardData buffer. The size
276of the buffer depends on the SCSI Device Characteristics
277dictionary for the device or bus. If there is no
278kIOPropertySCSIInquiryLengthKey value set in the dictionary
279or if it doesn't exist, then the size of the data will be
280the size of the full amount of Inquiry retrieved from the device.
281*/
282kSCSIProtocolFeature_SubmitDefaultInquiryData= 10,
283
284/*!
285@constant kSCSIProtocolFeature_ProtocolAlwaysReportsAutosenseData If
286the SCSI Protocol Services Driver always reports available
287autosense data when a kSCSITaskStatus_CHECK_CONDITION is set,
288then the protocol layer should return true. E.g. FireWire
289transport drivers should respond true to this.
290*/
291kSCSIProtocolFeature_ProtocolAlwaysReportsAutosenseData= 11,
292
293/*!
294@constant kSCSIProtocolFeature_ProtocolSpecificPowerOff If
295the SCSI Protocol Services Driver supports removing the power
296to the drive, then the protocol layer should return true. This is
297used for aggressive power management, specifically for ATAPI
298devices on ATA buses.
299*/
300kSCSIProtocolFeature_ProtocolSpecificPowerOff= 12,
301
302/*!
303@constant kSCSIProtocolFeature_ProtocolSpecificPowerControl
304Used to determine if the SCSI Protocol Services Driver supports
305switching the power to the drive on and off. This is used for aggressive
306power management, specifically for SATAPI devices on AHCI buses.
307*/
308kSCSIProtocolFeature_ProtocolSpecificPowerControl= 13,
309
310/*!
311@constant kSCSIProtocolFeature_ProtocolSpecificAsyncNotification
312Used to determine if the SCSI Protocol Services Driver supports
313asynchronous notifications from the drive. This is used to prevent
314polling for media, specifically for SATAPI devices on AHCI buses.
315*/
316kSCSIProtocolFeature_ProtocolSpecificAsyncNotification= 14
317
318};
319
320
321/*!
322@typedef SCSIProtocolPowerState
323@discussion
324Typedef for SCSIProtocolPowerState, a 32-bit quantity.
325*/
326typedef UInt32 SCSIProtocolPowerState;
327
328/*!
329@enum SCSI Protocol Power States
330@discussion
331The list of SCSI Protocol Power States.
332*/
333enum
334{
335/*!
336@constant kSCSIProtocolPowerStateOff
337Off power state.
338*/
339kSCSIProtocolPowerStateOff= 0,
340
341/*!
342@constant kSCSIProtocolPowerStateOn
343On power state.
344*/
345kSCSIProtocolPowerStateOn= 1
346};
347
348
349//-----------------------------------------------------------------------------
350//Class Declaration
351//-----------------------------------------------------------------------------
352
353/*!
354@class IOSCSIProtocolInterface
355@superclass IOService
356@discussion
357This class defines the public SCSI Protocol Layer API for any class that
358provides Protocol services or needs to provide the Protocol Service API
359for passing service requests to a Protocol Service driver.
360*/
361class IOSCSIProtocolInterface : public IOService
362{
363
364OSDeclareAbstractStructors ( IOSCSIProtocolInterface )
365
366public:
367
368/*!
369@function start
370@abstract During an IOService object's instantiation, starts the IOService object that has been selected to run on the provider.
371@discussion See IOService.h for details.
372@result <code>true</code> if the start was successful; <code>false</code> otherwise (which will cause the instance to be detached and usually freed).
373*/
374virtual boolstart ( IOService * provider );
375
376/*!
377@function free
378@abstract Called to release all resources held by the object.
379@discussion Release all resources held by the object, then call super::free().
380*/
381virtual voidfree ( void );
382
383/*!
384@function willTerminate
385@abstract Passes a termination up the stack.
386@discussion Notification that a provider has been terminated, sent before recursing up the stack, in root-to-leaf order.
387@param provider The terminated provider of this object.
388@param options Options originally passed to terminate().
389@result <code>true</code>.
390*/
391virtual boolwillTerminate ( IOService * provider, IOOptionBits options );
392
393/*!
394@function GetUserClientExclusivityState
395@abstract Gets the current exclusivity state of the user client.
396@discussion The GetUserClientExclusivityState() method is called by the SCSITaskUserClient
397to determine if any user client is holding exclusive access at the current time. This is simply
398a preflight check and a return value of <code>false</code> does not guarantee that a subsequent
399call to SetUserClientExclusivityState() will return successfully.
400@result <code>true</code> if a user client is in exclusive control of the device, <code>false</code> otherwise.
401*/
402virtual bool GetUserClientExclusivityState ( void );
403
404/*!
405@function SetUserClientExclusivityState
406@abstract Sets the current exclusivity state of the user client.
407@discussion The SetUserClientExclusivityState() method is called by the SCSITaskUserClient
408to set the exclusive access mode.
409@param userClient The instance of SCSITaskUserClient for which to change exclusivity state.
410@param state Exclusivity state. <code>true</code> means exclusive access is desired, <code>false</code>
411means exclusive access is being released.
412@result A valid IOReturn code indicating success or the type of failure.
413*/
414virtual IOReturnSetUserClientExclusivityState ( IOService * userClient, bool state );
415
416
417/*!
418@function initialPowerStateForDomainState
419@abstract Determines which power state a device is in, given the current power domain state.
420@discussion Power management calls this method once, when the driver is initializing power management.
421Subclasses should not need to override this method.
422@param flags Flags that describe the character of "domain power"; they represent the <code>outputPowerCharacter</code> field of a state in the power domain's power state array.
423@result A state number.
424*/
425virtual unsigned longinitialPowerStateForDomainState ( IOPMPowerFlags flags );
426
427/*!
428@function setPowerState
429@abstract Requests a power managed driver to change the power state of its device.
430@discussion Requests a power managed driver to change the power state of its device. Most subclasses
431of IOSCSIProtocolInterface have class-specific mechanisms and should not override this routine.
432See IOSCSIProtocolServices.h, IOSCSIBlockCommandsDevice.h, IOSCSIReducedBlockCommandsDevice.h, and
433IOSCSIMultimediaCommandsDevice.h for more information about power management changes.
434Subclasses should not need to override this method.
435@param powerStateOrdinal The number in the power state array to which the drive is being instructed to change.
436@param whichDevice A pointer to the power management object which registered to manage power for this device.
437The whichDevice field is not pertinent to us since the driver is both the "policy maker" for the device,
438and the "policy implementor" for the device.
439@result See IOService.h for details.
440*/
441virtual IOReturn setPowerState ( unsigned long powerStateOrdinal, IOService * whichDevice );
442
443/*!
444@function IsPowerManagementIntialized
445@abstract Called to determine if power management is initialized.
446@discussion Called to determine if power management is initialized.
447Subclasses should not need to override this method.
448@result <code>true</code> if power management has been initialized, <code>false</code> otherwise.
449*/
450virtual boolIsPowerManagementIntialized ( void );
451
452/*!
453@function CheckPowerState
454@abstract Called by clients to ensure device is in correct power state before issuing I/O.
455@discussion Called by clients to ensure device is in correct power state before issuing I/O.
456If the device is not ready to handle such requests, it gives the driver a chance to block the
457thread until the device is ready. Subclasses should not need to override this method.
458*/
459virtual void CheckPowerState ( void );
460
461/*!
462@function ExecuteCommand
463@abstract Called to send a SCSITask and transport it across the physical wire(s) to the device.
464@discussion Called to send a SCSITask and transport it across the physical wire(s) to the device.
465Subclasses internal to IOSCSIArchitectureModelFamily will need to override this method. Third
466party subclasses should not need to override this method.
467@param request A valid SCSITaskIdentifier representing the task to transport across the wire(s).
468*/
469virtual voidExecuteCommand ( SCSITaskIdentifier request ) = 0;
470
471/*!
472@function AbortCommand
473@abstract Obsolete. Do not use this method.
474@discussion Obsolete. Do not use this method.
475*/
476virtual SCSIServiceResponseAbortCommand ( SCSITaskIdentifier request ) = 0;
477
478/*!
479@function IsProtocolServiceSupported
480@abstract This method is called to query for support of a protocol specific service feature.
481@discussion This method is called to query for support of a protocol specific service feature.
482Subclasses of IOSCSIProtocolServices should override this method.
483@param feature A valid SCSIProtocolFeature. See enums for SCSIProtocolFeature.
484@param serviceValue A pointer to a structure/value that is used in conjunction with the feature
485requested. See enums for SCSIProtocolFeature. NB: This parameter may be NULL for certain
486feature requests.
487@result <code>true</code> if the feature is supported, <code>false</code> otherwise.
488*/
489virtual boolIsProtocolServiceSupported (
490SCSIProtocolFeature feature,
491void * serviceValue ) = 0;
492
493/*!
494@function HandleProtocolServiceFeature
495@abstract This method is called to enact support of a protocol specific service feature.
496@discussion This method is called to enact support of a protocol specific service feature.
497Subclasses of IOSCSIProtocolServices should override this method.
498@param feature A valid SCSIProtocolFeature. See enums for SCSIProtocolFeature.
499@param serviceValue A pointer to a structure/value that is used in conjunction with the feature
500requested. See enums for SCSIProtocolFeature. NB: This parameter may be NULL for certain
501feature requests.
502@result <code>true</code> if the service feature request succeeded, <code>false</code> otherwise.
503*/
504virtual boolHandleProtocolServiceFeature (
505SCSIProtocolFeature feature,
506void * serviceValue ) = 0;
507
508protected:
509
510// Reserve space for future expansion.
511struct IOSCSIProtocolInterfaceExpansionData
512{
513IOWorkLoop *fWorkLoop;
514};
515IOSCSIProtocolInterfaceExpansionData * fIOSCSIProtocolInterfaceReserved;
516
517// ------ Power Management Support ------
518
519thread_call_tfPowerManagementThread;
520IOCommandGate *fCommandGate;
521UInt32fCurrentPowerState;
522UInt32fProposedPowerState;
523boolfPowerTransitionInProgress;
524boolfPowerAckInProgress;
525boolfPowerManagementInitialized;
526
527/*!
528@function GetCommandGate
529@abstract Accessor method to obtain the IOCommandGate.
530@discussion Accessor method to obtain the IOCommandGate.
531@result The IOCommandGate for this instance. May return NULL.
532*/
533IOCommandGate *GetCommandGate ( void );
534
535/*!
536@function InitializePowerManagement
537@abstract This method is called to initialize power management.
538@discussion This method is called to initialize power management. It will call PMinit(), joinPMTree(),
539setIdleTimerPeriod(), and makeUsable(). This method does not call registerPowerDriver().
540Subclasses may override this method to change the behavior (such as the number of power states).
541@param provider The power management provider (i.e. the provider to attach to in the PowerManagement
542tree). This may be a device that is not in the PM Tree itself, in which case, the IOService plane
543is traversed towards the root node in an effort to find a node in the PM Tree.
544*/
545virtual voidInitializePowerManagement ( IOService * provider );
546
547/*!
548@function GetInitialPowerState
549@abstract This method is called to obtain the initial power state of the device (usually the highest).
550@discussion This method is called to obtain the initial power state of the device (usually the highest).
551Subclasses must override this method.
552@result A power state ordinal.
553*/
554virtual UInt32GetInitialPowerState ( void ) = 0;
555
556/*!
557@function finalize
558@abstract Finalizes the destruction of an IOService object.
559@discussion See IOService.h
560Subclasses may override this method, but should call super::finalize().
561 @result <code>true</code>.
562*/
563virtual boolfinalize ( IOOptionBits options );
564
565/*!
566@function sHandleSetPowerState
567@abstract The sHandleSetPowerState method is a static function used as C->C++ glue
568for going behind the command gate.
569@discussion The sHandleSetPowerState method is a static function used as C->C++ glue
570for going behind the command gate.
571@param self The 'this' pointer for the class.
572@param powerStateOrdinal The power state to which device shall be changed.
573 @result A valid IOReturn code indicating success or failure.
574*/
575static IOReturn sHandleSetPowerState ( IOSCSIProtocolInterface * self, UInt32 powerStateOrdinal );
576
577/*!
578@function sGetPowerTransistionInProgress
579@abstract The sGetPowerTransistionInProgress method is a static function used as C->C++ glue
580for going behind the command gate.
581@discussion The sGetPowerTransistionInProgress method is a static function used as C->C++ glue
582for going behind the command gate.
583@param self The 'this' pointer for the class.
584 @result <code>true</code> if a power state is in progress, otherwise <code>false</code>.
585*/
586static bool sGetPowerTransistionInProgress ( IOSCSIProtocolInterface * self );
587
588/*!
589@function HandleSetPowerState
590@abstract The HandleSetPowerState method is called by the glue code and is on the
591serialized side of the command gate.
592@discussion The HandleSetPowerState method is called by the glue code and is on the
593serialized side of the command gate. This allows us to touch any member
594variables as necessary without any multi-threading issues.
595Subclasses may override this method to change behavior. Third party subclasses
596should not need to override this method, but may.
597@param powerStateOrdinal The power state to which device shall be changed.
598*/
599virtual voidHandleSetPowerState ( UInt32 powerStateOrdinal );
600
601/*!
602@function sPowerManagement
603@abstract The sPowerManagement method is a static C-function which is called using
604mach's thread_call API. It guarantees us a thread of execution which is
605different than the power management thread and the workloop thread on which
606we can issue commands to the device synchronously or asynchronously without
607worrying about deadlocks. It calls through to HandlePowerChange, which is
608a state machine used to direct power management.
609@discussion The sPowerManagement method is a static C-function which is called using
610mach's thread_call API. It guarantees us a thread of execution which is
611different than the power management thread and the workloop thread on which
612we can issue commands to the device synchronously or asynchronously without
613worrying about deadlocks. It calls through to HandlePowerChange, which is
614a state machine used to direct power management.
615@param whichDevice The 'this' pointer.
616*/
617static voidsPowerManagement ( thread_call_param_t whichDevice );
618
619/*!
620@function HandlePowerChange
621@abstract The HandlePowerChange method is pure virtual and is left to each protocol or
622application layer driver to implement. It is guaranteed to be called on its
623own thread of execution and can make synchronous or asynchronous calls.
624@discussion The HandlePowerChange method is pure virtual and is left to each protocol or
625application layer driver to implement. It is guaranteed to be called on its
626own thread of execution and can make synchronous or asynchronous calls.
627Subclasses must override this method. Third party subclasses shouldn't need to override
628this method but can to alter the default behavior.
629*/
630virtual voidHandlePowerChange ( void ) = 0;
631
632/*!
633@function sHandleCheckPowerState
634@abstract The sHandleCheckPowerState method is a static function used as C->C++ glue
635for going behind the command gate.
636@discussion The sHandleCheckPowerState method is a static function used as C->C++ glue
637for going behind the command gate.
638@param self The 'this' pointer for the class.
639*/
640static voidsHandleCheckPowerState ( IOSCSIProtocolInterface * self );
641
642/*!
643@function HandleCheckPowerState(void)
644@abstract The HandleCheckPowerState (void) method is on the serialized side of the command
645gate and can change member variables safely without multi-threading issues.
646It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState )
647with the max power state the class registered with.
648@discussion The HandleCheckPowerState (void) method is on the serialized side of the command
649gate and can change member variables safely without multi-threading issues.
650It's main purpose is to call the superclass' HandleCheckPowerState ( UInt32 maxPowerState )
651with the max power state the class registered with.
652Subclasses must override this method. Third party subclasses shouldn't need to override
653this method but can to alter the default behavior.
654*/
655virtual voidHandleCheckPowerState ( void ) = 0;
656
657/*!
658@function HandleCheckPowerState(UInt32 maxPowerState)
659@abstract The HandleCheckPowerState(UInt32 maxPowerState) method is called by
660the subclasses and is passed the maxPowerState number given to the power
661manager at initialization time. This guarantees the threads block until that
662power state has been achieved.
663@discussion The HandleCheckPowerState(UInt32 maxPowerState) method is called by
664the subclasses and is passed the maxPowerState number given to the power
665manager at initialization time. This guarantees the threads block until that
666power state has been achieved.
667@param maxPowerState The maximum power state in the power state array.
668*/
669void HandleCheckPowerState ( UInt32 maxPowerState );
670
671/*!
672@function TicklePowerManager(void)
673@abstract The TicklePowerManager(void) method is called by CheckPowerState and
674sends an activity tickle to the power manager so that the idle timer is
675reset.
676@discussion The TicklePowerManager(void) method is called by CheckPowerState and
677sends an activity tickle to the power manager so that the idle timer is
678reset.
679Subclasses must override this method. Third party subclasses shouldn't need to override
680this method but can to alter the default behavior.
681*/
682virtual voidTicklePowerManager ( void ) = 0;
683
684/*!
685@function TicklePowerManager(UInt32 maxPowerState)
686@abstract The TicklePowerManager(UInt32 maxPowerState) method is a convenience
687function which can be called by subclasses in TicklePowerManager (void)
688in order to tell the power manager to reset idle timer or bring the device
689into the requested state. It returns whatever is returned by activityTickle
690(true if device is in the requested state, false if it is not).
691@discussion The TicklePowerManager(UInt32 maxPowerState) method is a convenience
692function which can be called by subclasses in TicklePowerManager(void)
693in order to tell the power manager to reset idle timer or bring the device
694into the requested state. It returns whatever is returned by activityTickle
695(true if device is in the requested state, false if it is not).
696@param maxPowerState The maximum power state in the power state array.
697@result The result of the call to activityTickle(). See IOService.h for details.
698*/
699boolTicklePowerManager ( UInt32 maxPowerState );
700
701// ------ User Client Support ------
702
703boolfUserClientExclusiveControlled;
704IOService *fUserClient;
705
706/*!
707@function sGetUserClientExclusivityState
708@abstract The sGetUserClientExclusivityState method is a static function used as C->C++ glue
709for going behind the command gate.
710@discussion The sGetUserClientExclusivityState method is a static function used as C->C++ glue
711for going behind the command gate.
712@param self The 'this' pointer for the class.
713@param state A pointer to a bool in which the state should be set.
714*/
715static void sGetUserClientExclusivityState ( IOSCSIProtocolInterface * self, bool * state );
716
717/*!
718@function sSetUserClientExclusivityState
719@abstract The sSetUserClientExclusivityState method is a static function used as C->C++ glue
720for going behind the command gate.
721@discussion The sSetUserClientExclusivityState method is a static function used as C->C++ glue
722for going behind the command gate.
723@param self The 'this' pointer for the class.
724@param result A pointer to an IOReturn for the resulting status.
725@param userClient The instance of SCSITaskUserClient for which to change exclusivity state.
726@param state A bool indicating the desired state to set.
727*/
728static voidsSetUserClientExclusivityState ( IOSCSIProtocolInterface * self, IOReturn * result, IOService * userClient, bool state );
729
730/*!
731@function HandleGetUserClientExclusivityState
732@abstract Gets the current exclusivity state of the user client.
733@discussion The HandleGetUserClientExclusivityState() method is called on the serialized side
734of the command gate to determine if any user client is holding exclusive access at the current
735time. See discussion for GetUserClientExclusivityState().
736Subclasses may override this method to alter default behavior. Third party subclasses should
737not need to override this method.
738@result <code>true</code> if a user client is in exclusive control of the device, <code>false</code> otherwise.
739*/
740virtual boolHandleGetUserClientExclusivityState ( void );
741
742/*!
743@function HandleSetUserClientExclusivityState
744@abstract Sets the current exclusivity state of the user client.
745@discussion The HandleSetUserClientExclusivityState() method is called on the serialized side
746of the command gate to set the exclusive access mode.
747@param userClient The instance of SCSITaskUserClient for which to change exclusivity state.
748@param state Exclusivity state. <code>true</code> means exclusive access is desired, <code>false</code>
749means exclusive access is being released.
750@result A valid IOReturn code indicating success or the type of failure.
751*/
752virtual IOReturnHandleSetUserClientExclusivityState ( IOService * userClient, bool state );
753
754public:
755
756// ------- SCSI Architecture Model Task Management Functions ------
757
758OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 1 );
759/*!
760@function AbortTask
761@abstract Aborts a task based on the Logical Unit and tagged task identifier.
762@discussion Aborts a task based on the Logical Unit and tagged task identifier.
763Subclasses must override this method. Third party subclasses should not need to override
764this method.
765@param theLogicalUnit This value should be zero unless the device driver is
766more complex and managing multiple Logical Units.
767@param theTag A valid SCSITaggedTaskIdentifier representing an outstanding SCSITask.
768@result A valid SCSIServiceResponse code.
769*/
770virtual SCSIServiceResponseAbortTask ( UInt8 theLogicalUnit, SCSITaggedTaskIdentifier theTag ) = 0;
771
772OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 2 );
773/*!
774@function AbortTaskSet
775@abstract Aborts a task set based on the Logical Unit.
776@discussion Aborts a task set based on the Logical Unit.
777Subclasses must override this method. Third party subclasses should not need to override
778this method.
779@param theLogicalUnit This value should be zero unless the device driver is
780more complex and managing multiple Logical Units.
781@result A valid SCSIServiceResponse code.
782*/
783virtual SCSIServiceResponseAbortTaskSet ( UInt8 theLogicalUnit ) = 0;
784
785OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 3 );
786/*!
787@function ClearACA
788@abstract Clears an Auto-Contingent Allegiance (ACA) for the specified Logical Unit.
789@discussion Clears an Auto-Contingent Allegiance (ACA) for the specified Logical Unit.
790Subclasses must override this method. Third party subclasses should not need to override
791this method.
792@param theLogicalUnit This value should be zero unless the device driver is
793more complex and managing multiple Logical Units.
794@result A valid SCSIServiceResponse code.
795*/
796virtual SCSIServiceResponseClearACA ( UInt8 theLogicalUnit ) = 0;
797
798OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 4 );
799/*!
800@function ClearTaskSet
801@abstract Clears a task set for the specified Logical Unit.
802@discussion Clears a task set for the specified Logical Unit.
803Subclasses must override this method. Third party subclasses should not need to override
804this method.
805@param theLogicalUnit This value should be zero unless the device driver is
806more complex and managing multiple Logical Units.
807@result A valid SCSIServiceResponse code.
808*/
809virtual SCSIServiceResponseClearTaskSet ( UInt8 theLogicalUnit ) = 0;
810
811OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 5 );
812/*!
813@function LogicalUnitReset
814@abstract Resets the specified Logical Unit.
815@discussion Resets the specified Logical Unit.
816Subclasses must override this method. Third party subclasses should not need to override
817this method.
818@param theLogicalUnit This value should be zero unless the device driver is
819more complex and managing multiple Logical Units.
820@result A valid SCSIServiceResponse code.
821*/
822virtual SCSIServiceResponseLogicalUnitReset ( UInt8 theLogicalUnit ) = 0;
823
824OSMetaClassDeclareReservedUsed ( IOSCSIProtocolInterface, 6 );
825
826/*!
827@function TargetReset
828@abstract Resets the target device.
829@discussion Resets the target device.
830Subclasses must override this method. Third party subclasses should not need to override
831this method.
832@result A valid SCSIServiceResponse code.
833*/
834virtual SCSIServiceResponseTargetReset ( void ) = 0;
835
836private:
837
838// Space reserved for future expansion.
839OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 7 );
840OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 8 );
841OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 9 );
842OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 10 );
843OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 11 );
844OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 12 );
845OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 13 );
846OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 14 );
847OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 15 );
848OSMetaClassDeclareReservedUnused ( IOSCSIProtocolInterface, 16 );
849
850};
851
852#endif/* defined(KERNEL) && defined(__cplusplus) */
853
854#endif/* _IOKIT_IO_SCSI_PROTOCOL_INTERFACE_H_ */
855

Archive Download this file

Revision: 1621