Super I/O chip fixes.

This commit is contained in:
OBattler
2022-07-18 23:53:05 +02:00
parent 25783f137d
commit 5dc9b4a7fc
2 changed files with 46 additions and 8 deletions

View File

@@ -125,11 +125,13 @@ serial_handler(i82091aa_t *dev, int uart)
static void static void
ide_handler(i82091aa_t *dev) ide_handler(i82091aa_t *dev)
{ {
ide_sec_disable(); int board = dev->has_ide - 1;
ide_set_base(1, (dev->regs[0x50] & 0x02) ? 0x170 : 0x1f0);
ide_set_side(1, (dev->regs[0x50] & 0x02) ? 0x376 : 0x3f6); ide_remove_handlers(board);
ide_set_base(board, (dev->regs[0x50] & 0x02) ? 0x170 : 0x1f0);
ide_set_side(board, (dev->regs[0x50] & 0x02) ? 0x376 : 0x3f6);
if (dev->regs[0x50] & 0x01) if (dev->regs[0x50] & 0x01)
ide_sec_enable(); ide_set_handlers(board);
} }
@@ -258,7 +260,7 @@ i82091aa_init(const device_t *info)
dev->uart[0] = device_add_inst(&ns16550_device, 1); dev->uart[0] = device_add_inst(&ns16550_device, 1);
dev->uart[1] = device_add_inst(&ns16550_device, 2); dev->uart[1] = device_add_inst(&ns16550_device, 2);
dev->has_ide = !!(info->local & 0x200); dev->has_ide = (info->local >> 9) & 0x03;
i82091aa_reset(dev); i82091aa_reset(dev);
@@ -303,8 +305,8 @@ const device_t i82091aa_398_device = {
.config = NULL .config = NULL
}; };
const device_t i82091aa_ide_device = { const device_t i82091aa_ide_pri_device = {
.name = "Intel 82091AA Super I/O (With IDE)", .name = "Intel 82091AA Super I/O (With Primary IDE)",
.internal_name = "i82091aa_ide", .internal_name = "i82091aa_ide",
.flags = 0, .flags = 0,
.local = 0x240, .local = 0x240,
@@ -316,3 +318,17 @@ const device_t i82091aa_ide_device = {
.force_redraw = NULL, .force_redraw = NULL,
.config = NULL .config = NULL
}; };
const device_t i82091aa_ide_device = {
.name = "Intel 82091AA Super I/O (With IDE)",
.internal_name = "i82091aa_ide",
.flags = 0,
.local = 0x440,
.init = i82091aa_init,
.close = i82091aa_close,
.reset = NULL,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};

View File

@@ -34,6 +34,7 @@
#include <86box/fdc.h> #include <86box/fdc.h>
#include <86box/hdc.h> #include <86box/hdc.h>
#include <86box/hdc_ide.h> #include <86box/hdc_ide.h>
#include <86box/gameport.h>
#include <86box/sio.h> #include <86box/sio.h>
#ifdef ENABLE_W83787_LOG #ifdef ENABLE_W83787_LOG
@@ -82,6 +83,7 @@ typedef struct {
ide_start; ide_start;
fdc_t *fdc; fdc_t *fdc;
serial_t *uart[2]; serial_t *uart[2];
void *gameport;
} w83787f_t; } w83787f_t;
@@ -200,6 +202,16 @@ w83787f_lpt_handler(w83787f_t *dev)
} }
static void
w83787f_gameport_handler(w83787f_t *dev)
{
if (!(dev->regs[3] & 0x40) && !(dev->regs[4] & 0x40))
gameport_remap(dev->gameport, 0x201);
else
gameport_remap(dev->gameport, 0);
}
static void static void
w83787f_fdc_handler(w83787f_t *dev) w83787f_fdc_handler(w83787f_t *dev)
{ {
@@ -282,6 +294,8 @@ w83787f_write(uint16_t port, uint8_t val, void *priv)
case 3: case 3:
if (valxor & 0x80) if (valxor & 0x80)
w83787f_lpt_handler(dev); w83787f_lpt_handler(dev);
if (valxor & 0x40)
w83787f_gameport_handler(dev);
if (valxor & 0x08) if (valxor & 0x08)
w83787f_serial_handler(dev, 0); w83787f_serial_handler(dev, 0);
if (valxor & 0x04) if (valxor & 0x04)
@@ -294,6 +308,8 @@ w83787f_write(uint16_t port, uint8_t val, void *priv)
w83787f_serial_handler(dev, 0); w83787f_serial_handler(dev, 0);
if (valxor & 0x80) if (valxor & 0x80)
w83787f_lpt_handler(dev); w83787f_lpt_handler(dev);
if (valxor & 0x40)
w83787f_gameport_handler(dev);
break; break;
case 6: case 6:
if (valxor & 0x08) if (valxor & 0x08)
@@ -392,16 +408,20 @@ w83787f_reset(w83787f_t *dev)
fdc_reset(dev->fdc); fdc_reset(dev->fdc);
dev->regs[0x01] = 0x2C; dev->regs[0x01] = 0x2C;
dev->regs[0x03] = 0x30; dev->regs[0x03] = 0x70;
dev->regs[0x07] = 0xF5; dev->regs[0x07] = 0xF5;
dev->regs[0x09] = dev->reg_init & 0xff; dev->regs[0x09] = dev->reg_init & 0xff;
dev->regs[0x0a] = 0x1F; dev->regs[0x0a] = 0x1F;
dev->regs[0x0c] = 0x2C; dev->regs[0x0c] = 0x2C;
dev->regs[0x0d] = 0xA3; dev->regs[0x0d] = 0xA3;
gameport_remap(dev->gameport, 0);
serial_setup(dev->uart[0], COM1_ADDR, COM1_IRQ); serial_setup(dev->uart[0], COM1_ADDR, COM1_IRQ);
serial_setup(dev->uart[1], COM2_ADDR, COM2_IRQ); serial_setup(dev->uart[1], COM2_ADDR, COM2_IRQ);
w83787f_lpt_handler(dev);
dev->key = 0x89; dev->key = 0x89;
w83787f_remap(dev); w83787f_remap(dev);
@@ -433,6 +453,8 @@ w83787f_init(const device_t *info)
dev->uart[0] = device_add_inst(&ns16550_device, 1); dev->uart[0] = device_add_inst(&ns16550_device, 1);
dev->uart[1] = device_add_inst(&ns16550_device, 2); dev->uart[1] = device_add_inst(&ns16550_device, 2);
dev->gameport = gameport_add(&gameport_sio_1io_device);
if ((dev->ide_function & 0x30) == 0x10) if ((dev->ide_function & 0x30) == 0x10)
device_add(&ide_isa_device); device_add(&ide_isa_device);