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)
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) {
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;
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;
}
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;
}
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) {
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) {
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;
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 */
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;
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;
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);
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;
int ide_drv;
int media_type;
bool mode_8bit;
+ int uae_unitnum;
bool atapi;
bool atapi_drdy;
bool inject_icons;
int badblock_num;
struct uaedev_badblock badblocks[MAX_UAEDEV_BADBLOCKS];
+ int uae_unitnum; // mountunit nr
};
struct uaedev_config_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);
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);
{
}
-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;
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;
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;
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;
}
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);
}
}
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);
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);
}
}
-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;
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;
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;
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;
}
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);
}
}
} 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)
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)
}
#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;
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;
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;
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)) {
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);
sd->blocksize = tape->blocksize;
sd->tape = tape;
sd->device_type = UAEDEV_TAPE;
+ sd->uae_unitnum = uae_unitnum;
allocscsibuf(sd);
return sd;
}
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;
}
{
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;
}