From: Toni Wilen Date: Sat, 31 Mar 2018 17:23:42 +0000 (+0300) Subject: CD/HD led correct UAE unit number information. X-Git-Tag: 4000~141 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=a9cf3f987ff7a6ebafb915f6d368b06b36fd8355;p=francis%2Fwinuae.git CD/HD led correct UAE unit number information. --- diff --git a/filesys.cpp b/filesys.cpp index 7898bdb0..adface99 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -831,19 +831,23 @@ static int set_filesys_unit (int nr, struct uaedev_config_info *ci) static int add_filesys_unit (struct uaedev_config_info *ci) { - int ret; + int nr; if (nr_units () >= MAX_FILESYSTEM_UNITS) return -1; - ret = set_filesys_unit_1 (-1, ci); + nr = set_filesys_unit_1 (-1, ci); #ifdef RETROPLATFORM - if (ret >= 0) { - rp_hd_device_enable (ret, true); - rp_harddrive_image_change (ret, ci->readonly, ci->rootdir); + if (nr >= 0) { + UnitInfo *ui = &mountinfo.ui[nr]; + rp_hd_device_enable (nr, true); + if (ui->unit_type == UNIT_CDFS) + rp_cd_image_change(nr, ci->rootdir); + else + rp_harddrive_image_change(nr, ci->readonly, ci->rootdir); } #endif - return ret; + return nr; } int kill_filesys_unitconfig (struct uae_prefs *p, int nr) @@ -1071,6 +1075,7 @@ static void initialize_mountinfo (void) int type = uci->controller_type; int unit = uci->controller_unit; bool added = false; + uci->uae_unitnum = nr; if (type == HD_CONTROLLER_TYPE_UAE) { continue; } else if (type != HD_CONTROLLER_TYPE_IDE_AUTO && type >= HD_CONTROLLER_TYPE_IDE_FIRST && type <= HD_CONTROLLER_TYPE_IDE_LAST) { diff --git a/hardfile.cpp b/hardfile.cpp index c4b52e5d..d75a6a3d 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -534,6 +534,7 @@ int hdf_hd_open (struct hd_hardfiledata *hfd) struct uaedev_config_info *ci = &hfd->hfd.ci; if (hdf_open (&hfd->hfd) <= 0) return 0; + hfd->hfd.unitnum = ci->uae_unitnum; if (ci->physical_geometry) { hfd->cyls = ci->pcyls; hfd->heads = ci->pheads; @@ -2450,7 +2451,7 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *ctx) trap_put_byte(ctx, ioreq + 31, 0); /* io_Error */ trap_put_byte(ctx, ioreq + 8, 7); /* ln_type = NT_REPLYMSG */ if (!hfpd->sd) - hfpd->sd = scsi_alloc_generic(hfd, UAEDEV_DIR); + hfpd->sd = scsi_alloc_generic(hfd, UAEDEV_DIR, unit); hf_log(_T("virtual hardfile_open, unit %d (%d), OK\n"), unit, trap_get_dreg(ctx, 0)); return 0; } @@ -2462,7 +2463,7 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *ctx) trap_put_byte(ctx, ioreq + 31, 0); /* io_Error */ trap_put_byte(ctx, ioreq + 8, 7); /* ln_type = NT_REPLYMSG */ if (!hfpd->sd) - hfpd->sd = scsi_alloc_generic(hfd, UAEDEV_HDF); + hfpd->sd = scsi_alloc_generic(hfd, UAEDEV_HDF, unit); hf_log(_T("hardfile_open, unit %d (%d), OK\n"), unit, trap_get_dreg(ctx, 0)); return 0; } diff --git a/ide.cpp b/ide.cpp index f60a3529..a2b68e8c 100644 --- a/ide.cpp +++ b/ide.cpp @@ -1023,7 +1023,7 @@ static void ide_read_sectors (struct ide_hdf *ide, int flags) return; } check_maxtransfer (ide, 1); - gui_flicker_led (LED_HD, ide->num, 1); + gui_flicker_led (LED_HD, ide->uae_unitnum, 1); nsec = get_nsec (ide); get_lbachs (ide, &lba, &cyl, &head, &sec); if (lba >= ide->max_lba) { @@ -1061,7 +1061,7 @@ static void ide_write_sectors (struct ide_hdf *ide, int flags) return; } check_maxtransfer (ide, 1); - gui_flicker_led (LED_HD, ide->num, 2); + gui_flicker_led (LED_HD, ide->uae_unitnum, 2); nsec = get_nsec (ide); get_lbachs (ide, &lba, &cyl, &head, &sec); if (lba >= ide->max_lba) { @@ -1093,7 +1093,7 @@ static void ide_format_track(struct ide_hdf *ide) unsigned int cyl, head, sec; uae_u64 lba; - gui_flicker_led(LED_HD, ide->num, 2); + gui_flicker_led(LED_HD, ide->uae_unitnum, 2); cyl = (ide->regs.ide_hcyl << 8) | ide->regs.ide_lcyl; head = ide->regs.ide_select & 15; sec = ide->regs.ide_nsector; @@ -1131,7 +1131,7 @@ static void ide_do_command (struct ide_hdf *ide, uae_u8 cmd) if (ide->atapi) { if (ide->scsi->device_type == UAEDEV_CD) { - gui_flicker_led(LED_CD, ide->num, 1); + gui_flicker_led(LED_CD, ide->uae_unitnum, 1); } ide->atapi_drdy = true; if (cmd == 0x00) { /* nop */ @@ -1618,7 +1618,7 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct if (ci->type == UAEDEV_CD && ci->device_emu_unit >= 0) { device_func_init(0); - ide->scsi = scsi_alloc_cd(ch, ci->device_emu_unit, true); + ide->scsi = scsi_alloc_cd(ch, ci->device_emu_unit, true, ci->uae_unitnum); if (!ide->scsi) { write_log(_T("IDE: CD EMU unit %d failed to open\n"), ide->cd_unit_num); return NULL; @@ -1628,13 +1628,14 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct ide->cd_unit_num = ci->device_emu_unit; ide->atapi = true; ide->blocksize = 512; - gui_flicker_led(LED_CD, ch, -1); + ide->uae_unitnum = ci->uae_unitnum; + gui_flicker_led(LED_CD, ci->uae_unitnum, -1); write_log(_T("IDE%d CD %d\n"), ch, ide->cd_unit_num); } else if (ci->type == UAEDEV_TAPE) { - ide->scsi = scsi_alloc_tape(ch, ci->rootdir, ci->readonly); + ide->scsi = scsi_alloc_tape(ch, ci->rootdir, ci->readonly, ci->uae_unitnum); if (!ide->scsi) { write_log(_T("IDE: TAPE EMU unit %d failed to open\n"), ch); return NULL; @@ -1644,6 +1645,7 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct ide->atapi = true; ide->blocksize = 512; ide->cd_unit_num = -1; + ide->uae_unitnum = ci->uae_unitnum; write_log(_T("IDE%d TAPE %d\n"), ch, ide->cd_unit_num); @@ -1658,7 +1660,8 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct ide->max_lba = ide->hdhfd.size / ide->blocksize; ide->lba48 = (ide->hdhfd.hfd.ci.unit_special_flags & 1) || ide->hdhfd.size >= 128 * (uae_u64)0x40000000 ? 1 : 0; ide->lba = true; - gui_flicker_led (LED_HD, ch, -1); + ide->uae_unitnum = ci->uae_unitnum; + gui_flicker_led (LED_HD, ide->uae_unitnum, -1); ide->cd_unit_num = -1; ide->media_type = ci->controller_media_type; ide->ata_level = ci->unit_feature_level; diff --git a/include/ide.h b/include/ide.h index 7d03876e..34aa6ea7 100644 --- a/include/ide.h +++ b/include/ide.h @@ -99,6 +99,7 @@ struct ide_hdf int ide_drv; int media_type; bool mode_8bit; + int uae_unitnum; bool atapi; bool atapi_drdy; diff --git a/include/options.h b/include/options.h index 2cec5639..77fef87d 100644 --- a/include/options.h +++ b/include/options.h @@ -228,6 +228,7 @@ struct uaedev_config_info { bool inject_icons; int badblock_num; struct uaedev_badblock badblocks[MAX_UAEDEV_BADBLOCKS]; + int uae_unitnum; // mountunit nr }; struct uaedev_config_data diff --git a/include/scsi.h b/include/scsi.h index a4b428bf..6279bf5d 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -55,12 +55,13 @@ struct scsi_data int cd_emu_unit; bool atapi; uae_u32 unit_attention; + int uae_unitnum; }; -extern struct scsi_data *scsi_alloc_generic(struct hardfiledata *hfd, int type); -extern struct scsi_data *scsi_alloc_hd(int, struct hd_hardfiledata*); -extern struct scsi_data *scsi_alloc_cd(int, int, bool); -extern struct scsi_data *scsi_alloc_tape(int id, const TCHAR *tape_directory, bool readonly); +extern struct scsi_data *scsi_alloc_generic(struct hardfiledata *hfd, int type, int); +extern struct scsi_data *scsi_alloc_hd(int, struct hd_hardfiledata*, int); +extern struct scsi_data *scsi_alloc_cd(int, int, bool, int); +extern struct scsi_data *scsi_alloc_tape(int id, const TCHAR *tape_directory, bool readonly, int); extern struct scsi_data *scsi_alloc_native(int, int); extern void scsi_free(struct scsi_data*); extern void scsi_reset(void); diff --git a/ncr9x_scsi.cpp b/ncr9x_scsi.cpp index 1362f3ea..0a0f56ba 100644 --- a/ncr9x_scsi.cpp +++ b/ncr9x_scsi.cpp @@ -673,7 +673,7 @@ int32_t scsiesp_req_enqueue(SCSIRequest *req) struct scsi_data *sd = (struct scsi_data*)req->dev->handle; if (sd->device_type == UAEDEV_CD) - gui_flicker_led (LED_CD, sd->id, 1); + gui_flicker_led (LED_CD, sd->uae_unitnum, 1); sd->data_len = 0; scsi_start_transfer(sd); @@ -2210,15 +2210,16 @@ void ncr9x_init(void) { } -static void allocscsidevice(struct ncr9x_state *ncr, int ch, struct scsi_data *handle) +static void allocscsidevice(struct ncr9x_state *ncr, int ch, struct scsi_data *handle, int uae_unitnum) { handle->privdata = ncr; ncr->scsid[ch] = xcalloc (SCSIDevice, 1); ncr->scsid[ch]->id = ch; ncr->scsid[ch]->handle = handle; + handle->uae_unitnum = uae_unitnum; } -static void add_ncr_scsi_hd(struct ncr9x_state *ncr, int ch, struct hd_hardfiledata *hfd, struct uaedev_config_info *ci) +static void add_ncr_scsi_hd(struct ncr9x_state *ncr, int ch, struct hd_hardfiledata *hfd, struct uaedev_config_info *ci, int uae_unitnum) { struct scsi_data *handle = NULL; @@ -2226,11 +2227,11 @@ static void add_ncr_scsi_hd(struct ncr9x_state *ncr, int ch, struct hd_hardfiled ncr->scsid[ch] = NULL; if (!add_scsi_hd(&handle, ch, hfd, ci)) return; - allocscsidevice(ncr, ch, handle); + allocscsidevice(ncr, ch, handle, uae_unitnum); ncr->enabled = true; } -static void add_ncr_scsi_cd(struct ncr9x_state *ncr, int ch, int unitnum) +static void add_ncr_scsi_cd(struct ncr9x_state *ncr, int ch, int unitnum, int uae_unitnum) { struct scsi_data *handle = NULL; @@ -2238,11 +2239,11 @@ static void add_ncr_scsi_cd(struct ncr9x_state *ncr, int ch, int unitnum) ncr->scsid[ch] = NULL; if (!add_scsi_cd(&handle, ch, unitnum)) return; - allocscsidevice(ncr, ch, handle); + allocscsidevice(ncr, ch, handle, uae_unitnum); ncr->enabled = true; } -static void add_ncr_scsi_tape(struct ncr9x_state *ncr, int ch, const TCHAR *tape_directory, bool readonly) +static void add_ncr_scsi_tape(struct ncr9x_state *ncr, int ch, const TCHAR *tape_directory, bool readonly, int uae_unitnum) { struct scsi_data *handle = NULL; @@ -2250,7 +2251,7 @@ static void add_ncr_scsi_tape(struct ncr9x_state *ncr, int ch, const TCHAR *tape ncr->scsid[ch] = NULL; if (!add_scsi_tape(&handle, ch, tape_directory, readonly)) return; - allocscsidevice(ncr, ch, handle); + allocscsidevice(ncr, ch, handle, uae_unitnum); ncr->enabled = true; } @@ -2259,11 +2260,11 @@ static void ncr9x_add_scsi_unit(struct ncr9x_state **ncrp, int ch, struct uaedev struct ncr9x_state *ncr = allocscsi(ncrp, rc, ch); if (ch >= 0 && ncr) { if (ci->type == UAEDEV_CD) - add_ncr_scsi_cd (ncr, ch, ci->device_emu_unit); + add_ncr_scsi_cd (ncr, ch, ci->device_emu_unit, ci->uae_unitnum); else if (ci->type == UAEDEV_TAPE) - add_ncr_scsi_tape (ncr, ch, ci->rootdir, ci->readonly); + add_ncr_scsi_tape (ncr, ch, ci->rootdir, ci->readonly, ci->uae_unitnum); else if (ci->type == UAEDEV_HDF) - add_ncr_scsi_hd (ncr, ch, NULL, ci); + add_ncr_scsi_hd (ncr, ch, NULL, ci, ci->uae_unitnum); } } diff --git a/ncr_scsi.cpp b/ncr_scsi.cpp index bcb08319..5b021c00 100644 --- a/ncr_scsi.cpp +++ b/ncr_scsi.cpp @@ -232,7 +232,7 @@ int32_t scsi_req_enqueue(SCSIRequest *req) struct scsi_data *sd = (struct scsi_data*)req->dev->handle; if (sd->device_type == UAEDEV_CD) - gui_flicker_led (LED_CD, sd->id, 1); + gui_flicker_led (LED_CD, sd->uae_unitnum, 1); sd->data_len = 0; scsi_start_transfer(sd); @@ -326,7 +326,7 @@ int32_t scsi710_req_enqueue(SCSIRequest *req) struct scsi_data *sd = (struct scsi_data*)req->dev->handle; if (sd->device_type == UAEDEV_CD) - gui_flicker_led (LED_CD, sd->id, 1); + gui_flicker_led (LED_CD, sd->uae_unitnum, 1); sd->data_len = 0; scsi_start_transfer (sd); @@ -1045,15 +1045,16 @@ void ncr_reset(void) } } -static void allocscsidevice(struct ncr_state *ncr, int ch, struct scsi_data *handle) +static void allocscsidevice(struct ncr_state *ncr, int ch, struct scsi_data *handle, int uae_unitnum) { handle->privdata = ncr; ncr->scsid[ch] = xcalloc (SCSIDevice, 1); ncr->scsid[ch]->id = ch; ncr->scsid[ch]->handle = handle; + handle->uae_unitnum = uae_unitnum; } -static void add_ncr_scsi_hd (struct ncr_state *ncr, int ch, struct hd_hardfiledata *hfd, struct uaedev_config_info *ci) +static void add_ncr_scsi_hd (struct ncr_state *ncr, int ch, struct hd_hardfiledata *hfd, struct uaedev_config_info *ci, int uae_unitnum) { struct scsi_data *handle = NULL; @@ -1061,11 +1062,11 @@ static void add_ncr_scsi_hd (struct ncr_state *ncr, int ch, struct hd_hardfileda ncr->scsid[ch] = NULL; if (!add_scsi_hd(&handle, ch, hfd, ci)) return; - allocscsidevice(ncr, ch, handle); + allocscsidevice(ncr, ch, handle, uae_unitnum); ncr->enabled = true; } -static void add_ncr_scsi_cd (struct ncr_state *ncr, int ch, int unitnum) +static void add_ncr_scsi_cd (struct ncr_state *ncr, int ch, int unitnum, int uae_unitnum) { struct scsi_data *handle = NULL; @@ -1073,11 +1074,11 @@ static void add_ncr_scsi_cd (struct ncr_state *ncr, int ch, int unitnum) ncr->scsid[ch] = NULL; if (!add_scsi_cd(&handle, ch, unitnum)) return; - allocscsidevice(ncr, ch, handle); + allocscsidevice(ncr, ch, handle, uae_unitnum); ncr->enabled = true; } -static void add_ncr_scsi_tape (struct ncr_state *ncr, int ch, const TCHAR *tape_directory, bool readonly) +static void add_ncr_scsi_tape (struct ncr_state *ncr, int ch, const TCHAR *tape_directory, bool readonly, int uae_unitnum) { struct scsi_data *handle = NULL; @@ -1085,7 +1086,7 @@ static void add_ncr_scsi_tape (struct ncr_state *ncr, int ch, const TCHAR *tape_ ncr->scsid[ch] = NULL; if (!add_scsi_tape(&handle, ch, tape_directory, readonly)) return; - allocscsidevice(ncr, ch, handle); + allocscsidevice(ncr, ch, handle, uae_unitnum); ncr->enabled = true; } @@ -1098,11 +1099,11 @@ static void ncr_add_scsi_unit(struct ncr_state **ncrp, int ch, struct uaedev_con ncr_init_board(ncr); if (ch >= 0 && ncr) { if (ci->type == UAEDEV_CD) - add_ncr_scsi_cd (ncr, ch, ci->device_emu_unit); + add_ncr_scsi_cd (ncr, ch, ci->device_emu_unit, ci->uae_unitnum); else if (ci->type == UAEDEV_TAPE) - add_ncr_scsi_tape (ncr, ch, ci->rootdir, ci->readonly); + add_ncr_scsi_tape (ncr, ch, ci->rootdir, ci->readonly, ci->uae_unitnum); else if (ci->type == UAEDEV_HDF) - add_ncr_scsi_hd (ncr, ch, NULL, ci); + add_ncr_scsi_hd (ncr, ch, NULL, ci, ci->uae_unitnum); } } diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index 9566d81e..12ae40f4 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -1562,7 +1562,7 @@ static bool ishd(int n) } else if (uci->ci.controller_type >= HD_CONTROLLER_TYPE_SCSI_FIRST && uci->ci.controller_type <= HD_CONTROLLER_TYPE_SCSI_LAST) { num = uci->ci.controller_unit; } - return num >= 0; + return num >= 0 && uci->ci.type == UAEDEV_HDF; } void rp_fixup_options (struct uae_prefs *p) @@ -1662,6 +1662,8 @@ void rp_fixup_options (struct uae_prefs *p) for (i = 0; i <= 4; i++) rp_update_leds (i, 0, -1, 0); set_config_changed (); + + write_log(_T("rp_fixup_options end\n")); } static void rp_device_writeprotect (int dev, int num, bool writeprotected) diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 9d0a5c0b..f1198258 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -20926,10 +20926,11 @@ static void gui_flicker_led2 (int led, int unitnum, int status) } #ifdef RETROPLATFORM if (unitnum >= 0) { - if (led == LED_HD) - rp_hd_activity (unitnum, status ? 1 : 0, status == 2 ? 1 : 0); - else if (led == LED_CD) - rp_cd_activity (unitnum, status); + if (led == LED_HD) { + rp_hd_activity(unitnum, status ? 1 : 0, status == 2 ? 1 : 0); + } else if (led == LED_CD) { + rp_cd_activity(unitnum, status); + } } #endif *p = status; diff --git a/scsi.cpp b/scsi.cpp index c783f3ce..d3c4c387 100644 --- a/scsi.cpp +++ b/scsi.cpp @@ -503,7 +503,7 @@ static void allocscsibuf(struct scsi_data *sd) sd->buffer = xcalloc(uae_u8, sd->buffer_size); } -struct scsi_data *scsi_alloc_generic(struct hardfiledata *hfd, int type) +struct scsi_data *scsi_alloc_generic(struct hardfiledata *hfd, int type, int uae_unitnum) { struct scsi_data *sd = xcalloc(struct scsi_data, 1); sd->hfd = hfd; @@ -512,11 +512,12 @@ struct scsi_data *scsi_alloc_generic(struct hardfiledata *hfd, int type) sd->cd_emu_unit = -1; sd->blocksize = hfd->ci.blocksize; sd->device_type = type; + sd->uae_unitnum = uae_unitnum; allocscsibuf(sd); return sd; } -struct scsi_data *scsi_alloc_hd(int id, struct hd_hardfiledata *hfd) +struct scsi_data *scsi_alloc_hd(int id, struct hd_hardfiledata *hfd, int uae_unitnum) { struct scsi_data *sd = xcalloc (struct scsi_data, 1); sd->hdhfd = hfd; @@ -526,11 +527,12 @@ struct scsi_data *scsi_alloc_hd(int id, struct hd_hardfiledata *hfd) sd->cd_emu_unit = -1; sd->blocksize = hfd->hfd.ci.blocksize; sd->device_type = UAEDEV_HDF; + sd->uae_unitnum = uae_unitnum; allocscsibuf(sd); return sd; } -struct scsi_data *scsi_alloc_cd(int id, int unitnum, bool atapi) +struct scsi_data *scsi_alloc_cd(int id, int unitnum, bool atapi, int uae_unitnum) { struct scsi_data *sd; if (!sys_command_open (unitnum)) { @@ -544,11 +546,12 @@ struct scsi_data *scsi_alloc_cd(int id, int unitnum, bool atapi) sd->atapi = atapi; sd->blocksize = 2048; sd->device_type = UAEDEV_CD; + sd->uae_unitnum = uae_unitnum; allocscsibuf(sd); return sd; } -struct scsi_data *scsi_alloc_tape(int id, const TCHAR *tape_directory, bool readonly) +struct scsi_data *scsi_alloc_tape(int id, const TCHAR *tape_directory, bool readonly, int uae_unitnum) { struct scsi_data_tape *tape; tape = tape_alloc (id, tape_directory, readonly); @@ -561,6 +564,7 @@ struct scsi_data *scsi_alloc_tape(int id, const TCHAR *tape_directory, bool read sd->blocksize = tape->blocksize; sd->tape = tape; sd->device_type = UAEDEV_TAPE; + sd->uae_unitnum = uae_unitnum; allocscsibuf(sd); return sd; } @@ -670,7 +674,7 @@ int add_scsi_hd (struct scsi_data **sd, int ch, struct hd_hardfiledata *hfd, str if (!hdf_hd_open (hfd)) return 0; hfd->ansi_version = ci->unit_feature_level + 1; - *sd = scsi_alloc_hd (ch, hfd); + *sd = scsi_alloc_hd (ch, hfd, ci->uae_unitnum); return *sd ? 1 : 0; } @@ -678,14 +682,14 @@ int add_scsi_cd (struct scsi_data **sd, int ch, int unitnum) { device_func_init (0); free_scsi (*sd); - *sd = scsi_alloc_cd (ch, unitnum, false); + *sd = scsi_alloc_cd (ch, unitnum, false, unitnum); return *sd ? 1 : 0; } int add_scsi_tape (struct scsi_data **sd, int ch, const TCHAR *tape_directory, bool readonly) { free_scsi (*sd); - *sd = scsi_alloc_tape (ch, tape_directory, readonly); + *sd = scsi_alloc_tape (ch, tape_directory, readonly, ch); return *sd ? 1 : 0; }