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 disk controllers.
|
|
|
|
|
*
|
2017-10-07 00:46:54 -04:00
|
|
|
* Version: @(#)hdc.c 1.0.3 2017/10/04
|
2017-09-30 16:56:38 -04:00
|
|
|
*
|
|
|
|
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
|
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
|
|
|
|
* Copyright 2016,2017 Miran Grca.
|
|
|
|
|
* Copyright 2017 Fred N. van Kempen.
|
|
|
|
|
*/
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
#include "../ibm.h"
|
|
|
|
|
#include "../cpu/cpu.h"
|
|
|
|
|
#include "../device.h"
|
|
|
|
|
#include "../machine/machine.h"
|
|
|
|
|
#include "hdc.h"
|
|
|
|
|
|
|
|
|
|
|
2017-10-02 02:15:35 -04:00
|
|
|
char hdc_name[16]; /* configured HDC name */
|
|
|
|
|
int hdc_current;
|
2017-09-30 16:56:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
2017-10-07 00:46:54 -04:00
|
|
|
null_init(device_t *info)
|
2017-09-30 16:56:38 -04:00
|
|
|
{
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
null_close(void *priv)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static device_t null_device = {
|
2017-10-07 00:46:54 -04:00
|
|
|
"Null HDC", 0, 0,
|
|
|
|
|
null_init, null_close, NULL,
|
2017-09-30 16:56:38 -04:00
|
|
|
NULL, NULL, NULL, NULL, NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2017-10-01 16:29:15 -04:00
|
|
|
static void *
|
2017-10-07 00:46:54 -04:00
|
|
|
inthdc_init(device_t *info)
|
2017-10-01 16:29:15 -04:00
|
|
|
{
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
inthdc_close(void *priv)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static device_t inthdc_device = {
|
2017-10-07 00:46:54 -04:00
|
|
|
"Internal Controller", 0, 0,
|
|
|
|
|
inthdc_init, inthdc_close, NULL,
|
2017-10-01 16:29:15 -04:00
|
|
|
NULL, NULL, NULL, NULL, NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2017-09-30 16:56:38 -04:00
|
|
|
static struct {
|
|
|
|
|
char name[50];
|
|
|
|
|
char internal_name[16];
|
|
|
|
|
device_t *device;
|
|
|
|
|
int is_mfm;
|
|
|
|
|
} controllers[] = {
|
|
|
|
|
{ "None", "none",
|
|
|
|
|
&null_device, 0 },
|
|
|
|
|
|
|
|
|
|
{ "Internal Controller", "internal",
|
2017-10-01 16:29:15 -04:00
|
|
|
&inthdc_device, 0 },
|
2017-09-30 16:56:38 -04:00
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [MFM] IBM PC Fixed Disk Adapter", "mfm_xebec",
|
2017-09-30 16:56:38 -04:00
|
|
|
&mfm_xt_xebec_device, 1 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [MFM] DTC-5150X Fixed Disk Adapter", "mfm_dtc5150x",
|
2017-09-30 16:56:38 -04:00
|
|
|
&mfm_xt_dtc5150x_device, 1 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [MFM] IBM PC/AT Fixed Disk Adapter", "mfm_at",
|
2017-09-30 16:56:38 -04:00
|
|
|
&mfm_at_wd1003_device, 1 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [ESDI] PC/AT ESDI Fixed Disk Adapter", "esdi_wd1007vse1",
|
2017-09-30 16:56:38 -04:00
|
|
|
&esdi_at_wd1007vse1_device, 0 },
|
|
|
|
|
|
2017-10-01 16:29:15 -04:00
|
|
|
#if 0
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [IDE] PC/AT IDE Adapter", "ide_isa",
|
2017-10-01 16:29:15 -04:00
|
|
|
&ide_isa_device, 0 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[PCI] [IDE] PCI IDE Adapter", "ide_pci",
|
2017-10-01 16:29:15 -04:00
|
|
|
&ide_pci_device, 0 },
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [IDE] PC/XT XTIDE", "xtide",
|
2017-09-30 16:56:38 -04:00
|
|
|
&xtide_device , 0 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [IDE] PC/AT XTIDE", "xtide_at",
|
2017-09-30 16:56:38 -04:00
|
|
|
&xtide_at_device, 0 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [IDE] PS/2 XTIDE (Acculogic)", "xtide_ps2",
|
2017-09-30 16:56:38 -04:00
|
|
|
&xtide_ps2_device, 0 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[ISA] [IDE] PS/2 AT XTIDE (1.1.5)", "xtide_at_ps2",
|
2017-09-30 16:56:38 -04:00
|
|
|
&xtide_at_ps2_device, 0 },
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
{ "[MCA] [ESDI] IBM PS/2 ESDI Fixed Disk Adapter","esdi_mca",
|
|
|
|
|
&esdi_ps2_device, 1 },
|
|
|
|
|
|
2017-09-30 16:56:38 -04:00
|
|
|
{ "", "", NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2017-10-02 02:15:35 -04:00
|
|
|
/* Initialize the 'hdc_current' value based on configured HDC name. */
|
|
|
|
|
void
|
|
|
|
|
hdc_init(char *name)
|
|
|
|
|
{
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
pclog("HDC: initializing..\n");
|
|
|
|
|
|
|
|
|
|
for (c=0; controllers[c].device; c++) {
|
|
|
|
|
if (! strcmp(name, controllers[c].internal_name)) {
|
|
|
|
|
hdc_current = c;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Reset the HDC, whichever one that is. */
|
|
|
|
|
void
|
|
|
|
|
hdc_reset(void)
|
|
|
|
|
{
|
|
|
|
|
pclog("HDC: reset(current=%d, internal=%d)\n",
|
|
|
|
|
hdc_current, (machines[machine].flags & MACHINE_HAS_HDC)?1:0);
|
|
|
|
|
|
|
|
|
|
/* If we have a valid controller, add its device. */
|
|
|
|
|
if (hdc_current > 1)
|
|
|
|
|
device_add(controllers[hdc_current].device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-09-30 16:56:38 -04:00
|
|
|
char *
|
|
|
|
|
hdc_get_name(int hdc)
|
|
|
|
|
{
|
|
|
|
|
return(controllers[hdc].name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
hdc_get_internal_name(int hdc)
|
|
|
|
|
{
|
|
|
|
|
return(controllers[hdc].internal_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-10-10 00:14:15 +02:00
|
|
|
device_t *
|
|
|
|
|
hdc_get_device(int hdc)
|
|
|
|
|
{
|
|
|
|
|
return(controllers[hdc].device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-09-30 16:56:38 -04:00
|
|
|
int
|
|
|
|
|
hdc_get_flags(int hdc)
|
|
|
|
|
{
|
|
|
|
|
return(controllers[hdc].device->flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
hdc_available(int hdc)
|
|
|
|
|
{
|
|
|
|
|
return(device_available(controllers[hdc].device));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
hdc_current_is_mfm(void)
|
|
|
|
|
{
|
|
|
|
|
return(controllers[hdc_current].is_mfm);
|
|
|
|
|
}
|