]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
scsi.device disable option
authorToni Wilen <twilen@winuae.net>
Sat, 1 Jan 2022 15:01:27 +0000 (17:01 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 1 Jan 2022 15:01:27 +0000 (17:01 +0200)
cfgfile.cpp
filesys.cpp
include/options.h

index 81bb136d7c8ecae5e13d0a8a5d5148469c651f1d..92e1c2fd739a69d7df0e76ef2ef148fb0c6cf066 100644 (file)
@@ -1964,8 +1964,9 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
                cfgfile_write_str (f, _T("cart"), p->cartident);
        cfgfile_dwrite_path (f, &p->path_rom, _T("picassoiv_rom_file"), p->picassoivromfile);
 
-       cfgfile_write_bool (f, _T("kickshifter"), p->kickshifter);
-       cfgfile_dwrite_bool (f, _T("ks_write_enabled"), p->rom_readwrite);
+       cfgfile_write_bool(f, _T("kickshifter"), p->kickshifter);
+       cfgfile_write_bool(f, _T("scsidevice_disable"), p->scsidevicedisable);
+       cfgfile_dwrite_bool(f, _T("ks_write_enabled"), p->rom_readwrite);
 
        cfgfile_write (f, _T("floppy_volume"), _T("%d"), p->dfxclickvolume_disk[0]);
        p->nr_floppies = 4;
@@ -5580,10 +5581,11 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
                || cfgfile_coords(option, value, _T("lightpen_offset"), &p->lightpen_offset[0], &p->lightpen_offset[1])
                || cfgfile_yesno(option, value, _T("lightpen_crosshair"), &p->lightpen_crosshair)
 
-               || cfgfile_yesno (option, value, _T("kickshifter"), &p->kickshifter)
-               || cfgfile_yesno (option, value, _T("ks_write_enabled"), &p->rom_readwrite)
-               || cfgfile_yesno (option, value, _T("ntsc"), &p->ntscmode)
-               || cfgfile_yesno (option, value, _T("sana2"), &p->sana2)
+               || cfgfile_yesno(option, value, _T("kickshifter"), &p->kickshifter)
+               || cfgfile_yesno(option, value, _T("scsidevice_disable"), &p->scsidevicedisable)
+               || cfgfile_yesno(option, value, _T("ks_write_enabled"), &p->rom_readwrite)
+               || cfgfile_yesno(option, value, _T("ntsc"), &p->ntscmode)
+               || cfgfile_yesno(option, value, _T("sana2"), &p->sana2)
                || cfgfile_yesno(option, value, _T("genlock"), &p->genlock)
                || cfgfile_yesno(option, value, _T("genlock_alpha"), &p->genlock_alpha)
                || cfgfile_yesno(option, value, _T("genlock_aspect"), &p->genlock_aspect)
@@ -5593,14 +5595,14 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
                || cfgfile_yesno(option, value, _T("cpu_reset_pause"), &p->reset_delay)
                || cfgfile_yesno(option, value, _T("cpu_halt_auto_reset"), &p->crash_auto_reset)
                || cfgfile_yesno(option, value, _T("parallel_on_demand"), &p->parallel_demand)
-               || cfgfile_yesno (option, value, _T("parallel_postscript_emulation"), &p->parallel_postscript_emulation)
-               || cfgfile_yesno (option, value, _T("parallel_postscript_detection"), &p->parallel_postscript_detection)
-               || cfgfile_yesno (option, value, _T("serial_on_demand"), &p->serial_demand)
-               || cfgfile_yesno (option, value, _T("serial_hardware_ctsrts"), &p->serial_hwctsrts)
-               || cfgfile_yesno (option, value, _T("serial_direct"), &p->serial_direct)
-               || cfgfile_yesno (option, value, _T("fpu_strict"), &p->fpu_strict)
-               || cfgfile_yesno (option, value, _T("comp_nf"), &p->compnf)
-               || cfgfile_yesno (option, value, _T("comp_constjump"), &p->comp_constjump)
+               || cfgfile_yesno(option, value, _T("parallel_postscript_emulation"), &p->parallel_postscript_emulation)
+               || cfgfile_yesno(option, value, _T("parallel_postscript_detection"), &p->parallel_postscript_detection)
+               || cfgfile_yesno(option, value, _T("serial_on_demand"), &p->serial_demand)
+               || cfgfile_yesno(option, value, _T("serial_hardware_ctsrts"), &p->serial_hwctsrts)
+               || cfgfile_yesno(option, value, _T("serial_direct"), &p->serial_direct)
+               || cfgfile_yesno(option, value, _T("fpu_strict"), &p->fpu_strict)
+               || cfgfile_yesno(option, value, _T("comp_nf"), &p->compnf)
+               || cfgfile_yesno(option, value, _T("comp_constjump"), &p->comp_constjump)
                || cfgfile_yesno(option, value, _T("comp_catchfault"), &p->comp_catchfault)
 #ifdef USE_JIT_FPU
                || cfgfile_yesno (option, value, _T("compfpu"), &p->compfpu)
index 5b6a6676ffde4072d11e2302fabe83a5b423e88a..a471b7346d793728dcd0611f8d69e55e2dffa350 100644 (file)
@@ -187,6 +187,7 @@ static uaecptr ROM_filesys_putmsg_return;
 static uaecptr ROM_filesys_hack_remove;
 static smp_comm_pipe shellexecute_pipe;
 static uae_u32 segtrack_mode = 0;
+static bool gayle_ide_in_use;
 
 #define FS_STARTUP 0
 #define FS_GO_DOWN 1
@@ -1281,6 +1282,9 @@ static bool add_ide_unit(int type, int unit, struct uaedev_config_info *uci)
                                                write_log(_T("Adding IDE %s '%s' unit %d ('%s')\n"), getunittype(uci),
                                                        ert->name, unit, uci->rootdir);
                                                ert->add(unit, uci, rc);
+                                               if ((ert->romtype & ROMTYPE_MASK) == ROMTYPE_MB_IDE) {
+                                                       gayle_ide_in_use = true;
+                                               }
                                        }
                                        if (cpuboard_hd)
                                                added = true;
@@ -1323,6 +1327,7 @@ static void initialize_mountinfo (void)
 
        cd_unit_offset = MAX_FILESYSTEM_UNITS;
        autocreatedunit = 0;
+       gayle_ide_in_use = false;
 
        for (nr = 0; nr < currprefs.mountitems; nr++) {
                struct uaedev_config_data *uci = &currprefs.mountconfig[nr];
@@ -7563,6 +7568,60 @@ static uaecptr add_resident(TrapContext *ctx, uaecptr resaddr, uaecptr myres)
        return resaddr;
 }
 
+static void kill_ide(TrapContext *ctx)
+{
+       if (!currprefs.scsidevicedisable) {
+               return;
+       }
+       if (gayle_ide_in_use) {
+               return;
+       }
+       if (kickstart_version < 36 || kickstart_version >= 50) {
+               return;
+       }
+       if (trap_is_indirect()) {
+               return;
+       }
+       uaecptr eb = trap_get_areg(ctx, 6);
+       uaecptr rm = trap_get_long(ctx, eb + 300);
+       for(;;) {
+               uaecptr addr = trap_get_long(ctx, rm);
+               if (!addr) {
+                       break;
+               }
+               if (addr & 0x80000000) {
+                       rm = addr & 0x7fffffff;
+                       continue;
+               }
+               if ((addr >= 0x00a80000 && addr < 0x00b80000) || (addr >= 0x00f00000 && addr < 0x01000000)) {
+                       uae_u8 res[22];
+                       if (trap_valid_address(ctx, addr, sizeof(res))) {
+                               trap_get_bytes(ctx, res, addr, sizeof(res));
+                               if (res[0] == 0x4a && res[1] == 0xfc && res[10] == 0x01 && res[11] >= 36 && res[11] < 50 && res[12] == 0x03 && res[13] > 0 && res[13] < 128) {
+                                       static const char sd[] = { "scsi.device" };
+                                       uaecptr name = (res[14] << 24) | (res[15] << 16) | (res[16] << 8) | (res[17] << 0);
+                                       int i;
+                                       for (i = 0; i < strlen(sd) + 1; i++) {
+                                               uae_u8 c = trap_get_byte(ctx, name + i);
+                                               if (c != sd[i] || c == 0) {
+                                                       break;
+                                               }
+                                       }
+                                       if (i == strlen(sd)) {
+                                               uaecptr desc = (res[18] << 24) | (res[19] << 16) | (res[20] << 8) | (res[21] << 0);
+                                               trap_get_bytes(ctx, res, desc, 4);
+                                               if (res[0] != 'S' && res[1] != 'C' && res[2] != 'S' && res[3] != 'I') {
+                                                       write_log(_T("scsi.device resmodules entry disabled\n"));
+                                                       trap_put_long(ctx, rm, 0x80000000 | (rm + 4));
+                                               }
+                                       }
+                               }
+                       }
+               }
+               rm += 4;
+       }
+}
+
 static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *ctx)
 {
        UnitInfo *uip = mountinfo.ui;
@@ -7806,6 +7865,8 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *ctx)
                }
        }
 
+       kill_ide(ctx);
+
        tmp = first_resident;
        while (tmp < last_resident && tmp >= first_resident) {
                if (trap_get_word(ctx, tmp) == 0x4AFC && trap_get_long(ctx, tmp + 0x2) == tmp) {
index c9a9537700971358dc2cf8956054718b3ba5b638..cd93adecc6a441a8c080990f9994ea10342f86b8 100644 (file)
@@ -778,6 +778,7 @@ struct uae_prefs {
        int uaeboard_order;
 
        bool kickshifter;
+       bool scsidevicedisable;
        bool filesys_no_uaefsdb;
        bool filesys_custom_uaefsdb;
        bool mmkeyboard;