From c82841f0fd784ba7f5560eda4285fcbcb5a8c695 Mon Sep 17 00:00:00 2001 From: SimoneN64 Date: Wed, 8 Nov 2023 23:59:36 +0100 Subject: [PATCH] Catch these cases, maybe we are missing something --- src/backend/core/Mem.cpp | 2 +- src/backend/core/mmio/PI.cpp | 75 +++++++++++++++--------------------- src/backend/core/mmio/PI.hpp | 2 +- src/utils/log.hpp | 2 +- 4 files changed, 33 insertions(+), 48 deletions(-) diff --git a/src/backend/core/Mem.cpp b/src/backend/core/Mem.cpp index c9bd48dc..05e47776 100644 --- a/src/backend/core/Mem.cpp +++ b/src/backend/core/Mem.cpp @@ -416,7 +416,7 @@ void Mem::Write16(Registers& regs, u32 paddr, u32 val) { } break; case REGION_CART: Util::debug("BusWrite8 @ {:08X} = {:04X}", paddr, val); - mmio.pi.BusWrite16(*this, paddr, val); + mmio.pi.BusWrite16(paddr, val); break; case MMIO_REGION: Util::panic("MMIO Write16!"); diff --git a/src/backend/core/mmio/PI.cpp b/src/backend/core/mmio/PI.cpp index e879dbfd..6116c605 100644 --- a/src/backend/core/mmio/PI.cpp +++ b/src/backend/core/mmio/PI.cpp @@ -58,13 +58,11 @@ auto PI::BusRead8(Mem& mem, u32 addr) -> u8 { switch (addr) { case REGION_PI_UNKNOWN: - //Util::warn("Reading byte from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN - This is the N64DD, returning FF because it is not emulated", addr); - return 0xFF; + Util::panic("Reading byte from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN - This is the N64DD, returning FF because it is not emulated", addr); case REGION_PI_64DD_REG: - //Util::warn("Reading byte from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG - This is the N64DD, returning FF because it is not emulated", addr); - return 0xFF; + Util::panic("Reading byte from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG - This is the N64DD, returning FF because it is not emulated", addr); case REGION_PI_64DD_ROM: - //Util::warn("Reading byte from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM - This is the N64DD, returning FF because it is not emulated", addr); + Util::warn("Reading byte from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM - This is the N64DD, returning FF because it is not emulated", addr); return 0xFF; case REGION_PI_SRAM: return mem.BackupRead8(addr - SREGION_PI_SRAM); @@ -75,7 +73,7 @@ auto PI::BusRead8(Mem& mem, u32 addr) -> u8 { } u32 index = BYTE_ADDRESS(addr) - SREGION_PI_ROM; if (index > mem.rom.size) { - //Util::warn("Address 0x{:08X} accessed an index {}/0x{:X} outside the bounds of the ROM! ({}/0x{:016X})", addr, index, index, mem.rom.size, mem.rom.size); + Util::warn("Address 0x{:08X} accessed an index {}/0x{:X} outside the bounds of the ROM! ({}/0x{:016X})", addr, index, index, mem.rom.size, mem.rom.size); return 0xFF; } return mem.rom.cart[index]; @@ -100,18 +98,16 @@ void PI::BusWrite8(Mem& mem, u32 addr, u32 val) { switch (addr) { case REGION_PI_UNKNOWN: - //Util::warn("Writing byte 0x{:02X} to address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", val, addr); - return; + Util::panic("Writing byte 0x{:02X} to address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", val, addr); case REGION_PI_64DD_REG: if (addr == 0x05000020) { fprintf(stderr, "%c", val); } else { - //Util::warn("Writing byte 0x{:02X} to address 0x{:08X} in region: REGION_PI_64DD_ROM, this is the 64DD, ignoring!", val, addr); + Util::panic("Writing byte 0x{:02X} to address 0x{:08X} in region: REGION_PI_64DD_ROM, this is the 64DD, ignoring!", val, addr); } return; case REGION_PI_64DD_ROM: - //Util::warn("Writing byte 0x{:02X} to address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", val, addr); - return; + Util::panic("Writing byte 0x{:02X} to address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", val, addr); case REGION_PI_SRAM: mem.BackupWrite8(addr - SREGION_PI_SRAM, val); return; @@ -133,14 +129,11 @@ auto PI::BusRead16(Mem& mem, u32 addr) -> u16 { switch (addr) { case REGION_PI_UNKNOWN: - //Util::warn("Reading half from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN - This is the N64DD, returning FF because it is not emulated", addr); - return 0xFF; + Util::panic("Reading half from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN - This is the N64DD, returning FF because it is not emulated", addr); case REGION_PI_64DD_REG: - //Util::warn("Reading half from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG - This is the N64DD, returning FF because it is not emulated", addr); - return 0xFF; + Util::panic("Reading half from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG - This is the N64DD, returning FF because it is not emulated", addr); case REGION_PI_64DD_ROM: - //Util::warn("Reading half from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM - This is the N64DD, returning FF because it is not emulated", addr); - return 0xFF; + Util::panic("Reading half from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM - This is the N64DD, returning FF because it is not emulated", addr); case REGION_PI_SRAM: Util::panic("Reading half from address 0x{:08X} in unsupported region: REGION_PI_SRAM", addr); case REGION_PI_ROM: { @@ -156,27 +149,23 @@ auto PI::BusRead16(Mem& mem, u32 addr) -> u16 { } } -void PI::BusWrite16(Mem& mem, u32 addr, u16 val) { +void PI::BusWrite16(u32 addr, u16 val) { if (!WriteLatch(val << 16)) [[unlikely]] { return; } switch (addr) { case REGION_PI_UNKNOWN: - //Util::warn("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", val, addr); - return; + Util::panic("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", val, addr); case REGION_PI_64DD_REG: - //Util::warn("Writing half 0x{:04X} to address 0x{:08X} in region: REGION_PI_64DD_ROM, this is the 64DD, ignoring!", val, addr); - return; + Util::panic("Writing half 0x{:04X} to address 0x{:08X} in region: REGION_PI_64DD_ROM, this is the 64DD, ignoring!", val, addr); case REGION_PI_64DD_ROM: - //Util::warn("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", val, addr); - return; + Util::panic("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", val, addr); case REGION_PI_SRAM: - //Util::warn("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_SRAM", val, addr); - return; + Util::panic("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_SRAM", val, addr); case REGION_PI_ROM: - //Util::warn("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); - return; + Util::warn("Writing half 0x{:04X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); + break; default: Util::panic("Should never end up here! Access to address {:08X} which did not match any PI bus regions!", addr); } @@ -189,13 +178,13 @@ auto PI::BusRead32(Mem& mem, u32 addr) -> u32 { switch (addr) { case REGION_PI_UNKNOWN: - //Util::warn("Reading word from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN - This is the N64DD, returning FF because it is not emulated", addr); + Util::warn("Reading word from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN - This is the N64DD, returning FF because it is not emulated", addr); return 0xFF; case REGION_PI_64DD_REG: - //Util::warn("Reading word from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG - This is the N64DD, returning FF because it is not emulated", addr); + Util::warn("Reading word from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG - This is the N64DD, returning FF because it is not emulated", addr); return 0xFF; case REGION_PI_64DD_ROM: - //Util::warn("Reading word from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM - This is the N64DD, returning FF because it is not emulated", addr); + Util::warn("Reading word from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM - This is the N64DD, returning FF because it is not emulated", addr); return 0xFF; case REGION_PI_SRAM: return mem.BackupRead32(); @@ -208,7 +197,7 @@ auto PI::BusRead32(Mem& mem, u32 addr) -> u32 { case CART_ISVIEWER_FLUSH: Util::panic("Read from ISViewer flush!"); } - //Util::warn("Address 0x{:08X} accessed an index {}/0x{:X} outside the bounds of the ROM!", addr, index, index); + Util::warn("Address 0x{:08X} accessed an index {}/0x{:X} outside the bounds of the ROM!", addr, index, index); return 0; } else { return Util::ReadAccess(mem.rom.cart, index); @@ -225,19 +214,19 @@ void PI::BusWrite32(Mem& mem, u32 addr, u32 val) { if (!WriteLatch(val)) [[unlikely]] { return; } - //Util::warn("Writing word 0x{:08X} to address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", val, addr); + Util::warn("Writing word 0x{:08X} to address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", val, addr); return; case REGION_PI_64DD_REG: if (!WriteLatch(val)) [[unlikely]] { return; } - //Util::warn("Writing word 0x{:08X} to address 0x{:08X} in region: REGION_PI_64DD_ROM, this is the 64DD, ignoring!", val, addr); + Util::warn("Writing word 0x{:08X} to address 0x{:08X} in region: REGION_PI_64DD_ROM, this is the 64DD, ignoring!", val, addr); return; case REGION_PI_64DD_ROM: if (!WriteLatch(val)) [[unlikely]] { return; } - //Util::warn("Writing word 0x{:08X} to address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", val, addr); + Util::warn("Writing word 0x{:08X} to address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", val, addr); return; case REGION_PI_SRAM: if (!WriteLatch(val)) [[unlikely]] { @@ -266,7 +255,7 @@ void PI::BusWrite32(Mem& mem, u32 addr, u32 val) { if (!WriteLatch(val)) [[unlikely]] { return; } - //Util::warn("Writing word 0x{:08X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); + Util::warn("Writing word 0x{:08X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); } return; default: @@ -281,17 +270,13 @@ auto PI::BusRead64(Mem& mem, u32 addr) -> u64 { switch (addr) { case REGION_PI_UNKNOWN: - //Util::warn("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", addr); - return 0xFFFFFFFFFFFFFFFF; + Util::panic("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_UNKNOWN", addr); case REGION_PI_64DD_REG: - //Util::warn("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG", addr); - return 0xFFFFFFFFFFFFFFFF; + Util::panic("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_64DD_REG", addr); case REGION_PI_64DD_ROM: - //Util::warn("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", addr); - return 0xFFFFFFFFFFFFFFFF; + Util::panic("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_64DD_ROM", addr); case REGION_PI_SRAM: - //Util::warn("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_SRAM", addr); - return 0xFFFFFFFFFFFFFFFF; + Util::panic("Reading dword from address 0x{:08X} in unsupported region: REGION_PI_SRAM", addr); case REGION_PI_ROM: { u32 index = addr - SREGION_PI_ROM; if (index > mem.rom.size - 7) { // -7 because we're reading an entire dword @@ -319,7 +304,7 @@ void PI::BusWrite64(Mem& mem, u32 addr, u64 val) { case REGION_PI_SRAM: Util::panic("Writing dword 0x{:016X} to address 0x{:08X} in unsupported region: REGION_PI_SRAM", val, addr); case REGION_PI_ROM: - //Util::warn("Writing dword 0x{:016X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); + Util::warn("Writing dword 0x{:016X} to address 0x{:08X} in unsupported region: REGION_PI_ROM", val, addr); break; default: Util::panic("Should never end up here! Access to address %08X which did not match any PI bus regions!", addr); diff --git a/src/backend/core/mmio/PI.hpp b/src/backend/core/mmio/PI.hpp index d872f4f1..93b77c46 100644 --- a/src/backend/core/mmio/PI.hpp +++ b/src/backend/core/mmio/PI.hpp @@ -17,7 +17,7 @@ struct PI { template void BusWrite8(Mem&, u32, u32); auto BusRead16(Mem&, u32) -> u16; - void BusWrite16(Mem&, u32, u16); + void BusWrite16(u32, u16); auto BusRead32(Mem&, u32) -> u32; void BusWrite32(Mem&, u32, u32); auto BusRead64(Mem&, u32) -> u64; diff --git a/src/utils/log.hpp b/src/utils/log.hpp index 0f6ad610..fff4d027 100644 --- a/src/utils/log.hpp +++ b/src/utils/log.hpp @@ -11,7 +11,7 @@ enum LogLevel : u8 { #ifndef NDEBUG static constexpr auto globalLogLevel = Debug; #else -static constexpr auto globalLogLevel = Info; +static constexpr auto globalLogLevel = Error; #endif template