Add new "blind write" option to increase write command performance. This causes issue...
[SCSI2SD-V6.git] / src / scsi2sd-util6 / ConfigUtil.cc
index 9db2ded62cdd97b279096d3974fbebb41d8ca5fe..26acaa79a8770c7f81143043e12e1b80fadcc540 100755 (executable)
@@ -168,6 +168,7 @@ ConfigUtil::toBytes(const S2S_TargetCfg& _config)
        config.headsPerCylinder = fromLE16(config.headsPerCylinder);
 
        const uint8_t* begin = reinterpret_cast<const uint8_t*>(&config);
+
        return std::vector<uint8_t>(begin, begin + sizeof(config));
 }
 
@@ -213,9 +214,28 @@ ConfigUtil::toXML(const S2S_TargetCfg& config)
                "       <!-- ********************************************************\n" <<
                "       Space separated list. Available options:\n" <<
                "       apple\t\tReturns Apple-specific mode pages\n" <<
+               "       omti\t\tOMTI host non-standard link control\n" <<
+               "       xebec\t\tXEBEC ignore step options in control byte\n" <<
                "       ********************************************************* -->\n" <<
-               "       <quirks>" <<
-                       (config.quirks & S2S_CFG_QUIRKS_APPLE ? "apple" : "") <<
+               "       <quirks>";
+       if (config.quirks == S2S_CFG_QUIRKS_APPLE)
+       {
+               s << "apple";
+       }
+       else if (config.quirks == S2S_CFG_QUIRKS_OMTI)
+       {
+               s << "omti";
+       }
+       else if (config.quirks == S2S_CFG_QUIRKS_XEBEC)
+       {
+               s << "xebec";
+       }
+       else if (config.quirks == S2S_CFG_QUIRKS_VMS)
+       {
+               s << "vms";
+       }
+
+       s <<
                        "</quirks>\n" <<
 
                "\n\n" <<
@@ -315,26 +335,6 @@ ConfigUtil::toXML(const S2S_BoardCfg& config)
                        (config.flags & S2S_CFG_ENABLE_SCSI2 ? "true" : "false") <<
                        "</enableScsi2>\n" <<
 
-               "       <enableCache>" <<
-                       (config.flags & S2S_CFG_ENABLE_CACHE ? "true" : "false") <<
-                       "</enableCache>\n" <<
-
-               "       <!-- ********************************************************\n" <<
-               "       Setting to 'true' will result in increased performance at the\n" <<
-               "       cost of lower noise immunity.\n" <<
-               "       Only set to true when using short cables with only 1 or two\n" <<
-               "       devices. This should remain off when using external SCSI1 DB25\n" <<
-               "       cables.\n" <<
-               "       ********************************************************* -->\n" <<
-               "       <disableGlitchFilter>" <<
-                       (config.flags & S2S_CFG_DISABLE_GLITCH ? "true" : "false") <<
-                       "</disableGlitchFilter>\n" <<
-
-
-               "       <enableDisconnect>" <<
-                       (config.flags & S2S_CFG_ENABLE_DISCONNECT ? "true" : "false") <<
-                       "</enableDisconnect>\n" <<
-
                "       <!-- ********************************************************\n" <<
                "       Respond to very short duration selection attempts. This supports\n" <<
                "       non-standard hardware, but is generally safe to enable.\n" <<
@@ -356,6 +356,43 @@ ConfigUtil::toXML(const S2S_BoardCfg& config)
                "       <mapLunsToIds>" <<
                        (config.flags & S2S_CFG_MAP_LUNS_TO_IDS ? "true" : "false") <<
                        "</mapLunsToIds>\n" <<
+
+
+               "       <!-- ********************************************************\n" <<
+               "       Delay (in milliseconds) before responding to a SCSI selection.\n" <<
+               "       255 (auto) sets it to 0 for SCSI2 hosts and 1ms otherwise.\n" <<
+               "       Some samplers need this set to 1 manually.\n" <<
+               "       ********************************************************* -->\n" <<
+               "       <selectionDelay>" << static_cast<int>(config.selectionDelay) << "</selectionDelay>\n" <<
+
+               "       <!-- ********************************************************\n" <<
+               "       Startup delay (in seconds) before responding to the SCSI bus \n" <<
+               "       after power on. Default = 0.\n" <<
+               "       ********************************************************* -->\n" <<
+               "       <startupDelay>" << static_cast<int>(config.startupDelay) << "</startupDelay>\n" <<
+
+               "       <!-- ********************************************************\n" <<
+               "       Speed limit the SCSI interface. This is the -max- speed the \n" <<
+               "       device will run at. The actual spee depends on the capability\n" <<
+               "       of the host controller.\n" <<
+               "       0       No limit\n" <<
+               "       1       Async 1.5MB/s\n" <<
+               "       2       Async 3.3MB/s\n" <<
+               "       3       Async 5MB/s\n" <<
+               "       4       Sync 5MB/s\n" <<
+               "       5       Sync 10MB/s\n" <<
+               "       ********************************************************* -->\n" <<
+               "       <scsiSpeed>" << static_cast<int>(config.scsiSpeed) << "</scsiSpeed>\n" <<
+
+               "       <!-- ********************************************************\n" <<
+               "       Enable SD card blind writes, which starts writing to the SD\n"
+               "       card before all the SCSI data has been received. Can cause problems\n" <<
+               "       with some SCSI hosts\n" <<
+               "       ********************************************************* -->\n" <<
+               "       <blindWrites>" <<
+                       (config.flags6 & S2S_CFG_ENABLE_BLIND_WRITES ? "true" : "false") <<
+                       "</blindWrites>\n" <<
+
                "</S2S_BoardCfg>\n";
 
        return s.str();
@@ -434,6 +471,18 @@ parseTarget(wxXmlNode* node)
                                {
                                        result.quirks |= S2S_CFG_QUIRKS_APPLE;
                                }
+                               else if (quirk == "omti")
+                               {
+                                       result.quirks |= S2S_CFG_QUIRKS_OMTI;
+                               }
+                               else if (quirk == "xebec")
+                               {
+                                       result.quirks |= S2S_CFG_QUIRKS_XEBEC;
+                               }
+                               else if (quirk == "vms")
+                               {
+                                       result.quirks |= S2S_CFG_QUIRKS_VMS;
+                               }
                        }
                }
                else if (child->GetName() == "deviceType")
@@ -507,8 +556,15 @@ parseBoardConfig(wxXmlNode* node)
        wxXmlNode *child = node->GetChildren();
        while (child)
        {
-// FIXME WHERE IS SELECTION DELAY ? STARTUP DELAY ? FFS.
-               if (child->GetName() == "unitAttention")
+               if (child->GetName() == "selectionDelay")
+               {
+                       result.selectionDelay = parseInt(child, 255);
+               }
+               else if (child->GetName() == "startupDelay")
+               {
+                       result.startupDelay = parseInt(child, 255);
+               }
+               else if (child->GetName() == "unitAttention")
                {
                        std::string s(child->GetNodeContent().mb_str());
                        if (s == "true")
@@ -544,18 +600,6 @@ parseBoardConfig(wxXmlNode* node)
                                result.flags = result.flags & ~S2S_CFG_ENABLE_SCSI2;
                        }
                }
-               else if (child->GetName() == "disableGlitchFilter")
-               {
-                       std::string s(child->GetNodeContent().mb_str());
-                       if (s == "true")
-                       {
-                               result.flags |= S2S_CFG_DISABLE_GLITCH;
-                       }
-                       else
-                       {
-                               result.flags = result.flags & ~S2S_CFG_DISABLE_GLITCH;
-                       }
-               }
                else if (child->GetName() == "enableTerminator")
                {
                        std::string s(child->GetNodeContent().mb_str());
@@ -568,28 +612,16 @@ parseBoardConfig(wxXmlNode* node)
                                result.flags6 = result.flags & ~S2S_CFG_ENABLE_TERMINATOR;
                        }
                }
-               else if (child->GetName() == "enableCache")
+               else if (child->GetName() == "blindWrites")
                {
                        std::string s(child->GetNodeContent().mb_str());
                        if (s == "true")
                        {
-                               result.flags |= S2S_CFG_ENABLE_CACHE;
+                               result.flags6 |= S2S_CFG_ENABLE_BLIND_WRITES;
                        }
                        else
                        {
-                               result.flags = result.flags & ~S2S_CFG_ENABLE_CACHE;
-                       }
-               }
-               else if (child->GetName() == "enableDisconnect")
-               {
-                       std::string s(child->GetNodeContent().mb_str());
-                       if (s == "true")
-                       {
-                               result.flags |= S2S_CFG_ENABLE_DISCONNECT;
-                       }
-                       else
-                       {
-                               result.flags = result.flags & ~S2S_CFG_ENABLE_DISCONNECT;
+                               result.flags6 = result.flags & ~S2S_CFG_ENABLE_BLIND_WRITES;
                        }
                }
                else if (child->GetName() == "selLatch")
@@ -616,6 +648,10 @@ parseBoardConfig(wxXmlNode* node)
                                result.flags = result.flags & ~S2S_CFG_MAP_LUNS_TO_IDS;
                        }
                }
+               else if (child->GetName() == "scsiSpeed")
+               {
+                       result.scsiSpeed = parseInt(child, S2S_CFG_SPEED_SYNC_10);
+               }
                child = child->GetNext();
        }
        return result;