Memory: GetPhysicalPointer should accept right open bound address

Also removed IO region check in GetPhysicalPointer as it doesn't make sense to get a pointer to MMIO
This commit is contained in:
Weiyi Wang 2018-11-16 00:14:17 -05:00
parent 560df843b1
commit 365eeb889f

View file

@ -274,7 +274,6 @@ u8* GetPhysicalPointer(PAddr address) {
static constexpr MemoryArea memory_areas[] = {
{VRAM_PADDR, VRAM_SIZE},
{IO_AREA_PADDR, IO_AREA_SIZE},
{DSP_RAM_PADDR, DSP_RAM_SIZE},
{FCRAM_PADDR, FCRAM_N3DS_SIZE},
{N3DS_EXTRA_RAM_PADDR, N3DS_EXTRA_RAM_SIZE},
@ -282,7 +281,9 @@ u8* GetPhysicalPointer(PAddr address) {
const auto area =
std::find_if(std::begin(memory_areas), std::end(memory_areas), [&](const auto& area) {
return address >= area.paddr_base && address < area.paddr_base + area.size;
// Note: the region end check is inclusive because the user can pass in an address that
// represents an open right bound
return address >= area.paddr_base && address <= area.paddr_base + area.size;
});
if (area == std::end(memory_areas)) {
@ -290,11 +291,6 @@ u8* GetPhysicalPointer(PAddr address) {
return nullptr;
}
if (area->paddr_base == IO_AREA_PADDR) {
LOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr=0x{:08X}", address);
return nullptr;
}
u32 offset_into_region = address - area->paddr_base;
u8* target_pointer = nullptr;