Added a fix for newly-initialized NVR on the Lucky Star 486 and AMI Apollo.
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
typedef struct _nvr_ {
|
typedef struct _nvr_ {
|
||||||
char *fn; /* pathname of image file */
|
char *fn; /* pathname of image file */
|
||||||
uint16_t size; /* device configuration */
|
uint16_t size; /* device configuration */
|
||||||
int8_t irq;
|
int8_t irq, new;
|
||||||
|
|
||||||
uint8_t onesec_cnt;
|
uint8_t onesec_cnt;
|
||||||
pc_timer_t onesec_time;
|
pc_timer_t onesec_time;
|
||||||
|
|||||||
@@ -262,13 +262,15 @@ nvr_load(void)
|
|||||||
path = nvr_path(saved_nvr->fn);
|
path = nvr_path(saved_nvr->fn);
|
||||||
nvr_log("NVR: loading from '%s'\n", path);
|
nvr_log("NVR: loading from '%s'\n", path);
|
||||||
fp = plat_fopen(path, "rb");
|
fp = plat_fopen(path, "rb");
|
||||||
|
saved_nvr->new = (fp == NULL);
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
/* Read NVR contents from file. */
|
/* Read NVR contents from file. */
|
||||||
if (fread(saved_nvr->regs, 1, saved_nvr->size, fp) != saved_nvr->size)
|
if (fread(saved_nvr->regs, 1, saved_nvr->size, fp) != saved_nvr->size)
|
||||||
fatal("nvr_load(): Error reading data\n");
|
fatal("nvr_load(): Error reading data\n");
|
||||||
(void)fclose(fp);
|
(void)fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
saved_nvr->new = 1;
|
||||||
|
|
||||||
/* Get the local RTC running! */
|
/* Get the local RTC running! */
|
||||||
if (saved_nvr->start != NULL)
|
if (saved_nvr->start != NULL)
|
||||||
|
|||||||
15
src/nvr_at.c
15
src/nvr_at.c
@@ -610,6 +610,10 @@ nvr_reg_write(uint16_t reg, uint8_t val, void *priv)
|
|||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
|
|
||||||
default: /* non-RTC registers are just NVRAM */
|
default: /* non-RTC registers are just NVRAM */
|
||||||
|
if ((reg == 0x2c) && (local->flags & FLAG_LS_HACK))
|
||||||
|
nvr->new = 0;
|
||||||
|
if ((reg == 0x52) && (local->flags & FLAG_APOLLO_HACK))
|
||||||
|
nvr->new = 0;
|
||||||
if ((reg >= 0x38) && (reg <= 0x3f) && local->wp[0])
|
if ((reg >= 0x38) && (reg <= 0x3f) && local->wp[0])
|
||||||
break;
|
break;
|
||||||
if ((reg >= 0xb8) && (reg <= 0xbf) && local->wp[1])
|
if ((reg >= 0xb8) && (reg <= 0xbf) && local->wp[1])
|
||||||
@@ -701,7 +705,7 @@ nvr_read(uint16_t addr, void *priv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x2c:
|
case 0x2c:
|
||||||
if (local->flags & FLAG_LS_HACK)
|
if (!nvr->new && (local->flags & FLAG_LS_HACK))
|
||||||
ret = nvr->regs[local->addr[addr_id]] & 0x7f;
|
ret = nvr->regs[local->addr[addr_id]] & 0x7f;
|
||||||
else
|
else
|
||||||
ret = nvr->regs[local->addr[addr_id]];
|
ret = nvr->regs[local->addr[addr_id]];
|
||||||
@@ -709,7 +713,7 @@ nvr_read(uint16_t addr, void *priv)
|
|||||||
|
|
||||||
case 0x2e:
|
case 0x2e:
|
||||||
case 0x2f:
|
case 0x2f:
|
||||||
if (local->flags & FLAG_LS_HACK) {
|
if (!nvr->new && (local->flags & FLAG_LS_HACK)) {
|
||||||
for (i = 0x10; i <= 0x2d; i++) {
|
for (i = 0x10; i <= 0x2d; i++) {
|
||||||
if (i == 0x2c)
|
if (i == 0x2c)
|
||||||
checksum += (nvr->regs[i] & 0x7f);
|
checksum += (nvr->regs[i] & 0x7f);
|
||||||
@@ -726,7 +730,7 @@ nvr_read(uint16_t addr, void *priv)
|
|||||||
|
|
||||||
case 0x3e:
|
case 0x3e:
|
||||||
case 0x3f:
|
case 0x3f:
|
||||||
if (local->flags & FLAG_APOLLO_HACK) {
|
if (!nvr->new && (local->flags & FLAG_APOLLO_HACK)) {
|
||||||
/* The checksum at 3E-3F is for 37-3D and 40-7F. */
|
/* The checksum at 3E-3F is for 37-3D and 40-7F. */
|
||||||
for (i = 0x37; i <= 0x3d; i++)
|
for (i = 0x37; i <= 0x3d; i++)
|
||||||
checksum += nvr->regs[i];
|
checksum += nvr->regs[i];
|
||||||
@@ -745,7 +749,7 @@ nvr_read(uint16_t addr, void *priv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x52:
|
case 0x52:
|
||||||
if (local->flags & FLAG_APOLLO_HACK)
|
if (!nvr->new && (local->flags & FLAG_APOLLO_HACK))
|
||||||
ret = nvr->regs[local->addr[addr_id]] & 0xf3;
|
ret = nvr->regs[local->addr[addr_id]] & 0xf3;
|
||||||
else
|
else
|
||||||
ret = nvr->regs[local->addr[addr_id]];
|
ret = nvr->regs[local->addr[addr_id]];
|
||||||
@@ -935,10 +939,13 @@ nvr_at_init(const device_t *info)
|
|||||||
if (info->local == 9)
|
if (info->local == 9)
|
||||||
local->flags |= FLAG_PIIX4;
|
local->flags |= FLAG_PIIX4;
|
||||||
else {
|
else {
|
||||||
|
local->def = 0x00;
|
||||||
if ((info->local & 7) == 5)
|
if ((info->local & 7) == 5)
|
||||||
local->flags |= FLAG_LS_HACK;
|
local->flags |= FLAG_LS_HACK;
|
||||||
else if ((info->local & 7) == 6)
|
else if ((info->local & 7) == 6)
|
||||||
local->flags |= FLAG_APOLLO_HACK;
|
local->flags |= FLAG_APOLLO_HACK;
|
||||||
|
else
|
||||||
|
local->def = 0xff;
|
||||||
}
|
}
|
||||||
nvr->irq = 8;
|
nvr->irq = 8;
|
||||||
local->cent = RTC_CENTURY_AT;
|
local->cent = RTC_CENTURY_AT;
|
||||||
|
|||||||
Reference in New Issue
Block a user