diff --git a/src/chipset/CMakeLists.txt b/src/chipset/CMakeLists.txt index f8c01a631..c68d5475a 100644 --- a/src/chipset/CMakeLists.txt +++ b/src/chipset/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(chipset OBJECT acc2168.c cs8230.c ali1217.c ali1429.c headland.c int neat.c opti495.c opti895.c opti5x7.c scamp.c scat.c via_vt82c49x.c via_vt82c505.c sis_85c310.c sis_85c4xx.c sis_85c496.c sis_85c50x.c gc100.c + olivetti_eva.c opti283.c opti291.c via_apollo.c via_pipc.c wd76c10.c vl82c480.c) diff --git a/src/chipset/olivetti_eva.c b/src/chipset/olivetti_eva.c new file mode 100644 index 000000000..34b09c622 --- /dev/null +++ b/src/chipset/olivetti_eva.c @@ -0,0 +1,166 @@ +/* + * 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. + * + * Implementation of the Olivetti EVA (98/86) Gate Array. + * + * Note: This chipset has no datasheet, everything were done via + * reverse engineering the BIOS of various machines using it. + * + * Authors: EngiNerd + * + * Copyright 2020-2021 EngiNerd + */ + + +#include +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include "cpu.h" +#include <86box/timer.h> +#include <86box/io.h> +#include <86box/device.h> +#include <86box/chipset.h> +#include <86box/video.h> +#include <86box/mem.h> + +typedef struct +{ + uint8_t reg_065; + uint8_t reg_067; + uint8_t reg_069; +} olivetti_eva_t; + +#ifdef ENABLE_OLIVETTI_EVA_LOG +int olivetti_eva_do_log = ENABLE_OLIVETTI_EVA_LOG; +static void +olivetti_eva_log(const char *fmt, ...) +{ + va_list ap; + + if (olivetti_eva_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +#define olivetti_eva_log(fmt, ...) +#endif + +static void +olivetti_eva_write(uint16_t addr, uint8_t val, void *priv) +{ + olivetti_eva_t *dev = (olivetti_eva_t *) priv; + olivetti_eva_log("Olivetti EVA Gate Array: Write %02x at %02x\n", val, addr); + + switch (addr) { + case 0x065: + dev->reg_065 = val; + break; + case 0x067: + dev->reg_067 = val; + break; + case 0x069: + dev->reg_069 = val; + /* + * Unfortunately, if triggered, the BIOS remapping function fails causing + * a fatal error. Therefore, this code section is currently commented. + */ + // if (val & 1){ + // /* + // * Set the register to 7 or above for the BIOS to trigger the + // * memory remapping function if shadowing is active. + // */ + // dev->reg_069 = 0x7; + // } + // if (val & 8) { + // /* + // * Activate shadowing for region e0000-fffff + // */ + // mem_remap_top(256); + // mem_set_mem_state_both(0xa0000, 0x60000, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL); + // } + break; + } +} + +static uint8_t +olivetti_eva_read(uint16_t addr, void *priv) +{ + olivetti_eva_t *dev = (olivetti_eva_t *) priv; + uint8_t ret = 0xff; + switch (addr) { + case 0x065: + ret = dev->reg_065; + break; + case 0x067: + /* never happens */ + ret = dev->reg_067; + break; + case 0x069: + ret = dev->reg_069; + break; + } + olivetti_eva_log("Olivetti EVA Gate Array: Read %02x at %02x\n", ret, addr); + return ret; +} + + +static void +olivetti_eva_close(void *priv) +{ + olivetti_eva_t *dev = (olivetti_eva_t *) priv; + + free(dev); +} + +static void * +olivetti_eva_init(const device_t *info) +{ + olivetti_eva_t *dev = (olivetti_eva_t *) malloc(sizeof(olivetti_eva_t)); + memset(dev, 0, sizeof(olivetti_eva_t)); + + /* GA98 registers */ + dev->reg_065 = 0x00; + + /* RAM page registers: never read, only set */ + dev->reg_067 = 0x00; + + /* RAM enable registers */ + dev->reg_069 = 0x0; + + io_sethandler(0x0065, 0x0001, olivetti_eva_read, NULL, NULL, olivetti_eva_write, NULL, NULL, dev); + io_sethandler(0x0067, 0x0001, olivetti_eva_read, NULL, NULL, olivetti_eva_write, NULL, NULL, dev); + io_sethandler(0x0069, 0x0001, olivetti_eva_read, NULL, NULL, olivetti_eva_write, NULL, NULL, dev); + + /* When shadowing is not enabled in BIOS, all upper memory is available as XMS */ + mem_remap_top(384); + + /* + * Default settings when NVRAM is cleared activate shadowing. + * Thus, to avoid boot errors, remap only 256k from UMB to XMS. + * Remove this block once BIOS memory remapping works. + */ + mem_remap_top(256); + + return dev; +} + +const device_t olivetti_eva_device = { + "Olivetti EVA Gate Array", + 0, + 0, + olivetti_eva_init, olivetti_eva_close, NULL, + { NULL }, NULL, NULL, + NULL +}; diff --git a/src/include/86box/chipset.h b/src/include/86box/chipset.h index a4534334a..f5c7e5f37 100644 --- a/src/include/86box/chipset.h +++ b/src/include/86box/chipset.h @@ -147,4 +147,7 @@ extern const device_t wd76c10_device; extern const device_t phoenix_486_jumper_device; extern const device_t vpc2007_device; +#if defined(DEV_BRANCH) && defined(USE_OLIVETTI) +extern const device_t olivetti_eva_device; +#endif #endif /*EMU_CHIPSET_H*/ diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 623cfddbb..57dc8ee3c 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -258,6 +258,10 @@ extern int machine_at_deskmaster286_init(const machine_t *); extern int machine_at_ncrpc8_init(const machine_t *); extern int machine_at_ncr3302_init(const machine_t *); +#if defined(DEV_BRANCH) && defined(USE_OLIVETTI) +extern int machine_at_olim290_init(const machine_t *); +#endif + extern int machine_at_shuttle386sx_init(const machine_t *); extern int machine_at_adi386sx_init(const machine_t *); extern int machine_at_commodore_sl386sx16_init(const machine_t *); @@ -272,12 +276,18 @@ extern int machine_at_arb1375_init(const machine_t *); extern int machine_at_pja511m_init(const machine_t *); #endif +extern int machine_at_ncrpc916sx_init(const machine_t *); + +extern int machine_at_olim300_08_init(const machine_t *); +extern int machine_at_olim300_15_init(const machine_t *); + #ifdef EMU_DEVICE_H extern const device_t *at_ama932j_get_device(void); extern const device_t *at_flytech386_get_device(void); extern const device_t *at_commodore_sl386sx25_get_device(void); extern const device_t *at_spc4620p_get_device(void); extern const device_t *at_spc6033p_get_device(void); +extern const device_t *at_m300_08_get_device(void); #endif /* m_at_386dx_486.c */ @@ -612,8 +622,6 @@ extern int machine_xt_ncrpc4i_init(const machine_t *); extern int machine_xt_mpc1600_init(const machine_t *); extern int machine_xt_eaglepcspirit_init(const machine_t *); extern int machine_xt_multitechpc700_init(const machine_t *); -extern int machine_xt_p3105_init(const machine_t *); -extern int machine_xt_p3120_init(const machine_t *); extern int machine_xt_iskra3104_init(const machine_t *); diff --git a/src/machine/m_at_286_386sx.c b/src/machine/m_at_286_386sx.c index 1197b7d99..1a0db4d98 100644 --- a/src/machine/m_at_286_386sx.c +++ b/src/machine/m_at_286_386sx.c @@ -35,6 +35,7 @@ #include <86box/rom.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/hdc.h> #include <86box/sio.h> #include <86box/serial.h> @@ -672,47 +673,6 @@ machine_at_pja511m_init(const machine_t *model) } #endif - - -static uint8_t -m290_read(uint16_t port, void *priv) -{ - uint8_t ret = 0x0; - switch (port) { - /* - * port 69: - * dip-switch bank on mainboard (off=1) - * bit 3 - use OCG/CGA display adapter (off) / other display adapter (on) - */ - case 0x69: - if(video_is_cga()) - ret |= 0x8|0x4; - ret |= 0x1|0x2; - } - return (ret); -} - -int -machine_at_olim290_init(const machine_t *model) -{ - int ret; - - ret = bios_load_linear(L"roms/machines/olivetti_m290/m290_pep3_1.25.bin", - 0x000f0000, 65536, 0); - - if (bios_only || !ret) - return ret; - - machine_at_common_init(model); - device_add(&keyboard_at_device); - device_add(&fdc_at_device); - - io_sethandler(0x069, 1, m290_read, NULL, NULL, NULL, NULL, NULL, NULL); - - return ret; -} - - /* * Current bugs: * - ctrl-alt-del produces an 8042 error @@ -766,3 +726,108 @@ machine_at_ncr3302_init(const machine_t *model) return ret; } + +/* + * Current bugs: + * - soft-reboot after saving CMOS settings/pressing ctrl-alt-del produces an 8042 error + */ +int +machine_at_ncrpc916sx_init(const machine_t *model) +{ + int ret; + + ret = bios_load_interleaved(L"roms/machines/ncr_pc916sx/ncr_386sx_u46-17_7.3.bin", + L"roms/machines/ncr_pc916sx/ncr_386sx_u12-19_7.3.bin", + 0x000f0000, 65536, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init(model); + + device_add(&keyboard_at_ncr_device); + mem_remap_top(384); + + device_add(&fdc_at_device); + + return ret; +} + +#if defined(DEV_BRANCH) && defined(USE_OLIVETTI) +int +machine_at_olim290_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/olivetti_m290/m290_pep3_1.25.bin", + 0x000f0000, 65536, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init(model); + device_add(&keyboard_at_olivetti_device); + + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); + + device_add(&olivetti_eva_device); + + return ret; +} +#endif + +const device_t * +at_m300_08_get_device(void) +{ + return &oti067_m300_device; +} + +int +machine_at_olim300_08_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/olivetti_m300_08/BIOS.ROM", + 0x000f0000, 65536, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init(model); + + device_add(&opti283_device); + device_add(&keyboard_ps2_olivetti_device); + device_add(&pc87310_ide_device); + + if (gfxcard == VID_INTERNAL) + device_add(&oti067_m300_device); + + return ret; +} + +/* Almost identical to M300-08, save for CPU speed, VRAM, and BIOS identification string */ +int +machine_at_olim300_15_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear(L"roms/machines/olivetti_m300_15/BIOS.ROM", + 0x000f0000, 65536, 0); + + if (bios_only || !ret) + return ret; + + machine_at_common_init(model); + + device_add(&opti283_device); + device_add(&keyboard_ps2_olivetti_device); + device_add(&pc87310_ide_device); + + /* Stock VRAM is maxed out, so no need to expose video card config */ + if (gfxcard == VID_INTERNAL) + device_add(&oti067_m300_device); + + return ret; +} + diff --git a/src/machine/m_xt_philips.c b/src/machine/m_xt_philips.c index 722b117ee..11af6835d 100644 --- a/src/machine/m_xt_philips.c +++ b/src/machine/m_xt_philips.c @@ -46,8 +46,6 @@ typedef struct uint8_t reg; } philips_t; -#define ENABLE_philips_LOG 1 - #ifdef ENABLE_philips_LOG int philips_do_log = ENABLE_philips_LOG; static void diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index b0db65429..959962e1d 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -122,6 +122,9 @@ const machine_t machines[] = { { "[ISA] Compaq Portable III", "portableiii", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_VIDEO, 640, 16384, 128, 127, machine_at_portableiii_init, at_cpqiii_get_device }, { "[ISA] MR 286 clone", "mr286", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_IDE, 512, 16384, 128, 127, machine_at_mr286_init, NULL }, { "[ISA] NCR PC8/810/710/3390/3392", "ncr_pc8", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 512, 16384, 128, 127, machine_at_ncrpc8_init, NULL }, +#if defined(DEV_BRANCH) && defined(USE_OLIVETTI) + { "[ISA] Olivetti M290", "olivetti_m290", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 640, 16384, 128, 127, machine_at_olim290_init, NULL }, +#endif #if defined(DEV_BRANCH) && defined(USE_OPEN_AT) { "[ISA] OpenAT", "open_at", MACHINE_TYPE_286, CPU_PKG_286, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 256, 15872, 128, 63, machine_at_open_at_init, NULL }, #endif @@ -149,6 +152,7 @@ const machine_t machines[] = { /* 386SX machines */ { "[ISA] IBM PS/1 model 2121", "ibmps1_2121", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO_FIXED, 2048, 6144,1024, 63, machine_ps1_m2121_init, NULL }, { "[ISA] IBM PS/1 m.2121+ISA", "ibmps1_2121_isa", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 6144,1024, 63, machine_ps1_m2121_init, NULL }, + { "[ISA] NCR PC916SX", "ncr_pc916sx", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 1024, 16384, 128, 127, machine_at_ncrpc916sx_init, NULL }, #if defined(DEV_BRANCH) && defined(USE_M6117) { "[ALi M6117D] Acrosser AR-B1375", "arb1375", MACHINE_TYPE_386SX, CPU_PKG_M6117, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE, 1024, 32768,1024, 127, machine_at_arb1375_init, NULL }, { "[ALi M6117D] Acrosser PJ-A511M", "pja511m", MACHINE_TYPE_386SX, CPU_PKG_M6117, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE, 1024, 32768,1024, 127, machine_at_pja511m_init, NULL }, @@ -159,6 +163,8 @@ const machine_t machines[] = { { "[Intel 82335] Shuttle 386SX", "shuttle386sx", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 512, 8192, 128, 127, machine_at_shuttle386sx_init, NULL }, { "[NEAT] Commodore SL386SX-16", "cbm_sl386sx16", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE, 1024, 8192, 512, 127, machine_at_commodore_sl386sx16_init, NULL }, { "[NEAT] DTK 386SX clone", "dtk386", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 512, 8192, 128, 127, machine_at_neat_init, NULL }, + { "[OPTi 283] Olivetti M300-08", "olivetti_m300_08", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 20000000, 20000000, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 16384, 2048, 127, machine_at_olim300_08_init, at_m300_08_get_device }, + { "[OPTi 283] Olivetti M300-15", "olivetti_m300_15", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 25000000, 25000000, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 16384, 2048, 127, machine_at_olim300_15_init, NULL }, { "[OPTi 291] DTK PPM-3333P", "awardsx", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT, 1024, 16384, 1024, 127, machine_at_awardsx_init, NULL }, { "[SCAMP] Commodore SL386SX-25", "cbm_sl386sx25", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 1024, 8192, 512, 127, machine_at_commodore_sl386sx25_init, at_commodore_sl386sx25_get_device }, { "[SCAMP] Samsung SPC-6033P", "spc6033p", MACHINE_TYPE_386SX, CPU_PKG_386SX, 0, 0, 0, 0, 0, 0, 0, MACHINE_AT | MACHINE_BUS_PS2 | MACHINE_IDE | MACHINE_VIDEO, 2048, 12288, 2048, 127, machine_at_spc6033p_init, at_spc6033p_get_device }, diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index db72f9bb7..282f1998f 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -102,6 +102,9 @@ ifeq ($(DEV_BUILD), y) ifndef USE_VECT486VL USE_VECT486VL := y endif + ifndef OLIVETTI + OLIVETTI := y + endif else ifndef DEBUG DEBUG := n @@ -178,6 +181,9 @@ else ifndef USE_VECT486VL USE_VECT486VL := n endif + ifndef OLIVETTI + OLIVETTI := n + endif endif # Defaults for several build options (possibly defined in a chained file.) @@ -586,6 +592,11 @@ ifeq ($(USE_VECT486VL), y) OPTS += -DUSE_VECT486VL endif +ifeq ($(OLIVETTI), y) +OPTS += -DUSE_OLIVETTI +endif + + endif @@ -620,6 +631,7 @@ CHIPSETOBJ := acc2168.o cs8230.o ali1217.o ali1429.o headland.o intel_82335.o cs neat.o opti495.o opti895.o opti5x7.o scamp.o scat.o via_vt82c49x.o via_vt82c505.o \ sis_85c310.o sis_85c4xx.o sis_85c496.o sis_85c50x.o opti283.o opti291.o \ gc100.o \ + olivetti_eva.o \ via_apollo.o via_pipc.o wd76c10.o vl82c480.o MCHOBJ := machine.o machine_table.o \