Files
PS2Recomp/ps2xRuntime/include/runtime/ps2_address.h
T
Ranieri 52edf07657 Feature/agressive recompiler (#146)
* feat: added guestBranchKind enum to categorize branch types
feat: added missingFunctionPolicy enum to define behaviors for missing function scenarios
refactor: added handle guest branches and report missing functions
feat lookupFunction to utilize new dispatch logic and improve error handling for unregistered functions

* fix: fix test conflict

* feat: added debug sound driver logs

* feat: emmiter for return

* feat: added recompiler reporter
feat: added strict diagnostics flag for heavy debug calls

* feat: staticc table insted of hashmap for runtime

* feat: back file to ignore

* feat: explode code across helpers and classes

* feat: update codegen test
feat: better guest nop check

* feat: fix link problem on linux

* feat: fix Segmentation fault

* feat: added recompile replace for DMA and MMIO
feat: added a clean memory helpers
feat: use memory helpers across the project
feat: fix ucrt on msvc

* feat: undo messup merge
2026-07-07 10:14:25 -03:00

62 lines
1.9 KiB
C++

#ifndef PS2_ADDRESS_H
#define PS2_ADDRESS_H
#include <cstdint>
#include "runtime/ps2_memory.h"
static inline constexpr uint32_t PS2_EE_UNCACHED_RAM_MIRROR_BASE = 0x20000000u;
static inline constexpr uint32_t PS2_EE_UNCACHED_RAM_MIRROR_SIZE = 0x20000000u;
static inline constexpr uint32_t PS2_KSEG0_BASE = 0x80000000u;
static inline constexpr uint32_t PS2_KSEG0_KSEG1_SIZE = 0x40000000u;
static inline constexpr uint32_t PS2_KSEG2_BASE = 0xC0000000u;
static inline constexpr bool Ps2AddressInRange(uint32_t value, uint32_t base, uint32_t size)
{
return (value - base) < size;
}
static inline constexpr bool Ps2IsUncachedRamMirrorAddress(uint32_t addr)
{
return Ps2AddressInRange(addr, PS2_EE_UNCACHED_RAM_MIRROR_BASE, PS2_EE_UNCACHED_RAM_MIRROR_SIZE);
}
static inline constexpr bool Ps2IsKseg01Address(uint32_t addr)
{
return Ps2AddressInRange(addr, PS2_KSEG0_BASE, PS2_KSEG0_KSEG1_SIZE);
}
static inline constexpr bool Ps2IsKseg23Address(uint32_t addr)
{
return addr >= PS2_KSEG2_BASE;
}
static inline constexpr uint32_t Ps2DirectMappedPhysicalAddress(uint32_t addr)
{
return addr & 0x1FFFFFFFu;
}
static inline constexpr uint32_t Ps2PhysicalAddress(uint32_t addr)
{
return (addr >= PS2_KSEG0_BASE) ? Ps2DirectMappedPhysicalAddress(addr) : addr;
}
static inline constexpr bool Ps2IsPhysicalSpecialAddress(uint32_t physAddr)
{
return Ps2AddressInRange(physAddr, PS2_BIOS_BASE, PS2_BIOS_SIZE) ||
Ps2AddressInRange(physAddr, PS2_SCRATCHPAD_BASE, PS2_SCRATCHPAD_SIZE) ||
Ps2AddressInRange(physAddr, PS2_IO_BASE, PS2_IO_SIZE) ||
Ps2AddressInRange(physAddr, PS2_GS_PRIV_REG_BASE, PS2_GS_PRIV_REG_SIZE) ||
(physAddr >= PS2_VU0_DATA_BASE && physAddr < (PS2_VU1_CODE_BASE + PS2_VU1_CODE_SIZE));
}
static inline constexpr bool Ps2IsSpecialAddress(uint32_t addr)
{
if (Ps2IsKseg23Address(addr))
return true;
return Ps2IsPhysicalSpecialAddress(Ps2PhysicalAddress(addr));
}
#endif // PS2_ADDRESS_H