mirror of
https://github.com/86Box/86Box.git
synced 2026-02-21 17:15:32 -07:00
Trned the LPT ports into device_t's.
This commit is contained in:
13
src/86box.c
13
src/86box.c
@@ -1265,6 +1265,11 @@ pc_init_modules(void)
|
||||
|
||||
machine_status_init();
|
||||
|
||||
serial_set_next_inst(0);
|
||||
|
||||
lpt_set_3bc_used(0);
|
||||
lpt_set_next_inst(0);
|
||||
|
||||
for (c = 0; c <= 0x7ff; c++) {
|
||||
int64_t exp = c - 1023; /* 1023 = BIAS64 */
|
||||
exp_pow_table[c] = pow(2.0, (double) exp);
|
||||
@@ -1379,10 +1384,6 @@ pc_reset_hard_close(void)
|
||||
|
||||
lpt_devices_close();
|
||||
|
||||
#ifdef UNCOMMENT_LATER
|
||||
lpt_close();
|
||||
#endif
|
||||
|
||||
nvr_save();
|
||||
nvr_close();
|
||||
|
||||
@@ -1411,6 +1412,9 @@ pc_reset_hard_close(void)
|
||||
cpu_close();
|
||||
|
||||
serial_set_next_inst(0);
|
||||
|
||||
lpt_set_3bc_used(0);
|
||||
lpt_set_next_inst(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1472,6 +1476,7 @@ pc_reset_hard_init(void)
|
||||
|
||||
/* Initialize parallel devices. */
|
||||
/* note: PLIP LPT side has to be initialized before the network side */
|
||||
lpt_standalone_init();
|
||||
lpt_devices_init();
|
||||
|
||||
/* Reset and reconfigure the serial ports. */
|
||||
|
||||
@@ -783,8 +783,8 @@ load_ports(void)
|
||||
lpt_ports[c].enabled = !!ini_section_get_int(cat, temp, (c == 0) ? 1 : 0);
|
||||
|
||||
sprintf(temp, "lpt%d_device", c + 1);
|
||||
p = ini_section_get_string(cat, temp, "none");
|
||||
lpt_ports[c].device = lpt_device_get_from_internal_name(p);
|
||||
p = ini_section_get_string(cat, temp, "none");
|
||||
lpt_ports[c].device = lpt_device_get_from_internal_name(p);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -2659,8 +2659,7 @@ save_ports(void)
|
||||
if (lpt_ports[c].device == 0)
|
||||
ini_section_delete_var(cat, temp);
|
||||
else
|
||||
ini_section_set_string(cat, temp,
|
||||
lpt_device_get_internal_name(lpt_ports[c].device));
|
||||
ini_section_set_string(cat, temp, lpt_device_get_internal_name(lpt_ports[c].device));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -349,12 +349,6 @@ device_reset_all(uint32_t match_flags)
|
||||
devices[c]->reset(device_priv[c]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UNCOMMENT_LATER
|
||||
/* TODO: Actually convert the LPT devices to device_t's. */
|
||||
if ((match_flags == DEVICE_ALL) || (match_flags == DEVICE_PCI))
|
||||
lpt_reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void *
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
|
||||
#define HASP_BYTEARRAY(...) \
|
||||
{ \
|
||||
|
||||
483
src/device/lpt.c
483
src/device/lpt.c
@@ -2,8 +2,9 @@
|
||||
see COPYING for more details
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
@@ -11,6 +12,7 @@
|
||||
#include <86box/io.h>
|
||||
#include <86box/fifo.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/dma.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pic.h>
|
||||
@@ -21,7 +23,12 @@
|
||||
#include <86box/machine.h>
|
||||
#include <86box/network.h>
|
||||
|
||||
lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
static int next_inst = 0;
|
||||
int lpt_3bc_used = 0;
|
||||
|
||||
lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
|
||||
lpt_device_t lpt_devs[PARALLEL_MAX];
|
||||
|
||||
const lpt_device_t lpt_none_device = {
|
||||
.name = "None",
|
||||
@@ -109,10 +116,17 @@ void
|
||||
lpt_devices_init(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
lpt_ports[i].dt = (lpt_device_t *) lpt_devices[lpt_ports[i].device].device;
|
||||
lpt_t *dev = lpt_devs[i].lpt;
|
||||
|
||||
if (lpt_ports[i].dt && lpt_ports[i].dt->init)
|
||||
lpt_ports[i].priv = lpt_ports[i].dt->init(&lpt_ports[i]);
|
||||
if (lpt_devices[lpt_ports[i].device].device != NULL) {
|
||||
memcpy(&(lpt_devs[i]), (lpt_device_t *) lpt_devices[lpt_ports[i].device].device, sizeof(lpt_device_t));
|
||||
|
||||
if (lpt_devs[i].init)
|
||||
lpt_devs[i].priv = lpt_devs[i].init(dev);
|
||||
} else
|
||||
memset(&(lpt_devs[i]), 0x00, sizeof(lpt_device_t));
|
||||
|
||||
lpt_devs[i].lpt = dev;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,22 +134,20 @@ void
|
||||
lpt_devices_close(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
lpt_port_t *dev = &lpt_ports[i];
|
||||
if (lpt_devs[i].close)
|
||||
lpt_devs[i].close(lpt_devs[i].priv);
|
||||
|
||||
if (lpt_ports[i].dt && lpt_ports[i].dt->close)
|
||||
dev->dt->close(dev->priv);
|
||||
|
||||
dev->dt = NULL;
|
||||
memset(&(lpt_devs[i]), 0x00, sizeof(lpt_device_t));
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_get_ctrl_raw(const lpt_port_t *dev)
|
||||
lpt_get_ctrl_raw(const lpt_t *dev)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
if (dev->dt && dev->dt->read_ctrl && dev->priv)
|
||||
ret = (dev->dt->read_ctrl(dev->priv) & 0xef) | dev->enable_irq;
|
||||
if (dev->dt && dev->dt->read_ctrl && dev->dt->priv)
|
||||
ret = (dev->dt->read_ctrl(dev->dt->priv) & 0xef) | dev->enable_irq;
|
||||
else
|
||||
ret = 0xc0 | dev->ctrl | dev->enable_irq;
|
||||
|
||||
@@ -143,13 +155,13 @@ lpt_get_ctrl_raw(const lpt_port_t *dev)
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_is_epp(const lpt_port_t *dev)
|
||||
lpt_is_epp(const lpt_t *dev)
|
||||
{
|
||||
return (dev->epp || ((dev->ecp) && ((dev->ecr & 0xe0) == 0x80)));
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_get_ctrl(const lpt_port_t *dev)
|
||||
lpt_get_ctrl(const lpt_t *dev)
|
||||
{
|
||||
uint8_t ret = lpt_get_ctrl_raw(dev);
|
||||
|
||||
@@ -160,7 +172,7 @@ lpt_get_ctrl(const lpt_port_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_write_fifo(lpt_port_t *dev, const uint8_t val, const uint8_t tag)
|
||||
lpt_write_fifo(lpt_t *dev, const uint8_t val, const uint8_t tag)
|
||||
{
|
||||
if (!fifo_get_full(dev->fifo)) {
|
||||
fifo_write_evt_tagged(tag, val, dev->fifo);
|
||||
@@ -171,7 +183,7 @@ lpt_write_fifo(lpt_port_t *dev, const uint8_t val, const uint8_t tag)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_ecp_update_irq(lpt_port_t *dev)
|
||||
lpt_ecp_update_irq(lpt_t *dev)
|
||||
{
|
||||
if (!(dev->ecr & 0x04) && ((dev->fifo_stat | dev->dma_stat) & 0x04))
|
||||
picintlevel(1 << dev->irq, &dev->irq_state);
|
||||
@@ -180,19 +192,19 @@ lpt_ecp_update_irq(lpt_port_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_autofeed(lpt_port_t *dev, const uint8_t val)
|
||||
lpt_autofeed(lpt_t *dev, const uint8_t val)
|
||||
{
|
||||
if (dev->dt && dev->dt->autofeed && dev->priv)
|
||||
dev->dt->autofeed(val, dev->priv);
|
||||
if (dev->dt && dev->dt->autofeed && dev->dt->priv)
|
||||
dev->dt->autofeed(val, dev->dt->priv);
|
||||
|
||||
dev->autofeed = val;
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_strobe(lpt_port_t *dev, const uint8_t val)
|
||||
lpt_strobe(lpt_t *dev, const uint8_t val)
|
||||
{
|
||||
if (dev->dt && dev->dt->strobe && dev->priv)
|
||||
dev->dt->strobe(dev->strobe, val, dev->priv);
|
||||
if (dev->dt && dev->dt->strobe && dev->dt->priv)
|
||||
dev->dt->strobe(dev->strobe, val, dev->dt->priv);
|
||||
|
||||
dev->strobe = val;
|
||||
}
|
||||
@@ -200,7 +212,7 @@ lpt_strobe(lpt_port_t *dev, const uint8_t val)
|
||||
static void
|
||||
lpt_fifo_out_callback(void *priv)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
switch (dev->state) {
|
||||
default:
|
||||
@@ -241,8 +253,8 @@ lpt_fifo_out_callback(void *priv)
|
||||
|
||||
/* We do not currently support sending commands. */
|
||||
if (tag == 0x01) {
|
||||
if (dev->dt && dev->dt->write_data && dev->priv)
|
||||
dev->dt->write_data(val, dev->priv);
|
||||
if (dev->dt && dev->dt->write_data && dev->dt->priv)
|
||||
dev->dt->write_data(val, dev->dt->priv);
|
||||
|
||||
lpt_strobe(dev, 1);
|
||||
lpt_strobe(dev, 0);
|
||||
@@ -278,7 +290,7 @@ lpt_fifo_out_callback(void *priv)
|
||||
void
|
||||
lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
uint16_t mask = 0x0407;
|
||||
|
||||
lpt_log("[W] %04X = %02X\n", port, val);
|
||||
@@ -294,15 +306,15 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
/* AFIFO */
|
||||
lpt_write_fifo(dev, val, 0x00);
|
||||
else if (!(dev->ecr & 0xc0) && (!(dev->ecr & 0x20) || !(lpt_get_ctrl_raw(dev) & 0x20)) &&
|
||||
dev->dt && dev->dt->write_data && dev->priv)
|
||||
dev->dt && dev->dt->write_data && dev->dt->priv)
|
||||
/* DATAR */
|
||||
dev->dt->write_data(val, dev->priv);
|
||||
dev->dt->write_data(val, dev->dt->priv);
|
||||
dev->dat = val;
|
||||
} else {
|
||||
/* DTR */
|
||||
if ((!dev->ext || !(lpt_get_ctrl_raw(dev) & 0x20)) && dev->dt &&
|
||||
dev->dt->write_data && dev->priv)
|
||||
dev->dt->write_data(val, dev->priv);
|
||||
dev->dt->write_data && dev->dt->priv)
|
||||
dev->dt->write_data(val, dev->dt->priv);
|
||||
dev->dat = val;
|
||||
}
|
||||
break;
|
||||
@@ -311,11 +323,11 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
break;
|
||||
|
||||
case 0x0002:
|
||||
if (dev->dt && dev->dt->write_ctrl && dev->priv) {
|
||||
if (dev->dt && dev->dt->write_ctrl && dev->dt->priv) {
|
||||
if (dev->ecp)
|
||||
dev->dt->write_ctrl((val & 0xfc) | dev->autofeed | dev->strobe, dev->priv);
|
||||
dev->dt->write_ctrl((val & 0xfc) | dev->autofeed | dev->strobe, dev->dt->priv);
|
||||
else
|
||||
dev->dt->write_ctrl(val, dev->priv);
|
||||
dev->dt->write_ctrl(val, dev->dt->priv);
|
||||
}
|
||||
dev->ctrl = val;
|
||||
dev->enable_irq = val & 0x10;
|
||||
@@ -326,15 +338,15 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
|
||||
case 0x0003:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->priv)
|
||||
dev->dt->epp_write_data(1, val, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->dt->priv)
|
||||
dev->dt->epp_write_data(1, val, dev->dt->priv);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0004 ... 0x0007:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->priv)
|
||||
dev->dt->epp_write_data(0, val, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_write_data && dev->dt->priv)
|
||||
dev->dt->epp_write_data(0, val, dev->dt->priv);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -396,7 +408,7 @@ lpt_write(const uint16_t port, const uint8_t val, void *priv)
|
||||
static void
|
||||
lpt_fifo_d_ready_evt(void *priv)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (!(dev->ecr & 0x08)) {
|
||||
if (lpt_get_ctrl_raw(dev) & 0x20)
|
||||
@@ -411,7 +423,7 @@ lpt_fifo_d_ready_evt(void *priv)
|
||||
void
|
||||
lpt_write_to_fifo(void *priv, const uint8_t val)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (dev->ecp) {
|
||||
if (((dev->ecr & 0xe0) == 0x20) && (lpt_get_ctrl_raw(dev) & 0x20))
|
||||
@@ -435,13 +447,13 @@ lpt_write_to_fifo(void *priv, const uint8_t val)
|
||||
void
|
||||
lpt_write_to_dat(void *priv, const uint8_t val)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
dev->dat = val;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
lpt_read_fifo(const lpt_port_t *dev)
|
||||
lpt_read_fifo(const lpt_t *dev)
|
||||
{
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
@@ -452,9 +464,8 @@ lpt_read_fifo(const lpt_port_t *dev)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
lpt_read_status(const int port)
|
||||
lpt_read_status(lpt_t *dev)
|
||||
{
|
||||
lpt_port_t *dev = &lpt_ports[port];
|
||||
uint8_t low_bits = 0x07;
|
||||
uint8_t ret;
|
||||
|
||||
@@ -472,8 +483,8 @@ lpt_read_status(const int port)
|
||||
low_bits |= 0x04;
|
||||
}
|
||||
|
||||
if (dev->dt && dev->dt->read_status && dev->priv)
|
||||
ret = (dev->dt->read_status(dev->priv) & 0xf8) | low_bits;
|
||||
if (dev->dt && dev->dt->read_status && dev->dt->priv)
|
||||
ret = (dev->dt->read_status(dev->dt->priv) & 0xf8) | low_bits;
|
||||
else
|
||||
ret = 0xd8 | low_bits;
|
||||
|
||||
@@ -483,9 +494,9 @@ lpt_read_status(const int port)
|
||||
uint8_t
|
||||
lpt_read(const uint16_t port, void *priv)
|
||||
{
|
||||
const lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
uint16_t mask = 0x0407;
|
||||
uint8_t ret = 0xff;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
uint16_t mask = 0x0407;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
/* This is needed so the parallel port at 3BC works. */
|
||||
if (dev->addr & 0x0004)
|
||||
@@ -503,7 +514,7 @@ lpt_read(const uint16_t port, void *priv)
|
||||
break;
|
||||
|
||||
case 0x0001:
|
||||
ret = lpt_read_status(dev->id);
|
||||
ret = lpt_read_status(dev);
|
||||
break;
|
||||
|
||||
case 0x0002:
|
||||
@@ -514,16 +525,16 @@ lpt_read(const uint16_t port, void *priv)
|
||||
|
||||
case 0x0003:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->priv)
|
||||
dev->dt->epp_request_read(1, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->dt->priv)
|
||||
dev->dt->epp_request_read(1, dev->dt->priv);
|
||||
ret = dev->dat;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0004 ... 0x0007:
|
||||
if (lpt_is_epp(dev)) {
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->priv)
|
||||
dev->dt->epp_request_read(0, dev->priv);
|
||||
if (dev->dt && dev->dt->epp_request_read && dev->dt->priv)
|
||||
dev->dt->epp_request_read(0, dev->dt->priv);
|
||||
ret = dev->dat;
|
||||
}
|
||||
break;
|
||||
@@ -543,7 +554,7 @@ lpt_read(const uint16_t port, void *priv)
|
||||
break;
|
||||
case 7:
|
||||
/* CNFGA */
|
||||
ret = 0x14;
|
||||
ret = dev->cnfga_readout;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -575,17 +586,15 @@ lpt_read(const uint16_t port, void *priv)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
lpt_read_port(const int port, const uint16_t reg)
|
||||
lpt_read_port(lpt_t *dev, const uint16_t reg)
|
||||
{
|
||||
lpt_port_t *dev = &(lpt_ports[port]);
|
||||
|
||||
return lpt_read(reg, dev);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_irq(void *priv, const int raise)
|
||||
{
|
||||
lpt_port_t *dev = (lpt_port_t *) priv;
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (dev->enable_irq) {
|
||||
if (dev->irq != 0xff) {
|
||||
@@ -617,79 +626,142 @@ lpt_irq(void *priv, const int raise)
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_ext(const int port, const uint8_t ext)
|
||||
lpt_set_ext(lpt_t *dev, const uint8_t ext)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].ext = ext;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->ext = ext;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_ecp(const int port, const uint8_t ecp)
|
||||
lpt_set_ecp(lpt_t *dev, const uint8_t ecp)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].ecp = ecp;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->ecp = ecp;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_epp(const int port, const uint8_t epp)
|
||||
lpt_set_epp(lpt_t *dev, const uint8_t epp)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].epp = epp;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->epp = epp;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_lv2(const int port, const uint8_t lv2)
|
||||
lpt_set_lv2(lpt_t *dev, const uint8_t lv2)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
lpt_ports[port].lv2 = lv2;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->lv2 = lv2;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_fifo_threshold(const int port, const int threshold)
|
||||
lpt_set_fifo_threshold(lpt_t *dev, const int threshold)
|
||||
{
|
||||
if (lpt_ports[port].enabled)
|
||||
fifo_set_trigger_len(lpt_ports[port].fifo, threshold);
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
fifo_set_trigger_len(dev->fifo, threshold);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_close(void)
|
||||
lpt_set_cnfga_readout(lpt_t *dev, const uint8_t cnfga_readout)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
if (lpt_ports[i].enabled) {
|
||||
fifo_close(lpt_ports[i].fifo);
|
||||
lpt_ports[i].fifo = NULL;
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->cnfga_readout = cnfga_readout;
|
||||
}
|
||||
|
||||
timer_disable(&lpt_ports[i].fifo_out_timer);
|
||||
void
|
||||
lpt_port_setup(lpt_t *dev, const uint16_t port)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
if ((dev->addr != 0x0000) && (dev->addr != 0xffff)) {
|
||||
io_removehandler(dev->addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
io_removehandler(dev->addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
}
|
||||
if ((port != 0x0000) && (port != 0xffff)) {
|
||||
lpt_log("Set handler: %04X-%04X\n", port, port + 0x0003);
|
||||
io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
if (dev->epp)
|
||||
io_sethandler(port + 0x0003, 0x0005, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
if (dev->ecp || dev->lv2) {
|
||||
io_sethandler(port + 0x0400, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
if (dev->epp)
|
||||
io_sethandler(port + 0x0404, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
}
|
||||
}
|
||||
dev->addr = port;
|
||||
} else
|
||||
dev->addr = 0xffff;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_irq(lpt_t *dev, const uint8_t irq)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->irq = irq;
|
||||
else
|
||||
dev->irq = 0xff;
|
||||
|
||||
lpt_log("Port %i IRQ = %02X\n", dev->id, irq);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_dma(lpt_t *dev, const uint8_t dma)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
dev->dma = dma;
|
||||
else
|
||||
dev->dma = 0xff;
|
||||
|
||||
lpt_log("Port %i DMA = %02X\n", dev->id, dma);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_remove(lpt_t *dev)
|
||||
{
|
||||
if (lpt_ports[dev->id].enabled && (dev->addr != 0xffff)) {
|
||||
io_removehandler(dev->addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
io_removehandler(dev->addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
|
||||
dev->addr = 0xffff;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_zero(lpt_port_t *dev)
|
||||
lpt1_remove_ams(lpt_t *dev)
|
||||
{
|
||||
lpt_port_t temp = { 0 };
|
||||
if (dev->enabled)
|
||||
io_removehandler(dev->addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, dev);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_speed_changed(void *priv)
|
||||
{
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (timer_is_enabled(&dev->fifo_out_timer)) {
|
||||
timer_disable(&dev->fifo_out_timer);
|
||||
timer_set_delay_u64(&dev->fifo_out_timer, (uint64_t) ((1000000.0 / 2500000.0) * (double) TIMER_USEC));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_zero(lpt_t *dev)
|
||||
{
|
||||
lpt_t temp = { 0 };
|
||||
|
||||
temp.irq = dev->irq;
|
||||
temp.id = dev->id;
|
||||
temp.device = dev->device;
|
||||
temp.dt = dev->dt;
|
||||
temp.priv = dev->priv;
|
||||
temp.enabled = dev->enabled;
|
||||
temp.fifo = dev->fifo;
|
||||
temp.fifo_out_timer = dev->fifo_out_timer;
|
||||
|
||||
if (dev->enabled)
|
||||
lpt_port_remove(dev->id);
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
lpt_port_remove(dev);
|
||||
|
||||
memset(dev, 0x00, sizeof(lpt_port_t));
|
||||
memset(dev, 0x00, sizeof(lpt_t));
|
||||
|
||||
dev->addr = 0xffff;
|
||||
dev->irq = temp.irq;
|
||||
dev->id = temp.id;
|
||||
dev->device = temp.device;
|
||||
dev->dt = temp.dt;
|
||||
dev->priv = temp.priv;
|
||||
dev->enabled = temp.enabled;
|
||||
dev->fifo = temp.fifo;
|
||||
dev->fifo_out_timer = temp.fifo_out_timer;
|
||||
|
||||
@@ -697,138 +769,149 @@ lpt_port_zero(lpt_port_t *dev)
|
||||
dev->ext = 1;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_reset(void)
|
||||
static void
|
||||
lpt_close(void *priv)
|
||||
{
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
if (lpt_ports[i].enabled)
|
||||
if (timer_is_enabled(&lpt_ports[i].fifo_out_timer))
|
||||
timer_disable(&lpt_ports[i].fifo_out_timer);
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
lpt_port_zero(&(lpt_ports[i]));
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
fifo_close(dev->fifo);
|
||||
dev->fifo = NULL;
|
||||
|
||||
if (lpt_ports[i].enabled) {
|
||||
if (lpt_ports[i].irq_state) {
|
||||
if (lpt_ports[i].irq == 0xff)
|
||||
lpt_ports[i].irq_state = 0x00;
|
||||
else {
|
||||
picintclevel(lpt_ports[i].irq, &lpt_ports[i].irq_state);
|
||||
picintc(lpt_ports[i].irq);
|
||||
}
|
||||
timer_disable(&dev->fifo_out_timer);
|
||||
|
||||
}
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
lpt_reset(void *priv)
|
||||
{
|
||||
lpt_t *dev = (lpt_t *) priv;
|
||||
|
||||
if (lpt_ports[dev->id].enabled)
|
||||
if (timer_is_enabled(&dev->fifo_out_timer))
|
||||
timer_disable(&dev->fifo_out_timer);
|
||||
|
||||
lpt_port_zero(dev);
|
||||
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
if (dev->irq_state) {
|
||||
if (dev->irq == 0xff)
|
||||
dev->irq_state = 0x00;
|
||||
else {
|
||||
picintclevel(dev->irq, &dev->irq_state);
|
||||
picintc(dev->irq);
|
||||
}
|
||||
|
||||
lpt_ports[i].enable_irq = 0x00;
|
||||
lpt_ports[i].ext = !!(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
lpt_ports[i].epp = 0;
|
||||
lpt_ports[i].ecp = 0;
|
||||
lpt_ports[i].ecr = 0x15;
|
||||
lpt_ports[i].dat = 0xff;
|
||||
lpt_ports[i].fifo_stat = 0x00;
|
||||
lpt_ports[i].dma_stat = 0x00;
|
||||
}
|
||||
|
||||
dev->enable_irq = 0x00;
|
||||
dev->ext = !!(machine_has_bus(machine, MACHINE_BUS_MCA));
|
||||
dev->epp = 0;
|
||||
dev->ecp = 0;
|
||||
dev->ecr = 0x15;
|
||||
dev->dat = 0xff;
|
||||
dev->fifo_stat = 0x00;
|
||||
dev->dma_stat = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_init(void)
|
||||
static void *
|
||||
lpt_init(const device_t *info)
|
||||
{
|
||||
lpt_t *dev = (lpt_t *) calloc(1, sizeof(lpt_t));
|
||||
int orig_inst = next_inst;
|
||||
|
||||
const uint16_t default_ports[PARALLEL_MAX] = { LPT1_ADDR, LPT2_ADDR, LPT_MDA_ADDR, LPT4_ADDR };
|
||||
const uint8_t default_irqs[PARALLEL_MAX] = { LPT1_IRQ, LPT2_IRQ, LPT_MDA_IRQ, LPT4_IRQ };
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; i++) {
|
||||
lpt_ports[i].id = i;
|
||||
lpt_ports[i].dt = NULL;
|
||||
lpt_ports[i].priv = NULL;
|
||||
lpt_ports[i].fifo = NULL;
|
||||
memset(&lpt_ports[i].fifo_out_timer, 0x00, sizeof(pc_timer_t));
|
||||
if (info->local & 0xFFF00000)
|
||||
next_inst = PARALLEL_MAX - 1;
|
||||
|
||||
lpt_port_zero(&(lpt_ports[i]));
|
||||
dev->id = next_inst;
|
||||
|
||||
lpt_ports[i].addr = 0xffff;
|
||||
lpt_ports[i].irq = 0xff;
|
||||
lpt_ports[i].dma = 0xff;
|
||||
lpt_ports[i].enable_irq = 0x00;
|
||||
lpt_ports[i].ext = 0;
|
||||
lpt_ports[i].epp = 0;
|
||||
lpt_ports[i].ecp = 0;
|
||||
lpt_ports[i].ecr = 0x15;
|
||||
if (lpt_ports[next_inst].enabled || (info->local & 0xFFF00000)) {
|
||||
lpt_log("Adding parallel port %i...\n", next_inst);
|
||||
dev->dt = &(lpt_devs[next_inst]);
|
||||
dev->dt->lpt = dev;
|
||||
|
||||
if (lpt_ports[i].enabled) {
|
||||
lpt_port_setup(i, default_ports[i]);
|
||||
lpt_port_irq(i, default_irqs[i]);
|
||||
dev->fifo = NULL;
|
||||
memset(&dev->fifo_out_timer, 0x00, sizeof(pc_timer_t));
|
||||
|
||||
lpt_ports[i].fifo = fifo16_init();
|
||||
lpt_port_zero(dev);
|
||||
|
||||
fifo_set_trigger_len(lpt_ports[i].fifo, 8);
|
||||
dev->addr = 0xffff;
|
||||
dev->irq = 0xff;
|
||||
dev->dma = 0xff;
|
||||
dev->enable_irq = 0x00;
|
||||
dev->ext = 0;
|
||||
dev->epp = 0;
|
||||
dev->ecp = 0;
|
||||
dev->ecr = 0x15;
|
||||
dev->cnfga_readout = 0x14;
|
||||
|
||||
fifo_set_d_ready_evt(lpt_ports[i].fifo, lpt_fifo_d_ready_evt);
|
||||
fifo_set_priv(lpt_ports[i].fifo, &lpt_ports[i]);
|
||||
|
||||
timer_add(&lpt_ports[i].fifo_out_timer, lpt_fifo_out_callback, &lpt_ports[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_setup(const int i, const uint16_t port)
|
||||
{
|
||||
if (lpt_ports[i].enabled) {
|
||||
if ((lpt_ports[i].addr != 0x0000) && (lpt_ports[i].addr != 0xffff)) {
|
||||
io_removehandler(lpt_ports[i].addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
io_removehandler(lpt_ports[i].addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
}
|
||||
if ((port != 0x0000) && (port != 0xffff)) {
|
||||
lpt_log("Set handler: %04X-%04X\n", port, port + 0x0003);
|
||||
io_sethandler(port, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[i].epp)
|
||||
io_sethandler(port + 0x0003, 0x0005, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[i].ecp || lpt_ports[i].lv2) {
|
||||
io_sethandler(port + 0x0400, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[i].epp)
|
||||
io_sethandler(port + 0x0404, 0x0003, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
if (lpt_ports[dev->id].enabled) {
|
||||
if (info->local & 0xfff00000) {
|
||||
lpt_port_setup(dev, info->local >> 20);
|
||||
lpt_port_irq(dev, (info->local >> 16) & 0xF);
|
||||
next_inst = orig_inst;
|
||||
} else {
|
||||
if ((dev->id == 2) && (lpt_3bc_used)) {
|
||||
lpt_port_setup(dev, LPT1_ADDR);
|
||||
lpt_port_irq(dev, LPT1_IRQ);
|
||||
} else {
|
||||
lpt_port_setup(dev, default_ports[dev->id]);
|
||||
lpt_port_irq(dev, default_irqs[dev->id]);
|
||||
}
|
||||
}
|
||||
|
||||
dev->fifo = fifo16_init();
|
||||
|
||||
fifo_set_trigger_len(dev->fifo, 8);
|
||||
|
||||
fifo_set_d_ready_evt(dev->fifo, lpt_fifo_d_ready_evt);
|
||||
fifo_set_priv(dev->fifo, dev);
|
||||
|
||||
timer_add(&dev->fifo_out_timer, lpt_fifo_out_callback, dev, 0);
|
||||
}
|
||||
lpt_ports[i].addr = port;
|
||||
} else
|
||||
lpt_ports[i].addr = 0xffff;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_irq(const int i, const uint8_t irq)
|
||||
{
|
||||
if (lpt_ports[i].enabled)
|
||||
lpt_ports[i].irq = irq;
|
||||
else
|
||||
lpt_ports[i].irq = 0xff;
|
||||
|
||||
lpt_log("Port %i IRQ = %02X\n", i, irq);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_dma(const int i, const uint8_t dma)
|
||||
{
|
||||
if (lpt_ports[i].enabled)
|
||||
lpt_ports[i].dma = dma;
|
||||
else
|
||||
lpt_ports[i].dma = 0xff;
|
||||
|
||||
lpt_log("Port %i DMA = %02X\n", i, dma);
|
||||
}
|
||||
|
||||
void
|
||||
lpt_port_remove(const int i)
|
||||
{
|
||||
if (lpt_ports[i].enabled && (lpt_ports[i].addr != 0xffff)) {
|
||||
io_removehandler(lpt_ports[i].addr, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
io_removehandler(lpt_ports[i].addr + 0x0400, 0x0007, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[i]);
|
||||
|
||||
lpt_ports[i].addr = 0xffff;
|
||||
}
|
||||
|
||||
if (!(info->local & 0xfff00000))
|
||||
next_inst++;
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
lpt1_remove_ams(void)
|
||||
lpt_set_next_inst(int ni)
|
||||
{
|
||||
if (lpt_ports[0].enabled)
|
||||
io_removehandler(lpt_ports[0].addr + 1, 0x0002, lpt_read, NULL, NULL, lpt_write, NULL, NULL, &lpt_ports[0]);
|
||||
next_inst = ni;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_set_3bc_used(int is_3bc_used)
|
||||
{
|
||||
lpt_3bc_used = is_3bc_used;
|
||||
}
|
||||
|
||||
void
|
||||
lpt_standalone_init(void)
|
||||
{
|
||||
while (next_inst < (PARALLEL_MAX - 1))
|
||||
device_add_inst(&lpt_port_device, next_inst + 1);
|
||||
};
|
||||
|
||||
const device_t lpt_port_device = {
|
||||
.name = "Parallel Port",
|
||||
.internal_name = "lpt",
|
||||
.flags = 0,
|
||||
.local = 0,
|
||||
.init = lpt_init,
|
||||
.close = lpt_close,
|
||||
.reset = lpt_reset,
|
||||
.available = NULL,
|
||||
.speed_changed = lpt_speed_changed,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
@@ -18,65 +18,25 @@
|
||||
#endif
|
||||
|
||||
typedef struct lpt_device_t {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
const char * name;
|
||||
const char * internal_name;
|
||||
|
||||
void *(*init)(void *lpt);
|
||||
void (*close)(void *priv);
|
||||
void (*write_data)(uint8_t val, void *priv);
|
||||
void (*write_ctrl)(uint8_t val, void *priv);
|
||||
void (*autofeed)(uint8_t val,void *priv);
|
||||
void (*strobe)(uint8_t old, uint8_t val,void *priv);
|
||||
uint8_t (*read_status)(void *priv);
|
||||
uint8_t (*read_ctrl)(void *priv);
|
||||
void (*epp_write_data)(uint8_t is_addr, uint8_t val, void *priv);
|
||||
void (*epp_request_read)(uint8_t is_addr, void *priv);
|
||||
void * (*init)(void *lpt);
|
||||
void (*close)(void *priv);
|
||||
void (*write_data)(uint8_t val, void *priv);
|
||||
void (*write_ctrl)(uint8_t val, void *priv);
|
||||
void (*autofeed)(uint8_t val,void *priv);
|
||||
void (*strobe)(uint8_t old, uint8_t val,void *priv);
|
||||
uint8_t (*read_status)(void *priv);
|
||||
uint8_t (*read_ctrl)(void *priv);
|
||||
void (*epp_write_data)(uint8_t is_addr, uint8_t val, void *priv);
|
||||
void (*epp_request_read)(uint8_t is_addr, void *priv);
|
||||
|
||||
void * priv;
|
||||
struct lpt_t *lpt;
|
||||
} lpt_device_t;
|
||||
|
||||
extern void lpt_set_ext(int port, uint8_t ext);
|
||||
extern void lpt_set_ecp(int port, uint8_t ecp);
|
||||
extern void lpt_set_epp(int port, uint8_t epp);
|
||||
extern void lpt_set_lv2(int port, uint8_t lv2);
|
||||
extern void lpt_set_fifo_threshold(int port, int threshold);
|
||||
extern void lpt_reset(void);
|
||||
extern void lpt_close(void);
|
||||
extern void lpt_init(void);
|
||||
extern void lpt_port_setup(int i, uint16_t port);
|
||||
extern void lpt_port_irq(int i, uint8_t irq);
|
||||
extern void lpt_port_dma(int i, uint8_t dma);
|
||||
extern void lpt_port_remove(int i);
|
||||
extern void lpt1_remove_ams(void);
|
||||
|
||||
#define lpt1_setup(a) lpt_port_setup(0, a)
|
||||
#define lpt1_irq(a) lpt_port_irq(0, a)
|
||||
#define lpt1_remove() lpt_port_remove(0)
|
||||
|
||||
#define lpt2_setup(a) lpt_port_setup(1, a)
|
||||
#define lpt2_irq(a) lpt_port_irq(1, a)
|
||||
#define lpt2_remove() lpt_port_remove(1)
|
||||
|
||||
#define lpt3_setup(a) lpt_port_setup(2, a)
|
||||
#define lpt3_irq(a) lpt_port_irq(2, a)
|
||||
#define lpt3_remove() lpt_port_remove(2)
|
||||
|
||||
#define lpt4_setup(a) lpt_port_setup(3, a)
|
||||
#define lpt4_irq(a) lpt_port_irq(3, a)
|
||||
#define lpt4_remove() lpt_port_remove(3)
|
||||
|
||||
#if 0
|
||||
#define lpt5_setup(a) lpt_port_setup(4, a)
|
||||
#define lpt5_irq(a) lpt_port_irq(4, a)
|
||||
#define lpt5_remove() lpt_port_remove(4)
|
||||
|
||||
#define lpt6_setup(a) lpt_port_setup(5, a)
|
||||
#define lpt6_irq(a) lpt_port_irq(5, a)
|
||||
#define lpt6_remove() lpt_port_remove(5)
|
||||
#endif
|
||||
|
||||
void lpt_devices_init(void);
|
||||
void lpt_devices_close(void);
|
||||
|
||||
typedef struct lpt_port_t {
|
||||
typedef struct lpt_t {
|
||||
uint8_t enabled;
|
||||
uint8_t irq;
|
||||
uint8_t irq_state;
|
||||
@@ -94,46 +54,52 @@ typedef struct lpt_port_t {
|
||||
uint8_t autofeed;
|
||||
uint8_t strobe;
|
||||
uint8_t lv2;
|
||||
uint8_t pad[7];
|
||||
uint8_t cnfga_readout;
|
||||
uint8_t inst;
|
||||
uint8_t pad[5];
|
||||
uint16_t addr;
|
||||
uint16_t id;
|
||||
uint16_t pad0[2];
|
||||
int device;
|
||||
int enable_irq;
|
||||
lpt_device_t *dt;
|
||||
#ifdef FIFO_H
|
||||
fifo16_t *fifo;
|
||||
fifo16_t * fifo;
|
||||
#else
|
||||
void *fifo;
|
||||
void * fifo;
|
||||
#endif
|
||||
void *priv;
|
||||
|
||||
pc_timer_t fifo_out_timer;
|
||||
} lpt_t;
|
||||
|
||||
typedef struct lpt_port_s {
|
||||
uint8_t enabled;
|
||||
|
||||
int device;
|
||||
} lpt_port_t;
|
||||
|
||||
extern lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
|
||||
typedef enum {
|
||||
LPT_STATE_IDLE = 0,
|
||||
LPT_STATE_READ_DMA,
|
||||
LPT_STATE_WRITE_FIFO
|
||||
} lpt_state_t;
|
||||
|
||||
extern lpt_port_t lpt_ports[PARALLEL_MAX];
|
||||
extern void lpt_write(uint16_t port, uint8_t val, void *priv);
|
||||
|
||||
extern void lpt_write(uint16_t port, uint8_t val, void *priv);
|
||||
extern void lpt_write_to_fifo(void *priv, uint8_t val);
|
||||
|
||||
extern void lpt_write_to_fifo(void *priv, uint8_t val);
|
||||
extern uint8_t lpt_read(uint16_t port, void *priv);
|
||||
|
||||
extern uint8_t lpt_read(uint16_t port, void *priv);
|
||||
extern uint8_t lpt_read_port(lpt_t *dev, uint16_t reg);
|
||||
|
||||
extern uint8_t lpt_read_port(int port, uint16_t reg);
|
||||
extern uint8_t lpt_read_status(lpt_t *dev);
|
||||
extern void lpt_irq(void *priv, int raise);
|
||||
|
||||
extern uint8_t lpt_read_status(int port);
|
||||
extern void lpt_irq(void *priv, int raise);
|
||||
extern int lpt_device_get_from_internal_name(const char *s);
|
||||
|
||||
extern int lpt_device_get_from_internal_name(const char *s);
|
||||
|
||||
extern const char *lpt_device_get_name(int id);
|
||||
extern const char *lpt_device_get_internal_name(int id);
|
||||
extern const char * lpt_device_get_name(int id);
|
||||
extern const char * lpt_device_get_internal_name(int id);
|
||||
|
||||
extern const lpt_device_t lpt_dac_device;
|
||||
extern const lpt_device_t lpt_dac_stereo_device;
|
||||
@@ -142,4 +108,42 @@ extern const lpt_device_t dss_device;
|
||||
|
||||
extern const lpt_device_t lpt_hasp_savquest_device;
|
||||
|
||||
extern void lpt_set_ext(lpt_t *dev, uint8_t ext);
|
||||
extern void lpt_set_ecp(lpt_t *dev, uint8_t ecp);
|
||||
extern void lpt_set_epp(lpt_t *dev, uint8_t epp);
|
||||
extern void lpt_set_lv2(lpt_t *dev, uint8_t lv2);
|
||||
extern void lpt_set_fifo_threshold(lpt_t *dev, int threshold);
|
||||
extern void lpt_set_cnfga_readout(lpt_t *dev, const uint8_t cnfga_readout);
|
||||
extern void lpt_port_setup(lpt_t *dev, uint16_t port);
|
||||
extern void lpt_port_irq(lpt_t *dev, uint8_t irq);
|
||||
extern void lpt_port_dma(lpt_t *dev, uint8_t dma);
|
||||
extern void lpt_port_remove(lpt_t *dev);
|
||||
extern void lpt1_remove_ams(lpt_t *dev);
|
||||
|
||||
#define lpt1_setup(a) lpt_port_setup(0, a)
|
||||
#define lpt1_irq(a) lpt_port_irq(0, a)
|
||||
#define lpt1_remove() lpt_port_remove(0)
|
||||
|
||||
#define lpt2_setup(a) lpt_port_setup(1, a)
|
||||
#define lpt2_irq(a) lpt_port_irq(1, a)
|
||||
#define lpt2_remove() lpt_port_remove(1)
|
||||
|
||||
#define lpt3_setup(a) lpt_port_setup(2, a)
|
||||
#define lpt3_irq(a) lpt_port_irq(2, a)
|
||||
#define lpt3_remove() lpt_port_remove(2)
|
||||
|
||||
#define lpt4_setup(a) lpt_port_setup(3, a)
|
||||
#define lpt4_irq(a) lpt_port_irq(3, a)
|
||||
#define lpt4_remove() lpt_port_remove(3)
|
||||
|
||||
extern void lpt_devices_init(void);
|
||||
extern void lpt_devices_close(void);
|
||||
|
||||
extern void lpt_set_next_inst(int ni);
|
||||
extern void lpt_set_3bc_used(int is_3bc_used);
|
||||
|
||||
extern void lpt_standalone_init(void);
|
||||
|
||||
extern const device_t lpt_port_device;
|
||||
|
||||
#endif /*EMU_LPT_H*/
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
typedef struct colorplus_t {
|
||||
cga_t cga;
|
||||
uint8_t control;
|
||||
|
||||
lpt_t * lpt;
|
||||
} colorplus_t;
|
||||
|
||||
void colorplus_init(colorplus_t *colorplus);
|
||||
|
||||
@@ -60,6 +60,7 @@ typedef struct {
|
||||
|
||||
int cols[256][2][2];
|
||||
|
||||
lpt_t *lpt;
|
||||
uint8_t *vram;
|
||||
int monitor_index;
|
||||
int prev_monitor_index;
|
||||
|
||||
@@ -119,7 +119,8 @@ typedef struct mda_t {
|
||||
int32_t prev_monitor_index;
|
||||
int32_t monitor_type; // Used for MDA Colour support (REV0 u64)
|
||||
|
||||
uint8_t *vram;
|
||||
uint8_t *vram;
|
||||
lpt_t *lpt;
|
||||
} mda_t;
|
||||
|
||||
#define VIDEO_MONITOR_PROLOGUE() \
|
||||
|
||||
@@ -155,7 +155,9 @@ typedef struct amstrad_t {
|
||||
|
||||
/* Video stuff. */
|
||||
amsvid_t *vid;
|
||||
|
||||
fdc_t *fdc;
|
||||
lpt_t *lpt;
|
||||
} amstrad_t;
|
||||
|
||||
uint32_t amstrad_latch;
|
||||
@@ -2884,8 +2886,10 @@ machine_amstrad_init(const machine_t *model, int type)
|
||||
|
||||
nmi_init();
|
||||
|
||||
lpt1_remove_ams();
|
||||
lpt2_remove();
|
||||
ams->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
lpt1_remove_ams(ams->lpt);
|
||||
lpt_set_next_inst(255);
|
||||
|
||||
io_sethandler(0x0378, 3,
|
||||
ams_read, NULL, NULL, ams_write, NULL, NULL, ams);
|
||||
|
||||
@@ -55,22 +55,22 @@
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
static serial_t *cmd_uart;
|
||||
static lpt_t *cmd_lpt;
|
||||
|
||||
static void
|
||||
cbm_io_write(UNUSED(uint16_t port), uint8_t val, UNUSED(void *priv))
|
||||
{
|
||||
lpt1_remove();
|
||||
lpt2_remove();
|
||||
lpt_port_remove(cmd_lpt);
|
||||
|
||||
switch (val & 3) {
|
||||
case 1:
|
||||
lpt1_setup(LPT_MDA_ADDR);
|
||||
lpt_port_setup(cmd_lpt, LPT_MDA_ADDR);
|
||||
break;
|
||||
case 2:
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt_port_setup(cmd_lpt, LPT1_ADDR);
|
||||
break;
|
||||
case 3:
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt_port_setup(cmd_lpt, LPT2_ADDR);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -116,6 +116,10 @@ machine_at_cmdpc_init(const machine_t *model)
|
||||
device_add(&fdc_at_device);
|
||||
|
||||
cmd_uart = device_add(&ns8250_device);
|
||||
serial_set_next_inst(1);
|
||||
|
||||
cmd_lpt = device_add(&lpt_port_device);
|
||||
lpt_set_next_inst(1);
|
||||
|
||||
cbm_io_init();
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ typedef struct {
|
||||
uint8_t ps1_e0_regs[256];
|
||||
|
||||
serial_t *uart;
|
||||
lpt_t *lpt;
|
||||
} ps1_t;
|
||||
|
||||
static void
|
||||
@@ -135,7 +136,7 @@ ps1_write(uint16_t port, uint8_t val, void *priv)
|
||||
|
||||
case 0x0102:
|
||||
if (!(ps->ps1_94 & 0x80)) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(ps->lpt);
|
||||
serial_remove(ps->uart);
|
||||
if (val & 0x04) {
|
||||
if (val & 0x08)
|
||||
@@ -146,13 +147,13 @@ ps1_write(uint16_t port, uint8_t val, void *priv)
|
||||
if (val & 0x10) {
|
||||
switch ((val >> 5) & 3) {
|
||||
case 0:
|
||||
lpt1_setup(LPT_MDA_ADDR);
|
||||
lpt_port_setup(ps->lpt, LPT_MDA_ADDR);
|
||||
break;
|
||||
case 1:
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt_port_setup(ps->lpt, LPT1_ADDR);
|
||||
break;
|
||||
case 2:
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt_port_setup(ps->lpt, LPT2_ADDR);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -314,9 +315,9 @@ ps1_setup(int model)
|
||||
ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps);
|
||||
|
||||
ps->uart = device_add_inst(&ns16450_device, 1);
|
||||
|
||||
lpt1_remove();
|
||||
lpt1_setup(LPT_MDA_ADDR);
|
||||
ps->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_remove(ps->lpt);
|
||||
lpt_port_setup(ps->lpt, LPT_MDA_ADDR);
|
||||
|
||||
mem_remap_top(384);
|
||||
|
||||
@@ -345,7 +346,7 @@ ps1_setup(int model)
|
||||
0xfc0000, 0x40000, 0x3ffff, 0, MEM_MAPPING_EXTERNAL);
|
||||
}
|
||||
|
||||
lpt2_remove();
|
||||
lpt_set_next_inst(255);
|
||||
|
||||
device_add(&ps1snd_device);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <86box/nmi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/nvr.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/mouse.h>
|
||||
|
||||
@@ -129,7 +129,8 @@ machine_zenith_init(const machine_t *model)
|
||||
int
|
||||
machine_xt_z184_init(const machine_t *model)
|
||||
{
|
||||
int ret;
|
||||
lpt_t *lpt = NULL;
|
||||
int ret;
|
||||
|
||||
ret = bios_load_linear("roms/machines/zdsupers/z184m v3.1d.10d",
|
||||
0x000f8000, 32768, 0);
|
||||
@@ -142,9 +143,11 @@ machine_xt_z184_init(const machine_t *model)
|
||||
if (fdc_current[0] == FDC_INTERNAL)
|
||||
device_add(&fdc_xt_device);
|
||||
|
||||
lpt1_remove(); /* only one parallel port */
|
||||
lpt2_remove();
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_remove(lpt);
|
||||
lpt_port_setup(lpt, LPT2_ADDR);
|
||||
lpt_set_next_inst(255);
|
||||
|
||||
device_add(&ns8250_device);
|
||||
/* So that serial_standalone_init() won't do anything. */
|
||||
serial_set_next_inst(SERIAL_MAX - 1);
|
||||
@@ -183,7 +186,8 @@ machine_xt_z151_init(const machine_t *model)
|
||||
int
|
||||
machine_xt_z159_init(const machine_t *model)
|
||||
{
|
||||
int ret;
|
||||
lpt_t *lpt = NULL;
|
||||
int ret;
|
||||
|
||||
ret = bios_load_linear("roms/machines/zdsz159/z159m v2.9e.10d",
|
||||
0x000f8000, 32768, 0);
|
||||
@@ -197,9 +201,10 @@ machine_xt_z159_init(const machine_t *model)
|
||||
device_add(&fdc_xt_tandy_device);
|
||||
|
||||
/* parallel port is on the memory board */
|
||||
lpt1_remove(); /* only one parallel port */
|
||||
lpt2_remove();
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_remove(lpt);
|
||||
lpt_port_setup(lpt, LPT2_ADDR);
|
||||
lpt_set_next_inst(255);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -98,8 +98,6 @@ machine_init_ex(int m)
|
||||
mem_reset();
|
||||
smbase = is_am486dxl ? 0x00060000 : 0x00030000;
|
||||
|
||||
lpt_init();
|
||||
|
||||
if (cassette_enable)
|
||||
device_add(&cassette_device);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/pit.h>
|
||||
@@ -499,7 +500,9 @@ const lpt_device_t lpt_plip_device = {
|
||||
.read_status = plip_read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
const device_t plip_device = {
|
||||
|
||||
@@ -2108,5 +2108,7 @@ const lpt_device_t lpt_prt_escp_device = {
|
||||
.read_status = read_status,
|
||||
.read_ctrl = read_ctrl,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/path.h>
|
||||
@@ -536,7 +537,9 @@ const lpt_device_t lpt_prt_ps_device = {
|
||||
.read_status = ps_read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
#ifdef USE_PCL
|
||||
@@ -552,6 +555,8 @@ const lpt_device_t lpt_prt_pcl_device = {
|
||||
.read_status = ps_read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -525,5 +525,7 @@ const lpt_device_t lpt_prt_text_device = {
|
||||
.read_status = read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef struct i82091aa_t {
|
||||
uint16_t base_address;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} i82091aa_t;
|
||||
|
||||
static void
|
||||
@@ -57,7 +58,7 @@ lpt1_handler(i82091aa_t *dev)
|
||||
{
|
||||
uint16_t lpt_port = LPT1_ADDR;
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
switch ((dev->regs[0x20] >> 1) & 0x03) {
|
||||
case 0x00:
|
||||
@@ -78,9 +79,9 @@ lpt1_handler(i82091aa_t *dev)
|
||||
}
|
||||
|
||||
if ((dev->regs[0x20] & 0x01) && lpt_port)
|
||||
lpt1_setup(lpt_port);
|
||||
lpt_port_setup(dev->lpt, lpt_port);
|
||||
|
||||
lpt1_irq((dev->regs[0x20] & 0x08) ? LPT1_IRQ : LPT2_IRQ);
|
||||
lpt_port_irq(dev->lpt, (dev->regs[0x20] & 0x08) ? LPT1_IRQ : LPT2_IRQ);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -264,6 +265,8 @@ i82091aa_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->has_ide = (info->local >> 9) & 0x03;
|
||||
|
||||
i82091aa_reset(dev);
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef struct acc3221_t {
|
||||
uint8_t regs[256];
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} acc3221_t;
|
||||
|
||||
/* Configuration Register Index, BE (R/W):
|
||||
@@ -302,10 +303,10 @@ typedef struct acc3221_t {
|
||||
static void
|
||||
acc3221_lpt_handle(acc3221_t *dev)
|
||||
{
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (!(dev->regs[0xbe] & REG_BE_LPT1_DISABLE))
|
||||
lpt1_setup(dev->regs[0xbf] << 2);
|
||||
lpt_port_setup(dev->lpt, dev->regs[0xbf] << 2);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -436,9 +437,10 @@ acc3221_reset(acc3221_t *dev)
|
||||
serial_remove(dev->uart[1]);
|
||||
serial_setup(dev->uart[1], COM2_ADDR, COM2_IRQ);
|
||||
|
||||
lpt1_remove();
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
|
||||
fdc_reset(dev->fdc);
|
||||
}
|
||||
@@ -461,6 +463,8 @@ acc3221_init(UNUSED(const device_t *info))
|
||||
dev->uart[0] = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
io_sethandler(0x00f2, 0x0002, acc3221_read, NULL, NULL, acc3221_write, NULL, NULL, dev);
|
||||
|
||||
acc3221_reset(dev);
|
||||
|
||||
@@ -47,6 +47,7 @@ typedef struct ali5123_t {
|
||||
int cur_reg;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[3];
|
||||
lpt_t *lpt;
|
||||
} ali5123_t;
|
||||
|
||||
static void ali5123_write(uint16_t port, uint8_t val, void *priv);
|
||||
@@ -95,47 +96,47 @@ ali5123_lpt_handler(ali5123_t *dev)
|
||||
if (lpt_dma >= 4)
|
||||
lpt_dma = 0xff;
|
||||
|
||||
lpt1_remove();
|
||||
lpt_set_fifo_threshold(0, (dev->ld_regs[3][0xf0] & 0x78) >> 3);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_set_fifo_threshold(dev->lpt, (dev->ld_regs[3][0xf0] & 0x78) >> 3);
|
||||
if ((lpt_mode == 0x04) && (dev->ld_regs[3][0xf1] & 0x80))
|
||||
lpt_mode = 0x00;
|
||||
switch (lpt_mode) {
|
||||
default:
|
||||
case 0x04:
|
||||
lpt_set_epp(0, 0);
|
||||
lpt_set_ecp(0, 0);
|
||||
lpt_set_ext(0, 0);
|
||||
lpt_set_epp(dev->lpt, 0);
|
||||
lpt_set_ecp(dev->lpt, 0);
|
||||
lpt_set_ext(dev->lpt, 0);
|
||||
break;
|
||||
case 0x00:
|
||||
lpt_set_epp(0, 0);
|
||||
lpt_set_ecp(0, 0);
|
||||
lpt_set_ext(0, 1);
|
||||
lpt_set_epp(dev->lpt, 0);
|
||||
lpt_set_ecp(dev->lpt, 0);
|
||||
lpt_set_ext(dev->lpt, 1);
|
||||
break;
|
||||
case 0x01: case 0x05:
|
||||
mask = 0xfff8;
|
||||
lpt_set_epp(0, 1);
|
||||
lpt_set_ecp(0, 0);
|
||||
lpt_set_ext(0, 0);
|
||||
lpt_set_epp(dev->lpt, 1);
|
||||
lpt_set_ecp(dev->lpt, 0);
|
||||
lpt_set_ext(dev->lpt, 0);
|
||||
break;
|
||||
case 0x02:
|
||||
lpt_set_epp(0, 0);
|
||||
lpt_set_ecp(0, 1);
|
||||
lpt_set_ext(0, 0);
|
||||
lpt_set_epp(dev->lpt, 0);
|
||||
lpt_set_ecp(dev->lpt, 1);
|
||||
lpt_set_ext(dev->lpt, 0);
|
||||
break;
|
||||
case 0x03: case 0x07:
|
||||
mask = 0xfff8;
|
||||
lpt_set_epp(0, 1);
|
||||
lpt_set_ecp(0, 1);
|
||||
lpt_set_ext(0, 0);
|
||||
lpt_set_epp(dev->lpt, 1);
|
||||
lpt_set_ecp(dev->lpt, 1);
|
||||
lpt_set_ext(dev->lpt, 0);
|
||||
break;
|
||||
}
|
||||
if (global_enable && local_enable) {
|
||||
ld_port = (make_port(dev, 3) & 0xfffc) & mask;
|
||||
if ((ld_port >= 0x0100) && (ld_port <= (0x0ffc & mask)))
|
||||
lpt1_setup(ld_port);
|
||||
lpt_port_setup(dev->lpt, ld_port);
|
||||
}
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_dma(0, lpt_dma);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
lpt_port_dma(dev->lpt, lpt_dma);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -515,6 +516,7 @@ ali5123_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
dev->uart[2] = device_add_inst(&ns16550_device, 3);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->chip_id = info->local & 0xff;
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ typedef struct upc_t {
|
||||
nvr_t *nvr;
|
||||
void *gameport;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} upc_t;
|
||||
|
||||
#ifdef ENABLE_F82C606_LOG
|
||||
@@ -87,8 +88,7 @@ f82c606_update_ports(upc_t *dev, int set)
|
||||
|
||||
serial_remove(dev->uart[0]);
|
||||
serial_remove(dev->uart[1]);
|
||||
lpt1_remove();
|
||||
lpt2_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
nvr_at_handler(0, ((uint16_t) dev->regs[3]) << 2, dev->nvr);
|
||||
nvr_at_handler(0, 0x70, dev->nvr);
|
||||
@@ -174,8 +174,8 @@ f82c606_update_ports(upc_t *dev, int set)
|
||||
}
|
||||
|
||||
if (dev->regs[0] & 8) {
|
||||
lpt1_setup(((uint16_t) dev->regs[6]) << 2);
|
||||
lpt1_irq(lpt1_int);
|
||||
lpt_port_setup(dev->lpt, ((uint16_t) dev->regs[6]) << 2);
|
||||
lpt_port_irq(dev->lpt, lpt1_int);
|
||||
f82c606_log("LPT1 at %04X, IRQ %i\n", ((uint16_t) dev->regs[6]) << 2, lpt1_int);
|
||||
}
|
||||
|
||||
@@ -296,13 +296,15 @@ f82c606_close(void *priv)
|
||||
static void *
|
||||
f82c606_init(const device_t *info)
|
||||
{
|
||||
upc_t *dev = (upc_t *) calloc(1, sizeof(upc_t));
|
||||
upc_t *dev = (upc_t *) calloc(1, sizeof(upc_t));
|
||||
|
||||
dev->nvr = device_add(&at_nvr_old_device);
|
||||
dev->gameport = gameport_add(&gameport_sio_device);
|
||||
|
||||
dev->uart[0] = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
dev->uart[0] = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
io_sethandler(0x02fa, 0x0001, NULL, NULL, NULL, f82c606_config_write, NULL, NULL, dev);
|
||||
io_sethandler(0x03fa, 0x0001, NULL, NULL, NULL, f82c606_config_write, NULL, NULL, dev);
|
||||
|
||||
@@ -71,6 +71,7 @@ typedef struct upc_t {
|
||||
void *mouse;
|
||||
void *hdc_xta;
|
||||
serial_t *uart;
|
||||
lpt_t *lpt;
|
||||
} upc_t;
|
||||
|
||||
#ifdef ENABLE_F82C710_LOG
|
||||
@@ -110,15 +111,15 @@ lpt_handler(upc_t *dev)
|
||||
{
|
||||
uint16_t lpt_addr = 0x0000;
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (dev->regs[0x00] & 0x08) {
|
||||
lpt_addr = dev->regs[0x06] << 2;
|
||||
|
||||
lpt1_setup(lpt_addr);
|
||||
lpt1_irq(dev->lpt_irq);
|
||||
lpt_port_setup(dev->lpt, lpt_addr);
|
||||
lpt_port_irq(dev->lpt, dev->lpt_irq);
|
||||
|
||||
lpt_set_ext(0, !!(dev->regs[0x01] & 0x40));
|
||||
lpt_set_ext(dev->lpt, !!(dev->regs[0x01] & 0x40));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,16 +351,17 @@ f82c710_init(const device_t *info)
|
||||
upc_t *dev = (upc_t *) calloc(1, sizeof(upc_t));
|
||||
|
||||
if (strstr(machine_get_internal_name(), "5086") != NULL)
|
||||
dev->fdc = device_add(&fdc_at_actlow_device);
|
||||
dev->fdc = device_add(&fdc_at_actlow_device);
|
||||
else
|
||||
dev->fdc = device_add(&fdc_at_device);
|
||||
dev->fdc = device_add(&fdc_at_device);
|
||||
|
||||
dev->uart = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart = device_add_inst(&ns16450_device, 1);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->mouse = device_add_params(&mouse_upc_device, (void *) (uintptr_t) (is8086 ? 2 : 12));
|
||||
dev->mouse = device_add_params(&mouse_upc_device, (void *) (uintptr_t) (is8086 ? 2 : 12));
|
||||
|
||||
dev->serial_irq = device_get_config_int("serial_irq");
|
||||
dev->lpt_irq = device_get_config_int("lpt_irq");
|
||||
dev->lpt_irq = device_get_config_int("lpt_irq");
|
||||
|
||||
io_sethandler(0x02fa, 0x0001, NULL, NULL, NULL, f82c710_config_write, NULL, NULL, dev);
|
||||
io_sethandler(0x03fa, 0x0001, NULL, NULL, NULL, f82c710_config_write, NULL, NULL, dev);
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef struct fdc37c669_t {
|
||||
int rw_locked;
|
||||
int cur_reg;
|
||||
fdc_t *fdc;
|
||||
lpt_t *lpt;
|
||||
serial_t *uart[2];
|
||||
} fdc37c669_t;
|
||||
|
||||
@@ -105,9 +106,9 @@ fdc37c669_lpt_handler(fdc37c669_t *dev)
|
||||
{
|
||||
uint8_t mask = ~(dev->regs[0x04] & 0x01);
|
||||
|
||||
lpt_port_remove(dev->id);
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0x01] & 0x04) && (dev->regs[0x23] >= 0x40))
|
||||
lpt_port_setup(dev->id, ((uint16_t) (dev->regs[0x23] & mask)) << 2);
|
||||
lpt_port_setup(dev->lpt, ((uint16_t) (dev->regs[0x23] & mask)) << 2);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -251,7 +252,7 @@ fdc37c669_write(uint16_t port, uint8_t val, void *priv)
|
||||
if (valxor & 0xf0)
|
||||
fdc_set_irq(dev->fdc, val >> 4);
|
||||
if (valxor & 0x0f)
|
||||
lpt_port_irq(dev->id, val & 0x0f);
|
||||
lpt_port_irq(dev->lpt, val & 0x0f);
|
||||
break;
|
||||
case 0x28:
|
||||
dev->regs[dev->cur_reg] = val;
|
||||
@@ -345,6 +346,8 @@ fdc37c669_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, (next_id << 1) + 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, (next_id << 1) + 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, next_id + 1);
|
||||
|
||||
io_sethandler(info->local ? FDC_SECONDARY_ADDR : (next_id ? FDC_SECONDARY_ADDR : FDC_PRIMARY_ADDR),
|
||||
0x0002, fdc37c669_read, NULL, NULL, fdc37c669_write, NULL, NULL, dev);
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef struct fdc37c67x_t {
|
||||
int cur_reg;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} fdc37c67x_t;
|
||||
|
||||
static void fdc37c67x_write(uint16_t port, uint8_t val, void *priv);
|
||||
@@ -130,13 +131,13 @@ fdc37c67x_lpt_handler(fdc37c67x_t *dev)
|
||||
if (lpt_irq > 15)
|
||||
lpt_irq = 0xff;
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if (global_enable && local_enable) {
|
||||
ld_port = make_port(dev, 3) & 0xFFFC;
|
||||
if ((ld_port >= 0x0100) && (ld_port <= 0x0FFC))
|
||||
lpt1_setup(ld_port);
|
||||
lpt_port_setup(dev->lpt, ld_port);
|
||||
}
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -598,6 +599,8 @@ fdc37c67x_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->chip_id = info->local & 0xff;
|
||||
|
||||
dev->gpio_regs[0] = 0xff;
|
||||
|
||||
@@ -44,6 +44,7 @@ typedef struct fdc37c6xx_t {
|
||||
int com4_addr;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} fdc37c6xx_t;
|
||||
|
||||
static void
|
||||
@@ -106,21 +107,21 @@ set_serial_addr(fdc37c6xx_t *dev, int port)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt1_handler(fdc37c6xx_t *dev)
|
||||
lpt_handler(fdc37c6xx_t *dev)
|
||||
{
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
switch (dev->regs[1] & 3) {
|
||||
case 1:
|
||||
lpt1_setup(LPT_MDA_ADDR);
|
||||
lpt1_irq(LPT_MDA_IRQ);
|
||||
lpt_port_setup(dev->lpt, LPT_MDA_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT_MDA_IRQ);
|
||||
break;
|
||||
case 2:
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt1_irq(LPT1_IRQ /*LPT2_IRQ*/);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ /*LPT2_IRQ*/);
|
||||
break;
|
||||
case 3:
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt1_irq(LPT1_IRQ /*LPT2_IRQ*/);
|
||||
lpt_port_setup(dev->lpt, LPT2_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ /*LPT2_IRQ*/);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -183,7 +184,7 @@ fdc37c6xx_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case 1:
|
||||
if (valxor & 3)
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
if (valxor & 0x60) {
|
||||
set_com34_addr(dev);
|
||||
set_serial_addr(dev, 0);
|
||||
@@ -293,7 +294,7 @@ fdc37c6xx_reset(fdc37c6xx_t *dev)
|
||||
set_serial_addr(dev, 0);
|
||||
set_serial_addr(dev, 1);
|
||||
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
|
||||
fdc_handler(dev);
|
||||
|
||||
@@ -330,6 +331,8 @@ fdc37c6xx_init(const device_t *info)
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
}
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
io_sethandler(FDC_PRIMARY_ADDR, 0x0002,
|
||||
fdc37c6xx_read, NULL, NULL, fdc37c6xx_write, NULL, NULL, dev);
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ typedef struct fdc37c93x_t {
|
||||
acpi_t *acpi;
|
||||
void *kbc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} fdc37c93x_t;
|
||||
|
||||
static void fdc37c93x_write(uint16_t port, uint8_t val, void *priv);
|
||||
@@ -807,13 +808,13 @@ fdc37c93x_lpt_handler(fdc37c93x_t *dev)
|
||||
|
||||
if (dev->lpt_base != old_base) {
|
||||
if ((old_base >= 0x0100) && (old_base <= 0x0ffc))
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if ((dev->lpt_base >= 0x0100) && (dev->lpt_base <= 0x0ffc))
|
||||
lpt1_setup(dev->lpt_base);
|
||||
lpt_port_setup(dev->lpt, dev->lpt_base);
|
||||
}
|
||||
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1798,6 +1799,8 @@ fdc37c93x_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->chip_id = info->local & FDC37C93X_CHIP_ID;
|
||||
dev->kbc_type = info->local & FDC37C93X_KBC;
|
||||
|
||||
|
||||
@@ -77,8 +77,9 @@ typedef struct fdc37m60x_t {
|
||||
uint16_t sio_index_port;
|
||||
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} fdc37m60x_t;
|
||||
|
||||
static void fdc37m60x_fdc_handler(fdc37m60x_t *dev);
|
||||
@@ -213,11 +214,11 @@ fdc37m60x_uart_handler(uint8_t num, fdc37m60x_t *dev)
|
||||
void
|
||||
fdc37m60x_lpt_handler(fdc37m60x_t *dev)
|
||||
{
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (ENABLED(3) || (POWER_CONTROL & 0x08)) {
|
||||
lpt1_setup(BASE_ADDRESS(3));
|
||||
lpt1_irq(IRQ(3) & 0xf);
|
||||
lpt_port_setup(dev->lpt, BASE_ADDRESS(3));
|
||||
lpt_port_irq(dev->lpt, IRQ(3) & 0xf);
|
||||
fdc37m60x_log("SMC60x-LPT: BASE %04x IRQ %d\n", BASE_ADDRESS(3), IRQ(3) & 0xf);
|
||||
}
|
||||
}
|
||||
@@ -310,9 +311,12 @@ fdc37m60x_init(const device_t *info)
|
||||
SIO_INDEX_PORT = info->local;
|
||||
|
||||
dev->fdc = device_add(&fdc_at_smc_device);
|
||||
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
io_sethandler(SIO_INDEX_PORT, 0x0002, fdc37m60x_read, NULL, NULL, fdc37m60x_write, NULL, NULL, dev);
|
||||
|
||||
fdc37m60x_reset(dev);
|
||||
|
||||
@@ -243,6 +243,7 @@ typedef struct it86x1f_t {
|
||||
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
void *gameport;
|
||||
} it86x1f_t;
|
||||
|
||||
@@ -290,11 +291,11 @@ it8661f_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *pri
|
||||
break;
|
||||
|
||||
case 3:
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) {
|
||||
it86x1f_log("IT86x1F: LPT enabled at port %04X IRQ %d\n", config->io[0].base, config->irq[0].irq);
|
||||
lpt1_setup(config->io[0].base);
|
||||
lpt_port_setup(dev->lpt, config->io[0].base);
|
||||
} else {
|
||||
it86x1f_log("IT86x1F: LPT disabled\n");
|
||||
}
|
||||
@@ -777,7 +778,7 @@ it86x1f_reset(it86x1f_t *dev)
|
||||
|
||||
serial_remove(dev->uart[1]);
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
isapnp_enable_card(dev->pnp_card, ISAPNP_CARD_DISABLE);
|
||||
|
||||
@@ -822,6 +823,8 @@ it86x1f_init(UNUSED(const device_t *info))
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->gameport = gameport_add(&gameport_sio_device);
|
||||
|
||||
dev->instance = device_get_instance();
|
||||
|
||||
@@ -45,6 +45,7 @@ typedef struct pc87306_t {
|
||||
int cur_reg;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
nvr_t *nvr;
|
||||
} pc87306_t;
|
||||
|
||||
@@ -115,7 +116,7 @@ pc87306_gpio_handler(pc87306_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt1_handler(pc87306_t *dev)
|
||||
lpt_handler(pc87306_t *dev)
|
||||
{
|
||||
int temp;
|
||||
uint16_t lptba;
|
||||
@@ -123,7 +124,7 @@ lpt1_handler(pc87306_t *dev)
|
||||
uint8_t lpt_irq = LPT2_IRQ;
|
||||
uint8_t lpt_dma = ((dev->regs[0x18] & 0x06) >> 1);
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (lpt_dma == 0x00)
|
||||
lpt_dma = 0xff;
|
||||
@@ -159,17 +160,17 @@ lpt1_handler(pc87306_t *dev)
|
||||
if (dev->regs[0x1b] & 0x10)
|
||||
lpt_irq = (dev->regs[0x1b] & 0x20) ? 7 : 5;
|
||||
|
||||
lpt_set_ext(0, !!(dev->regs[0x02] & 0x80));
|
||||
lpt_set_ext(dev->lpt, !!(dev->regs[0x02] & 0x80));
|
||||
|
||||
lpt_set_epp(0, !!(dev->regs[0x04] & 0x01));
|
||||
lpt_set_ecp(0, !!(dev->regs[0x04] & 0x04));
|
||||
lpt_set_epp(dev->lpt, !!(dev->regs[0x04] & 0x01));
|
||||
lpt_set_ecp(dev->lpt, !!(dev->regs[0x04] & 0x04));
|
||||
|
||||
if (lpt_port)
|
||||
lpt1_setup(lpt_port);
|
||||
lpt_port_setup(dev->lpt, lpt_port);
|
||||
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
|
||||
lpt_port_dma(0, lpt_dma);
|
||||
lpt_port_dma(dev->lpt, lpt_dma);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -278,9 +279,9 @@ pc87306_write(uint16_t port, uint8_t val, void *priv)
|
||||
switch (dev->cur_reg) {
|
||||
case 0x00:
|
||||
if (valxor & 0x01) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((val & 1) && !(dev->regs[0x02] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
if (valxor & 0x02) {
|
||||
serial_remove(dev->uart[0x00]);
|
||||
@@ -300,9 +301,9 @@ pc87306_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case 0x01:
|
||||
if (valxor & 0x03) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
if (valxor & 0xcc) {
|
||||
serial_remove(dev->uart[0x00]);
|
||||
@@ -317,14 +318,14 @@ pc87306_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case 0x02:
|
||||
if (valxor & 0x01) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
serial_remove(dev->uart[0x00]);
|
||||
serial_remove(dev->uart[0x01]);
|
||||
fdc_remove(dev->fdc);
|
||||
|
||||
if (!(val & 1)) {
|
||||
if (dev->regs[0x00] & 0x01)
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
if (dev->regs[0x00] & 0x02)
|
||||
serial_handler(dev, 0);
|
||||
if (dev->regs[0x00] & 0x04)
|
||||
@@ -334,16 +335,16 @@ pc87306_write(uint16_t port, uint8_t val, void *priv)
|
||||
}
|
||||
}
|
||||
if (valxor & 0x08) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
break;
|
||||
case 0x04:
|
||||
if (valxor & (0x05)) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0x00] & 0x01) && !(dev->regs[0x02] & 0x01))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
if (valxor & 0x80)
|
||||
nvr_lock_set(0x00, 256, !!(val & 0x80), dev->nvr);
|
||||
@@ -372,25 +373,25 @@ pc87306_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case 0x18:
|
||||
if (valxor & (0x06)) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0x00] & 0x01) && !(dev->regs[0x02] & 0x01))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
break;
|
||||
case 0x19:
|
||||
if (valxor) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
break;
|
||||
case 0x1b:
|
||||
if (valxor & 0x70) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if (!(val & 0x40))
|
||||
dev->regs[0x19] = 0xef;
|
||||
if ((dev->regs[0x00] & 1) && !(dev->regs[0x02] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
break;
|
||||
case 0x1c:
|
||||
@@ -455,8 +456,8 @@ pc87306_reset_common(void *priv)
|
||||
0 = 360 rpm @ 500 kbps for 3.5"
|
||||
1 = Default, 300 rpm @ 500, 300, 250, 1000 kbps for 3.5"
|
||||
*/
|
||||
lpt1_remove();
|
||||
lpt1_handler(dev);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_handler(dev);
|
||||
serial_remove(dev->uart[0x00]);
|
||||
serial_remove(dev->uart[0x01]);
|
||||
serial_handler(dev, 0);
|
||||
@@ -499,6 +500,8 @@ pc87306_init(UNUSED(const device_t *info))
|
||||
dev->uart[0x00] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[0x01] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->nvr = device_add(&at_mb_nvr_device);
|
||||
|
||||
dev->gpio[0] = dev->gpio[1] = 0xff;
|
||||
|
||||
@@ -54,6 +54,7 @@ typedef struct pc87307_t {
|
||||
void *kbc;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} pc87307_t;
|
||||
|
||||
enum {
|
||||
@@ -72,7 +73,7 @@ enum {
|
||||
#define LD_MAX LD_PM
|
||||
|
||||
static void fdc_handler(pc87307_t *dev);
|
||||
static void lpt1_handler(pc87307_t *dev);
|
||||
static void lpt_handler(pc87307_t *dev);
|
||||
static void serial_handler(pc87307_t *dev, int uart);
|
||||
static void kbc_handler(pc87307_t *dev);
|
||||
static void pc87307_write(uint16_t port, uint8_t val, void *priv);
|
||||
@@ -187,7 +188,7 @@ pc87307_pm_write(uint16_t port, uint8_t val, void *priv)
|
||||
switch (dev->pm_idx) {
|
||||
case 0x00:
|
||||
fdc_handler(dev);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
serial_handler(dev, 1);
|
||||
serial_handler(dev, 0);
|
||||
break;
|
||||
@@ -277,7 +278,7 @@ fdc_handler(pc87307_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt1_handler(pc87307_t *dev)
|
||||
lpt_handler(pc87307_t *dev)
|
||||
{
|
||||
uint8_t active = (dev->ld_regs[LD_LPT][0x00] & 0x01) &&
|
||||
(dev->pm[0x00] & 0x10);
|
||||
@@ -287,11 +288,11 @@ lpt1_handler(pc87307_t *dev)
|
||||
|
||||
if (active && (addr <= 0xfffc)) {
|
||||
pc87307_log("Enabling LPT1 on %04X...\n", addr);
|
||||
lpt1_setup(addr);
|
||||
lpt_port_setup(dev->lpt, addr);
|
||||
} else
|
||||
lpt1_setup(0xffff);
|
||||
lpt_port_setup(dev->lpt, 0xffff);
|
||||
|
||||
lpt1_irq(irq);
|
||||
lpt_port_irq(dev->lpt, irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -439,7 +440,7 @@ pc87307_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -488,7 +489,7 @@ pc87307_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = (old & 0xfc) | (val & 0x03);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -526,7 +527,7 @@ pc87307_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = (old & 0x03) | (val & 0xfc);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = (old & 0x07) | (val & 0xf8);
|
||||
@@ -594,7 +595,7 @@ pc87307_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -630,7 +631,7 @@ pc87307_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -662,7 +663,7 @@ pc87307_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2: case LD_UART1:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -822,7 +823,7 @@ pc87307_reset(void *priv)
|
||||
|
||||
kbc_handler(dev);
|
||||
fdc_handler(dev);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
serial_handler(dev, 0);
|
||||
serial_handler(dev, 1);
|
||||
gpio_handler(dev);
|
||||
@@ -850,6 +851,8 @@ pc87307_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
switch (info->local & PCX730X_KBC) {
|
||||
default:
|
||||
case PCX730X_AMI:
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef struct pc87309_t {
|
||||
void *kbc;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt
|
||||
} pc87309_t;
|
||||
|
||||
enum {
|
||||
@@ -66,7 +67,7 @@ enum {
|
||||
#define LD_MAX LD_MOUSE
|
||||
|
||||
static void fdc_handler(pc87309_t *dev);
|
||||
static void lpt1_handler(pc87309_t *dev);
|
||||
static void lpt_handler(pc87309_t *dev);
|
||||
static void serial_handler(pc87309_t *dev, int uart);
|
||||
static void kbc_handler(pc87309_t *dev);
|
||||
static void pc87309_write(uint16_t port, uint8_t val, void *priv);
|
||||
@@ -103,7 +104,7 @@ pc87309_pm_write(uint16_t port, uint8_t val, void *priv)
|
||||
switch (dev->pm_idx) {
|
||||
case 0x00:
|
||||
fdc_handler(dev);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
serial_handler(dev, 1);
|
||||
serial_handler(dev, 0);
|
||||
break;
|
||||
@@ -193,7 +194,7 @@ fdc_handler(pc87309_t *dev)
|
||||
}
|
||||
|
||||
static void
|
||||
lpt1_handler(pc87309_t *dev)
|
||||
lpt_handler(pc87309_t *dev)
|
||||
{
|
||||
uint8_t active = (dev->ld_regs[LD_LPT][0x00] & 0x01) &&
|
||||
(dev->pm[0x00] & 0x10);
|
||||
@@ -203,11 +204,11 @@ lpt1_handler(pc87309_t *dev)
|
||||
|
||||
if (active && (addr <= 0xfffc)) {
|
||||
pc87309_log("Enabling LPT1 on %04X...\n", addr);
|
||||
lpt1_setup(addr);
|
||||
lpt_port_setup(dev->lpt, addr);
|
||||
} else
|
||||
lpt1_setup(0xffff);
|
||||
lpt_port_setup(dev->lpt, 0xffff);
|
||||
|
||||
lpt1_irq(irq);
|
||||
lpt_port_irq(dev->lpt, irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -330,7 +331,7 @@ pc87309_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -372,7 +373,7 @@ pc87309_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = (old & 0xfc) | (val & 0x03);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -403,7 +404,7 @@ pc87309_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = (old & 0x03) | (val & 0xfc);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = (old & 0x07) | (val & 0xf8);
|
||||
@@ -456,7 +457,7 @@ pc87309_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -492,7 +493,7 @@ pc87309_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -524,7 +525,7 @@ pc87309_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case LD_LPT:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
break;
|
||||
case LD_UART2: case LD_UART1:
|
||||
dev->ld_regs[ld][reg] = val;
|
||||
@@ -658,7 +659,7 @@ pc87309_reset(void *priv)
|
||||
|
||||
kbc_handler(dev);
|
||||
fdc_handler(dev);
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
serial_handler(dev, 0);
|
||||
serial_handler(dev, 1);
|
||||
pm_handler(dev);
|
||||
@@ -685,6 +686,8 @@ pc87309_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
switch (info->local & PCX730X_KBC) {
|
||||
default:
|
||||
case PCX730X_AMI:
|
||||
|
||||
@@ -64,10 +64,11 @@ typedef struct pc87310_t {
|
||||
uint8_t regs[2];
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} pc87310_t;
|
||||
|
||||
static void
|
||||
lpt1_handler(pc87310_t *dev)
|
||||
lpt_handler(pc87310_t *dev)
|
||||
{
|
||||
int temp;
|
||||
uint16_t lpt_port = LPT1_ADDR;
|
||||
@@ -81,7 +82,7 @@ lpt1_handler(pc87310_t *dev)
|
||||
*/
|
||||
temp = dev->regs[1] & 0x03;
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
switch (temp) {
|
||||
case 0:
|
||||
@@ -103,9 +104,9 @@ lpt1_handler(pc87310_t *dev)
|
||||
}
|
||||
|
||||
if (lpt_port)
|
||||
lpt1_setup(lpt_port);
|
||||
lpt_port_setup(dev->lpt, lpt_port);
|
||||
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -187,7 +188,7 @@ pc87310_write(UNUSED(uint16_t port), uint8_t val, void *priv)
|
||||
/* Reconfigure parallel port. */
|
||||
if (valxor & 0x03)
|
||||
/* Bits 1, 0: 1, 1 = Disable parallel port. */
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
|
||||
/* Reconfigure serial ports. */
|
||||
if (valxor & 0x1c)
|
||||
@@ -253,7 +254,7 @@ pc87310_reset(pc87310_t *dev)
|
||||
|
||||
dev->tries = 0;
|
||||
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
serial_handler(dev);
|
||||
if (dev->flags & PC87310_IDE) {
|
||||
ide_pri_disable();
|
||||
@@ -283,6 +284,8 @@ pc87310_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
if (dev->flags & PC87310_IDE)
|
||||
device_add((dev->flags & PC87310_ALI) ? &ide_vlb_device : &ide_isa_device);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ typedef struct pc87311_t {
|
||||
uint16_t irq;
|
||||
fdc_t *fdc_controller;
|
||||
serial_t *uart[2];
|
||||
|
||||
lpt_t *lpt;
|
||||
} pc87311_t;
|
||||
|
||||
void pc87311_fdc_handler(pc87311_t *dev);
|
||||
@@ -202,7 +202,7 @@ pc87311_uart_handler(uint8_t num, pc87311_t *dev)
|
||||
void
|
||||
pc87311_lpt_handler(pc87311_t *dev)
|
||||
{
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
switch (LPT_BA) {
|
||||
case 0:
|
||||
dev->base = LPT1_ADDR;
|
||||
@@ -220,8 +220,8 @@ pc87311_lpt_handler(pc87311_t *dev)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
lpt1_setup(dev->base);
|
||||
lpt1_irq(dev->irq);
|
||||
lpt_port_setup(dev->lpt, dev->base);
|
||||
lpt_port_irq(dev->lpt, dev->irq);
|
||||
pc87311_log("PC87311-LPT: BASE %04x IRQ %01x\n", dev->base, dev->irq);
|
||||
}
|
||||
|
||||
@@ -277,6 +277,7 @@ pc87311_init(const device_t *info)
|
||||
dev->fdc_controller = device_add(&fdc_at_nsc_device);
|
||||
dev->uart[0] = device_add_inst(&ns16450_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16450_device, 2);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
if (HAS_IDE_FUNCTIONALITY)
|
||||
device_add(&ide_isa_2ch_device);
|
||||
|
||||
@@ -43,10 +43,11 @@ typedef struct pc87332_t {
|
||||
int cur_reg;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} pc87332_t;
|
||||
|
||||
static void
|
||||
lpt1_handler(pc87332_t *dev)
|
||||
lpt_handler(pc87332_t *dev)
|
||||
{
|
||||
int temp;
|
||||
uint16_t lpt_port = LPT1_ADDR;
|
||||
@@ -77,9 +78,9 @@ lpt1_handler(pc87332_t *dev)
|
||||
}
|
||||
|
||||
if (lpt_port)
|
||||
lpt1_setup(lpt_port);
|
||||
lpt_port_setup(dev->lpt, lpt_port);
|
||||
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -189,9 +190,9 @@ pc87332_write(uint16_t port, uint8_t val, void *priv)
|
||||
switch (dev->cur_reg) {
|
||||
case 0:
|
||||
if (valxor & 1) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((val & 1) && !(dev->regs[2] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
if (valxor & 2) {
|
||||
serial_remove(dev->uart[0]);
|
||||
@@ -213,9 +214,9 @@ pc87332_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case 1:
|
||||
if (valxor & 3) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0] & 1) && !(dev->regs[2] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
if (valxor & 0xcc) {
|
||||
serial_remove(dev->uart[0]);
|
||||
@@ -230,14 +231,14 @@ pc87332_write(uint16_t port, uint8_t val, void *priv)
|
||||
break;
|
||||
case 2:
|
||||
if (valxor & 1) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
serial_remove(dev->uart[0]);
|
||||
serial_remove(dev->uart[1]);
|
||||
fdc_remove(dev->fdc);
|
||||
|
||||
if (!(val & 1)) {
|
||||
if (dev->regs[0] & 1)
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
if (dev->regs[0] & 2)
|
||||
serial_handler(dev, 0);
|
||||
if (dev->regs[0] & 4)
|
||||
@@ -247,9 +248,9 @@ pc87332_write(uint16_t port, uint8_t val, void *priv)
|
||||
}
|
||||
}
|
||||
if (valxor & 8) {
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if ((dev->regs[0] & 1) && !(dev->regs[2] & 1))
|
||||
lpt1_handler(dev);
|
||||
lpt_handler(dev);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -298,8 +299,8 @@ pc87332_reset(pc87332_t *dev)
|
||||
0 = 360 rpm @ 500 kbps for 3.5"
|
||||
1 = Default, 300 rpm @ 500, 300, 250, 1000 kbps for 3.5"
|
||||
*/
|
||||
lpt1_remove();
|
||||
lpt1_handler(dev);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_handler(dev);
|
||||
serial_remove(dev->uart[0]);
|
||||
serial_remove(dev->uart[1]);
|
||||
serial_handler(dev, 0);
|
||||
@@ -330,6 +331,8 @@ pc87332_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->has_ide = (info->local >> 8) & 0xff;
|
||||
dev->fdc_on = (info->local >> 16) & 0xff;
|
||||
pc87332_reset(dev);
|
||||
|
||||
@@ -66,8 +66,9 @@ typedef struct prime3b_t {
|
||||
uint16_t com4_addr;
|
||||
|
||||
fdc_t *fdc_controller;
|
||||
serial_t *uart[2];
|
||||
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} prime3b_t;
|
||||
|
||||
void prime3b_fdc_handler(prime3b_t *dev);
|
||||
@@ -175,9 +176,9 @@ void
|
||||
prime3b_lpt_handler(prime3b_t *dev)
|
||||
{
|
||||
uint16_t lpt_base = (ASR & 2) ? LPT_MDA_ADDR : (!(ASR & 1) ? LPT1_ADDR : LPT2_ADDR);
|
||||
lpt1_remove();
|
||||
lpt1_setup(lpt_base);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_port_setup(dev->lpt, lpt_base);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
prime3b_log("Prime3B-LPT: Enabled with base %03x\n", lpt_base);
|
||||
}
|
||||
|
||||
@@ -210,7 +211,7 @@ prime3b_enable(prime3b_t *dev)
|
||||
Note: 86Box LPT is simplistic and can't do ECP or EPP.
|
||||
*/
|
||||
|
||||
!(FSR & 3) ? prime3b_lpt_handler(dev) : lpt1_remove();
|
||||
!(FSR & 3) ? prime3b_lpt_handler(dev) : lpt_port_remove(dev->lpt);
|
||||
(FSR & 4) ? prime3b_uart_handler(0, dev) : serial_remove(dev->uart[0]);
|
||||
(FSR & 8) ? prime3b_uart_handler(1, dev) : serial_remove(dev->uart[1]);
|
||||
(FSR & 0x10) ? prime3b_fdc_handler(dev) : fdc_remove(dev->fdc_controller);
|
||||
@@ -240,7 +241,7 @@ prime3b_powerdown(prime3b_t *dev)
|
||||
serial_remove(dev->uart[1]);
|
||||
|
||||
if (PDR & 0x10)
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (PDR & 1)
|
||||
PDR = old_base;
|
||||
@@ -267,6 +268,7 @@ prime3b_init(const device_t *info)
|
||||
dev->fdc_controller = device_add(&fdc_at_device);
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
if (HAS_IDE_FUNCTIONALITY)
|
||||
device_add(&ide_isa_device);
|
||||
|
||||
|
||||
@@ -83,8 +83,9 @@ typedef struct prime3c_t {
|
||||
uint8_t ide_function;
|
||||
|
||||
fdc_t *fdc_controller;
|
||||
serial_t *uart[2];
|
||||
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} prime3c_t;
|
||||
|
||||
void prime3c_fdc_handler(prime3c_t *dev);
|
||||
@@ -238,11 +239,12 @@ prime3c_uart_handler(uint8_t num, prime3c_t *dev)
|
||||
void
|
||||
prime3c_lpt_handler(prime3c_t *dev)
|
||||
{
|
||||
lpt1_remove();
|
||||
if (!(FUNCTION_SELECT & 0x03)) {
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (!(FUNCTION_SELECT & 0x03)) {
|
||||
lpt_port_setup(dev->lpt, LPT_BASE_ADDRESS << 2);
|
||||
lpt_port_irq(dev->lpt, FDC_LPT_IRQ & 0xf);
|
||||
|
||||
lpt1_setup(LPT_BASE_ADDRESS << 2);
|
||||
lpt1_irq(FDC_LPT_IRQ & 0xf);
|
||||
prime3c_log("Prime3C-LPT: BASE %04x IRQ %02x\n", LPT_BASE_ADDRESS << 2, FDC_LPT_IRQ & 0xf);
|
||||
}
|
||||
}
|
||||
@@ -277,7 +279,7 @@ prime3c_enable(prime3c_t *dev)
|
||||
Note: 86Box LPT is simplistic and can't do ECP or EPP.
|
||||
*/
|
||||
|
||||
!(FUNCTION_SELECT & 0x03) ? prime3c_lpt_handler(dev) : lpt1_remove();
|
||||
!(FUNCTION_SELECT & 0x03) ? prime3c_lpt_handler(dev) : lpt_port_remove(dev->lpt);
|
||||
(FUNCTION_SELECT & 0x04) ? prime3c_uart_handler(0, dev) : serial_remove(dev->uart[0]);
|
||||
(FUNCTION_SELECT & 0x08) ? prime3c_uart_handler(1, dev) : serial_remove(dev->uart[1]);
|
||||
(FUNCTION_SELECT & 0x10) ? prime3c_fdc_handler(dev) : fdc_remove(dev->fdc_controller);
|
||||
@@ -311,6 +313,7 @@ prime3c_init(const device_t *info)
|
||||
dev->fdc_controller = device_add(&fdc_at_device);
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
if (HAS_IDE_FUNCTIONALITY)
|
||||
device_add(&ide_isa_device);
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ typedef struct um8663f_t {
|
||||
uint8_t regs[5];
|
||||
|
||||
fdc_t *fdc;
|
||||
|
||||
serial_t *uart[2];
|
||||
lpt_t * lpt;
|
||||
} um8663f_t;
|
||||
|
||||
static void
|
||||
@@ -102,16 +104,16 @@ um8663f_uart_handler(um8663f_t *dev, int port)
|
||||
static void
|
||||
um8663f_lpt_handler(um8663f_t *dev)
|
||||
{
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if (dev->regs[0] & 0x08) {
|
||||
switch ((dev->regs[1] >> 3) & 0x01) {
|
||||
case 0x01:
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
break;
|
||||
case 0x00:
|
||||
lpt1_setup(LPT2_ADDR);
|
||||
lpt1_irq(LPT2_IRQ);
|
||||
lpt_port_setup(dev->lpt, LPT2_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT2_IRQ);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -230,8 +232,8 @@ um8663f_reset(void *priv)
|
||||
serial_remove(dev->uart[1]);
|
||||
serial_setup(dev->uart[1], COM2_ADDR, COM2_IRQ);
|
||||
|
||||
lpt1_remove();
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
|
||||
fdc_reset(dev->fdc);
|
||||
fdc_remove(dev->fdc);
|
||||
@@ -268,6 +270,8 @@ um8663f_init(UNUSED(const device_t *info))
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->ide = info->local & 0xff;
|
||||
if (dev->ide < IDE_BUS_MAX)
|
||||
device_add(&ide_isa_device);
|
||||
|
||||
@@ -157,6 +157,7 @@ typedef struct um8669f_t {
|
||||
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t * lpt;
|
||||
uint8_t ide;
|
||||
void *gameport;
|
||||
} um8669f_t;
|
||||
@@ -203,11 +204,11 @@ um8669f_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *pri
|
||||
break;
|
||||
|
||||
case 3:
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) {
|
||||
um8669f_log("UM8669F: LPT enabled at port %04X IRQ %d\n", config->io[0].base, config->irq[0].irq);
|
||||
lpt1_setup(config->io[0].base);
|
||||
lpt_port_setup(dev->lpt, config->io[0].base);
|
||||
} else {
|
||||
um8669f_log("UM8669F: LPT disabled\n");
|
||||
}
|
||||
@@ -301,7 +302,7 @@ um8669f_reset(um8669f_t *dev)
|
||||
|
||||
serial_remove(dev->uart[1]);
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (dev->ide < IDE_BUS_MAX)
|
||||
ide_remove_handlers(dev->ide);
|
||||
@@ -339,6 +340,8 @@ um8669f_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->ide = info->local;
|
||||
if (dev->ide < IDE_BUS_MAX)
|
||||
device_add(&ide_isa_device);
|
||||
|
||||
@@ -44,6 +44,7 @@ typedef struct vt82c686_t {
|
||||
uint8_t lpt_irq;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} vt82c686_t;
|
||||
|
||||
static uint8_t
|
||||
@@ -83,15 +84,15 @@ vt82c686_lpt_handler(vt82c686_t *dev)
|
||||
if (io_len == 8)
|
||||
io_mask = 0x3f8; /* EPP */
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if (((dev->regs[0x02] & 0x03) != 0x03) && !(dev->regs[0x0f] & 0x11) && (io_base >= 0x100) && (io_base <= io_mask))
|
||||
lpt1_setup(io_base);
|
||||
lpt_port_setup(dev->lpt, io_base);
|
||||
|
||||
if (dev->lpt_irq) {
|
||||
lpt1_irq(dev->lpt_irq);
|
||||
lpt_port_irq(dev->lpt, dev->lpt_irq);
|
||||
} else {
|
||||
lpt1_irq(0xff);
|
||||
lpt_port_irq(dev->lpt, 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,6 +296,7 @@ vt82c686_init(UNUSED(const device_t *info))
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
dev->lpt_dma = 3;
|
||||
|
||||
vt82c686_reset(dev);
|
||||
|
||||
@@ -86,6 +86,7 @@ typedef struct w83787f_t {
|
||||
int ide_start;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
void *gameport;
|
||||
} w83787f_t;
|
||||
|
||||
@@ -195,10 +196,10 @@ w83787f_lpt_handler(w83787f_t *dev)
|
||||
if (dev->regs[4] & 0x80)
|
||||
enable = 0;
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if (enable) {
|
||||
lpt1_setup(addr);
|
||||
lpt1_irq(irq);
|
||||
lpt_port_setup(dev->lpt, addr);
|
||||
lpt_port_irq(dev->lpt, irq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,9 +378,9 @@ w83787f_reset(w83787f_t *dev)
|
||||
{
|
||||
uint16_t hefere = dev->reg_init & 0x0100;
|
||||
|
||||
lpt1_remove();
|
||||
lpt1_setup(LPT1_ADDR);
|
||||
lpt1_irq(LPT1_IRQ);
|
||||
lpt_port_remove(dev->lpt);
|
||||
lpt_port_setup(dev->lpt, LPT1_ADDR);
|
||||
lpt_port_irq(dev->lpt, LPT1_IRQ);
|
||||
|
||||
memset(dev->regs, 0, 0x2A);
|
||||
|
||||
@@ -452,6 +453,8 @@ w83787f_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->gameport = gameport_add(&gameport_sio_1io_device);
|
||||
|
||||
if ((dev->ide_function & 0x30) == 0x10)
|
||||
|
||||
@@ -68,6 +68,7 @@ typedef struct w83877f_t {
|
||||
int key_times;
|
||||
fdc_t *fdc;
|
||||
serial_t *uart[2];
|
||||
lpt_t *lpt;
|
||||
} w83877f_t;
|
||||
|
||||
static void w83877f_write(uint16_t port, uint8_t val, void *priv);
|
||||
@@ -166,9 +167,9 @@ w83877f_lpt_handler(w83877f_t *dev)
|
||||
uint8_t lpt_irq;
|
||||
uint8_t lpt_irqs[8] = { 0, 7, 9, 10, 11, 14, 15, 5 };
|
||||
|
||||
lpt1_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
if (!(dev->regs[4] & 0x80) && (dev->regs[0x23] & 0xc0))
|
||||
lpt1_setup(make_port(dev, 0x23));
|
||||
lpt_port_setup(dev->lpt, make_port(dev, 0x23));
|
||||
|
||||
lpt_irq = 0xff;
|
||||
|
||||
@@ -176,7 +177,7 @@ w83877f_lpt_handler(w83877f_t *dev)
|
||||
if (lpt_irq == 0)
|
||||
lpt_irq = PRTIQS;
|
||||
|
||||
lpt1_irq(lpt_irq);
|
||||
lpt_port_irq(dev->lpt, lpt_irq);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -451,6 +452,8 @@ w83877f_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
|
||||
dev->reg_init = info->local;
|
||||
|
||||
w83877f_reset(dev);
|
||||
|
||||
@@ -48,6 +48,7 @@ typedef struct w83977f_t {
|
||||
int type;
|
||||
int hefras;
|
||||
fdc_t *fdc;
|
||||
lpt_t *lpt;
|
||||
serial_t *uart[2];
|
||||
} w83977f_t;
|
||||
|
||||
@@ -108,21 +109,12 @@ w83977f_lpt_handler(w83977f_t *dev)
|
||||
if (io_len == 8)
|
||||
io_mask = 0xff8;
|
||||
|
||||
if (dev->id == 1) {
|
||||
lpt2_remove();
|
||||
lpt_port_remove(dev->lpt);
|
||||
|
||||
if ((dev->dev_regs[1][0x00] & 0x01) && (dev->regs[0x22] & 0x08) && (io_base >= 0x100) && (io_base <= io_mask))
|
||||
lpt2_setup(io_base);
|
||||
if ((dev->dev_regs[1][0x00] & 0x01) && (dev->regs[0x22] & 0x08) && (io_base >= 0x100) && (io_base <= io_mask))
|
||||
lpt_port_setup(dev->lpt, io_base);
|
||||
|
||||
lpt2_irq(dev->dev_regs[1][0x40] & 0x0f);
|
||||
} else {
|
||||
lpt1_remove();
|
||||
|
||||
if ((dev->dev_regs[1][0x00] & 0x01) && (dev->regs[0x22] & 0x08) && (io_base >= 0x100) && (io_base <= io_mask))
|
||||
lpt1_setup(io_base);
|
||||
|
||||
lpt1_irq(dev->dev_regs[1][0x40] & 0x0f);
|
||||
}
|
||||
lpt_port_irq(dev->lpt, dev->dev_regs[1][0x40] & 0x0f);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -608,6 +600,8 @@ w83977f_init(const device_t *info)
|
||||
dev->uart[0] = device_add_inst(&ns16550_device, (next_id << 1) + 1);
|
||||
dev->uart[1] = device_add_inst(&ns16550_device, (next_id << 1) + 2);
|
||||
|
||||
dev->lpt = device_add_inst(&lpt_port_device, next_id + 1);
|
||||
|
||||
w83977f_reset(dev);
|
||||
|
||||
next_id++;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <86box/86box.h>
|
||||
#include <86box/filters.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/sound.h>
|
||||
@@ -128,7 +129,9 @@ const lpt_device_t lpt_dac_device = {
|
||||
.read_status = dac_read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
const lpt_device_t lpt_dac_stereo_device = {
|
||||
@@ -143,5 +146,7 @@ const lpt_device_t lpt_dac_stereo_device = {
|
||||
.read_status = dac_read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <86box/86box.h>
|
||||
#include <86box/filters.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/sound.h>
|
||||
@@ -144,5 +145,7 @@ const lpt_device_t dss_device = {
|
||||
.read_status = dss_read_status,
|
||||
.read_ctrl = NULL,
|
||||
.epp_write_data = NULL,
|
||||
.epp_request_read = NULL
|
||||
.epp_request_read = NULL,
|
||||
.priv = NULL,
|
||||
.lpt = NULL
|
||||
};
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
#include "cpu.h"
|
||||
#include <86box/io.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/vid_cga.h>
|
||||
#include <86box/vid_colorplus.h>
|
||||
@@ -357,7 +357,9 @@ colorplus_standalone_init(UNUSED(const device_t *info))
|
||||
mem_mapping_add(&colorplus->cga.mapping, 0xb8000, 0x08000, colorplus_read, NULL, NULL, colorplus_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, colorplus);
|
||||
io_sethandler(0x03d0, 0x0010, colorplus_in, NULL, NULL, colorplus_out, NULL, NULL, colorplus);
|
||||
|
||||
lpt3_setup(LPT_MDA_ADDR);
|
||||
colorplus->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_setup(colorplus->lpt, LPT_MDA_ADDR);
|
||||
lpt_set_3bc_used(1);
|
||||
|
||||
return colorplus;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#include <86box/rom.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/vid_hercules.h>
|
||||
#include <86box/plat_unused.h>
|
||||
@@ -606,7 +606,9 @@ hercules_init(UNUSED(const device_t *info))
|
||||
video_inform(VIDEO_FLAG_TYPE_MDA, &timing_hercules);
|
||||
|
||||
/* Force the LPT3 port to be enabled. */
|
||||
lpt3_setup(LPT_MDA_ADDR);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_setup(dev->lpt, LPT_MDA_ADDR);
|
||||
lpt_set_3bc_used(1);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
#include <86box/86box.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
@@ -179,6 +179,8 @@ typedef struct {
|
||||
uint32_t rgb[64];
|
||||
|
||||
uint8_t *vram;
|
||||
|
||||
lpt_t *lpt;
|
||||
} incolor_t;
|
||||
|
||||
static video_timings_t timing_incolor = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 };
|
||||
@@ -1035,7 +1037,9 @@ incolor_init(UNUSED(const device_t *info))
|
||||
video_inform(VIDEO_FLAG_TYPE_MDA, &timing_incolor);
|
||||
|
||||
/* Force the LPT3 port to be enabled. */
|
||||
lpt3_setup(LPT_MDA_ADDR);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_setup(dev->lpt, LPT_MDA_ADDR);
|
||||
lpt_set_3bc_used(1);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
#include <86box/86box.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
@@ -86,6 +86,8 @@ typedef struct {
|
||||
int cols[256][2][2];
|
||||
|
||||
uint8_t *vram;
|
||||
|
||||
lpt_t *lpt;
|
||||
} herculesplus_t;
|
||||
|
||||
#define VIDEO_MONITOR_PROLOGUE() \
|
||||
@@ -687,7 +689,9 @@ herculesplus_init(UNUSED(const device_t *info))
|
||||
video_inform(VIDEO_FLAG_TYPE_MDA, &timing_herculesplus);
|
||||
|
||||
/* Force the LPT3 port to be enabled. */
|
||||
lpt3_setup(LPT_MDA_ADDR);
|
||||
dev->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_setup(dev->lpt, LPT_MDA_ADDR);
|
||||
lpt_set_3bc_used(1);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
#include <86box/86box.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/rom.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/vid_mda.h>
|
||||
#include <86box/plat_unused.h>
|
||||
@@ -453,7 +453,9 @@ mda_standalone_init(UNUSED(const device_t *info))
|
||||
|
||||
mda_init(mda);
|
||||
|
||||
lpt3_setup(LPT_MDA_ADDR);
|
||||
mda->lpt = device_add_inst(&lpt_port_device, 1);
|
||||
lpt_port_setup(mda->lpt, LPT_MDA_ADDR);
|
||||
lpt_set_3bc_used(1);
|
||||
|
||||
return mda;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <86box/machine.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/lpt.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/vid_svga.h>
|
||||
|
||||
Reference in New Issue
Block a user