Roms list properly handle sorting + use ircolib's log so i can stop worrying about re-definition of macros and shit
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <Core.hpp>
|
||||
#include <log.hpp>
|
||||
#include <ircolib/log.hpp>
|
||||
|
||||
namespace n64 {
|
||||
Cop0::Cop0() { Reset(); }
|
||||
@@ -103,7 +103,7 @@ u32 Cop0::GetReg32(const u8 addr) {
|
||||
case 31:
|
||||
return openbus;
|
||||
default:
|
||||
panic("Unsupported word read from COP0 register {}", addr);
|
||||
ircolib::panic("Unsupported word read from COP0 register {}", addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ u64 Cop0::GetReg64(const u8 addr) const {
|
||||
case 31:
|
||||
return openbus;
|
||||
default:
|
||||
panic("Unsupported dword read from COP0 register {}", addr);
|
||||
ircolib::panic("Unsupported dword read from COP0 register {}", addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ void Cop0::SetReg32(const u8 addr, const u32 value) {
|
||||
case 31:
|
||||
break;
|
||||
default:
|
||||
panic("Unsupported word write from COP0 register {}", addr);
|
||||
ircolib::panic("Unsupported word write from COP0 register {}", addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ void Cop0::SetReg64(const u8 addr, const u64 value) {
|
||||
ErrorEPC = (s64)value;
|
||||
break;
|
||||
default:
|
||||
panic("Unsupported dword write to COP0 register {}", addr);
|
||||
ircolib::panic("Unsupported dword write to COP0 register {}", addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ void Cop0::FireException(const ExceptionCode code, const int cop, s64 pc) {
|
||||
}
|
||||
|
||||
if (status.bev) {
|
||||
panic("BEV bit set!");
|
||||
ircolib::panic("BEV bit set!");
|
||||
}
|
||||
|
||||
regs.SetPC32(s32(0x80000000 + vectorOffset));
|
||||
@@ -408,7 +408,7 @@ void Cop0::HandleTLBException(const u64 vaddr) {
|
||||
Cop0::ExceptionCode Cop0::GetTLBExceptionCode(const TLBError error, const TLBAccessType accessType) {
|
||||
switch (error) {
|
||||
case NONE:
|
||||
panic("Getting TLB exception with error NONE");
|
||||
ircolib::panic("Getting TLB exception with error NONE");
|
||||
case INVALID:
|
||||
case MISS:
|
||||
return accessType == LOAD ? ExceptionCode::TLBLoad : ExceptionCode::TLBStore;
|
||||
@@ -417,7 +417,7 @@ Cop0::ExceptionCode Cop0::GetTLBExceptionCode(const TLBError error, const TLBAcc
|
||||
case DISALLOWED_ADDRESS:
|
||||
return accessType == LOAD ? ExceptionCode::AddressErrorLoad : ExceptionCode::AddressErrorStore;
|
||||
default:
|
||||
panic("Getting TLB exception for unknown error code! ({})", static_cast<u8>(error));
|
||||
ircolib::panic("Getting TLB exception for unknown error code! ({})", static_cast<u8>(error));
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -459,14 +459,14 @@ void Cop0::decode(const Instruction instr) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
panic("Unimplemented COP0 instruction {}", instr.cop_rs());
|
||||
ircolib::panic("Unimplemented COP0 instruction {}", instr.cop_rs());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
bool Cop0::MapVirtualAddress<u32, true>(const TLBAccessType accessType, const u64 vaddr, u32 &paddr) {
|
||||
if (ircolib::IsInsideRange(vaddr, START_VREGION_KUSEG, END_VREGION_KUSEG))
|
||||
if (ircolib::is_inside_range(vaddr, START_VREGION_KUSEG, END_VREGION_KUSEG))
|
||||
return ProbeTLB(accessType, s64(s32(vaddr)), paddr);
|
||||
|
||||
tlbError = DISALLOWED_ADDRESS;
|
||||
@@ -476,25 +476,25 @@ bool Cop0::MapVirtualAddress<u32, true>(const TLBAccessType accessType, const u6
|
||||
template <>
|
||||
bool Cop0::MapVirtualAddress<u32, false>(const TLBAccessType accessType, const u64 vaddr, u32 &paddr) {
|
||||
u8 segment = static_cast<u32>(vaddr) >> 29 & 7;
|
||||
if (ircolib::IsInsideRange(segment, 0, 3) || segment == 7)
|
||||
if (ircolib::is_inside_range(segment, 0, 3) || segment == 7)
|
||||
return ProbeTLB(accessType, static_cast<s32>(vaddr), paddr);
|
||||
|
||||
if (ircolib::IsInsideRange(segment, 4, 5)) {
|
||||
if (ircolib::is_inside_range(segment, 4, 5)) {
|
||||
paddr = vaddr & 0x1FFFFFFF;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (segment == 6)
|
||||
panic("Unimplemented virtual mapping in KSSEG! ({:08X})", vaddr);
|
||||
ircolib::panic("Unimplemented virtual mapping in KSSEG! ({:08X})", vaddr);
|
||||
|
||||
panic("Should never end up in base case in MapVirtualAddress! ({:08X})", vaddr);
|
||||
ircolib::panic("Should never end up in base case in MapVirtualAddress! ({:08X})", vaddr);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool Cop0::MapVirtualAddress<u64, true>(const TLBAccessType accessType, const u64 vaddr, u32 &paddr) {
|
||||
if (ircolib::IsInsideRange(vaddr, 0x0000000000000000, 0x000000FFFFFFFFFF))
|
||||
if (ircolib::is_inside_range(vaddr, 0x0000000000000000, 0x000000FFFFFFFFFF))
|
||||
return ProbeTLB(accessType, vaddr, paddr);
|
||||
|
||||
tlbError = DISALLOWED_ADDRESS;
|
||||
@@ -503,19 +503,19 @@ bool Cop0::MapVirtualAddress<u64, true>(const TLBAccessType accessType, const u6
|
||||
|
||||
template <>
|
||||
bool Cop0::MapVirtualAddress<u64, false>(const TLBAccessType accessType, const u64 vaddr, u32 &paddr) {
|
||||
if (ircolib::IsInsideRange(vaddr, 0x0000000000000000, 0x000000FFFFFFFFFF) || // VREGION_XKUSEG
|
||||
ircolib::IsInsideRange(vaddr, 0x4000000000000000, 0x400000FFFFFFFFFF) || // VREGION_XKSSEG
|
||||
ircolib::IsInsideRange(vaddr, 0xC000000000000000, 0xC00000FF7FFFFFFF) || // VREGION_XKSEG
|
||||
ircolib::IsInsideRange(vaddr, 0xFFFFFFFFE0000000, 0xFFFFFFFFFFFFFFFF)) // VREGION_CKSEG3
|
||||
if (ircolib::is_inside_range(vaddr, 0x0000000000000000, 0x000000FFFFFFFFFF) || // VREGION_XKUSEG
|
||||
ircolib::is_inside_range(vaddr, 0x4000000000000000, 0x400000FFFFFFFFFF) || // VREGION_XKSSEG
|
||||
ircolib::is_inside_range(vaddr, 0xC000000000000000, 0xC00000FF7FFFFFFF) || // VREGION_XKSEG
|
||||
ircolib::is_inside_range(vaddr, 0xFFFFFFFFE0000000, 0xFFFFFFFFFFFFFFFF)) // VREGION_CKSEG3
|
||||
return ProbeTLB(accessType, vaddr, paddr);
|
||||
|
||||
if (ircolib::IsInsideRange(vaddr, 0x8000000000000000, 0xBFFFFFFFFFFFFFFF)) { // VREGION_XKPHYS
|
||||
if (ircolib::is_inside_range(vaddr, 0x8000000000000000, 0xBFFFFFFFFFFFFFFF)) { // VREGION_XKPHYS
|
||||
if (!kernelMode)
|
||||
panic("Access to XKPHYS address 0x{:016X} when outside kernel mode!", vaddr);
|
||||
ircolib::panic("Access to XKPHYS address 0x{:016X} when outside kernel mode!", vaddr);
|
||||
|
||||
const u8 high_two_bits = (vaddr >> 62) & 0b11;
|
||||
if (high_two_bits != 0b10)
|
||||
panic("Access to XKPHYS address 0x{:016X} with high two bits != 0b10!", vaddr);
|
||||
ircolib::panic("Access to XKPHYS address 0x{:016X} with high two bits != 0b10!", vaddr);
|
||||
|
||||
const u8 subsegment = (vaddr >> 59) & 0b11;
|
||||
bool cached = subsegment != 2; // do something with this eventually
|
||||
@@ -530,31 +530,31 @@ bool Cop0::MapVirtualAddress<u64, false>(const TLBAccessType accessType, const u
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ircolib::IsInsideRange(vaddr, 0xFFFFFFFF80000000, 0xFFFFFFFF9FFFFFFF) || // VREGION_CKSEG0
|
||||
ircolib::IsInsideRange(vaddr, 0xFFFFFFFFA0000000, 0xFFFFFFFFBFFFFFFF)) { // VREGION_CKSEG1
|
||||
if (ircolib::is_inside_range(vaddr, 0xFFFFFFFF80000000, 0xFFFFFFFF9FFFFFFF) || // VREGION_CKSEG0
|
||||
ircolib::is_inside_range(vaddr, 0xFFFFFFFFA0000000, 0xFFFFFFFFBFFFFFFF)) { // VREGION_CKSEG1
|
||||
u32 cut = u32(vaddr) >> 28;
|
||||
u32 num = cut == 0xA;
|
||||
// Identical to ksegX in 32 bit mode.
|
||||
// Unmapped translation. Subtract the base address of the space to get the physical address.
|
||||
paddr = vaddr - (cut << 28); // Implies cutting off the high 32 bits
|
||||
trace("CKSEG{}: Translated 0x{:016X} to 0x{:08X}", num, vaddr, paddr);
|
||||
ircolib::trace("CKSEG{}: Translated 0x{:016X} to 0x{:08X}", num, vaddr, paddr);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ircolib::IsInsideRange(vaddr, 0x0000010000000000, 0x3FFFFFFFFFFFFFFF) || // VREGION_XBAD1
|
||||
ircolib::IsInsideRange(vaddr, 0x4000010000000000, 0x7FFFFFFFFFFFFFFF) || // VREGION_XBAD2
|
||||
ircolib::IsInsideRange(vaddr, 0xC00000FF80000000, 0xFFFFFFFF7FFFFFFF)) { // VREGION_XBAD3
|
||||
if (ircolib::is_inside_range(vaddr, 0x0000010000000000, 0x3FFFFFFFFFFFFFFF) || // VREGION_XBAD1
|
||||
ircolib::is_inside_range(vaddr, 0x4000010000000000, 0x7FFFFFFFFFFFFFFF) || // VREGION_XBAD2
|
||||
ircolib::is_inside_range(vaddr, 0xC00000FF80000000, 0xFFFFFFFF7FFFFFFF)) { // VREGION_XBAD3
|
||||
tlbError = DISALLOWED_ADDRESS;
|
||||
return false;
|
||||
}
|
||||
|
||||
panic("Resolving virtual address 0x{:016X} in 64 bit mode", vaddr);
|
||||
ircolib::panic("Resolving virtual address 0x{:016X} in 64 bit mode", vaddr);
|
||||
return false; // just to silence warning
|
||||
}
|
||||
|
||||
bool Cop0::MapVAddr(const TLBAccessType accessType, const u64 vaddr, u32 &paddr) {
|
||||
if (supervisorMode)
|
||||
panic("Supervisor mode memory access");
|
||||
ircolib::panic("Supervisor mode memory access");
|
||||
|
||||
if (is64BitAddressing) [[unlikely]] {
|
||||
if (kernelMode) [[likely]]
|
||||
@@ -562,7 +562,7 @@ bool Cop0::MapVAddr(const TLBAccessType accessType, const u64 vaddr, u32 &paddr)
|
||||
if (userMode)
|
||||
return MapVirtualAddress<u64, true>(accessType, vaddr, paddr);
|
||||
|
||||
panic("Unknown mode! This should never happen!");
|
||||
ircolib::panic("Unknown mode! This should never happen!");
|
||||
}
|
||||
|
||||
if (kernelMode) [[likely]]
|
||||
@@ -570,6 +570,6 @@ bool Cop0::MapVAddr(const TLBAccessType accessType, const u64 vaddr, u32 &paddr)
|
||||
if (userMode)
|
||||
return MapVirtualAddress<u32, true>(accessType, vaddr, paddr);
|
||||
|
||||
panic("Unknown mode! This should never happen!");
|
||||
ircolib::panic("Unknown mode! This should never happen!");
|
||||
}
|
||||
} // namespace n64
|
||||
|
||||
Reference in New Issue
Block a user