VIA southbridge overhaul, day 1.5

This commit is contained in:
RichardG867
2020-10-10 17:02:33 -03:00
parent 8f1f3bdc08
commit 9043d7b656
6 changed files with 114 additions and 45 deletions

View File

@@ -55,7 +55,8 @@
#define VIA_PIPC_586A 0x05862000
#define VIA_PIPC_586B 0x05864700
#define VIA_PIPC_596B 0x05961200
#define VIA_PIPC_596A 0x05961200
#define VIA_PIPC_596B 0x05960000
#define VIA_PIPC_686A 0x06861400
#define VIA_PIPC_686B 0x06864000
@@ -151,7 +152,7 @@ pipc_reset_hard(void *priv)
dev->ide_regs[0x02] = 0x71; dev->ide_regs[0x03] = 0x05;
dev->ide_regs[0x04] = 0x80;
dev->ide_regs[0x06] = (dev->local == VIA_PIPC_686A) ? 0x90 : 0x80; dev->ide_regs[0x07] = 0x02;
dev->ide_regs[0x08] = 0x06;
dev->ide_regs[0x08] = (dev->local >= VIA_PIPC_596B) ? 0x10 : 0x06;
dev->ide_regs[0x09] = 0x85;
dev->ide_regs[0x0a] = 0x01;
dev->ide_regs[0x0b] = 0x01;
@@ -179,7 +180,7 @@ pipc_reset_hard(void *priv)
dev->ide_regs[0x4f] = 0xff;
dev->ide_regs[0x50] = 0x03; dev->ide_regs[0x51] = 0x03;
dev->ide_regs[0x52] = 0x03; dev->ide_regs[0x53] = 0x03;
if (dev->local >= VIA_PIPC_596B)
if (dev->local >= VIA_PIPC_596A)
dev->ide_regs[0x54] = 0x06;
dev->ide_regs[0x61] = 0x02;
@@ -196,12 +197,13 @@ pipc_reset_hard(void *priv)
dev->usb_regs[i][0x02] = 0x38; dev->usb_regs[i][0x03] = 0x30;
dev->usb_regs[i][0x04] = 0x00; dev->usb_regs[i][0x05] = 0x00;
dev->usb_regs[i][0x06] = 0x00; dev->usb_regs[i][0x07] = 0x02;
if (dev->local >= VIA_PIPC_686A)
dev->usb_regs[i][0x08] = 0x16;
else if (dev->local >= VIA_PIPC_596B)
if (dev->local <= VIA_PIPC_586B)
dev->usb_regs[i][0x08] = 0x02;
else if (dev->local <= VIA_PIPC_596B)
dev->usb_regs[i][0x08] = 0x08;
else
dev->usb_regs[i][0x08] = 0x02;
dev->usb_regs[i][0x08] = 0x16;
dev->usb_regs[i][0x0a] = 0x03;
dev->usb_regs[i][0x0b] = 0x0c;
dev->usb_regs[i][0x0d] = 0x16;
@@ -229,15 +231,15 @@ pipc_reset_hard(void *priv)
dev->power_regs[0x03] = 0x30;
dev->power_regs[0x04] = 0x00; dev->power_regs[0x05] = 0x00;
dev->power_regs[0x06] = (dev->local == VIA_PIPC_686B) ? 0x90 : 0x80; dev->power_regs[0x07] = 0x02;
if (dev->local >= VIA_PIPC_686A)
dev->power_regs[0x08] = 0x40;
else if (dev->local >= VIA_PIPC_596B)
if (dev->local <= VIA_PIPC_586B)
dev->power_regs[0x08] = 0x10;
else if (dev->local <= VIA_PIPC_596B)
dev->power_regs[0x08] = 0x20;
else
dev->power_regs[0x08] = 0x10;
dev->power_regs[0x08] = 0x40;
dev->power_regs[0x48] = 0x01;
if (dev->local >= VIA_PIPC_596B)
if (dev->local >= VIA_PIPC_596A)
dev->power_regs[0x90] = 0x01;
}
@@ -246,9 +248,12 @@ pipc_reset_hard(void *priv)
pci_set_irq_routing(PCI_INTC, PCI_IRQ_DISABLED);
pci_set_irq_routing(PCI_INTD, PCI_IRQ_DISABLED);
pci_set_mirq_routing(PCI_MIRQ0, PCI_IRQ_DISABLED);
pci_set_mirq_routing(PCI_MIRQ1, PCI_IRQ_DISABLED);
pci_set_mirq_routing(PCI_MIRQ2, PCI_IRQ_DISABLED);
if (dev->local <= VIA_PIPC_586B) {
pci_set_mirq_routing(PCI_MIRQ0, PCI_IRQ_DISABLED);
pci_set_mirq_routing(PCI_MIRQ1, PCI_IRQ_DISABLED);
if (dev->local == VIA_PIPC_586B)
pci_set_mirq_routing(PCI_MIRQ2, PCI_IRQ_DISABLED);
}
ide_pri_disable();
ide_sec_disable();
@@ -392,10 +397,13 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
(addr == 0x53) || ((addr >= 0x5d) && (addr < 0x5f)) || ((addr >= 0x71) && (addr < 0x74)) || (addr >= 0x90))
return;
if ((dev->local <= VIA_PIPC_586A) && ((addr >= 0x58) && (addr < 0x80)))
return;
if ((dev->local <= VIA_PIPC_586B) && (addr >= 0x74))
return;
if ((dev->local <= VIA_PIPC_596B) && ((addr == 0x51) || (addr == 0x52) || (addr == 0x5f) || (addr == 0x85) ||
if ((dev->local <= VIA_PIPC_596A) && ((addr == 0x51) || (addr == 0x52) || (addr == 0x5f) || (addr == 0x85) ||
(addr == 0x86) || ((addr >= 0x8a) && (addr < 0x90))))
return;
@@ -408,12 +416,8 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
break;
case 0x47:
if ((val & 0x81) == 0x81) {
/* Trigger TRC reset. */
outb(0xcf9, 0x00);
outb(0xcf9, 0xff);
return;
}
if (val & 0x01)
trc_write(0x0047, (val & 0x80) ? 0x06 : 0x04, NULL);
pic_set_shadow(!!(val & 0x10));
pci_elcr_set_enabled(!!(val & 0x20));
dev->pci_isa_regs[0x47] = val & 0xfe;
@@ -430,24 +434,24 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
pci_set_irq_level(PCI_INTD, !(val & 1));
break;
case 0x55:
pci_set_irq_routing((dev->local >= VIA_PIPC_596B) ? PCI_INTA : PCI_INTD, (val & 0xf0) ? (val >> 4) : PCI_IRQ_DISABLED);
if (dev->local < VIA_PIPC_686A)
pci_set_irq_routing((dev->local >= VIA_PIPC_596A) ? PCI_INTA : PCI_INTD, (val & 0xf0) ? (val >> 4) : PCI_IRQ_DISABLED);
if (dev->local <= VIA_PIPC_586B)
pci_set_mirq_routing(PCI_MIRQ0, (val & 0x0f) ? (val & 0x0f) : PCI_IRQ_DISABLED);
dev->pci_isa_regs[0x55] = val;
break;
case 0x56:
pci_set_irq_routing((dev->local >= VIA_PIPC_596B) ? PCI_INTC : PCI_INTA, (val & 0xf0) ? (val >> 4) : PCI_IRQ_DISABLED);
pci_set_irq_routing((dev->local >= VIA_PIPC_596A) ? PCI_INTC : PCI_INTA, (val & 0xf0) ? (val >> 4) : PCI_IRQ_DISABLED);
pci_set_irq_routing(PCI_INTB, (val & 0x0f) ? (val & 0x0f) : PCI_IRQ_DISABLED);
dev->pci_isa_regs[0x56] = val;
break;
case 0x57:
pci_set_irq_routing((dev->local >= VIA_PIPC_596B) ? PCI_INTD : PCI_INTC, (val & 0xf0) ? (val >> 4) : PCI_IRQ_DISABLED);
if (dev->local < VIA_PIPC_686A)
pci_set_irq_routing((dev->local >= VIA_PIPC_596A) ? PCI_INTD : PCI_INTC, (val & 0xf0) ? (val >> 4) : PCI_IRQ_DISABLED);
if (dev->local <= VIA_PIPC_586B)
pci_set_mirq_routing(PCI_MIRQ1, (val & 0x0f) ? (val & 0x0f) : PCI_IRQ_DISABLED);
dev->pci_isa_regs[0x57] = val;
break;
case 0x58:
if (dev->local < VIA_PIPC_686A)
if (dev->local == VIA_PIPC_586B)
pci_set_mirq_routing(PCI_MIRQ2, (val & 0x0f) ? (val & 0x0f) : PCI_IRQ_DISABLED);
dev->pci_isa_regs[0x58] = val;
break;
@@ -618,26 +622,37 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
/* Read-only addresses */
if ((addr < 0xd) || ((addr >= 0xe) && (addr < 0x40)) || (addr == 0x43) || (addr == 0x48) ||
(addr == 0x4e) || (addr == 0x4f) || (addr == 0x56) || (addr == 0x57) || ((addr >= 0x5c) && (addr < 0x61)) ||
((addr >= 0x64) && (addr < 0x70)) || (addr == 0x72) || (addr == 0x73) || ((addr >= 0x75) && (addr < 0x90)) ||
((addr >= 0x92) && (addr < 0xd2)) || (addr >= 0xd7))
((addr >= 0x64) && (addr < 0x70)) || (addr == 0x72) || (addr == 0x73) || ((addr >= 0x75) && (addr < 0x80)) ||
((addr >= 0x82) && (addr < 0x90)) || ((addr >= 0x92) && (addr < 0xd2)) || (addr >= 0xd7))
return;
if ((dev->local <= VIA_PIPC_586B) && ((addr == 0x4c) || (addr == 0x4d) || (addr >= 0x54)))
return;
if ((dev->local <= VIA_PIPC_596A) && ((addr >= 0x64) && (addr < 0x80)))
return;
if ((dev->local <= VIA_PIPC_596B) && ((addr >= 0x64) && (addr < 0x90)))
return;
switch (addr) {
case 0x41: case 0x49:
dev->power_regs[addr] = val;
acpi_update_io_mapping(dev->acpi, dev->power_regs[0x49] << 8, dev->power_regs[0x41] & 0x80);
c = (dev->power_regs[0x49] << 8);
if (dev->local >= VIA_PIPC_596A)
c |= (dev->power_regs[0x48] & 0x80);
acpi_update_io_mapping(dev->acpi, c, dev->power_regs[0x41] & 0x80);
break;
case 0x61: case 0x62: case 0x63:
dev->power_regs[(addr - 0x58)] = val;
break;
case 0x80: case 0x81:
dev->power_regs[addr] = val;
smbus_piix4_remap(dev->smbus, (dev->power_regs[0x81] << 8) | (dev->power_regs[0x80] & 0xf0), 1);
break;
case 0x90: case 0x91:
dev->power_regs[addr] = val;
smbus_piix4_remap(dev->smbus, (dev->power_regs[0x91] << 8) | (dev->power_regs[0x90] & 0xf0), dev->power_regs[0xd2] & 0x01);
@@ -690,9 +705,12 @@ pipc_init(const device_t *info)
dma_alias_set();
pci_enable_mirq(0);
pci_enable_mirq(1);
pci_enable_mirq(2);
if (dev->local <= VIA_PIPC_586B) {
pci_enable_mirq(0);
pci_enable_mirq(1);
if (dev->local == VIA_PIPC_586B)
pci_enable_mirq(2);
}
return dev;
}
@@ -722,6 +740,21 @@ const device_t via_vt82c586b_device =
NULL
};
const device_t via_vt82c596_device =
{
"VIA VT82C596(A)",
DEVICE_PCI,
VIA_PIPC_596A,
pipc_init,
pipc_close,
NULL,
NULL,
NULL,
NULL,
NULL
};
const device_t via_vt82c596b_device =
{
"VIA VT82C596B",

View File

@@ -214,7 +214,7 @@ smbus_piix4_remap(smbus_piix4_t *dev, uint16_t new_io_base, uint8_t enable)
io_removehandler(dev->io_base, 0x10, smbus_piix4_read, NULL, NULL, smbus_piix4_write, NULL, NULL, dev);
dev->io_base = new_io_base;
smbus_piix4_log("SMBus PIIX4: remap to %04Xh\n", dev->io_base);
smbus_piix4_log("SMBus PIIX4: remap to %04Xh (enable %d)\n", dev->io_base, !!enable);
if ((enable) && (dev->io_base != 0x0000))
io_sethandler(dev->io_base, 0x10, smbus_piix4_read, NULL, NULL, smbus_piix4_write, NULL, NULL, dev);

View File

@@ -121,6 +121,7 @@ extern const device_t via_mvp3_device;
extern const device_t via_apro_device;
extern const device_t via_vt82c586b_device;
extern const device_t via_vt82c596_device;
extern const device_t via_vt82c596b_device;
/* VLSI */

View File

@@ -423,6 +423,7 @@ extern int machine_at_ax6bc_init(const machine_t *);
extern int machine_at_atc6310bxii_init(const machine_t *);
extern int machine_at_tsunamiatx_init(const machine_t *);
extern int machine_at_p6sba_init(const machine_t *);
extern int machine_at_ka6100_init(const machine_t *);
extern int machine_at_6vx_init(const machine_t *);
#ifdef EMU_DEVICE_H

View File

@@ -567,6 +567,46 @@ machine_at_tsunamiatx_init(const machine_t *model)
}
const device_t *
at_tsunamiatx_get_device(void)
{
return &es1371_onboard_device;
}
int
machine_at_ka6100_init(const machine_t *model)
{
int ret;
ret = bios_load_linear(L"roms/machines/ka6100/610011ex.bin",
0x000e0000, 131072, 0);
if (bios_only || !ret)
return ret;
machine_at_common_init_ex(model, 2);
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0);
pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 3, 4);
pci_register_slot(0x08, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x09, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x01, PCI_CARD_SPECIAL, 1, 2, 3, 4);
device_add(&via_apro_device);
device_add(&via_vt82c596_device);
device_add(&w83877f_device);
device_add(&keyboard_ps2_ami_pci_device);
device_add(&sst_flash_39sf020_device);
spd_register(SPD_TYPE_SDRAM, 0x7, 256);
return ret;
}
int
machine_at_6vx_init(const machine_t *model)
{
@@ -582,15 +622,15 @@ machine_at_6vx_init(const machine_t *model)
pci_init(PCI_CONFIG_TYPE_1);
pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0);
pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 1, 2, 3, 4);
pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 3, 4);
pci_register_slot(0x08, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x09, PCI_CARD_NORMAL, 2, 3, 4, 1);
pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 4, 1, 2);
pci_register_slot(0x0B, PCI_CARD_NORMAL, 4, 1, 2, 3);
pci_register_slot(0x0C, PCI_CARD_NORMAL, 1, 2, 3, 4);
pci_register_slot(0x01, PCI_CARD_SPECIAL, 0, 0, 3, 4);
pci_register_slot(0x01, PCI_CARD_SPECIAL, 1, 2, 3, 4);
device_add(&via_apro_device);
device_add(&via_vt82c596b_device);
device_add(&via_vt82c596_device);
device_add(&w83877f_device);
device_add(&keyboard_ps2_ami_pci_device);
device_add(&sst_flash_39sf020_device);
@@ -598,10 +638,3 @@ machine_at_6vx_init(const machine_t *model)
return ret;
}
const device_t *
at_tsunamiatx_get_device(void)
{
return &es1371_onboard_device;
}

View File

@@ -363,6 +363,7 @@ const machine_t machines[] = {
{ "[i440BX] A-Trend ATC6310BXII", "atc6310bxii", MACHINE_TYPE_SLOT1, {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_atc6310bxii_init, NULL },
{ "[i440BX] Tyan Tsunami ATX", "tsunamiatx", MACHINE_TYPE_SLOT1, {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_SOUND, 8, 1024, 8, 255, machine_at_tsunamiatx_init, at_tsunamiatx_get_device },
{ "[i440BX] SuperMicro Super P6SBA", "p6sba", MACHINE_TYPE_SLOT1, {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_p6sba_init, NULL },
{ "[VIA Apollo Pro] FIC KA-6100", "ka6100", MACHINE_TYPE_SLOT1, {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_ka6100_init, NULL },
{ "[VIA Apollo Pro] Gigabyte GA-6VX", "6vx", MACHINE_TYPE_SLOT1, {{"Intel", cpus_PentiumII}, {"Intel/PGA370", cpus_Celeron},{"VIA", cpus_Cyrix3},{"", NULL},{"", NULL}}, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 768, 8, 255, machine_at_6vx_init, NULL },
/* Slot 2 machines(Including Slot 1/2 Hybrids) */