Add Virtual PC 2007 port 440h device
This commit is contained in:
187
src/device/vpc2007.c
Normal file
187
src/device/vpc2007.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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 port 440h device from Virtual PC 2007.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Author: RichardG, <richardg867@gmail.com>
|
||||
*
|
||||
* Copyright 2020 RichardG.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#include <86box/mem.h>
|
||||
#include "cpu.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t port440, port440read, port442, port443, port444;
|
||||
} vpc2007_t;
|
||||
|
||||
|
||||
#ifdef ENABLE_VPC2007_LOG
|
||||
int vpc2007_do_log = ENABLE_VPC2007_LOG;
|
||||
|
||||
|
||||
static void
|
||||
vpc2007_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (vpc2007_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
int vpc2007_do_log = 0;
|
||||
|
||||
#define vpc2007_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
static uint8_t
|
||||
vpc2007_read(uint16_t port, void *priv)
|
||||
{
|
||||
vpc2007_t *dev = (vpc2007_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
switch (port) {
|
||||
case 0x440:
|
||||
ret = dev->port440read;
|
||||
dev->port440read = 0x02;
|
||||
break;
|
||||
|
||||
case 0x445:
|
||||
if ((dev->port440 == 0x1e) && (dev->port442 == 0x48) && (dev->port444 == 0xa7)) {
|
||||
switch (dev->port443) {
|
||||
case 0x0b:
|
||||
ret = 0x00;
|
||||
break;
|
||||
|
||||
case 0x1b: case 0x05:
|
||||
ret = 0x01;
|
||||
break;
|
||||
|
||||
case 0x02:
|
||||
ret = 0x02;
|
||||
break;
|
||||
|
||||
case 0x11:
|
||||
ret = 0x04;
|
||||
break;
|
||||
|
||||
case 0x12:
|
||||
ret = 0x06;
|
||||
break;
|
||||
|
||||
case 0x04: case 0x0d:
|
||||
ret = 0x08;
|
||||
break;
|
||||
|
||||
case 0x03: case 0x09:
|
||||
ret = 0x0b;
|
||||
break;
|
||||
|
||||
case 0x15:
|
||||
ret = 0x12;
|
||||
break;
|
||||
|
||||
case 0x17:
|
||||
ret = 0x40;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 0xff)
|
||||
vpc2007_log("VPC2007: unknown combination %02X %02X %02X %02X\n", dev->port440, dev->port442, dev->port443, dev->port444);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
vpc2007_log("VPC2007: read from unknown port %02X\n", port);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
vpc2007_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
vpc2007_t *dev = (vpc2007_t *) priv;
|
||||
uint32_t seg;
|
||||
|
||||
switch (port) {
|
||||
case 0x440:
|
||||
dev->port440 = val;
|
||||
dev->port440read = 0x03;
|
||||
break;
|
||||
|
||||
case 0x442:
|
||||
dev->port442 = val;
|
||||
break;
|
||||
|
||||
case 0x443:
|
||||
dev->port443 = val;
|
||||
break;
|
||||
|
||||
case 0x444:
|
||||
dev->port444 = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
vpc2007_init(const device_t *info)
|
||||
{
|
||||
vpc2007_t *dev = (vpc2007_t *) malloc(sizeof(vpc2007_t));
|
||||
memset(dev, 0, sizeof(vpc2007_t));
|
||||
|
||||
io_sethandler(0x440, 6,
|
||||
vpc2007_read, NULL, NULL, vpc2007_write, NULL, NULL, dev);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
vpc2007_close(void *priv)
|
||||
{
|
||||
vpc2007_t *dev = (vpc2007_t *) priv;
|
||||
|
||||
io_removehandler(0x440, 6,
|
||||
vpc2007_read, NULL, NULL, vpc2007_write, NULL, NULL, dev);
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
||||
const device_t vpc2007_device = {
|
||||
"Virtual PC 2007 Port 440h Device",
|
||||
DEVICE_ISA,
|
||||
0,
|
||||
vpc2007_init, vpc2007_close, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
@@ -84,6 +84,9 @@ ifeq ($(DEV_BUILD), y)
|
||||
ifndef VGAWONDER
|
||||
VGAWONDER := y
|
||||
endif
|
||||
ifndef VIRTUALPC
|
||||
VIRTUALPC := y
|
||||
endif
|
||||
ifndef VNC
|
||||
VNC := y
|
||||
endif
|
||||
@@ -160,6 +163,9 @@ else
|
||||
ifndef VGAWONDER
|
||||
VGAWONDER := n
|
||||
endif
|
||||
ifndef VIRTUALPC
|
||||
VIRTUALPC := y
|
||||
endif
|
||||
ifndef VNC
|
||||
VNC := n
|
||||
endif
|
||||
@@ -554,7 +560,7 @@ endif
|
||||
|
||||
ifeq ($(STPC), y)
|
||||
OPTS += -DUSE_STPC
|
||||
STPCOBJ := stpc.o
|
||||
DEVBROBJ += stpc.o
|
||||
endif
|
||||
|
||||
ifeq ($(596B), y)
|
||||
@@ -565,6 +571,11 @@ ifeq ($(VGAWONDER), y)
|
||||
OPTS += -DUSE_VGAWONDER
|
||||
endif
|
||||
|
||||
ifeq ($(VIRTUALPC), y)
|
||||
OPTS += -DUSE_VIRTUALPC
|
||||
DEVBROBJ += vpc2007.o
|
||||
endif
|
||||
|
||||
ifeq ($(WIN471), y)
|
||||
OPTS += -DUSE_WIN471
|
||||
endif
|
||||
@@ -617,7 +628,7 @@ CPUOBJ := cpu.o cpu_table.o \
|
||||
CHIPSETOBJ := acc2168.o cs8230.o ali1429.o headland.o i82335.o cs4031.o \
|
||||
intel_420ex.o intel_4x0.o intel_sio.o intel_piix.o ioapic.o \
|
||||
neat.o opti495.o opti895.o opti5x7.o scamp.o scat.o via_vt82c49x.o via_vt82c505.o \
|
||||
sis_85c310.o sis_85c471.o sis_85c496.o opti283.o opti291.o $(STPCOBJ) \
|
||||
sis_85c310.o sis_85c471.o sis_85c496.o opti283.o opti291.o \
|
||||
via_apollo.o via_vpx.o via_vt82c586b.o via_vt82c596b.o wd76c10.o vl82c480.o \
|
||||
amd640.o
|
||||
|
||||
@@ -637,7 +648,7 @@ MCHOBJ := machine.o machine_table.o \
|
||||
m_at_socket4_5.o m_at_socket7_s7.o m_at_sockets7.o \
|
||||
m_at_socket8.o m_at_slot1.o m_at_slot2.o m_at_socket370.o
|
||||
|
||||
DEVOBJ := bugger.o hwm.o hwm_lm75.o hwm_lm78.o hwm_gl518sm.o ibm_5161.o isamem.o isartc.o lpt.o postcard.o serial.o \
|
||||
DEVOBJ := bugger.o hwm.o hwm_lm75.o hwm_lm78.o hwm_gl518sm.o ibm_5161.o isamem.o isartc.o lpt.o postcard.o vpc2007.o serial.o \
|
||||
smbus.o smbus_piix4.o \
|
||||
keyboard.o \
|
||||
keyboard_xt.o keyboard_at.o \
|
||||
|
Reference in New Issue
Block a user