Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port; Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX); Finished the 586MC1; Added 8087 emulation; Moved Cyrix 6x86'es to the Dev branch; Sanitized/cleaned up memregs.c/h and intel.c/h; Split the chipsets from machines and sanitized Port 92 emulation; Added support for the 15bpp mode to the Compaq ATI 28800; Moved the MR 386DX and 486 machines to the Dev branch; Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00; Ported the new timer code from PCem; Cleaned up the CPU table of unused stuff and better optimized its structure; Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch; Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem; Added the AHA-1540A and the BusTek BT-542B; Moved the Sumo SCSI-AT to the Dev branch; Minor IDE, FDC, and floppy drive code clean-ups; Made NCR 5380/53C400-based cards' BIOS address configurable; Got rid of the legacy romset variable; Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit; Added the Amstead PPC512 per PCem patch by John Elliott; Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages); Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing; Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem; Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit; Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement; Amstrad MegaPC does now works correctly with non-internal graphics card; The SLiRP code no longer casts a packed struct type to a non-packed struct type; The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present; The S3 Virge on BeOS is no longer broken (was broken by build #1591); OS/2 2.0 build 6.167 now sees key presses again; Xi8088 now work on CGA again; 86F images converted from either the old or new variants of the HxC MFM format now work correctly; Hardware interrupts with a vector of 0xFF are now handled correctly; OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct; Fixed VNC keyboard input bugs; Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver; Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly; Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4; Compaq Portable now works with all graphics cards; Fixed various MDSI Genius bugs; Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly; Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355; OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400. Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391. Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389. Fixed a minor IDE timing bug, fixes #388. Fixed Toshiba T1000 RAM issues, fixes #379. Fixed EGA/(S)VGA overscan border handling, fixes #378; Got rid of the now long useless IDE channel 2 auto-removal, fixes #370; Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366; Ported the Unicode CD image file name fix from VARCem, fixes #365; Fixed high density floppy disks on the Xi8088, fixes #359; Fixed some bugs in the Hercules emulation, fixes #346, fixes #358; Fixed the SCSI hard disk mode sense pages, fixes #356; Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349; Fixed bugs in the serial mouse emulation, fixes #344; Compiled 86Box binaries now include all the required .DLL's, fixes #341; Made some combo boxes in the Settings dialog slightly wider, fixes #276.
This commit is contained in:
292
src/chipset/wd76c10.c
Normal file
292
src/chipset/wd76c10.c
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* 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 WD76C10 System Controller chip.
|
||||
*
|
||||
* Version: @(#)wd76c10.c 1.0.0 2019/05/14
|
||||
*
|
||||
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2017-2019 Fred N. van Kempen.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../timer.h"
|
||||
#include "../io.h"
|
||||
#include "../keyboard.h"
|
||||
#include "../mem.h"
|
||||
#include "../port_92.h"
|
||||
#include "../serial.h"
|
||||
#include "../floppy/fdd.h"
|
||||
#include "../floppy/fdc.h"
|
||||
#include "../video/vid_paradise.h"
|
||||
#include "chipset.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
|
||||
uint16_t reg_0092;
|
||||
uint16_t reg_2072;
|
||||
uint16_t reg_2872;
|
||||
uint16_t reg_5872;
|
||||
|
||||
uint16_t reg_f872;
|
||||
|
||||
serial_t *uart[2];
|
||||
|
||||
fdc_t *fdc;
|
||||
|
||||
mem_mapping_t extram_mapping;
|
||||
uint8_t extram[65536];
|
||||
} wd76c10_t;
|
||||
|
||||
|
||||
static uint16_t
|
||||
wd76c10_read(uint16_t port, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
int16_t ret = 0xffff;
|
||||
|
||||
switch (port) {
|
||||
case 0x2072:
|
||||
ret = dev->reg_2072;
|
||||
break;
|
||||
|
||||
case 0x2872:
|
||||
ret = dev->reg_2872;
|
||||
break;
|
||||
|
||||
case 0x5872:
|
||||
ret = dev->reg_5872;
|
||||
break;
|
||||
|
||||
case 0xf872:
|
||||
ret = dev->reg_f872;
|
||||
break;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wd76c10_write(uint16_t port, uint16_t val, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
switch (port) {
|
||||
case 0x2072:
|
||||
dev->reg_2072 = val;
|
||||
|
||||
serial_remove(dev->uart[0]);
|
||||
if (!(val & 0x10))
|
||||
{
|
||||
switch ((val >> 5) & 7)
|
||||
{
|
||||
case 1: serial_setup(dev->uart[0], 0x3f8, 4); break;
|
||||
case 2: serial_setup(dev->uart[0], 0x2f8, 4); break;
|
||||
case 3: serial_setup(dev->uart[0], 0x3e8, 4); break;
|
||||
case 4: serial_setup(dev->uart[0], 0x2e8, 4); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
serial_remove(dev->uart[1]);
|
||||
if (!(val & 0x01))
|
||||
{
|
||||
switch ((val >> 1) & 7)
|
||||
{
|
||||
case 1: serial_setup(dev->uart[1], 0x3f8, 3); break;
|
||||
case 2: serial_setup(dev->uart[1], 0x2f8, 3); break;
|
||||
case 3: serial_setup(dev->uart[1], 0x3e8, 3); break;
|
||||
case 4: serial_setup(dev->uart[1], 0x2e8, 3); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x2872:
|
||||
dev->reg_2872 = val;
|
||||
|
||||
fdc_remove(dev->fdc);
|
||||
if (! (val & 1))
|
||||
fdc_set_base(dev->fdc, 0x03f0);
|
||||
break;
|
||||
|
||||
case 0x5872:
|
||||
dev->reg_5872 = val;
|
||||
break;
|
||||
|
||||
case 0xf872:
|
||||
dev->reg_f872 = val;
|
||||
switch (val & 3) {
|
||||
case 0:
|
||||
mem_set_mem_state(0xd0000, 0x10000, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL);
|
||||
break;
|
||||
case 1:
|
||||
mem_set_mem_state(0xd0000, 0x10000, MEM_READ_INTERNAL | MEM_WRITE_EXTERNAL);
|
||||
break;
|
||||
case 2:
|
||||
mem_set_mem_state(0xd0000, 0x10000, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
|
||||
break;
|
||||
case 3:
|
||||
mem_set_mem_state(0xd0000, 0x10000, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
|
||||
break;
|
||||
}
|
||||
flushmmucache_nopc();
|
||||
if (val & 4)
|
||||
mem_mapping_enable(&dev->extram_mapping);
|
||||
else
|
||||
mem_mapping_disable(&dev->extram_mapping);
|
||||
flushmmucache_nopc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static uint8_t
|
||||
wd76c10_readb(uint16_t port, void *priv)
|
||||
{
|
||||
if (port & 1)
|
||||
return(wd76c10_read(port & ~1, priv) >> 8);
|
||||
|
||||
return(wd76c10_read(port, priv) & 0xff);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wd76c10_writeb(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
uint16_t temp = wd76c10_read(port, priv);
|
||||
|
||||
if (port & 1)
|
||||
wd76c10_write(port & ~1, (temp & 0x00ff) | (val << 8), priv);
|
||||
else
|
||||
wd76c10_write(port , (temp & 0xff00) | val, priv);
|
||||
}
|
||||
|
||||
|
||||
uint8_t
|
||||
wd76c10_read_extram(uint32_t addr, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
return dev->extram[addr & 0xffff];
|
||||
}
|
||||
|
||||
|
||||
uint16_t
|
||||
wd76c10_read_extramw(uint32_t addr, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
return *(uint16_t *)&dev->extram[addr & 0xffff];
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
wd76c10_read_extraml(uint32_t addr, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
return *(uint32_t *)&dev->extram[addr & 0xffff];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wd76c10_write_extram(uint32_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
dev->extram[addr & 0xffff] = val;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wd76c10_write_extramw(uint32_t addr, uint16_t val, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
*(uint16_t *)&dev->extram[addr & 0xffff] = val;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wd76c10_write_extraml(uint32_t addr, uint32_t val, void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
*(uint32_t *)&dev->extram[addr & 0xffff] = val;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wd76c10_close(void *priv)
|
||||
{
|
||||
wd76c10_t *dev = (wd76c10_t *)priv;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
wd76c10_init(const device_t *info)
|
||||
{
|
||||
wd76c10_t *dev;
|
||||
|
||||
dev = (wd76c10_t *) malloc(sizeof(wd76c10_t));
|
||||
memset(dev, 0x00, sizeof(wd76c10_t));
|
||||
dev->type = info->local;
|
||||
|
||||
dev->fdc = (fdc_t *)device_add(&fdc_at_device);
|
||||
|
||||
dev->uart[0] = device_add_inst(&i8250_device, 1);
|
||||
dev->uart[1] = device_add_inst(&i8250_device, 2);
|
||||
|
||||
device_add(&port_92_word_device);
|
||||
|
||||
io_sethandler(0x2072, 2,
|
||||
wd76c10_readb,wd76c10_read,NULL,
|
||||
wd76c10_writeb,wd76c10_write,NULL, dev);
|
||||
io_sethandler(0x2872, 2,
|
||||
wd76c10_readb,wd76c10_read,NULL,
|
||||
wd76c10_writeb,wd76c10_write,NULL, dev);
|
||||
io_sethandler(0x5872, 2,
|
||||
wd76c10_readb,wd76c10_read,NULL,
|
||||
wd76c10_writeb,wd76c10_write,NULL, dev);
|
||||
io_sethandler(0xf872, 2,
|
||||
wd76c10_readb,wd76c10_read,NULL,
|
||||
wd76c10_writeb,wd76c10_write,NULL, dev);
|
||||
|
||||
mem_mapping_add(&dev->extram_mapping, 0xd0000, 0x10000,
|
||||
wd76c10_read_extram,wd76c10_read_extramw,wd76c10_read_extraml,
|
||||
wd76c10_write_extram,wd76c10_write_extramw,wd76c10_write_extraml,
|
||||
dev->extram, MEM_MAPPING_EXTERNAL, dev);
|
||||
mem_mapping_disable(&dev->extram_mapping);
|
||||
|
||||
return(dev);
|
||||
}
|
||||
|
||||
|
||||
const device_t wd76c10_device = {
|
||||
"WD 76C10",
|
||||
0,
|
||||
0,
|
||||
wd76c10_init, wd76c10_close, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
Reference in New Issue
Block a user