Jelajahi Sumber

Add more filename prefixes: MO, RE, TP

Petteri Aimonen 3 tahun lalu
induk
melakukan
54242ed199
4 mengubah file dengan 40 tambahan dan 9 penghapusan
  1. 3 0
      README.md
  2. 16 3
      src/ZuluSCSI.cpp
  3. 20 5
      src/ZuluSCSI_disk.cpp
  4. 1 1
      src/ZuluSCSI_disk.h

+ 3 - 0
README.md

@@ -12,6 +12,9 @@ Examples of valid filenames:
 
 In addition to the simplified filenames style above, the ZuluSCSI firmware also looks for images using the BlueSCSI-style "HDxy_512.hda" filename formatting.
 
+The media type can be set in `zuluscsi.ini`, or directly by the file name prefix.
+Supported prefixes are `HD` (hard drive), `CD` (cd-rom), `FD` (floppy), `MO` (magneto-optical), `RE` (generic removeable media), `TP` (sequential tape drive).
+
 Log files and error indications
 -------------------------------
 Log messages are stored in `zululog.txt`, which is cleared on every boot.

+ 16 - 3
src/ZuluSCSI.cpp

@@ -212,8 +212,11 @@ bool findHDDImages()
       bool is_hd = (tolower(name[0]) == 'h' && tolower(name[1]) == 'd');
       bool is_cd = (tolower(name[0]) == 'c' && tolower(name[1]) == 'd');
       bool is_fd = (tolower(name[0]) == 'f' && tolower(name[1]) == 'd');
+      bool is_mo = (tolower(name[0]) == 'm' && tolower(name[1]) == 'o');
+      bool is_re = (tolower(name[0]) == 'r' && tolower(name[1]) == 'e');
+      bool is_tp = (tolower(name[0]) == 't' && tolower(name[1]) == 'p');
 
-      if (is_hd || is_cd || is_fd)
+      if (is_hd || is_cd || is_fd || is_mo || is_re || is_tp)
       {
         // Check file extension
         // We accept anything except known compressed files
@@ -308,7 +311,17 @@ bool findHDDImages()
         // Open the image file
         if(id < NUM_SCSIID && lun < NUM_SCSILUN) {
           azlog("-- Opening ", fullname, " for id:", id, " lun:", lun);
-          imageReady = scsiDiskOpenHDDImage(id, fullname, id, lun, blk, is_cd, is_fd);
+
+          // Type mapping based on filename.
+          // If type is FIXED, the type can still be overridden in .ini file.
+          S2S_CFG_TYPE type = S2S_CFG_FIXED;
+          if (is_cd) type = S2S_CFG_OPTICAL;
+          if (is_fd) type = S2S_CFG_FLOPPY_14MB;
+          if (is_mo) type = S2S_CFG_MO;
+          if (is_re) type = S2S_CFG_REMOVEABLE;
+          if (is_tp) type = S2S_CFG_SEQUENTIAL;
+
+          imageReady = scsiDiskOpenHDDImage(id, fullname, id, lun, blk, type);
           if(imageReady)
           {
             foundImage = true;
@@ -388,7 +401,7 @@ static void reinitSCSI()
 #if RAW_FALLBACK_ENABLE
     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);
+                         RAW_FALLBACK_BLOCKSIZE);
 #else
     azlog("No valid image files found!");
 #endif

+ 20 - 5
src/ZuluSCSI_disk.cpp

@@ -367,7 +367,7 @@ static void setDefaultDriveInfo(int target_idx)
     formatDriveInfoField(img.serial, sizeof(img.serial), true);
 }
 
-bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, bool is_cd, bool is_fd)
+bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, S2S_CFG_TYPE type)
 {
     image_config_t &img = g_DiskImages[target_idx];
     img.file = ImageBackingStore(filename);
@@ -396,16 +396,31 @@ bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int
             azlog("---- WARNING: file ", filename, " is not contiguous. This will increase read latency.");
         }
 
-        if (is_cd)
+        if (type == S2S_CFG_OPTICAL)
         {
             azlog("---- Configuring as CD-ROM drive based on image name");
             img.deviceType = S2S_CFG_OPTICAL;
         }
-        else if (is_fd)
+        else if (type == S2S_CFG_FLOPPY_14MB)
         {
             azlog("---- Configuring as floppy drive based on image name");
             img.deviceType = S2S_CFG_FLOPPY_14MB;
         }
+        else if (type == S2S_CFG_MO)
+        {
+            azlog("---- Configuring as magneto-optical based on image name");
+            img.deviceType = S2S_CFG_MO;
+        }
+        else if (type == S2S_CFG_REMOVEABLE)
+        {
+            azlog("---- Configuring as removable drive based on image name");
+            img.deviceType = S2S_CFG_REMOVEABLE;
+        }
+        else if (type == S2S_CFG_SEQUENTIAL)
+        {
+            azlog("---- Configuring as tape drive based on image name");
+            img.deviceType = S2S_CFG_SEQUENTIAL;
+        }
 
 #ifdef AZPLATFORM_CONFIG_HOOK
         AZPLATFORM_CONFIG_HOOK(&img);
@@ -528,7 +543,7 @@ void scsiDiskLoadConfig(int target_idx)
         image_config_t &img = g_DiskImages[target_idx];
         int blocksize = (img.deviceType == S2S_CFG_OPTICAL) ? 2048 : 512;
         azlog("-- Opening ", filename, " for id:", target_idx, ", specified in " CONFIGFILE);
-        scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0, blocksize, false, false);
+        scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0, blocksize);
     }
 }
 
@@ -793,7 +808,7 @@ static bool checkNextCDImage()
         azlog("Switching to next CD-ROM image for ", target_idx, ": ", filename);
         image_config_t &img = g_DiskImages[target_idx];
         img.file.close();
-        bool status = scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0, 2048, false, false);
+        bool status = scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0, 2048);
 
         if (status)
         {

+ 1 - 1
src/ZuluSCSI_disk.h

@@ -14,7 +14,7 @@ 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);
+bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, S2S_CFG_TYPE type = S2S_CFG_FIXED);
 void scsiDiskLoadConfig(int target_idx);
 
 // Returns true if there is at least one image active