diff --git a/CHANGELOG b/CHANGELOG index c9df6b2..02c01c5 100644 --- 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 diff --git a/software/SCSI2SD/src/config.c b/software/SCSI2SD/src/config.c index c672c31..70948f7 100755 --- a/software/SCSI2SD/src/config.c +++ b/software/SCSI2SD/src/config.c @@ -79,6 +79,7 @@ static void initBoardConfig(BoardConfig* config) { config->flags = getConfigByIndex(0)->flagsDEPRECATED; config->selectionDelay = 255; // auto + config->flags6 = S2S_CFG_ENABLE_TERMINATOR; } } @@ -146,7 +147,7 @@ writeFlashCommand(const uint8_t* cmd, size_t cmdSize) if ((flashArray != SCSI_CONFIG_ARRAY) || (flashRow < SCSI_CONFIG_4_ROW) || (flashRow >= SCSI_CONFIG_3_ROW + SCSI_CONFIG_ROWS)) - { + { uint8_t response[] = { CONFIG_STATUS_ERR }; hidPacket_send(response, sizeof(response)); } diff --git a/software/SCSI2SD/src/main.c b/software/SCSI2SD/src/main.c index e40b2cc..114e8fb 100755 --- a/software/SCSI2SD/src/main.c +++ b/software/SCSI2SD/src/main.c @@ -41,6 +41,8 @@ int main() configInit(&scsiDev.boardCfg); debugInit(); + scsiPhyConfig(); + scsiInit(); scsiDiskInit(); diff --git a/software/SCSI2SD/src/scsiPhy.c b/software/SCSI2SD/src/scsiPhy.c index d0fd43e..84cbd88 100755 --- a/software/SCSI2SD/src/scsiPhy.c +++ b/software/SCSI2SD/src/scsiPhy.c @@ -509,7 +509,10 @@ void scsiPhyInit() SCSI_RST_ISR_StartEx(scsiResetISR); SCSI_SEL_ISR_StartEx(scsiSelectionISR); +} +void scsiPhyConfig() +{ // Disable the glitch filter for ACK to improve performance. if (scsiDev.boardCfg.flags & CONFIG_DISABLE_GLITCH) { @@ -518,7 +521,7 @@ void scsiPhyInit() // Reduce deskew time to 1. (deskew init + 0) CY_SET_REG8(scsiTarget_datapath__D0_REG, 0); } - if ((scsiDev.target->cfg->quirks == CONFIG_QUIRKS_XEBEC) || + if ((scsiDev.target->cfg->quirks & CONFIG_QUIRKS_XEBEC) || (scsiDev.boardCfg.scsiSpeed == CONFIG_SPEED_ASYNC_15)) { // 125ns to 250ns deskew time = 3.125 clocks diff --git a/software/SCSI2SD/src/scsiPhy.h b/software/SCSI2SD/src/scsiPhy.h index 08676b9..ec458c2 100755 --- a/software/SCSI2SD/src/scsiPhy.h +++ b/software/SCSI2SD/src/scsiPhy.h @@ -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); diff --git a/software/scsi2sd-util/Makefile b/software/scsi2sd-util/Makefile index 5bce4e0..548b07f 100755 --- a/software/scsi2sd-util/Makefile +++ b/software/scsi2sd-util/Makefile @@ -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} \ diff --git a/software/scsi2sd-util/TargetPanel.cc b/software/scsi2sd-util/TargetPanel.cc index deba6c1..8ee7963 100755 --- a/software/scsi2sd-util/TargetPanel.cc +++ b/software/scsi2sd-util/TargetPanel.cc @@ -32,6 +32,9 @@ #include #include #include // 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 index 0000000..ca19300 --- /dev/null +++ b/software/scsi2sd-util/gnulib_ffs.c @@ -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 . */ + +/* Written by Eric Blake. */ + +// michael@codesrc.com #include + +/* Specification. */ +#include + +#include + +int +ffs (int i) +{ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) + return __builtin_ffs (i); +#else + /* + 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 +} diff --git a/software/scsi2sd-util/scsi2sd-util.cc b/software/scsi2sd-util/scsi2sd-util.cc index c55bea8..e8b6013 100644 --- a/software/scsi2sd-util/scsi2sd-util.cc +++ b/software/scsi2sd-util/scsi2sd-util.cc @@ -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 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 \n" + "Copyright (C) 2014-2018 Michael McMaster \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)