From a042925efe3e3918b760b0c6a82509af74eeb790 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 9 Jun 2025 18:30:50 +0200 Subject: [PATCH] Tulip jumper device. --- src/device/CMakeLists.txt | 1 + src/device/tulip_jumper.c | 103 ++++++++++++++++++++++++++++++++++++ src/include/86box/chipset.h | 2 + 3 files changed, 106 insertions(+) create mode 100644 src/device/tulip_jumper.c diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index ea89f5cd9..29fc0b9b4 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -57,6 +57,7 @@ add_library(dev OBJECT smbus_ali7101.c smbus_piix4.c smbus_sis5595.c + tulip_jumper.c unittester.c ) diff --git a/src/device/tulip_jumper.c b/src/device/tulip_jumper.c new file mode 100644 index 000000000..1974129e3 --- /dev/null +++ b/src/device/tulip_jumper.c @@ -0,0 +1,103 @@ +/* + * 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 Tulip Jumper Readout. + * + * Bits 7-5 = board number, 0-5 valid, 6, 7 invalid. + * + * Authors: Miran Grca, + * + * Copyright 2025 Miran Grca. + */ +#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/machine.h> +#include <86box/sound.h> +#include <86box/chipset.h> +#include <86box/plat.h> +#include <86box/plat_unused.h> + +typedef struct tulip_jumper_t { + uint8_t jumper; +} tulip_jumper_t; + +#ifdef ENABLE_TULIP_JUMPER_LOG +int tulip_jumper_do_log = ENABLE_TULIP_JUMPER_LOG; + +static void +tulip_jumper_log(const char *fmt, ...) +{ + va_list ap; + + if (tulip_jumper_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +# define tulip_jumper_log(fmt, ...) +#endif + +static uint8_t +tulip_jumper_read(uint16_t addr, void *priv) +{ + const tulip_jumper_t *dev = (tulip_jumper_t *) priv; + uint8_t ret = 0xff; + + tulip_jumper_log("Tulip Jumper: Read %02x\n", dev->jumper); + + ret = dev->jumper; + + return ret; +} + +static void +tulip_jumper_close(void *priv) +{ + tulip_jumper_t *dev = (tulip_jumper_t *) priv; + + free(dev); +} + +static void * +tulip_jumper_init(const device_t *info) +{ + tulip_jumper_t *dev = (tulip_jumper_t *) calloc(1, sizeof(tulip_jumper_t)); + + /* Return board number 05. */ + dev->jumper = 0xbf; + + io_sethandler(0x0d80, 0x0001, tulip_jumper_read, NULL, NULL, NULL, NULL, NULL, dev); + + return dev; +} + +const device_t tulip_jumper_device = { + .name = "Tulip Jumper Readout", + .internal_name = "tulip_jumper", + .flags = 0, + .local = 0, + .init = tulip_jumper_init, + .close = tulip_jumper_close, + .reset = NULL, + .available = NULL, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; diff --git a/src/include/86box/chipset.h b/src/include/86box/chipset.h index e0e775fa1..1b5684414 100644 --- a/src/include/86box/chipset.h +++ b/src/include/86box/chipset.h @@ -201,6 +201,8 @@ extern const device_t vlsi_scamp_device; extern const device_t wd76c10_device; /* Miscellaneous Hardware */ +extern const device_t tulip_jumper_device; + extern const device_t dell_jumper_device; extern const device_t nec_mate_unk_device;