📄 scsi1lib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/scsi1Lib.html - generated by refgen from scsi1Lib.c --> <title> scsi1Lib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>scsi1Lib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>scsi1Lib</strong> - Small Computer System Interface (SCSI) library (SCSI-1) </p></blockquote><h4>ROUTINES</h4><blockquote><p><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library implements the Small Computer System Interface (SCSI)protocol in a controller-independent manner. It implements only the SCSIinitiator function; the library does not support a VxWorks targetacting as a SCSI target. Furthermore, in the current implementation, aVxWorks target is assumed to be the only initiator on the SCSI bus,although there may be multiple targets (SCSI peripherals) on the bus.<p>The implementation is transaction based. A transaction is defined as theselection of a SCSI device by the initiator, the issuance of a SCSI command,and the sequence of data, status, and message phases necessary to performthe command. A transaction normally completes with a "Command Complete" message fromthe target, followed by disconnection from the SCSI bus. Ifthe status from the target is "Check Condition," the transaction continues;the initiator issues a "Request Sense" command to gain more informationon the exception condition reported.<p>Many of the subroutines in <b><a href="./scsi1Lib.html#top">scsi1Lib</a></b> facilitate the transaction offrequently used SCSI commands. Individual command fields are passed asarguments from which SCSI Command Descriptor Blocks are constructed, andfields of a <b>SCSI_TRANSACTION</b> structure are filled in appropriately. Thisstructure, along with the <b>SCSI_PHYS_DEV</b> structure associated with thetarget SCSI device, is passed to the routine whose address is indicated bythe <b>scsiTransact</b> field of the <b>SCSI_CTRL</b> structure associated with therelevant SCSI controller.<p>The function variable <b>scsiTransact</b> is set by the individual SCSIcontroller driver. For off-board SCSI controllers, thisroutine rearranges the fields of the <b>SCSI_TRANSACTION</b> structure intothe appropriate structure for the specified hardware, which then carries outthe transaction through firmware control. Drivers for an on-boardSCSI-controller chip can use the <b>scsiTransact( )</b> routine in <b><a href="./scsiLib.html#top">scsiLib</a></b> (whichinvokes the <b>scsi1Transact( )</b> routine in <b><a href="./scsi1Lib.html#top">scsi1Lib</a></b>), as long as they provide the other functions specified in the <b>SCSI_CTRL</b> structure.<p>Note that no disconnect/reconnect capability is currently supported.<p></blockquote><h4>SUPPORTED SCSI DEVICES</h4><blockquote><p>The <b><a href="./scsi1Lib.html#top">scsi1Lib</a></b> library supports use of SCSI peripherals conforming to the standards specified in <i>Common Command Set (CCS) of the SCSI, Rev. 4.B. </i>Most SCSI peripherals currently offered support CCS. While an attempt has been madeto have <b><a href="./scsi1Lib.html#top">scsi1Lib</a></b> support non-CCS peripherals, not all commands or featuresof this library are guaranteed to work with them. For example,auto-configuration may be impossible with non-CCS devices, if they do notsupport the INQUIRY command.<p>Not all classes of SCSI devices are supported. However, the <b><a href="./scsiLib.html#top">scsiLib</a></b> libraryprovides the capability to transact any SCSI command on any SCSI devicethrough the FIOSCSICOMMAND function of the <b><a href="./scsiLib.html#scsiIoctl">scsiIoctl</a>( )</b> routine.<p>Only direct-access devices (disks) are supported by a file system. Forother types of devices, additional, higher-level software is necessary tomap user-level commands to SCSI transactions.<p></blockquote><h4>CONFIGURING SCSI CONTROLLERS</h4><blockquote><p>The routines to create and initialize a specific SCSI controller areparticular to the controller and normally are found in its librarymodule. The normal calling sequence is:<p><pre> xxCtrlCreate (...); /* parameters are controller specific */ xxCtrlInit (...); /* parameters are controller specific */</pre>The conceptual difference between the two routines is that <b>xxCtrlCreate( )</b>calloc's memory for the <b>xx_SCSI_CTRL</b> data structure and initializesinformation that is never expected to change (for example, clock rate). Theremaining fields in the <b>xx_SCSI_CTRL</b> structure are initialized by<b>xxCtrlInit( )</b> and any necessary registers are written on the SCSIcontroller to effect the desired initialization. Thisroutine can be called multiple times, although this is rarely required.For example, the bus ID of the SCSIcontroller can be changed without rebooting the VxWorks system.<p></blockquote><h4>CONFIGURING PHYSICAL SCSI DEVICES</h4><blockquote><p>Before a device can be used, it must be "created," that is, declared.This is done with <b><a href="./scsiLib.html#scsiPhysDevCreate">scsiPhysDevCreate</a>( )</b> and can only be done after a<b>SCSI_CTRL</b> structure exists and has been properly initialized.<p><pre>SCSI_PHYS_DEV *scsiPhysDevCreate ( SCSI_CTRL * pScsiCtrl,/* ptr to SCSI controller info */ int devBusId, /* device's SCSI bus ID */ int devLUN, /* device's logical unit number */ int reqSenseLength, /* length of REQUEST SENSE data dev returns */ int devType, /* type of SCSI device */ BOOL removable, /* whether medium is removable */ int numBlocks, /* number of blocks on device */ int blockSize /* size of a block in bytes */ )</pre>Several of these parameters can be left unspecified, as follows:<dl><dt><i>reqSenseLength</i><dd>If 0, issue a <b>REQUEST_SENSE</b> to determine a request sense length.<dt><i>devType</i><dd>If -1, issue an INQUIRY to determine the device type.<dt><i>numBlocks</i>, <i>blockSize</i><dd>If 0, issue a <b>READ_CAPACITY</b> to determine the number of blocks.</dl>The above values are recommended, unless the device does not support therequired commands, or other non-standard conditions prevail.<p></blockquote><h4>LOGICAL PARTITIONS ON BLOCK DEVICES</h4><blockquote><p>It is possible to have more than one logical partition on a SCSI blockdevice. This capability is currently not supported for removable mediadevices. A partition is an array of contiguously addressed blockswith a specified starting block address and a specified number of blocks.The <b><a href="./scsiLib.html#scsiBlkDevCreate">scsiBlkDevCreate</a>( )</b> routine is called once for each block devicepartition. Under normal usage, logical partitions should not overlap.<p><pre>SCSI_BLK_DEV *scsiBlkDevCreate ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device info */ int numBlocks, /* number of blocks in block device */ int blockOffset /* address of first block in volume */ )</pre>Note that if <i>numBlocks</i> is 0, the rest of the device is used.<p></blockquote><h4>ATTACHING FILE SYSTEMS TO LOGICAL PARTITIONS</h4><blockquote><p>Files cannot be read or written to a disk partition until a file system(such as dosFs or rt11Fs) has been initialized on the partition. For moreinformation, see the documentation in <b><a href="./dosFsLib.html#top">dosFsLib</a></b> or <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b>.<p></blockquote><h4>TRANSMITTING ARBITRARY COMMANDS TO SCSI DEVICES</h4><blockquote><p>The <b><a href="./scsi1Lib.html#top">scsi1Lib</a></b> library provides routines that implement many common SCSIcommands. Still, there are situations that require commands that are notsupported by <b><a href="./scsi1Lib.html#top">scsi1Lib</a></b> (for example, writing software to control non-direct access devices). Arbitrary commands are handled with the FIOSCSICOMMAND option to <b><a href="./scsiLib.html#scsiIoctl">scsiIoctl</a>( )</b>. The <i>arg</i> parameter for FIOSCSICOMMAND is a pointer to a valid <b>SCSI_TRANSACTION</b> structure. Typically, a call to <b><a href="./scsiLib.html#scsiIoctl">scsiIoctl</a>( )</b> is written as a subroutine of the form:<pre>STATUS myScsiCommand ( SCSI_PHYS_DEV * pScsiPhysDev, /* ptr to SCSI physical device */ char * buffer, /* ptr to data buffer */ int bufLength, /* length of buffer in bytes */ int someParam /* param. specifiable in cmd block */ ) { SCSI_COMMAND myScsiCmdBlock; /* SCSI command byte array */ SCSI_TRANSACTION myScsiXaction; /* info on a SCSI transaction */ /* fill in fields of SCSI_COMMAND structure */ myScsiCmdBlock [0] = MY_COMMAND_OPCODE; /* the required opcode */ . myScsiCmdBlock [X] = (UINT8) someParam; /* for example */ . myScsiCmdBlock [N-1] = MY_CONTROL_BYTE; /* typically == 0 */ /* fill in fields of SCSI_TRANSACTION structure */ myScsiXaction.cmdAddress = myScsiCmdBlock; myScsiXaction.cmdLength = <# of valid bytes in myScsiCmdBlock>; myScsiXaction.dataAddress = (UINT8 *) buffer; myScsiXaction.dataDirection = <O_RDONLY (0) or O_WRONLY (1)>; myScsiXaction.dataLength = bufLength; myScsiXaction.cmdTimeout = timeout in usec; /* if dataDirection is O_RDONLY, and the length of the input data is * variable, the following parameter specifies the byte # (min == 0) * of the input data which will specify the additional number of * bytes available */ myScsiXaction.addLengthByte = X; if (scsiIoctl (pScsiPhysDev, FIOSCSICOMMAND, &myScsiXaction) == OK) return (OK); else /* optionally perform retry or other action based on value of * myScsiXaction.statusByte */ return (ERROR); }</pre></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>scsiLib.h</b>, <b>scsi1Lib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./dosFsLib.html#top">dosFsLib</a></b>, <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b>,<i> American National Standards for Information Systems - Small Computer" </i><i> System Interface (SCSI), ANSI X3.131-1986,"</i><i>VxWorks Programmer's Guide: I/O System, Local File Systems </i><p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -