Changes to device_t struct to accomodate the upcoming PCI IRQ arbitration rewrite; Added device.c/h API to obtain name from the device_t struct; Significant changes to win/win_settings.c to clean up the code a bit and fix bugs; Ported all the CPU and AudioPCI commits from PCem; Added an API call to allow ACPI soft power off to gracefully stop the emulator; Removed the Siemens PCD-2L from the Dev branch because it now works; Removed the Socket 5 HP Vectra from the Dev branch because it now works; Fixed the Compaq Presario and the Micronics Spitfire; Give the IBM PC330 its own list of 486 CPU so it can have DX2's with CPUID 0x470; SMM fixes; Rewrote the SYSENTER, SYSEXIT, SYSCALL, and SYSRET instructions; Changed IDE reset period to match the specification, fixes #929; The keyboard input and output ports are now forced in front of the queue when read, fixes a number of bugs, including the AMI Apollo hanging on soft reset; Added the Intel AN430TX but Dev branched because it does not work; The network code no longer drops packets if the emulated network card has failed to receive them (eg. when the buffer is full); Changes to PCI card adding and renamed some PCI slot types, also added proper AGP bridge slot types; USB UHCI emulation is no longer a stub (still doesn't fully work, but at least Windows XP chk with Debug no longer ASSERT's on it); Fixed NVR on the the SMC FDC37C932QF and APM variants; A number of fixes to Intel 4x0 chipsets, including fixing every register of the 440LX and 440EX; Some ACPI changes.
187 lines
3.4 KiB
C
187 lines
3.4 KiB
C
/*
|
|
* 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;
|
|
|
|
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
|
|
};
|