1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Move trans tests inside switch.

This commit is contained in:
Thomas Harte 2024-04-17 21:29:42 -04:00
parent 87d1a476a4
commit b63178132d

View File

@ -71,13 +71,10 @@ struct MemoryController {
template <typename IntT> template <typename IntT>
bool write(uint32_t address, IntT source, InstructionSet::ARM::Mode, bool trans) { bool write(uint32_t address, IntT source, InstructionSet::ARM::Mode, bool trans) {
// User mode may only _write_ to logically-mapped RAM (subject to further testing below).
if(trans && address >= 0x200'0000) {
return false;
}
switch(write_zones_[(address >> 21) & 31]) { switch(write_zones_[(address >> 21) & 31]) {
case Zone::DMAAndMEMC: { case Zone::DMAAndMEMC: {
if(trans) return false;
const auto buffer_address = [](uint32_t source) -> uint32_t { const auto buffer_address = [](uint32_t source) -> uint32_t {
return (source & 0x1'fffc) << 2; return (source & 0x1'fffc) << 2;
}; };
@ -126,19 +123,23 @@ struct MemoryController {
} break; } break;
case Zone::IOControllers: case Zone::IOControllers:
if(trans) return false;
ioc_.template write<IntT>(address, source); ioc_.template write<IntT>(address, source);
break; break;
case Zone::VideoController: case Zone::VideoController:
if(trans) return false;
// TODO: handle byte writes correctly. // TODO: handle byte writes correctly.
ioc_.video().write(source); ioc_.video().write(source);
break; break;
case Zone::PhysicallyMappedRAM: case Zone::PhysicallyMappedRAM:
if(trans) return false;
physical_ram<IntT>(address) = source; physical_ram<IntT>(address) = source;
break; break;
case Zone::AddressTranslator: case Zone::AddressTranslator:
if(trans) return false;
// printf("Translator write at %08x; replaces %08x\n", address, pages_[address & 0x7f]); // printf("Translator write at %08x; replaces %08x\n", address, pages_[address & 0x7f]);
pages_[address & 0x7f] = address; pages_[address & 0x7f] = address;
map_dirty_ = true; map_dirty_ = true;
@ -154,13 +155,9 @@ struct MemoryController {
template <typename IntT> template <typename IntT>
bool read(uint32_t address, IntT &source, InstructionSet::ARM::Mode, bool trans) { bool read(uint32_t address, IntT &source, InstructionSet::ARM::Mode, bool trans) {
// User mode may only read logically-maped RAM and ROM.
if(trans && address >= 0x200'0000 && address < 0x380'0000) {
return false;
}
switch (read_zones_[(address >> 21) & 31]) { switch (read_zones_[(address >> 21) & 31]) {
case Zone::PhysicallyMappedRAM: case Zone::PhysicallyMappedRAM:
if(trans) return false;
source = physical_ram<IntT>(address); source = physical_ram<IntT>(address);
break; break;
@ -184,6 +181,7 @@ struct MemoryController {
break; break;
case Zone::IOControllers: case Zone::IOControllers:
if(trans) return false;
ioc_.template read<IntT>(address, source); ioc_.template read<IntT>(address, source);
break; break;