MMIO: UnmapRegion

This commit is contained in:
MerryMage 2016-04-02 09:54:11 +01:00
parent 5e8d1e0289
commit bef912b7ec

View File

@ -104,6 +104,13 @@ void UnmapRegion(VAddr base, u32 size) {
ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size); ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size);
ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base); ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base);
MapPages(base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Unmapped); MapPages(base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Unmapped);
for (auto iter = current_page_table->special_regions.begin(); iter != current_page_table->special_regions.end(); iter++) {
if (base == iter->base && size == iter->size) {
current_page_table->special_regions.erase(iter);
return;
}
}
} }
/** /**
@ -111,7 +118,7 @@ void UnmapRegion(VAddr base, u32 size) {
*/ */
static MMIORegionPointer GetMMIOHandler(VAddr vaddr) { static MMIORegionPointer GetMMIOHandler(VAddr vaddr) {
for (const auto& region : current_page_table->special_regions) { for (const auto& region : current_page_table->special_regions) {
if (vaddr >= region.base && vaddr < (region.base + region.size)) { if (vaddr >= region.base && (vaddr - region.base) < region.size) {
return region.handler; return region.handler;
} }
} }