Chameleon

Chameleon Svn Source Tree

Root/branches/JrCs/i386/include/IOKit/scsi/spi/IOSCSIParallelInterfaceController.h

1/*
2 * Copyright (c) 2002-2008 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_PARALLEL_INTERFACE_CONTROLLER_H__
25#define __IOKIT_IO_SCSI_PARALLEL_INTERFACE_CONTROLLER_H__
26
27
28 /*!
29 @header IOSCSIParallelInterfaceController
30The IOSCSIParallelInterfaceController class and the associated HBA child
31class is responsible for the management of all related hardware. This
32includes the onboard HBA controller chip and the physical state of the
33bus. These classes are not responsible for any of the management of
34the SCSI Devices on the bus with the exception of maintaining the queue that
35holds the objects representing those SCSI Devices.
36*/
37
38
39//-----------------------------------------------------------------------------
40//Includes
41//-----------------------------------------------------------------------------
42
43// General IOKit includes
44#include <IOKit/IOService.h>
45#include <IOKit/IOWorkLoop.h>
46#include <IOKit/IOCommandGate.h>
47#include <IOKit/IODMACommand.h>
48#include <IOKit/IOInterruptEventSource.h>
49#include <IOKit/IOFilterInterruptEventSource.h>
50#include <IOKit/IOTimerEventSource.h>
51#include <IOKit/IOCommandPool.h>
52
53// IOKit SCSI ArchitectureModel Family includes
54#include <IOKit/scsi/SCSITask.h>
55#include <IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h>
56#include <IOKit/scsi/SCSIPort.h>
57
58//-----------------------------------------------------------------------------
59//Constants
60//-----------------------------------------------------------------------------
61
62
63#define kIOPropertySCSIDeviceFeaturesKey"SCSI Device Features"
64#define kIOPropertySCSI_I_T_NexusFeaturesKey"SCSI I_T Nexus Features"
65
66// This is the alignment mask used when allocating per-task HBA data. It allows
67// the HBA to declare whether or not it supports 64-bit addressability and what the
68// minimum byte alignment is for the data. E.g. By specifying 0x0000FFFFFFFFFFFEULL,
69// the controller would be indicating that it supports 48-bits of addressability, but
70// at a minimum of being 2-byte aligned.
71#define kIOMinimumHBADataAlignmentMaskKey"HBA Data Alignment"
72
73// The Feature Selectors used to identify features of the SCSI Parallel
74// Interface. These are used by the DoesHBASupportSCSIParallelFeature
75// to report whether the HBA supports a given SCSI Parallel Interface
76// feature and are used for requesting negotiation and reporting negotiation
77// results between the controller and the device.
78
79// When the DoesHBASupportSCSIParallelFeature() member routine of the controller
80// child class is called, it will return true if the HBA that it controls
81// supports the specified SCSIParallelFeature or false if it does not.
82typedef enum SCSIParallelFeature
83{
84// The selector for support of Wide Data Transfers. Only Wide16 is supported
85// as Wide32 has been obsoleted by the SPI-3 specification.
86kSCSIParallelFeature_WideDataTransfer = 0,
87
88// The selector for support of Synchronous Data Transfers.
89kSCSIParallelFeature_SynchronousDataTransfer = 1,
90
91// The selector for support of Quick Arbitration and Selection (QAS).
92kSCSIParallelFeature_QuickArbitrationAndSelection = 2,
93
94// The selector for support of Double Transition (DT) data transfers.
95kSCSIParallelFeature_DoubleTransitionDataTransfers = 3,
96
97// The selector for SPI Information Unit (IU) transfers.
98kSCSIParallelFeature_InformationUnitTransfers = 4,
99
100// Since the Feature selectors are zero base, this will always have the
101// correct total.
102kSCSIParallelFeature_TotalFeatureCount
103} SCSIParallelFeature;
104
105
106typedef enum SCSIParallelFeatureRequest
107{
108// This selector indicates that current negotiation
109// should be used.
110kSCSIParallelFeature_NoNegotiation = 0,
111
112// This selector indicates that the controller
113// should attempt negotiation for the feature
114kSCSIParallelFeature_AttemptNegotiation = 1,
115
116// This selector indicates that the controller
117// should clear any negotiation for the feature
118kSCSIParallelFeature_ClearNegotiation = 2
119};
120
121typedef enum SCSIParallelFeatureResult
122{
123kSCSIParallelFeature_NegotitiationUnchanged= 0,
124kSCSIParallelFeature_NegotitiationCleared= 1,
125kSCSIParallelFeature_NegotitiationSuccess= 2
126};
127
128
129// The SCSI Message Codes used for MESSAGE IN and MESSAGE OUT phases.
130enum SCSIParallelMessages
131{
132// Link Control Messages
133kSCSIParallelMessage_TASK_COMPLETE= 0x00,
134kSCSIParallelMessage_EXTENDED_MESSAGE= 0x01,
135kSCSIParallelMessage_SAVE_DATA_POINTER = 0x02,
136kSCSIParallelMessage_RESTORE_POINTERS= 0x03,
137kSCSIParallelMessage_DISCONNECT= 0x04,
138kSCSIParallelMessage_INITIATOR_DETECTED_ERROR = 0x05,
139kSCSIParallelMessage_MESSAGE_REJECT = 0x07,
140kSCSIParallelMessage_NO_OPERATION = 0x08,
141kSCSIParallelMessage_MESSAGE_PARITY_ERROR = 0x09,
142kSCSIParallelMessage_IGNORE_WIDE_RESIDUE= 0x23,
143kSCSIParallelMessage_QAS_REQUEST = 0x55,
144kSCSIParallelMessage_IDENTIFY= 0x80,
145
146// The Message Codes used in the EXTENDED_MESSAGE message.
147kSCSIParallelMessage_MODIFY_DATA_POINTER= 0x00,
148kSCSIParallelMessage_SYNCHONOUS_DATA_TRANSFER_REQUEST= 0x01,
149// Reserved= 0x02
150kSCSIParallelMessage_WIDE_DATA_TRANSFER_REQUEST= 0x03,
151kSCSIParallelMessage_PARALLEL_PROTOCOL_REQUEST= 0x04,
152// Reserved= 0x05 through 0xFF
153
154// Task Attribute Message Codes
155kSCSIParallelMessage_ACA= 0x24,
156kSCSIParallelMessage_HEAD_OF_QUEUE= 0x21,
157kSCSIParallelMessage_LINKED_COMMAND_COMPLETE= 0x0A,
158kSCSIParallelMessage_ORDERED= 0x22,
159kSCSIParallelMessage_SIMPLE= 0x20,
160
161// Task Management Message Codes
162kSCSIParallelMessage_ABORT_TASK= 0x0D,
163kSCSIParallelMessage_ABORT_TASK_SET= 0x06,
164kSCSIParallelMessage_CLEAR_ACA= 0x16,
165kSCSIParallelMessage_CLEAR_TASK_SET= 0x0E,
166kSCSIParallelMessage_LOGICAL_UNIT_RESET= 0x17,
167kSCSIParallelMessage_TARGET_RESET= 0x0C
168};
169
170enum
171{
172kSCSIParallelTaskControllerIDQueueHead = 0
173};
174
175// Notifications
176enum
177{
178kSCSIControllerNotificationBusReset= 0x68000000
179};
180
181// Forward declaration for the internally used Parallel Device object.
182class IOSCSIParallelInterfaceDevice;
183
184// This is the identifier that is used to specify a given parallel Task.
185typedef OSObject *SCSIParallelTaskIdentifier;
186
187
188//-----------------------------------------------------------------------------
189//Class Declarations
190//-----------------------------------------------------------------------------
191
192/*! @class IOSCSIParallelInterfaceController
193@abstract Class that represents a SCSI Host Bus Adapter.
194@discussion Class that represents a SCSI Host Bus Adapter.
195*/
196class IOSCSIParallelInterfaceController : public IOService
197{
198
199OSDeclareAbstractStructors ( IOSCSIParallelInterfaceController )
200
201#if 0
202#pragma mark -
203#pragma mark Client API
204#endif
205
206
207public:
208
209/*!
210@function GetSCSIParallelTask
211@abstract Method to allow the client to get a SCSIParallelTask
212@discussion Get a SCSIParallelTask from the controller so that a request
213can be issued to the HBA driver.
214@param blockForCommand If the blockForCommand parameter is set to false
215and there are no free SCSIParallelTasks, this method will return NULL,
216otherwise it will wait for one to become available before returning.
217@result If there is a SCSI Parallel Task available, a reference to it
218will be returned.
219*/
220
221SCSIParallelTaskIdentifierGetSCSIParallelTask ( bool blockForCommand );
222
223/*!
224@function FreeSCSIParallelTask
225@abstract Method to allow the client to release a SCSIParallelTask
226@discussionThe FreeSCSIParallelTask method is called by the client when
227a SCSIParallelTask has been completed and the associated returnTask
228needs to be returned to the pool.
229@param returnTask is a reference to the SCSIParallelTaskIdentifier to be
230returned.
231*/
232
233void FreeSCSIParallelTask ( SCSIParallelTaskIdentifier returnTask );
234
235/*!
236@function FindTaskForAddress
237@abstract Find a task for a given Task Address, if one exists.
238@discussion If a valid Tagged Task Identifier is specified, this method
239will return the task specified by the Tagged Task Address if one is
240found, or else NULL will be returned. If zero is used as the Tagged
241Task Identifier, then this routine will search for an outstanding task
242based on the Untagged Task Address and return the task or else, if one
243is not found, return NULL.
244@param theT is the Target component of the I_T_L or I_T_L_Q nexus.
245@param theL is the Logical Unit component of the I_T_L or I_T_L_Q nexus.
246@param theQ is the Queue Tag component of the I_T_L_Q nexus. If this is
247an I_T_L nexus, then the kSCSIUntaggedTaskIdentifier constant should be
248used for theQ.
249@result returns a valid SCSIParallelTaskIdentifier or NULL if none
250found.
251*/
252
253SCSIParallelTaskIdentifierFindTaskForAddress (
254SCSIDeviceIdentifier theT,
255SCSILogicalUnitNumbertheL,
256SCSITaggedTaskIdentifiertheQ );
257
258
259/*!
260@function FindTaskForControllerIdentifier
261@abstract Find a task for a given Target and Controller Task Identifier
262@discussion Allows the controller child class to find an outstanding task
263for a specified target and controller task identifier
264@param theTarget is the Target that the task .
265@param theIdentifier is the controller task identifier set using the SCSI
266Parallel Task's SetControllerTaskIdentifier() method.
267@result returns a valid SCSIParallelTaskIdentifier or NULL if none
268found.
269*/
270
271SCSIParallelTaskIdentifierFindTaskForControllerIdentifier (
272SCSIDeviceIdentifier theTarget,
273UInt64theIdentifier );
274
275
276/*!
277@function ExecuteParallelTask
278@abstract Submit a SCSIParallelTask for execution.
279@discussionThe ExecuteParallelTask call is made by the client to submit
280a SCSIParallelTask for execution.
281@param parallelRequest is a reference to the SCSIParallelTaskIdentifier
282to be executed.
283@result is an appropriate SCSIServiceResponse which are defined in the
284file <IOKit/scsi/SCSITask.h>.
285*/
286
287SCSIServiceResponse ExecuteParallelTask (
288SCSIParallelTaskIdentifierparallelRequest );
289
290// --- Public API methods provided by HBA child classes ----
291
292/*!
293@function ReportHBAHighestLogicalUnitNumber
294@abstract Gets the Highest Logical Unit Number.
295@discussionThis method is used to query the HBA child class to
296determine what the highest Logical Unit Number that the controller can
297address.
298@result returns a valid 64-bit logical unit number.
299*/
300
301virtual SCSILogicalUnitNumberReportHBAHighestLogicalUnitNumber ( void ) = 0;
302
303/*!
304@function DoesHBASupportSCSIParallelFeature
305@abstract Queries the HBA child class to determine if it supports a
306specific SPI feature.
307@discussionQueries the HBA child class to determine if it supports the
308specified feature as defined by the SCSI Parallel Interconnect
309specifications.
310@result Returns true if requested feature is supported.
311*/
312
313virtual boolDoesHBASupportSCSIParallelFeature (
314SCSIParallelFeature theFeature ) = 0;
315
316/*!
317@function InitializeTargetForID
318@abstract Called to initialize a target device.
319@discussionThis method will be called to initialize a target device in
320a single-threaded manner. The HBA can use this method to probe the
321target or do anything else necessary before the device object is
322registered with IOKit for matching.
323@result Returns true if the target was successfully initialized.
324*/
325
326virtual boolInitializeTargetForID (
327SCSITargetIdentifier targetID ) = 0;
328
329// The SCSI Task Management Functions as defined in the SCSI Architecture
330// Model - 2 (SAM-2) specification. These are used by the client to request
331// the specified function. The controller can complete these immmediately
332// by returning the appropriate SCSIServiceResponse, or these can be completed
333// asyncronously by the controller returning a SCSIServiceResponse of
334// kSCSIServiceResponse_Request_In_Process and then calling the appropriate
335// function complete member routine listed in the child class API section.
336
337virtual SCSIServiceResponseAbortTaskRequest (
338SCSITargetIdentifier theT,
339SCSILogicalUnitNumbertheL,
340SCSITaggedTaskIdentifiertheQ ) = 0;
341
342virtualSCSIServiceResponse AbortTaskSetRequest (
343SCSITargetIdentifier theT,
344SCSILogicalUnitNumbertheL ) = 0;
345
346virtualSCSIServiceResponse ClearACARequest (
347SCSITargetIdentifier theT,
348SCSILogicalUnitNumbertheL ) = 0;
349
350virtualSCSIServiceResponse ClearTaskSetRequest (
351SCSITargetIdentifier theT,
352SCSILogicalUnitNumbertheL ) = 0;
353
354virtualSCSIServiceResponse LogicalUnitResetRequest (
355SCSITargetIdentifier theT,
356SCSILogicalUnitNumbertheL ) = 0;
357
358virtualSCSIServiceResponse TargetResetRequest (
359SCSITargetIdentifier theT ) = 0;
360
361
362
363/*!
364@function DoesHBAPerformAutoSense
365@abstract Queries the HBA child class to determine if it automatically
366performs AutoSense and provides AutoSense data for each I/O. If the HBA
367allocates space for AutoSense in its HBA specific data region on a per
368task basis, the HBA should respond true.
369@discussionQueries the HBA child class to determine if it automatically
370performs AutoSense and provides AutoSense data for each I/O. If the HBA
371allocates space for AutoSense in its HBA specific data region on a per
372task basis, the HBA should respond true.
373@result Return true if HBA performs AutoSense into its own private data
374buffer.
375*/
376
377OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 1 );
378
379virtual boolDoesHBAPerformAutoSense ( void );
380
381/*!
382@function ReportHBAConstraints
383@abstract Called to report the I/O constraints for this controller.
384A list of valid keys includes:
385kIOMaximumSegmentCountReadKey, (required)
386kIOMaximumSegmentCountWriteKey, (required)
387kIOMaximumSegmentByteCountReadKey, (required)
388kIOMaximumSegmentByteCountWriteKey, (required)
389kIOMinimumSegmentAlignmentByteCountKey, (required)
390kIOMaximumSegmentAddressableBitCountKey, (required)
391kIOMinimumHBADataAlignmentMaskKey (required).
392NB: These keys and their values are described in this header and <IOKit/IOKitKeys.h>
393@param constraints. An OSDictionary object used to aggregate the key/value pairs.
394Subclasses must set the required keys if they override this method. If a subclass does
395not provide the required keys, the system will panic.
396*/
397OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 2 );
398
399virtual voidReportHBAConstraints ( OSDictionary * constraints );
400
401// Padding for the Client API
402OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 3 );
403OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 4 );
404OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 5 );
405OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 6 );
406OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 7 );
407OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 8 );
408
409
410#if 0
411#pragma mark -
412#pragma mark Child Class API
413#endif
414
415
416protected:
417
418// ---- Target Creation and Destruction methods ---
419
420/*!
421@function CreateTargetForID
422@abstract Method to perform device creation.
423@discussionFor HBA child classes that report true to the
424DoesHBAPerformDeviceManagement() method, the child class will be
425responsible for all device management by using these methods;
426otherwise, the superclass will be responsible for all device management.
427This method must be used to perform SCSI Parallel Device creation and
428cannot be overridden.
429@param targetID SCSIDeviceIdentifier of desired targetID.
430@result returns true if successful.
431*/
432
433boolCreateTargetForID ( SCSIDeviceIdentifier targetID );
434
435 /*!
436@function CreateTargetForID
437@abstract Method to perform device creation.
438@discussionFor HBA child classes that report true to the
439DoesHBAPerformDeviceManagement() method, the child class will be
440responsible for all device management by using these methods;
441otherwise, the superclass will be responsible for all device management.
442This method must be used to perform SCSI Parallel Device creation and
443cannot be overridden.
444@param targetID SCSIDeviceIdentifier of desired targetID.
445@paramproperties A dictionary of properties to associate with the device
446upon creation. The list of valid property keys is as follows:
447kIOPropertySASAddressKey,
448kIOPropertyFibreChannelNodeWorldWideNameKey,
449kIOPropertyFibreChannelPortWorldWideNameKey,
450kIOPropertyFibreChannelAddressIdentifierKey, and
451kIOPropertyFibreChannelALPAKey.
452These keys are defined in
453<IOKit/storage/IOStorageProtocolCharacteristics.h> and the values
454associated with these keys must be of the proper type/size,
455or the target creation will not succeed.
456@result returns true if successful.
457*/
458
459boolCreateTargetForID ( SCSIDeviceIdentifier targetID,
460OSDictionary * properties );
461
462 /*!
463@function DestroyTargetForID
464@abstract Method to perform device destruction.
465@discussionFor HBA child classes that report true to the
466DoesHBAPerformDeviceManagement() method, the child class will be
467responsible for all device management by using these methods; otherwise,
468the superclass will be responsible for all device management.
469This method must be used to perform SCSI Parallel Device destruction and
470cannot be overridden.
471@param targetID SCSIDeviceIdentifier of desired targetID.
472*/
473
474voidDestroyTargetForID ( SCSIDeviceIdentifier targetID );
475
476/*!
477@function GetTargetForID
478@abstract Accessor for getting pointer to IOSCSIParallelInterfaceDevice.
479@param targetID SCSIDeviceIdentifier of desired targetID.
480@result returns pointer to IOSCSIParallelInterfaceDevice or NULL if not
481found.
482*/
483
484IOSCSIParallelInterfaceDevice *GetTargetForID (
485SCSIDeviceIdentifier targetID );
486
487/*!
488@function SetTargetProperty
489@abstract Accessor for setting a property for a specific target.
490@param device A pointer to a valid IOSCSIParallelInterfaceDevice.
491@param key A pointer to a valid OSString object which represents the key.
492A list of valid keys includes:
493kIOPropertySASAddressKey,
494kIOPropertyFibreChannelNodeWorldWideNameKey,
495kIOPropertyFibreChannelPortWorldWideNameKey,
496kIOPropertyFibreChannelAddressIdentifierKey, and
497kIOPropertyFibreChannelALPAKey.
498NB: These keys and their values are described in <IOKit/storage/IOStorageProtocolCharacteristics.h>
499@param value Pointer to an OSObject (one of type OSData, OSString, etc.)
500which represents the value for the property. The value must be of the proper type
501and size for the specified key.
502@result returns true if identifier was properly set, otherwise false.
503*/
504
505boolSetTargetProperty ( SCSIDeviceIdentifier targetID,
506const char * key,
507OSObject *value );
508
509/*!
510@function RemoveTargetProperty
511@abstract Accessor for removing a property from a specific target.
512@param device A pointer to a valid IOSCSIParallelInterfaceDevice.
513@param key A pointer to a valid OSString object which represents the key.
514*/
515
516voidRemoveTargetProperty ( SCSIDeviceIdentifier targetID,
517 const char * key );
518
519// ---- Methods for HBA specifics. ----
520
521/*!
522@function SetHBAProperty
523@abstract Accessor for setting a property for this object.
524@param key A pointer to a valid OSString object which represents the key.
525A list of valid keys includes:
526kIOPropertyVendorNameKey,
527kIOPropertyProductNameKey,
528kIOPropertyProductRevisionLevelKey,
529kIOPropertyPortDescriptionKey,
530kIOPropertyPortSpeedKey,
531kIOPropertyPortTopologyKey,
532kIOPropertySCSIParallelSignalingTypeKey,
533kIOPropertyFibreChannelCableDescriptionKey,
534kIOPropertyFibreChannelNodeWorldWideNameKey,
535kIOPropertyFibreChannelPortWorldWideNameKey,
536kIOPropertyFibreChannelAddressIdentifierKey, and
537kIOPropertyFibreChannelALPAKey.
538NB: These keys and their values are described in <IOKit/storage/IOStorageDeviceCharacteristics.h>
539and <IOKit/storage/IOStorageProtocolCharacteristics.h>
540@param value Pointer to an OSObject (one of type OSData, OSString, etc.)
541which represents the value for the property. The value must be of the proper type,
542and/or size for the specified key.
543@result returns true if identifier was properly set, otherwise false.
544*/
545
546boolSetHBAProperty ( const char *key,
547 OSObject * value );
548
549/*!
550@function RemoveHBAProperty
551@abstract Accessor for removing a property for this object.
552@param key A pointer to a valid OSString object which represents the key.
553See the SetHBAProperty() method for a list of valid keys.
554*/
555
556voidRemoveHBAProperty ( const char * key );
557
558// These methods will not be called before the InitializeController() call,
559// and will not be called after the TerminateController() call. But in the
560// interval between those calls, they shall report the correct requested
561// information. They are implemented as seperate pure virtual methods
562// instead of a selector driven method because the HBA child class is
563// required to report this information.
564
565/*!
566@function ReportInitiatorIdentifier
567@abstract Get the SCSI Device Identifier for the HBA.
568@discussion This method will be called to determine the SCSI Device
569Identifier that the Initiator has assigned for this HBA.
570@result returns SCSIInitiatorIdentifier.
571*/
572
573virtual SCSIInitiatorIdentifierReportInitiatorIdentifier ( void ) = 0;
574
575/*!
576@function ReportHighestSupportedDeviceID
577@abstract Get the highest supported SCSI Device Identifier.
578@discussion This method will be called to determine the value of the
579highest SCSI Device Identifier supported by the HBA. This value will be
580used to determine the last ID to process.
581@result returns highest SCSIDeviceIdentifier
582*/
583
584virtual SCSIDeviceIdentifierReportHighestSupportedDeviceID ( void ) = 0;
585
586/*!
587@function ReportMaximumTaskCount
588@abstract Report Maximum Task Count
589@discussion This method will be called to retrieve the maximum number of
590outstanding tasks the HBA can process. This number must be greater than
591zero or the controller driver will fail to match and load.
592@result returns maximum (non-zero) task count.
593*/
594
595virtual UInt32ReportMaximumTaskCount ( void ) = 0;
596
597 /*!
598@function ReportHBASpecificTaskDataSize
599@abstract Determine memory needed for HBA Task specific use.
600@discussion This method is used to retrieve the amount of memory that
601will be allocated in the SCSI Parallel Task for HBA specific use.
602@result returns memory required in bytes
603*/
604
605virtual UInt32ReportHBASpecificTaskDataSize ( void ) = 0;
606
607 /*!
608@function ReportHBASpecificDeviceDataSize
609@abstract Determine memory needed for HBA Device specific use.
610@discussion This method is used to retrieve the amount of memory that
611will be allocated in the SCSI Parallel Device for HBA specific use.
612@result returns memory required in bytes
613*/
614
615virtual UInt32ReportHBASpecificDeviceDataSize ( void ) = 0;
616
617 /*!
618@function DoesHBAPerformDeviceManagement
619@abstract Determine if HBA will manage devices.
620@discussion This method is used to determine if the HBA will manage
621target device creation and destruction.
622@result return true means objects for target devices will only be
623created when the child class calls the CreateTargetForID method.
624*/
625
626virtual boolDoesHBAPerformDeviceManagement ( void ) = 0;
627
628// ---- Initialize and Terminate methods for the subclass to implement -----
629// The subclass shall not override the IOKit init and terminate methods,
630// but shall instead rely on these methods for initialization and
631// termination.
632
633// This is done to allow for this superclass to manage all IOKit specifics
634// and to require only a Family specific API to be implemented by the
635// subclass drivers.
636
637 /*!
638@function InitializeController
639@abstract Called to initialize the controller
640@discussion It is guaranteed that the InitializeController() will only be
641called once per instantiation. The InitializeController() methods allows
642the subclass driver to do all the necessary initialization required by
643the hardware before it is able to accept requests to execute. All
644necessary allocation of resources should be made during this method
645call. This is the first method that will be called in the subclass.
646@result return true means that initialization was successful.
647*/
648
649virtual boolInitializeController ( void ) = 0;
650
651 /*!
652@function TerminateController
653@abstract Called to terminate the controller
654@discussion It is guaranteed that the TerminateController() will only be
655called once and only after the InitializeController() method and only if
656true was returned in response to the InitializeController() method.
657The TerminateController() method allows the subclass to release all
658resources that were acquired for operation of the hardware and shutdown
659all hardware services.
660This is the last method of the subclass that will be called before the
661class is destroyed.
662*/
663
664virtual voidTerminateController ( void ) = 0;
665
666// ---- Start and Stop methods for the subclass ----
667
668/*!
669@function StartController
670@abstract Called to start the controller
671@discussion The StartController will always be called before any
672requests are sent to the driver for execution. This method is called
673after an initialize to start the services provided by the specific HBA
674driver or called after a StopController call to restart those services.
675After this call completes, all services provided by the HBA driver are
676available to the client.
677@result return true means that start was successful.
678*/
679
680virtual boolStartController ( void ) = 0;
681
682/*!
683@function StopController
684@abstract Called to stop the controller
685@discussion The StopController method will be called any time that the
686system wants the card to stop accepting requests. ( See StartController
687discussion ). The subclass should disable the hardware interrupt for
688the particular controller (if possible) in this method.
689*/
690
691virtual voidStopController ( void ) = 0;
692
693// ---- Suspend and Resume Methods for the subclass ----
694
695/*!
696@function SuspendServices
697@abstract Called to suspend controller services
698@discussion Method will be called when the system wants to suspend the
699services that are provided by the HBA driver. This call is not a reset
700and the driver shall retain all state data between this so that if a
701ResumeServices call is received, the driver can continue providing
702services without a visible difference to the client. The driver may
703receive multiple SuspendServices calls without receiving a
704ResumeServices call and should ignore any after the first until a
705ResumeServices call is received.
706*/
707
708virtual voidSuspendServices ( void );
709
710/*!
711@function ResumeServices
712@abstract Called to resume controller services
713@discussion Method that will be called to resume services
714provided by the driver. ( See SuspendServices discussion )
715*/
716
717virtual voidResumeServices ( void );
718
719/*!
720@function HandleInterruptRequest
721@abstract Handle Interrupt Request
722@discussion The HandleInterruptRequest is used to notify an HBA
723specific subclass that an interrupt request needs to be serviced. It is
724called on the workloop (it holds the gate) at secondary interrupt level.
725*/
726
727virtual voidHandleInterruptRequest ( void ) = 0;
728
729/*!
730@function EnableInterrupt
731@abstract Enable Interrupt
732@discussion Method that the HBA child class can call to enable
733the associated IOInterruptEventSource.
734*/
735
736voidEnableInterrupt ( void );
737
738/*!
739@function DisableInterrupt
740@abstract Disable Interrupt
741@discussion Method that the HBA child class can call to disable
742the associated IOInterruptEventSource.
743*/
744
745voidDisableInterrupt ( void );
746
747/*!
748@function SignalInterrupt
749@abstract Signals that an interrupt has occurred.
750@discussion Subclasses of IOSCSIParallelInterfaceController
751should call this method in order to get the secondary interrupt
752thread scheduled if and only if they will be returning false from
753their overriden FilterInterruptRequest() method. See the
754discussion for the FilterInterruptRequest() method for more
755details.
756
757NOTE: This method should only be called from within the
758FilterInterruptRequest() method and at no other time.
759
760Available in 10.3.3 or later.
761
762*/
763
764voidSignalInterrupt ( void );
765
766/*!
767@function ProcessParallelTask
768@abstract Called by client to process a parallel task.
769@discussion This method is called to process a parallel task (i.e. put
770the command on the bus). The HBA specific sublcass must implement this
771method.
772@param parallelRequest A valid SCSIParallelTaskIdentifier.
773@result serviceResponse (see <IOKit/scsi/SCSITask.h>)
774*/
775
776virtual SCSIServiceResponse ProcessParallelTask (
777SCSIParallelTaskIdentifier parallelRequest ) = 0;
778
779/*!
780@function CompleteParallelTask
781@abstract Parallel Task Completion
782@discussion The HBA specific sublcass inherits the CompleteParallelTask()
783method which shall be called when the HBA has completed the processing
784of a parallel task.
785@param parallelTask A valid SCSIParallelTaskIdentifier.
786@param completionStatus The status of the SCSI bus.
787@param serviceResponse (see <IOKit/scsi/SCSITask.h>)
788*/
789
790voidCompleteParallelTask (
791SCSIParallelTaskIdentifierparallelRequest,
792SCSITaskStatus completionStatus,
793SCSIServiceResponse serviceResponse );
794
795
796// Completion routines for the SCSI Task Management functions as described
797// in the SCSI ArchitectureModel - 2 (SAM-2) specification. Each of these
798// correspond to a client request for the specific Task Management functions.
799// If the Controller Child Class completed the request by returning a
800// SCSIServiceResponse of anything other than kSCSIServiceResponse_Request_In_Process,
801// then the controller class does not need to call the completion member routine.
802// If the controller did not complete the request immediately, then it will
803// need to call the appropriate completion member routine listed here.
804voidCompleteAbortTask (
805SCSITargetIdentifier theT,
806SCSILogicalUnitNumbertheL,
807SCSITaggedTaskIdentifiertheQ,
808SCSIServiceResponse serviceResponse );
809
810void CompleteAbortTaskSet (
811SCSITargetIdentifier theT,
812SCSILogicalUnitNumbertheL,
813SCSIServiceResponse serviceResponse );
814
815void CompleteClearACA (
816SCSITargetIdentifier theT,
817SCSILogicalUnitNumbertheL,
818SCSIServiceResponse serviceResponse );
819
820void CompleteClearTaskSet (
821SCSITargetIdentifier theT,
822SCSILogicalUnitNumbertheL,
823SCSIServiceResponse serviceResponse );
824
825void CompleteLogicalUnitReset (
826SCSITargetIdentifier theT,
827SCSILogicalUnitNumbertheL,
828SCSIServiceResponse serviceResponse );
829
830void CompleteTargetReset (
831SCSITargetIdentifier theT,
832SCSIServiceResponse serviceResponse );
833
834/*!
835@function NotifyClientsOfBusReset
836@abstract Method called to notify clients that a bus reset has occurred.
837@discussion This method is used by the HBA child class to inform the
838parent class and any clients that a bus reset has occurred.
839*/
840
841voidNotifyClientsOfBusReset ( void );
842
843/*!
844@function NotifyClientsOfPortStatusChange
845@abstract Method called to notify clients of port status change events.
846@discussion This method is used by the HBA child class to inform the
847parent class and any clients that a port has changed status.
848*/
849
850voidNotifyClientsOfPortStatusChange ( SCSIPortStatus newStatus );
851
852/*!
853@function GetSCSIDomainIdentifier
854@abstract Accessor method to get the SCSI Domain Identifier.
855@discussion Accessor method to get the SCSI Domain Identifier.
856@result returns SCSI Domain Identifier.
857*/
858
859SInt32GetSCSIDomainIdentifier ( void );
860
861/*!
862@function GetProvider
863@abstract Accessor method to get the IOService which is the controller's
864provider.
865@discussion Accessor method to get the IOService which is the
866controller's provider.
867@result returns pointer to IOService.
868*/
869
870IOService *GetProvider ( void );
871
872/*!
873@function GetWorkLoop
874@abstract Accessor method to get the IOWorkLoop associated with this
875HBA.
876@discussion Accessor method to get the IOWorkLoop associated with this
877HBA.
878@result returns pointer to IOWorkLoop.
879*/
880
881IOWorkLoop *GetWorkLoop ( void ) const;
882
883/*!
884@function GetCommandGate
885@abstract Accessor to get an IOCommandGate associated with the workloop.
886@discussion Accessor to get an IOCommandGate associated with the
887workloop.
888@result returns pointer to IOCommandGate.
889*/
890
891IOCommandGate *GetCommandGate ( void );
892
893// ---- SCSI Parallel Task Object Accessors ----
894
895/*!
896@function GetSCSITaskIdentifier
897@abstract Method to retrieve a SCSITaskIdentifier from a valid
898SCSIParallelTaskIdentifier.
899@discussion Method to retrieve a SCSITaskIdentifier from a valid
900SCSIParallelTaskIdentifier.
901@param parallelTask A valid SCSIParallelTaskIdentifier.
902@result returns SCSITaskIdentifier that represents the original request
903from the SCSI Application Layer client.
904*/
905
906SCSITaskIdentifierGetSCSITaskIdentifier (
907SCSIParallelTaskIdentifier parallelTask );
908
909/*!
910@function GetTargetIdentifier
911@abstract Method to get the SCSITargetIdentifier associated with a
912request.
913@discussionMethod to get the SCSITargetIdentifier associated with a
914request.
915@param parallelTask A valid SCSIParallelTaskIdentifier.
916@result returns SCSITargetIdentifier
917*/
918
919SCSITargetIdentifierGetTargetIdentifier (
920SCSIParallelTaskIdentifier parallelTask );
921
922// ---- Methods for Accessing data in the client's SCSI Task Object ----
923// Method to retrieve the LUN that identifies the Logical Unit whose Task
924// Set to which this task is to be added.
925
926/*!
927@function GetLogicalUnitNumber
928@abstract Method to get the logical unit number associated with a
929request.
930@discussion Method to get the logical unit number associated with a
931request.
932@param parallelTask A valid SCSIParallelTaskIdentifier.
933@result returns a valid 64-bit logical unit number.
934*/
935
936SCSILogicalUnitNumberGetLogicalUnitNumber (
937SCSIParallelTaskIdentifier parallelTask );
938
939/*!
940@function GetTaggedTaskIdentifier
941@abstract Method to retrieve the SCSI Tagged Task Identifier of the
942task. If the returned value is equal to kSCSIUntaggedTaskIdentifier,
943then this task is untagged.
944@param parallelTask A valid SCSIParallelTaskIdentifier.
945@result an SCSITaskAttribute value.
946*/
947
948SCSITaggedTaskIdentifier GetTaggedTaskIdentifier (
949SCSIParallelTaskIdentifierparallelTask );
950
951/*!
952@function GetTaskAttribute
953@abstract Method to retrieve the SCSI Task Attribute of the task
954@param parallelTask A valid SCSIParallelTaskIdentifier.
955@result an SCSITaskAttribute value.
956*/
957
958SCSITaskAttributeGetTaskAttribute (
959SCSIParallelTaskIdentifierparallelTask );
960
961/*!
962@function GetCommandDescriptorBlockSize
963@abstract Method to retrieve the size of the SCSI Command Descriptor
964Block (CDB).
965@param parallelTask A valid SCSIParallelTaskIdentifier.
966@result returns the size of the SCSI Command Descriptor Block in bytes.
967*/
968
969UInt8GetCommandDescriptorBlockSize (
970SCSIParallelTaskIdentifier parallelTask );
971
972/*!
973@function GetCommandDescriptorBlock
974@abstract Method to retrieve the SCSI Command Descriptor Block (CDB).
975@discussion This will always return a 16 Byte CDB. If the Protocol Layer
976driver does not support 16 Byte CDBs, it will have to create a local
977SCSICommandDescriptorBlock variable to get the CDB data and then
978transfer the needed bytes from there.
979@param parallelTask A valid SCSIParallelTaskIdentifier.
980@param cdbData is a SCSICommandDescriptorBlock pointer to 16 byte CDB
981@result returns true if data was copied to cdbData pointer
982*/
983
984boolGetCommandDescriptorBlock (
985SCSIParallelTaskIdentifier parallelTask,
986SCSICommandDescriptorBlock * cdbData );
987
988/*!
989@function GetDataTransferDirection
990@abstract Retrieves the data transfer direction for any data associated
991with the request.
992@param parallelTask A valid SCSIParallelTaskIdentifier.
993@result One of the valid data transfer directions described in
994<IOKit/scsi/SCSITask.h>
995*/
996
997UInt8GetDataTransferDirection ( SCSIParallelTaskIdentifier parallelTask );
998
999/*!
1000@function GetRequestedDataTransferCount
1001@abstract Retrieves the requested data transfer count for any data
1002associated with the request.
1003@param parallelTask A valid SCSIParallelTaskIdentifier.
1004@result The requested data transfer count in bytes.
1005*/
1006
1007UInt64GetRequestedDataTransferCount (
1008SCSIParallelTaskIdentifier parallelTask );
1009
1010/*!
1011@function GetRealizedDataTransferCount
1012@abstract Retrieves the realized data transfer count for any data
1013associated with the request.
1014@param parallelTask A valid SCSIParallelTaskIdentifier.
1015@result The realized data transfer count in bytes.
1016*/
1017
1018UInt64GetRealizedDataTransferCount (
1019SCSIParallelTaskIdentifier parallelTask );
1020
1021/*!
1022@function SetRealizedDataTransferCount
1023@abstract Sets the realized data transfer count in bytes.
1024@param parallelTask A valid SCSIParallelTaskIdentifier.
1025@param realizedTransferCountInBytes is the number of bytes actually
1026transferred.
1027@result true means the data transfer count was successfully set.
1028*/
1029
1030boolSetRealizedDataTransferCount (
1031SCSIParallelTaskIdentifier parallelTask,
1032UInt64 realizedTransferCountInBytes );
1033
1034/*!
1035@function IncrementRealizedDataTransferCount
1036@abstract Increments the realized data transfer count. This method is
1037helpful for when the HBA has to do multiple passes of DMA because there
1038are more scatter-gather elements than it can process in one pass.
1039@param parallelTask A valid SCSIParallelTaskIdentifier.
1040@param realizedTransferCountInBytes is the number of bytes to add to the
1041realized data count for the task.
1042*/
1043
1044voidIncrementRealizedDataTransferCount (
1045SCSIParallelTaskIdentifier parallelTask,
1046UInt64 realizedTransferCountInBytes );
1047
1048/*!
1049@function GetDataBuffer
1050@abstract Method to retrieve client buffer from the request.
1051@param parallelTask A valid SCSIParallelTaskIdentifier.
1052@result returns pointer to an IOMemoryDescriptor which represents the
1053buffer.
1054*/
1055
1056IOMemoryDescriptor * GetDataBuffer (
1057SCSIParallelTaskIdentifier parallelTask );
1058
1059/*!
1060@function GetDataBufferOffset
1061@abstract Method to retrieve offset into client buffer at which to start
1062processing.
1063@param parallelTask A valid SCSIParallelTaskIdentifier.
1064@result returns offset in bytes
1065*/
1066
1067UInt64GetDataBufferOffset ( SCSIParallelTaskIdentifier parallelTask );
1068
1069/*!
1070@function GetDMACommand
1071@abstract Method to retrieve a pointer to an IODMACommand from the request.
1072@discussion For devices utilizing DMA, the IODMACommand object should be
1073obtained via GetDMACommand(). The subclass is responsible for calling prepare()
1074on the IODMACommand object using the proper offset obtained via GetDataBufferOffset()
1075and correct size obtained via GetRequestedDataTransferCount(). The subclass
1076is further responsible for calling complete() on the IODMACommand object once
1077all DMA operations have finished.
1078NB: Subclasses should not call IODMACommand::setMemoryDescriptor().
1079@param parallelTask A valid SCSIParallelTaskIdentifier.
1080@result returns pointer to an IODMACommand which is used in conjunction
1081with the task.
1082*/
1083
1084IODMACommand * GetDMACommand (
1085SCSIParallelTaskIdentifier parallelTask );
1086
1087/*!
1088@function GetTimeoutDuration
1089@abstract Method to retrieve the timeout duration in milliseconds for a
1090request.
1091@discussion Method to retrieve the timeout duration in milliseconds for
1092a request. A value of zero represents an infinite timeout, or on
1093hardware where infinite timeouts are not possible, substitute the
1094longest timeout possible.
1095@param parallelTask A valid SCSIParallelTaskIdentifier.
1096@result returns timeout duration in milliseconds
1097*/
1098
1099UInt32GetTimeoutDuration ( SCSIParallelTaskIdentifier parallelTask );
1100
1101/*!
1102@function SetAutoSenseData
1103@abstract Method to set the auto sense data buffer associated with a
1104request.
1105@param parallelTask A valid SCSIParallelTaskIdentifier.
1106@param newSensedata pointer to auto sense data buffer
1107@result returns true if data in newSenseData was succesfully into the
1108task object
1109*/
1110
1111boolSetAutoSenseData (
1112SCSIParallelTaskIdentifier parallelTask,
1113SCSI_Sense_Data * newSenseData,
1114UInt8senseDataSize );
1115
1116/*!
1117@function GetAutoSenseData
1118@abstract Method to retrieve auto sense data buffer associated with a
1119request.
1120@param parallelTask A valid SCSIParallelTaskIdentifier.
1121@param receivingBuffer pointer to auto sense data buffer
1122@result returns true if successfully copied data into receivingBuffer
1123*/
1124
1125 boolGetAutoSenseData (
1126 SCSIParallelTaskIdentifier parallelTask,
1127 SCSI_Sense_Data * receivingBuffer,
1128 UInt8senseDataSize );
1129
1130/*!
1131@function GetAutoSenseDataSize
1132@abstract Method to retrieve auto sense data buffer size associated with a
1133request.
1134@param parallelTask A valid SCSIParallelTaskIdentifier.
1135@result returns Size of auto sense data buffer.
1136*/
1137
1138 UInt8GetAutoSenseDataSize (
1139 SCSIParallelTaskIdentifier parallelTask );
1140
1141
1142/*!
1143@function GetSCSIParallelFeatureNegotiation
1144@abstract Method to retrieve the requested value for negotiation of the.
1145@discussion Query as to whether the SCSI Parallel Device object has
1146negotiated wide data transfers.
1147@param parallelTask A valid SCSIParallelTaskIdentifier.
1148@result A valid SCSIParallelFeatureControl.
1149*/
1150
1151SCSIParallelFeatureRequestGetSCSIParallelFeatureNegotiation (
1152SCSIParallelTaskIdentifier parallelTask,
1153SCSIParallelFeature requestedFeature );
1154
1155/*!
1156@function GetSCSIParallelFeatureNegotiationCount
1157@abstract Method to retrieve the number of requested negotiations.
1158@discussion Query as to the number of SCSI Parallel Features that are
1159requested to either be negotitated or cleared. These are all features
1160that are set to either kSCSIParallelFeature_AttemptNegotiation or
1161kSCSIParallelFeature_ClearNegotiation. If the return value is zero,
1162then all features are set to kSCSIParallelFeature_NoNegotiation
1163and all feature negotiations are to remain as they currently exist.
1164@param parallelTask A valid SCSIParallelTaskIdentifier.
1165@result an unsigned integer up to 64 bits in size.
1166*/
1167
1168UInt64GetSCSIParallelFeatureNegotiationCount (
1169SCSIParallelTaskIdentifier parallelTask);
1170
1171/*!
1172@function SetSCSIParallelFeatureNegotiationResult
1173@abstract Method to set the wide data transfer negotiation result.
1174@discussion Method to set the wide data transfer negotiation result.
1175@param parallelTask A valid SCSIParallelTaskIdentifier.
1176@param requestedFeature The SCSIParallelFeature that the has been set to
1177newResult.
1178@param newResult A valid SCSIParallelFeatureResult value.
1179*/
1180
1181voidSetSCSIParallelFeatureNegotiationResult (
1182SCSIParallelTaskIdentifier parallelTask,
1183SCSIParallelFeature requestedFeature,
1184SCSIParallelFeatureResult newResult );
1185
1186/*!
1187@function GetSCSIParallelFeatureNegotiationResult
1188@abstract Method to retrieve the result of any wide transfer
1189negotiations.
1190@discussion Query as to whether the SCSI Parallel Controller object has
1191negotiated wide data transfers.
1192@param parallelTask A valid SCSIParallelTaskIdentifier.
1193@result A valid SCSIParallelFeatureResult.
1194*/
1195
1196SCSIParallelFeatureResultGetSCSIParallelFeatureNegotiationResult (
1197SCSIParallelTaskIdentifier parallelTask,
1198SCSIParallelFeature requestedFeature );
1199
1200/*!
1201@function GetSCSIParallelFeatureNegotiationResultCount
1202@abstract Method to retrieve the number of changed negotiations.
1203@discussion Query as to the number of SCSI Parallel Features that have
1204been changed to either negotitated or cleared. These are all features
1205that are set to either kSCSIParallelFeature_NegotitiationCleared or
1206kSCSIParallelFeature_NegotitiationSuccess. If the return value is zero,
1207then all features are set to kSCSIParallelFeature_NegotitiationUnchanged.
1208@param parallelTask A valid SCSIParallelTaskIdentifier.
1209@result an unsigned integer up to 64 bits in size.
1210*/
1211
1212UInt64GetSCSIParallelFeatureNegotiationResultCount (
1213SCSIParallelTaskIdentifier parallelTask);
1214
1215// Controller Task Identifier related member routines
1216
1217/*!
1218@function SetControllerTaskIdentifier
1219@abstract Method to set the Controller Task Identifier.
1220@discussion This method allows the Controller Child Class
1221driver to set a unique identifier to associate with the specified
1222SCSI Parallel Task. This identifier is designed to be used by
1223controllers that do not have access to the LUN and Tag information
1224when notified by the HBA that a request has completed.
1225If the kSCSIParallelTaskControllerIDQueueHead is used, this
1226member routine will return the first Task on the queue.
1227@param parallelTask A valid SCSIParallelTaskIdentifier.
1228@param newIdentifier unsigned 64 bit integer token.
1229@result none
1230*/
1231
1232voidSetControllerTaskIdentifier (
1233SCSIParallelTaskIdentifier parallelTask,
1234UInt64 newIdentifier );
1235
1236UInt64GetControllerTaskIdentifier (
1237SCSIParallelTaskIdentifier parallelTask);
1238
1239
1240// The HBA Data related fields
1241
1242/*!
1243@function GetHBADataSize
1244@abstract Method to retrieve the HBA Data Size in bytes.
1245@discussion Method to retrieve the HBA Data Size in bytes.
1246@param parallelTask A valid SCSIParallelTaskIdentifier.
1247@result returns HBA Data size in bytes.
1248*/
1249
1250UInt32GetHBADataSize ( SCSIParallelTaskIdentifier parallelTask );
1251
1252/*!
1253@function GetHBADataPointer
1254@abstract Method to retrieve the HBA Data pointer.
1255@discussion Method to retrieve the HBA Data pointer.
1256@param parallelTask A valid SCSIParallelTaskIdentifier.
1257@result returns pointer to buffer for HBA specific data, NULL if
1258none found or GetHBADataSize() returns zero.
1259*/
1260
1261void *GetHBADataPointer ( SCSIParallelTaskIdentifier parallelTask );
1262
1263/*!
1264@function GetHBADataDescriptor
1265@abstract Method to retrieve the IOMemoryDescriptor associated with
1266the HBA Data.
1267@discussion Method to retrieve the IOMemoryDescriptor associated with
1268the HBA Data.
1269@param parallelTask A valid SCSIParallelTaskIdentifier.
1270@result returns pointer to an IOMemoryDescriptor that wraps the HBA
1271specific data buffer, NULL if none found or GetHBADataSize() returns zero.
1272*/
1273
1274IOMemoryDescriptor *GetHBADataDescriptor (
1275SCSIParallelTaskIdentifier parallelTask );
1276
1277// ---- SCSI Parallel Device Object Accessors ----
1278
1279// The HBA Data related fields
1280
1281/*!
1282@function GetHBATargetDataSize
1283@abstract Method to retrieve the HBA Data Size in bytes.
1284@discussion Method to retrieve the HBA Data Size in bytes.
1285@param targetDevice A valid SCSITargetIdentifier.
1286@result returns HBA Data size in bytes.
1287*/
1288
1289UInt32GetHBATargetDataSize ( SCSITargetIdentifier targetID );
1290
1291/*!
1292@function GetHBATargetDataPointer
1293@abstract Method to retrieve the HBA Data pointer.
1294@discussion Method to retrieve the HBA Data pointer.
1295@param targetDevice A valid SCSITargetIdentifier.
1296@result returns pointer to buffer for HBA specific data, NULL if
1297none found or GetHBADataSize is zero.
1298*/
1299
1300void *GetHBATargetDataPointer ( SCSITargetIdentifier targetID );
1301
1302
1303#if 0
1304#pragma mark -
1305#pragma mark Additional Child Class APIs
1306#endif
1307
1308
1309// ---- Timeout Related Methods ----
1310
1311/*!
1312@function SetTimeoutForTask
1313@abstract Method to set the timeout duration in milliseconds for a
1314request.
1315@discussion Method to set the timeout duration in milliseconds for a
1316request.
1317@param parallelTask A valid SCSIParallelTaskIdentifier.
1318@param timeoutOverride A timeout value in milliseconds in case the
1319HBA driver wishes to override the default value provided in the
1320parallelTask.
1321*/
1322
1323voidSetTimeoutForTask ( SCSIParallelTaskIdentifier parallelTask,
1324UInt32timeoutOverride = 0 );
1325
1326/*!
1327@function HandleTimeout
1328@abstract Method to handle command timeouts.
1329@discussion Method to handle command timeouts. This should
1330be overridden by the child class in order to clean up HBA
1331specific structures after a timeout has occurred. This method
1332is called on the workloop (it holds the gate).
1333@param parallelRequest A valid SCSIParallelTaskIdentifier.
1334*/
1335
1336OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 9 );
1337
1338virtual voidHandleTimeout (
1339SCSIParallelTaskIdentifier parallelRequest );
1340
1341
1342// ---- Filter Interrupt ----
1343
1344/*!
1345@function FilterInterruptRequest
1346@abstract Filter method called at primary interrupt time.
1347@discussion Filter method called at primary interrupt time.
1348This should only be overridden by the child class in order
1349to determine if an interrupt occurred for this controller instance.
1350Since all work occurs at primary interrupt time, this routine
1351should be quick and efficient and defer as much processing as
1352possible to the HandleInterruptRequest() method.
1353
1354NOTE: Unlike the HandleInterruptRequest() and HandleTimeout()
1355methods, FilterInterruptRequest() is NOT called with the
1356workloop lock held.
1357
1358If the value returned by FilterInterruptRequest() is true, the
1359secondary interrupt thread will be scheduled and the hardware
1360interrupt line will be disabled. If the controller instance shares
1361that interrupt line with other devices, it can cause large
1362interrupt latencies. If the controller instance can disable the
1363interrupt in the chip itself, the following can be done to reduce
1364interrupt latencies:
1365
1366- Interrupt occurs
1367- FilterInterruptRequest() method is called.
1368- If the interrupt is not for this controller, return false
1369 immediately.
1370- If the interrupt is for this controller, and the controller
1371 can disable interrupts for this chip, the controller should
1372 disable the interrupts for this chip, call SignalInterrupt(),
1373 and return false. This causes the secondary interrupt thread
1374 to get scheduled, yet does not disable the interrupt line for
1375 all devices tied to that interrupt. This effectively allows
1376 other devices to process their interrrupts, thus reducing
1377 interrupt latency for those devices.
1378- HandleInterruptRequest() method is called.
1379- Controller processes interrupt and completes I/O requests.
1380- Controller re-enables interrupts for the device.
1381
1382NOTE: If you use this approach, the interrupting condition MUST be
1383cleared from the hardware, otherwise an infinite process interrupt
1384loop will occur.
1385
1386If the controller cannot disable interrupts on the chip, it should
1387simply return true if an interrupt has occurred for its device.
1388
1389@result True if the hardware interrupt line should be disabled,
1390otherwise false.
1391*/
1392
1393OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 10 );
1394
1395virtual boolFilterInterruptRequest ( void );
1396
1397/*!
1398@function InitializeDMASpecification
1399@abstract Called to initialize an IODMACommand with a DMA specification.
1400@param command A pointer to a valid IODMACommand object. Subclasses
1401should override this method and call IODMACommand::initWithSpecification()
1402supplying the proper arguments to that method based on the DMA strategy.
1403@result boolean value indicating success or failure.
1404*/
1405OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 11 );
1406
1407virtual boolInitializeDMASpecification ( IODMACommand * command );
1408
1409/*!
1410@function CreateDeviceInterrupt
1411@abstract Called to create an IOInterruptEventSource for the device. Subclasses
1412may wish to use a different interrupt index than 0 (e.g. for using PCI Message
1413Signaled Interrupts) or might not need an interrupt at all (virtual HBA).
1414@param action A pointer to the action routine that should be passed to either
1415IOInterruptEventSource::interruptEventSource() or
1416IOFilterInterruptEventSource::filterInterruptEventSource as the method to call
1417when an interrupt occurs for the device (sometimes called the "deferred procedure call"
1418or the "secondary context method". By passing this routine along, it will
1419properly wire up the HandleInterruptRequest() method you should override to handle
1420interrupts.
1421@param filter A pointer to the filter routine that should be passed to
1422IOFilterInterruptEventSource::filterInterruptEventSource as the method to call
1423at primary interrupt time when an interrupt occurs for the device.
1424By passing this routine along, it will properly wire up the
1425FilterInterruptRequest() method you may override to handle primary interrupts.
1426@result IOInterruptEventSource. May return NULL if and only if there is no
1427hardware interrupt associated with this device.
1428*/
1429OSMetaClassDeclareReservedUsed ( IOSCSIParallelInterfaceController, 12 );
1430
1431virtual IOInterruptEventSource *CreateDeviceInterrupt (
1432IOInterruptEventSource::Actionaction,
1433IOFilterInterruptEventSource::Filterfilter,
1434IOService *provider );
1435
1436// Padding for the Child Class API
1437OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 13 );
1438OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 14 );
1439OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 15 );
1440OSMetaClassDeclareReservedUnused ( IOSCSIParallelInterfaceController, 16 );
1441
1442
1443#if 0
1444#pragma mark -
1445#pragma mark Internal Use Only
1446#endif
1447
1448private:
1449
1450// binary compatibility instance variable expansion
1451struct ExpansionData { };
1452ExpansionData * fIOSCSIParallelInterfaceControllerExpansionData;
1453
1454IOService *fProvider;
1455OSSet *fClients;
1456
1457static SInt32fSCSIParallelDomainCount;
1458SInt32fSCSIDomainIdentifier;
1459
1460// The HBA attributes
1461SCSIInitiatorIdentifierfInitiatorIdentifier;
1462
1463// The maximum SCSI Device Identifier support by the HBA
1464// This is retreived from the child class via the
1465SCSIDeviceIdentifierfHighestSupportedDeviceID;
1466
1467// The total number of tasks that the HBA can proccess at a time.
1468// This is retrieved from the child class via ReportMaximumTaskCount
1469UInt32fSupportedTaskCount;
1470
1471// The Number of requests that are currently outstanding for the current
1472// instantiation.
1473UInt16fOutstandingRequests;
1474
1475// The member variable to indicate if the current instantiation has been
1476// succesfully intialized.
1477boolfHBAHasBeenInitialized;
1478
1479// The member variable to indicate if the current instantiation is running.
1480// A true means that the last or only Start call made was successful. A
1481// false value means that either a successful Start has not been made or a
1482// Stop call has been made.
1483boolfHBACanAcceptClientRequests;
1484
1485// The pool for the available SCSI Parallel Task objects
1486IOCommandPool *fParallelTaskPool;
1487
1488// WorkLoop variables
1489IOWorkLoop *fWorkLoop;
1490IOTimerEventSource *fTimerEvent;
1491IOInterruptEventSource *fDispatchEvent;
1492
1493IOCommandGate *fControllerGate;
1494
1495boolAllocateSCSIParallelTasks ( void );
1496voidDeallocateSCSIParallelTasks ( void );
1497
1498IOWorkLoop *getWorkLoop ( void ) const;
1499bool CreateWorkLoop ( IOService * provider );
1500void ReleaseWorkLoop ( void );
1501
1502// SCSI Parallel Device List
1503// The SCSI Parallel Device List will consist of 16 elements to represent
1504// identifiers that end in 0h through Fh. Each array element will point
1505// to a device object that represents the beginning of a linked list of
1506// device objects. By using an array of linked lists, the traversal time
1507// to find an object on a bus that supports a large number of devices, such
1508// as Fibre Channel, will be significantly lower than having to walk a list
1509// that is comprised of all devices on the bus. For parallel wide and
1510// narrow busses, which support 16 and 8 devices respectively, this will act
1511// like a simple array of device objects.
1512enum
1513{
1514kSCSIParallelDeviceListArrayCount = 16,
1515kSCSIParallelDeviceListIndexMask= 0x0F
1516};
1517
1518IOSimpleLock * fDeviceLock;
1519IOSCSIParallelInterfaceDevice *
1520fParallelDeviceList[kSCSIParallelDeviceListArrayCount];
1521
1522voidInitializeDeviceList ( void );
1523voidAddDeviceToTargetList (
1524IOSCSIParallelInterfaceDevice *newDevice );
1525voidRemoveDeviceFromTargetList (
1526IOSCSIParallelInterfaceDevice * victimDevice );
1527
1528// The Interrupt Service Routine for the controller.
1529static voidServiceInterrupt (
1530OSObject *theObject,
1531IOInterruptEventSource *theSource,
1532intcount );
1533
1534static voidTimeoutOccurred ( OSObject * owner, IOTimerEventSource * sender );
1535
1536static boolFilterInterrupt (
1537OSObject *theObject,
1538IOFilterInterruptEventSource *theSource );
1539
1540// IOService support methods
1541// These shall not be overridden by the HBA child classes.
1542boolstart ( IOService * provider );
1543voidstop ( IOService * provider );
1544
1545
1546protected:
1547
1548// These may be overriden by the HBA child classes if necessary, but should
1549// call the superclass implementation.
1550virtual boolhandleOpen (
1551IOService * client,
1552IOOptionBits options,
1553void * arg );
1554
1555virtual voidhandleClose (
1556IOService * client,
1557IOOptionBits options );
1558
1559virtual boolhandleIsOpen (
1560const IOService * client ) const;
1561
1562virtual boolwillTerminate ( IOService * provider, IOOptionBits options );
1563virtual booldidTerminate ( IOService * provider, IOOptionBits options, bool * defer );
1564
1565};
1566
1567
1568#endif/* __IOKIT_IO_SCSI_PARALLEL_INTERFACE_CONTROLLER_H__ */

Archive Download this file

Revision: 1466