2018-01-17 18:43:36 +01:00
|
|
|
/*
|
2023-01-06 15:36:05 -05:00
|
|
|
* 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.
|
2018-01-17 18:43:36 +01:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* This file is part of the 86Box distribution.
|
2018-01-17 18:43:36 +01:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Super I/O chip detection code.
|
2018-01-17 18:43:36 +01:00
|
|
|
*
|
2020-03-25 00:46:02 +02:00
|
|
|
*
|
2018-01-17 18:43:36 +01:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
2018-01-17 18:43:36 +01:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Copyright 2016-2018 Miran Grca.
|
2018-01-17 18:43:36 +01:00
|
|
|
*/
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
2018-11-08 19:21:55 +01:00
|
|
|
#include <stdlib.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <wchar.h>
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/86box.h>
|
|
|
|
|
#include <86box/device.h>
|
|
|
|
|
#include <86box/io.h>
|
|
|
|
|
#include <86box/timer.h>
|
|
|
|
|
#include <86box/fdd.h>
|
|
|
|
|
#include <86box/fdc.h>
|
|
|
|
|
#include <86box/sio.h>
|
2023-06-28 13:46:28 -04:00
|
|
|
#include <86box/plat_unused.h>
|
2017-06-16 03:18:59 +02:00
|
|
|
|
2023-06-28 13:46:28 -04:00
|
|
|
typedef struct sio_detect_t {
|
2018-11-08 19:21:55 +01:00
|
|
|
uint8_t regs[2];
|
|
|
|
|
} sio_detect_t;
|
2017-06-16 03:18:59 +02:00
|
|
|
|
2018-11-08 19:21:55 +01:00
|
|
|
static void
|
|
|
|
|
sio_detect_write(uint16_t port, uint8_t val, void *priv)
|
2017-06-16 03:18:59 +02:00
|
|
|
{
|
2018-11-08 19:21:55 +01:00
|
|
|
sio_detect_t *dev = (sio_detect_t *) priv;
|
2017-06-16 03:18:59 +02:00
|
|
|
|
2018-11-08 19:21:55 +01:00
|
|
|
pclog("sio_detect_write : port=%04x = %02X\n", port, val);
|
2017-09-04 01:52:29 -04:00
|
|
|
|
2018-11-08 19:21:55 +01:00
|
|
|
dev->regs[port & 1] = val;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint8_t
|
|
|
|
|
sio_detect_read(uint16_t port, void *priv)
|
|
|
|
|
{
|
2023-08-21 20:24:33 -04:00
|
|
|
const sio_detect_t *dev = (sio_detect_t *) priv;
|
2018-11-08 19:21:55 +01:00
|
|
|
|
|
|
|
|
pclog("sio_detect_read : port=%04x = %02X\n", port, dev->regs[port & 1]);
|
|
|
|
|
|
2021-08-07 12:28:33 +02:00
|
|
|
return 0xff /*dev->regs[port & 1]*/;
|
2017-06-16 03:18:59 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-08 19:21:55 +01:00
|
|
|
static void
|
|
|
|
|
sio_detect_close(void *priv)
|
2017-06-16 03:18:59 +02:00
|
|
|
{
|
2018-11-08 19:21:55 +01:00
|
|
|
sio_detect_t *dev = (sio_detect_t *) priv;
|
2017-06-16 03:18:59 +02:00
|
|
|
|
2018-11-08 19:21:55 +01:00
|
|
|
free(dev);
|
2017-06-16 03:18:59 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-08 19:21:55 +01:00
|
|
|
static void *
|
2023-06-28 13:46:28 -04:00
|
|
|
sio_detect_init(UNUSED(const device_t *info))
|
2017-06-16 03:18:59 +02:00
|
|
|
{
|
2018-11-08 19:21:55 +01:00
|
|
|
sio_detect_t *dev = (sio_detect_t *) malloc(sizeof(sio_detect_t));
|
|
|
|
|
memset(dev, 0, sizeof(sio_detect_t));
|
|
|
|
|
|
|
|
|
|
device_add(&fdc_at_smc_device);
|
|
|
|
|
|
2020-10-15 23:54:18 +02:00
|
|
|
io_sethandler(0x0022, 0x0006,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2018-11-08 19:21:55 +01:00
|
|
|
io_sethandler(0x002e, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2018-11-08 19:21:55 +01:00
|
|
|
io_sethandler(0x0044, 0x0004,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2018-11-08 19:21:55 +01:00
|
|
|
io_sethandler(0x004e, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2018-11-08 19:21:55 +01:00
|
|
|
io_sethandler(0x0108, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-10-16 14:21:23 +02:00
|
|
|
io_sethandler(0x015c, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-04-01 08:59:29 +02:00
|
|
|
io_sethandler(0x0250, 0x0003,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-10-15 23:54:18 +02:00
|
|
|
io_sethandler(0x026e, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-04-01 08:59:29 +02:00
|
|
|
io_sethandler(0x0279, 0x0001,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2022-03-11 22:04:57 -05:00
|
|
|
io_sethandler(FDC_SECONDARY_ADDR, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-10-15 23:54:18 +02:00
|
|
|
io_sethandler(0x0398, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-04-01 08:59:29 +02:00
|
|
|
io_sethandler(0x03e3, 0x0001,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2022-03-11 22:04:57 -05:00
|
|
|
io_sethandler(FDC_PRIMARY_ADDR, 0x0002,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2020-04-01 08:59:29 +02:00
|
|
|
io_sethandler(0x0a79, 0x0001,
|
2022-09-18 17:17:00 -04:00
|
|
|
sio_detect_read, NULL, NULL, sio_detect_write, NULL, NULL, dev);
|
2018-11-08 19:21:55 +01:00
|
|
|
|
|
|
|
|
return dev;
|
2017-06-16 03:18:59 +02:00
|
|
|
}
|
2018-11-08 19:21:55 +01:00
|
|
|
|
|
|
|
|
const device_t sio_detect_device = {
|
2022-09-18 17:17:00 -04:00
|
|
|
.name = "Super I/O Detection Helper",
|
2022-03-13 09:57:57 -04:00
|
|
|
.internal_name = "sio_detect",
|
2022-09-18 17:17:00 -04:00
|
|
|
.flags = 0,
|
|
|
|
|
.local = 0,
|
|
|
|
|
.init = sio_detect_init,
|
|
|
|
|
.close = sio_detect_close,
|
|
|
|
|
.reset = NULL,
|
2022-03-13 09:57:57 -04:00
|
|
|
{ .available = NULL },
|
|
|
|
|
.speed_changed = NULL,
|
2022-09-18 17:17:00 -04:00
|
|
|
.force_redraw = NULL,
|
|
|
|
|
.config = NULL
|
2018-11-08 19:21:55 +01:00
|
|
|
};
|