1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:47:35 +00:00

Kernel: Make Memory::Region::map() return KResult

..and use TRY() at the call sites to propagate errors. :^)
This commit is contained in:
Andreas Kling 2021-09-06 12:52:23 +02:00
parent 7981422500
commit e3a716ceff
6 changed files with 17 additions and 25 deletions

View file

@ -243,7 +243,7 @@ void Region::set_page_directory(PageDirectory& page_directory)
m_page_directory = page_directory;
}
bool Region::map(PageDirectory& page_directory, ShouldFlushTLB should_flush_tlb)
KResult Region::map(PageDirectory& page_directory, ShouldFlushTLB should_flush_tlb)
{
SpinlockLocker page_lock(page_directory.get_lock());
SpinlockLocker lock(s_mm_lock);
@ -263,16 +263,18 @@ bool Region::map(PageDirectory& page_directory, ShouldFlushTLB should_flush_tlb)
if (page_index > 0) {
if (should_flush_tlb == ShouldFlushTLB::Yes)
MM.flush_tlb(m_page_directory, vaddr(), page_index);
return page_index == page_count();
if (page_index == page_count())
return KSuccess;
}
return false;
return ENOMEM;
}
void Region::remap()
{
VERIFY(m_page_directory);
auto result = map(*m_page_directory);
VERIFY(result);
if (result.is_error())
TODO();
}
PageFaultResponse Region::handle_fault(PageFault const& fault)