소스 검색

Add ability to clear the rom header via CLEAR_ROM file

Note: Added #ifdefs for platforms without romdrive (Petteri Aimonen)
Eric Helgeson 2 년 전
부모
커밋
09e0cde73d
3개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      src/ZuluSCSI.cpp
  2. 20 0
      src/ZuluSCSI_disk.cpp
  3. 2 0
      src/ZuluSCSI_disk.h

+ 6 - 0
src/ZuluSCSI.cpp

@@ -214,6 +214,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

+ 20 - 0
src/ZuluSCSI_disk.cpp

@@ -116,6 +116,26 @@ static bool check_romdrive(romdrive_hdr_t *hdr)
     return true;
 }
 
+// Clear the drive metadata header
+bool scsiDiskClearRomDrive()
+{
+#ifndef PLATFORM_HAS_ROM_DRIVE
+    azlog("---- Platform does not support ROM drive");
+    return false;
+#else
+    romdrive_hdr_t hdr = {0x0};
+
+    if (!azplatform_write_romdrive((const uint8_t*)&hdr, 0, AZPLATFORM_ROMDRIVE_PAGE_SIZE))
+    {
+        azlog("-- Failed to clear ROM drive");
+        return false;
+    }
+    azlog("-- Cleared ROM drive");
+    SD.remove("CLEAR_ROM");
+    return true;
+#endif
+}
+
 // Load an image file to romdrive
 bool scsiDiskProgramRomDrive(const char *filename, int scsi_id, int blocksize, S2S_CFG_TYPE type)
 {

+ 2 - 0
src/ZuluSCSI_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);