@@ -16,7 +16,6 @@
|
|||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2016-2018 Miran Grca.
|
||||||
* Copyright 2021 RichardG.
|
* Copyright 2021 RichardG.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -37,7 +36,7 @@
|
|||||||
#define CHECK_CURRENT_CARD() if (1) { \
|
#define CHECK_CURRENT_CARD() if (1) { \
|
||||||
card = dev->first_card; \
|
card = dev->first_card; \
|
||||||
while (card) { \
|
while (card) { \
|
||||||
if (card->state == PNP_STATE_CONFIG) \
|
if (card->enable && (card->state == PNP_STATE_CONFIG)) \
|
||||||
break; \
|
break; \
|
||||||
card = card->next; \
|
card = card->next; \
|
||||||
} \
|
} \
|
||||||
@@ -86,12 +85,13 @@ typedef struct _isapnp_device_ {
|
|||||||
uint8_t number;
|
uint8_t number;
|
||||||
uint8_t regs[256];
|
uint8_t regs[256];
|
||||||
uint8_t mem_upperlimit, irq_types, io_16bit, io_len[8];
|
uint8_t mem_upperlimit, irq_types, io_16bit, io_len[8];
|
||||||
|
const isapnp_device_config_t *defaults;
|
||||||
|
|
||||||
struct _isapnp_device_ *next;
|
struct _isapnp_device_ *next;
|
||||||
} isapnp_device_t;
|
} isapnp_device_t;
|
||||||
|
|
||||||
typedef struct _isapnp_card_ {
|
typedef struct _isapnp_card_ {
|
||||||
uint8_t state, csn, id_checksum, serial_read, serial_read_pair, serial_read_pos, *rom;
|
uint8_t enable, state, csn, id_checksum, serial_read, serial_read_pair, serial_read_pos, *rom;
|
||||||
uint16_t rom_pos, rom_size;
|
uint16_t rom_pos, rom_size;
|
||||||
void *priv;
|
void *priv;
|
||||||
|
|
||||||
@@ -163,6 +163,59 @@ isapnp_device_config_changed(isapnp_card_t *card, isapnp_device_t *ld)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
isapnp_reset_ld_config(isapnp_device_t *ld)
|
||||||
|
{
|
||||||
|
/* Do nothing if there's no default configuration for this device. */
|
||||||
|
const isapnp_device_config_t *config = ld->defaults;
|
||||||
|
if (!config)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Populate configuration registers. */
|
||||||
|
ld->regs[0x30] = !!config->activate;
|
||||||
|
uint8_t i, reg_base;
|
||||||
|
uint32_t size;
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
reg_base = 0x40 + (8 * i);
|
||||||
|
ld->regs[reg_base] = config->mem[i].base >> 16;
|
||||||
|
ld->regs[reg_base + 1] = config->mem[i].base >> 8;
|
||||||
|
size = config->mem[i].size;
|
||||||
|
if (ld->regs[reg_base + 2] & 0x01) /* upper limit */
|
||||||
|
size += config->mem[i].base;
|
||||||
|
ld->regs[reg_base + 3] = size >> 16;
|
||||||
|
ld->regs[reg_base + 4] = size >> 8;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
reg_base = (i == 0) ? 0x76 : (0x80 + (16 * i));
|
||||||
|
ld->regs[reg_base] = config->mem32[i].base >> 24;
|
||||||
|
ld->regs[reg_base + 1] = config->mem32[i].base >> 16;
|
||||||
|
ld->regs[reg_base + 2] = config->mem32[i].base >> 8;
|
||||||
|
ld->regs[reg_base + 3] = config->mem32[i].base;
|
||||||
|
size = config->mem32[i].size;
|
||||||
|
if (ld->regs[reg_base + 4] & 0x01) /* upper limit */
|
||||||
|
size += config->mem32[i].base;
|
||||||
|
ld->regs[reg_base + 5] = size >> 24;
|
||||||
|
ld->regs[reg_base + 6] = size >> 16;
|
||||||
|
ld->regs[reg_base + 7] = size >> 8;
|
||||||
|
ld->regs[reg_base + 8] = size;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
reg_base = 0x60 + (2 * i);
|
||||||
|
ld->regs[reg_base] = config->io[i].base >> 8;
|
||||||
|
ld->regs[reg_base + 1] = config->io[i].base;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
reg_base = 0x70 + (2 * i);
|
||||||
|
ld->regs[reg_base] = config->irq[i].irq;
|
||||||
|
ld->regs[reg_base + 1] = (!!config->irq[i].level << 1) | !!config->irq[i].type;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
reg_base = 0x74 + i;
|
||||||
|
ld->regs[reg_base] = config->dma[i].dma;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
isapnp_reset_ld_regs(isapnp_device_t *ld)
|
isapnp_reset_ld_regs(isapnp_device_t *ld)
|
||||||
{
|
{
|
||||||
@@ -190,6 +243,9 @@ isapnp_reset_ld_regs(isapnp_device_t *ld)
|
|||||||
else if (ld->irq_types & (0x8 << (4 * i)))
|
else if (ld->irq_types & (0x8 << (4 * i)))
|
||||||
ld->regs[0x70 + (2 * i)] = 0x01;
|
ld->regs[0x70 + (2 * i)] = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset configuration registers to match the default configuration. */
|
||||||
|
isapnp_reset_ld_config(ld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -212,7 +268,7 @@ isapnp_read_data(uint16_t addr, void *priv)
|
|||||||
case 0x01: /* Serial Isolation */
|
case 0x01: /* Serial Isolation */
|
||||||
card = dev->first_card;
|
card = dev->first_card;
|
||||||
while (card) {
|
while (card) {
|
||||||
if (card->state == PNP_STATE_ISOLATION)
|
if (card->enable && (card->state == PNP_STATE_ISOLATION))
|
||||||
break;
|
break;
|
||||||
card = card->next;
|
card = card->next;
|
||||||
}
|
}
|
||||||
@@ -349,6 +405,8 @@ isapnp_write_addr(uint16_t addr, uint8_t val, void *priv)
|
|||||||
if (!card) /* don't do anything if we have no PnP cards */
|
if (!card) /* don't do anything if we have no PnP cards */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
dev->reg = val;
|
||||||
|
|
||||||
if (card->state == PNP_STATE_WAIT_FOR_KEY) { /* checking only the first card should be fine */
|
if (card->state == PNP_STATE_WAIT_FOR_KEY) { /* checking only the first card should be fine */
|
||||||
/* Check written value against LFSR key. */
|
/* Check written value against LFSR key. */
|
||||||
if (val == pnp_init_key[dev->key_pos]) {
|
if (val == pnp_init_key[dev->key_pos]) {
|
||||||
@@ -356,7 +414,7 @@ isapnp_write_addr(uint16_t addr, uint8_t val, void *priv)
|
|||||||
if (!dev->key_pos) {
|
if (!dev->key_pos) {
|
||||||
isapnp_log("ISAPnP: Key unlocked, putting cards to SLEEP\n");
|
isapnp_log("ISAPnP: Key unlocked, putting cards to SLEEP\n");
|
||||||
while (card) {
|
while (card) {
|
||||||
if (card->state == PNP_STATE_WAIT_FOR_KEY)
|
if (card->enable && (card->state == PNP_STATE_WAIT_FOR_KEY))
|
||||||
card->state = PNP_STATE_SLEEP;
|
card->state = PNP_STATE_SLEEP;
|
||||||
card = card->next;
|
card = card->next;
|
||||||
}
|
}
|
||||||
@@ -364,9 +422,6 @@ isapnp_write_addr(uint16_t addr, uint8_t val, void *priv)
|
|||||||
} else {
|
} else {
|
||||||
dev->key_pos = 0;
|
dev->key_pos = 0;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* Nobody waiting for key, set register address. */
|
|
||||||
dev->reg = val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +538,7 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv)
|
|||||||
case 0x30: /* Activate */
|
case 0x30: /* Activate */
|
||||||
CHECK_CURRENT_LD();
|
CHECK_CURRENT_LD();
|
||||||
|
|
||||||
isapnp_log("ISAPnP: Activate CSN %02X device %02X\n", dev->current_ld_card->csn, dev->current_ld->number);
|
isapnp_log("ISAPnP: %sctivate CSN %02X device %02X\n", (val & 0x01) ? "A" : "Dea", dev->current_ld_card->csn, dev->current_ld->number);
|
||||||
|
|
||||||
dev->current_ld->regs[dev->reg] = val & 0x01;
|
dev->current_ld->regs[dev->reg] = val & 0x01;
|
||||||
isapnp_device_config_changed(dev->current_ld_card, dev->current_ld);
|
isapnp_device_config_changed(dev->current_ld_card, dev->current_ld);
|
||||||
@@ -541,18 +596,18 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv)
|
|||||||
switch (dev->reg) {
|
switch (dev->reg) {
|
||||||
case 0x42: case 0x4a: case 0x52: case 0x5a:
|
case 0x42: case 0x4a: case 0x52: case 0x5a:
|
||||||
case 0x7a: case 0x84: case 0x94: case 0xa4:
|
case 0x7a: case 0x84: case 0x94: case 0xa4:
|
||||||
/* read-only memory range length / upper limit bit */
|
/* Read-only memory range length / upper limit bit. */
|
||||||
val = (val & 0xfe) | (dev->current_ld->regs[dev->reg] & 0x01);
|
val = (val & 0xfe) | (dev->current_ld->regs[dev->reg] & 0x01);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x60: case 0x62: case 0x64: case 0x66: case 0x68: case 0x6a: case 0x6c: case 0x6e:
|
case 0x60: case 0x62: case 0x64: case 0x66: case 0x68: case 0x6a: case 0x6c: case 0x6e:
|
||||||
/* discard upper address bits if this I/O range can only decode 10-bit */
|
/* Discard upper address bits if this I/O range can only decode 10-bit. */
|
||||||
if (!(dev->current_ld->io_16bit & (1 << ((dev->reg >> 1) & 0x07))))
|
if (!(dev->current_ld->io_16bit & (1 << ((dev->reg >> 1) & 0x07))))
|
||||||
val &= 0x07;
|
val &= 0x03;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x71: case 0x73:
|
case 0x71: case 0x73:
|
||||||
/* limit IRQ types to supported ones */
|
/* Limit IRQ types to supported ones. */
|
||||||
if ((val & 0x01) && !(dev->current_ld->irq_types & ((dev->reg == 0x71) ? 0x0c : 0xc0))) /* level, not supported = force edge */
|
if ((val & 0x01) && !(dev->current_ld->irq_types & ((dev->reg == 0x71) ? 0x0c : 0xc0))) /* level, not supported = force edge */
|
||||||
val &= ~0x01;
|
val &= ~0x01;
|
||||||
else if (!(val & 0x01) && !(dev->current_ld->irq_types & ((dev->reg == 0x71) ? 0x03 : 0x30))) /* edge, not supported = force level */
|
else if (!(val & 0x01) && !(dev->current_ld->irq_types & ((dev->reg == 0x71) ? 0x03 : 0x30))) /* edge, not supported = force level */
|
||||||
@@ -629,6 +684,7 @@ isapnp_add_card(uint8_t *rom, uint16_t rom_size,
|
|||||||
isapnp_card_t *card = (isapnp_card_t *) malloc(sizeof(isapnp_card_t));
|
isapnp_card_t *card = (isapnp_card_t *) malloc(sizeof(isapnp_card_t));
|
||||||
memset(card, 0, sizeof(isapnp_card_t));
|
memset(card, 0, sizeof(isapnp_card_t));
|
||||||
|
|
||||||
|
card->enable = 1;
|
||||||
card->rom = rom;
|
card->rom = rom;
|
||||||
card->rom_size = rom_size;
|
card->rom_size = rom_size;
|
||||||
card->priv = priv;
|
card->priv = priv;
|
||||||
@@ -839,6 +895,41 @@ isapnp_add_card(uint8_t *rom, uint16_t rom_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
isapnp_enable_card(void *priv, uint8_t enable)
|
||||||
|
{
|
||||||
|
isapnp_t *dev = (isapnp_t *) device_get_priv(&isapnp_device);
|
||||||
|
if (!dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Look for a matching card. */
|
||||||
|
isapnp_card_t *card = dev->first_card;
|
||||||
|
while (card) {
|
||||||
|
if (card == priv) {
|
||||||
|
/* Enable or disable the card. */
|
||||||
|
card->enable = !!enable;
|
||||||
|
|
||||||
|
/* enable=2 is a cheat code to jump straight into CONFIG state. */
|
||||||
|
card->state = (enable == 2) ? PNP_STATE_CONFIG : PNP_STATE_WAIT_FOR_KEY;
|
||||||
|
|
||||||
|
/* Invalidate other references if we're disabling this card. */
|
||||||
|
if (!card->enable) {
|
||||||
|
if (dev->isolated_card == card)
|
||||||
|
dev->isolated_card = NULL;
|
||||||
|
if (dev->current_ld_card == card) {
|
||||||
|
dev->current_ld = NULL;
|
||||||
|
dev->current_ld_card = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
card = card->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
isapnp_set_csn(void *priv, uint8_t csn)
|
isapnp_set_csn(void *priv, uint8_t csn)
|
||||||
{
|
{
|
||||||
@@ -850,9 +941,62 @@ isapnp_set_csn(void *priv, uint8_t csn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
isapnp_set_device_defaults(void *priv, uint8_t ldn, const isapnp_device_config_t *config)
|
||||||
|
{
|
||||||
|
isapnp_card_t *card = (isapnp_card_t *) priv;
|
||||||
|
isapnp_device_t *ld = card->first_ld;
|
||||||
|
|
||||||
|
/* Look for a logical device with this number. */
|
||||||
|
while (ld && (ld->number != ldn))
|
||||||
|
ld = ld->next;
|
||||||
|
|
||||||
|
if (!ld) /* none found */
|
||||||
|
return;
|
||||||
|
|
||||||
|
ld->defaults = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
isapnp_reset_card(void *priv)
|
||||||
|
{
|
||||||
|
isapnp_card_t *card = (isapnp_card_t *) priv;
|
||||||
|
isapnp_device_t *ld = card->first_ld;
|
||||||
|
|
||||||
|
/* Reset all logical devices. */
|
||||||
|
while (ld) {
|
||||||
|
/* Reset the logical device's configuration. */
|
||||||
|
isapnp_reset_ld_config(ld);
|
||||||
|
isapnp_device_config_changed(card, ld);
|
||||||
|
|
||||||
|
ld = ld->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
isapnp_reset_device(void *priv, uint8_t ldn)
|
||||||
|
{
|
||||||
|
isapnp_card_t *card = (isapnp_card_t *) priv;
|
||||||
|
isapnp_device_t *ld = card->first_ld;
|
||||||
|
|
||||||
|
/* Look for a logical device with this number. */
|
||||||
|
while (ld && (ld->number != ldn))
|
||||||
|
ld = ld->next;
|
||||||
|
|
||||||
|
if (!ld) /* none found */
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Reset the logical device's configuration. */
|
||||||
|
isapnp_reset_ld_config(ld);
|
||||||
|
isapnp_device_config_changed(card, ld);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const device_t isapnp_device = {
|
static const device_t isapnp_device = {
|
||||||
"ISA Plug and Play",
|
"ISA Plug and Play",
|
||||||
DEVICE_ISA,
|
0,
|
||||||
0,
|
0,
|
||||||
isapnp_init, isapnp_close, NULL,
|
isapnp_init, isapnp_close, NULL,
|
||||||
{ NULL }, NULL, NULL,
|
{ NULL }, NULL, NULL,
|
||||||
|
@@ -135,22 +135,46 @@ static ide_bm_t *ide_bm[4] = { NULL, NULL, NULL, NULL };
|
|||||||
static uint8_t ide_ter_pnp_rom[] = {
|
static uint8_t ide_ter_pnp_rom[] = {
|
||||||
0x09, 0xf8, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /* BOX0001, serial 0, dummy checksum (filled in by isapnp_add_card) */
|
0x09, 0xf8, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /* BOX0001, serial 0, dummy checksum (filled in by isapnp_add_card) */
|
||||||
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
||||||
|
0x82, 0x0e, 0x00, 'I', 'D', 'E', ' ', 'C', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', /* ANSI identifier */
|
||||||
|
|
||||||
0x15, 0x41, 0xd0, 0x06, 0x00, 0x00, /* logical device PNP0600 */
|
0x15, 0x09, 0xf8, 0x00, 0x01, 0x00, /* logical device BOX0001 */
|
||||||
0x22, 0xb8, 0x1e, /* IRQ 3/4/5/7/9/10/11/12 */
|
0x1c, 0x41, 0xd0, 0x06, 0x00, /* compatible device PNP0600 */
|
||||||
0x47, 0x00, 0x68, 0x01, 0x68, 0x01, 0x01, 0x08, /* I/O 0x168, decodes 10-bit, 1-byte alignment, 8 addresses */
|
0x31, 0x00, /* start dependent functions, preferred */
|
||||||
0x47, 0x00, 0x6e, 0x03, 0x6e, 0x03, 0x01, 0x01, /* I/O 0x36E, decodes 10-bit, 1-byte alignment, 1 address */
|
0x22, 0x00, 0x04, /* IRQ 10 */
|
||||||
|
0x47, 0x01, 0x68, 0x01, 0x68, 0x01, 0x01, 0x08, /* I/O 0x168, decodes 16-bit, 1-byte alignment, 8 addresses */
|
||||||
|
0x47, 0x01, 0x6e, 0x03, 0x6e, 0x03, 0x01, 0x01, /* I/O 0x36E, decodes 16-bit, 1-byte alignment, 1 address */
|
||||||
|
0x30, /* start dependent functions, acceptable */
|
||||||
|
0x22, 0xb8, 0x1e, /* IRQ 3/4/5/7/9/10/11/12 */
|
||||||
|
0x47, 0x01, 0x68, 0x01, 0x68, 0x01, 0x01, 0x08, /* I/O 0x168, decodes 16-bit, 1-byte alignment, 8 addresses */
|
||||||
|
0x47, 0x01, 0x6e, 0x03, 0x6e, 0x03, 0x01, 0x01, /* I/O 0x36E, decodes 16-bit, 1-byte alignment, 1 address */
|
||||||
|
0x30, /* start dependent functions, acceptable */
|
||||||
|
0x22, 0xb8, 0x1e, /* IRQ 3/4/5/7/9/10/11/12 */
|
||||||
|
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08, /* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||||
|
0x47, 0x01, 0x00, 0x01, 0xff, 0xff, 0x01, 0x01, /* I/O 0x100-0xFFFF, decodes 16-bit, 1-byte alignment, 1 address */
|
||||||
|
0x38, /* end dependent functions */
|
||||||
|
|
||||||
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
||||||
};
|
};
|
||||||
static uint8_t ide_qua_pnp_rom[] = {
|
static uint8_t ide_qua_pnp_rom[] = {
|
||||||
0x09, 0xf8, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, /* BOX0001, serial 1, dummy checksum (filled in by isapnp_add_card) */
|
0x09, 0xf8, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, /* BOX0001, serial 1, dummy checksum (filled in by isapnp_add_card) */
|
||||||
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
||||||
|
0x82, 0x0e, 0x00, 'I', 'D', 'E', ' ', 'C', 'o', 'n', 't', 'r', 'o', 'l', 'l', 'e', 'r', /* ANSI identifier */
|
||||||
|
|
||||||
0x15, 0x41, 0xd0, 0x06, 0x00, 0x00, /* logical device PNP0600 */
|
0x15, 0x09, 0xf8, 0x00, 0x01, 0x00, /* logical device BOX0001 */
|
||||||
0x22, 0xb8, 0x1e, /* IRQ 3/4/5/7/9/10/11/12 */
|
0x1c, 0x41, 0xd0, 0x06, 0x00, /* compatible device PNP0600 */
|
||||||
0x47, 0x00, 0xe8, 0x01, 0xe8, 0x01, 0x01, 0x08, /* I/O 0x1E8, decodes 10-bit, 1-byte alignment, 8 addresses */
|
0x31, 0x00, /* start dependent functions, preferred */
|
||||||
0x47, 0x00, 0xee, 0x03, 0xee, 0x03, 0x01, 0x01, /* I/O 0x3EE, decodes 10-bit, 1-byte alignment, 1 address */
|
0x22, 0x00, 0x08, /* IRQ 11 */
|
||||||
|
0x47, 0x01, 0xe8, 0x01, 0xe8, 0x01, 0x01, 0x08, /* I/O 0x1E8, decodes 16-bit, 1-byte alignment, 8 addresses */
|
||||||
|
0x47, 0x01, 0xee, 0x03, 0xee, 0x03, 0x01, 0x01, /* I/O 0x3EE, decodes 16-bit, 1-byte alignment, 1 address */
|
||||||
|
0x30, /* start dependent functions, acceptable */
|
||||||
|
0x22, 0xb8, 0x1e, /* IRQ 3/4/5/7/9/10/11/12 */
|
||||||
|
0x47, 0x01, 0x68, 0x01, 0x68, 0x01, 0x01, 0x08, /* I/O 0x168, decodes 16-bit, 1-byte alignment, 8 addresses */
|
||||||
|
0x47, 0x01, 0x6e, 0x03, 0x6e, 0x03, 0x01, 0x01, /* I/O 0x36E, decodes 16-bit, 1-byte alignment, 1 address */
|
||||||
|
0x30, /* start dependent functions, acceptable */
|
||||||
|
0x22, 0xb8, 0x1e, /* IRQ 3/4/5/7/9/10/11/12 */
|
||||||
|
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08, /* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||||
|
0x47, 0x01, 0x00, 0x01, 0xff, 0xff, 0x01, 0x01, /* I/O 0x100-0xFFFF, decodes 16-bit, 1-byte alignment, 1 address */
|
||||||
|
0x38, /* end dependent functions */
|
||||||
|
|
||||||
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
||||||
};
|
};
|
||||||
|
@@ -60,6 +60,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct _gameport_ {
|
typedef struct _gameport_ {
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
|
uint16_t addr;
|
||||||
|
|
||||||
g_axis_t axis[4];
|
g_axis_t axis[4];
|
||||||
|
|
||||||
@@ -243,10 +244,49 @@ timer_over(void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
void
|
||||||
init_common(void)
|
gameport_update_joystick_type(void)
|
||||||
{
|
{
|
||||||
gameport_t *p = malloc(sizeof(gameport_t));
|
gameport_t *p = gameport_global;
|
||||||
|
|
||||||
|
if (p != NULL) {
|
||||||
|
p->joystick->close(p->joystick_dat);
|
||||||
|
p->joystick = joysticks[joystick_type].joystick;
|
||||||
|
p->joystick_dat = p->joystick->init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gameport_remap(uint16_t address)
|
||||||
|
{
|
||||||
|
gameport_t *p = gameport_global;
|
||||||
|
if (!p)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (p->addr)
|
||||||
|
io_removehandler(p->addr, (p->addr & 1) ? 1 : 8,
|
||||||
|
gameport_read, NULL, NULL, gameport_write, NULL, NULL, p);
|
||||||
|
|
||||||
|
p->addr = address;
|
||||||
|
|
||||||
|
if (p->addr)
|
||||||
|
io_sethandler(p->addr, (p->addr & 1) ? 1 : 8,
|
||||||
|
gameport_read, NULL, NULL, gameport_write, NULL, NULL, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void *
|
||||||
|
gameport_init(const device_t *info)
|
||||||
|
{
|
||||||
|
gameport_t *p = NULL;
|
||||||
|
|
||||||
|
if (!joystick_type) {
|
||||||
|
gameport_global = p = NULL;
|
||||||
|
return(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = malloc(sizeof(gameport_t));
|
||||||
|
|
||||||
memset(p, 0x00, sizeof(gameport_t));
|
memset(p, 0x00, sizeof(gameport_t));
|
||||||
|
|
||||||
@@ -270,56 +310,7 @@ init_common(void)
|
|||||||
|
|
||||||
gameport_global = p;
|
gameport_global = p;
|
||||||
|
|
||||||
return(p);
|
gameport_remap(info->local);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
gameport_update_joystick_type(void)
|
|
||||||
{
|
|
||||||
gameport_t *p = gameport_global;
|
|
||||||
|
|
||||||
if (p != NULL) {
|
|
||||||
p->joystick->close(p->joystick_dat);
|
|
||||||
p->joystick = joysticks[joystick_type].joystick;
|
|
||||||
p->joystick_dat = p->joystick->init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
gameport_init(const device_t *info)
|
|
||||||
{
|
|
||||||
gameport_t *p = NULL;
|
|
||||||
|
|
||||||
if (!joystick_type) {
|
|
||||||
p = NULL;
|
|
||||||
return(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = init_common();
|
|
||||||
|
|
||||||
io_sethandler(0x0200, 8,
|
|
||||||
gameport_read,NULL,NULL, gameport_write,NULL,NULL, p);
|
|
||||||
|
|
||||||
return(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
gameport_201_init(const device_t *info)
|
|
||||||
{
|
|
||||||
gameport_t *p;
|
|
||||||
|
|
||||||
if (!joystick_type) {
|
|
||||||
p = NULL;
|
|
||||||
return(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = init_common();
|
|
||||||
|
|
||||||
io_sethandler(0x0201, 1,
|
|
||||||
gameport_read,NULL,NULL, gameport_write,NULL,NULL, p);
|
|
||||||
|
|
||||||
return(p);
|
return(p);
|
||||||
}
|
}
|
||||||
@@ -342,7 +333,7 @@ gameport_close(void *priv)
|
|||||||
|
|
||||||
const device_t gameport_device = {
|
const device_t gameport_device = {
|
||||||
"Game port",
|
"Game port",
|
||||||
0, 0,
|
0, 0x200,
|
||||||
gameport_init,
|
gameport_init,
|
||||||
gameport_close,
|
gameport_close,
|
||||||
NULL, { NULL }, NULL,
|
NULL, { NULL }, NULL,
|
||||||
@@ -351,8 +342,8 @@ const device_t gameport_device = {
|
|||||||
|
|
||||||
const device_t gameport_201_device = {
|
const device_t gameport_201_device = {
|
||||||
"Game port (port 201h only)",
|
"Game port (port 201h only)",
|
||||||
0, 0,
|
0, 0x201,
|
||||||
gameport_201_init,
|
gameport_init,
|
||||||
gameport_close,
|
gameport_close,
|
||||||
NULL, { NULL }, NULL,
|
NULL, { NULL }, NULL,
|
||||||
NULL
|
NULL
|
||||||
|
@@ -150,6 +150,7 @@ extern char *joystick_get_button_name(int js, int id);
|
|||||||
extern char *joystick_get_pov_name(int js, int id);
|
extern char *joystick_get_pov_name(int js, int id);
|
||||||
|
|
||||||
extern void gameport_update_joystick_type(void);
|
extern void gameport_update_joystick_type(void);
|
||||||
|
extern void gameport_remap(uint16_t address);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -51,8 +51,11 @@ void *isapnp_add_card(uint8_t *rom, uint16_t rom_size,
|
|||||||
uint8_t (*read_vendor_reg)(uint8_t ld, uint8_t reg, void *priv),
|
uint8_t (*read_vendor_reg)(uint8_t ld, uint8_t reg, void *priv),
|
||||||
void (*write_vendor_reg)(uint8_t ld, uint8_t reg, uint8_t val, void *priv),
|
void (*write_vendor_reg)(uint8_t ld, uint8_t reg, uint8_t val, void *priv),
|
||||||
void *priv);
|
void *priv);
|
||||||
|
void isapnp_enable_card(void *priv, uint8_t enable);
|
||||||
void isapnp_set_csn(void *priv, uint8_t csn);
|
void isapnp_set_csn(void *priv, uint8_t csn);
|
||||||
uint8_t isapnp_get_rom_checksum(void *priv);
|
void isapnp_set_device_defaults(void *priv, uint8_t ldn, const isapnp_device_config_t *config);
|
||||||
|
void isapnp_reset_card(void *priv);
|
||||||
|
void isapnp_reset_device(void *priv, uint8_t ld);
|
||||||
|
|
||||||
|
|
||||||
#endif /*EMU_ISAPNP_H*/
|
#endif /*EMU_ISAPNP_H*/
|
||||||
|
@@ -1,31 +1,30 @@
|
|||||||
/*um8669f :
|
/*
|
||||||
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
aa to 108 unlocks
|
* running old operating systems and software designed for IBM
|
||||||
next 108 write is register select (Cx?)
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
data read/write to 109
|
* system designs based on the PCI bus.
|
||||||
55 to 108 locks
|
*
|
||||||
|
* This file is part of the 86Box distribution.
|
||||||
C1
|
*
|
||||||
bit 7 - enable PnP registers
|
* Emulation of the UMC UM8669F Super I/O chip.
|
||||||
|
*
|
||||||
PnP registers :
|
*
|
||||||
|
*
|
||||||
07 - device :
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
0 = FDC
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
1 = COM1
|
* RichardG, <richardg867@gmail.com>
|
||||||
2 = COM2
|
*
|
||||||
3 = LPT1
|
* Copyright 2008-2021 Sarah Walker.
|
||||||
5 = Game port
|
* Copyright 2016-2021 Miran Grca.
|
||||||
30 - enable
|
* Copyright 2021 RichardG.
|
||||||
60/61 - addr
|
*/
|
||||||
70 - IRQ
|
#include <stdarg.h>
|
||||||
74 - DMA*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#define HAVE_STDARG_H
|
||||||
#include <86box/86box.h>
|
#include <86box/86box.h>
|
||||||
#include <86box/device.h>
|
#include <86box/device.h>
|
||||||
#include <86box/io.h>
|
#include <86box/io.h>
|
||||||
@@ -35,37 +34,94 @@ PnP registers :
|
|||||||
#include <86box/serial.h>
|
#include <86box/serial.h>
|
||||||
#include <86box/fdd.h>
|
#include <86box/fdd.h>
|
||||||
#include <86box/fdc.h>
|
#include <86box/fdc.h>
|
||||||
|
#include <86box/gameport.h>
|
||||||
#include <86box/sio.h>
|
#include <86box/sio.h>
|
||||||
|
#include <86box/isapnp.h>
|
||||||
|
|
||||||
|
|
||||||
#define DEV_FDC 0
|
/* This ROM is reconstructed out of the several assumptions, some of which are based on the IT8671F. */
|
||||||
#define DEV_COM1 1
|
static uint8_t um8669f_pnp_rom[] = {
|
||||||
#define DEV_COM2 2
|
0x55, 0xa3, 0x86, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, /* UMC8669, dummy checksum (filled in by isapnp_add_card) */
|
||||||
#define DEV_LPT1 3
|
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
||||||
#define DEV_GAME 5
|
|
||||||
|
|
||||||
#define REG_DEVICE 0x07
|
0x15, 0x41, 0xd0, 0x07, 0x00, 0x01, /* logical device PNP0700, can participate in boot */
|
||||||
#define REG_ENABLE 0x30
|
0x22, 0xfa, 0x1f, /* IRQ 1/3/4/5/6/7/8/9/10/11/12 */
|
||||||
#define REG_ADDRHI 0x60
|
0x2a, 0x0f, 0x0c, /* DMA 0/1/2/3, compatibility, no count by word, count by byte, is bus master, 8-bit only */
|
||||||
#define REG_ADDRLO 0x61
|
0x47, 0x00, 0x00, 0x01, 0xf8, 0x03, 0x08, 0x08, /* I/O 0x100-0x3F8, decodes 10-bit, 8-byte alignment, 8 addresses */
|
||||||
#define REG_IRQ 0x70
|
|
||||||
#define REG_DMA 0x74
|
0x15, 0x41, 0xd0, 0x05, 0x01, 0x01, /* logical device PNP0501, can participate in boot */
|
||||||
|
0x22, 0xfa, 0x1f, /* IRQ 1/3/4/5/6/7/8/9/10/11/12 */
|
||||||
|
0x47, 0x00, 0x00, 0x01, 0xf8, 0x03, 0x08, 0x08, /* I/O 0x100-0x3F8, decodes 10-bit, 8-byte alignment, 8 addresses */
|
||||||
|
|
||||||
|
0x15, 0x41, 0xd0, 0x05, 0x01, 0x01, /* logical device PNP0501, can participate in boot */
|
||||||
|
0x22, 0xfa, 0x1f, /* IRQ 1/3/4/5/6/7/8/9/10/11/12 */
|
||||||
|
0x47, 0x00, 0x00, 0x01, 0xf8, 0x03, 0x08, 0x08, /* I/O 0x100-0x3F8, decodes 10-bit, 8-byte alignment, 8 addresses */
|
||||||
|
|
||||||
|
0x15, 0x41, 0xd0, 0x04, 0x00, 0x01, /* logical device PNP0400, can participate in boot */
|
||||||
|
0x22, 0xfa, 0x1f, /* IRQ 1/3/4/5/6/7/8/9/10/11/12 */
|
||||||
|
0x47, 0x00, 0x00, 0x01, 0xf8, 0x03, 0x08, 0x08, /* I/O 0x100-0x3F8, decodes 10-bit, 8-byte alignment, 8 addresses */
|
||||||
|
|
||||||
|
0x15, 0x55, 0xa3, 0x86, 0x69, 0x00, /* logical device UMC8669 (just a dummy to create a gap in LDNs) */
|
||||||
|
|
||||||
|
0x15, 0x41, 0xd0, 0xb0, 0x2f, 0x01, /* logical device PNPB02F, can participate in boot */
|
||||||
|
0x47, 0x00, 0x00, 0x01, 0xf8, 0x03, 0x08, 0x08, /* I/O 0x100-0x3F8, decodes 10-bit, 8-byte alignment, 8 addresses */
|
||||||
|
|
||||||
|
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
||||||
|
};
|
||||||
|
static const isapnp_device_config_t um8669f_pnp_defaults[] = {
|
||||||
|
{
|
||||||
|
.activate = 1,
|
||||||
|
.io = { { .base = 0x03f0 }, },
|
||||||
|
.irq = { { .irq = 6 }, },
|
||||||
|
.dma = { { .dma = 2 }, }
|
||||||
|
}, {
|
||||||
|
.activate = 1,
|
||||||
|
.io = { { .base = 0x03f8 }, },
|
||||||
|
.irq = { { .irq = 4 }, }
|
||||||
|
}, {
|
||||||
|
.activate = 1,
|
||||||
|
.io = { { .base = 0x02f8 }, },
|
||||||
|
.irq = { { .irq = 3 }, }
|
||||||
|
}, {
|
||||||
|
.activate = 1,
|
||||||
|
.io = { { .base = 0x0378 }, },
|
||||||
|
.irq = { { .irq = 7 }, }
|
||||||
|
}, {
|
||||||
|
.activate = 0
|
||||||
|
}, {
|
||||||
|
.activate = 1,
|
||||||
|
.io = { { .base = 0x200 }, }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_UM8669F_LOG
|
||||||
|
int um8669f_do_log = ENABLE_UM8669F_LOG;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
um8669f_log(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (um8669f_do_log) {
|
||||||
|
va_start(ap, fmt);
|
||||||
|
pclog_ex(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define um8669f_log(fmt, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct um8669f_t
|
typedef struct um8669f_t
|
||||||
{
|
{
|
||||||
int locked, cur_reg_108,
|
int locked, cur_reg_108;
|
||||||
cur_reg, cur_device,
|
void *pnp_card;
|
||||||
pnp_active;
|
isapnp_device_config_t *pnp_config[5];
|
||||||
|
|
||||||
uint8_t regs_108[256];
|
uint8_t regs_108[256];
|
||||||
|
|
||||||
struct {
|
|
||||||
int enable;
|
|
||||||
uint16_t addr;
|
|
||||||
int irq;
|
|
||||||
int dma;
|
|
||||||
} dev[8];
|
|
||||||
|
|
||||||
fdc_t *fdc;
|
fdc_t *fdc;
|
||||||
serial_t *uart[2];
|
serial_t *uart[2];
|
||||||
@@ -73,111 +129,64 @@ typedef struct um8669f_t
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
um8669f_pnp_write(uint16_t port, uint8_t val, void *priv)
|
um8669f_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
|
||||||
{
|
{
|
||||||
um8669f_t *dev = (um8669f_t *) priv;
|
if (ld > 5) {
|
||||||
|
um8669f_log("UM8669F: Unknown logical device %d\n", ld);
|
||||||
uint8_t valxor = 0;
|
return;
|
||||||
uint8_t lpt_irq = 0xff;
|
|
||||||
|
|
||||||
if (port == 0x279)
|
|
||||||
dev->cur_reg = val;
|
|
||||||
else {
|
|
||||||
if (dev->cur_reg == REG_DEVICE)
|
|
||||||
dev->cur_device = val & 7;
|
|
||||||
else {
|
|
||||||
switch (dev->cur_reg) {
|
|
||||||
case REG_ENABLE:
|
|
||||||
valxor = dev->dev[dev->cur_device].enable ^ val;
|
|
||||||
dev->dev[dev->cur_device].enable = val;
|
|
||||||
break;
|
|
||||||
case REG_ADDRLO:
|
|
||||||
valxor = (dev->dev[dev->cur_device].addr & 0xff) ^ val;
|
|
||||||
dev->dev[dev->cur_device].addr = (dev->dev[dev->cur_device].addr & 0xff00) | val;
|
|
||||||
break;
|
|
||||||
case REG_ADDRHI:
|
|
||||||
valxor = ((dev->dev[dev->cur_device].addr >> 8) & 0xff) ^ val;
|
|
||||||
dev->dev[dev->cur_device].addr = (dev->dev[dev->cur_device].addr & 0x00ff) | (val << 8);
|
|
||||||
break;
|
|
||||||
case REG_IRQ:
|
|
||||||
valxor = dev->dev[dev->cur_device].irq ^ val;
|
|
||||||
dev->dev[dev->cur_device].irq = val;
|
|
||||||
break;
|
|
||||||
case REG_DMA:
|
|
||||||
valxor = dev->dev[dev->cur_device].dma ^ val;
|
|
||||||
dev->dev[dev->cur_device].dma = val;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
valxor = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (dev->cur_device) {
|
|
||||||
case DEV_FDC:
|
|
||||||
if (valxor) {
|
|
||||||
fdc_remove(dev->fdc);
|
|
||||||
if (dev->dev[DEV_FDC].enable & 1)
|
|
||||||
fdc_set_base(dev->fdc, dev->dev[DEV_FDC].addr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DEV_COM1:
|
|
||||||
if (valxor) {
|
|
||||||
serial_remove(dev->uart[0]);
|
|
||||||
if (dev->dev[DEV_COM1].enable & 1)
|
|
||||||
serial_setup(dev->uart[0], dev->dev[DEV_COM1].addr, dev->dev[DEV_COM1].irq);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DEV_COM2:
|
|
||||||
if (valxor) {
|
|
||||||
serial_remove(dev->uart[1]);
|
|
||||||
if (dev->dev[DEV_COM2].enable & 1)
|
|
||||||
serial_setup(dev->uart[1], dev->dev[DEV_COM2].addr, dev->dev[DEV_COM2].irq);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DEV_LPT1:
|
|
||||||
if (valxor) {
|
|
||||||
lpt1_remove();
|
|
||||||
if (dev->dev[DEV_LPT1].enable & 1)
|
|
||||||
lpt1_init(dev->dev[DEV_LPT1].addr);
|
|
||||||
}
|
|
||||||
if (dev->dev[DEV_LPT1].irq <= 15)
|
|
||||||
lpt_irq = dev->dev[DEV_LPT1].irq;
|
|
||||||
lpt1_irq(lpt_irq);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t
|
|
||||||
um8669f_pnp_read(uint16_t port, void *priv)
|
|
||||||
{
|
|
||||||
um8669f_t *dev = (um8669f_t *) priv;
|
|
||||||
uint8_t ret = 0xff;
|
|
||||||
|
|
||||||
switch (dev->cur_reg) {
|
|
||||||
case REG_DEVICE:
|
|
||||||
ret = dev->cur_device;
|
|
||||||
break;
|
|
||||||
case REG_ENABLE:
|
|
||||||
ret = dev->dev[dev->cur_device].enable;
|
|
||||||
break;
|
|
||||||
case REG_ADDRLO:
|
|
||||||
ret = dev->dev[dev->cur_device].addr & 0xff;
|
|
||||||
break;
|
|
||||||
case REG_ADDRHI:
|
|
||||||
ret = dev->dev[dev->cur_device].addr >> 8;
|
|
||||||
break;
|
|
||||||
case REG_IRQ:
|
|
||||||
ret = dev->dev[dev->cur_device].irq;
|
|
||||||
break;
|
|
||||||
case REG_DMA:
|
|
||||||
ret = dev->dev[dev->cur_device].dma;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
um8669f_t *dev = (um8669f_t *) priv;
|
||||||
|
|
||||||
|
switch (ld) {
|
||||||
|
case 0:
|
||||||
|
fdc_remove(dev->fdc);
|
||||||
|
|
||||||
|
if (config->activate) {
|
||||||
|
um8669f_log("UM8669F: FDC enabled at port %04X IRQ %d DMA %d\n", config->io[0].base, config->irq[0].irq, (config->dma[0].dma == ISAPNP_DMA_DISABLED) ? -1 : config->dma[0].dma);
|
||||||
|
|
||||||
|
if (config->io[0].base != ISAPNP_IO_DISABLED)
|
||||||
|
fdc_set_base(dev->fdc, config->io[0].base);
|
||||||
|
|
||||||
|
fdc_set_irq(dev->fdc, config->irq[0].irq);
|
||||||
|
fdc_set_dma_ch(dev->fdc, (config->dma[0].dma == ISAPNP_DMA_DISABLED) ? -1 : config->dma[0].dma);
|
||||||
|
} else
|
||||||
|
um8669f_log("UM8669F: FDC disabled\n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
serial_remove(dev->uart[ld - 1]);
|
||||||
|
|
||||||
|
if (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) {
|
||||||
|
um8669f_log("UM8669F: UART %d enabled at port %04X IRQ %d\n", ld - 1, config->io[0].base, config->irq[0].irq);
|
||||||
|
serial_setup(dev->uart[ld - 1], config->io[0].base, config->irq[0].irq);
|
||||||
|
} else
|
||||||
|
um8669f_log("UM8669F: UART %d disabled\n", ld - 1);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
lpt1_remove();
|
||||||
|
|
||||||
|
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_init(config->io[0].base);
|
||||||
|
} else
|
||||||
|
um8669f_log("UM8669F: LPT disabled\n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
gameport_remap(0);
|
||||||
|
|
||||||
|
if (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) {
|
||||||
|
um8669f_log("UM8669F: Game port enabled at port %04X\n", config->io[0].base);
|
||||||
|
gameport_remap(config->io[0].base);
|
||||||
|
} else
|
||||||
|
um8669f_log("UM8669F: Game port disabled\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,7 +194,8 @@ void
|
|||||||
um8669f_write(uint16_t port, uint8_t val, void *priv)
|
um8669f_write(uint16_t port, uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
um8669f_t *dev = (um8669f_t *) priv;
|
um8669f_t *dev = (um8669f_t *) priv;
|
||||||
int new_pnp_active;
|
|
||||||
|
um8669f_log("UM8669F: write(%04X, %02X)\n", port, val);
|
||||||
|
|
||||||
if (dev->locked) {
|
if (dev->locked) {
|
||||||
if ((port == 0x108) && (val == 0xaa))
|
if ((port == 0x108) && (val == 0xaa))
|
||||||
@@ -200,26 +210,8 @@ um8669f_write(uint16_t port, uint8_t val, void *priv)
|
|||||||
dev->regs_108[dev->cur_reg_108] = val;
|
dev->regs_108[dev->cur_reg_108] = val;
|
||||||
|
|
||||||
if (dev->cur_reg_108 == 0xc1) {
|
if (dev->cur_reg_108 == 0xc1) {
|
||||||
new_pnp_active = !!(dev->regs_108[0xc1] & 0x80);
|
um8669f_log("UM8669F: ISAPnP %sabled\n", (val & 0x80) ? "en" : "dis");
|
||||||
if (new_pnp_active != dev->pnp_active) {
|
isapnp_enable_card(dev->pnp_card, (val & 0x80) ? 2 : 0);
|
||||||
io_removehandler(0x0279, 0x0001,
|
|
||||||
NULL, NULL, NULL, um8669f_pnp_write, NULL, NULL, dev);
|
|
||||||
io_removehandler(0x0a79, 0x0001,
|
|
||||||
NULL, NULL, NULL, um8669f_pnp_write, NULL, NULL, dev);
|
|
||||||
io_removehandler(0x03e3, 0x0001,
|
|
||||||
um8669f_pnp_read, NULL, NULL, NULL, NULL, NULL, dev);
|
|
||||||
|
|
||||||
if (new_pnp_active) {
|
|
||||||
io_sethandler(0x0279, 0x0001,
|
|
||||||
NULL, NULL, NULL, um8669f_pnp_write, NULL, NULL, dev);
|
|
||||||
io_sethandler(0x0a79, 0x0001,
|
|
||||||
NULL, NULL, NULL, um8669f_pnp_write, NULL, NULL, dev);
|
|
||||||
io_sethandler(0x03e3, 0x0001,
|
|
||||||
um8669f_pnp_read, NULL, NULL, NULL, NULL, NULL, dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->pnp_active = new_pnp_active;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,6 +231,8 @@ um8669f_read(uint16_t port, void *priv)
|
|||||||
ret = dev->regs_108[dev->cur_reg_108];
|
ret = dev->regs_108[dev->cur_reg_108];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
um8669f_log("UM8669F: read(%04X) = %02X\n", port, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,42 +240,21 @@ um8669f_read(uint16_t port, void *priv)
|
|||||||
void
|
void
|
||||||
um8669f_reset(um8669f_t *dev)
|
um8669f_reset(um8669f_t *dev)
|
||||||
{
|
{
|
||||||
|
um8669f_log("UM8669F: reset()\n");
|
||||||
|
|
||||||
fdc_reset(dev->fdc);
|
fdc_reset(dev->fdc);
|
||||||
|
|
||||||
serial_remove(dev->uart[0]);
|
serial_remove(dev->uart[0]);
|
||||||
serial_setup(dev->uart[0], SERIAL1_ADDR, SERIAL1_IRQ);
|
|
||||||
|
|
||||||
serial_remove(dev->uart[1]);
|
serial_remove(dev->uart[1]);
|
||||||
serial_setup(dev->uart[1], SERIAL2_ADDR, SERIAL2_IRQ);
|
|
||||||
|
|
||||||
lpt1_remove();
|
lpt1_remove();
|
||||||
lpt1_init(0x378);
|
|
||||||
|
|
||||||
if (dev->pnp_active) {
|
isapnp_enable_card(dev->pnp_card, 0);
|
||||||
io_removehandler(0x0279, 0x0001, NULL, NULL, NULL, um8669f_pnp_write, NULL, NULL, dev);
|
|
||||||
io_removehandler(0x0a79, 0x0001, NULL, NULL, NULL, um8669f_pnp_write, NULL, NULL, dev);
|
|
||||||
io_removehandler(0x03e3, 0x0001, um8669f_pnp_read, NULL, NULL, NULL, NULL, NULL, dev);
|
|
||||||
dev->pnp_active = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->locked = 1;
|
dev->locked = 1;
|
||||||
|
|
||||||
dev->dev[DEV_FDC].enable = 1;
|
isapnp_reset_card(dev->pnp_card);
|
||||||
dev->dev[DEV_FDC].addr = 0x03f0;
|
|
||||||
dev->dev[DEV_FDC].irq = 6;
|
|
||||||
dev->dev[DEV_FDC].dma = 2;
|
|
||||||
|
|
||||||
dev->dev[DEV_COM1].enable = 1;
|
|
||||||
dev->dev[DEV_COM1].addr = 0x03f8;
|
|
||||||
dev->dev[DEV_COM1].irq = 4;
|
|
||||||
|
|
||||||
dev->dev[DEV_COM2].enable = 1;
|
|
||||||
dev->dev[DEV_COM2].addr = 0x02f8;
|
|
||||||
dev->dev[DEV_COM2].irq = 3;
|
|
||||||
|
|
||||||
dev->dev[DEV_LPT1].enable = 1;
|
|
||||||
dev->dev[DEV_LPT1].addr = 0x0378;
|
|
||||||
dev->dev[DEV_LPT1].irq = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -290,6 +263,8 @@ um8669f_close(void *priv)
|
|||||||
{
|
{
|
||||||
um8669f_t *dev = (um8669f_t *) priv;
|
um8669f_t *dev = (um8669f_t *) priv;
|
||||||
|
|
||||||
|
um8669f_log("UM8669F: close()\n");
|
||||||
|
|
||||||
free(dev);
|
free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,9 +272,15 @@ um8669f_close(void *priv)
|
|||||||
static void *
|
static void *
|
||||||
um8669f_init(const device_t *info)
|
um8669f_init(const device_t *info)
|
||||||
{
|
{
|
||||||
|
um8669f_log("UM8669F: init()\n");
|
||||||
|
|
||||||
um8669f_t *dev = (um8669f_t *) malloc(sizeof(um8669f_t));
|
um8669f_t *dev = (um8669f_t *) malloc(sizeof(um8669f_t));
|
||||||
memset(dev, 0, sizeof(um8669f_t));
|
memset(dev, 0, sizeof(um8669f_t));
|
||||||
|
|
||||||
|
dev->pnp_card = isapnp_add_card(um8669f_pnp_rom, sizeof(um8669f_pnp_rom), um8669f_pnp_config_changed, NULL, NULL, NULL, dev);
|
||||||
|
for (uint8_t i = 0; i < (sizeof(um8669f_pnp_defaults) / sizeof(isapnp_device_config_t)); i++)
|
||||||
|
isapnp_set_device_defaults(dev->pnp_card, i, &um8669f_pnp_defaults[i]);
|
||||||
|
|
||||||
dev->fdc = device_add(&fdc_at_smc_device);
|
dev->fdc = device_add(&fdc_at_smc_device);
|
||||||
|
|
||||||
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
dev->uart[0] = device_add_inst(&ns16550_device, 1);
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Author: RichardG, <richardg867@gmail.com>
|
* Author: RichardG, <richardg867@gmail.com>
|
||||||
|
*
|
||||||
* Copyright 2020 RichardG.
|
* Copyright 2020 RichardG.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -149,7 +150,7 @@ vt82c686_read(uint16_t port, void *priv)
|
|||||||
{
|
{
|
||||||
vt82c686_t *dev = (vt82c686_t *) priv;
|
vt82c686_t *dev = (vt82c686_t *) priv;
|
||||||
uint8_t ret = 0xff;
|
uint8_t ret = 0xff;
|
||||||
|
|
||||||
/* NOTE: Registers are [0xE0:0xFF] but we store them as [0x00:0x1F]. */
|
/* NOTE: Registers are [0xE0:0xFF] but we store them as [0x00:0x1F]. */
|
||||||
if (!(port & 1))
|
if (!(port & 1))
|
||||||
ret = dev->cur_reg;
|
ret = dev->cur_reg;
|
||||||
|
Reference in New Issue
Block a user