Quellcode durchsuchen

Merge pull request #342 from ZuluSCSI/fix-implicit-device-typing

Restore implicit device settings. This is a fix for issue: #340
Alex Perez vor 1 Jahr
Ursprung
Commit
9b12855720

+ 1 - 1
lib/ZuluSCSI_platform_GD32F205/platform_hw_config.cpp

@@ -101,7 +101,7 @@ void HardwareConfig::init_state(bool is_active)
         m_blocksize = RAW_FALLBACK_BLOCKSIZE;
     }
 
-//    initDeviceSettingsPreset(m_scsi_id, m_device_preset);
+
 }
 
 #endif // ZULUSCSI_HARDWARE_CONFIG

+ 10 - 0
platformio.ini

@@ -147,6 +147,16 @@ board_build.core = earlephilhower
 extra_scripts = src/build_bootloader.py
 ldscript_bootloader = lib/ZuluSCSI_platform_RP2040/rp2040_btldr.ld
 board_build.ldscript = lib/ZuluSCSI_platform_RP2040/rp2040-daynaport.ld
+debug_tool = cmsis-dap
+debug_build_flags =
+    -O2 -ggdb -g3
+    -DLOGBUFSIZE=4096
+    -DPREFETCH_BUFFER_SIZE=0
+    -DSCSI2SD_BUFFER_SIZE=57344
+    ; This controls the depth of 2 x NETWORK_PACKET_MAX_SIZE (1520 bytes)
+    ; For example a queue size of 10 would be 10 x 2 x 1520 = 30400 bytes
+    -DNETWORK_PACKET_QUEUE_SIZE=10
+
 lib_deps =
     SdFat=https://github.com/rabbitholecomputing/SdFat#2.2.0-gpt
     minIni

+ 3 - 1
src/ZuluSCSI.cpp

@@ -497,6 +497,7 @@ bool findHDDImages()
         if (is_re) type = S2S_CFG_REMOVABLE;
         if (is_tp) type = S2S_CFG_SEQUENTIAL;
 
+        g_scsi_settings.initDevice(id & 7, type);
         // Open the image file
         if (id < NUM_SCSIID && is_romdrive)
         {
@@ -648,7 +649,7 @@ static void reinitSCSI()
   {
     bool success;
     uint8_t scsiId = g_hw_config.scsi_id();
-    g_scsi_settings.initDevicePreset(scsiId, g_hw_config.device_preset());
+    g_scsi_settings.initDevice(scsiId, g_hw_config.device_type());
 
     logmsg("Direct/Raw mode enabled, using hardware switches for configuration");
     success = scsiDiskOpenHDDImage(scsiId, "RAW:0:0xFFFFFFFF",scsiId, 0,
@@ -681,6 +682,7 @@ static void reinitSCSI()
     {
   #ifdef RAW_FALLBACK_ENABLE
       logmsg("No images found, enabling RAW fallback partition");
+      g_scsi_settings.initDevice(RAW_FALLBACK_SCSI_ID, S2S_CFG_FIXED);
       scsiDiskOpenHDDImage(RAW_FALLBACK_SCSI_ID, "RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
                           RAW_FALLBACK_BLOCKSIZE);
   #else

+ 2 - 22
src/ZuluSCSI_disk.cpp

@@ -141,6 +141,7 @@ bool scsiDiskActivateRomDrive()
     }
 
     logmsg("---- Activating ROM drive, SCSI id ", (int)hdr.scsi_id, " size ", (int)(hdr.imagesize / 1024), " kB");
+    g_scsi_settings.initDevice(hdr.scsi_id, hdr.drivetype);
     bool status = scsiDiskOpenHDDImage(hdr.scsi_id, "ROM:", hdr.scsi_id, 0, hdr.blocksize, hdr.drivetype);
 
     if (!status)
@@ -510,6 +511,7 @@ static void scsiDiskSetConfig(int target_idx)
         tmp[2] += target_idx;
         scsiDiskCheckDir(tmp, target_idx, &img, S2S_CFG_FLOPPY_14MB, "floppy");
     }
+    g_scsi_settings.initDevice(target_idx, (S2S_CFG_TYPE)img.deviceType);
 }
 
 // Finds filename with the lowest lexical order _after_ the given filename in
@@ -707,28 +709,6 @@ int scsiDiskGetNextImageName(image_config_t &img, char *buf, size_t buflen)
 
 void scsiDiskLoadConfig(int target_idx)
 {
-    // Get values from system preset, if any
-    char presetName[32] = {};
-
-    // Get values from device preset, if any
-    char section[6] = "SCSI0";
-    section[4] = '0' + target_idx;
-#ifdef ZULUSCSI_HARDWARE_CONFIG
-    const char *hwDevicePresetName = g_scsi_settings.getDevicePresetName(target_idx);
-    if (g_hw_config.is_active())
-    {
-        if (strlen(hwDevicePresetName) < sizeof(presetName))
-        {
-            strncpy(presetName, hwDevicePresetName, sizeof(presetName) - 1);
-        }
-    }
-    else
-#endif
-    {
-        ini_gets(section, "Device", "", presetName, sizeof(presetName), CONFIGFILE);
-    }
-    g_scsi_settings.initDevicePName(target_idx, presetName);
-
     // Then settings specific to target ID
     scsiDiskSetConfig(target_idx);
 

+ 27 - 14
src/ZuluSCSI_settings.cpp

@@ -92,13 +92,15 @@ const char **ZuluSCSISettings::deviceInitST32430N(uint8_t scsiId)
 }
 
 
-void ZuluSCSISettings::setDefaultDriveInfo(uint8_t scsiId, const char *presetName)
+void ZuluSCSISettings::setDefaultDriveInfo(uint8_t scsiId, const char *presetName, S2S_CFG_TYPE type)
 {
     char section[6] = "SCSI0";
     section[4] += scsiId;
 
     scsi_device_settings_t &cfgDev = m_dev[scsiId];
     scsi_device_settings_t &cfgDefault = m_dev[SCSI_SETTINGS_SYS_IDX];
+    
+
 
     static const char *driveinfo_fixed[4]     = DRIVEINFO_FIXED;
     static const char *driveinfo_removable[4] = DRIVEINFO_REMOVABLE;
@@ -155,7 +157,8 @@ void ZuluSCSISettings::setDefaultDriveInfo(uint8_t scsiId, const char *presetNam
 
     if (m_devPreset[scsiId] == DEV_PRESET_NONE)
     {
-            if (cfgSys.quirks == S2S_CFG_QUIRKS_APPLE)
+        cfgDev.deviceType = type;
+        if (cfgSys.quirks == S2S_CFG_QUIRKS_APPLE)
         {
             // Use default drive IDs that are recognized by Apple machines
             switch (cfgDev.deviceType)
@@ -365,16 +368,32 @@ scsi_system_settings_t *ZuluSCSISettings::initSystem(const char *presetName)
     return &cfgSys;
 }
 
-scsi_device_settings_t* ZuluSCSISettings::initDevicePName(uint8_t scsiId, const char *presetName)
+scsi_device_settings_t* ZuluSCSISettings::initDevice(uint8_t scsiId, S2S_CFG_TYPE type)
 {
     scsi_device_settings_t& cfg = m_dev[scsiId];
+    char presetName[32] = {};
+    char section[6] = "SCSI0";
+    section[4] = '0' + scsiId;
+
+#ifdef ZULUSCSI_HARDWARE_CONFIG
+    const char *hwDevicePresetName = g_scsi_settings.getDevicePresetName(scsiId);
+    if (g_hw_config.is_active())
+    {
+        if (strlen(hwDevicePresetName) < sizeof(presetName))
+        {
+            strncpy(presetName, hwDevicePresetName, sizeof(presetName) - 1);
+        }
+    }
+    else
+#endif
+    {
+        ini_gets(section, "Device", "", presetName, sizeof(presetName), CONFIGFILE);
+    }
+
 
     // Write default configuration from system setting initialization
     memcpy(&cfg, &m_dev[SCSI_SETTINGS_SYS_IDX], sizeof(cfg));
-    
-    char section[6] = "SCSI0";
-    section[4] += scsiId;
-    setDefaultDriveInfo(scsiId, presetName);
+    setDefaultDriveInfo(scsiId, presetName, type);
     readIniSCSIDeviceSetting(cfg, section);
 
     if (cfg.serial[0] == '\0')
@@ -408,12 +427,6 @@ scsi_device_settings_t* ZuluSCSISettings::initDevicePName(uint8_t scsiId, const
     return &cfg;
 }
 
-scsi_device_settings_t *ZuluSCSISettings::initDevicePreset(uint8_t scsiId, const scsi_device_preset_t preset)
-{
-    return initDevicePName(scsiId, devicePresetName[preset]);
-}
-
-
 scsi_system_settings_t *ZuluSCSISettings::getSystem()
 {
     return &m_sys;
@@ -442,4 +455,4 @@ scsi_device_preset_t ZuluSCSISettings::getDevicePreset(uint8_t scsiId)
 const char* ZuluSCSISettings::getDevicePresetName(uint8_t scsiId)
 {
     return devicePresetName[m_devPreset[scsiId]];
-}
+}

+ 3 - 3
src/ZuluSCSI_settings.h

@@ -23,6 +23,7 @@
 #ifdef __cplusplus
 
 #include <stdint.h>
+#include <scsi2sd.h>
 
 // Index 8 is the system defaults
 // Index 0-7 represent device settings
@@ -102,8 +103,7 @@ public:
     // Copy any shared device setting done the initSystemSettings as default settings, 
     // or return the default config if unknown device type.
     // Then overwrite any settings with those in the CONFIGFILE
-    scsi_device_settings_t *initDevicePName(uint8_t scsiId, const char *presetName);
-    scsi_device_settings_t *initDevicePreset(uint8_t scsiId, const scsi_device_preset_t preset);
+    scsi_device_settings_t *initDevice(uint8_t scsiId, S2S_CFG_TYPE type);
     // return the system settings struct to read values
     scsi_system_settings_t *getSystem();
 
@@ -125,7 +125,7 @@ public:
 protected:
     // Set default drive vendor / product info after the image file
     // is loaded and the device type is known.
-    void setDefaultDriveInfo(uint8_t scsiId, const char *presetName);
+    void setDefaultDriveInfo(uint8_t scsiId, const char *presetName, S2S_CFG_TYPE type);
 
     // Settings for the specific device
     const char **deviceInitST32430N(uint8_t scsiId);