More AT NVR and VIA fixes - the Gigabyte GA-6VX-4X AMI BIOS (machine will be added on the WIP branch) works fine now.

This commit is contained in:
OBattler
2021-07-18 04:52:32 +02:00
parent f691778039
commit 00a9894821
3 changed files with 41 additions and 41 deletions

View File

@@ -480,7 +480,7 @@ acpi_reg_read_via(int size, uint16_t addr, void *p)
case 0x42:
/* GPIO port Output Value */
if (size == 1)
ret = (dev->regs.gpio_val & 0x2f) | 0x10;
ret = dev->regs.gpio_val & 0x13;
break;
case 0x44:
/* GPIO port Input Value */
@@ -532,7 +532,7 @@ acpi_reg_read_via_596b(int size, uint16_t addr, void *p)
case 0x42:
/* GPIO port Output Value */
if (size == 1)
ret = (dev->regs.gpio_val & 0x2f) | 0x10;
ret = dev->regs.gpio_val & 0x13;
break;
case 0x44: case 0x45:
/* External SMI Input Value */
@@ -1037,7 +1037,7 @@ acpi_reg_write_via(int size, uint16_t addr, uint8_t val, void *p)
case 0x42:
/* GPIO port Output Value */
if (size == 1) {
dev->regs.gpio_val = val & 0x2f;
dev->regs.gpio_val = val & 0x13;
acpi_i2c_set(dev);
}
break;
@@ -1065,13 +1065,12 @@ acpi_reg_write_via_596b(int size, uint16_t addr, uint8_t val, void *p)
switch (addr) {
case 0x42:
/* GPIO port Output Value */
if (size == 1) {
dev->regs.gpio_val = val & 0x2f;
acpi_i2c_set(dev);
}
if (size == 1)
dev->regs.gpio_val = val & 0x13;
break;
case 0x4c: case 0x4d: case 0x4e: case 0x4f:
/* GPO Port Output Value */
pclog("Write %02X to %02X\n", val, addr);
dev->regs.gpo_val = ((dev->regs.gpo_val & ~(0xff << shift32)) | (val << shift32)) & 0x7fffffff;
break;
default:
@@ -1583,7 +1582,7 @@ acpi_reset(void *priv)
dev->regs.gpi_val |= 0x00000004;
if (!strcmp(machines[machine].internal_name, "6via90ap"))
dev->regs.gpi_val |= 0x00000004;
dev->regs.gpi_val = 0xffffffe5;
// dev->regs.gpi_val = 0xffffffe5;
// dev->regs.gpi_val = 0x00000004;
}

View File

@@ -285,7 +285,7 @@ pipc_reset_hard(void *priv)
dev->power_regs[0x34] = 0x68;
dev->power_regs[0x40] = 0x20;
dev->power_regs[0x42] = 0xd0;
dev->power_regs[0x42] = 0x50;
dev->power_regs[0x48] = 0x01;
if (dev->local == VIA_PIPC_686B) {
@@ -927,8 +927,8 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
break;
case 0x42:
dev->power_regs[addr] &= ~0x0f;
dev->power_regs[addr] |= val & 0x0f;
dev->power_regs[addr] &= ~0x2f;
dev->power_regs[addr] |= val & 0x2f;
acpi_set_irq_line(dev->acpi, dev->power_regs[addr]);
break;

View File

@@ -589,19 +589,6 @@ nvr_reg_write(uint16_t reg, uint8_t val, void *priv)
break;
case RTC_REGD: /* R/O */
#if 0
/* VT82C686A/B have an ACPI register bit controlled by 0D bit 7.
This is overwritten on read, but testing shows BIOSes will
immediately check the ACPI register after writing to this. */
if (local->cent == RTC_CENTURY_VIA) {
nvr->regs[RTC_REGD] &= ~0x80;
if (val & 0x80)
nvr->regs[RTC_REGD] |= 0x80;
}
#else
if ((local->cent == RTC_CENTURY_VIA) && !local->wp_0d)
nvr->regs[RTC_REGD] = val/* & 0x80*/;
#endif
break;
case 0x2e:
@@ -704,6 +691,10 @@ nvr_read(uint16_t addr, void *priv)
ret = (nvr->regs[RTC_REGA] & 0x7f) | local->stat;
break;
case RTC_REGB:
ret = nvr->regs[local->addr[addr_id]] | 0x40;
break;
case RTC_REGC:
picintc(1 << nvr->irq);
ret = nvr->regs[RTC_REGC];
@@ -711,14 +702,9 @@ nvr_read(uint16_t addr, void *priv)
break;
case RTC_REGD:
/* On VIA VT82C596B onwards, bits 6-0 of this register always read 0. */
if (local->cent == RTC_CENTURY_VIA)
ret = 0x80;
// ret = nvr->regs[RTC_REGD]/* & 0x80*/;
else {
nvr->regs[RTC_REGD] |= REGD_VRT;
ret = nvr->regs[RTC_REGD];
}
/* Bits 6-0 of this register always read 0. Bit 7 is battery state,
we should always return it set, as that means the battery is OK. */
ret = REGD_VRT;
break;
case 0x2c:
@@ -935,6 +921,17 @@ nvr_lock_set(int base, int size, int lock, nvr_t *nvr)
}
static void
nvr_at_reset(void *priv)
{
nvr_t *nvr = (nvr_t *) priv;
/* These bits are reset on reset. */
nvr->regs[RTC_REGB] &= ~(REGB_PIE | REGB_AIE | REGB_UIE | REGB_SQWE);
nvr->regs[RTC_REGC] &= ~(REGC_PF | REGC_AF | REGC_UF | REGC_IRQF);
}
static void *
nvr_at_init(const device_t *info)
{
@@ -1019,6 +1016,10 @@ nvr_at_init(const device_t *info)
timer_add(&local->update_timer, timer_update, nvr, 0);
timer_add(&local->rtc_timer, timer_intr, nvr, 0);
/* On power on, if the oscillator is disabled, it's reenabled. */
if ((nvr->regs[RTC_REGA] & 0x70) == 0x00)
nvr->regs[RTC_REGA] = (nvr->regs[RTC_REGA] & 0x8f) | 0x20;
nvr_at_reset(nvr);
timer_load_count(nvr);
timer_set_delay_u64(&local->rtc_timer, RTCCONST);
@@ -1068,7 +1069,7 @@ const device_t at_nvr_old_device = {
"PC/AT NVRAM (No century)",
DEVICE_ISA | DEVICE_AT,
0,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1077,7 +1078,7 @@ const device_t at_nvr_device = {
"PC/AT NVRAM",
DEVICE_ISA | DEVICE_AT,
1,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1086,7 +1087,7 @@ const device_t ps_nvr_device = {
"PS/1 or PS/2 NVRAM",
DEVICE_PS2,
2,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1095,7 +1096,7 @@ const device_t amstrad_nvr_device = {
"Amstrad NVRAM",
DEVICE_ISA | DEVICE_AT,
3,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1104,7 +1105,7 @@ const device_t ibmat_nvr_device = {
"IBM AT NVRAM",
DEVICE_ISA | DEVICE_AT,
4,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1113,7 +1114,7 @@ const device_t piix4_nvr_device = {
"Intel PIIX4 PC/AT NVRAM",
DEVICE_ISA | DEVICE_AT,
9,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1122,7 +1123,7 @@ const device_t ls486e_nvr_device = {
"Lucky Star LS-486E PC/AT NVRAM",
DEVICE_ISA | DEVICE_AT,
13,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1131,7 +1132,7 @@ const device_t ami_apollo_nvr_device = {
"AMI Apollo PC/AT NVRAM",
DEVICE_ISA | DEVICE_AT,
14,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};
@@ -1140,7 +1141,7 @@ const device_t via_nvr_device = {
"VIA PC/AT NVRAM",
DEVICE_ISA | DEVICE_AT,
15,
nvr_at_init, nvr_at_close, NULL,
nvr_at_init, nvr_at_close, nvr_at_reset,
{ NULL }, nvr_at_speed_changed,
NULL
};