1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +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 "../../TimedMachine.hpp"
#include "../../../InstructionSets/ARM/Executor.hpp" #include "../../../InstructionSets/ARM/Executor.hpp"
#include "../../../Outputs/Log.hpp"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
@ -22,6 +23,8 @@
namespace { namespace {
Log::Logger<Log::Source::Archimedes> logger;
enum class Zone { enum class Zone {
LogicallyMappedRAM, LogicallyMappedRAM,
PhysicallyMappedRAM, PhysicallyMappedRAM,
@ -75,20 +78,23 @@ struct Memory {
case Zone::DMAAndMEMC: case Zone::DMAAndMEMC:
// if(mode != InstructionSet::ARM::Mode::Supervisor) return false; // if(mode != InstructionSet::ARM::Mode::Supervisor) return false;
if((address & 0b1110'0000'0000'0000'0000) == 0b1110'0000'0000'0000'0000) { 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; break;
} }
[[fallthrough]];
case Zone::PhysicallyMappedRAM:
// if(mode != InstructionSet::ARM::Mode::Supervisor) return false;
physical_ram<IntT>(address) = source;
break;
default: 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; break;
} }
if(has_moved_rom_ && address < ram_.size()) {
*reinterpret_cast<IntT *>(&ram_[address]) = source;
}
return true; return true;
} }
@ -100,23 +106,29 @@ struct Memory {
switch (read_zones_[(address >> 21) & 31]) { switch (read_zones_[(address >> 21) & 31]) {
case Zone::PhysicallyMappedRAM: case Zone::PhysicallyMappedRAM:
// if(mode != InstructionSet::ARM::Mode::Supervisor) return false; // 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; return true;
default: break; case Zone::LogicallyMappedRAM:
} if(!has_moved_rom_) {
if(address >= 0x3800000) { source = high_rom<IntT>(address);
has_moved_rom_ = true; break;
source = *reinterpret_cast<const IntT *>(&rom_[address - 0x3800000]); }
} else if(!has_moved_rom_) { logger.error().append("TODO: Logical RAM read from %08x", address);
// TODO: this is true only very transiently. break;
source = *reinterpret_cast<const IntT *>(&rom_[address]);
} else if(address < ram_.size()) { case Zone::HighROM:
source = *reinterpret_cast<const IntT *>(&ram_[address]); has_moved_rom_ = true;
} else { source = high_rom<IntT>(address);
source = 0; break;
default:
logger.error().append("TODO: read from %08x", address);
break;
} }
source = 0;
return true; return true;
} }
@ -125,6 +137,16 @@ struct Memory {
std::array<uint8_t, 4*1024*1024> ram_{}; std::array<uint8_t, 4*1024*1024> ram_{};
std::array<uint8_t, 2*1024*1024> rom_; 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> read_zones_ = zones(true);
static constexpr std::array<Zone, 0x20> write_zones_ = zones(false); 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. // TODO: turn the below into a trace-driven test case.
//- (void)testROM319 { - (void)testROM319 {
// constexpr ROM::Name rom_name = ROM::Name::AcornRISCOS319; constexpr ROM::Name rom_name = ROM::Name::AcornRISCOS319;
// ROM::Request request(rom_name); ROM::Request request(rom_name);
// const auto roms = CSROMFetcher()(request); const auto roms = CSROMFetcher()(request);
//
// auto executor = std::make_unique<Executor<Model::ARMv2, Memory>>(); auto executor = std::make_unique<Executor<Model::ARMv2, Memory>>();
// executor->bus.rom = roms.find(rom_name)->second; executor->bus.rom = roms.find(rom_name)->second;
//
// for(int c = 0; c < 1000; c++) { for(int c = 0; c < 1000; c++) {
// uint32_t instruction; uint32_t instruction;
// executor->bus.read(executor->pc(), instruction, executor->registers().mode(), false); executor->bus.read(executor->pc(), instruction, executor->registers().mode(), false);
//
// printf("%08x: %08x [", executor->pc(), instruction); if(instruction == 0xe33ff343) {
// for(int c = 0; c < 15; c++) { printf("");
// printf("r%d:%08x ", c, executor->registers()[c]); }
// }
// printf("psr:%08x]\n", executor->registers().status()); printf("%08x: %08x [", executor->pc(), instruction);
// execute<Model::ARMv2>(instruction, *executor); 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 @end

View File

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