Kaynağa Gözat

Disable raw fallback when image is specified through .ini (ZuluSCSI/ZuluSCSI-firmware#39)

Changed so that code properly checks for image specified through
any means, not just through filename lookup.
Petteri Aimonen 3 yıl önce
ebeveyn
işleme
04ab950e5c
3 değiştirilmiş dosya ile 22 ekleme ve 8 silme
  1. 6 8
      src/ZuluSCSI.cpp
  2. 13 0
      src/ZuluSCSI_disk.cpp
  3. 3 0
      src/ZuluSCSI_disk.h

+ 6 - 8
src/ZuluSCSI.cpp

@@ -329,12 +329,6 @@ bool findHDDImages()
   }
   root.close();
 
-  // Error if there are 0 image files
-  if(!foundImage) {
-    azlog("ERROR: No valid images found!");
-    blinkStatus(BLINK_ERROR_NO_IMAGES);
-  }
-
   // Print SCSI drive map
   for (int i = 0; i < NUM_SCSIID; i++)
   {
@@ -381,9 +375,10 @@ static void reinitSCSI()
 {
   scsiDiskResetImages();
   readSCSIDeviceConfig();
-  bool foundImage = findHDDImages();
+  findHDDImages();
 
-  if (foundImage)
+  // Error if there are 0 image files
+  if (scsiDiskCheckAnyImagesConfigured())
   {
     // Ok, there is an image
     blinkStatus(BLINK_STATUS_OK);
@@ -394,7 +389,10 @@ static void reinitSCSI()
     azlog("No images found, enabling RAW fallback partition");
     scsiDiskOpenHDDImage(RAW_FALLBACK_SCSI_ID, "RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
                          RAW_FALLBACK_BLOCKSIZE, false, false);
+#else
+    azlog("No valid image files found!");
 #endif
+    blinkStatus(BLINK_ERROR_NO_IMAGES);
   }
 
   scsiPhyReset();

+ 13 - 0
src/ZuluSCSI_disk.cpp

@@ -521,6 +521,19 @@ void scsiDiskLoadConfig(int target_idx)
     }
 }
 
+bool scsiDiskCheckAnyImagesConfigured()
+{
+    for (int i = 0; i < S2S_MAX_TARGETS; i++)
+    {
+        if (g_DiskImages[i].file.isOpen() && (g_DiskImages[i].scsiId & S2S_CFG_TARGET_ENABLED))
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 /*******************************/
 /* Config handling for SCSI2SD */
 /*******************************/

+ 3 - 0
src/ZuluSCSI_disk.h

@@ -16,3 +16,6 @@ extern "C" {
 void scsiDiskResetImages();
 bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, bool is_cd, bool is_fd);
 void scsiDiskLoadConfig(int target_idx);
+
+// Returns true if there is at least one image active
+bool scsiDiskCheckAnyImagesConfigured();