2016-06-26 00:34:39 +02:00
|
|
|
#include "ibm.h"
|
|
|
|
|
|
2017-03-15 01:37:09 +01:00
|
|
|
#include "device.h"
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "io.h"
|
|
|
|
|
#include "ide.h"
|
2017-03-15 01:37:09 +01:00
|
|
|
#include "mem.h"
|
|
|
|
|
#include "rom.h"
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "xtide.h"
|
|
|
|
|
|
2017-03-15 01:37:09 +01:00
|
|
|
typedef struct xtide_t
|
|
|
|
|
{
|
|
|
|
|
uint8_t data_high;
|
|
|
|
|
rom_t bios_rom;
|
|
|
|
|
} xtide_t;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-03-15 01:37:09 +01:00
|
|
|
static void xtide_write(uint16_t port, uint8_t val, void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-03-15 01:37:09 +01:00
|
|
|
xtide_t *xtide = (xtide_t *)p;
|
|
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
switch (port & 0xf)
|
|
|
|
|
{
|
|
|
|
|
case 0x0:
|
2017-03-15 01:37:09 +01:00
|
|
|
writeidew(0, val | (xtide->data_high << 8));
|
2016-06-26 00:34:39 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 0x1: case 0x2: case 0x3:
|
|
|
|
|
case 0x4: case 0x5: case 0x6: case 0x7:
|
|
|
|
|
writeide(0, (port & 0xf) | 0x1f0, val);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 0x8:
|
2017-03-15 01:37:09 +01:00
|
|
|
xtide->data_high = val;
|
2016-06-26 00:34:39 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 0xe:
|
|
|
|
|
writeide(0, 0x3f6, val);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 01:37:09 +01:00
|
|
|
static uint8_t xtide_read(uint16_t port, void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-03-15 01:37:09 +01:00
|
|
|
xtide_t *xtide = (xtide_t *)p;
|
2016-06-26 00:34:39 +02:00
|
|
|
uint16_t tempw;
|
2017-03-15 01:37:09 +01:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
switch (port & 0xf)
|
|
|
|
|
{
|
|
|
|
|
case 0x0:
|
|
|
|
|
tempw = readidew(0);
|
2017-03-15 01:37:09 +01:00
|
|
|
xtide->data_high = tempw >> 8;
|
2016-06-26 00:34:39 +02:00
|
|
|
return tempw & 0xff;
|
|
|
|
|
|
|
|
|
|
case 0x1: case 0x2: case 0x3:
|
|
|
|
|
case 0x4: case 0x5: case 0x6: case 0x7:
|
|
|
|
|
return readide(0, (port & 0xf) | 0x1f0);
|
|
|
|
|
|
|
|
|
|
case 0x8:
|
2017-03-15 01:37:09 +01:00
|
|
|
return xtide->data_high;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
case 0xe:
|
|
|
|
|
return readide(0, 0x3f6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 01:37:09 +01:00
|
|
|
static void *xtide_init()
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2017-03-15 01:37:09 +01:00
|
|
|
xtide_t *xtide = malloc(sizeof(xtide_t));
|
|
|
|
|
memset(xtide, 0, sizeof(xtide_t));
|
|
|
|
|
|
|
|
|
|
rom_init(&xtide->bios_rom, "roms/ide_xt.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
|
2016-06-26 00:34:39 +02:00
|
|
|
ide_init();
|
2017-03-15 01:37:09 +01:00
|
|
|
ide_pri_disable();
|
|
|
|
|
ide_sec_disable();
|
|
|
|
|
io_sethandler(0x0300, 0x0010, xtide_read, NULL, NULL, xtide_write, NULL, NULL, xtide);
|
|
|
|
|
|
|
|
|
|
return xtide;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
2017-03-15 01:37:09 +01:00
|
|
|
|
|
|
|
|
static void *xtide_at_init()
|
|
|
|
|
{
|
|
|
|
|
xtide_t *xtide = malloc(sizeof(xtide_t));
|
|
|
|
|
memset(xtide, 0, sizeof(xtide_t));
|
|
|
|
|
|
|
|
|
|
rom_init(&xtide->bios_rom, "roms/ide_at.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL);
|
|
|
|
|
ide_init();
|
|
|
|
|
|
|
|
|
|
return xtide;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void xtide_close(void *p)
|
|
|
|
|
{
|
|
|
|
|
xtide_t *xtide = (xtide_t *)p;
|
|
|
|
|
|
|
|
|
|
free(xtide);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int xtide_available()
|
|
|
|
|
{
|
|
|
|
|
return rom_present("roms/ide_xt.bin");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int xtide_at_available()
|
|
|
|
|
{
|
|
|
|
|
return rom_present("roms/ide_at.bin");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
device_t xtide_device =
|
|
|
|
|
{
|
|
|
|
|
"XTIDE",
|
|
|
|
|
0,
|
|
|
|
|
xtide_init,
|
|
|
|
|
xtide_close,
|
|
|
|
|
xtide_available,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
device_t xtide_at_device =
|
|
|
|
|
{
|
|
|
|
|
"XTIDE (AT)",
|
|
|
|
|
DEVICE_AT,
|
|
|
|
|
xtide_at_init,
|
|
|
|
|
xtide_close,
|
|
|
|
|
xtide_at_available,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL
|
|
|
|
|
};
|