|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
1.1.1.5 root 6:
7: //
8: // SCSI (定数等)
1.1 root 9: //
10:
1.1.1.6 ! root 11: #include "scsi.h"
1.1 root 12:
1.1.1.4 root 13: // フェーズ文字列を返す
14: /*static*/ const char *
15: SCSI::GetPhaseName(Phase phase)
16: {
17: switch (phase) {
18: case BusFree: return "BusFree";
19: case Arbitration: return "Arbitration";
20: case Selection: return "Selection";
21: case Reselection: return "Reselection";
22: case Transfer: return "Transfer";
23: default: return "Phase?";
24: }
25: }
26:
27: // 情報転送フェーズ文字列を返す
28: /*static*/ const char *
29: SCSI::GetXferPhaseName(XferPhase xfer)
30: {
31: switch (xfer) {
32: case DataOut: return "DataOut";
33: case DataIn: return "DataIn";
34: case Command: return "Command";
35: case Status: return "Status";
36: case MsgOut: return "MsgOut";
37: case MsgIn: return "MsgIn";
38: case End: return "End";
39: default: return "XferPhase?";
40: }
41: }
42:
43: // デバイス種別文字列を返す
44: /*static*/ const char *
45: SCSI::GetDevTypeName(DevType type)
46: {
47: switch (type) {
48: case DevType::None: return "None";
49: case DevType::Initiator: return "Initiator";
50: case DevType::HD: return "HD";
51: case DevType::CD: return "CD";
52: case DevType::MO: return "MO";
53: default: return "DevType?";
54: }
55: }
56:
1.1 root 57: // cmd に対応するコマンド名を返す。
1.1.1.4 root 58: /*static*/ const char *
1.1 root 59: SCSI::GetCommandName(uint8 cmd)
60: {
1.1.1.4 root 61: if (cmd < commandname.size()) {
1.1 root 62: return commandname[cmd];
63: } else {
64: return NULL;
65: }
66: }
67:
68: // コマンド名
1.1.1.4 root 69: /*static*/ const std::vector<const char *>
70: SCSI::commandname =
1.1 root 71: {
72: "TestUnitReady", // 00
73: "RezeroUnit", // 01
74: NULL, // 02
75: "RequestSense", // 03
76: "FormatUnit", // 04
77: NULL, // 05
78: NULL, // 06
79: "ReassignBlocks", // 07
80: "Read(6)", // 08
81: NULL, // 09
82: "Write(6)", // 0a
83: "Seek(6)", // 0b
84: NULL, // 0c
85: NULL, // 0d
86: NULL, // 0e
87: NULL, // 0f
88:
89: NULL, // 10
90: NULL, // 11
91: "Inquiry", // 12
92: NULL, // 13
93: NULL, // 14
94: "ModeSelect(6)", // 15
95: "Reserve", // 16
96: "Release", // 17
97: "Copy", // 18
98: NULL, // 19
99: "ModeSense(6)", // 1a
100: "StartStopUnit", // 1b
101: "ReceiveDiagnosticResults", // 1c
102: "SendDiagnostic", // 1d
103: "PreventAllowMediumRemoval", // 1e
104: NULL, // 1f
105:
106: NULL, // 20
107: NULL, // 21
108: NULL, // 22
1.1.1.4 root 109: "ReadFormatCapacities", // 23
1.1 root 110: NULL, // 24
111: "ReadCapacity", // 25
112: NULL, // 26
113: NULL, // 27
114: "Read(10)", // 28
115: NULL, // 29
116: "Write(10)", // 2a
117: "Seek(10)", // 2b
118: NULL, // 2c
119: NULL, // 2d
120: "WriteAndVerify(10)", // 2e
121: "Verify(10)", // 2f
122:
123: "SearchDataHigh(10)", // 30
124: "SearchDataEqual(10)", // 31
125: "SearchDataLow(10)", // 32
126: "SetLimits", // 33
127: "PreFetch", // 34
128: "SynchronizeCache", // 35
129: "LockUnlockCache", // 36
130: "ReadDefectData(10)", // 37
131: NULL, // 38
132: "Compare", // 39
133: "CopyAndVerify", // 3a
134: "WriteBuffer", // 3b
135: "ReadBuffer", // 3c
136: NULL, // 3d
137: "ReadLong", // 3e
138: "WriteLong", // 3f
139:
140: "ChangeDefinition", // 40
141: "WriteSame", // 41
142: NULL, // 42
1.1.1.4 root 143: "ReadTOC", // 43
144: "ReadHeader", // 44
1.1 root 145: NULL, // 45
146: NULL, // 46
147: NULL, // 47
148: NULL, // 48
149: NULL, // 49
150: NULL, // 4a
151: NULL, // 4b
152: "LogSelect", // 4c
153: "LogSense", // 4d
154: NULL, // 4e
155: NULL, // 4f
156: NULL, // 50
1.1.1.4 root 157: "ReadDiscInformation", // 51
1.1 root 158: NULL, // 52
159: NULL, // 53
160: NULL, // 54
161: "ModeSelect(10)", // 55
162: NULL, // 56
163: NULL, // 57
164: NULL, // 58
165: NULL, // 59
166: "ModeSense(10)", // 5a
167: };
1.1.1.4 root 168:
169: // センスキーとその名前を表示用に整形したものを返す
170: /*static*/ std::string
171: SCSI::GetSenseKeyDisp(uint8 key)
172: {
173: if (__predict_true(key < sensekeyname.size())) {
174: return string_format("%s($%x)",sensekeyname[key], key);
175: } else {
176: return string_format("$%x", key);
177: }
178: }
179:
180: /*static*/ const std::vector<const char *>
181: SCSI::sensekeyname =
182: {
183: "NoSense", // 0x0
184: "RecoveredError", // 0x1
185: "NotReady", // 0x2
186: "MediumError", // 0x3
187: "HardwareError", // 0x4
188: "IllegalRequest", // 0x5
189: "UnitAttention", // 0x6
190: "DataProtect", // 0x7
191: "BlankCheck", // 0x8
192: "VendorSpecific", // 0x9
193: "CopyAborted", // 0xa
194: "AbortedCommand", // 0xb
195: "Equal", // 0xc
196: "VolumeOverflow", // 0xd
197: "Miscompare", // 0xe
198: "Reserved", // 0xf
199: };
200:
201: // Mode Select/Sense のページ番号とページ名を表示用に整形したものを返す
202: /*static*/ std::string
203: SCSI::GetModePageDisp(uint8 page)
204: {
205: const char *name;
206:
207: if (__predict_true(page < modepagename.size())) {
208: name = modepagename[page];
209: } else if (page == 0x3f) {
210: name = "AllPages";
211: } else {
212: return string_format("$%02x", page);
213: }
214:
215: return string_format("$%02x(%s)", page, name);
216: }
217:
218: /*static*/ const std::vector<const char *>
219: SCSI::modepagename =
220: {
221: "VendorSpecific", // 00
222: "ReadWriteErrorRecovery", // 01
223: "DisconnectReconnect", // 02
224: "FormatDevice", // 03
225: "RigidDiskGeometry", // 04
226: "FlexibleDisk", // 05
227: "OpticalMemory", // 06
228: "VerifyErrorRecovery", // 07
229: "CachingPage", // 08
230: "PeripheralDevice", // 09
231: "ControlMode", // 0a
232: "MediumTypeSupported", // 0b
233: "NotchAndPartition", // 0c
234: "CDROM", // 0d
235: "CDROMAudioControl", // 0e
236: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.