macio: Range check scc compatible register index.

Also, non-compatible registers don't begin until 0x60 for SCC compatible addressing.
This commit is contained in:
joevt
2024-04-26 01:50:57 -07:00
committed by dingusdev
parent ab59a34604
commit 1bf4073fa7
3 changed files with 40 additions and 8 deletions
+15 -3
View File
@@ -132,7 +132,15 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
case 1:
return this->viacuda->read(offset >> 9);
case 4: // SCC registers
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
if ((offset & 0xF) < 0x0C)
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
else
LOG_F(ERROR, "AMIC SCC read @%x.%c", offset, SIZE_ARG(size));
return 0;
case 0x8:
case 0x9:
LOG_F(WARNING, "AMIC Ethernet ID Rom read @%x.%c", offset, SIZE_ARG(size));
return 0;
case 0xA: // MACE registers
return this->mace->read((offset >> 4) & 0x1F);
case 0x10: // SCSI registers
@@ -227,8 +235,12 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
case 1:
this->viacuda->write(offset >> 9, value);
return;
case 4:
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
case 4: // SCC registers
if ((offset & 0xF) < 0x0C)
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
else
LOG_F(ERROR, "AMIC SCC write @%x.%c = %0*x",
offset, SIZE_ARG(size), size * 2, value);
return;
case 0xA: // MACE registers
this->mace->write((offset >> 4) & 0x1F, value);
+11 -2
View File
@@ -186,9 +186,13 @@ uint32_t GrandCentral::read(uint32_t rgn_start, uint32_t offset, int size)
case 1: // MACE
return this->mace->read((offset >> 4) & 0x1F);
case 2: // ESCC compatible addressing
if ((offset & 0xFF) < 16) {
if ((offset & 0xFF) < 0x0C) {
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
}
if ((offset & 0xFF) < 0x60) {
LOG_F(ERROR, "%s: ESCC compatible read @%x.%c", this->name.c_str(), offset, SIZE_ARG(size));
return 0;
}
// fallthrough
case 3: // ESCC MacRISC addressing
return this->escc->read((offset >> 4) & 0xF);
@@ -293,10 +297,15 @@ void GrandCentral::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
this->mace->write((offset >> 4) & 0x1F, value);
break;
case 2: // ESCC compatible addressing
if ((offset & 0xFF) < 16) {
if ((offset & 0xFF) < 0x0C) {
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
break;
}
if ((offset & 0xFF) < 0x60) {
LOG_F(ERROR, "%s: SCC write @%x.%c = %0*x", this->name.c_str(),
offset, SIZE_ARG(size), size * 2, value);
break;
}
// fallthrough
case 3: // ESCC MacRISC addressing
this->escc->write((offset >> 4) & 0xF, value);
+14 -3
View File
@@ -184,8 +184,14 @@ uint32_t HeathrowIC::read(uint32_t rgn_start, uint32_t offset, int size) {
res = BYTESWAP_SIZED(this->bmac->read(offset & 0xFFFU), size);
break;
case 0x12: // ESCC compatible addressing
if ((offset & 0xFF) < 16) {
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
if ((offset & 0xFF) < 0x0C) {
res = this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
break;
}
if ((offset & 0xFF) < 0x60) {
res = 0;
LOG_F(ERROR, "%s: ESCC compatible read @%x.%c", this->name.c_str(), offset, SIZE_ARG(size));
break;
}
// fallthrough
case 0x13: // ESCC MacRISC addressing
@@ -235,10 +241,15 @@ void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
this->bmac->write(offset & 0xFFFU, BYTESWAP_SIZED(value, size));
break;
case 0x12: // ESCC compatible addressing
if ((offset & 0xFF) < 16) {
if ((offset & 0xFF) < 0x0C) {
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
break;
}
if ((offset & 0xFF) < 0x60) {
LOG_F(ERROR, "%s: SCC write @%x.%c = %0*x", this->name.c_str(),
offset, SIZE_ARG(size), size * 2, value);
break;
}
// fallthrough
case 0x13: // ESCC MacRISC addressing
this->escc->write((offset >> 4) & 0xF, value);