]> localhost Git - SCSI2SD.git/commitdiff
Minor config fixes for 5.1 support. v4.8
authorMichael McMaster <michael@codesrc.com>
Mon, 16 Apr 2018 10:35:36 +0000 (20:35 +1000)
committerMichael McMaster <michael@codesrc.com>
Mon, 16 Apr 2018 10:35:36 +0000 (20:35 +1000)
CHANGELOG
software/SCSI2SD/src/config.c
software/SCSI2SD/src/main.c
software/SCSI2SD/src/scsiPhy.c
software/SCSI2SD/src/scsiPhy.h
software/scsi2sd-util/Makefile
software/scsi2sd-util/TargetPanel.cc
software/scsi2sd-util/gnulib_ffs.c [new file with mode: 0644]
software/scsi2sd-util/scsi2sd-util.cc

index c9df6b2fd46d2fe688f521025279a1fd2dc1d461..02c01c5800b5d25afb43147258f84befca0f56d1 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,4 @@
-2018XXXX               4.8
+20180416               4.8
        - Fix Unit Serial Number inquiry page to use return configured serial number
        - Apple mode pages now only sent when in Apple mode.
        - Added quirks selection to scsi2sd-util. Apple users should manually fix
index c672c3154182b059b0abd2014ccf5fec88f61443..70948f7afec817dd61ed8ebef730afa95e88c71b 100755 (executable)
@@ -79,6 +79,7 @@ static void initBoardConfig(BoardConfig* config) {
                config->flags = getConfigByIndex(0)->flagsDEPRECATED;\r
 \r
                config->selectionDelay = 255; // auto\r
+               config->flags6 = S2S_CFG_ENABLE_TERMINATOR;\r
        }\r
 }\r
 \r
@@ -146,7 +147,7 @@ writeFlashCommand(const uint8_t* cmd, size_t cmdSize)
        if ((flashArray != SCSI_CONFIG_ARRAY) ||\r
                (flashRow < SCSI_CONFIG_4_ROW) ||\r
                (flashRow >= SCSI_CONFIG_3_ROW + SCSI_CONFIG_ROWS))\r
-    {\r
+       {\r
                uint8_t response[] = { CONFIG_STATUS_ERR };\r
                hidPacket_send(response, sizeof(response));\r
        }\r
index e40b2cc0ca687259e631f3d178180c5a7ef1b2b7..114e8fb4ce984279762ad89309fdbce7c9f3e1c8 100755 (executable)
@@ -41,6 +41,8 @@ int main()
        configInit(&scsiDev.boardCfg);\r
        debugInit();\r
 \r
+       scsiPhyConfig();\r
+\r
        scsiInit();\r
        scsiDiskInit();\r
 \r
index d0fd43e15b41b978d9dceae25f00505563c8c143..84cbd885f2a41d88fced117b5ee78b0c06ae27d9 100755 (executable)
@@ -509,7 +509,10 @@ void scsiPhyInit()
        SCSI_RST_ISR_StartEx(scsiResetISR);\r
 \r
        SCSI_SEL_ISR_StartEx(scsiSelectionISR);\r
+}\r
 \r
+void scsiPhyConfig()\r
+{\r
        // Disable the glitch filter for ACK to improve performance.\r
        if (scsiDev.boardCfg.flags & CONFIG_DISABLE_GLITCH)\r
        {\r
@@ -518,7 +521,7 @@ void scsiPhyInit()
                // Reduce deskew time to 1. (deskew init + 0)\r
                CY_SET_REG8(scsiTarget_datapath__D0_REG, 0);\r
        }\r
-       if ((scsiDev.target->cfg->quirks == CONFIG_QUIRKS_XEBEC) ||\r
+       if ((scsiDev.target->cfg->quirks & CONFIG_QUIRKS_XEBEC) ||\r
                (scsiDev.boardCfg.scsiSpeed == CONFIG_SPEED_ASYNC_15))\r
        {\r
                // 125ns to 250ns deskew time = 3.125 clocks\r
index 08676b9954d7997016aca884c172ad75b2b68ff7..ec458c2e32d1c0c5fc96791b0da9749644ff520a 100755 (executable)
@@ -50,7 +50,7 @@ typedef enum
        CyPins_SetPin((pin));
 
 #define SCSI_ClearPin(pin) \
-       CyPins_ClearPin((pin)); 
+       CyPins_ClearPin((pin));
 #endif
 
 // Active low: we interpret a 0 as "true", and non-zero as "false"
@@ -83,6 +83,7 @@ extern volatile uint8_t scsiTxDMAComplete;
 
 void scsiPhyReset(void);
 void scsiPhyInit(void);
+void scsiPhyConfig(void);
 
 uint8_t scsiReadByte(void);
 void scsiRead(uint8_t* data, uint32_t count);
index 5bce4e03b5aaedd47ba04173995dbbda9644a958..548b07f3fcea3f31138ac94688f77dd62fed407d 100755 (executable)
@@ -57,6 +57,7 @@ ifeq ($(TARGET),Win32)
        LIBZIPPER_CONFIG+=--host=i686-w64-mingw32
        EXE=.exe
        WX_CONFIG+=--host=i686-w64-mingw32
+       TARGETOBJ = $(BUILD)/gnulib_ffs.o
 endif
 ifeq ($(TARGET),Win64)
        VPATH += hidapi-windows
@@ -67,6 +68,7 @@ ifeq ($(TARGET),Win64)
        LIBZIPPER_CONFIG+=--host=x86_64-w64-mingw32
        EXE=.exe
        WX_CONFIG+=--host=x86_64-w64-mingw32
+       TARGETOBJ = $(BUILD)/gnulib_ffs.o
 endif
 ifeq ($(TARGET),Linux)
        VPATH += hidapi/linux
@@ -114,6 +116,7 @@ CONSOLEOBJ = \
        $(BUILD)/SCSI2SD_Bootloader.o \
        $(BUILD)/SCSI2SD_HID.o \
        $(BUILD)/hidpacket.o \
+       $(TARGETOBJ)
 
 OBJ = \
        ${CONSOLEOBJ} \
index deba6c1ed119e9b463d2eee3d7e632dd934bc740..8ee7963a22c297881a33e1d9fa035f847e3b360e 100755 (executable)
@@ -32,6 +32,9 @@
 #include <math.h>
 #include <string.h>
 #include <strings.h> // for ffs
+#ifdef __MINGW32__
+extern "C" int ffs(int);
+#endif
 
 using namespace SCSI2SD;
 
diff --git a/software/scsi2sd-util/gnulib_ffs.c b/software/scsi2sd-util/gnulib_ffs.c
new file mode 100644 (file)
index 0000000..ca19300
--- /dev/null
@@ -0,0 +1,56 @@
+/* ffs.c -- find the first set bit in a word.
+   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake.  */
+
+// michael@codesrc.com #include <config.h>
+
+/* Specification.  */
+#include <strings.h>
+
+#include <limits.h>
+
+int
+ffs (int i)
+{
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+  return __builtin_ffs (i);
+#else
+  /* <https://github.com/gibsjose/BitHacks>
+     gives this deBruijn constant for a branch-less computation, although
+     that table counted trailing zeros rather than bit position.  This
+     requires 32-bit int, we fall back to a naive algorithm on the rare
+     platforms where that assumption is not true.  */
+  if (CHAR_BIT * sizeof i == 32)
+    {
+      static unsigned int table[] = {
+        1, 2, 29, 3, 30, 15, 25, 4, 31, 23, 21, 16, 26, 18, 5, 9,
+        32, 28, 14, 24, 22, 20, 17, 8, 27, 13, 19, 7, 12, 6, 11, 10
+      };
+      unsigned int u = i;
+      unsigned int bit = u & -u;
+      return table[(bit * 0x077cb531U) >> 27] - !i;
+    }
+  else
+    {
+      unsigned int j;
+      for (j = 0; j < CHAR_BIT * sizeof i; j++)
+        if (i & (1U << j))
+          return j + 1;
+      return 0;
+    }
+#endif
+}
index c55bea8dd0b20dddbdbe79571062f8d49b4aa4fb..e8b6013d5093207d890ccea23ebc0fcc95f8f8ae 100644 (file)
@@ -177,6 +177,18 @@ public:
                        ID_ConfigDefaults,
                        _("Load &Defaults"),
                        _("Load default configuration options."));
+
+               menuFile->AppendSeparator();
+               myLoadButton = menuFile->Append(
+                       ID_BtnLoad,
+                       _("Load from device"),
+                       _("Load configuration from hardware device"));
+               mySaveButton = menuFile->Append(
+                       ID_BtnSave,
+                       _("Save to device"),
+                       _("Save configuration to hardware device"));
+
+               menuFile->AppendSeparator();
                menuFile->Append(
                        ID_Firmware,
                        _("&Upgrade Firmware..."),
@@ -241,23 +253,13 @@ public:
                        tabs->Fit();
                        fgs->Add(tabs);
 
-
-                       wxPanel* btnPanel = new wxPanel(cfgPanel);
-                       wxFlexGridSizer *btnFgs = new wxFlexGridSizer(1, 2, 5, 5);
-                       btnPanel->SetSizer(btnFgs);
-                       myLoadButton =
-                               new wxButton(btnPanel, ID_BtnLoad, _("Load from device"));
-                       btnFgs->Add(myLoadButton);
-                       mySaveButton =
-                               new wxButton(btnPanel, ID_BtnSave, _("Save to device"));
-                       btnFgs->Add(mySaveButton);
-                       fgs->Add(btnPanel);
-
-                       btnPanel->Fit();
                        cfgPanel->Fit();
                }
-               //Fit(); // Needed to reduce window size on Windows
+#ifdef __WINDOWS__
+               Fit(); // Needed to reduce window size on Windows
+#else
                FitInside(); // Needed on Linux to prevent status bar overlap
+#endif
 
                myLogWindow = new wxLogWindow(this, _("scsi2sd-util debug log"), true);
                myLogWindow->PassMessages(false); // Prevent messagebox popups
@@ -270,8 +272,8 @@ private:
        wxLogWindow* myLogWindow;
        BoardPanel* myBoardPanel;
        std::vector<TargetPanel*> myTargets;
-       wxButton* myLoadButton;
-       wxButton* mySaveButton;
+       wxMenuItem* myLoadButton;
+       wxMenuItem* mySaveButton;
        wxMenuItem* mySCSILogChk;
        wxMenuItem* mySelfTestChk;
        wxTimer* myTimer;
@@ -1211,7 +1213,7 @@ private:
        {
                wxMessageBox(
                        "SCSI2SD (scsi2sd-util)\n"
-                       "Copyright (C) 2014 Michael McMaster <michael@codesrc.com>\n"
+                       "Copyright (C) 2014-2018 Michael McMaster <michael@codesrc.com>\n"
                        "\n"
 "This program is free software: you can redistribute it and/or modify\n"
 "it under the terms of the GNU General Public License as published by\n"
@@ -1246,8 +1248,8 @@ wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
 
        EVT_COMMAND(wxID_ANY, ConfigChangedEvent, AppFrame::onConfigChanged)
 
-       EVT_BUTTON(ID_BtnSave, AppFrame::doSave)
-       EVT_BUTTON(ID_BtnLoad, AppFrame::doLoad)
+       EVT_MENU(ID_BtnSave, AppFrame::doSave)
+       EVT_MENU(ID_BtnLoad, AppFrame::doLoad)
 
        EVT_CLOSE(AppFrame::OnCloseEvt)