ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:26.30KB ,
资源ID:5233138      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5233138.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(SCSI命令.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

SCSI命令.docx

1、SCSI命令SCSI命令的发行1. uscsi接口Solaris通过uscsi(user SCSI command interface)接口来发行SCSI命令. 接口函数是ioctl:#include ioctl(int fildes, int request, struct uscsi_cmd *cmd); 设备描述符 USCSICMD uscsi_cmd结构体包含以下的成员: int uscsi_flags; /* read, write, etc. see below */ short uscsi_status; /* resulting status */ short uscsi_ti

2、meout; /* Command Timeout */ caddr_t uscsi_cdb; /* CDB to send to target */ caddr_t uscsi_bufaddr; /* i/o source/destination */ u_int uscsi_buflen; /* size of i/o to take place */ u_int uscsi_resid; /* resid from i/o operation */ u_char uscsi_cdblen; /* # of valid CDB bytes */ u_char uscsi_rqlen; /*

3、 size of uscsi_rqbuf */ u_char uscsi_rqstatus; /* status of request sense cmd */ u_char uscsi_rqresid; /* resid of request sense cmd */ caddr_t uscsi_rqbuf; /* request sense buffer */ void *uscsi_reserved_5; /* Reserved for future use */ 1.1. uscsi_cmd : uscsi_flagsuscsi_flags设置I/O的方向以及其他一些细节:名称可选值描

4、述uscsi_flagsUSCSI_READ从设备中读取数据USCSI_WRITE 向设备发行数据USCSI_RQENABLE 获取sense信息有效USCSI_SILENT 禁止向console打印出错或警告信息USCSI_DIAGNOSE SCSI命令异常终止后, 禁止retry或recovery机制USCSI_ISOLATE 禁止此SCSI命令与其他命令同时发行USCSI_ASYNC 设置SCSI bus为异步模式USCSI_SYNC 设置SCSI bus为同步模式USCSI_RESET向设备发送reset消息USCSI_RESET_ALL Reset SCSI bus我们常用的是USC

5、SI_READ, USCSI_WRITE; 而USCSI_RQENABLE做为获取sense信息的必要条件, 常常被做为复选值设置. 比如:ucmd.uscsi_flags = USCSI_READ | USCSI_RQENABLE | ; 或ucmd.uscsi_flags |= USCSI_RQENABLE;1.2. uscsi_cmd : uscsi_cdbuscsi_cdb是指向设置的CDB指针, 其中存储了向设备发行哪种SCSI命令的具体信息.SCSI命令格式CDBCDB (Command / Descriptor / Block)存储了准备向设备发行的命令信息.CDB format

6、BitByte765432100Operation Code1(N-1)Command Spec. ParameterNControllerOperation Code FormatBitByte76543210Group CodeCommand Code Group Code 0000b : 6 Byte Command1001b : 10 Byte Command2010b : 10 Byte Command3011b : Reserve4100b : 16 Byte Command5101b : 12 Byte Command6110b : Vendor Specification711

7、1b : Vendor Specification 有关各SCSI命令的Operation Code, 请参考Appendix 1: SCSI Command List 关于各SCSI命令的CDB具体信息, 请参考富士通SCSI相关资料编程中的实例如下, 发行Read(10), 此命令的CDB格式如下表所示:Read (10)BitByteOperation Code (28h)1Reserved( 0 0 0 )bDPOFUA( 0 )bReserved( 0 0 0 )bRelAdr ( 0 )b(MSB)LBA(LSB)Reserved ( 00 h)(MSB) Transfer Len

8、gth (LSB)Controllerstruct uscsi_cmd my_cmd; unsigned char my_scsi_cdb10; /* Initialize my_scsi_cdb as a Read(10) */ my_scsi_cdb0 = 0x28; /* Operation Code 28h */ my_scsi_cdb1 = 0x00; /* Flag */ my_scsi_cdb2 = 0x01; /* LBA: 0x01020304 */ my_scsi_cdb3 = 0x02; my_scsi_cdb4 = 0x03; my_scsi_cdb5 = 0x04;

9、my_scsi_cdb6 = 0x00; /* Reserved */ my_scsi_cdb7 = 0x00; /* Length: 0x00ff */ my_scsi_cdb8 = 0xff; my_scsi_cdb9 = 0x00; /* Controller */ my_cmd.uscsi_cdb = my_scsi_cdb; /* Well be using the array above for the CDB */my_cmd.uscsi_cdblen = 10; /* The CDB is 6 bytes long */1.3. uscsi_cmd : uscsi_cdblen

10、定义了uscsi_cdb的长度.1.4. uscsi_cmd : uscsi_status当ioctl发行后, uscsi_status用来返回SCSI status byte, 指示命令返回的状态. SCSI status byte只有bit 15有效, 表示状态值, 而bit 0, 6, 7保留, 如下所示:76543210RRR返回的状态值有以下几种:Bit of status byte7 6 5 4 3 2 1 0Value in HexMeaningR R 0 0 0 0 0 R00Good StatusR R 0 0 0 0 1 R02Check ConditionR R 0 0

11、0 1 0 R04Condition Met/GoodR R 0 0 1 0 0 R08BusyR R 0 1 0 0 0 R10Intermediate/GoodR R 0 1 0 1 0 R14Intermediate/Condition Met/GoodR R 0 1 1 0 0 R18Reservation ConflictR R 1 0 0 0 1 R22Command TerminatedR R 1 0 1 0 0 R28Queue FullxxOther Codes Are Reserved当返回值为02(Check Condition)时, 在USCSI_RQENABLE设置的

12、情况下, 设备驱动会自动发行Request Sense Command, 从而可以进一步对sense data进行分析. 根据以上的特性, 在编程过程中可以选择如下的方法:#define STATUS_MASK 0x3E#define STATUS_GOOD 0x00#define STATUS_CHECK 0x02ret = ioctl(fd, USCSICMD, &req);if (ret 0) /* API error handle */else /* Device driver execute result */if (req.uscsi_status & STATUS_MASK) =

13、 STATUS_GOOD) /* Good */ else if (req.uscsi_status & STATUS_MASK) = STATUS_CHECK) /* Check Condition */ /* Check Sense key, Additional Sense Codes / Qualifiers (ASC/ASCQ) */ else /* other */1.5. uscsi_cmd : uscsi_bufaddr用户定义的buffer, SCSI命令从设备读取/写入的信息, 都存储在此buffer中. 1.6. uscsi_cmd : uscsi_buflen定义了us

14、csi_bufaddr的长度, 以byte计数. 1.7. uscsi_cmd : uscsi_resid如果数据传输在完成所有被要求的数据传送之前终止, 则剩余部分(remainder/ residue)的数据个数被存储在uscsi_resid中. 当然, uscsi_resid的期待值应该是0.1.8. uscsi_cmd : uscsi_rqlen如果设置了USCSI_RQENABL位, caddr_t uscsi_rqlen规定了要得到的Sense buffer的长度, 以byte计数.1.9. uscsi_cmd : uscsi_rqstatus如果设置了USCSI_RQENABL位

15、, 并且uscsi_status返回位02(Check Condition), 系统将自动发行Request Sense command来获取Sense信息, uscsi_rqstatus用来接受Request Sense command的返回值. 性质和uscsi_status相同.1.10. uscsi_cmd : uscsi_rqresid如果为Request Sense信息定义的buffer过小, uscsi_rqresid表示了没有被存储进来的数目. 性质和uscsi_resid相同.1.11. uscsi_cmd : uscsi_rqbufuscsi_rqbuf指针指向了存储Req

16、uest Sense信息的buffer.1.12. uscsi_cmd : uscsi_timeout允许命令运行的时间, 以秒为单位, 一般设置几秒到几分钟不等. 如果系统在规定时间内没有完成, 则认为失败.my_cmd.uscsi_timeout = 15; /* Allow 15 seconds for completion */1.13. uscsi_cmd : uscsi_reserved_5这5个字节, 他(她)们还没有被用到.2. Sense Data当设备返回02(Check condition)状态, 且设置了USCSI_RQENABL标志位, 系统执行Reqeuest Se

17、nse Command生成sense data, sense信息可以帮助我们找出错误的原因.格式如下:Bit76543210Byte 0ValidError Code (70h)1Segment number (00h)20000Sense Key3MSBLSB4567Additional Sense Data Length8Command Specific Information9101112Sense Code (ASC)13Sub Sense Code (ASCQ)14FRU code15SKSV(00h)16Sense Key Specific Information1718Desti

18、nation ID (LOOP ID)19HOST operation Command20Fault Factor Code21Reserved2223LUN2455Detail Information15671Detail Information1Sense Key表示了什么错误原因导致了sense data. 下表列出了Sense Key各值的意义:Sense KeyNameDescription0NO SENSENo specific Sense Key exists1RECOVERED ERRORa) The last command executed successfully ter

19、minated along with the recover operation. If a multiple number of errors that were successfully correction occurred during the process of a command, the last one isreported.b) The Rounding Process of the MODE SELECT Parameter was executed.2NOT READYThe Logical Device cannot be accessed.3MEDIUM ERROR

20、Due to defective media or errors in recorded data, unrecoverable errors have been detected.4HARDWARE ERRORUnrecoverable Errors detected in hardware while executing a command or the self-diag. Process.5ILLEGAL REQUESTIllegal value detected in CDB or transferred parameter. Or the LUN specification is

21、wrong.6UNIT ATTENTIONUnit Attention Condition occurred.7DATA PROTECTIllegal execution of operation in the Read/Write Inhibited Area. (command not executed) The SET LIMITS command occurred twice in a link command group.8BLANK CHECKNot used9VENDER SPECIFICNot usedACOPY ABORTEDNot usedBABORTED COMMANDE

22、xecuted command abnormally terminated. INIT normally reissues the command in an attempt to successfully complete the command.CEQUALNot usedDVOLUME OVERFLOWNot usedEMISCOMPARENo match when data comparison was made during the Verify Command Byte Check process.F(Reserved)Not usedSense Code(BYTE 12) 和Su

23、b sense Code(BYTE 13) 提供了更具体的信息, 有关具体意义请参考Appendix 2: Additional Sense Codes / Qualifiers (ASC/ASCQ).3. 实现时的注意点3.1. 设备打开方式如果是Direct Access, 打开设备时应使用O_NDELAY 方式, 如:fd=open(“/dev/rdsk/c3t0d0s2”, O_RDWR|O_NDELAY);3.2. Endian差异具体请参考上次介绍Endian的文档. Appendix 1: SCSI Command List Operatoin Code - Command Na

24、me 00 - Test Unit Ready 01 - Rewind (Sequential Devices) 01 - Rezero Unit (other Devices) 03 - Request Sense 04 - Format Unit 05 - Read Block Limits (Sequential) 07 - Reassign Blocks 08 - Read(6) (Sequential Devices) 0A - Write(6) (Sequential Devices) 0B - Seek 0F - Read Reverse (Sequential) 10 - Wr

25、ite Filemarks (Seq. Devices) 11 - Space (Sequential) 12 - Inquiry 13 - Verify (Sequential) 14 - Recover Buffered Data (Seqntl) 15 - Mode Select(6) 16 - Reserve Unit(6) 17 - Release Unit(6) 18 - Copy 19 - Erase (Sequential Devices) 1A - Mode Sense(6) 1B - Load/Unload (Sequential) 1C - Stop/Start Unit

26、 1D - Send Diagnostics 1E - Prevent/Allow Media Removal 24 - Set Window 25 - Read Capacity 28 - Read(10) (Direct Access Devices) 29 - Read(10) Generation 2A - Write(10) (Direct Access Devices) 2B - Seek (10) 2C - Erase (10) 2D - Read Updated Block 2E - Write and Verify 2F - Verify 30 - Search Data H

27、igh 31 - Search Data Equal 32 - Search Data Low 33 - Set Limits 34 - Pre-Fetch 35 - Synchronize Cache 36 - Lock/Unlock Cache 37 - Read Defect Data 38 - Medium Scan 39 - Compare 3A - Copy and Verify 3B - Write Buffer 3C - Read Buffer 3D - Update Block 3E - Read Long 3F - Write Long 40 - Change Defini

28、tion 41 - Write Same 42 - Read Sub-Channel 43 - Read TOC 44 - Read Header 45 - Play Audio (10) 47 - Play Audio MSF 48 - Play Audio Track Index 49 - Play Track Relative (10) 4B - Pause/Resume 4C - Log Select 4D - Log Sense 55 - Mode Select (10) 5A - Mode Sense (10) A5 - Move Medium A6 - Exchange Medium A8 - Read (12) A9 - Play Track Relative (12) AA - Write (12) AC - Erase (12) AE - Write and Verify (12) AF - Verify (12) B0 - Search Data High (12) B1 - Search Data Equal (12) B2 - Search Data Low (12) B3 - Set Limits (12) B5 - Request Volume Element Address

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1