2017-09-30 16:56:38 -04:00
|
|
|
/*
|
|
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the 86Box distribution.
|
|
|
|
|
*
|
|
|
|
|
* Common code to handle all sorts of hard disk images.
|
|
|
|
|
*
|
2020-03-25 00:46:02 +02:00
|
|
|
*
|
2017-09-30 16:56:38 -04:00
|
|
|
*
|
|
|
|
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
|
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
2017-10-08 19:14:46 -04:00
|
|
|
*
|
2019-09-26 10:02:43 +02:00
|
|
|
* Copyright 2016-2019 Miran Grca.
|
|
|
|
|
* Copyright 2017-2019 Fred N. van Kempen.
|
2017-09-30 16:56:38 -04:00
|
|
|
*/
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <wchar.h>
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/86box.h>
|
|
|
|
|
#include <86box/plat.h>
|
|
|
|
|
#include <86box/ui.h>
|
|
|
|
|
#include <86box/hdd.h>
|
|
|
|
|
#include <86box/cdrom.h>
|
2017-03-15 01:37:09 +01:00
|
|
|
|
2017-08-24 01:14:39 -04:00
|
|
|
|
2017-09-30 16:56:38 -04:00
|
|
|
hard_disk_t hdd[HDD_NUM];
|
2017-10-01 16:29:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
hdd_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* Clear all global data. */
|
|
|
|
|
memset(hdd, 0x00, sizeof(hdd));
|
|
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
hdd_string_to_bus(char *str, int cdrom)
|
|
|
|
|
{
|
|
|
|
|
if (! strcmp(str, "none"))
|
|
|
|
|
return(HDD_BUS_DISABLED);
|
|
|
|
|
|
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
|
|
|
if (! strcmp(str, "mfm") || ! strcmp(str, "rll")) {
|
2017-10-07 00:46:54 -04:00
|
|
|
if (cdrom) {
|
|
|
|
|
no_cdrom:
|
2020-06-18 21:23:34 -03:00
|
|
|
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2130, (wchar_t *) IDS_4099);
|
2017-10-07 00:46:54 -04:00
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(HDD_BUS_MFM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: delete 'rll' in a year or so.. --FvK */
|
|
|
|
|
if (!strcmp(str, "esdi") || !strcmp(str, "rll")) {
|
|
|
|
|
if (cdrom) goto no_cdrom;
|
|
|
|
|
|
|
|
|
|
return(HDD_BUS_ESDI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! strcmp(str, "ide_pio_only"))
|
2018-04-25 23:51:13 +02:00
|
|
|
return(HDD_BUS_IDE);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "ide"))
|
2018-04-25 23:51:13 +02:00
|
|
|
return(HDD_BUS_IDE);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "atapi_pio_only"))
|
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
|
|
|
return(HDD_BUS_ATAPI);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "atapi"))
|
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
|
|
|
return(HDD_BUS_ATAPI);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "eide"))
|
2018-04-25 23:51:13 +02:00
|
|
|
return(HDD_BUS_IDE);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
2018-04-25 23:51:13 +02:00
|
|
|
if (! strcmp(str, "xta"))
|
|
|
|
|
return(HDD_BUS_XTA);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "atide"))
|
2018-04-25 23:51:13 +02:00
|
|
|
return(HDD_BUS_IDE);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "ide_pio_and_dma"))
|
2018-04-25 23:51:13 +02:00
|
|
|
return(HDD_BUS_IDE);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "atapi_pio_and_dma"))
|
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
|
|
|
return(HDD_BUS_ATAPI);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
if (! strcmp(str, "scsi"))
|
|
|
|
|
return(HDD_BUS_SCSI);
|
|
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
hdd_bus_to_string(int bus, int cdrom)
|
|
|
|
|
{
|
|
|
|
|
char *s = "none";
|
|
|
|
|
|
|
|
|
|
switch (bus) {
|
|
|
|
|
case HDD_BUS_DISABLED:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HDD_BUS_MFM:
|
|
|
|
|
s = "mfm";
|
|
|
|
|
break;
|
|
|
|
|
|
2018-04-25 23:51:13 +02:00
|
|
|
case HDD_BUS_XTA:
|
|
|
|
|
s = "xta";
|
2017-10-07 00:46:54 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HDD_BUS_ESDI:
|
|
|
|
|
s = "esdi";
|
|
|
|
|
break;
|
|
|
|
|
|
2018-04-25 23:51:13 +02:00
|
|
|
case HDD_BUS_IDE:
|
PIC rewrite, proper SMRAM API, complete SiS 471 rewrite and addition of 40x, 460, and 461, changes to mem.c/h, disabled Voodoo memory dumping on exit, bumped SDL Hardware scale quality to 2, bumped IDE/ATAPI drives to ATA-6, finally bumped emulator version to 3.0, redid the bus type ID's to allow for planned ATAPI hard disks, made SST flash set its high mappings to the correct address if the CPU is 16-bit, and added the SiS 401 AMI 486 Clone, AOpen Vi15G, and the Soyo 4SA2 (486 with SiS 496/497 that can boot from CD-ROM), assorted 286+ protected mode fixes (for slightly more accuracy), and fixes to 808x emulation (MS Word 1.0 and 1.10 for DOS now work correctly from floppy).
2020-10-14 23:15:01 +02:00
|
|
|
s = "ide";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HDD_BUS_ATAPI:
|
|
|
|
|
s = "atapi";
|
2017-10-07 00:46:54 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HDD_BUS_SCSI:
|
|
|
|
|
s = "scsi";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
hdd_is_valid(int c)
|
|
|
|
|
{
|
2018-04-25 23:51:13 +02:00
|
|
|
if (hdd[c].bus == HDD_BUS_DISABLED)
|
|
|
|
|
return(0);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
2021-03-14 20:35:01 +01:00
|
|
|
if (strlen(hdd[c].fn) == 0)
|
2018-04-25 23:51:13 +02:00
|
|
|
return(0);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
2018-04-25 23:51:13 +02:00
|
|
|
if ((hdd[c].tracks==0) || (hdd[c].hpc==0) || (hdd[c].spt==0))
|
|
|
|
|
return(0);
|
2017-10-07 00:46:54 -04:00
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
|
}
|