From faf7cf9ce689775279c00afc79ae51ff1098acdf Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 28 Jun 2025 01:05:24 +0200 Subject: [PATCH] PC87310 / ALi M5105 - merge the three device_t's and use device_add_param(). --- src/include/86box/sio.h | 12 ++++++---- src/machine/m_at_286_386sx.c | 6 ++--- src/machine/m_at_386dx_486.c | 2 +- src/sio/sio_pc87310.c | 44 ++++++------------------------------ 4 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/include/86box/sio.h b/src/include/86box/sio.h index 0b07d7a13..72878ff46 100644 --- a/src/include/86box/sio.h +++ b/src/include/86box/sio.h @@ -20,8 +20,6 @@ extern const device_t acc3221_device; /* Acer / ALi */ -extern const device_t ali5105_device; - extern const device_t ali5123_device; /* Chips & Technologies */ @@ -79,10 +77,13 @@ extern const device_t i82091aa_398_device; extern const device_t i82091aa_ide_pri_device; extern const device_t i82091aa_ide_device; -/* National Semiconductors */ -extern const device_t pc87310_device; -extern const device_t pc87310_ide_device; +/* National Semiconductors PC87310 / ALi M5105 */ +#define PC87310_IDE 0x0001 +#define PC87310_ALI 0x0002 +extern const device_t pc87310_device; + +/* National Semiconductors */ extern const device_t pc87306_device; extern const device_t pc87311_device; extern const device_t pc87311_ide_device; @@ -92,6 +93,7 @@ extern const device_t pc87332_398_ide_device; extern const device_t pc87332_398_ide_sec_device; extern const device_t pc87332_398_ide_fdcon_device; +/* National Semiconductors PC87307 / PC87309 */ #define PCX7307_PC87307 0x00c0 #define PCX7307_PC97307 0x00cf diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index eb5394ba4..6a5ac1f47 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -118,7 +118,7 @@ machine_at_ama932j_init(const machine_t *model) machine_at_headland_common_init(model, 2); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); return ret; } @@ -858,7 +858,7 @@ machine_at_cmdsl386sx25_init(const machine_t *model) device_add(&ide_isa_device); - device_add(&ali5105_device); /* The FDC is part of the ALi M5105. */ + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); device_add(&vl82c113_device); /* The keyboard controller is part of the VL82c113. */ device_add(&vlsi_scamp_device); @@ -1008,7 +1008,7 @@ machine_at_acer100t_init(const machine_t *model) if (gfxcard[0] == VID_INTERNAL) device_add(&oti077_acer100t_device); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); return ret; } diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 09efd51bf..eb91f300c 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -535,7 +535,7 @@ machine_at_acera1g_init(const machine_t *model) device_add(&keyboard_ps2_acer_pci_device); - device_add(&ali5105_device); + device_add_params(&pc87310_device, (void *) (PC87310_ALI)); device_add(&ide_ali5213_device); return ret; diff --git a/src/sio/sio_pc87310.c b/src/sio/sio_pc87310.c index 5bd595f05..ae0f5d977 100644 --- a/src/sio/sio_pc87310.c +++ b/src/sio/sio_pc87310.c @@ -40,9 +40,6 @@ #include <86box/sio.h> #include <86box/plat_unused.h> -#define FLAG_IDE 0x00000001 -#define FLAG_ALI 0x00000002 - #ifdef ENABLE_PC87310_LOG int pc87310_do_log = ENABLE_PC87310_LOG; @@ -137,7 +134,7 @@ serial_handler(pc87310_t *dev) * Then they become simple toggle bits. * Therefore, we do this for easier operation. */ - if (dev->flags & FLAG_ALI) { + if (dev->flags & PC87310_ALI) { temp2 = dev->regs[0] & 0x03; temp2 ^= ((temp2 & 0x02) >> 1); } @@ -197,7 +194,7 @@ pc87310_write(UNUSED(uint16_t port), uint8_t val, void *priv) serial_handler(dev); /* Reconfigure IDE controller. */ - if ((dev->flags & FLAG_IDE) && (valxor & 0x20)) { + if ((dev->flags & PC87310_IDE) && (valxor & 0x20)) { pc87310_log("SIO: HDC disabled\n"); ide_pri_disable(); /* Bit 5: 1 = Disable IDE controller. */ @@ -258,7 +255,7 @@ pc87310_reset(pc87310_t *dev) lpt1_handler(dev); serial_handler(dev); - if (dev->flags & FLAG_IDE) { + if (dev->flags & PC87310_IDE) { ide_pri_disable(); ide_pri_enable(); } @@ -286,21 +283,22 @@ pc87310_init(const device_t *info) dev->uart[0] = device_add_inst(&ns16450_device, 1); dev->uart[1] = device_add_inst(&ns16450_device, 2); - if (dev->flags & FLAG_IDE) - device_add((dev->flags & FLAG_ALI) ? &ide_vlb_device : &ide_isa_device); + if (dev->flags & PC87310_IDE) + device_add((dev->flags & PC87310_ALI) ? &ide_vlb_device : &ide_isa_device); pc87310_reset(dev); io_sethandler(0x3f3, 0x0001, pc87310_read, NULL, NULL, pc87310_write, NULL, NULL, dev); - if (dev->flags & FLAG_ALI) + if (dev->flags & PC87310_ALI) io_sethandler(0x3f1, 0x0001, pc87310_read, NULL, NULL, pc87310_write, NULL, NULL, dev); return dev; } +/* The ALi M5105 is an extended clone of this. */ const device_t pc87310_device = { .name = "National Semiconductor PC87310 Super I/O", .internal_name = "pc87310", @@ -314,31 +312,3 @@ const device_t pc87310_device = { .force_redraw = NULL, .config = NULL }; - -const device_t pc87310_ide_device = { - .name = "National Semiconductor PC87310 Super I/O with IDE functionality", - .internal_name = "pc87310_ide", - .flags = 0, - .local = FLAG_IDE, - .init = pc87310_init, - .close = pc87310_close, - .reset = NULL, - .available = NULL, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -const device_t ali5105_device = { - .name = "ALi M5105 Super I/O", - .internal_name = "ali5105", - .flags = 0, - .local = FLAG_ALI, - .init = pc87310_init, - .close = pc87310_close, - .reset = NULL, - .available = NULL, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -};