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:
OBattler
2019-09-20 14:02:30 +02:00
parent b06296bbf6
commit 552a87ea3d
524 changed files with 129555 additions and 21862 deletions

321
src/lpt.c
View File

@@ -8,12 +8,13 @@
#include "86box.h"
#include "io.h"
#include "lpt.h"
#include "pic.h"
#include "sound/snd_lpt_dac.h"
#include "sound/snd_lpt_dss.h"
#include "printer/prt_devs.h"
char lpt_device_names[3][16];
lpt_port_t lpt_ports[3];
static const struct
@@ -32,205 +33,201 @@ static const struct
{"", "", NULL}
};
char *lpt_device_get_name(int id)
char *
lpt_device_get_name(int id)
{
if (strlen((char *) lpt_devices[id].name) == 0)
return NULL;
return (char *) lpt_devices[id].name;
}
char *lpt_device_get_internal_name(int id)
{
if (strlen((char *) lpt_devices[id].internal_name) == 0)
return NULL;
return (char *) lpt_devices[id].internal_name;
if (strlen((char *) lpt_devices[id].name) == 0)
return NULL;
return (char *) lpt_devices[id].name;
}
static lpt_device_t *lpt_device_ts[3];
static void *lpt_device_ps[3];
void lpt_devices_init()
char *
lpt_device_get_internal_name(int id)
{
int i = 0;
int c;
for (i = 0; i < 3; i++) {
c = 0;
while (strcmp((char *) lpt_devices[c].internal_name, lpt_device_names[i]) && strlen((char *) lpt_devices[c].internal_name) != 0)
c++;
if (strlen((char *) lpt_devices[c].internal_name) == 0)
lpt_device_ts[i] = NULL;
else
{
lpt_device_ts[i] = (lpt_device_t *) lpt_devices[c].device;
if (lpt_device_ts[i])
lpt_device_ps[i] = lpt_device_ts[i]->init(lpt_device_ts[i]);
}
}
if (strlen((char *) lpt_devices[id].internal_name) == 0)
return NULL;
return (char *) lpt_devices[id].internal_name;
}
void lpt_devices_close()
{
int i = 0;
for (i = 0; i < 3; i++) {
if (lpt_device_ts[i])
lpt_device_ts[i]->close(lpt_device_ps[i]);
lpt_device_ts[i] = NULL;
}
int
lpt_device_get_from_internal_name(char *s)
{
int c = 0;
while (strlen((char *) lpt_devices[c].internal_name) != 0) {
if (strcmp(lpt_devices[c].internal_name, s) == 0)
return c;
c++;
}
return 0;
}
static uint8_t lpt_dats[3], lpt_ctrls[3] = { 0x04, 0x04, 0x04 };
void lpt_write(int i, uint16_t port, uint8_t val, void *priv)
void
lpt_devices_init(void)
{
switch (port & 3)
{
case 0:
if (lpt_device_ts[i] && lpt_device_ts[i]->write_data)
lpt_device_ts[i]->write_data(val, lpt_device_ps[i]);
lpt_dats[i] = val;
break;
case 1:
int i = 0;
for (i = 0; i < 3; i++) {
lpt_ports[i].dt = (lpt_device_t *) lpt_devices[lpt_ports[i].device].device;
if (lpt_ports[i].dt)
lpt_ports[i].priv = lpt_ports[i].dt->init(&lpt_ports[i]);
}
}
void
lpt_devices_close(void)
{
int i = 0;
lpt_port_t *dev;
for (i = 0; i < 3; i++) {
dev = &lpt_ports[i];
if (dev->dt)
dev->dt->close(dev->priv);
dev->dt = NULL;
}
}
void
lpt_write(uint16_t port, uint8_t val, void *priv)
{
lpt_port_t *dev = (lpt_port_t *) priv;
switch (port & 3) {
case 0:
if (dev->dt && dev->dt->write_data)
dev->dt->write_data(val, dev->priv);
dev->dat = val;
break;
case 2:
if (lpt_device_ts[i] && lpt_device_ts[i]->write_ctrl)
lpt_device_ts[i]->write_ctrl(val, lpt_device_ps[i]);
lpt_ctrls[i] = val;
break;
}
}
uint8_t lpt_read(int i, uint16_t port, void *priv)
{
uint8_t retval = 0xff;
switch (port & 3)
{
case 0:
if (lpt_device_ts[i] && lpt_device_ts[i]->read_data) {
retval = lpt_device_ts[i]->read_data(lpt_device_ps[i]);
break;
}
retval = lpt_dats[i];
case 1:
break;
case 1:
if (lpt_device_ts[i] && lpt_device_ts[i]->read_status) {
retval = lpt_device_ts[i]->read_status(lpt_device_ps[i]);
break;
}
retval = 0xdf;
break;
case 2:
if (lpt_device_ts[i] && lpt_device_ts[i]->read_ctrl) {
retval = lpt_device_ts[i]->read_ctrl(lpt_device_ps[i]);
break;
}
retval = 0xe0 | lpt_ctrls[i];
case 2:
if (dev->dt && dev->dt->write_ctrl)
dev->dt->write_ctrl(val, dev->priv);
dev->ctrl = val;
break;
}
return retval;
}
void lpt1_write(uint16_t port, uint8_t val, void *priv)
{
lpt_write(0, port, val, priv);
}
uint8_t lpt1_read(uint16_t port, void *priv)
{
return lpt_read(0, port, priv);
}
}
void lpt2_write(uint16_t port, uint8_t val, void *priv)
uint8_t
lpt_read(uint16_t port, void *priv)
{
lpt_write(1, port, val, priv);
uint8_t ret = 0xff;
lpt_port_t *dev = (lpt_port_t *) priv;
switch (port & 3) {
case 0:
if (dev->dt && dev->dt->read_data)
ret = dev->dt->read_data(dev->priv);
else
ret = dev->dat;
break;
case 1:
if (dev->dt && dev->dt->read_status)
ret = dev->dt->read_status(dev->priv);
else
ret = 0xdf;
break;
case 2:
if (dev->dt && dev->dt->read_ctrl)
ret = dev->dt->read_ctrl(dev->priv);
else
ret = 0xe0 | dev->ctrl;
break;
}
return ret;
}
uint8_t lpt2_read(uint16_t port, void *priv)
void
lpt_irq(void *priv, int raise)
{
return lpt_read(1, port, priv);
lpt_port_t *dev = (lpt_port_t *) priv;
uint8_t ctrl = lpt_read(2, priv);
if ((ctrl & 0x10) && (dev->irq != 0xff)) {
if (raise)
picint(1 << dev->irq);
else
picintc(1 << dev->irq);
}
}
void lpt3_write(uint16_t port, uint8_t val, void *priv)
{
lpt_write(2, port, val, priv);
}
uint8_t lpt3_read(uint16_t port, void *priv)
void
lpt_init(void)
{
return lpt_read(2, port, priv);
}
int i;
uint16_t default_ports[3] = { 0x378, 0x278, 0x3bc };
uint8_t default_irqs[3] = { 7, 5, 7 };
uint16_t lpt_addr[3] = { 0x378, 0x278, 0x3bc };
for (i = 0; i < 3; i++) {
lpt_ports[i].addr = 0xffff;
lpt_ports[i].irq = 0xff;
void lpt_init(void)
{
if (lpt_enabled)
{
io_sethandler(0x0378, 0x0003, lpt1_read, NULL, NULL, lpt1_write, NULL, NULL, NULL);
io_sethandler(0x0278, 0x0003, lpt2_read, NULL, NULL, lpt2_write, NULL, NULL, NULL);
lpt_addr[0] = 0x378;
lpt_addr[1] = 0x278;
if (lpt_ports[i].enabled) {
lpt_port_init(i, default_ports[i]);
lpt_port_irq(i, default_irqs[i]);
}
}
}
void lpt1_init(uint16_t port)
void
lpt_port_init(int i, uint16_t port)
{
if (lpt_enabled)
{
io_sethandler(port, 0x0003, lpt1_read, NULL, NULL, lpt1_write, NULL, NULL, NULL);
lpt_addr[0] = port;
}
}
void lpt1_remove(void)
{
if (lpt_enabled)
{
io_removehandler(lpt_addr[0], 0x0003, lpt1_read, NULL, NULL, lpt1_write, NULL, NULL, NULL);
}
}
void lpt2_init(uint16_t port)
{
if (lpt_enabled)
{
io_sethandler(port, 0x0003, lpt2_read, NULL, NULL, lpt2_write, NULL, NULL, NULL);
lpt_addr[1] = port;
}
}
void lpt2_remove(void)
{
if (lpt_enabled)
{
io_removehandler(lpt_addr[1], 0x0003, lpt2_read, NULL, NULL, lpt2_write, NULL, NULL, NULL);
}
if (lpt_ports[i].enabled) {
if (lpt_ports[i].addr != 0xffff)
io_removehandler(lpt_ports[i].addr, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
if (port != 0xffff)
io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
lpt_ports[i].addr = port;
} else
lpt_ports[i].addr = 0xffff;
}
void lpt2_remove_ams(void)
void
lpt_port_irq(int i, uint8_t irq)
{
if (lpt_enabled)
{
io_removehandler(0x0379, 0x0002, lpt2_read, NULL, NULL, lpt2_write, NULL, NULL, NULL);
}
if (lpt_ports[i].enabled)
lpt_ports[i].irq = irq;
else
lpt_ports[i].irq = 0xff;
}
void lpt3_init(uint16_t port)
void
lpt_port_remove(int i)
{
if (lpt_enabled)
{
io_sethandler(port, 0x0003, lpt3_read, NULL, NULL, lpt3_write, NULL, NULL, NULL);
lpt_addr[2] = port;
}
if (lpt_ports[i].enabled && (lpt_ports[i].addr != 0xffff)) {
io_removehandler(lpt_ports[i].addr, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
lpt_ports[i].addr = 0xffff;
}
}
void lpt3_remove(void)
void
lpt1_remove_ams(void)
{
if (lpt_enabled)
{
io_removehandler(lpt_addr[2], 0x0003, lpt3_read, NULL, NULL, lpt3_write, NULL, NULL, NULL);
}
if (lpt_ports[0].enabled)
io_removehandler(lpt_ports[0].addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[0]);
}