diff --git a/src/device/mouse.c b/src/device/mouse.c index f7d8c9861..0bf87934d 100644 --- a/src/device/mouse.c +++ b/src/device/mouse.c @@ -83,23 +83,24 @@ static const device_t mouse_internal_device = { static mouse_t mouse_devices[] = { // clang-format off - { &mouse_none_device }, - { &mouse_internal_device }, - { &mouse_logibus_device }, - { &mouse_msinport_device }, + { &mouse_none_device }, + { &mouse_internal_device }, + { &mouse_logibus_device }, + { &mouse_msinport_device }, #ifdef USE_GENIBUS - { &mouse_genibus_device }, + { &mouse_genibus_device }, #endif - { &mouse_mssystems_device }, - { &mouse_msserial_device }, - { &mouse_ltserial_device }, - { &mouse_ps2_device }, + { &mouse_mssystems_device }, + { &mouse_mssystems_bus_device }, + { &mouse_msserial_device }, + { &mouse_ltserial_device }, + { &mouse_ps2_device }, #ifdef USE_WACOM - { &mouse_wacom_device }, - { &mouse_wacom_artpad_device }, + { &mouse_wacom_device }, + { &mouse_wacom_artpad_device }, #endif - { &mouse_mtouch_device }, - { NULL } + { &mouse_mtouch_device }, + { NULL } // clang-format on }; diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index 8ed4865cd..24d7ae853 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -833,10 +833,6 @@ sermouse_close(void *priv) { mouse_t *dev = (mouse_t *) priv; - /* Detach serial port from the mouse. */ - if (dev && dev->serial && dev->serial->sd) - memset(dev->serial->sd, 0, sizeof(serial_device_t)); - free(dev); } @@ -849,6 +845,11 @@ sermouse_init(const device_t *info) void (*dev_write)(struct serial_s *serial, void *priv, uint8_t data); void (*transmit_period_callback)(struct serial_s *serial, void *priv, double transmit_period); + if (info->local == MOUSE_TYPE_MSYSTEMSB) { + uintptr_t irqbase = ((device_get_config_int("irq") << 16) | (device_get_config_hex16("addr") << 20)) | ns16450_device.local; + device_add_params(&ns16450_device, (void*)irqbase); + } + dev = (mouse_t *) calloc(1, sizeof(mouse_t)); dev->name = info->name; dev->but = device_get_config_int("buttons"); @@ -862,7 +863,7 @@ sermouse_init(const device_t *info) if (dev->but > 2) dev->flags |= FLAG_3BTN; - if (info->local == MOUSE_TYPE_MSYSTEMS) { + if (info->local == MOUSE_TYPE_MSYSTEMS || info->local == MOUSE_TYPE_MSYSTEMSB) { dev->format = 0; dev->type = info->local; dev->id_len = 1; @@ -893,7 +894,7 @@ sermouse_init(const device_t *info) } } - dev->port = device_get_config_int("port"); + dev->port = (info->local == MOUSE_TYPE_MSYSTEMSB) ? SERIAL_MAX : device_get_config_int("port"); /* Attach a serial port to the mouse. */ rcr_callback = dev->rts_toggle ? sermouse_callback : NULL; @@ -968,6 +969,76 @@ static const device_config_t msssermouse_config[] = { // clang-format on }; +static const device_config_t mssbusmouse_config[] = { + // clang-format off + { + .name = "addr", + .description = "Address", + .type = CONFIG_HEX16, + .default_string = NULL, + .default_int = 0x238, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "0x338", .value = 0x338 }, + { .description = "0x238", .value = 0x238 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + + { + .name = "irq", + .description = "IRQ", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 5, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "IRQ 2", .value = 2 }, + { .description = "IRQ 3", .value = 3 }, + { .description = "IRQ 4", .value = 4 }, + { .description = "IRQ 5", .value = 5 }, + { .description = "IRQ 7", .value = 7 }, + { .description = "IRQ 10", .value = 10 }, + { .description = "IRQ 11", .value = 11 }, + { .description = "IRQ 12", .value = 12 }, + { .description = "IRQ 15", .value = 15 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "buttons", + .description = "Buttons", + .type = CONFIG_SELECTION, + .default_string = NULL, + .default_int = 2, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { + { .description = "Two", .value = 2 }, + { .description = "Three", .value = 3 }, + { .description = "" } + }, + .bios = { { 0 } } + }, + { + .name = "rts_toggle", + .description = "RTS toggle", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, + { .name = "", .description = "", .type = CONFIG_END } + // clang-format on + }; + static const device_config_t mssermouse_config[] = { // clang-format off { @@ -1087,6 +1158,20 @@ const device_t mouse_mssystems_device = { .config = msssermouse_config }; +const device_t mouse_mssystems_bus_device = { + .name = "Mouse Systems Bus Mouse", + .internal_name = "mssystems_bus", + .flags = DEVICE_ISA, + .local = MOUSE_TYPE_MSYSTEMSB, + .init = sermouse_init, + .close = sermouse_close, + .reset = NULL, + .available = NULL, + .speed_changed = sermouse_speed_changed, + .force_redraw = NULL, + .config = mssbusmouse_config +}; + const device_t mouse_msserial_device = { .name = "Microsoft Serial Mouse", .internal_name = "msserial", diff --git a/src/device/serial.c b/src/device/serial.c index deb97225a..c00cfad10 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -38,7 +38,7 @@ #include <86box/serial.h> #include <86box/mouse.h> -serial_port_t com_ports[SERIAL_MAX]; +serial_port_t com_ports[SERIAL_MAX + 1]; enum { SERIAL_INT_LSR = 1, @@ -53,7 +53,7 @@ enum { void serial_update_ints(serial_t *dev); static int next_inst = 0; -static serial_device_t serial_devices[SERIAL_MAX]; +static serial_device_t serial_devices[SERIAL_MAX + 1]; static void serial_xmit_d_empty_evt(void *priv); @@ -884,10 +884,10 @@ serial_close(void *priv) { serial_t *dev = (serial_t *) priv; - next_inst--; - - if (com_ports[dev->inst].enabled) + if (dev->sd) { + memset(dev->sd, 0, sizeof(serial_device_t)); fifo_close(dev->rcvr_fifo); + } free(dev); } @@ -897,7 +897,7 @@ serial_reset(void *priv) { serial_t *dev = (serial_t *) priv; - if (com_ports[dev->inst].enabled) { + if (dev->sd) { timer_disable(&dev->transmit_timer); timer_disable(&dev->timeout_timer); timer_disable(&dev->receive_timer); @@ -930,16 +930,28 @@ static void * serial_init(const device_t *info) { serial_t *dev = (serial_t *) calloc(1, sizeof(serial_t)); + int orig_inst = next_inst; + + if (info->local & 0xFFF00000) { + next_inst = SERIAL_MAX; + } dev->inst = next_inst; - if (com_ports[next_inst].enabled) { + if (com_ports[next_inst].enabled || (info->local & 0xFFF00000)) { serial_log("Adding serial port %i...\n", next_inst); dev->type = info->local; memset(&(serial_devices[next_inst]), 0, sizeof(serial_device_t)); dev->sd = &(serial_devices[next_inst]); dev->sd->serial = dev; - if (next_inst == 6) + + if (info->local & 0xFFF00000) { + dev->base_address = info->local >> 20; + dev->irq = (info->local >> 16) & 0xF; + io_sethandler(dev->base_address, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, dev); + next_inst = orig_inst; + } + else if (next_inst == 6) serial_setup(dev, COM7_ADDR, COM7_IRQ); else if (next_inst == 5) serial_setup(dev, COM6_ADDR, COM6_IRQ); @@ -984,7 +996,8 @@ serial_init(const device_t *info) serial_reset_port(dev); } - next_inst++; + if (!(info->local & 0xFFF00000)) + next_inst++; return dev; } diff --git a/src/include/86box/mouse.h b/src/include/86box/mouse.h index 333849846..8dd3bad2d 100644 --- a/src/include/86box/mouse.h +++ b/src/include/86box/mouse.h @@ -41,6 +41,7 @@ #define MOUSE_TYPE_PS2 11 /* PS/2 series Bus Mouse */ #define MOUSE_TYPE_WACOM 12 /* WACOM tablet */ #define MOUSE_TYPE_WACOMARTP 13 /* WACOM tablet (ArtPad) */ +#define MOUSE_TYPE_MSYSTEMSB 14 /* Mouse Systems bus mouse */ #define MOUSE_TYPE_ONBOARD 0x80 /* Mouse is an on-board version of one of the above. */ @@ -68,6 +69,7 @@ extern const device_t mouse_msinport_device; extern const device_t mouse_genibus_device; # endif extern const device_t mouse_mssystems_device; +extern const device_t mouse_mssystems_bus_device; extern const device_t mouse_msserial_device; extern const device_t mouse_ltserial_device; extern const device_t mouse_ps2_device; diff --git a/src/include/86box/serial.h b/src/include/86box/serial.h index 31c77ce5a..c6259d7bc 100644 --- a/src/include/86box/serial.h +++ b/src/include/86box/serial.h @@ -116,7 +116,7 @@ typedef struct serial_port_s { uint8_t enabled; } serial_port_t; -extern serial_port_t com_ports[SERIAL_MAX]; +extern serial_port_t com_ports[SERIAL_MAX + 1]; extern serial_t *serial_attach_ex(int port, void (*rcr_callback)(struct serial_s *serial, void *priv),