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

Get a bit more rigorous about reporting.

This commit is contained in:
Thomas Harte 2024-03-06 09:54:39 -05:00
parent fe467be124
commit 0d666f9935
3 changed files with 68 additions and 40 deletions

View File

@ -15,6 +15,7 @@
#include "../../TimedMachine.hpp"
#include "../../../InstructionSets/ARM/Executor.hpp"
#include "../../../Outputs/Log.hpp"
#include <algorithm>
#include <array>
@ -22,6 +23,8 @@
namespace {
Log::Logger<Log::Source::Archimedes> logger;
enum class Zone {
LogicallyMappedRAM,
PhysicallyMappedRAM,
@ -75,20 +78,23 @@ struct Memory {
case Zone::DMAAndMEMC:
// if(mode != InstructionSet::ARM::Mode::Supervisor) return false;
if((address & 0b1110'0000'0000'0000'0000) == 0b1110'0000'0000'0000'0000) {
printf("MEMC Control: %04x\n", source);
logger.error().append("TODO: MEMC Control: %08x", source);
break;
} else {
logger.error().append("TODO: DMA/MEMC %08x to %08x", source, address);
break;
}
[[fallthrough]];
case Zone::PhysicallyMappedRAM:
// if(mode != InstructionSet::ARM::Mode::Supervisor) return false;
physical_ram<IntT>(address) = source;
break;
default:
printf("Unhandled W of %08x to %08x [%lu]\n", source, address, sizeof(IntT));
printf("TODO: write of %08x to %08x [%lu]\n", source, address, sizeof(IntT));
break;
}
if(has_moved_rom_ && address < ram_.size()) {
*reinterpret_cast<IntT *>(&ram_[address]) = source;
}
return true;
}
@ -100,23 +106,29 @@ struct Memory {
switch (read_zones_[(address >> 21) & 31]) {
case Zone::PhysicallyMappedRAM:
// if(mode != InstructionSet::ARM::Mode::Supervisor) return false;
source = *reinterpret_cast<const IntT *>(&ram_[address & (ram_.size() - 1)]);
source = physical_ram<IntT>(address);
return true;
default: break;
}
if(address >= 0x3800000) {
has_moved_rom_ = true;
source = *reinterpret_cast<const IntT *>(&rom_[address - 0x3800000]);
} else if(!has_moved_rom_) {
// TODO: this is true only very transiently.
source = *reinterpret_cast<const IntT *>(&rom_[address]);
} else if(address < ram_.size()) {
source = *reinterpret_cast<const IntT *>(&ram_[address]);
} else {
source = 0;
case Zone::LogicallyMappedRAM:
if(!has_moved_rom_) {
source = high_rom<IntT>(address);
break;
}
logger.error().append("TODO: Logical RAM read from %08x", address);
break;
case Zone::HighROM:
has_moved_rom_ = true;
source = high_rom<IntT>(address);
break;
default:
logger.error().append("TODO: read from %08x", address);
break;
}
source = 0;
return true;
}
@ -125,6 +137,16 @@ struct Memory {
std::array<uint8_t, 4*1024*1024> ram_{};
std::array<uint8_t, 2*1024*1024> rom_;
template <typename IntT>
IntT &physical_ram(uint32_t address) {
return *reinterpret_cast<IntT *>(&ram_[address & (ram_.size() - 1)]);
}
template <typename IntT>
IntT &high_rom(uint32_t address) {
return *reinterpret_cast<IntT *>(&rom_[address & (rom_.size() - 1)]);
}
static constexpr std::array<Zone, 0x20> read_zones_ = zones(true);
static constexpr std::array<Zone, 0x20> write_zones_ = zones(false);
};

View File

@ -211,25 +211,29 @@ struct Memory {
}
// TODO: turn the below into a trace-driven test case.
//- (void)testROM319 {
// constexpr ROM::Name rom_name = ROM::Name::AcornRISCOS319;
// ROM::Request request(rom_name);
// const auto roms = CSROMFetcher()(request);
//
// auto executor = std::make_unique<Executor<Model::ARMv2, Memory>>();
// executor->bus.rom = roms.find(rom_name)->second;
//
// for(int c = 0; c < 1000; c++) {
// uint32_t instruction;
// executor->bus.read(executor->pc(), instruction, executor->registers().mode(), false);
//
// printf("%08x: %08x [", executor->pc(), instruction);
// for(int c = 0; c < 15; c++) {
// printf("r%d:%08x ", c, executor->registers()[c]);
// }
// printf("psr:%08x]\n", executor->registers().status());
// execute<Model::ARMv2>(instruction, *executor);
// }
//}
- (void)testROM319 {
constexpr ROM::Name rom_name = ROM::Name::AcornRISCOS319;
ROM::Request request(rom_name);
const auto roms = CSROMFetcher()(request);
auto executor = std::make_unique<Executor<Model::ARMv2, Memory>>();
executor->bus.rom = roms.find(rom_name)->second;
for(int c = 0; c < 1000; c++) {
uint32_t instruction;
executor->bus.read(executor->pc(), instruction, executor->registers().mode(), false);
if(instruction == 0xe33ff343) {
printf("");
}
printf("%08x: %08x [", executor->pc(), instruction);
for(int c = 0; c < 15; c++) {
printf("r%d:%08x ", c, executor->registers()[c]);
}
printf("psr:%08x]\n", executor->registers().status());
execute<Model::ARMv2>(instruction, *executor);
}
}
@end

View File

@ -24,6 +24,7 @@ enum class Source {
AmigaChipset,
AmigaBlitter,
AppleIISCSICard,
Archimedes,
AtariST,
AtariSTDMAController,
CommodoreStaticAnalyser,
@ -87,6 +88,7 @@ constexpr const char *prefix(Source source) {
case Source::AmigaCopper: return "Copper";
case Source::AmigaDisk: return "Disk";
case Source::AppleIISCSICard: return "SCSI card";
case Source::Archimedes: return "Archimedes";
case Source::AtariST: return "AtariST";
case Source::AtariSTDMAController: return "DMA";
case Source::CommodoreStaticAnalyser: return "Commodore Static Analyser";