Apollo ProMedia Implementation

Needed for excessive 686A/B development
This commit is contained in:
Panagiotis
2020-10-20 20:45:12 +03:00
committed by GitHub
parent 2e92878869
commit 3465198d32
7 changed files with 212 additions and 45 deletions

View File

@@ -35,10 +35,14 @@
#include <86box/chipset.h>
#include <86box/spd.h>
#define VIA_597 0x05970100
#define VIA_598 0x05980000
#define VIA_691 0x06910000
#define VIA_8601 0x86010500
typedef struct via_apollo_t
{
uint16_t id;
uint32_t id;
uint8_t pci_conf[256];
smram_t *smram;
@@ -84,8 +88,8 @@ via_apollo_setup(via_apollo_t *dev)
/* Host Bridge */
dev->pci_conf[0x00] = 0x06; /*VIA*/
dev->pci_conf[0x01] = 0x11;
dev->pci_conf[0x02] = dev->id & 0xff;
dev->pci_conf[0x03] = (dev->id >> 8);
dev->pci_conf[0x02] = dev->id >> 16;
dev->pci_conf[0x03] = dev->id >> 24;
dev->pci_conf[0x04] = 6;
dev->pci_conf[0x05] = 0;
@@ -93,8 +97,7 @@ via_apollo_setup(via_apollo_t *dev)
dev->pci_conf[0x06] = 0x90;
dev->pci_conf[0x07] = 0x02;
if (dev->id == 0x0597)
dev->pci_conf[0x08] = 1; /* Production Silicon ("Revision B") */
dev->pci_conf[0x08] = dev->id >> 8;
dev->pci_conf[0x09] = 0;
dev->pci_conf[0x0a] = 0;
dev->pci_conf[0x0b] = 6;
@@ -105,7 +108,9 @@ via_apollo_setup(via_apollo_t *dev)
dev->pci_conf[0x10] = 0x08;
dev->pci_conf[0x34] = 0xa0;
if (dev->id == 0x0691) {
if (dev->id == VIA_8601)
dev->pci_conf[0x52] = 0x10;
if (dev->id == VIA_691) {
dev->pci_conf[0x56] = 0x01;
dev->pci_conf[0x57] = 0x01;
}
@@ -119,7 +124,7 @@ via_apollo_setup(via_apollo_t *dev)
dev->pci_conf[0x64] = 0xec;
dev->pci_conf[0x65] = 0xec;
dev->pci_conf[0x66] = 0xec;
if (dev->id == 0x0691)
if (dev->id == VIA_691)
dev->pci_conf[0x67] = 0xec; /* DRAM Timing for Banks 6,7. */
dev->pci_conf[0x6b] = 0x01;
@@ -138,7 +143,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
if (func)
return;
/*Read-only addresses*/
if ((addr < 4) || ((addr >= 5) && (addr < 7)) || ((addr >= 8) && (addr < 0xd)) ||
((addr >= 0xe) && (addr < 0x12)) || ((addr >= 0x14) && (addr < 0x50)) ||
@@ -148,9 +153,9 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
((addr >= 0xad) && (addr < 0xf0)) || ((addr >= 0xf8) && (addr < 0xfc)) ||
(addr == 0xfd))
return;
if (((addr == 0x78) || (addr >= 0xad)) && (dev->id == 0x0597))
if (((addr == 0x78) || (addr >= 0xad)) && (dev->id == VIA_597))
return;
if (((addr == 0x67) || ((addr >= 0xf0) && (addr < 0xfc))) && (dev->id != 0x0691))
if (((addr == 0x67) || ((addr >= 0xf0) && (addr < 0xfc))) && (dev->id != VIA_691))
return;
switch(addr) {
@@ -161,7 +166,11 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
dev->pci_conf[0x07] &= ~(val & 0xb0);
break;
case 0x0d:
if(dev->id == VIA_8601)
dev->pci_conf[0x0d] = (dev->pci_conf[0x0d] & ~0x07) | (val & 0x07);
else
dev->pci_conf[0x0d] = (dev->pci_conf[0x0d] & ~0x07) | (val & 0x07);
dev->pci_conf[0x75] = (dev->pci_conf[0x75] & ~0x30) | ((val & 0x06) << 3);
break;
@@ -173,45 +182,51 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
break;
case 0x50: /* Cache Control 1 */
if (dev->id == 0x0691)
if (dev->id == VIA_8601)
dev->pci_conf[0x50] = (dev->pci_conf[0x50] & ~0xd3) | (val & 0xd3);
else if (dev->id == VIA_691)
dev->pci_conf[0x50] = val;
else
dev->pci_conf[0x50] = (dev->pci_conf[0x50] & ~0xf8) | (val & 0xf8);
break;
case 0x51: /* Cache Control 2 */
if (dev->id == 0x0691)
if (dev->id >= VIA_691)
dev->pci_conf[0x51] = val;
else
dev->pci_conf[0x51] = (dev->pci_conf[0x51] & ~0xeb) | (val & 0xeb);
break;
case 0x52: /* Non_Cacheable Control */
if (dev->id == 0x0691)
if (dev->id == VIA_8601)
dev->pci_conf[0x52] = (dev->pci_conf[0x52] & ~0xdf) | (val & 0xdf);
else if (dev->id == VIA_691)
dev->pci_conf[0x52] = (dev->pci_conf[0x52] & ~0x9f) | (val & 0x9f);
else
dev->pci_conf[0x52] = (dev->pci_conf[0x52] & ~0xf5) | (val & 0xf5);
break;
case 0x53: /* System Performance Control */
if (dev->id == 0x0691)
if (dev->id == VIA_8601)
dev->pci_conf[0x53] = (dev->pci_conf[0x53] & ~0xfc) | (val & 0xfc);
else if (dev->id == VIA_691)
dev->pci_conf[0x53] = val;
else
dev->pci_conf[0x53] = (dev->pci_conf[0x53] & ~0xf0) | (val & 0xf0);
break;
case 0x56: case 0x57: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: /* DRAM Row Ending Address */
if (dev->id >= 0x0691)
if (dev->id >= VIA_691)
spd_write_drbs(dev->pci_conf, 0x5a, 0x56, 8);
else if (addr >= 0x5a)
spd_write_drbs(dev->pci_conf, 0x5a, 0x5f, 8);
break;
case 0x58:
if (dev->id == 0x0597)
if ((dev->id == VIA_597) || (dev->id == VIA_8601))
dev->pci_conf[0x58] = (dev->pci_conf[0x58] & ~0xee) | (val & 0xee);
else
dev->pci_conf[0x58] = val;
break;
case 0x59:
if (dev->id == 0x0691)
if (dev->id == VIA_691)
dev->pci_conf[0x59] = val;
else
dev->pci_conf[0x59] = (dev->pci_conf[0x59] & ~0xf0) | (val & 0xf0);
@@ -248,7 +263,7 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
apollo_map(0xe0000, 0x10000, (val & 0xc0) >> 6);
dev->pci_conf[0x63] = val;
smram_disable_all();
if (dev->id == 0x0691) switch (val & 0x03) {
if (dev->id >= VIA_691) switch (val & 0x03) {
case 0x00:
default:
apollo_smram_map(dev, 1, 0x000a0000, 0x00020000, 1); /* SMM: Code DRAM, Data DRAM */
@@ -271,21 +286,21 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
default:
/* Disable SMI Address Redirection (default) */
apollo_smram_map(dev, 1, 0x000a0000, 0x00020000, 0);
if (dev->id == 0x0597)
if (dev->id == VIA_597)
apollo_smram_map(dev, 1, 0x00030000, 0x00020000, 1);
apollo_smram_map(dev, 0, 0x000a0000, 0x00020000, 0);
break;
case 0x01:
/* Allow access to DRAM Axxxx-Bxxxx for both normal and SMI cycles */
apollo_smram_map(dev, 1, 0x000a0000, 0x00020000, 1);
if (dev->id == 0x0597)
if (dev->id == VIA_597)
apollo_smram_map(dev, 1, 0x00030000, 0x00020000, 1);
apollo_smram_map(dev, 0, 0x000a0000, 0x00020000, 1);
break;
case 0x02:
/* Reserved */
apollo_smram_map(dev, 1, 0x000a0000, 0x00020000, 3);
if (dev->id == 0x0597) {
if (dev->id == VIA_597) {
/* SMI 3xxxx-4xxxx redirect to Axxxx-Bxxxx. */
apollo_smram_map(dev, 1, 0x00030000, 0x00020000, 1);
}
@@ -294,38 +309,46 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
case 0x03:
/* Allow SMI Axxxx-Bxxxx DRAM access */
apollo_smram_map(dev, 1, 0x000a0000, 0x00020000, 1);
if (dev->id == 0x0597)
if (dev->id == VIA_597)
apollo_smram_map(dev, 1, 0x00030000, 0x00020000, 1);
apollo_smram_map(dev, 0, 0x000a0000, 0x00020000, 0);
break;
}
break;
case 0x68:
if (dev->id == 0x0597)
if (dev->id == VIA_597)
dev->pci_conf[0x68] = (dev->pci_conf[0x6b] & ~0xfe) | (val & 0xfe);
else if (dev->id == 0x0598)
else if ((dev->id == VIA_598) || (dev->id == VIA_8601))
dev->pci_conf[0x68] = val;
else
dev->pci_conf[0x68] = (dev->pci_conf[0x6b] & ~0xfd) | (val & 0xfd);
break;
case 0x69:
if (dev->id == VIA_8601)
dev->pci_conf[0x69] = (dev->pci_conf[0x69] & ~0xfe) | (val & 0xfe);
else
dev->pci_conf[0x69] = val;
break;
case 0x6b:
if (dev->id == 0x0691)
if (dev->id == VIA_8601)
dev->pci_conf[0x6b] = val;
else if (dev->id == VIA_691)
dev->pci_conf[0x6b] = (dev->pci_conf[0x6b] & ~0xcf) | (val & 0xcf);
else
dev->pci_conf[0x6b] = (dev->pci_conf[0x6b] & ~0xc1) | (val & 0xc1);
break;
case 0x6c:
if (dev->id == 0x0597)
if ((dev->id == VIA_597) || (dev->id == VIA_8601))
dev->pci_conf[0x6c] = (dev->pci_conf[0x6c] & ~0x1f) | (val & 0x1f);
else if (dev->id == 0x0598)
else if (dev->id == VIA_598)
dev->pci_conf[0x6c] = (dev->pci_conf[0x6c] & ~0x7f) | (val & 0x7f);
else
dev->pci_conf[0x6c] = val;
break;
case 0x6d:
if (dev->id == 0x0597)
if (dev->id == VIA_597)
dev->pci_conf[0x6d] = (dev->pci_conf[0x6d] & ~0x0f) | (val & 0x0f);
else if (dev->id == 0x0598)
else if ((dev->id == VIA_598) || (dev->id == VIA_8601))
dev->pci_conf[0x6d] = (dev->pci_conf[0x6d] & ~0x7f) | (val & 0x7f);
else
dev->pci_conf[0x6d] = val;
@@ -335,24 +358,52 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
break;
case 0x70:
if (dev->id == 0x0597)
if (dev->id == VIA_8601)
dev->pci_conf[0x70] = (dev->pci_conf[0x70] & ~0xdf) | (val & 0xdf);
else if (dev->id == VIA_597)
dev->pci_conf[0x70] = (dev->pci_conf[0x70] & ~0xf1) | (val & 0xf1);
else
dev->pci_conf[0x70] = val;
break;
case 0x73:
if (dev->id == VIA_8601)
dev->pci_conf[0x73] = (dev->pci_conf[0x73] & ~0x7f) | (val & 0x7f);
else
dev->pci_conf[0x73] = val;
break;
case 0x74:
dev->pci_conf[0x74] = (dev->pci_conf[0x74] & ~0xc0) | (val & 0xc0);
if (dev->id == VIA_8601)
dev->pci_conf[0x74] = (dev->pci_conf[0x74] & ~0xdf) | (val & 0xdf);
else
dev->pci_conf[0x74] = (dev->pci_conf[0x74] & ~0xc0) | (val & 0xc0);
break;
case 0x75:
dev->pci_conf[0x75] = (dev->pci_conf[0x75] & ~0xcf) | (val & 0xcf);
if (dev->id == VIA_8601)
dev->pci_conf[0x75] = val;
else
dev->pci_conf[0x75] = (dev->pci_conf[0x75] & ~0xcf) | (val & 0xcf);
break;
case 0x76:
dev->pci_conf[0x76] = (dev->pci_conf[0x76] & ~0xf0) | (val & 0xf0);
if (dev->id == VIA_8601)
dev->pci_conf[0x75] = val;
else
dev->pci_conf[0x76] = (dev->pci_conf[0x76] & ~0xf0) | (val & 0xf0);
break;
case 0x77:
if (dev->id != VIA_8601)
dev->pci_conf[0x77] = (dev->pci_conf[0x77] & ~0xc0) | (val & 0xc0);
break;
case 0x78:
dev->pci_conf[0x78] = (dev->pci_conf[0x78] & ~0xd5) | (val & 0xd5);
break;
case 0x79:
dev->pci_conf[0x79] = (dev->pci_conf[0x79] & ~0xfc) | (val & 0xfc);
break;
case 0x7a:
dev->pci_conf[0x7a] = (dev->pci_conf[0x7a] & ~0x89) | (val & 0x89);
break;
case 0x7e:
if (dev->id != VIA_8601)
dev->pci_conf[0x7e] = (dev->pci_conf[0x7e] & ~0x3f) | (val & 0x3f);
break;
@@ -361,14 +412,25 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
break;
case 0x84:
/* The datasheet first mentions 7-0 but then says 3-0 are reserved -
- minimum of 16 MB for the graphics aperture? */
dev->pci_conf[0x84] = (dev->pci_conf[0x84] & ~0xf0) | (val & 0xf0);
- minimum of 16 MB for the graphics aperture? 8601 datasheet doesn't refer it. */
if(dev->id == VIA_8601)
dev->pci_conf[0x84] = val;
else
dev->pci_conf[0x84] = (dev->pci_conf[0x84] & ~0xf0) | (val & 0xf0);
break;
case 0x88:
dev->pci_conf[0x88] = (dev->pci_conf[0x88] & ~0x07) | (val & 0x07);
if(dev->id == VIA_8601)
dev->pci_conf[0x88] = (dev->pci_conf[0x88] & ~0x06) | (val & 0x06);
else
dev->pci_conf[0x88] = (dev->pci_conf[0x88] & ~0x07) | (val & 0x07);
break;
case 0x89:
dev->pci_conf[0x89] = (dev->pci_conf[0x89] & ~0xf0) | (val & 0xf0);
case 0x8a:
case 0x8b:
if(dev->id == VIA_8601)
dev->pci_conf[addr] = val;
else
dev->pci_conf[0x89] = (dev->pci_conf[0x89] & ~0xf0) | (val & 0xf0);
break;
case 0xa8:
@@ -378,13 +440,29 @@ via_apollo_host_bridge_write(int func, int addr, uint8_t val, void *priv)
dev->pci_conf[0xa9] = (dev->pci_conf[0xa9] & ~0x03) | (val & 0x03);
break;
case 0xac:
if(dev->id == VIA_8601)
dev->pci_conf[0xac] = (dev->pci_conf[0xac] & ~0x7f) | (val & 0x7f);
else
dev->pci_conf[0xac] = (dev->pci_conf[0xac] & ~0x0f) | (val & 0x0f);
break;
case 0xad:
dev->pci_conf[0xac] = (dev->pci_conf[0xac] & ~0x0f) | (val & 0x0f);
break;
case 0xfc:
if (dev->id > 0x0597)
if (dev->id == VIA_8601)
dev->pci_conf[0xfc] = (dev->pci_conf[0xfc] & ~0x03) | (val & 0x03);
else if (dev->id > VIA_597)
dev->pci_conf[0xfc] = (dev->pci_conf[0xfc] & ~0x01) | (val & 0x01);
break;
case 0xfd:
if (dev->id == VIA_8601)
dev->pci_conf[0xfd] = (dev->pci_conf[0xfd] & ~0x07) | (val & 0x07);
else
dev->pci_conf[0xfd] = val;
break;
default:
dev->pci_conf[addr] = val;
break;
@@ -442,17 +520,21 @@ via_apollo_init(const device_t *info)
dev->id = info->local;
switch (dev->id) {
case 0x0597:
case VIA_597:
device_add(&via_vp3_agp_device);
break;
case 0x0598:
case VIA_598:
device_add(&via_mvp3_agp_device);
break;
case 0x0691:
case VIA_691:
device_add(&via_apro_agp_device);
break;
case VIA_8601:
device_add(&via_vt8601_agp_device);
break;
}
via_apollo_setup(dev);
@@ -477,7 +559,7 @@ const device_t via_vp3_device =
{
"VIA Apollo VP3",
DEVICE_PCI,
0x0597, /*VT82C597*/
VIA_597, /*VT82C597*/
via_apollo_init,
via_apollo_close,
via_apollo_reset,
@@ -491,7 +573,7 @@ const device_t via_mvp3_device =
{
"VIA Apollo MVP3",
DEVICE_PCI,
0x0598, /*VT82C598MVP*/
VIA_598, /*VT82C598MVP*/
via_apollo_init,
via_apollo_close,
via_apollo_reset,
@@ -504,7 +586,20 @@ const device_t via_mvp3_device =
const device_t via_apro_device = {
"VIA Apollo Pro",
DEVICE_PCI,
0x0691, /*VT82C691*/
VIA_691, /*VT82C691*/
via_apollo_init,
via_apollo_close,
via_apollo_reset,
NULL,
NULL,
NULL,
NULL
};
const device_t via_vt8601_device = {
"VIA Apollo ProMedia",
DEVICE_PCI,
VIA_8601, /*VT8601*/
via_apollo_init,
via_apollo_close,
via_apollo_reset,

View File

@@ -39,6 +39,7 @@
#define AGP_BRIDGE_VIA_597 0x11068597
#define AGP_BRIDGE_VIA_598 0x11068598
#define AGP_BRIDGE_VIA_691 0x11068691
#define AGP_BRIDGE_VIA_8601 0x11068601
#define AGP_BRIDGE_VIA(x) (((x) >> 16) == 0x1106)
#define AGP_BRIDGE(x) ((x) >= AGP_BRIDGE_VIA_597)
@@ -227,6 +228,7 @@ pci_bridge_reset(void *priv)
case AGP_BRIDGE_VIA_597:
case AGP_BRIDGE_VIA_598:
case AGP_BRIDGE_VIA_691:
case AGP_BRIDGE_VIA_8601:
dev->regs[0x04] = 0x07;
dev->regs[0x06] = 0x20;
dev->regs[0x07] = 0x02;
@@ -406,3 +408,17 @@ const device_t via_apro_agp_device =
NULL,
NULL
};
const device_t via_vt8601_agp_device =
{
"VIA Apollo ProMedia AGP Bridge",
DEVICE_PCI,
AGP_BRIDGE_VIA_8601,
pci_bridge_init,
NULL,
pci_bridge_reset,
NULL,
NULL,
NULL,
NULL
};

View File

@@ -120,6 +120,7 @@ extern const device_t via_vpx_device;
extern const device_t via_vp3_device;
extern const device_t via_mvp3_device;
extern const device_t via_apro_device;
extern const device_t via_vt8601_device;
extern const device_t via_vt82c586b_device;
extern const device_t via_vt82c596_device;
extern const device_t via_vt82c596b_device;

View File

@@ -478,6 +478,7 @@ extern int machine_at_awo671r_init(const machine_t *);
extern int machine_at_63a_init(const machine_t *);
extern int machine_at_s370sba_init(const machine_t *);
extern int machine_at_apas3_init(const machine_t *);
extern int machine_at_603tcf_init(const machine_t *);
/* m_at_misc.c */
extern int machine_at_vpc2007_init(const machine_t *);

View File

@@ -122,6 +122,7 @@ extern const device_t i440gx_agp_device;
extern const device_t via_vp3_agp_device;
extern const device_t via_mvp3_agp_device;
extern const device_t via_apro_agp_device;
extern const device_t via_vt8601_agp_device;
#endif

View File

@@ -276,7 +276,6 @@ machine_at_63a_init(const machine_t *model)
return ret;
}
int
machine_at_apas3_init(const machine_t *model)
{
@@ -307,3 +306,56 @@ machine_at_apas3_init(const machine_t *model)
return ret;
}
int
machine_at_603tcf_init(const machine_t *model)
{
int ret;
ret = bios_load_linear(L"roms/machines/603tcf/603tcfA4.BIN",
0x000c0000, 262144, 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, 1, 2, 0, 0);
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(0x01, PCI_CARD_SPECIAL, 1, 2, 3, 4);
device_add(&via_vt8601_device);
device_add(&via_vt82c686b_device);
device_add(&via_vt82c686_sio_device);
device_add(&keyboard_ps2_ami_pci_device);
device_add(&sst_flash_39sf020_device);
spd_register(SPD_TYPE_SDRAM, 0x3, 256);
hwm_values_t machine_hwm = {
{ /* fan speeds */
3000, /* Chassis */
3000, /* CPU */
3000 /* Power */
}, { /* temperatures */
30, /* MB */
30, /* JTPWR */
30 /* CPU */
}, { /* voltages */
2050, /* VCORE (2.05V by default) */
0, /* unused */
3300, /* +3.3V */
RESISTOR_DIVIDER(5000, 11, 16), /* +5V (divider values bruteforced) */
RESISTOR_DIVIDER(12000, 28, 10), /* +12V (28K/10K divider suggested in the W83781D datasheet) */
RESISTOR_DIVIDER(12000, 59, 20), /* -12V (divider values bruteforced) */
RESISTOR_DIVIDER(5000, 1, 2) /* -5V (divider values bruteforced) */
}
};
hwm_set_values(machine_hwm);
device_add(&via_vt82c686_hwm_device);
return ret;
}

View File

@@ -399,6 +399,7 @@ const machine_t machines[] = {
/* VIA Apollo Pro */
{ "[VIA Apollo Pro] PC Partner APAS3", "apas3", MACHINE_TYPE_SOCKET370, {{"Intel", cpus_Celeron}, {"VIA", cpus_Cyrix3}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_AGP | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8, 768, 8, 255, machine_at_apas3_init, NULL },
{ "[VIA Apollo ProMedia] Jetway 603TCF", "603tcf", MACHINE_TYPE_SOCKET370, {{"Intel", cpus_Celeron}, {"VIA", cpus_Cyrix3}, {"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_AGP | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8, 512, 8, 255, machine_at_603tcf_init, NULL },
/* Miscellaneous/Fake/Hypervisor machines */
{ "[i440BX] Microsoft Virtual PC 2007", "vpc2007", MACHINE_TYPE_MISC, {{"Intel", cpus_PentiumIID}, {"Intel/PGA370", cpus_Celeron},{"", NULL}, {"", NULL}, {"", NULL}}, MACHINE_AGP | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8, 1024, 8, 255, machine_at_vpc2007_init, NULL },