mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 10:28:19 -07:00
Fixed the hard disk controller mess (and added a check to prevent double IDE initialization), and made IDE always initialized as a device_t.
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
*
|
||||
* Common code to handle all sorts of disk controllers.
|
||||
*
|
||||
* Version: @(#)hdc.c 1.0.8 2017/12/15
|
||||
* Version: @(#)hdc.c 1.0.9 2018/02/14
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -97,27 +97,36 @@ static struct {
|
||||
{ "[ISA] [IDE] PC/AT IDE Adapter", "ide_isa",
|
||||
&ide_isa_device, 0 },
|
||||
|
||||
{ "[ISA] [IDE] PC/XT XTIDE", "xtide",
|
||||
&xtide_device , 0 },
|
||||
{ "[ISA] [IDE] PC/AT IDE Adapter (Dual-Channel)", "ide_isa_2ch",
|
||||
&ide_isa_2ch_device, 0 },
|
||||
|
||||
{ "[ISA] [IDE] PC/AT XTIDE", "xtide_at",
|
||||
&xtide_at_device, 0 },
|
||||
|
||||
{ "[ISA] [IDE] PS/2 XTIDE (Acculogic)", "xtide_ps2",
|
||||
&xtide_ps2_device, 0 },
|
||||
|
||||
{ "[ISA] [IDE] PS/2 AT XTIDE (1.1.5)", "xtide_at_ps2",
|
||||
&xtide_at_ps2_device, 0 },
|
||||
|
||||
{ "[ISA] [XT IDE] Acculogic XT IDE", "xtide_acculogic",
|
||||
&xtide_acculogic_device, 0 },
|
||||
|
||||
{ "[ISA] [XT IDE] PC/XT XTIDE", "xtide",
|
||||
&xtide_device , 0 },
|
||||
|
||||
{ "[MCA] [ESDI] IBM PS/2 ESDI Fixed Disk Adapter","esdi_mca",
|
||||
&esdi_ps2_device, 1 },
|
||||
|
||||
{ "[PCI] [IDE] PCI IDE Adapter", "ide_pci",
|
||||
&ide_pci_device, 0 },
|
||||
|
||||
{ "[PCI] [IDE] PCI IDE Adapter (Dual-Channel)", "ide_pci_2ch",
|
||||
&ide_pci_2ch_device, 0 },
|
||||
|
||||
{ "[VLB] [IDE] PC/AT IDE Adapter", "vlb_isa",
|
||||
&ide_vlb_device, 0 },
|
||||
|
||||
{ "[VLB] [IDE] PC/AT IDE Adapter (Dual-Channel)", "vlb_isa_2ch",
|
||||
&ide_vlb_2ch_device, 0 },
|
||||
|
||||
{ "", "", NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
*
|
||||
* Definitions for the common disk controller handler.
|
||||
*
|
||||
* Version: @(#)hdc.h 1.0.4 2017/12/15
|
||||
* Version: @(#)hdc.h 1.0.5 2018/02/14
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#ifndef EMU_HDC_H
|
||||
# define EMU_HDC_H
|
||||
@@ -40,12 +40,16 @@ extern device_t esdi_at_wd1007vse1_device; /* esdi_at */
|
||||
extern device_t esdi_ps2_device; /* esdi_mca */
|
||||
|
||||
extern device_t ide_isa_device; /* isa_ide */
|
||||
extern device_t ide_pci_device; /* pci_ide */
|
||||
extern device_t ide_isa_2ch_device; /* isa_ide_2ch */
|
||||
extern device_t ide_isa_2ch_opt_device; /* isa_ide_2ch_opt */
|
||||
extern device_t ide_vlb_device; /* vlb_ide */
|
||||
extern device_t ide_vlb_2ch_device; /* vlb_ide_2ch */
|
||||
extern device_t ide_pci_device; /* pci_ide */
|
||||
extern device_t ide_pci_2ch_device; /* pci_ide_2ch */
|
||||
|
||||
extern device_t xtide_device; /* xtide_xt */
|
||||
extern device_t xtide_at_device; /* xtide_at */
|
||||
extern device_t xtide_ps2_device; /* xtide_ps2 */
|
||||
extern device_t xtide_acculogic_device; /* xtide_ps2 */
|
||||
extern device_t xtide_at_ps2_device; /* xtide_at_ps2 */
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the IDE emulation for hard disks and ATAPI
|
||||
* CD-ROM devices.
|
||||
*
|
||||
* Version: @(#)hdc_ide.c 1.0.25 2018/02/08
|
||||
* Version: @(#)hdc_ide.c 1.0.26 2018/02/14
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -106,6 +106,7 @@ int (*ide_bus_master_write)(int channel, uint8_t *data, int transfer_length);
|
||||
void (*ide_bus_master_set_irq)(int channel);
|
||||
int64_t idecallback[5] = {0LL, 0LL, 0LL, 0LL, 0LL};
|
||||
int cur_ide[5];
|
||||
int ide_init_ch[2] = {0, 0};
|
||||
|
||||
|
||||
#ifdef ENABLE_IDE_LOG
|
||||
@@ -2701,16 +2702,6 @@ void ide_init_first(void)
|
||||
}
|
||||
|
||||
|
||||
void ide_init(void)
|
||||
{
|
||||
ide_pri_enable();
|
||||
ide_sec_enable();
|
||||
|
||||
timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL);
|
||||
timer_add(ide_callback_sec, &idecallback[1], &idecallback[1], NULL);
|
||||
}
|
||||
|
||||
|
||||
void ide_xtide_init(void)
|
||||
{
|
||||
ide_bus_master_read = ide_bus_master_write = NULL;
|
||||
@@ -2731,21 +2722,18 @@ void secondary_ide_check(void)
|
||||
int secondary_cdroms = 0;
|
||||
int secondary_zips = 0;
|
||||
|
||||
for (i=0; i<ZIP_NUM; i++)
|
||||
{
|
||||
for (i=0; i<ZIP_NUM; i++) {
|
||||
if ((zip_drives[i].ide_channel >= 2) && (zip_drives[i].ide_channel <= 3) && ((zip_drives[i].bus_type == ZIP_BUS_ATAPI_PIO_ONLY) || (zip_drives[i].bus_type == ZIP_BUS_ATAPI_PIO_AND_DMA)))
|
||||
{
|
||||
secondary_zips++;
|
||||
}
|
||||
}
|
||||
for (i=0; i<CDROM_NUM; i++)
|
||||
{
|
||||
for (i=0; i<CDROM_NUM; i++) {
|
||||
if ((cdrom_drives[i].ide_channel >= 2) && (cdrom_drives[i].ide_channel <= 3) && ((cdrom_drives[i].bus_type == CDROM_BUS_ATAPI_PIO_ONLY) || (cdrom_drives[i].bus_type == CDROM_BUS_ATAPI_PIO_AND_DMA)))
|
||||
{
|
||||
secondary_cdroms++;
|
||||
}
|
||||
}
|
||||
if (!secondary_zips && !secondary_cdroms) ide_sec_disable();
|
||||
if (!secondary_zips && !secondary_cdroms) {
|
||||
ide_sec_disable();
|
||||
ide_init_ch[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2762,20 +2750,29 @@ ide_sainit(device_t *info)
|
||||
{
|
||||
switch(info->local) {
|
||||
case 0: /* ISA, single-channel */
|
||||
ide_pri_enable();
|
||||
ide_bus_master_read = ide_bus_master_write = NULL;
|
||||
timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL);
|
||||
break;
|
||||
case 2: /* ISA, dual-channel */
|
||||
case 3: /* ISA, dual-channel, optional 2nd channel */
|
||||
case 4: /* VLB, single-channel */
|
||||
case 6: /* VLB, dual-channel */
|
||||
case 8: /* PCI, single-channel */
|
||||
case 10: /* PCI, dual-channel */
|
||||
if (!ide_init_ch[0]) {
|
||||
ide_pri_enable();
|
||||
timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL);
|
||||
ide_init_ch[0] = 1;
|
||||
}
|
||||
|
||||
case 1: /* VLB, single-channel */
|
||||
ide_pri_enable();
|
||||
ide_bus_master_read = ide_bus_master_write = NULL;
|
||||
timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL);
|
||||
break;
|
||||
if ((info->local & 2) && !ide_init_ch[1]) {
|
||||
ide_sec_enable();
|
||||
timer_add(ide_callback_sec, &idecallback[1], &idecallback[1], NULL);
|
||||
ide_init_ch[1] = 1;
|
||||
|
||||
case 2: /* PCI, single-channel */
|
||||
ide_pri_enable();
|
||||
timer_add(ide_callback_pri, &idecallback[0], &idecallback[0], NULL);
|
||||
if (info->local & 1)
|
||||
secondary_ide_check();
|
||||
}
|
||||
|
||||
if (!(info->local & 8))
|
||||
ide_bus_master_read = ide_bus_master_write = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2787,6 +2784,7 @@ ide_sainit(device_t *info)
|
||||
static void
|
||||
ide_saclose(void *priv)
|
||||
{
|
||||
ide_init_ch[0] = ide_init_ch[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2799,19 +2797,55 @@ device_t ide_isa_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_pci_device = {
|
||||
"PCI IDE Controller",
|
||||
DEVICE_PCI | DEVICE_AT,
|
||||
device_t ide_isa_2ch_device = {
|
||||
"ISA PC/AT IDE Controller (Dual-Channel)",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
2,
|
||||
ide_sainit, ide_saclose, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_isa_2ch_opt_device = {
|
||||
"ISA PC/AT IDE Controller (Single/Dual)",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
3,
|
||||
ide_sainit, ide_saclose, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_vlb_device = {
|
||||
"VLB IDE Controller",
|
||||
DEVICE_VLB | DEVICE_AT,
|
||||
1,
|
||||
4,
|
||||
ide_sainit, ide_saclose, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_vlb_2ch_device = {
|
||||
"VLB IDE Controller (Dual-Channel)",
|
||||
DEVICE_VLB | DEVICE_AT,
|
||||
6,
|
||||
ide_sainit, ide_saclose, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_pci_device = {
|
||||
"PCI IDE Controller",
|
||||
DEVICE_PCI | DEVICE_AT,
|
||||
8,
|
||||
ide_sainit, ide_saclose, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t ide_pci_2ch_device = {
|
||||
"PCI IDE Controller (Dual-Channel)",
|
||||
DEVICE_PCI | DEVICE_AT,
|
||||
10,
|
||||
ide_sainit, ide_saclose, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
* Implementation of the IDE emulation for hard disks and ATAPI
|
||||
* CD-ROM devices.
|
||||
*
|
||||
* Version: @(#)hdd_ide.h 1.0.5 2017/10/26
|
||||
* Version: @(#)hdd_ide.h 1.0.6 2018/02/14
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*/
|
||||
#ifndef EMU_IDE_H
|
||||
# define EMU_IDE_H
|
||||
@@ -82,7 +82,7 @@ extern void ide_set_base(int controller, uint16_t port);
|
||||
extern void ide_set_side(int controller, uint16_t port);
|
||||
|
||||
extern void ide_init_first(void);
|
||||
extern void ide_init(void);
|
||||
|
||||
extern void ide_reset(void);
|
||||
extern void ide_reset_hard(void);
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
* already on their way out, the newer IDE standard based on the
|
||||
* PC/AT controller and 16b design became the IDE we now know.
|
||||
*
|
||||
* Version: @(#)hdc_xtide.c 1.0.10 2017/11/04
|
||||
* Version: @(#)hdc_xtide.c 1.0.11 2018/02/14
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -163,7 +163,7 @@ xtide_at_init(device_t *info)
|
||||
rom_init(&xtide->bios_rom, ROM_PATH_AT,
|
||||
0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
|
||||
|
||||
ide_init();
|
||||
device_add(&ide_isa_2ch_device);
|
||||
|
||||
return(xtide);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ xtide_at_available(void)
|
||||
|
||||
|
||||
static void *
|
||||
xtide_ps2_init(device_t *info)
|
||||
xtide_acculogic_init(device_t *info)
|
||||
{
|
||||
xtide_t *xtide = malloc(sizeof(xtide_t));
|
||||
|
||||
@@ -197,7 +197,7 @@ xtide_ps2_init(device_t *info)
|
||||
|
||||
|
||||
static int
|
||||
xtide_ps2_available(void)
|
||||
xtide_acculogic_available(void)
|
||||
{
|
||||
return(rom_present(ROM_PATH_PS2));
|
||||
}
|
||||
@@ -213,7 +213,7 @@ xtide_at_ps2_init(device_t *info)
|
||||
rom_init(&xtide->bios_rom, ROM_PATH_PS2AT,
|
||||
0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
|
||||
|
||||
ide_init();
|
||||
device_add(&ide_isa_2ch_device);
|
||||
|
||||
return(xtide);
|
||||
}
|
||||
@@ -253,12 +253,12 @@ device_t xtide_at_device = {
|
||||
NULL
|
||||
};
|
||||
|
||||
device_t xtide_ps2_device = {
|
||||
device_t xtide_acculogic_device = {
|
||||
"XTIDE (Acculogic)",
|
||||
DEVICE_ISA,
|
||||
0,
|
||||
xtide_ps2_init, xtide_close, NULL,
|
||||
xtide_ps2_available, NULL, NULL, NULL,
|
||||
xtide_acculogic_init, xtide_close, NULL,
|
||||
xtide_acculogic_available, NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user