From 5ef085253178bb99c85cbb7ac15d7ad5c5db686b Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sat, 30 Jan 2021 18:01:56 +0200 Subject: [PATCH 1/4] Adapt the DTK FDC to 86Box Rewrote few parts so the DTK FDC is more adaptive on 86Box standards. --- src/floppy/fdc_pii15xb.c | 111 ++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 65 deletions(-) diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index b85738129..5090f8307 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -21,7 +21,7 @@ * or without modification, are permitted provided that the * following conditions are met: * - * 1. Redistributions of source code must retain the entire + * 1. Redistributions of source code must retain the entire * above notice, this list of conditions and the following * disclaimer. * @@ -47,9 +47,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE -#define _GNU_SOURCE #include #include #include @@ -61,57 +58,45 @@ #include <86box/device.h> #include <86box/io.h> #include <86box/mem.h> -#include <86box/pic.h> #include <86box/rom.h> #include <86box/machine.h> #include <86box/timer.h> -#include <86box/plat.h> -#include <86box/ui.h> #include <86box/fdd.h> #include <86box/fdc.h> #include <86box/fdc_ext.h> -#define ROM_PII_151B L"roms/floppy/dtk/pii-151b.rom" -#define ROM_PII_158B L"roms/floppy/dtk/pii-158b.rom" +#define ROM_PII_151B L"roms/floppy/dtk/pii-151b.rom" +#define ROM_PII_158B L"roms/floppy/dtk/pii-158b.rom" -typedef struct { - const char *name; - int type; +#ifdef ENABLE_PII15XB_LOG +int pii15xb_do_log = ENABLE_PII15XB_LOG; - uint32_t bios_addr, - bios_size; - rom_t bios_rom; - - fdc_t *fdc; -} pii_t; - - -/* Load and enable a BIOS ROM if we have one, and is enabled. */ static void -set_bios(pii_t *dev, wchar_t *fn) +pii15xb_log(const char *fmt, ...) { - uint32_t temp; - FILE *fp; + va_list ap; - /* Only do this if needed. */ - if ((fn == NULL) || (dev->bios_addr == 0)) return; - - if ((fp = rom_fopen(fn, L"rb")) == NULL) return; - - (void)fseek(fp, 0L, SEEK_END); - temp = ftell(fp); - (void)fclose(fp); - - /* Assume 128K, then go down. */ - dev->bios_size = 0x020000; - while (temp < dev->bios_size) - dev->bios_size >>= 1; - - /* Create a memory mapping for the space. */ - rom_init(&dev->bios_rom, fn, dev->bios_addr, - dev->bios_size, dev->bios_size-1, 0, MEM_MAPPING_EXTERNAL); + if (fdc_do_log) + { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } } +#else +#define pii15xb_log(fmt, ...) +#endif +typedef struct +{ + const char *name; + int type; + + uint32_t bios_addr; + rom_t bios_rom; + + fdc_t *fdc; +} pii_t; static void pii_close(void *priv) @@ -121,7 +106,6 @@ pii_close(void *priv) free(dev); } - static void * pii_init(const device_t *info) { @@ -133,24 +117,14 @@ pii_init(const device_t *info) dev->bios_addr = device_get_config_hex20("bios_addr"); - if (dev->bios_addr != 0x000000) { - switch (dev->type) { - case 151: - set_bios(dev, ROM_PII_151B); - break; - case 158: - set_bios(dev, ROM_PII_158B); - break; - } - } + if (dev->bios_addr != 0) + rom_init(&dev->bios_rom, (dev->type == 0x158) ? ROM_PII_158B : ROM_PII_151B, dev->bios_addr, 0x2000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL); - /* Attach the DP8473 chip. */ - dev->fdc = device_add(&fdc_at_device); + dev->fdc = device_add(&fdc_at_device); //Our DP8473 emulation is broken. If fixed this has to be changed! - //pclog("FDC: %s (I/O=%04X, flags=%08x)\n", - // info->name, dev->fdc->base_address, dev->fdc->flags); + pii15xb_log("PII15XB: %s (I/O=%04X, flags=%08x)\n", info->name, dev->fdc->base_address, dev->fdc->flags); - return(dev); + return (dev); } static int pii_151b_available(void) @@ -163,6 +137,7 @@ static int pii_158_available(void) return rom_present(ROM_PII_158B); } + static const device_config_t pii_config[] = { { "bios_addr", "BIOS address", CONFIG_HEX20, "", 0x0ce000, "", { 0 }, @@ -193,16 +168,22 @@ const device_t fdc_pii151b_device = { "DTK PII-151B (MiniMicro) Floppy Drive Controller", DEVICE_ISA, 151, - pii_init, pii_close, NULL, - { pii_151b_available }, NULL, NULL, - pii_config -}; + pii_init, + pii_close, + NULL, + {pii_151b_available}, + NULL, + NULL, + pii_config}; const device_t fdc_pii158b_device = { "DTK PII-158B (MiniMicro4) Floppy Drive Controller", DEVICE_ISA, 158, - pii_init, pii_close, NULL, - { pii_158_available }, NULL, NULL, - pii_config -}; + pii_init, + pii_close, + NULL, + {pii_158_available}, + NULL, + NULL, + pii_config}; From 782d8d9c956c37787383d0abd187aab84f5cf8ca Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sat, 30 Jan 2021 18:24:47 +0200 Subject: [PATCH 2/4] Minor improvements and fixes on the DTK FDC's --- src/floppy/fdc_pii15xb.c | 49 ++++++++-------------------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index 5090f8307..b3f32a22e 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -65,37 +65,14 @@ #include <86box/fdc.h> #include <86box/fdc_ext.h> +#define DTK_VARIANT ((info->local == 158) ? ROM_PII_158B : ROM_PII_151B) +#define BIOS_ADDR (uint32_t)(device_get_config_hex20("bios_addr") & 0x000fffff) #define ROM_PII_151B L"roms/floppy/dtk/pii-151b.rom" #define ROM_PII_158B L"roms/floppy/dtk/pii-158b.rom" -#ifdef ENABLE_PII15XB_LOG -int pii15xb_do_log = ENABLE_PII15XB_LOG; - -static void -pii15xb_log(const char *fmt, ...) -{ - va_list ap; - - if (fdc_do_log) - { - va_start(ap, fmt); - pclog_ex(fmt, ap); - va_end(ap); - } -} -#else -#define pii15xb_log(fmt, ...) -#endif - typedef struct { - const char *name; - int type; - - uint32_t bios_addr; rom_t bios_rom; - - fdc_t *fdc; } pii_t; static void @@ -112,17 +89,12 @@ pii_init(const device_t *info) pii_t *dev; dev = (pii_t *)malloc(sizeof(pii_t)); - memset(dev, 0x00, sizeof(pii_t)); - dev->type = info->local; + memset(dev, 0, sizeof(pii_t)); - dev->bios_addr = device_get_config_hex20("bios_addr"); + if (BIOS_ADDR != 0) + rom_init(&dev->bios_rom, DTK_VARIANT, BIOS_ADDR, 0x2000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL); - if (dev->bios_addr != 0) - rom_init(&dev->bios_rom, (dev->type == 0x158) ? ROM_PII_158B : ROM_PII_151B, dev->bios_addr, 0x2000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL); - - dev->fdc = device_add(&fdc_at_device); //Our DP8473 emulation is broken. If fixed this has to be changed! - - pii15xb_log("PII15XB: %s (I/O=%04X, flags=%08x)\n", info->name, dev->fdc->base_address, dev->fdc->flags); + device_add(&fdc_at_device); /* Our DP8473 emulation is broken. If fixed this has to be changed! */ return (dev); } @@ -137,22 +109,21 @@ static int pii_158_available(void) return rom_present(ROM_PII_158B); } - static const device_config_t pii_config[] = { { - "bios_addr", "BIOS address", CONFIG_HEX20, "", 0x0ce000, "", { 0 }, + "bios_addr", "BIOS Address:", CONFIG_HEX20, "", 0xce000, "", { 0 }, { { "Disabled", 0 }, { - "CA00H", 0x0ca000 + "CA00H", 0xca000 }, { - "CC00H", 0x0cc000 + "CC00H", 0xcc000 }, { - "CE00H", 0x0ce000 + "CE00H", 0xce000 }, { "" From 1290fdb06504641d7d106507558a2b7c7dd05c74 Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 31 Jan 2021 13:09:42 +0200 Subject: [PATCH 3/4] Few more changes on the DTK FDC's DP8473 now uses the correct flags. Included few notes related to the DTK FDC. --- src/floppy/fdc.c | 2 +- src/floppy/fdc_pii15xb.c | 72 +++++++++++++++++++++++----------------- src/include/86box/fdc.h | 1 - 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index a48307b2f..8194d35f4 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -2426,7 +2426,7 @@ const device_t fdc_at_nsc_device = { const device_t fdc_dp8473_device = { "NS DP8473 Floppy Drive Controller", 0, - FDC_FLAG_NSDP, + FDC_FLAG_AT | FDC_FLAG_NSC, fdc_init, fdc_close, fdc_reset, diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c index b3f32a22e..1a6fc8fad 100644 --- a/src/floppy/fdc_pii15xb.c +++ b/src/floppy/fdc_pii15xb.c @@ -1,52 +1,63 @@ /* * VARCem Virtual ARchaeological Computer EMulator. * An emulator of (mostly) x86-based PC systems and devices, - * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly * spanning the era between 1981 and 1995. * * This file is part of the VARCem Project. * - * Implementation of the DTK PII-151B and PII-158B cards. + * Implementation of the DTK MiniMicro series of Floppy Disk Controllers. + * Original code from VARCem. Fully rewritten, fixed and improved for 86Box. * - * These are DP8473-based floppy controller ISA cards for XT - * class systems, and allow usage of standard and high-density - * drives on them. They have their own BIOS which takes over - * from the standard system BIOS. - * - * Author: Fred N. van Kempen, + * Author: Fred N. van Kempen, , + * Tiseno100 * * Copyright 2019 Fred N. van Kempen. + * Copyright 2021 Tiseno100 * - * Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that the + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the * following conditions are met: * * 1. Redistributions of source code must retain the entire - * above notice, this list of conditions and the following - * disclaimer. + * above notice, this list of conditions and the following + * disclaimer. * * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names - * of its contributors may be used to endorse or promote - * products derived from this software without specific - * prior written permission. + * 3. Neither the name of the copyright holder nor the names + * of its contributors may be used to endorse or promote + * products derived from this software without specific + * prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +/* +Notes: +VARCem uses the DP8473 for both floppy disk controllers. The statement though is wrong. + +MiniMicro 4 uses a Zilog Z0765A08PSC(Clone of the NEC 765) +MiniMicro 1 uses a National Semiconductor DP8473(Clone of the NEC 765 with additional NSC commands) + +Issues: +MiniMicro 4 WON'T WORK with XT machines. This statement has to be confirmed by someone with the real card itself. +MiniMicro 4 also won't work with the XT FDC which the Zilog claims to be. +*/ + #include #include #include @@ -66,6 +77,7 @@ #include <86box/fdc_ext.h> #define DTK_VARIANT ((info->local == 158) ? ROM_PII_158B : ROM_PII_151B) +#define DTK_CHIP ((info->local == 158) ? &fdc_at_device : &fdc_dp8473_device) #define BIOS_ADDR (uint32_t)(device_get_config_hex20("bios_addr") & 0x000fffff) #define ROM_PII_151B L"roms/floppy/dtk/pii-151b.rom" #define ROM_PII_158B L"roms/floppy/dtk/pii-158b.rom" @@ -94,9 +106,9 @@ pii_init(const device_t *info) if (BIOS_ADDR != 0) rom_init(&dev->bios_rom, DTK_VARIANT, BIOS_ADDR, 0x2000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL); - device_add(&fdc_at_device); /* Our DP8473 emulation is broken. If fixed this has to be changed! */ + device_add(DTK_CHIP); - return (dev); + return dev; } static int pii_151b_available(void) diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index 68d4ea0ce..b818258de 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -34,7 +34,6 @@ extern int fdc_type; #define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */ #define FDC_FLAG_TOSHIBA 0x100 /* T1000, T1200 */ #define FDC_FLAG_AMSTRAD 0x200 /* Non-AT Amstrad machines */ -#define FDC_FLAG_NSDP 0x400 /* DP8473N, DP8473V */ typedef struct { From 41c3dbc451e14d20d99dc8a7cb9e8d12a384fcf8 Mon Sep 17 00:00:00 2001 From: Panagiotis <58827426+tiseno100@users.noreply.github.com> Date: Sun, 31 Jan 2021 13:49:14 +0200 Subject: [PATCH 4/4] Added the Magitronic B215 Intended for just testing the XT FDC issues --- src/floppy/CMakeLists.txt | 2 +- src/floppy/fdc.c | 1 + src/floppy/fdc_magitronic.c | 99 +++++++++++++++++++++++++++++++++++++ src/include/86box/fdc_ext.h | 1 + src/win/Makefile.mingw | 2 +- 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 src/floppy/fdc_magitronic.c diff --git a/src/floppy/CMakeLists.txt b/src/floppy/CMakeLists.txt index a3039ddd5..75e7b5947 100644 --- a/src/floppy/CMakeLists.txt +++ b/src/floppy/CMakeLists.txt @@ -13,5 +13,5 @@ # Copyright 2020,2021 David Hrdlička. # -add_library(fdd OBJECT fdd.c fdc.c fdc_pii15xb.c fdi2raw.c fdd_common.c +add_library(fdd OBJECT fdd.c fdc.c fdc_magitronic.c fdc_pii15xb.c fdi2raw.c fdd_common.c fdd_86f.c fdd_fdi.c fdd_imd.c fdd_img.c fdd_json.c fdd_mfm.c fdd_td0.c) \ No newline at end of file diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 8194d35f4..459370724 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -109,6 +109,7 @@ typedef const struct { /* All emulated machines have at least one integrated FDC controller */ static fdc_cards_t fdc_cards[] = { { "internal", NULL }, + { "b215", &fdc_b215_device }, { "dtk_pii151b", &fdc_pii151b_device }, { "dtk_pii158b", &fdc_pii158b_device }, { "", NULL }, diff --git a/src/floppy/fdc_magitronic.c b/src/floppy/fdc_magitronic.c new file mode 100644 index 000000000..3b7ceb64d --- /dev/null +++ b/src/floppy/fdc_magitronic.c @@ -0,0 +1,99 @@ +/* + * 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 Magitronic B215 XT-FDC Controller. + * + * Authors: Tiseno100 + * + * Copyright 2021 Tiseno100 + * + */ + +#include +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/timer.h> +#include <86box/io.h> +#include <86box/device.h> +#include <86box/mem.h> +#include <86box/rom.h> +#include <86box/fdd.h> +#include <86box/fdc.h> +#include <86box/fdc_ext.h> + +#define ROM_B215 L"roms/floppy/magitronic/Magitronic B215 - BIOS ROM.bin" +#define ROM_ADDR (uint32_t)(device_get_config_hex20("bios_addr") & 0x000fffff) + +typedef struct +{ + fdc_t *fdc_controller; + rom_t rom; +} b215_t; + +static void +b215_close(void *priv) +{ + b215_t *dev = (b215_t *)priv; + + free(dev); +} + +static void * +b215_init(const device_t *info) +{ + b215_t *dev = (b215_t *)malloc(sizeof(b215_t)); + memset(dev, 0, sizeof(b215_t)); + + rom_init(&dev->rom, ROM_B215, ROM_ADDR, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); + + device_add(&fdc_at_device); + + return dev; +} + +static int b215_available(void) +{ + return rom_present(ROM_B215); +} + +static const device_config_t b215_config[] = { + { + "bios_addr", "BIOS Address:", CONFIG_HEX20, "", 0xca000, "", { 0 }, + { + { + "CA00H", 0xca000 + }, + { + "CC00H", 0xcc000 + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + +const device_t fdc_b215_device = { + "Magitronic B215", + DEVICE_ISA, + 0, + b215_init, + b215_close, + NULL, + {b215_available}, + NULL, + NULL, + b215_config}; diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h index a9aa000f3..c87786dc0 100644 --- a/src/include/86box/fdc_ext.h +++ b/src/include/86box/fdc_ext.h @@ -27,6 +27,7 @@ extern int fdc_type; /* Controller types. */ #define FDC_INTERNAL 0 +extern const device_t fdc_b215_device; extern const device_t fdc_pii151b_device; extern const device_t fdc_pii158b_device; diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 7b2488060..b4aaa599d 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -658,7 +658,7 @@ SIOOBJ := sio_acc3221.o \ sio_um8669f.o \ sio_vt82c686.o -FDDOBJ := fdd.o fdc.o fdc_pii15xb.o \ +FDDOBJ := fdd.o fdc.o fdc_magitronic.o fdc_pii15xb.o \ fdi2raw.o \ fdd_common.o fdd_86f.o \ fdd_fdi.o fdd_imd.o fdd_img.o fdd_json.o \