Implemented more previously unimplemented AT NVR behavior.

This commit is contained in:
OBattler
2022-08-04 23:52:25 +02:00
parent 449c103ec8
commit 730af4dd53

View File

@@ -467,10 +467,10 @@ timer_update(void *priv)
nvr->regs[RTC_REGC] |= REGC_AF;
if (nvr->regs[RTC_REGB] & REGB_AIE) {
/* Generate an interrupt. */
if ((nvr->irq != -1) && (!(nvr->regs[RTC_REGC] & REGC_IRQF)))
picint(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
if ((nvr->irq != -1) && (!(nvr->regs[RTC_REGC] & REGC_IRQF))) {
picintlevel(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
}
}
}
@@ -481,10 +481,10 @@ timer_update(void *priv)
nvr->regs[RTC_REGC] |= REGC_UF;
if (nvr->regs[RTC_REGB] & REGB_UIE) {
/* Generate an interrupt. */
if ((nvr->irq != -1) && (!(nvr->regs[RTC_REGC] & REGC_IRQF)))
picint(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
if ((nvr->irq != -1) && (!(nvr->regs[RTC_REGC] & REGC_IRQF))) {
picintlevel(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
}
}
}
}
@@ -533,10 +533,10 @@ timer_intr(void *priv)
nvr->regs[RTC_REGC] |= REGC_PF;
if (nvr->regs[RTC_REGB] & REGB_PIE) {
/* Generate an interrupt. */
if ((nvr->irq != -1) && (!(nvr->regs[RTC_REGC] & REGC_IRQF)))
picint(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
if ((nvr->irq != -1) && (!(nvr->regs[RTC_REGC] & REGC_IRQF))) {
picintlevel(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
}
}
}
}
@@ -592,6 +592,7 @@ nvr_reg_write(uint16_t reg, uint8_t val, void *priv)
local_t *local = (local_t *)nvr->data;
struct tm tm;
uint8_t old;
uint8_t irq = 0, old_irq = 0;
old = nvr->regs[reg];
switch(reg) {
@@ -601,12 +602,21 @@ nvr_reg_write(uint16_t reg, uint8_t val, void *priv)
break;
case RTC_REGB:
old_irq = (nvr->regs[RTC_REGB] & nvr->regs[RTC_REGC]) & 0x70;
nvr->regs[RTC_REGB] = val;
if (((old^val) & REGB_SET) && (val & REGB_SET)) {
/* According to the datasheet... */
nvr->regs[RTC_REGA] &= ~REGA_UIP;
nvr->regs[RTC_REGB] &= ~REGB_UIE;
}
irq = (nvr->regs[RTC_REGB] & nvr->regs[RTC_REGC]) & 0x70;
if (old_irq && !irq) {
picintc(1 << nvr->irq);
nvr->regs[RTC_REGC] &= ~REGC_IRQF;
} else if (!old_irq && irq) {
picintlevel(1 << nvr->irq);
nvr->regs[RTC_REGC] |= REGC_IRQF;
}
break;
case RTC_REGC: /* R/O */
@@ -694,8 +704,8 @@ nvr_read(uint16_t addr, void *priv)
break;
case RTC_REGC:
picintc(1 << nvr->irq);
ret = nvr->regs[RTC_REGC];
picintc(1 << nvr->irq);
nvr->regs[RTC_REGC] = 0x00;
break;