diff --git a/src/devices/disk/hdc.h b/src/devices/disk/hdc.h index 4938f26..df682ab 100644 --- a/src/devices/disk/hdc.h +++ b/src/devices/disk/hdc.h @@ -8,7 +8,7 @@ * * Definitions for the common disk controller handler. * - * Version: @(#)hdc.h 1.0.15 2019/02/24 + * Version: @(#)hdc.h 1.0.16 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,8 +46,8 @@ * least 7 devices, with each device being * able to support 8 units, but hey... */ -#define HDC_NONE 0 -#define HDC_INTERNAL 1 +#define HDC_NONE 0 /* no disk controller selected */ +#define HDC_INTERNAL 1 /* internal/onboard controller selected */ #ifdef __cplusplus diff --git a/src/devices/input/mouse.h b/src/devices/input/mouse.h index 0eacb7b..c769d2e 100644 --- a/src/devices/input/mouse.h +++ b/src/devices/input/mouse.h @@ -8,7 +8,7 @@ * * Definitions for the mouse driver. * - * Version: @(#)mouse.h 1.0.10 2019/04/09 + * Version: @(#)mouse.h 1.0.11 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -80,8 +80,9 @@ extern const device_t *mouse_get_device(int mouse); extern void *mouse_ps2_init(const device_t *, void *parent); extern const device_t mouse_logibus_device; -extern const device_t mouse_logibus_internal_device; +extern const device_t mouse_logibus_onboard_device; extern const device_t mouse_msinport_device; +extern const device_t mouse_msinport_onboard_device; #if 0 extern const device_t mouse_genibus_device; #endif @@ -101,6 +102,8 @@ extern void mouse_process(void); extern void mouse_set_poll(int (*f)(int,int,int,int,void *), void *); extern void mouse_poll(void); +extern void mouse_bus_set_irq(void *priv, int irq); + extern const char *mouse_get_name(int mouse); extern const char *mouse_get_internal_name(int mouse); extern int mouse_get_from_internal_name(const char *s); diff --git a/src/devices/input/mouse_bus.c b/src/devices/input/mouse_bus.c index 3ad28ef..2b8cc40 100644 --- a/src/devices/input/mouse_bus.c +++ b/src/devices/input/mouse_bus.c @@ -53,7 +53,7 @@ * Microsoft Windows NT 3.1 * Microsoft Windows 98 SE * - * Version: @(#)mouse_bus.c 1.1.6 2019/04/21 + * Version: @(#)mouse_bus.c 1.1.7 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -284,7 +284,8 @@ lt_write(uint16_t port, uint8_t val, void *priv) else dev->flags &= ~FLAG_HOLD; - picintc(1 << dev->irq); + if (dev->irq != -1) + picintc(1 << dev->irq); break; @@ -425,7 +426,8 @@ ms_write(uint16_t port, uint8_t val, void *priv) break; case INP_PORT_DATA: - picintc(1 << dev->irq); + if (dev->irq != -1) + picintc(1 << dev->irq); switch (dev->cmd) { case INP_CTRL_COMMAND: if (val & INP_HOLD_COUNTER) @@ -462,7 +464,8 @@ ms_write(uint16_t port, uint8_t val, void *priv) case 6: if (val & INP_ENABLE_TIMER_IRQ) - picint(1 << dev->irq); + if (dev->irq != -1) + picint(1 << dev->irq); dev->ctrl &= INP_PERIOD_MASK; dev->ctrl |= (val & ~INP_PERIOD_MASK); break; @@ -546,7 +549,8 @@ bm_poll(int x, int y, int z, int b, void *priv) /* Send interrupt. */ if (dev->flags & FLAG_DATA_INT) { - picint(1 << dev->irq); + if (dev->irq != -1) + picint(1 << dev->irq); DBGLOG(1, "MOUSE: Data Interrupt fired\n"); } } @@ -673,7 +677,7 @@ bm_init(const device_t *info, UNUSED(void *parent)) case 1: /* on-board controller, Logitech compatible */ dev->base = 0x023c; - dev->irq = 2; + dev->irq = -1; break; case 10: /* Microsoft InPort controller */ @@ -681,6 +685,12 @@ bm_init(const device_t *info, UNUSED(void *parent)) dev->base = device_get_config_hex16("base"); dev->irq = device_get_config_int("irq"); break; + + case 11: /* Microsoft InPort on-board controller */ + dev->flags = FLAG_INPORT; + dev->base = 0x023c; + dev->irq = -1; + break; } dev->bn = device_get_config_int("buttons"); @@ -885,7 +895,7 @@ const device_t mouse_logibus_device = { lt_config }; -const device_t mouse_logibus_internal_device = { +const device_t mouse_logibus_onboard_device = { "Logitech Bus Mouse (Internal)", 0, 1, @@ -906,3 +916,31 @@ const device_t mouse_msinport_device = { NULL, NULL, NULL, ms_config }; + +const device_t mouse_msinport_onboard_device = { + "Microsoft InPort Mouse (Internal)", + DEVICE_ISA, + 11, + NULL, + bm_init, bm_close, NULL, + bm_poll, + NULL, NULL, NULL, + NULL +}; + + +/* + * *** THIS IS A TEMPORARY FUNCTION *** + * + * Allows setting of the mouse device's IRQ value, + * currently needed for onboard devices. + */ +void +mouse_bus_set_irq(void *priv, int irq) +{ + mouse_t *dev = (mouse_t *)priv; + + DBGLOG(1, "MOUSE: Set_IRQ(%i)\n", irq); + + dev->irq = irq; +} diff --git a/src/devices/scsi/scsi.c b/src/devices/scsi/scsi.c index 67a4401..8e7a2ba 100644 --- a/src/devices/scsi/scsi.c +++ b/src/devices/scsi/scsi.c @@ -8,13 +8,13 @@ * * Handling of the SCSI controllers. * - * Version: @(#)scsi.c 1.0.15 2018/10/20 + * Version: @(#)scsi.c 1.0.16 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, * TheCollector1995, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -71,6 +71,7 @@ static const struct { const device_t *device; } scsi_cards[] = { { "none", NULL }, + { "internal", NULL }, { "aha1540b", &aha1540b_device }, { "aha1542c", &aha1542c_device }, @@ -189,7 +190,7 @@ scsi_card_init(void) memset(&scsi_devices[i][j], 0x00, sizeof(scsi_device_t)); - scsi_devices[i][j].type = SCSI_NONE; + scsi_devices[i][j].type = SCSI_NO_DEVICE; } } diff --git a/src/devices/scsi/scsi.h b/src/devices/scsi/scsi.h index 0f55a1e..646aa2d 100644 --- a/src/devices/scsi/scsi.h +++ b/src/devices/scsi/scsi.h @@ -8,13 +8,13 @@ * * SCSI module definitions. * - * Version: @(#)scsi.h 1.0.9 2018/10/16 + * Version: @(#)scsi.h 1.0.10 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, * TheCollector1995, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -39,17 +39,21 @@ #define EMU_SCSI_H -extern void scsi_card_log(int level, const char *fmt, ...); +#define SCSI_NONE 0 /* no SCSI controller selected */ +#define SCSI_INTERNAL 1 /* internal/onboard controller selected */ -extern int scsi_card_available(int card); -extern const char *scsi_card_getname(int card); + +extern void scsi_card_log(int level, const char *fmt, ...); + +extern int scsi_card_available(int card); +extern const char *scsi_card_getname(int card); #ifdef EMU_DEVICE_H -extern const device_t *scsi_card_getdevice(int card); +extern const device_t *scsi_card_getdevice(int card); #endif -extern int scsi_card_has_config(int card); -extern const char *scsi_card_get_internal_name(int card); -extern int scsi_card_get_from_internal_name(const char *s); -extern void scsi_card_init(void); +extern int scsi_card_has_config(int card); +extern const char *scsi_card_get_internal_name(int card); +extern int scsi_card_get_from_internal_name(const char *s); +extern void scsi_card_init(void); #endif /*EMU_SCSI_H*/ diff --git a/src/devices/scsi/scsi_device.c b/src/devices/scsi/scsi_device.c index 46cd42e..4f4b799 100644 --- a/src/devices/scsi/scsi_device.c +++ b/src/devices/scsi/scsi_device.c @@ -8,12 +8,12 @@ * * The generic SCSI device command handler. * - * Version: @(#)scsi_device.c 1.0.13 2018/10/20 + * Version: @(#)scsi_device.c 1.0.14 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -134,7 +134,7 @@ scsi_device_reset(scsi_device_t *dev) int scsi_device_present(scsi_device_t *dev) { - if (dev->type == SCSI_NONE) + if (dev->type == SCSI_NO_DEVICE) return 0; return 1; diff --git a/src/devices/scsi/scsi_device.h b/src/devices/scsi/scsi_device.h index 5360b5b..3d67de5 100644 --- a/src/devices/scsi/scsi_device.h +++ b/src/devices/scsi/scsi_device.h @@ -8,7 +8,7 @@ * * Definitions for the generic SCSI device command handler. * - * Version: @(#)scsi_device.h 1.0.6 2018/10/16 + * Version: @(#)scsi_device.h 1.0.7 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -286,7 +286,7 @@ #define MODE_SELECT_PHASE_PAGE 4 /* These are based on the INQUIRY values. */ -#define SCSI_NONE 0x0060 +#define SCSI_NO_DEVICE 0x0060 #define SCSI_FIXED_DISK 0x0000 #define SCSI_REMOVABLE_DISK 0x8000 #define SCSI_REMOVABLE_CDROM 0x8005 diff --git a/src/devices/scsi/scsi_disk.c b/src/devices/scsi/scsi_disk.c index bd1c671..124685a 100644 --- a/src/devices/scsi/scsi_disk.c +++ b/src/devices/scsi/scsi_disk.c @@ -143,13 +143,22 @@ static uint64_t mode_sense_page_flags = (GPMODEP_FORMAT_DEVICE_PAGE | /* This should be done in a better way but for time being, it's been done this way so it's not as huge and more readable. */ static const mode_sense_pages_t mode_sense_pages_default = { { [GPMODE_FORMAT_DEVICE_PAGE] = { GPMODE_FORMAT_DEVICE_PAGE, 0x16, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, +#if 1 + [GPMODE_RIGID_DISK_PAGE ] = { GPMODE_RIGID_DISK_PAGE, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 200, 0xff, 0xff, 0xff, 0, 0, 0, 0x15, 0x18, 0, 0 }, +#else [GPMODE_RIGID_DISK_PAGE ] = { GPMODE_RIGID_DISK_PAGE, 0x16, 0, 0x10, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0 }, +#endif [GPMODE_UNK_VENDOR_PAGE ] = { 0xB0, 0x16, '8', '6', 'B', 'o', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' } } }; static const mode_sense_pages_t mode_sense_pages_changeable = +#if 1 +{ { [GPMODE_FORMAT_DEVICE_PAGE] = { GPMODE_FORMAT_DEVICE_PAGE, 0x16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + [GPMODE_RIGID_DISK_PAGE ] = { GPMODE_RIGID_DISK_PAGE, 0x16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, +#else { { [GPMODE_FORMAT_DEVICE_PAGE] = { GPMODE_FORMAT_DEVICE_PAGE, 0x16, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0 }, [GPMODE_RIGID_DISK_PAGE ] = { GPMODE_RIGID_DISK_PAGE, 0x16, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0 }, +#endif [GPMODE_UNK_VENDOR_PAGE ] = { 0xB0, 0x16, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } } }; @@ -198,9 +207,15 @@ mode_sense_load(scsi_disk_t *dev) wchar_t temp[512]; FILE *fp; +#if 0 + // FIXME: + // This seems to make NextStep, OpenStep and maybe other + // systems not like the SCSI Disk device we present to + // them. Being investigated. /* Start out with a default set of pages. */ memcpy(&dev->ms_pages_saved, &mode_sense_pages_default, sizeof(mode_sense_pages_t)); +#endif /* Create the pathname for this data. */ swprintf(temp, sizeof_w(temp), @@ -259,15 +274,78 @@ mode_sense_read(scsi_disk_t *dev, uint8_t page_control, uint8_t page, uint8_t po { uint8_t ret = 0x00; +#if 1 + if (page_control == 1) + return mode_sense_pages_changeable.pages[page][pos]; + + if (page == GPMODE_RIGID_DISK_PAGE) switch (page_control) { + /* Rigid disk geometry page. */ + case 0: + case 2: + case 3: +#else switch (page_control) { case 0: case 3: +#endif +#if 1 + switch(pos) { + case 0: + case 1: + default: + return mode_sense_pages_default.pages[page][pos]; + + case 2: + case 6: + case 9: + return (dev->drv->tracks >> 16) & 0xff; + + case 3: + case 7: + case 10: + return (dev->drv->tracks >> 8) & 0xff; + + case 4: + case 8: + case 11: + return dev->drv->tracks & 0xff; + + case 5: + return dev->drv->hpc & 0xff; + } +#else ret = dev->ms_pages_saved.pages[page][pos]; +#endif break; +#if 1 + } else if (page == GPMODE_FORMAT_DEVICE_PAGE) switch (page_control) { + /* Format device page. */ + case 0: + case 2: + case 3: + switch(pos) { + case 0: + case 1: + default: + return mode_sense_pages_default.pages[page][pos]; + + case 10: + return (dev->drv->spt >> 8) & 0xff; + + case 11: + return dev->drv->spt & 0xff; + } + break; + } else switch (page_control) { + case 0: + case 3: + return dev->ms_pages_saved.pages[page][pos]; +#else case 1: ret = mode_sense_pages_changeable.pages[page][pos]; break; +#endif case 2: ret = mode_sense_pages_default.pages[page][pos]; diff --git a/src/devices/scsi/scsi_ncr5380.c b/src/devices/scsi/scsi_ncr5380.c index 7e833ca..ac63d59 100644 --- a/src/devices/scsi/scsi_ncr5380.c +++ b/src/devices/scsi/scsi_ncr5380.c @@ -11,7 +11,7 @@ * * NOTE: This code now only supports targets at LUN=0 !! * - * Version: @(#)scsi_ncr5380.c 1.0.15 2019/04/11 + * Version: @(#)scsi_ncr5380.c 1.0.16 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -369,7 +369,8 @@ ncr_callback(void *priv) DEBUG("NCR: CurBus BSY|REQ=%02x\n", ncr->cur_bus); ncr->command_pos = 0; SET_BUS_STATE(ncr, SCSI_PHASE_COMMAND); - picint(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); } else { ncr->state = STATE_IDLE; ncr->cur_bus = 0; @@ -506,7 +507,7 @@ ncr_callback(void *priv) ncr->bus_in = ncr->bus_host; } - if (ncr_dev->type < 3) { + if (ncr_dev->type < 13) { //FIXME: if (ncr->dma_mode == DMA_INITIATOR_RECEIVE) { if (!(ncr_dev->status_ctrl & CTRL_DATA_DIR)) { DEBUG("NCR: DMA_INITIATOR_RECEIVE with DMA direction set wrong\n"); @@ -564,7 +565,8 @@ ncr_callback(void *priv) if (ncr->mode & MODE_ENA_EOP_INT) { DEBUG("NCR: NCR read irq\n"); ncr->isr |= STATUS_INT; - picint(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); } } break; @@ -630,7 +632,8 @@ ncr_callback(void *priv) if (ncr->mode & MODE_ENA_EOP_INT) { DEBUG("NCR: write irq\n"); ncr->isr |= STATUS_INT; - picint(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); } } break; @@ -684,7 +687,8 @@ ncr_callback(void *priv) if (ncr->mode & MODE_ENA_EOP_INT) { DEBUG("NCR: read irq\n"); ncr->isr |= STATUS_INT; - picint(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); } } break; @@ -737,7 +741,8 @@ ncr_callback(void *priv) if (ncr->mode & MODE_ENA_EOP_INT) { DEBUG("NCR: write irq\n"); ncr->isr |= STATUS_INT; - picint(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); } } break; @@ -884,8 +889,10 @@ ncr_read(uint16_t port, void *priv) (ncr->cur_bus & SCSI_PHASE_MESSAGE_IN)) { DEBUG("Phase match\n"); ret |= STATUS_PHASE_MATCH; - } else - picint(1 << ncr_dev->irq); + } else { + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); + } ncr_wait_process(ncr_dev); @@ -917,7 +924,8 @@ ncr_read(uint16_t port, void *priv) case 7: /* reset Parity/Interrupt */ ncr->isr &= ~STATUS_INT; - picintc(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picintc(1 << ncr_dev->irq); DEBUG("Reset IRQ\n"); break; @@ -1052,7 +1060,8 @@ memio_write(uint32_t addr, uint8_t val, void *priv) DEBUG("Write 0x3980: val=%02x\n", val); if (val & 0x80) { DEBUG("Resetting the 53c400\n"); - picint(1 << ncr_dev->irq); + if (ncr_dev->irq != -1) + picint(1 << ncr_dev->irq); } if ((val & CTRL_DATA_DIR) && !(ncr_dev->status_ctrl & CTRL_DATA_DIR)) { @@ -1282,6 +1291,115 @@ scsiat_out(uint16_t port, uint8_t val, void *priv) } +static uint8_t +dev_in(uint16_t port, void *priv) +{ + ncr5380_t *ncr_dev = (ncr5380_t *)priv; + uint8_t ret = 0xff; + + switch (port & 0x0f) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + ret = ncr_read(port, ncr_dev); + break; + } + + DBGLOG(2, "5380: in(0x%03x) = %02x\n", port, ret); + + return(ret); +} + + +static void +dev_out(uint16_t port, uint8_t val, void *priv) +{ + ncr5380_t *ncr_dev = (ncr5380_t *)priv; + ncr_t *ncr = &ncr_dev->ncr; + scsi_device_t *dev = &scsi_devices[ncr->target_id][ncr->target_lun]; + + DBGLOG(2, "5380 write(0x%03x, %02x)\n", port, val); + + switch (port & 0x0f) { + case 0x08: + ncr->unk_08 = val; + + if (ncr->unk_08 & 0x08) { + if (ncr->dma_mode == DMA_INITIATOR_RECEIVE) { + while (ncr_dev->buffer_host_pos < 128) { + uint8_t temp; + + temp = ncr_dev->buffer[ncr_dev->buffer_host_pos++]; + + DBGLOG(1, "Read Buffer host=%d\n", ncr_dev->buffer_host_pos); + + ncr->bus_host = get_bus_host(ncr) & ~BUS_DATAMASK; + ncr->bus_host |= BUS_SETDATA(temp); + + if (ncr_dev->buffer_host_pos == 128) + break; + } + } else if (ncr->dma_mode == DMA_SEND) { + while (ncr_dev->buffer_host_pos < 128) { + /* Data ready. */ + uint8_t temp; + + ncr_wait_process(ncr_dev); + temp = BUS_GETDATA(ncr->bus_host); + ncr->bus_host = get_bus_host(ncr); + + ncr_dev->buffer[ncr_dev->buffer_host_pos++] = temp; + + DBGLOG(1, "Write Buffer host=%d\n", ncr_dev->buffer_host_pos); + + if (ncr_dev->buffer_host_pos == 128) { + + break; + } + } + } + } + + if (ncr->unk_08 & 0x01) { + ncr_dev->block_count_loaded = 1; + ncr_dev->block_count = dev->buffer_length / 128; + } + break; + + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + ncr_write(port, val, ncr_dev); + break; + } +} + + +static void +ncr_close(void *priv) +{ + ncr5380_t *ncr_dev = (ncr5380_t *)priv; + + if (ncr_dev) { + /* Tell the timer to terminate. */ + ncr_dev->timer_period = 0LL; + ncr_dev->timer_enabled = 0LL; + + free(ncr_dev); + } +} + + static void * ncr_init(const device_t *info, UNUSED(void *parent)) { @@ -1294,7 +1412,12 @@ ncr_init(const device_t *info, UNUSED(void *parent)) ncr_dev->type = info->local; switch(ncr_dev->type) { - case 0: /* Longshine LCS6821N */ + case 0: /* NCR 53C80 (on-board) */ + ncr_dev->base = 0; + ncr_dev->irq = -1; + break; + + case 10: /* Longshine LCS6821N */ ncr_dev->rom_addr = 0xDC000; rom_init(&ncr_dev->bios_rom, info->path, ncr_dev->rom_addr, 0x4000, 0x3fff, @@ -1303,12 +1426,11 @@ ncr_init(const device_t *info, UNUSED(void *parent)) mem_map_disable(&ncr_dev->bios_rom.mapping); mem_map_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, - memio_read, NULL, NULL, - memio_write, NULL, NULL, + memio_read, NULL, NULL, memio_write, NULL, NULL, ncr_dev->bios_rom.rom, 0, ncr_dev); break; - case 1: /* Rancho RT1000B */ + case 11: /* Rancho RT1000B */ ncr_dev->rom_addr = 0xDC000; rom_init(&ncr_dev->bios_rom, info->path, ncr_dev->rom_addr, 0x4000, 0x3fff, @@ -1317,12 +1439,11 @@ ncr_init(const device_t *info, UNUSED(void *parent)) mem_map_disable(&ncr_dev->bios_rom.mapping); mem_map_add(&ncr_dev->mapping, ncr_dev->rom_addr, 0x4000, - memio_read, NULL, NULL, - memio_write, NULL, NULL, + memio_read, NULL, NULL, memio_write, NULL, NULL, ncr_dev->bios_rom.rom, 0, ncr_dev); break; - case 2: /* Trantor T130B */ + case 12: /* Trantor T130B */ ncr_dev->rom_addr = 0xDC000; ncr_dev->base = device_get_config_hex16("base"); ncr_dev->irq = device_get_config_int("irq"); @@ -1339,7 +1460,7 @@ ncr_init(const device_t *info, UNUSED(void *parent)) t130b_in,NULL,NULL, t130b_out,NULL,NULL, ncr_dev); break; - case 3: /* Sumo SCSI-AT */ + case 13: /* Sumo SCSI-AT */ ncr_dev->base = device_get_config_hex16("base"); ncr_dev->irq = device_get_config_int("irq"); ncr_dev->rom_addr = device_get_config_hex20("bios_addr"); @@ -1379,21 +1500,6 @@ ncr_init(const device_t *info, UNUSED(void *parent)) } -static void -ncr_close(void *priv) -{ - ncr5380_t *ncr_dev = (ncr5380_t *)priv; - - if (ncr_dev) { - /* Tell the timer to terminate. */ - ncr_dev->timer_period = 0LL; - ncr_dev->timer_enabled = 0LL; - - free(ncr_dev); - } -} - - static const device_config_t t130b_config[] = { { "base", "Address", CONFIG_HEX16, "", 0x0350, @@ -1534,10 +1640,20 @@ static const device_config_t scsiat_config[] = { }; +const device_t scsi_ncr53c80_onboard_device = { + "NCR 53C80 (onboard)", + DEVICE_ISA, + 0, + NULL, + ncr_init, ncr_close, NULL, + NULL, NULL, NULL, NULL, + NULL +}; + const device_t scsi_lcs6821n_device = { "Longshine LCS-6821N", DEVICE_ISA, - 0, + 10, LCS6821N_ROM, ncr_init, ncr_close, NULL, NULL, NULL, NULL, NULL, @@ -1547,7 +1663,7 @@ const device_t scsi_lcs6821n_device = { const device_t scsi_rt1000b_device = { "Ranco RT1000B", DEVICE_ISA, - 1, + 11, RT1000B_ROM, ncr_init, ncr_close, NULL, NULL, NULL, NULL, NULL, @@ -1557,7 +1673,7 @@ const device_t scsi_rt1000b_device = { const device_t scsi_t130b_device = { "Trantor T130B", DEVICE_ISA, - 2, + 12, T130B_ROM, ncr_init, ncr_close, NULL, NULL, NULL, NULL, NULL, @@ -1567,9 +1683,33 @@ const device_t scsi_t130b_device = { const device_t scsi_scsiat_device = { "Sumo SCSI-AT", DEVICE_ISA, - 3, + 13, SCSIAT_ROM, ncr_init, ncr_close, NULL, NULL, NULL, NULL, NULL, scsiat_config }; + + +/* + * *** THIS IS A TEMPORARY FUNCTION *** + * + * Allows setting of the device's IRQ value, + * currently needed for onboard devices. + */ +void +scsi_ncr5380_set_info(void *priv, int base, int irq) +{ + ncr5380_t *dev = (ncr5380_t *)priv; + + DBGLOG(1, "5380: Set_Info(%04x, %i)\n", base, irq); + + if (dev->base != 0) + io_removehandler(dev->base, 16, + dev_in,NULL,NULL, dev_out,NULL,NULL, dev); + dev->base = base; + io_sethandler(dev->base, 16, + dev_in,NULL,NULL, dev_out,NULL,NULL, dev); + + dev->irq = irq; +} diff --git a/src/devices/scsi/scsi_ncr5380.h b/src/devices/scsi/scsi_ncr5380.h index 358cbd2..2f8f9ae 100644 --- a/src/devices/scsi/scsi_ncr5380.h +++ b/src/devices/scsi/scsi_ncr5380.h @@ -10,12 +10,12 @@ * made by NCR. These controllers were designed for * the ISA bus. * - * Version: @(#)scsi_ncr5380.c 1.0.2 2018/03/15 + * Version: @(#)scsi_ncr5380.c 1.0.3 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * * This program is free software; you can redistribute it and/or modify @@ -40,10 +40,15 @@ # define SCSI_NCR5380_H +extern const device_t scsi_ncr53c80_onboard_device; + extern const device_t scsi_lcs6821n_device; extern const device_t scsi_rt1000b_device; extern const device_t scsi_t130b_device; extern const device_t scsi_scsiat_device; +extern void scsi_ncr5380_set_info(void *priv, int base, int irq); + + #endif /*SCSI_NCR5380_H*/ diff --git a/src/devices/video/vid_ega.c b/src/devices/video/vid_ega.c index f93ff2d..03a7019 100644 --- a/src/devices/video/vid_ega.c +++ b/src/devices/video/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.13 2019/04/19 + * Version: @(#)vid_ega.c 1.0.14 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1282,6 +1282,20 @@ const device_t ega_device = { ega_config }; +const device_t ega_onboard_device = { + "Onboard EGA", + DEVICE_VIDEO(VID_TYPE_SPEC) | DEVICE_ISA, + EGA_IBM, + NULL, + ega_standalone_init, ega_close, NULL, + NULL, + speed_changed, + NULL, + &ega_timing, + ega_config +}; + + static const video_timings_t ega_compaq_timing = {VID_ISA,8,16,32,8,16,32}; const device_t ega_compaq_device = { "Compaq EGA", diff --git a/src/devices/video/video.h b/src/devices/video/video.h index 955704f..1c2e5da 100644 --- a/src/devices/video/video.h +++ b/src/devices/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.31 2019/04/19 + * Version: @(#)video.h 1.0.32 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -207,6 +207,7 @@ extern const device_t cga_compaq2_device; /* IBM EGA and compatibles. */ extern const device_t ega_device; +extern const device_t ega_onboard_device; #if defined(DEV_BRANCH) && defined(USE_COMPAQ) extern const device_t ega_compaq_device; #endif diff --git a/src/machines/m_bull.c b/src/machines/m_bull.c new file mode 100644 index 0000000..3c759a6 --- /dev/null +++ b/src/machines/m_bull.c @@ -0,0 +1,277 @@ +/* + * 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 various machines made by (Groupe) Bull. + * + * **NOTE** This is not finished yet, and, therefore, still in Dev: + * + * - proper handling of the SW-1 and and SW-2 switches and + * their readout. Fabien is looking into that. + * - figure out how the NCR 83C80 chip is mapped in. + * - figure out why the InPort is detected, but does not work. + * - at some point, hopefully add the Paradise PGA2A chip. + * + * Other than the above, the machine works as expected. + * + * Version: @(#)m_bull.c 1.0.1 2019/04/23 + * + * Authors: Fred N. van Kempen, + * Idea from a patch for PCem by DNS2KV2, but fully rewritten. + * Many thanks to Fabien Neck for technical info, BIOS and tools. + * + * 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. + */ +#include +#include +#include +#include +#include "../emu.h" +#include "../cpu/cpu.h" +#include "../io.h" +#include "../mem.h" +#include "../rom.h" +#include "../device.h" +#include "../devices/input/mouse.h" +#include "../devices/floppy/fdd.h" +#include "../devices/floppy/fdc.h" +#include "../devices/disk/hdc.h" +#include "../devices/scsi/scsi.h" +#include "../devices/scsi/scsi_ncr5380.h" +#include "../devices/video/video.h" +#include "machine.h" + + +static void * +common_init(const device_t *info, void *arg) +{ + int ega, mouse, scsi; + void *priv; + int irq; + + /* Allocate machine device to system. */ + device_add_ex(info, arg); + + ega = machine_get_config_int("pega"); + mouse = machine_get_config_int("mouse"); + scsi = machine_get_config_int("scsi"); + + switch(info->local) { + /* MICRAL45: Bull Micral 45/286@12 */ + case 45: + m_at_init(); + + /* Mainboard switch. */ + mem_remap_top(384); + + if (hdc_type == HDC_INTERNAL) + device_add(&st506_at_wd1003_device); + + if (video_card == VID_INTERNAL && ega) { + /* Paradise PGA2A, really! */ + device_add(&ega_onboard_device); + } + + if (mouse_type == MOUSE_INTERNAL && mouse) { + priv = device_add(&mouse_msinport_onboard_device); + mouse_bus_set_irq(priv, mouse); + } + + if (scsi_card == SCSI_INTERNAL && scsi) { + priv = device_add(&scsi_ncr53c80_onboard_device); + irq = machine_get_config_int("scsi_irq"); + scsi_ncr5380_set_info(priv, scsi, irq); + } + + device_add(&fdc_at_device); + + break; + } + + return(arg); +} + + +/* + * Micral 45 motherboard jumpers and switches. + * + * SWD1 DIPswitch on back, 4-pos. + * JD01 Jumper on mainboard. + * + * Display Mode SWD-1 SWD-2 SWD-3 SWD-4 JD01 + * Mono 80 OFF OFF OFF OFF 2-3 + * Color 80 ON OFF OFF OFF 2-3 + * (Color 40) OFF ON OFF OFF 2-3 + * EGA OFF ON ON OFF 1-2 + * + * These switches and the jumper drive the Paradise PGA2A EGA + * chip. More modes like Hercules and Plantronics are possible. + * + * SW1 DIPswitch on mainboard. + * + * SW1-2 SW1-1 Memory mode + * OFF OFF Total 1152 KB + * OFF ON Total 640K + * ON OFF Extended Memory enabled + * ON ON Bank2 = 2MB + * + * SW1-3 Reserved + * + * SW1-5 SW1-4 Video controller + * OFF X Enable internal EGA controller + * ON OFF Enable external CGA + * ON ON Enable external MDA + * + * SW1-6 Reserved + * SW1-7 Reserved + * SW1-8 Reserved + * + * SW2 DIPswitch on mainboard. + * + * SW2-3 SW2-2 SW2-1 Mouse mode + * X X ON Disable mouse + * ON OFF OFF Enable mouse, IRQ3 * + * OFF ON OFF Enable mouse, IRQ5 + * + * SW2-4 Various + * ON CP8 (SmartCard reader) at 370H, serial at 2F8H, parallel at 278H + * + * SW2-5 SCSI controller I/O + * OFF controller at 320H * + * ON controller at 328H + * + * SW2-7 SW2-6 SCSI controller IRQ + * ON OFF SCSI uses IRQ7 * + * OFF ON SCSI uses IRQ15 + * + * SW2-9 SW2-8 Parallel port IRQ + * ON OFF Enable parallel port IRQ5 * + * OFF ON Enable parallel port IRQ7 + * + * SW2-10 CP8 IRQ + * ON Enable CP8 IRQ3 * + * + * These are somewhat configuring, and need to be verified. + */ +static const device_config_t m45_config[] = { + { + "ega", "Internal EGA", CONFIG_SELECTION, "", 0, + { /* This is SW1-5 on mainboard. */ + { + "Disabled", 0 + }, + { + "Enabled", 1 + }, + { + NULL + } + } + }, + { + "mouse", "Internal Mouse", CONFIG_SELECTION, "", 3, + { + { + "Disabled", 0 + }, + { + "Enabled, using IRQ3", 3 + }, + { + "Enabled, using IRQ5", 5 + }, + { + NULL + } + } + }, + { + "scsi", "Internal SCSI", CONFIG_SELECTION, "", 0, + { + { + "Disabled", 0 + }, + { + "320H", 0x320 + }, + { + "328H", 0x328 + }, + { + NULL + } + } + }, + { + "scsi_irq", "Internal SCSI IRQ", CONFIG_SELECTION, "", 7, + { + { + "Disabled", 0 + }, + { + "IRQ7", 7 + }, + { + "IRQ15", 15 + }, + { + NULL + } + } + }, + { + NULL + } +}; + +static const machine_t m45_info = { + MACHINE_ISA | MACHINE_AT | MACHINE_HDC | MACHINE_VIDEO | MACHINE_MOUSE | MACHINE_SCSI, + MACHINE_HDC, + 1024, 6144, 512, 128, -1, + {{"Intel",cpus_286}} +}; + +const device_t m_bull_micral45 = { + "Bull Micral 45", + DEVICE_ROOT, + 45, + L"bull/micral45", + common_init, NULL, NULL, + NULL, NULL, NULL, + &m45_info, + m45_config +}; diff --git a/src/machines/m_europc.c b/src/machines/m_europc.c index f44c992..7efc884 100644 --- a/src/machines/m_europc.c +++ b/src/machines/m_europc.c @@ -69,7 +69,7 @@ * FIXME: Find a new way to handle the switching of color/mono on * external cards. New video_get_type(int card) function? * - * Version: @(#)m_europc.c 1.0.21 2019/04/11 + * Version: @(#)m_europc.c 1.0.22 2019/04/23 * * Author: Fred N. van Kempen, * @@ -545,6 +545,7 @@ static void * europc_init(const device_t *info, void *arg) { europc_t *dev; + void *priv; uint8_t b; int i; @@ -675,7 +676,8 @@ europc_init(const device_t *info, void *arg) b = (dev->nvr.regs[MRTC_CONF_C] & 0xfc); if (mouse_type == MOUSE_INTERNAL) { /* Enable the Logitech Bus Mouse device. */ - device_add(&mouse_logibus_internal_device); + priv = device_add(&mouse_logibus_onboard_device); + mouse_bus_set_irq(priv, 2); /* Configure the port for (Bus Mouse Compatible) Mouse. */ b |= 0x01; diff --git a/src/machines/machine.h b/src/machines/machine.h index 78c6c58..75a6b64 100644 --- a/src/machines/machine.h +++ b/src/machines/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.30 2019/04/14 + * Version: @(#)machine.h 1.0.31 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -57,6 +57,7 @@ #define MACHINE_MOUSE 0x040000 /* sys has int mouse */ #define MACHINE_SOUND 0x080000 /* sys has int sound */ #define MACHINE_VIDEO 0x100000 /* sys has int video */ +#define MACHINE_SCSI 0x200000 /* sys has int SCSI */ #define IS_ARCH(a) (machine->flags & (a)) ? 1 : 0; @@ -138,6 +139,10 @@ extern const device_t m_xt286; extern const device_t m_neat_ami; extern const device_t m_neat_dtk; +#if defined(DEV_BRANCH) && defined(USE_MICRAL) +extern const device_t m_bull_micral45; +#endif + extern const device_t m_tg286m; extern const device_t m_headland_386_ami; extern const device_t m_ama932j; diff --git a/src/machines/machine_table.c b/src/machines/machine_table.c index 43c1035..83352f6 100644 --- a/src/machines/machine_table.c +++ b/src/machines/machine_table.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine_table.c 1.0.39 2019/04/20 + * Version: @(#)machine_table.c 1.0.40 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -106,6 +106,9 @@ static const struct { { "[286 ISA] AMI 286 (NEAT)", "ami_286", &m_neat_ami }, { "[286 ISA] Award 286 (SCAT)", "award_286", &m_scat_award }, +#if defined(DEV_BRANCH) && defined(USE_MICRAL) + { "[286 ISA] Bull Micral 45", "bull_micral45", &m_bull_micral45 }, +#endif { "[286 ISA] Commodore PC-30", "commodore_pc30", &m_cbm_pc30 }, #if defined(DEV_BRANCH) && defined(USE_COMPAQ) { "[286 ISA] Compaq Portable (286)", "compaq_portable286", &m_cpq_p1_286 }, diff --git a/src/pc.c b/src/pc.c index f2d2f68..8581bb2 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.68 2019/04/19 + * Version: @(#)pc.c 1.0.69 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -139,8 +139,8 @@ int game_enabled = 0, /* (C) enable game port */ #ifdef WALTJE int romdos_enabled = 0; /* (C) enable ROM DOS */ #endif -int hdc_type = 0; /* (C) HDC type */ -int scsi_card = 0; /* (C) selected SCSI card */ +int hdc_type = HDC_NONE; /* (C) HDC type */ +int scsi_card = SCSI_NONE; /* (C) selected SCSI card */ int sound_card = 0, /* (C) selected sound card */ sound_is_float = 1, /* (C) sound uses FP values */ sound_gain = 0, /* (C) sound volume gain */ diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index 183df88..3806eb3 100644 --- a/src/win/mingw/Makefile.MinGW +++ b/src/win/mingw/Makefile.MinGW @@ -8,7 +8,7 @@ # # Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.81 2019/04/21 +# Version: @(#)Makefile.mingw 1.0.82 2019/04/23 # # Author: Fred N. van Kempen, # @@ -140,6 +140,9 @@ endif ifndef COMPAQ COMPAQ := n endif +ifndef MICRAL + MICRAL := n +endif ifndef SUPERSPORT SUPERSPORT := n endif @@ -218,6 +221,7 @@ ifeq ($(DEV_BUILD), y) SIS471 := y SIS496 := y COMPAQ := y + MICRAL := y SUPERSPORT := y ST11 := y WD1002 := y @@ -642,6 +646,11 @@ ifeq ($(DEV_BRANCH), y) DEVBROBJ += m_compaq.o m_compaq_vid.o vid_cga_compaq.o endif + ifeq ($(MICRAL), y) + OPTS += -DUSE_MICRAL + DEVBROBJ += m_bull.o + endif + ifeq ($(SUPERSPORT), y) OPTS += -DUSE_SUPERSPORT DEVBROBJ += m_zenith.o m_zenith_vid.o diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index c54c735..daf0778 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.65 2019/04/20 +# Version: @(#)Makefile.VC 1.0.66 2019/04/23 # # Author: Fred N. van Kempen, # @@ -141,6 +141,9 @@ endif ifndef COMPAQ COMPAQ := n endif +ifndef MICRAL + MICRAL := n +endif ifndef SUPERSPORT SUPERSPORT := n endif @@ -218,6 +221,7 @@ ifeq ($(DEV_BUILD), y) SIS471 := y SIS496 := y COMPAQ := y + MICRAL := y SUPERSPORT := y ST11 := y WD1002 := y @@ -584,6 +588,11 @@ ifeq ($(DEV_BRANCH), y) DEVBROBJ += m_compaq.obj m_compaq_vid.obj vid_cga_compaq.obj endif + ifeq ($(MICRAL), y) + OPTS += -DUSE_MICRAL + DEVBROBJ += m_bull.obj + endif + ifeq ($(SUPERSPORT), y) OPTS += -DUSE_SUPERSPORT DEVBROBJ += m_zenith.obj m_zenith_vid.obj diff --git a/src/win/win_settings_periph.h b/src/win/win_settings_periph.h index d400651..1ee1ac0 100644 --- a/src/win/win_settings_periph.h +++ b/src/win/win_settings_periph.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_periph.h 1.0.18 2019/04/08 + * Version: @(#)win_settings_periph.h 1.0.19 2019/04/23 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -76,6 +76,13 @@ recalc_scsi_list(const machine_t *m, HWND hdlg) if (c == 0) { SendMessage(h, CB_ADDSTRING, 0, win_string(IDS_NONE)); + } else if (c == 1) { + if (! (m->flags & MACHINE_SCSI)) { + /* Skip "Internal" if machine doesn't have one. */ + c++; + continue; + } + SendMessage(h, CB_ADDSTRING, 0, win_string(IDS_INTERNAL)); } else { stransi = scsi_card_getname(c); sprintf(tempA, "[%s] %s",