diff --git a/src/config.c b/src/config.c index 65d0cd2e4..e1d0ad6d4 100644 --- a/src/config.c +++ b/src/config.c @@ -47,6 +47,7 @@ #include <86box/hdc_ide.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/machine.h> #include <86box/mouse.h> @@ -783,6 +784,12 @@ load_other_peripherals(void) else scsi_card_current = 0; + p = config_get_string(cat, "fdc", NULL); + if (p != NULL) + fdc_type = fdc_card_get_from_internal_name(p); + else + fdc_type = FDC_INTERNAL; + p = config_get_string(cat, "hdc", NULL); if (p == NULL) { if (machines[machine].flags & MACHINE_HDC) { @@ -1744,6 +1751,12 @@ save_other_peripherals(void) config_set_string(cat, "scsicard", scsi_card_get_internal_name(scsi_card_current)); + if (fdc_type == FDC_INTERNAL) + config_delete_var(cat, "fdc"); + else + config_set_string(cat, "fdc", + fdc_card_get_internal_name(fdc_type)); + config_set_string(cat, "hdc", hdc_get_internal_name(hdc_current)); diff --git a/src/cpu/cpu_table.c b/src/cpu/cpu_table.c index 82f99b3ab..71df19605 100644 --- a/src/cpu/cpu_table.c +++ b/src/cpu/cpu_table.c @@ -186,6 +186,7 @@ CPU cpus_i386DX[] = { {"", -1, 0, 0, 0, 0, 0, 0, 0,0,0,0, 0} }; + CPU cpus_Am386SX[] = { /*Am386SX*/ {"Am386SX/16", CPU_386SX, fpus_80386, 16000000, 1, 0x2308, 0, 0, 0, 3,3,3,3, 2}, diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 66e665f76..189f3d678 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -35,6 +35,7 @@ #include <86box/ui.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> extern uint64_t motoron[FDD_NUM]; @@ -89,6 +90,9 @@ int lastbyte=0; int floppymodified[4]; int floppyrate[4]; + +int fdc_type = 0; + #ifdef ENABLE_FDC_LOG int fdc_do_log = ENABLE_FDC_LOG; @@ -110,6 +114,85 @@ fdc_log(const char *fmt, ...) #endif +typedef const struct { + const char *name; + const char *internal_name; + const device_t *device; +} fdc_cards_t; + +/* All emulated machines have at least one integrated FDC controller */ +static fdc_cards_t fdc_cards[] = { + { "Internal controller", "internal", NULL, }, + { "DTK PII-151B", "dtk_pii151b", &fdc_pii151b_device, }, + { "DTK PII-158B", "dtk_pii158b", &fdc_pii158b_device, }, + { "", "", NULL, }, +}; + +int +fdc_card_available(int card) +{ + if (fdc_cards[card].device) + return(device_available(fdc_cards[card].device)); + + return(1); +} + + +char * +fdc_card_getname(int card) +{ + return((char *) fdc_cards[card].name); +} + + +const device_t * +fdc_card_getdevice(int card) +{ + return(fdc_cards[card].device); +} + + +int +fdc_card_has_config(int card) +{ + if (! fdc_cards[card].device) return(0); + + return(fdc_cards[card].device->config ? 1 : 0); +} + + +char * +fdc_card_get_internal_name(int card) +{ + return((char *) fdc_cards[card].internal_name); +} + + +int +fdc_card_get_from_internal_name(char *s) +{ + int c = 0; + + while (strlen((char *) fdc_cards[c].internal_name)) { + if (!strcmp((char *) fdc_cards[c].internal_name, s)) + return(c); + c++; + } + + return(0); +} + + +void +fdc_card_init(void) +{ + if (!fdc_cards[fdc_type].device) + return; + + device_add(fdc_cards[fdc_type].device); +} + + uint8_t fdc_get_current_drive(void) { @@ -2138,7 +2221,6 @@ fdc_init(const device_t *info) memset(fdc, 0, sizeof(fdc_t)); fdc->flags = info->local; - fdc_reset(fdc); fdc->irq = 6; @@ -2271,3 +2353,13 @@ const device_t fdc_at_nsc_device = { fdc_reset, NULL, NULL, NULL }; + +const device_t fdc_dp8473_device = { + "NS DP8473 Floppy Drive Controller", + 0, + FDC_FLAG_NSDP, + fdc_init, + fdc_close, + fdc_reset, + NULL, NULL, NULL +}; diff --git a/src/floppy/fdc_pii15xb.c b/src/floppy/fdc_pii15xb.c new file mode 100644 index 000000000..55dd55460 --- /dev/null +++ b/src/floppy/fdc_pii15xb.c @@ -0,0 +1,208 @@ +/* + * 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 + * 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. + * + * 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, + * + * Copyright 2019 Fred N. van Kempen. + * + * 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. + * + * 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. + * + * 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 + * 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 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#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" + +typedef struct { + const char *name; + int type; + + 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) +{ + uint32_t temp; + FILE *fp; + + /* 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); +} + + +static void +pii_close(void *priv) +{ + pii_t *dev = (pii_t *)priv; + + free(dev); +} + + +static void * +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; + + 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; + } + } + + /* Attach the DP8473 chip. */ + dev->fdc = device_add(&fdc_at_device); + + //pclog("FDC: %s (I/O=%04X, flags=%08x)\n", + // info->name, dev->fdc->base_address, dev->fdc->flags); + + return(dev); +} + +static int pii_151b_available(void) +{ + return rom_present(ROM_PII_151B); +} + +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, + { + { + "Disabled", 0 + }, + { + "CA00H", 0x0ca000 + }, + { + "CC00H", 0x0cc000 + }, + { + "CE00H", 0x0ce000 + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + +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 +}; + +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 +}; diff --git a/src/include/86box/config.h b/src/include/86box/config.h index 969bc2489..1a82a0879 100644 --- a/src/include/86box/config.h +++ b/src/include/86box/config.h @@ -117,7 +117,8 @@ typedef struct { parallel_enabled[3]; /* LPT1, LPT2, LPT3 enabled */ /* Other peripherals category */ - int hdc, /* Hard disk controller */ + int fdc_type, /* Floppy disk controller type */ + hdc, /* Hard disk controller */ scsi_card, /* SCSI controller */ ide_ter_enabled, /* Tertiary IDE controller enabled */ ide_qua_enabled, /* Quaternary IDE controller enabled */ diff --git a/src/include/86box/fdc.h b/src/include/86box/fdc.h index cae83896a..56249069b 100644 --- a/src/include/86box/fdc.h +++ b/src/include/86box/fdc.h @@ -22,6 +22,7 @@ #ifndef EMU_FDC_H # define EMU_FDC_H +extern int fdc_type; #define FDC_FLAG_PCJR 0x01 /* PCjr */ #define FDC_FLAG_DISKCHG_ACTLOW 0x02 /* Amstrad, PS/1, PS/2 ISA */ @@ -33,6 +34,7 @@ #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 { @@ -178,7 +180,7 @@ extern const device_t fdc_at_ps1_device; extern const device_t fdc_at_smc_device; extern const device_t fdc_at_winbond_device; extern const device_t fdc_at_nsc_device; +extern const device_t fdc_dp8473_device; #endif - #endif /*EMU_FDC_H*/ diff --git a/src/include/86box/fdc_ext.h b/src/include/86box/fdc_ext.h new file mode 100644 index 000000000..1e10e4b7a --- /dev/null +++ b/src/include/86box/fdc_ext.h @@ -0,0 +1,42 @@ +/* + * 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 NEC uPD-765 and compatible floppy disk + * controller. + * + * + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2020 Sarah Walker. + * Copyright 2016-2020 Miran Grca. + * Copyright 2018-2020 Fred N. van Kempen. + */ +#ifndef EMU_FDC_EXT_H +# define EMU_FDC_EXT_H + +extern int fdc_type; + +/* Controller types. */ +#define FDC_INTERNAL 0 + +extern const device_t fdc_pii151b_device; +extern const device_t fdc_pii158b_device; + +extern void fdc_card_init(void); + +extern char *fdc_card_getname(int card); +extern char *fdc_card_get_internal_name(int card); +extern int fdc_card_get_from_internal_name(char *s); +extern const device_t *fdc_card_getdevice(int card); +extern int fdc_card_has_config(int card); +extern int fdc_card_available(int card); + +#endif /*EMU_FDC_H*/ diff --git a/src/include/86box/language.h b/src/include/86box/language.h index b95f692f7..d5a6d9b8f 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -91,6 +91,7 @@ #define IDS_2115 2115 // "MO %i (%03i): %ls" #define IDS_2116 2116 // "MO images (*.IM?)\0*.IM..." #define IDS_2117 2117 // "Welcome to 86Box!" +#define IDS_2118 2118 // "Internal controller" #define IDS_4096 4096 // "Hard disk (%s)" #define IDS_4097 4097 // "%01i:%01i" @@ -169,7 +170,7 @@ #define IDS_LANG_ENUS IDS_7168 -#define STR_NUM_2048 70 +#define STR_NUM_2048 71 #define STR_NUM_3072 11 #define STR_NUM_4096 18 #define STR_NUM_4352 7 diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 1d91905f9..98e1ad1d3 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -40,6 +40,7 @@ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_SOUND 0x010000 /* sys has int sound */ #define MACHINE_NONMI 0x020000 /* sys does not have NMI's */ +#define MACHINE_FDC 0x040000 /* sys has int FDC */ #else #define MACHINE_PC 0x000000 /* PC architecture */ #define MACHINE_AT 0x000001 /* PC/AT architecture */ @@ -57,6 +58,7 @@ #define MACHINE_MOUSE 0x008000 /* sys has int mouse */ #define MACHINE_SOUND 0x010000 /* sys has int sound */ #define MACHINE_NONMI 0x020000 /* sys does not have NMI's */ +#define MACHINE_FDC 0x040000 /* sys has int FDC */ #endif #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 7c225fe00..afcb33e5b 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -99,6 +99,7 @@ #define IDT_1765 1765 /* Board #3: */ #define IDT_1766 1766 /* Board #4: */ #define IDT_1767 1767 /* ISA RTC: */ +#define IDT_1768 1768 /* Ext FD Controller: */ /* @@ -180,6 +181,8 @@ #define IDC_CHECK_POSTCARD 1130 #define IDC_COMBO_ISARTC 1131 #define IDC_CONFIGURE_ISARTC 1132 +#define IDC_COMBO_FDC 1133 +#define IDC_CONFIGURE_FDC 1134 #define IDC_GROUP_ISAMEM 1140 #define IDC_COMBO_ISAMEM_1 1141 #define IDC_COMBO_ISAMEM_2 1142 diff --git a/src/include/86box/scsi_x54x.h b/src/include/86box/scsi_x54x.h index 175fdfe6c..6c8164902 100644 --- a/src/include/86box/scsi_x54x.h +++ b/src/include/86box/scsi_x54x.h @@ -423,7 +423,7 @@ typedef struct { PendingInterrupt, Lock, target_data_len, pad0; - uint32_t Base, rom_addr, /* address of BIOS ROM */ + uint32_t Base, fdc_address, rom_addr, /* address of BIOS ROM */ CmdParamLeft, Outgoing, transfer_size; @@ -486,6 +486,8 @@ typedef struct { pc_timer_t timer, ResetCB; Req_t Req; + + fdc_t *fdc; } x54x_t; diff --git a/src/machine/m_at.c b/src/machine/m_at.c index 90f4fc40c..7adc98ecd 100644 --- a/src/machine/m_at.c +++ b/src/machine/m_at.c @@ -49,6 +49,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/nvr.h> #include <86box/gameport.h> #include <86box/keyboard.h> @@ -102,7 +103,8 @@ machine_at_ibm_common_init(const machine_t *model) mem_remap_top(384); - device_add(&fdc_at_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); } diff --git a/src/machine/m_at_compaq.c b/src/machine/m_at_compaq.c index 7cd3f254e..aed26a6f6 100644 --- a/src/machine/m_at_compaq.c +++ b/src/machine/m_at_compaq.c @@ -33,6 +33,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/machine.h> @@ -45,7 +46,8 @@ enum { COMPAQ_PORTABLEII = 0, COMPAQ_PORTABLEIII, - COMPAQ_PORTABLEIII386 + COMPAQ_PORTABLEIII386, + COMPAQ_DESKPRO386 }; #define CGA_RGB 0 @@ -809,9 +811,11 @@ machine_at_compaq_init(const machine_t *model, int type) { machine_at_init(model); - mem_remap_top(384); + if (type != COMPAQ_DESKPRO386) + mem_remap_top(384); - device_add(&fdc_at_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_at_device); mem_mapping_add(&ram_mapping, 0xfa0000, 0x60000, read_ram, read_ramw, read_raml, @@ -833,6 +837,11 @@ machine_at_compaq_init(const machine_t *model, int type) if (gfxcard == VID_INTERNAL) device_add(&compaq_plasma_device); break; + + case COMPAQ_DESKPRO386: + if (hdc_current == 1) + device_add(&ide_isa_device); + break; } } diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index 3fee77bba..26777dc77 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -35,6 +35,7 @@ #include <86box/nvr.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> #include <86box/sound.h> @@ -1495,7 +1496,8 @@ machine_tandy1k_init(const machine_t *model, int type) device_add(&keyboard_tandy_device); keyboard_set_table(scancode_tandy); - device_add(&fdc_xt_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); switch(type) { case TYPE_TANDY: @@ -1524,6 +1526,7 @@ machine_tandy1k_init(const machine_t *model, int type) device_add_ex(&vid_device_sl, dev); device_add(&pssj_device); device_add(&eep_1000sl2_device); + break; } if (joystick_type != JOYSTICK_TYPE_NONE) diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 3fb30eab6..2f55040e6 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -10,6 +10,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/ibm_5161.h> #include <86box/keyboard.h> @@ -24,7 +25,9 @@ machine_xt_common_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); - device_add(&fdc_xt_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); + nmi_init(); if (joystick_type != JOYSTICK_TYPE_NONE) device_add(&gameport_device); diff --git a/src/machine/m_xt_compaq.c b/src/machine/m_xt_compaq.c index 575500ffb..1b84a10de 100644 --- a/src/machine/m_xt_compaq.c +++ b/src/machine/m_xt_compaq.c @@ -31,6 +31,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> #include <86box/lpt.h> @@ -53,7 +54,8 @@ machine_xt_compaq_init(const machine_t *model) pit_ctr_set_out_func(&pit->counters[1], pit_refresh_timer_xt); device_add(&keyboard_xt_compaq_device); - device_add(&fdc_xt_device); + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); nmi_init(); if (joystick_type != JOYSTICK_TYPE_NONE) device_add(&gameport_device); diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c index 0d527d20b..c0448bd09 100644 --- a/src/machine/m_xt_zenith.c +++ b/src/machine/m_xt_zenith.c @@ -36,6 +36,7 @@ #include <86box/device.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/gameport.h> #include <86box/keyboard.h> #include <86box/lpt.h> @@ -116,8 +117,10 @@ machine_xt_zenith_init(const machine_t *model) return ret; machine_common_init(model); - - device_add(&fdc_xt_device); + + if (fdc_type == FDC_INTERNAL) + device_add(&fdc_xt_device); + lpt1_remove(); /* only one parallel port */ lpt2_remove(); lpt1_init(0x278); diff --git a/src/pc.c b/src/pc.c index e720cf529..6b1d57ce0 100644 --- a/src/pc.c +++ b/src/pc.c @@ -59,6 +59,7 @@ #include <86box/gameport.h> #include <86box/fdd.h> #include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/hdd.h> #include <86box/hdc.h> #include <86box/hdc_ide.h> @@ -747,6 +748,8 @@ pc_reset_hard_init(void) /* Reset any ISA RTC cards. */ isartc_reset(); + + fdc_card_init(); fdd_reset(); diff --git a/src/scsi/scsi_aha154x.c b/src/scsi/scsi_aha154x.c index e8342ad90..8e50864e1 100644 --- a/src/scsi/scsi_aha154x.c +++ b/src/scsi/scsi_aha154x.c @@ -36,6 +36,8 @@ #include <86box/dma.h> #include <86box/pic.h> #include <86box/plat.h> +#include <86box/fdd.h> +#include <86box/fdc.h> #include <86box/scsi.h> #include <86box/scsi_aha154x.h> #include <86box/scsi_x54x.h> @@ -187,6 +189,13 @@ aha154x_eeprom(x54x_t *dev, uint8_t cmd,uint8_t arg,uint8_t len,uint8_t off,uint r = 0; aha_eeprom_save(dev); + + if (dev->type == AHA_154xCF) { + if (dev->fdc_address > 0) { + fdc_remove(dev->fdc); + fdc_set_base(dev->fdc, dev->fdc_address); + } + } } if (cmd == 0x23) { @@ -702,6 +711,8 @@ aha_initnvr(x54x_t *dev) /* Initialize the on-board EEPROM. */ dev->nvr[0] = dev->HostID; /* SCSI ID 7 */ dev->nvr[0] |= (0x10 | 0x20 | 0x40); + if (dev->fdc_address == 0x370) + dev->nvr[0] |= EE0_ALTFLOP; dev->nvr[1] = dev->Irq-9; /* IRQ15 */ dev->nvr[1] |= (dev->DmaChannel<<4); /* DMA6 */ dev->nvr[2] = (EE2_HABIOS | /* BIOS enabled */ @@ -757,6 +768,10 @@ aha_init(const device_t *info) dev->Irq = device_get_config_int("irq"); dev->DmaChannel = device_get_config_int("dma"); dev->rom_addr = device_get_config_hex20("bios_addr"); + if (!(dev->bus & DEVICE_MCA)) + dev->fdc_address = device_get_config_hex16("fdc_addr"); + else + dev->fdc_address = 0; dev->HostID = 7; /* default HA ID */ dev->setup_info_len = sizeof(aha_setup_t); dev->max_id = 7; @@ -834,6 +849,8 @@ aha_init(const device_t *info) dev->ven_get_irq = aha_get_irq; /* function to return IRQ from EEPROM */ dev->ven_get_dma = aha_get_dma; /* function to return DMA channel from EEPROM */ dev->ha_bps = 10000000.0; /* fast SCSI */ + if (dev->fdc_address > 0) + dev->fdc = device_add(&fdc_at_device); break; case AHA_154xCP: @@ -1022,7 +1039,6 @@ static const device_config_t aha_154xb_config[] = { } }; - static const device_config_t aha_154x_config[] = { { "base", "Address", CONFIG_HEX16, "", 0x334, @@ -1122,6 +1138,122 @@ static const device_config_t aha_154x_config[] = { }; +static const device_config_t aha_154xcf_config[] = { + { + "base", "Address", CONFIG_HEX16, "", 0x334, + { + { + "None", 0 + }, + { + "0x330", 0x330 + }, + { + "0x334", 0x334 + }, + { + "0x230", 0x230 + }, + { + "0x234", 0x234 + }, + { + "0x130", 0x130 + }, + { + "0x134", 0x134 + }, + { + "" + } + }, + }, + { + "irq", "IRQ", CONFIG_SELECTION, "", 9, + { + { + "IRQ 9", 9 + }, + { + "IRQ 10", 10 + }, + { + "IRQ 11", 11 + }, + { + "IRQ 12", 12 + }, + { + "IRQ 14", 14 + }, + { + "IRQ 15", 15 + }, + { + "" + } + }, + }, + { + "dma", "DMA channel", CONFIG_SELECTION, "", 6, + { + { + "DMA 5", 5 + }, + { + "DMA 6", 6 + }, + { + "DMA 7", 7 + }, + { + "" + } + }, + }, + { + "bios_addr", "BIOS Address", CONFIG_HEX20, "", 0, + { + { + "Disabled", 0 + }, + { + "C800H", 0xc8000 + }, + { + "D000H", 0xd0000 + }, + { + "D800H", 0xd8000 + }, + { + "" + } + }, + }, + { + "fdc_addr", "FDC address", CONFIG_HEX16, "", 0, + { + { + "None", 0 + }, + { + "0x3f0", 0x3f0 + }, + { + "0x370", 0x370 + }, + { + "" + } + }, + }, + { + "", "", -1 + } +}; + + const device_t aha154xa_device = { "Adaptec AHA-154xA", DEVICE_ISA | DEVICE_AT, @@ -1155,7 +1287,7 @@ const device_t aha154xcf_device = { AHA_154xCF, aha_init, x54x_close, NULL, NULL, NULL, NULL, - aha_154x_config + aha_154xcf_config }; const device_t aha1640_device = { diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 71529ef32..a3e7b6161 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -37,6 +37,8 @@ #include <86box/device.h> #include <86box/nvr.h> #include <86box/dma.h> +#include <86box/fdd.h> +#include <86box/fdc.h> #include <86box/pic.h> #include <86box/pci.h> #include <86box/plat.h> diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 0f301abdf..a3e8d2f0d 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -38,6 +38,8 @@ #include <86box/mem.h> #include <86box/rom.h> #include <86box/device.h> +#include <86box/fdd.h> +#include <86box/fdc.h> #include <86box/nvr.h> #include <86box/plat.h> #include <86box/scsi.h> diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 9370caf34..4ca9269a6 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -551,7 +551,12 @@ BEGIN LTEXT "#4:",IDT_1766,12,172,21,10 COMBOBOX IDC_COMBO_ISAMEM_4,25,171,190,120, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12 + PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12 + + LTEXT "FDC Controller:",IDT_1768,7,190,48,10 + COMBOBOX IDC_COMBO_FDC,64,189,155,120,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Configure",IDC_CONFIGURE_FDC,217,189,38,12 END DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 @@ -963,6 +968,7 @@ BEGIN IDS_2115 "MO %i (%03i): %ls" IDS_2116 "MO images (*.IM?)\0*.IM?\0All files (*.*)\0*.*\0" IDS_2117 "Welcome to 86Box!" + IDS_2118 "Internal controller" END STRINGTABLE DISCARDABLE diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 7511ba61c..3d48ac37a 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -598,7 +598,8 @@ SIOOBJ := sio_acc3221.o \ sio_w83877f.o sio_w83977f.o \ sio_um8669f.o -FDDOBJ := fdd.o fdc.o fdi2raw.o \ +FDDOBJ := fdd.o fdc.o fdc_pii15xb.o \ + fdi2raw.o \ fdd_common.o fdd_86f.o \ fdd_fdi.o fdd_imd.o fdd_img.o fdd_json.o \ fdd_mfm.o fdd_td0.o diff --git a/src/win/win_settings.c b/src/win/win_settings.c index cf3304427..3ddd0dffb 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -52,6 +52,8 @@ #include <86box/hdc_ide.h> #include <86box/zip.h> #include <86box/fdd.h> +#include <86box/fdc.h> +#include <86box/fdc_ext.h> #include <86box/network.h> #include <86box/sound.h> #include <86box/midi.h> @@ -95,7 +97,7 @@ static int temp_lpt_devices[3]; static int temp_serial[2], temp_lpt[3]; /* Other peripherals category */ -static int temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua; +static int temp_fdc_card, temp_hdc, temp_scsi_card, temp_ide_ter, temp_ide_qua; static int temp_bugger; static int temp_postcard; static int temp_isartc; @@ -123,6 +125,7 @@ extern int is486; static int listtomachinetype[256], machinetypetolist[256]; static int listtomachine[256], machinetolist[256]; static int settings_device_to_list[2][20], settings_list_to_device[2][20]; +static int settings_fdc_to_list[2][20], settings_list_to_fdc[2][20]; static int settings_midi_to_list[20], settings_list_to_midi[20]; static int settings_midi_in_to_list[20], settings_list_to_midi_in[20]; @@ -247,6 +250,7 @@ win_settings_init(void) /* Other peripherals category */ temp_scsi_card = scsi_card_current; + temp_fdc_card = fdc_type; temp_hdc = hdc_current; temp_ide_ter = ide_ter_enabled; temp_ide_qua = ide_qua_enabled; @@ -356,6 +360,7 @@ win_settings_changed(void) /* Peripherals category */ i = i || (scsi_card_current != temp_scsi_card); + i = i || (fdc_type != temp_fdc_card); i = i || (hdc_current != temp_hdc); i = i || (temp_ide_ter != ide_ter_enabled); i = i || (temp_ide_qua != ide_qua_enabled); @@ -462,6 +467,7 @@ win_settings_save(void) /* Peripherals category */ scsi_card_current = temp_scsi_card; hdc_current = temp_hdc; + fdc_type = temp_fdc_card; ide_ter_enabled = temp_ide_ter; ide_qua_enabled = temp_ide_qua; bugger_enabled = temp_bugger; @@ -1584,7 +1590,6 @@ win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } - static void recalc_hdc_list(HWND hdlg) { @@ -1641,6 +1646,7 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa char *stransi; const device_t *scsi_dev; const device_t *dev; + const device_t *fdc_dev; char *s; switch (message) { @@ -1657,6 +1663,43 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa else EnableWindow(h, FALSE); + + /*FD controller config*/ + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + c = d = 0; + while (1) { + char *s = fdc_card_getname(c); + + if (!s[0]) + break; + + settings_fdc_to_list[0][c] = d; + + if (fdc_card_available(c)) { + fdc_dev = fdc_card_getdevice(c); + + if (device_is_valid(fdc_dev, machines[temp_machine].flags)) { + if (c == 0) + SendMessage(h, CB_ADDSTRING, 0, win_get_string(IDS_2118)); + else { + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + settings_list_to_fdc[0][d] = c; + d++; + } + } + + c++; + } + SendMessage(h, CB_SETCURSEL, settings_fdc_to_list[0][temp_fdc_card], 0); + + EnableWindow(h, d ? TRUE : FALSE); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC); + EnableWindow(h, fdc_card_has_config(temp_fdc_card) ? TRUE : FALSE); + + /*SCSI config*/ h = GetDlgItem(hdlg, IDC_COMBO_SCSI); c = d = 0; @@ -1776,6 +1819,24 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa case WM_COMMAND: switch (LOWORD(wParam)) { + case IDC_CONFIGURE_FDC: + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + temp_fdc_card = settings_list_to_fdc[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; + + temp_deviceconfig |= deviceconfig_open(hdlg, (void *)fdc_card_getdevice(temp_fdc_card)); + break; + + case IDC_COMBO_FDC: + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + temp_fdc_card = settings_list_to_fdc[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; + + h = GetDlgItem(hdlg, IDC_CONFIGURE_FDC); + if (fdc_card_has_config(temp_fdc_card)) + EnableWindow(h, TRUE); + else + EnableWindow(h, FALSE); + break; + case IDC_CONFIGURE_HDC: lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR)); stransi = (char *) malloc(512); @@ -1903,6 +1964,9 @@ win_settings_peripherals_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPa wcstombs(stransi, lptsTemp, 512); temp_hdc = hdc_get_id(stransi); + h = GetDlgItem(hdlg, IDC_COMBO_FDC); + temp_fdc_card = settings_list_to_fdc[0][SendMessage(h, CB_GETCURSEL, 0, 0)]; + h = GetDlgItem(hdlg, IDC_COMBO_SCSI); temp_scsi_card = settings_list_to_device[0][SendMessage(h, CB_GETCURSEL, 0, 0)];