Merge pull request from wwylele/p2ptr-boundary

Memory: GetPhysicalPointer should accept right open bound address
This commit is contained in:
Weiyi Wang 2018-11-19 11:05:42 -05:00 committed by GitHub
commit 471b4cf44f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;