public:
virtual void RWCompletion(struct context *cx);
We implement this function in this class. It is called from the base class when an IO operation completes.
protected:
virtual IOReturn allocateFormatBuffer(UInt8 **buf,UInt32 *buflen);
If a format buffer is to be used, then "allocateFormatBuffer" and deleteFormatBuffer" must be overridden to manage the buffer. The buffer must be prepared for IO upon return from allocateFormatBuffer. The default implementations of these methods don't allocate a buffer.
Name Description buf A pointer for the returned buffer pointer. buflen The desired length of the buffer, in bytes.
protected:
virtual UInt8 composeFormatBuffer(UInt8 *buf,UInt32 buflen);
This method will be called to compose the data in the format buffer.
The default implementation of this method does nothing.
Result: The return value should be the desired values for the "CmpLst" and Defect List Format bits in the CDB. The default implementation returns zero.
Name Description buf A pointer to the format data buffer. buflen The size of the format data buffer, in bytes.
public:
virtual OSDictionary *constructDeviceProperties(void);
This function creates a set of properties reflecting information
about the device.
This function is presently not used.
protected:
virtual UInt32 createFormatCdb( UInt64 byteCapacity, /* in */ UInt8 *cdb, /* in */ UInt32 *cdbLength, /* out */ UInt8 buf[], /* in */ UInt32 bufLen, /* in */ UInt32 *maxAutoSenseLength, /* out */ UInt32 *timeoutSeconds); /* out */
Override this to control the cdb created for a format operation.
The default implementation creates a 6-byte format command with
no data buffer, disconnect allowed, 8-byte autosense, and a 15-minute timeout.
See also: allocateFormatBuffer, deleteFormatBuffer, composeFormatBuffer.
Result: The IOSCSICommandOptions returned will be used to issue the command.
Name Description byteCapacity The requested byte capacity to which the media should be formatted. This value should have been previously validated, otherwise the device may return an error. cdb A pointer to the CDB bytes. cdbLength The length of the CDB in bytes. block The device block to be written. nblks The number of blocks to be transferred. maxAutoSenseLength The maximum size of the autosense data, in bytes. A value of zero will disable autosense. timeoutSeconds The command timeout in seconds.
protected:
virtual IOService * createNub(void);
This method calls instantiateNub, then init, attach, and register.
Result: A pointer to the nub or NULL if something failed.protected:
virtual void deleteFormatBuffer(UInt8 *buf,UInt32 buflen);
If a format buffer is to be used, then "allocateFormatBuffer" and deleteFormatBuffer" must be overridden to manage the buffer. The default implementation of this method does nothing.
Name Description buf A pointer to the buffer to delete. buflen The size of the buffer, in bytes.
public:
virtual bool deviceTypeMatches(UInt8 inqBuf[],UInt32 inqLen);
We implement this function so we can return a match on the hard disk device type.
public:
virtual IOReturn doAsyncReadWrite(IOMemoryDescriptor *buffer, UInt32 block,UInt32 nblks, gdCompletionFunction action, IOService *target,void *param);
See IOHDDriveNub for details.
public:
virtual IOReturn doEjectMedia(void);
See IOHDDriveNub for details.
public:
virtual IOReturn doFormatMedia(UInt64 byteCapacity);
The default implementation ignores the byteCapacity parameter. See IOHDDriveNub for details.
public:
virtual UInt32 doGetFormatCapacities(UInt64 * capacities, UInt32 capacitiesMaxCount) const;
The default implementation of this method returns a value of block size * max block, and a capacities count of 1. See IOHDDriveNub for details.
public:
virtual IOReturn doLockUnlockMedia(bool doLock);
This method issues a standard SCSI Prevent/Allow command to lock or unlock the media in the drive. See IOHDDriveNub for details.
protected:
virtual IOReturn doStart(void);
This method calls doStartStop.
protected:
virtual IOReturn doStartStop(bool start,bool loadEject,UInt8 powerCondition);
This method issues a SCSI Start Stop Unit command to start or stop the device. Because the powerCondition value is only for use with SCSI-3 devices, the current implementation ignores powerCondition.
Name Description start True to start (spin-up) the media; False to stop (spin-down) the media. loadEject True to eject; False to not eject. This parameter is applicable only to a stop operation. powerCondition The power condition to which the drive should transition. This is a SCSI-3 capability; it is presently unused.
protected:
virtual IOReturn doStop(void);
This method calls doStartStop.
public:
virtual IOReturn doSyncReadWrite(IOMemoryDescriptor *buffer,UInt32 block,UInt32 nblks);
See IOHDDriveNub for details.
public:
virtual IOReturn doSynchronizeCache(void);
This method issues a SCSI Synchronize Cache command, to ensure that all blocks in the device cache are written to the media. See IOHDDriveNub for details.
protected:
virtual const char * getDeviceTypeName(void);
The default implementation of this method returns kDeviceTypeHardDisk.
protected:
virtual UInt32 getEjectPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.Result: The return value must be a valid power state value.protected:
virtual UInt32 getExecuteCDBPowerState(void); /* default = kAllOn */
protected:
virtual UInt32 getFormatMediaPowerState(void); /* default = kAllOn */
The default implementation of this method returns kAllOn.
Result: The return value must be a valid power state value.protected:
virtual unsigned long getInitialPowerState(void); /* default = kAllOn */
The default implementation of this method returns kAllOn, assuming that the drive spindle spins up initially.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getInquiryPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getLockUnlockMediaPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getReadCapacityPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getReadWritePowerState(void); /* default = kAllOn */
The default implementation of this method returns kAllOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getReportWriteProtectionPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getStartPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getStopPowerState(void); /* default = kAllOn */
The default implementation of this method returns kAllOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getSynchronizeCachePowerState(void); /* default = kAllOn */
The default implementation of this method returns kAllOn.
Result: The return value must be a valid power state value.protected:
virtual UInt32 getTestUnitReadyPowerState(void); /* default = kElectronicsOn */
The default implementation of this method returns kElectronicsOn.
Result: The return value must be a valid power state value.protected:
virtual unsigned long initialPowerStateForDomainState( IOPMPowerFlags domainState );
This method is called to obtain the initial power state for the device, by calling getInitialPowerState.
Result: The return value must be a valid power state value.
Name Description domainState Power domain state flags.
protected:
virtual IOService * instantiateNub(void);
A subclass will override this method to change the type of nub created. A CD driver, for example, will instantiate an IOSCSICDDriveNub instead of the default implementation's IOSCSIHDDriveNub.
protected:
virtual unsigned long maxCapabilityForDomainState( IOPMPowerFlags domainState );
This method is called to obtain the maximum power level obtainable for the given state.
Result: The return value must be a valid power state value.
Name Description domainState Power domain state flags.
protected:
virtual IOReturn powerStateDidChangeTo( unsigned long, unsigned long stateOrdinal, IOService* );
This method is called when the power state changes. We call restoreElectronicsState if necessary, then call dequeueCommands if we have changed to a state that has power.
Name Description stateOrdinal The power level to which we have changed.
protected:
virtual unsigned long powerStateForDomainState( IOPMPowerFlags domainState );
This method is called to obtain the maximum power level obtainable for the given state.
Result: The return value must be a valid power state value.
Name Description domainState Power domain state flags.
protected:
virtual IOReturn powerStateWillChangeTo( unsigned long, unsigned long stateOrdinal, IOService* );
This method is called when the power state will change. If we are powering-up from kAllOff, we schedule a call to restoreElectronicsState. If, instead, we are powering-down from an "on" state, we schedule a call to saveElectronicsState.
Name Description stateOrdinal The power level to which we will change.
protected:
virtual bool powerTickle(UInt32 desiredState);
This method simply "tickles" the Power Management subsystem to ensure that the device transitions to the desired state if necessary.
public:
virtual IOReturn reportMediaState(bool *mediaPresent,bool *changed);
This method reports whether media is present or not, and also
whether the media state has changed since the last call to
reportMediaState. The default implementation issues a SCSI Test
Unit Ready command: depending on the result of that command, the
following cases are reported:
1. TUR status == good completion: we report media present and return
kIOReturnSuccess.
2. TUR status != good completion, but good autosense returned:
2a: sense key says not ready: we report media not present
and return kIOReturnSuccess.
2b: sense key is anything else: we report media not present
and return kIOReturnIOError.
3. TUR status != good completion, and no autosense data: we do not
set mediaPresent or changedState, and we return whatever result
came back from the SCSI operation.
protected:
virtual IOReturn restoreElectronicsState(void);
This method is called just after the device transitions from a powered-off state.
The default implementation of this method does nothing and returns kIOReturnSuccess.
protected:
virtual IOReturn saveElectronicsState(void);
This method is called just before the device transitions to a powered-off state.
The default implementation of this method does nothing and returns kIOReturnSuccess.
protected:
virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService* );
This method is called to cause a change in power state. We handle changes to and from kAllOn and kElectronicsOn, which are done by spinning up and down the media.
Name Description powerStateOrdinal The power level to which we must change.
public:
virtual bool start(IOService * provider);
We override IOBasicSCSI::start so we can initialize Power Management, then we call createNub to create an IOSCSIHDDriveNub.
protected:bool _mediaPresent;
True if media is present; False if media is not present.
protected:bool _restoreState; /* true if we must restore after power-up */ };
True if we must restore the device electronics state after a power-up.
protected:bool _startStopDisabled;
True if the start/stop commands are disabled due to an error.
© 2000 Apple Computer, Inc. (Last Updated 2/23/2000)