Separation of HDD (disks) and HDC (disk controllers) with major cleanup. IDE remains same until Kotori finishes that part.

This commit is contained in:
waltje
2017-09-30 16:56:38 -04:00
parent c62e0b923c
commit 9d9f5fdd58
44 changed files with 3098 additions and 2843 deletions

View File

@@ -1,3 +1,20 @@
/*
* 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.
*
* Version: @(#)hdd.c 1.0.1 2017/09/29
*
* 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>
@@ -7,107 +24,6 @@
#include "../device.h"
#include "../machine/machine.h"
#include "hdd.h"
#include "hdd_esdi_at.h"
#include "hdd_esdi_mca.h"
#include "hdd_mfm_at.h"
#include "hdd_mfm_xebec.h"
#include "hdd_ide_xt.h"
char hdd_controller_name[16];
hard_disk_t hdc[HDC_NUM];
static device_t null_hdd_device;
static int hdd_controller_current;
static struct
{
char name[50];
char internal_name[16];
device_t *device;
int is_mfm;
} hdd_controllers[] =
{
{"None", "none", &null_hdd_device, 0},
{"[MFM] AT Fixed Disk Adapter", "mfm_at", &mfm_at_device, 1},
{"[MFM] DTC 5150X", "dtc5150x", &dtc_5150x_device, 1},
{"[MFM] Fixed Disk Adapter (Xebec)", "mfm_xebec", &mfm_xebec_device, 1},
{"[ESDI] IBM ESDI Fixed Disk Adapter", "esdi_mca", &hdd_esdi_device, 1},
{"[ESDI] Western Digital WD1007V-SE1", "wd1007vse1", &wd1007vse1_device, 0},
{"[IDE] XTIDE", "xtide", &xtide_device, 0},
{"[IDE] XTIDE (Acculogic)", "xtide_ps2", &xtide_ps2_device, 0},
{"[IDE] XTIDE (AT)", "xtide_at", &xtide_at_device, 0},
{"[IDE] XTIDE (AT) (1.1.5)", "xtide_at_ps2", &xtide_at_ps2_device, 0},
{"", "", NULL, 0}
};
char *hdd_controller_get_name(int hdd)
{
return hdd_controllers[hdd].name;
}
char *hdd_controller_get_internal_name(int hdd)
{
return hdd_controllers[hdd].internal_name;
}
int hdd_controller_get_flags(int hdd)
{
return hdd_controllers[hdd].device->flags;
}
int hdd_controller_available(int hdd)
{
return device_available(hdd_controllers[hdd].device);
}
int hdd_controller_current_is_mfm()
{
return hdd_controllers[hdd_controller_current].is_mfm;
}
void hdd_controller_init(char *internal_name)
{
int c = 0;
if (machines[machine].flags & MACHINE_HAS_IDE)
{
return;
}
while (hdd_controllers[c].device)
{
if (!strcmp(internal_name, hdd_controllers[c].internal_name))
{
hdd_controller_current = c;
if (strcmp(internal_name, "none"))
device_add(hdd_controllers[c].device);
return;
}
c++;
}
}
static void *null_hdd_init()
{
return NULL;
}
static void null_hdd_close(void *p)
{
}
static device_t null_hdd_device =
{
"Null HDD controller",
0,
null_hdd_init,
null_hdd_close,
NULL,
NULL,
NULL,
NULL,
NULL
};
hard_disk_t hdd[HDD_NUM];