Annotation of nono/vm/scsi.cpp, revision 1.1.1.4

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.