Просмотр исходного кода

Add back original BlueSCSI Toolbox

Eric Helgeson 6 месяцев назад
Родитель
Сommit
94268e8ef5
3 измененных файлов с 61 добавлено и 57 удалено
  1. 5 5
      lib/SCSI2SD/src/firmware/mode.c
  2. 34 32
      src/BlueSCSI_Toolbox.cpp
  3. 22 20
      src/BlueSCSI_Toolbox.h

+ 5 - 5
lib/SCSI2SD/src/firmware/mode.c

@@ -248,12 +248,12 @@ static const uint8_t AppleVendorPage[] =
 'A','P','P','L','E',' ','C','O','M','P','U','T','E','R',',',' ','I','N','C',' ',' ',' '
 };
 
-static const uint8_t ToolboxVendorPage[] =
+static const uint8_t BlueSCSIVendorPage[] =
 {
 0x31, // Page code
 42,   // Page length
-'Z','u','l','u','S','C','S','I',' ','i','s',' ','G','P','L','v','3',' ','F','T','W',
-' ','R','a','b','b','i','t','H','o','l','e','C','o','m','p','u','t','i','n','g',0x00
+'B','l','u','e','S','C','S','I',' ','i','s',' ','t','h','e',' ','B','E','S','T',' ',
+'S','T','O','L','E','N',' ','F','R','O','M',' ','B','L','U','E','S','C','S','I',0x00
 };
 
 static const uint8_t IomegaZip100VendorPage[] =
@@ -570,8 +570,8 @@ static void doModeSense(
 	if (scsiToolboxEnabled() && (pageCode == 0x31 || pageCode == 0x3F))
 	{
 		pageFound = 1;
-		pageIn(pc, idx, ToolboxVendorPage, sizeof(ToolboxVendorPage));
-		idx += sizeof(ToolboxVendorPage);
+		pageIn(pc, idx, BlueSCSIVendorPage, sizeof(BlueSCSIVendorPage));
+		idx += sizeof(BlueSCSIVendorPage);
 	}
 
 	if (pageCode == 0x38) // Don't send unless requested

+ 34 - 32
src/BlueSCSI_Toolbox.cpp

@@ -1,5 +1,6 @@
 /**
- * Copyright (C) 2023 Eric Helgeson
+ * Copyright (C) 2023-2025 Eric Helgeson
+ * Copyright (c) 2024-2025 Rabbit Hole Computing
  *
  * This file is part of BlueSCSI
  *
@@ -29,10 +30,6 @@ extern "C" {
 #include <mode.h>
 }
 
-
-const uint8_t MAX_FILE_LISTING_FILES = 100;
-
-
 extern "C" int8_t scsiToolboxEnabled()
 {
     static int8_t enabled = -1;
@@ -52,6 +49,11 @@ static bool toolboxFilenameValid(const char* name, bool isCD = false)
         dbgmsg("toolbox: Ignoring filename empty file name");
         return false;
     }
+    if(name[0] == '.')
+    {
+        dbgmsg("toolbox: Ignoring hidden file ", name);
+        return false;
+    }
     if (isCD)
     {
       return scsiDiskFilenameValid(name);
@@ -105,7 +107,6 @@ static void doCountFiles(const char * dir_name, bool isCD = false)
 static void onListFiles(const char * dir_name, bool isCD = false) {
     FsFile dir;
     FsFile file;
-    const size_t ENTRY_SIZE = 40;
 
     memset(scsiDev.data, 0, ENTRY_SIZE * (MAX_FILE_LISTING_FILES + 1));
     char name[MAX_FILE_PATH] = {0};
@@ -220,6 +221,7 @@ static void onListDevices()
         }
     }
     scsiDev.dataLen = NUM_SCSIID;
+    scsiDev.phase = DATA_IN;
 }
 
 static void onSetNextCD(const char * img_dir)
@@ -267,7 +269,7 @@ void onGetFile10(char * dir_name) {
 }
 
 /*
-  Prepares a file for receving. The file name is null terminated in the scsi data.
+  Prepares a file for receiving. The file name is null terminated in the scsi data.
 */
 static void onSendFilePrep(char * dir_name)
 {
@@ -370,73 +372,73 @@ extern "C" int scsiToolboxCommand()
     image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
     uint8_t command = scsiDev.cdb[0];
 
-    if (unlikely(command == TOOLBOX_COUNT_FILES))
+    if (unlikely(command == BLUESCSI_TOOLBOX_COUNT_FILES))
     {
         char img_dir[MAX_FILE_PATH];
-        dbgmsg("TOOLBOX_COUNT_FILES");
+        dbgmsg("BLUESCSI_TOOLBOX_COUNT_FILES");
         getToolBoxSharedDir(img_dir);
         doCountFiles(img_dir);
     }
-    else if (unlikely(command == TOOLBOX_LIST_FILES))
+    else if (unlikely(command == BLUESCSI_TOOLBOX_LIST_FILES))
     {
         char img_dir[MAX_FILE_PATH];
-        dbgmsg("TOOLBOX_LIST_FILES");
+        dbgmsg("BLUESCSI_TOOLBOX_LIST_FILES");
         getToolBoxSharedDir(img_dir);
         onListFiles(img_dir);
     }
-    else if (unlikely(command == TOOLBOX_GET_FILE))
+    else if (unlikely(command == BLUESCSI_TOOLBOX_GET_FILE))
     {
         char img_dir[MAX_FILE_PATH];
-        dbgmsg("TOOLBOX_GET_FILE");
+        dbgmsg("BLUESCSI_TOOLBOX_GET_FILE");
         getToolBoxSharedDir(img_dir);
         onGetFile10(img_dir);
     }
-    else if (unlikely(command == TOOLBOX_SEND_FILE_PREP))
+    else if (unlikely(command == BLUESCSI_TOOLBOX_SEND_FILE_PREP))
     {
         char img_dir[MAX_FILE_PATH];
-        dbgmsg("TOOLBOX_SEND_FILE_PREP");
+        dbgmsg("BLUESCSI_TOOLBOX_SEND_FILE_PREP");
         getToolBoxSharedDir(img_dir);
         onSendFilePrep(img_dir);
     }
-    else if (unlikely(command == TOOLBOX_SEND_FILE_10))
+    else if (unlikely(command == BLUESCSI_TOOLBOX_SEND_FILE_10))
     {
-        dbgmsg("TOOLBOX_SEND_FILE_10");
+        dbgmsg("BLUESCSI_TOOLBOX_SEND_FILE_10");
         onSendFile10();
     }
-    else if (unlikely(command == TOOLBOX_SEND_FILE_END))
+    else if (unlikely(command == BLUESCSI_TOOLBOX_SEND_FILE_END))
     {
-        dbgmsg("TOOLBOX_SEND_FILE_END");
+        dbgmsg("BLUESCSI_TOOLBOX_SEND_FILE_END");
         onSendFileEnd();
     }
-    else if(unlikely(command == TOOLBOX_TOGGLE_DEBUG))
+    else if(unlikely(command == BLUESCSI_TOOLBOX_TOGGLE_DEBUG))
     {
-        dbgmsg("TOOLBOX_TOGGLE_DEBUG");
+        dbgmsg("BLUESCSI_TOOLBOX_TOGGLE_DEBUG");
         onToggleDebug();
     }
-    else if(unlikely(command == TOOLBOX_LIST_CDS))
+    else if(unlikely(command == BLUESCSI_TOOLBOX_LIST_CDS))
     {
         char img_dir[4];
-        dbgmsg("TOOLBOX_LIST_CDS");
-        snprintf(img_dir, sizeof(img_dir), CD_IMG_DIR, (int)img.scsiId & S2S_CFG_TARGET_ID_BITS);
+        dbgmsg("BLUESCSI_TOOLBOX_LIST_CDS");
+        snprintf(img_dir, sizeof(img_dir), CD_IMG_DIR, static_cast<int>(img.scsiId) & S2S_CFG_TARGET_ID_BITS);
         onListFiles(img_dir, true);
     }
-    else if(unlikely(command == TOOLBOX_SET_NEXT_CD))
+    else if(unlikely(command == BLUESCSI_TOOLBOX_SET_NEXT_CD))
     {
         char img_dir[4];
-        dbgmsg("TOOLBOX_SET_NEXT_CD");
-        snprintf(img_dir, sizeof(img_dir), CD_IMG_DIR, (int)img.scsiId & S2S_CFG_TARGET_ID_BITS);
+        dbgmsg("BLUESCSI_TOOLBOX_SET_NEXT_CD");
+        snprintf(img_dir, sizeof(img_dir), CD_IMG_DIR, static_cast<int>(img.scsiId) & S2S_CFG_TARGET_ID_BITS);
         onSetNextCD(img_dir);
     }
-    else if(unlikely(command == TOOLBOX_LIST_DEVICES))
+    else if(unlikely(command == BLUESCSI_TOOLBOX_LIST_DEVICES))
     {
-        dbgmsg("TOOLBOX_LIST_DEVICES");
+        dbgmsg("BLUESCSI_TOOLBOX_LIST_DEVICES");
         onListDevices();
     }
-    else if (unlikely(command == TOOLBOX_COUNT_CDS))
+    else if (unlikely(command == BLUESCSI_TOOLBOX_COUNT_CDS))
     {
         char img_dir[4];
-        dbgmsg("TOOLBOX_COUNT_CDS");
-        snprintf(img_dir, sizeof(img_dir), CD_IMG_DIR, (int)img.scsiId & S2S_CFG_TARGET_ID_BITS);
+        dbgmsg("BLUESCSI_TOOLBOX_COUNT_CDS");
+        snprintf(img_dir, sizeof(img_dir), CD_IMG_DIR, static_cast<int>(img.scsiId) & S2S_CFG_TARGET_ID_BITS);
         doCountFiles(img_dir, true);
     }
     else

+ 22 - 20
src/BlueSCSI_Toolbox.h

@@ -1,18 +1,18 @@
-/** 
- * Copyright (C) 2023 Eric Helgeson
- * 
+/**
+ * Copyright (C) 2023-2025 Eric Helgeson
+ *
  * This file is part of BlueSCSI
- * 
+ *
  * 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. 
- * 
+ * (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. 
- * 
+ * 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/>.
 **/
@@ -20,18 +20,20 @@
 #pragma once
 
 #define MAX_MAC_PATH 32
-#define CD_IMG_DIR "CD%d"
+#define ENTRY_SIZE 40
+#define MAX_FILE_LISTING_FILES 100
 
+#define CD_IMG_DIR "CD%d"
 
-#define TOOLBOX_LIST_FILES     0xD0
-#define TOOLBOX_GET_FILE       0xD1
-#define TOOLBOX_COUNT_FILES    0xD2
-#define TOOLBOX_SEND_FILE_PREP 0xD3
-#define TOOLBOX_SEND_FILE_10   0xD4
-#define TOOLBOX_SEND_FILE_END  0xD5
-#define TOOLBOX_TOGGLE_DEBUG   0xD6
-#define TOOLBOX_LIST_CDS       0xD7
-#define TOOLBOX_SET_NEXT_CD    0xD8
-#define TOOLBOX_LIST_DEVICES   0xD9
-#define TOOLBOX_COUNT_CDS      0xDA
+#define BLUESCSI_TOOLBOX_COUNT_FILES    0xD2
+#define BLUESCSI_TOOLBOX_LIST_FILES     0xD0
+#define BLUESCSI_TOOLBOX_GET_FILE       0xD1
+#define BLUESCSI_TOOLBOX_SEND_FILE_PREP 0xD3
+#define BLUESCSI_TOOLBOX_SEND_FILE_10   0xD4
+#define BLUESCSI_TOOLBOX_SEND_FILE_END  0xD5
+#define BLUESCSI_TOOLBOX_TOGGLE_DEBUG   0xD6
+#define BLUESCSI_TOOLBOX_LIST_CDS       0xD7
+#define BLUESCSI_TOOLBOX_SET_NEXT_CD    0xD8
+#define BLUESCSI_TOOLBOX_LIST_DEVICES   0xD9
+#define BLUESCSI_TOOLBOX_COUNT_CDS      0xDA
 #define OPEN_RETRO_SCSI_TOO_MANY_FILES 0x0001