SCSI Operation Codes
USB Mass Storage 是 USB host侧遇到最多的场景,基于 Bulk传输,使用 SCSI协议进行资源交互。当然 UFS也用到 SCSI协议,在使用 UFS的系统,我们插入 U盘经常生成的 dev节点是 /dev/sdb或者是 /dev/sde 。前面的如 /dev/sda、/dev/sdc这些节点可能就被 UFS占用了,识别 log可能就变成 “sd 1:0:0:0: [sde] …”。
在读写有坏块的 U盘时,不免会打印下面的 log。通过 opcode,就可以清楚是什么操作报的错。这里 opcode=0x28,即 READ(10)。
1 |
|
我们还可以阅读 SCSI的 manual,确定这次的 READ(10) 想从 LBA 0x2b0900 读多 0x1d * block size的数据回来。
USB Mass Storage 常用的 SCSI Operation Codes 包括下面这些:
指令代码 | 指令名称 | 指令说明 |
---|---|---|
0x00 | Test Unit Ready | 查询设备是否ready |
0x03 | Request Sense | 主机请求设备返回执行结果,及获取状态信息 |
0x12 | Inquiry | 获取设备信息 |
0x1A | Mode Sense(6) | 向host传输参数 |
0x5A | Mode Sense(10) | 向host传输参数 |
0x25 | Read Capacity(10) | 读取设备容量 |
0x28 | Read(10) | Host从设备读取数据 |
0x2A | Write(10) | Host写数据到存储设备 |
0x23 | Read Format Capacity | 查询当前容量及可用空间 |
0x15 | Mode Select(6) | 允许Host对外部设备设置参数 |
0x55 | Mode Select(10) | 允许Host对外部设备设置参数 |
0x1E | Prevent/Allow Medium Removal | 禁止/允许存储介质移动 |
0x1B | Start/Stop Uint | 启动/停止存储单元电源(写保护) |
0xA0 | Report LUNs | 索取设备的LUN数和LUN清单 |
0x2F | Verify | 在存储中验证数据 |
下面是全部的 SCSI Operation Codes:
Code | Command |
---|---|
00 | TEST UNIT READY (mandatory) |
01 | RECALIBRATE or REWIND |
03 | REQUEST SENSE (mandatory except RBC) |
04 | FORMAT UNIT |
05 | READ BLOCK LIMITS |
07 | REASSIGN BLOCKS |
07 | INITIALIZE ELEMENT STATUS |
08 | READ (6) |
0A | WRITE (6) |
0B | SEEK (6) |
0F | READ REVERSE (6) |
10 | WRITE FILEMARKS (6) |
11 | SPACE (6) |
12 | INQUIRY (mandatory) |
13 | VERIFY(6) |
14 | RECOVER BUFFERED DATA |
15 | MODE SELECT (6) |
16 | RESERVE (6) |
17 | RELEASE (6) |
18 | COPY |
19 | ERASE (6) |
1A | MODE SENSE (6) |
1B | START/STOP UNIT |
1B | LOAD UNLOAD |
1C | RECEIVE DIAGNOSTIC RESULTS |
1D | SEND DIAGNOSTIC |
1E | PREVENT/ALLOW MEDIUM REMOVAL |
23 | READ FORMAT CAPACITIES (MMC) |
24 | SET WINDOW |
25 | READ CAPACITY (10) |
28 | READ (10) |
29 | READ GENERATION |
2A | WRITE (10) |
2B | SEEK (10) |
2C | ERASE (10) |
2D | READ UPDATED BLOCK |
2E | WRITE AND VERIFY (10) |
2F | VERIFY (10) |
30 | SEARCH DATA HIGH (10) |
31 | SEARCH DATA EQUAL (10) |
32 | SEARCH DATA LOW (10) |
33 | SET LIMITS (10) |
34 | PRE-FETCH (10) |
35 | SYNCHRONIZE CACHE (10) |
36 | LOCK/UNLOCK CACHE (10) |
37 | READ DEFECT DATA (10) |
37 | INITIALIZE ELEMENT STATUS WITH RANGE |
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 DEFINITION |
41 | WRITE SAME (10) |
44 | REPORT DENSITY SUPPORT |
45 | PLAY AUDIO (10) |
46 | GET CONFIGURATION |
47 | PLAY AUDIO MSF |
48 | AUDIO TRACK INDEX (not mentioned in T10 overview) |
49 | AUDIO TRACK RELATIVE 10 (not mentioned in T10 overview) |
4A | GET EVENT STATUS NOTIFICATION |
4B | PAUSE / RESUME |
4C | LOG SELECT |
4D | LOG SENSE |
50 | XDWRITE (10) |
51 | XPWRITE (10) /READ DISC INFORMATION CDB (in mmc5r02c 6.22.2)/ |
52 | XDREAD (10) |
53 | XDWRITEREAD (10) |
54 | SEND OPC INFORMATION |
55 | MODE SELECT (10) |
56 | RESERVE (10) |
57 | RELEASE (10) |
58 | REPAIR TRACK |
5A | MODE SENSE (10) |
5B | CLOSE TRACK / SESSION |
5C | READ BUFFER CAPACITY |
5D | SEND CUE SHEET |
5E | PERSISTENT RESERVE IN |
5F | PERSISTENT RESERVE OUT |
7E | EXTENDED CDB |
7F | VARIABLE LENGTH CDB |
80 | XDWRITE EXTENDED (16) |
80 | WRITE FILEMARKS (16) |
81 | REBUILD (16) |
81 | READ REVERSE (16) |
82 | REGENERATE (16) |
83 | EXTENDED COPY |
84 | RECEIVE COPY RESULTS |
85 | ATA COMMAND PASS THROUGH (16) |
86 | ACCESS CONTROL IN |
87 | ACCESS CONTROL OUT |
88 | READ (16) |
89 | COMPARE AND WRITE |
8A | WRITE (16) |
8B | ORWRITE |
8C | READ ATTRIBUTE |
8D | WRITE ATTRIBUTE |
8E | WRITE AND VERIFY (16) |
8F | VERIFY (16) |
90 | PRE-FETCH (16) |
91 | SYNCHRONIZE CACHE (16) |
91 | SPACE (16) |
92 | LOCK UNLOCK CACHE (16) |
93 | WRITE SAME (16) |
9E | SERVICE ACTION IN (16) |
9F | SERVICE ACTION OUT (16) |
A0 | REPORT LUNS |
A1 | ATA COMMAND PASS THROUGH (12) |
A2 | SECURITY PROTOCOL IN |
A2 | SEND EVENT (not mentioned in T10 overview) |
A3 | MAINTENANCE IN |
A4 | MAINTENANCE OUT (REPORT_KEY) |
A5 | MOVE MEDIUM |
A5 | PLAY AUDIO 12 (not mentioned in T10 overview) |
A6 | EXCHANGE MEDIUM |
A7 | MOVE MEDIUM ATTACHED |
A8 | READ (12) |
A9 | SERVICE ACTION OUT (12) |
A9 | AUDIO TRACK RELATIVE 12 (not mentioned in T10 overview) |
AA | WRITE (12) |
AB | SERVICE ACTION IN (12) |
AC | ERASE (12) |
AD | READ DVD STRUCTURE |
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) |
B4 | READ ELEMENT STATUS ATTACHED |
B5 | SECURITY PROTOCOL OUT |
B6 | SEND VOLUME TAG |
B7 | READ DEFECT DATA (12) |
B8 | READ ELEMENT STATUS |
B9 | READ CD MSF |
BA | REDUNDANCY GROUP (IN) |
BB | REDUNDANCY GROUP (OUT) |
BC | SPARE (IN) |
BC | PLAY CD (not mentioned in T10 overview) |
BD | SPARE (OUT) |
BE | VOLUME SET (IN) |
BF | VOLUME SET (OUT) |
上述部分内容来自 wiki 、ymangu 和 SCSI Commands Reference Manual。更多SCSI 相关推荐查看 SCSI Commands Reference Manual、t10.org。
SCSI Operation Codes
http://xxxdk.xyz/xxx/2020/03/SCSI-Operation-Codes/