From aae4163a8e7dc1d39088944680c720324d7d19c5 Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 2 May 2021 10:33:45 +0300 Subject: [PATCH 1/4] Removed the PS/1 Model 2133. Introduced the Siemens D824. --- src/include/86box/machine.h | 7 +- src/include/86box/sio.h | 1 + src/machine/m_at_386dx_486.c | 32 +++++- src/machine/m_ps1.c | 36 +------ src/machine/machine_table.c | 4 +- src/sio/CMakeLists.txt | 2 +- src/sio/sio_fdc37c651.c | 190 +++++++++++++++++++++++++++++++++++ src/win/Makefile.mingw | 2 +- 8 files changed, 227 insertions(+), 47 deletions(-) create mode 100644 src/sio/sio_fdc37c651.c diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index ad95f843b..8c2e2a6b9 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -319,6 +319,7 @@ extern int machine_at_opti495_ami_init(const machine_t *); extern int machine_at_opti495_mr_init(const machine_t *); extern int machine_at_vect486vl_init(const machine_t *); +extern int machine_at_d824_init(const machine_t *); extern int machine_at_403tg_init(const machine_t *); extern int machine_at_pc330_6573_init(const machine_t *); @@ -362,6 +363,7 @@ extern int machine_at_pcm5330_init(const machine_t *); #ifdef EMU_DEVICE_H extern const device_t *at_acera1g_get_device(void); extern const device_t *at_vect486vl_get_device(void); +extern const device_t *at_d824_get_device(void); extern const device_t *at_valuepoint433_get_device(void); #endif @@ -595,11 +597,6 @@ extern const device_t *pcjr_get_device(void); /* m_ps1.c */ extern int machine_ps1_m2011_init(const machine_t *); extern int machine_ps1_m2121_init(const machine_t *); -extern int machine_ps1_m2133_init(const machine_t *); - -#ifdef EMU_DEVICE_H -extern const device_t *ps1_m2133_get_device(void); -#endif /* m_ps1_hdc.c */ #ifdef EMU_DEVICE_H diff --git a/src/include/86box/sio.h b/src/include/86box/sio.h index ec94f5404..f1e6cf82d 100644 --- a/src/include/86box/sio.h +++ b/src/include/86box/sio.h @@ -20,6 +20,7 @@ extern void vt82c686_sio_write(uint8_t addr, uint8_t val, void *priv); extern const device_t acc3221_device; extern const device_t f82c710_device; +extern const device_t fdc37c651_device; extern const device_t fdc37c661_device; extern const device_t fdc37c663_device; extern const device_t fdc37c663_ide_device; diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index c7714ebf8..54f9a8a83 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -345,8 +345,7 @@ machine_at_vect486vl_init(const machine_t *model) // has HDC problems device_add(&vl82c480_device); device_add(&keyboard_ps2_ami_device); - device_add(&fdc37c661_device); // presumably SMC FDC37C651 - device_add(&ide_isa_2ch_device); + device_add(&fdc37c651_device); if (gfxcard == VID_INTERNAL) device_add(&gd5428_onboard_device); @@ -354,13 +353,40 @@ machine_at_vect486vl_init(const machine_t *model) // has HDC problems return ret; } - const device_t * at_vect486vl_get_device(void) { return &gd5428_onboard_device; } +int +machine_at_d824_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear("roms/machines/d824/fts-biosupdated824noflashbiosepromv320-320334-160.bin", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init(model); + + device_add(&vl82c480_device); + device_add(&keyboard_ps2_device); + device_add(&fdc37c651_device); + + if (gfxcard == VID_INTERNAL) + device_add(&gd5428_onboard_device); + + return ret; +} + +const device_t * +at_d824_get_device(void) +{ + return &gd5428_onboard_device; +} int machine_at_acera1g_init(const machine_t *model) diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index 2d51c5edb..7edc81883 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -6,7 +6,7 @@ * * This file is part of the 86Box distribution. * - * Emulation of the IBM PS/1 models 2011, 2121 and 2133. + * Emulation of the IBM PS/1 models 2011, 2121. * * Model 2011: The initial model, using a 10MHz 80286. * @@ -558,37 +558,3 @@ machine_ps1_m2121_init(const machine_t *model) return ret; } - -int -machine_ps1_m2133_init(const machine_t *model) -{ - int ret; - - ret = bios_load_linear("roms/machines/ibmps1_2133/ps1_2133_52g2974_rom.bin", - 0x000e0000, 131072, 0); - - if (bios_only || !ret) - return ret; - - ps1_common_init(model); - /* The PS/1 model 2133 expects a NVR without the century register. */ - device_add(&ide_isa_device); - device_add(&at_nvr_old_device); - device_add(&pc87332_398_ide_fdcon_device); - device_add(&vl82c480_device); - - nmi_mask = 0x80; - - if (gfxcard == VID_INTERNAL) - device_add(&gd5426_onboard_device); - - return ret; -} - - -const device_t * -ps1_m2133_get_device(void) -{ - return &gd5426_onboard_device; -} - diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index d066d7978..4330beaae 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -202,8 +202,8 @@ const machine_t machines[] = { { "[CS4031] AMI 486 CS4031", "cs4031", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_VLB, 1024, 65536, 1024, 127, machine_at_cs4031_init, NULL }, { "[OPTi 895] Mylex MVI486", "mvi486", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_VLB | MACHINE_IDE_DUAL, 1024, 65536, 1024, 127, machine_at_mvi486_init, NULL }, { "[VIA VT82C495] FIC 486-VC-HD", "486vchd", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 1024, 64512, 1024, 127, machine_at_486vchd_init, NULL }, - { "[VLSI 82C480] IBM PS/1 model 2133", "ibmps1_2133", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_VLB | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_NONMI | MACHINE_VIDEO, 2048, 32768, 1024, 127, machine_ps1_m2133_init, ps1_m2133_get_device }, - { "[VLSI 82C480] HP Vectra 486VL", "vect486vl", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 65536, 1024, 127, machine_at_vect486vl_init, at_vect486vl_get_device }, + { "[VLSI 82C480] HP Vectra 486VL", "vect486vl", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 4096, 32768, 4096, 127, machine_at_vect486vl_init, at_vect486vl_get_device }, + { "[VLSI 82C481] Siemens Nixdorf System Board D824", "d824", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 4096, 32768, 4096, 127, machine_at_d824_init, at_d824_get_device }, /* 486 machines with utilize the MCA bus */ #if defined(DEV_BRANCH) && defined(USE_PS2M70T4) diff --git a/src/sio/CMakeLists.txt b/src/sio/CMakeLists.txt index d19a8e251..9eff04f30 100644 --- a/src/sio/CMakeLists.txt +++ b/src/sio/CMakeLists.txt @@ -13,7 +13,7 @@ # Copyright 2020,2021 David Hrdlička. # -add_library(sio OBJECT sio_acc3221.c sio_f82c710.c sio_82091aa.c sio_fdc37c661.c +add_library(sio OBJECT sio_acc3221.c sio_f82c710.c sio_82091aa.c sio_fdc37c651.c sio_fdc37c661.c sio_fdc37c66x.c sio_fdc37c669.c sio_fdc37c93x.c sio_fdc37m60x.c sio_it8661f.c sio_pc87306.c sio_pc87307.c sio_pc87309.c sio_pc87310.c sio_pc87311.c sio_pc87332.c diff --git a/src/sio/sio_fdc37c651.c b/src/sio/sio_fdc37c651.c new file mode 100644 index 000000000..8909ef5bb --- /dev/null +++ b/src/sio/sio_fdc37c651.c @@ -0,0 +1,190 @@ +/* + * 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. + * + * Emulation of the LG fdc37c651 Super I/O + * + * Authors: Tiseno100 + * Copyright 2020 Tiseno100 + */ +#include +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/io.h> +#include <86box/timer.h> +#include <86box/device.h> +#include <86box/lpt.h> +#include <86box/serial.h> +#include <86box/hdc.h> +#include <86box/hdc_ide.h> +#include <86box/fdd.h> +#include <86box/fdc.h> +#include <86box/sio.h> + +#ifdef ENABLE_FDC37C651_LOG +int fdc37c651_do_log = ENABLE_FDC37C651_LOG; +static void +fdc37c651_log(const char *fmt, ...) +{ + va_list ap; + + if (fdc37c651_do_log) + { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +#define fdc37c651_log(fmt, ...) +#endif + +typedef struct +{ + uint8_t configuration_select, regs[3]; + uint16_t com3, com4; + + fdc_t *fdc_controller; + serial_t *uart[2]; + +} fdc37c651_t; + +static void +fdc37c651_write(uint16_t addr, uint8_t val, void *priv) +{ + fdc37c651_t *dev = (fdc37c651_t *)priv; + + switch (addr) + { + case 0x3f0: + dev->configuration_select = val; + break; + case 0x3f1: + switch (dev->configuration_select) + { + case 0: /* CR0 */ + dev->regs[dev->configuration_select] = val; + ide_pri_disable(); + fdc_remove(dev->fdc_controller); + + if (val & 1) /* Enable IDE */ + ide_pri_enable(); + + if (val & 0x10) /* Enable FDC */ + fdc_set_base(dev->fdc_controller, 0x3f0); + + break; + + case 1: /* CR1 */ + dev->regs[dev->configuration_select] = val; + lpt1_remove(); + + if ((val & 3) != 0) /* Program LPT if not Disabled */ + lpt1_init((val & 2) ? ((val & 1) ? 0x278 : 0x378) : 0x3f8); + + switch ((val >> 4) & 3) /* COM3 & 4 Select*/ + { + case 0: + dev->com3 = 0x338; + dev->com4 = 0x238; + break; + case 1: + dev->com3 = 0x3e8; + dev->com4 = 0x2e8; + break; + case 2: + dev->com3 = 0x2e8; + dev->com4 = 0x2e0; + break; + case 3: + dev->com3 = 0x220; + dev->com4 = 0x228; + break; + } + + break; + + case 2: /* CR2 */ + dev->regs[dev->configuration_select] = val; + serial_remove(dev->uart[0]); + serial_remove(dev->uart[1]); + + if (val & 4) + serial_setup(dev->uart[0], (val & 2) ? ((val & 1) ? dev->com4 : dev->com3) : ((val & 1) ? 0x2f8 : 0x3f8), 4); + + if (val & 0x40) + serial_setup(dev->uart[1], (val & 0x20) ? ((val & 0x10) ? dev->com4 : dev->com3) : ((val & 0x10) ? 0x2f8 : 0x3f8), 3); + + break; + } + break; + } +} + +static uint8_t +fdc37c651_read(uint16_t addr, void *priv) +{ + fdc37c651_t *dev = (fdc37c651_t *)priv; + + return dev->regs[dev->configuration_select]; +} + +static void +fdc37c651_close(void *priv) +{ + fdc37c651_t *dev = (fdc37c651_t *)priv; + free(dev); +} + +static void * +fdc37c651_init(const device_t *info) +{ + fdc37c651_t *dev = (fdc37c651_t *)malloc(sizeof(fdc37c651_t)); + memset(dev, 0, sizeof(fdc37c651_t)); + + dev->fdc_controller = device_add(&fdc_at_smc_device); + dev->uart[0] = device_add_inst(&ns16550_device, 1); + dev->uart[1] = device_add_inst(&ns16550_device, 2); + device_add(&ide_isa_device); + + /* Program Defaults */ + dev->regs[0] = 0x3f; + dev->regs[1] = 0x9f; + dev->regs[2] = 0xdc; + ide_pri_disable(); + fdc_remove(dev->fdc_controller); + lpt1_remove(); + serial_remove(dev->uart[0]); + serial_remove(dev->uart[1]); + + ide_pri_enable(); + fdc_set_base(dev->fdc_controller, 0x3f0); + lpt1_init(0x278); + serial_setup(dev->uart[0], 0x2f8, 4); + serial_setup(dev->uart[1], 0x3f8, 3); + + io_sethandler(0x03f0, 2, fdc37c651_read, NULL, NULL, fdc37c651_write, NULL, NULL, dev); + + return dev; +} + +const device_t fdc37c651_device = { + "SMC FDC37C651", + 0, + 0, + fdc37c651_init, + fdc37c651_close, + NULL, + {NULL}, + NULL, + NULL, + NULL}; diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 4a52b2e08..d714a20b0 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -648,7 +648,7 @@ DEVOBJ := bugger.o hwm.o hwm_lm75.o hwm_lm78.o hwm_gl518sm.o hwm_vt82c686.o ibm phoenix_486_jumper.o SIOOBJ := sio_acc3221.o \ - sio_f82c710.o sio_82091aa.o \ + sio_f82c710.o sio_82091aa.o sio_fdc37c651.o \ sio_fdc37c661.o sio_fdc37c66x.o sio_fdc37c669.o sio_fdc37c93x.o sio_fdc37m60x.o \ sio_it8661f.o \ sio_pc87306.o sio_pc87307.o sio_pc87309.o sio_pc87310.o sio_pc87311.o sio_pc87332.o \ From c1240af39b4f7089f246fed99ca6b3d327fee3ac Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 2 May 2021 10:35:22 +0300 Subject: [PATCH 2/4] I copy paste commentaries --- src/sio/sio_fdc37c651.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sio/sio_fdc37c651.c b/src/sio/sio_fdc37c651.c index 8909ef5bb..3223d1178 100644 --- a/src/sio/sio_fdc37c651.c +++ b/src/sio/sio_fdc37c651.c @@ -6,10 +6,10 @@ * * This file is part of the 86Box distribution. * - * Emulation of the LG fdc37c651 Super I/O + * Emulation of the SMC FDC37C651 Super I/O * * Authors: Tiseno100 - * Copyright 2020 Tiseno100 + * Copyright 2021 Tiseno100 */ #include #include From 78b2f7c9fb0fc44619ebbef2c3aac196ef3cbd1c Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 2 May 2021 13:48:18 +0300 Subject: [PATCH 3/4] Memory changes and SIO done according to the Intel Classic R --- src/machine/machine_table.c | 4 ++-- src/sio/sio_fdc37c651.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 4330beaae..4ba82a9b5 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -202,8 +202,8 @@ const machine_t machines[] = { { "[CS4031] AMI 486 CS4031", "cs4031", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_VLB, 1024, 65536, 1024, 127, machine_at_cs4031_init, NULL }, { "[OPTi 895] Mylex MVI486", "mvi486", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_VLB | MACHINE_IDE_DUAL, 1024, 65536, 1024, 127, machine_at_mvi486_init, NULL }, { "[VIA VT82C495] FIC 486-VC-HD", "486vchd", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 1024, 64512, 1024, 127, machine_at_486vchd_init, NULL }, - { "[VLSI 82C480] HP Vectra 486VL", "vect486vl", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 4096, 32768, 4096, 127, machine_at_vect486vl_init, at_vect486vl_get_device }, - { "[VLSI 82C481] Siemens Nixdorf System Board D824", "d824", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 4096, 32768, 4096, 127, machine_at_d824_init, at_d824_get_device }, + { "[VLSI 82C480] HP Vectra 486VL", "vect486vl", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 32768, 2048, 127, machine_at_vect486vl_init, at_vect486vl_get_device }, + { "[VLSI 82C481] Siemens Nixdorf D824", "d824", MACHINE_TYPE_486, CPU_PKG_SOCKET1, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 32768, 2048, 127, machine_at_d824_init, at_d824_get_device }, /* 486 machines with utilize the MCA bus */ #if defined(DEV_BRANCH) && defined(USE_PS2M70T4) diff --git a/src/sio/sio_fdc37c651.c b/src/sio/sio_fdc37c651.c index 3223d1178..6b0681059 100644 --- a/src/sio/sio_fdc37c651.c +++ b/src/sio/sio_fdc37c651.c @@ -6,10 +6,10 @@ * * This file is part of the 86Box distribution. * - * Emulation of the SMC FDC37C651 Super I/O + * Emulation of the LG fdc37c651 Super I/O * * Authors: Tiseno100 - * Copyright 2021 Tiseno100 + * Copyright 2020 Tiseno100 */ #include #include @@ -152,8 +152,8 @@ fdc37c651_init(const device_t *info) memset(dev, 0, sizeof(fdc37c651_t)); dev->fdc_controller = device_add(&fdc_at_smc_device); - dev->uart[0] = device_add_inst(&ns16550_device, 1); - dev->uart[1] = device_add_inst(&ns16550_device, 2); + dev->uart[0] = device_add_inst(&ns16450_device, 1); + dev->uart[1] = device_add_inst(&ns16450_device, 2); device_add(&ide_isa_device); /* Program Defaults */ From 5129e1e331af2d9c65c5b86717bb6e7044867a2e Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 2 May 2021 13:48:58 +0300 Subject: [PATCH 4/4] Reverted commentary again --- src/sio/sio_fdc37c651.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sio/sio_fdc37c651.c b/src/sio/sio_fdc37c651.c index 6b0681059..2bfd3fd93 100644 --- a/src/sio/sio_fdc37c651.c +++ b/src/sio/sio_fdc37c651.c @@ -6,7 +6,7 @@ * * This file is part of the 86Box distribution. * - * Emulation of the LG fdc37c651 Super I/O + * Emulation of the SMC FDC37C651 Super I/O * * Authors: Tiseno100 * Copyright 2020 Tiseno100