📄 scsilib.c
字号:
STATUS scsiBusReset ( SCSI_CTRL * pScsiCtrl /* ptr to SCSI controller info */ ) { if (pScsiIfTbl->scsiBusReset != NULL) return ((STATUS) (pScsiIfTbl->scsiBusReset) (pScsiCtrl)); else return (ERROR); }/********************************************************************************* scsiPhaseNameGet - get the name of a specified SCSI phase** This routine returns a pointer to a string which is the name of the SCSI* phase input as an integer. It's primarily used to improve readability of* debugging messages.** RETURNS: A pointer to a string naming the SCSI phase input** NOMANUAL*/char * scsiPhaseNameGet ( int scsiPhase /* phase whose name to look up */ ) { if (pScsiIfTbl->scsiPhaseNameGet != NULL) return ((char *) (pScsiIfTbl->scsiPhaseNameGet) (scsiPhase)); else return (NULL); }/********************************************************************************* scsiCmdBuild - fills in the fields of a SCSI command descriptor block** Typically, this routine is not called directly by the user, but by other* routines in scsiLib. It fills in fields of a SCSI-command descriptor block* based on the input parameters. The field layouts vary based on the command* group, which is determined from the `opCode'.** RETURNS: ERROR if vendor-unique command group or out-of-bounds parameter,* otherwise OK.** NOMANUAL*/STATUS scsiCmdBuild ( SCSI_COMMAND scsiCmd, /* command to be built */ int * pCmdLength, /* ptr to command length variable */ UINT8 opCode, /* SCSI opCode for command */ int LUN, /* logical unit number for command */ BOOL relAdrs, /* whether to set relative address bit */ int logBlockAdrs, /* logical block address */ int xferLength, /* number of blocks or bytes to xfer */ UINT8 controlByte /* control byte for command */ ) { if (pScsiIfTbl->scsiCmdBuild != NULL) return ((STATUS) (pScsiIfTbl->scsiCmdBuild) (scsiCmd, pCmdLength, opCode, LUN, relAdrs, logBlockAdrs, xferLength, controlByte)); else return (ERROR); }/********************************************************************************* scsiTransact - obtain exclusive use of SCSI controller for a transaction** This routine calls scsiPhaseSequence() to execute the command specified.* If there are physical path management errors, then this routine returns* ERROR. If not, then the status returned from the command is checked. If* it is "Check Condition", then a "Request Sense" CCS command is executed* and the sense key is examined. An indication of the success of the* command is returned (OK or ERROR).** RETURNS: OK, or ERROR if a path management error occurs* or the status or sense information indicates an error.** NOMANUAL*/STATUS scsiTransact ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to the target device */ SCSI_TRANSACTION * pScsiXaction /* ptr to the transaction info */ ) { if (pScsiIfTbl->scsiTransact != NULL) return ((STATUS) (pScsiIfTbl->scsiTransact) (pScsiPhysDev, pScsiXaction)); else return (ERROR); }/********************************************************************************* scsiIoctl - perform a device-specific I/O control function** This routine performs a specified `ioctl' function using a specified SCSI * block device.** RETURNS: The status of the request, or ERROR if the request is unsupported.*/STATUS scsiIoctl ( SCSI_PHYS_DEV * pScsiPhysDev,/* ptr to SCSI block device info */ int function, /* function code */ int arg /* argument to pass called function */ ) { if (pScsiIfTbl->scsiIoctl != NULL) return ((STATUS) (pScsiIfTbl->scsiIoctl) (pScsiPhysDev, function, arg)); else return (ERROR); }/********************************************************************************* scsiFormatUnit - issue a FORMAT_UNIT command to a SCSI device** This routine issues a FORMAT_UNIT command to a specified SCSI device.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiFormatUnit ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ BOOL cmpDefectList, /* whether defect list is complete */ int defListFormat, /* defect list format */ int vendorUnique, /* vendor unique byte */ int interleave, /* interleave factor */ char * buffer, /* ptr to input data buffer */ int bufLength /* length of buffer in bytes */ ) { if (pScsiIfTbl->scsiFormatUnit != NULL) return ((STATUS) (pScsiIfTbl->scsiFormatUnit) (pScsiPhysDev, cmpDefectList, defListFormat, vendorUnique, interleave, buffer, bufLength)); else return (ERROR); }/********************************************************************************* scsiModeSelect - issue a MODE_SELECT command to a SCSI device** This routine issues a MODE_SELECT command to a specified SCSI device.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiModeSelect ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ int pageFormat, /* value of the page format bit (0-1) */ int saveParams, /* value of the save parameters bit (0-1) */ char * buffer, /* ptr to output data buffer */ int bufLength /* length of buffer in bytes */ ) { if (pScsiIfTbl->scsiModeSelect != NULL) return ((STATUS) (pScsiIfTbl->scsiModeSelect) (pScsiPhysDev, pageFormat, saveParams, buffer, bufLength)); else return (ERROR); }/********************************************************************************* scsiModeSense - issue a MODE_SENSE command to a SCSI device** This routine issues a MODE_SENSE command to a specified SCSI device.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiModeSense ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ int pageControl, /* value of the page control field (0-3) */ int pageCode, /* value of the page code field (0-0x3f) */ char * buffer, /* ptr to input data buffer */ int bufLength /* length of buffer in bytes */ ) { if (pScsiIfTbl->scsiModeSense != NULL) return ((STATUS) (pScsiIfTbl->scsiModeSense) (pScsiPhysDev, pageControl, pageCode, buffer, bufLength)); else return (ERROR); }/********************************************************************************* scsiReadCapacity - issue a READ_CAPACITY command to a SCSI device** This routine issues a READ_CAPACITY command to a specified SCSI device.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiReadCapacity ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ int * pLastLBA, /* where to return last logical block address */ int * pBlkLength /* where to return block length */ ) { if (pScsiIfTbl->scsiReadCapacity != NULL) return ((STATUS) (pScsiIfTbl->scsiReadCapacity) (pScsiPhysDev, pLastLBA, pBlkLength)); else return (ERROR); }/********************************************************************************* scsiRdSecs - read sector(s) from a SCSI block device** This routine reads the specified physical sector(s) from a specified* physical device.** RETURNS: OK, or ERROR if the sector(s) cannot be read.*/STATUS scsiRdSecs ( SCSI_BLK_DEV * pScsiBlkDev, /* ptr to SCSI block device info */ int sector, /* sector number to be read */ int numSecs, /* total sectors to be read */ char * buffer /* ptr to input data buffer */ ) { if (pScsiIfTbl->scsiRdSecs != NULL) return ((STATUS) (pScsiIfTbl->scsiRdSecs) (pScsiBlkDev, sector, numSecs, buffer)); else return (ERROR); }/********************************************************************************* scsiWrtSecs - write sector(s) to a SCSI block device** This routine writes the specified physical sector(s) to a specified physical* device.** RETURNS: OK, or ERROR if the sector(s) cannot be written.*/STATUS scsiWrtSecs ( SCSI_BLK_DEV * pScsiBlkDev, /* ptr to SCSI block device info */ int sector, /* sector number to be written */ int numSecs, /* total sectors to be written */ char * buffer /* ptr to input data buffer */ ) { if (pScsiIfTbl->scsiWrtSecs != NULL) return ((STATUS) (pScsiIfTbl->scsiWrtSecs) (pScsiBlkDev, sector, numSecs, buffer)); else return (ERROR); }/********************************************************************************* scsiTestUnitRdy - issue a TEST_UNIT_READY command to a SCSI device** This routine issues a TEST_UNIT_READY command to a specified SCSI device.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiTestUnitRdy ( SCSI_PHYS_DEV * pScsiPhysDev /* ptr to SCSI physical device */ ) { if (pScsiIfTbl->scsiTestUnitRdy != NULL) return ((STATUS) (pScsiIfTbl->scsiTestUnitRdy) (pScsiPhysDev)); else return (ERROR); }/********************************************************************************* scsiInquiry - issue an INQUIRY command to a SCSI device** This routine issues an INQUIRY command to a specified SCSI device.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiInquiry ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ char * buffer, /* ptr to input data buffer */ int bufLength /* length of buffer in bytes */ ) { if (pScsiIfTbl->scsiInquiry != NULL) return ((STATUS) (pScsiIfTbl->scsiInquiry) (pScsiPhysDev, buffer, bufLength)); else return (ERROR); }/********************************************************************************* scsiReqSense - issue a REQUEST_SENSE command to a SCSI device and read results** This routine issues a REQUEST_SENSE command to a specified SCSI device and* reads the results.** RETURNS: OK, or ERROR if the command fails.*/STATUS scsiReqSense ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ char * buffer, /* ptr to input data buffer */ int bufLength /* length of buffer in bytes */ ) { if (pScsiIfTbl->scsiReqSense != NULL) return ((STATUS) (pScsiIfTbl->scsiReqSense) (pScsiPhysDev, buffer, bufLength)); else return (ERROR); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -