Pārlūkot izejas kodu

Add ability to clear the rom header via CLEAR_ROM file

Eric Helgeson 2 gadi atpakaļ
vecāks
revīzija
ce81e51882
3 mainītis faili ar 23 papildinājumiem un 0 dzēšanām
  1. 6 0
      src/BlueSCSI.cpp
  2. 15 0
      src/BlueSCSI_disk.cpp
  3. 2 0
      src/BlueSCSI_disk.h

+ 6 - 0
src/BlueSCSI.cpp

@@ -248,6 +248,12 @@ bool findHDDImages()
       bool is_re = (tolower(name[0]) == 'r' && tolower(name[1]) == 'e');
       bool is_tp = (tolower(name[0]) == 't' && tolower(name[1]) == 'p');
 
+      if(strcasecmp(name, "CLEAR_ROM") == 0)
+      {
+        scsiDiskClearRomDrive();
+        continue;
+      }
+
       if (is_hd || is_cd || is_fd || is_mo || is_re || is_tp)
       {
         // Check file extension

+ 15 - 0
src/BlueSCSI_disk.cpp

@@ -116,6 +116,21 @@ static bool check_romdrive(romdrive_hdr_t *hdr)
     return true;
 }
 
+// Clear the drive metadata header
+bool scsiDiskClearRomDrive()
+{
+    romdrive_hdr_t hdr = {0x0};
+
+    if (!platform_write_romdrive((const uint8_t*)&hdr, 0, PLATFORM_ROMDRIVE_PAGE_SIZE))
+    {
+        log("-- Failed to clear ROM drive");
+        return false;
+    }
+    log("-- Cleared ROM drive");
+    SD.remove("CLEAR_ROM");
+    return true;
+}
+
 // Load an image file to romdrive
 bool scsiDiskProgramRomDrive(const char *filename, int scsi_id, int blocksize, S2S_CFG_TYPE type)
 {

+ 2 - 0
src/BlueSCSI_disk.h

@@ -17,6 +17,8 @@ void scsiDiskResetImages();
 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);
 
+// Clear the ROM drive header from flash
+bool scsiDiskClearRomDrive();
 // Program ROM drive and rename image file
 bool scsiDiskProgramRomDrive(const char *filename, int scsi_id, int blocksize, S2S_CFG_TYPE type);