Merge pull request #4604 from jriwanek-forks/hdcfdc

FDC improvements, some bug fixes & cleanups
This commit is contained in:
Miran Grča
2024-07-08 20:37:24 +02:00
committed by GitHub
14 changed files with 116 additions and 89 deletions

View File

@@ -433,8 +433,11 @@ load_video(void)
free_p = 1;
}
gfxcard[0] = video_get_video_from_internal_name(p);
if (free_p)
if (free_p) {
free(p);
p = NULL;
free_p = 0;
}
}
if (((gfxcard[0] == VID_INTERNAL) && machine_has_flags(machine, MACHINE_VIDEO_8514A)) ||
@@ -792,10 +795,31 @@ load_storage_controllers(void)
}
p = ini_section_get_string(cat, "fdc", NULL);
#if 1
if (p != NULL)
fdc_type = fdc_card_get_from_internal_name(p);
else
fdc_type = FDC_INTERNAL;
#else
if (p == NULL) {
if (machine_has_flags(machine, MACHINE_FDC)) {
p = (char *) malloc((strlen("internal") + 1) * sizeof(char));
strcpy(p, "internal");
} else {
p = (char *) malloc((strlen("none") + 1) * sizeof(char));
strcpy(p, "none");
}
free_p = 1;
}
fdc_type = fdc_card_get_from_internal_name(p);
if (free_p) {
free(p);
p = NULL;
free_p = 0;
}
#endif
p = ini_section_get_string(cat, "hdc", NULL);
if (p == NULL) {
@@ -832,6 +856,7 @@ load_storage_controllers(void)
if (free_p) {
free(p);
p = NULL;
free_p = 0;
}
ide_ter_enabled = !!ini_section_get_int(cat, "ide_ter", 0);

View File

@@ -132,7 +132,7 @@ hdc_reset(void)
hdc_current, (machines[machine].flags & MACHINE_HDC) ? 1 : 0);
/* If we have a valid controller, add its device. */
if (hdc_current > 1)
if (hdc_current > HDC_INTERNAL)
device_add(controllers[hdc_current].device);
/* Now, add the tertiary and/or quaternary IDE controllers. */

View File

@@ -97,7 +97,6 @@ fdc_log(const char *fmt, ...)
# define fdc_log(fmt, ...)
#endif
#if 0
const device_t fdc_none_device = {
.name = "None",
.internal_name = "none",
@@ -111,7 +110,6 @@ const device_t fdc_none_device = {
.force_redraw = NULL,
.config = NULL
};
#endif
const device_t fdc_internal_device = {
.name = "Internal",
@@ -133,10 +131,10 @@ typedef const struct {
static fdc_cards_t fdc_cards[] = {
// clang-format off
#if 0
{ &fdc_none_device },
#endif
{ &fdc_internal_device },
{ &fdc_xt_device },
{ &fdc_at_device },
{ &fdc_b215_device },
{ &fdc_pii151b_device },
{ &fdc_pii158b_device },
@@ -192,8 +190,8 @@ fdc_card_get_from_internal_name(char *s)
void
fdc_card_init(void)
{
if ((fdc_type > 0) && fdc_cards[fdc_type].device)
device_add(fdc_cards[fdc_type].device);
if ((fdc_type > FDC_INTERNAL) && fdc_cards[fdc_type].device)
device_add_inst(fdc_cards[fdc_type].device, 0);
}
uint8_t

View File

@@ -114,6 +114,7 @@ typedef struct config_t {
/* Other peripherals category */
int fdc_type; /* Floppy disk controller type */
int hdc_current; /* Hard disk controller type */
int hdc; /* Hard disk controller */
int scsi_card; /* SCSI controller */
int ide_ter_enabled; /* Tertiary IDE controller enabled */

View File

@@ -40,24 +40,23 @@ extern int fdc_type;
#define FDC_QUATERNARY_IRQ 6
#define FDC_QUATERNARY_DMA 2
#define FDC_FLAG_PCJR 0x01 /* PCjr */
#define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */
#define FDC_FLAG_AT 0x04 /* AT+, PS/x */
#define FDC_FLAG_PS1 0x08 /* PS/1, PS/2 ISA */
#define FDC_FLAG_SUPERIO 0x10 /* Super I/O chips */
#define FDC_FLAG_START_RWC_1 0x20 /* W83877F, W83977F */
#define FDC_FLAG_MORE_TRACKS 0x40 /* W83877F, W83977F, PC87306, PC87309 */
#define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */
#define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */
#define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */
#define FDC_FLAG_UMC 0x400 /* UMC UM8398 */
#define FDC_FLAG_ALI 0x800 /* ALi M512x / M1543C */
#define FDC_FLAG_SEC 0x1000 /* Is Secondary */
#define FDC_FLAG_TER 0x2000 /* Is Tertiary */
#define FDC_FLAG_QUA 0x3000 /* Is Quaternary */
#define FDC_FLAG_CHANNEL 0x3000 /* Channel mask */
#define FDC_FLAG_NO_DSR_RESET 0x4000 /* Has no DSR reset */
#define FDC_FLAG_NEC 0x8000 /* Is NEC upd765-compatible */
#define FDC_FLAG_PCJR 0x01 /* PCjr */
#define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */
#define FDC_FLAG_AT 0x04 /* AT+, PS/x */
#define FDC_FLAG_PS1 0x08 /* PS/1, PS/2 ISA */
#define FDC_FLAG_SUPERIO 0x10 /* Super I/O chips */
#define FDC_FLAG_START_RWC_1 0x20 /* W83877F, W83977F */
#define FDC_FLAG_MORE_TRACKS 0x40 /* W83877F, W83977F, PC87306, PC87309 */
#define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */
#define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */
#define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */
#define FDC_FLAG_UMC 0x400 /* UMC UM8398 */
#define FDC_FLAG_ALI 0x800 /* ALi M512x / M1543C */
#define FDC_FLAG_NO_DSR_RESET 0x1000 /* Has no DSR reset */
#define FDC_FLAG_NEC 0x2000 /* Is NEC upd765-compatible */
#define FDC_FLAG_SEC 0x10000 /* Is Secondary */
#define FDC_FLAG_TER 0x20000 /* Is Tertiary */
#define FDC_FLAG_QUA 0x40000 /* Is Quaternary */
typedef struct fdc_t {
uint8_t dor;

View File

@@ -25,7 +25,8 @@
extern int fdc_type;
/* Controller types. */
#define FDC_INTERNAL 0
#define FDC_NONE 0
#define FDC_INTERNAL 1
extern const device_t fdc_b215_device;
extern const device_t fdc_pii151b_device;

View File

@@ -798,7 +798,7 @@ machine_at_compaq_init(const machine_t *model, int type)
break;
case COMPAQ_PORTABLEIII:
if (hdc_current == 1)
if (hdc_current == HDC_INTERNAL)
device_add(&ide_isa_device);
if (gfxcard[0] == VID_INTERNAL)
device_add(&compaq_plasma_device);
@@ -806,7 +806,7 @@ machine_at_compaq_init(const machine_t *model, int type)
break;
case COMPAQ_PORTABLEIII386:
if (hdc_current == 1)
if (hdc_current == HDC_INTERNAL)
device_add(&ide_isa_device);
if (gfxcard[0] == VID_INTERNAL)
device_add(&compaq_plasma_device);

View File

@@ -660,7 +660,7 @@ europc_boot(UNUSED(const device_t *info))
*
* We only do this if we have not configured another one.
*/
if (hdc_current == 1)
if (hdc_current == HDC_INTERNAL)
(void) device_add(&xta_hd20_device);
return sys;

View File

@@ -353,7 +353,7 @@ ps1_setup(int model)
device_add(&fdc_at_ps1_device);
/* Enable the builtin HDC. */
if (hdc_current == 1) {
if (hdc_current == HDC_INTERNAL) {
priv = device_add(&ps1_hdc_device);
ps1_hdc_inform(priv, &ps->ps1_91);

View File

@@ -179,7 +179,7 @@ ps2_isa_setup(int model, int cpu_type)
device_add(&fdc_at_ps1_device);
/* Enable the builtin HDC. */
if (hdc_current == 1) {
if (hdc_current == HDC_INTERNAL) {
priv = device_add(&ps1_hdc_device);
ps1_hdc_inform(priv, &ps2->ps2_91);
}

View File

@@ -94,7 +94,7 @@ machine_v86p_init(const machine_t *model)
if (gfxcard[0] == VID_INTERNAL)
device_add(&f82c425_video_device);
if (hdc_current <= 1)
if (hdc_current <= HDC_INTERNAL)
device_add(&st506_xt_victor_v86p_device);
return ret;

View File

@@ -23,15 +23,15 @@
extern const device_t vendex_xt_rtc_onboard_device;
static void
machine_xt_common_init(const machine_t *model)
machine_xt_common_init(const machine_t *model, int fixed_floppy)
{
if ((fdc_type == FDC_INTERNAL) || fixed_floppy)
device_add(&fdc_xt_device);
machine_common_init(model);
pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt);
if (fdc_type == FDC_INTERNAL)
device_add(&fdc_xt_device);
nmi_init();
standalone_gameport_type = &gameport_device;
}
@@ -59,7 +59,7 @@ machine_pc_init(const machine_t *model)
device_add(&keyboard_pc_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -93,19 +93,11 @@ machine_pc82_init(const machine_t *model)
device_add(&keyboard_pc82_device);
device_add(&ibm_5161_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
static void
machine_xt_init_ex(const machine_t *model)
{
device_add(&keyboard_xt_device);
machine_xt_common_init(model);
}
int
machine_xt_init(const machine_t *model)
{
@@ -127,10 +119,12 @@ machine_xt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_init_ex(model);
device_add(&keyboard_xt_device);
device_add(&ibm_5161_device);
machine_xt_common_init(model, 0);
return ret;
}
@@ -145,7 +139,9 @@ machine_genxt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_init_ex(model);
device_add(&keyboard_xt_device);
machine_xt_common_init(model, 0);
return ret;
}
@@ -170,17 +166,17 @@ machine_xt86_init(const machine_t *model)
device_add(&keyboard_xt86_device);
device_add(&ibm_5161_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
static void
machine_xt_clone_init(const machine_t *model)
machine_xt_clone_init(const machine_t *model, int fixed_floppy)
{
device_add(&keyboard_xtclone_device);
machine_xt_common_init(model);
machine_xt_common_init(model, fixed_floppy);
}
int
@@ -194,7 +190,7 @@ machine_xt_americxt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -210,7 +206,7 @@ machine_xt_amixt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -226,7 +222,7 @@ machine_xt_znic_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -242,7 +238,7 @@ machine_xt_dtk_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -258,7 +254,7 @@ machine_xt_jukopc_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -274,7 +270,7 @@ machine_xt_openxt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -294,7 +290,7 @@ machine_xt_pcxt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -312,7 +308,7 @@ machine_xt_pxxt_init(const machine_t *model)
device_add(&keyboard_xt_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -329,7 +325,7 @@ machine_xt_iskra3104_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -363,7 +359,7 @@ machine_xt_pravetz16_imko4_init(const machine_t *model)
device_add(&keyboard_pravetz_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -379,7 +375,10 @@ machine_xt_micoms_xl7turbo_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_init_ex(model);
device_add(&keyboard_xt_device);
machine_xt_common_init(model, 0);
return ret;
}
@@ -394,7 +393,7 @@ machine_xt_pc4i_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -412,7 +411,7 @@ machine_xt_mpc1600_init(const machine_t *model)
device_add(&keyboard_pc82_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -435,7 +434,7 @@ machine_xt_pcspirit_init(const machine_t *model)
device_add(&keyboard_pc82_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -453,7 +452,7 @@ machine_xt_pc700_init(const machine_t *model)
device_add(&keyboard_pc_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -471,7 +470,7 @@ machine_xt_pc500_init(const machine_t *model)
device_add(&keyboard_pc_device);
machine_xt_common_init(model);
machine_xt_common_init(model, 0);
return ret;
}
@@ -487,18 +486,20 @@ machine_xt_vendex_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
/* On-board FDC cannot be disabled */
machine_xt_clone_init(model, 1);
device_add(&vendex_xt_rtc_onboard_device);
return ret;
}
static void
machine_xt_hyundai_common_init(const machine_t *model)
machine_xt_hyundai_common_init(const machine_t *model, int fixed_floppy)
{
device_add(&keyboard_xt_hyundai_device);
machine_xt_common_init(model);
machine_xt_common_init(model, fixed_floppy);
}
int
@@ -512,10 +513,8 @@ machine_xt_super16t_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_hyundai_common_init(model);
/* On-board FDC cannot be disabled */
device_add(&fdc_xt_device);
machine_xt_hyundai_common_init(model, 1);
return ret;
}
@@ -531,10 +530,8 @@ machine_xt_super16te_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_hyundai_common_init(model);
/* On-board FDC cannot be disabled */
device_add(&fdc_xt_device);
machine_xt_hyundai_common_init(model, 1);
return ret;
}
@@ -550,10 +547,8 @@ machine_xt_top88_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
/* On-board FDC cannot be disabled */
device_add(&fdc_xt_device);
machine_xt_clone_init(model, 1);
return ret;
}
@@ -569,7 +564,7 @@ machine_xt_kaypropc_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -585,10 +580,8 @@ machine_xt_sansx16_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
/* On-board FDC cannot be disabled */
device_add(&fdc_xt_device);
machine_xt_clone_init(model, 1);
return ret;
}
@@ -604,7 +597,7 @@ machine_xt_bw230_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -620,7 +613,7 @@ machine_xt_v20xt_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -636,7 +629,7 @@ machine_xt_pb8810_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_clone_init(model);
machine_xt_clone_init(model, 0);
return ret;
}
@@ -652,7 +645,9 @@ machine_xt_glabios_init(const machine_t *model)
if (bios_only || !ret)
return ret;
machine_xt_init_ex(model);
device_add(&keyboard_xt_device);
machine_xt_common_init(model, 0);
return ret;
}

View File

@@ -969,7 +969,7 @@ machine_xt_t1200_init(const machine_t *model)
if (gfxcard[0] == VID_INTERNAL)
device_add(&t1200_video_device);
if (hdc_current <= 1)
if (hdc_current <= HDC_INTERNAL)
device_add(&st506_xt_toshiba_t1200_device);
return ret;

View File

@@ -110,6 +110,14 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
c = 0;
selectedRow = 0;
while (true) {
#if 0
/* Skip "internal" if machine doesn't have it. */
if ((c == 1) && (machine_has_flags(machineId, MACHINE_FDC) == 0)) {
c++;
continue;
}
#endif
QString name = DeviceConfig::DeviceName(fdc_card_getdevice(c), fdc_card_get_internal_name(c), 1);
if (name.isEmpty()) {
break;