diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-22 15:42:39 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-22 15:43:02 +0200 |
commit | b824f156197d8f2552442ecf0c8073ff28308941 (patch) | |
tree | a69fcf864f51668dbfca80a23089508b9f250793 /Kernel/MemoryManager.cpp | |
parent | befeabd8fe47e6d33b0e5648d7db8dbff5eb280e (diff) | |
download | serenity-b824f156197d8f2552442ecf0c8073ff28308941.zip |
Launching an arbitrary ELF executable from disk works! :^)
This is so cool! It's a bit messy now with two Task constructors,
but eventually they should fold into a single constructor somehow.
Diffstat (limited to 'Kernel/MemoryManager.cpp')
-rw-r--r-- | Kernel/MemoryManager.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Kernel/MemoryManager.cpp b/Kernel/MemoryManager.cpp index 1d85aca254..019242a741 100644 --- a/Kernel/MemoryManager.cpp +++ b/Kernel/MemoryManager.cpp @@ -161,20 +161,27 @@ bool MemoryManager::unmapRegionsForTask(Task& task) return true; } +bool MemoryManager::mapRegion(Task& task, Task::Region& region) +{ + auto& zone = *region.zone; + for (size_t i = 0; i < zone.m_pages.size(); ++i) { + auto laddr = region.linearAddress.offset(i * PAGE_SIZE); + auto pte = ensurePTE(laddr); + pte.setPhysicalPageBase(zone.m_pages[i].get()); + pte.setPresent(true); + pte.setWritable(true); + pte.setUserAllowed(!task.isRing0()); + + //kprintf("MM: >> Mapped L%x => P%x <<\n", laddr, zone.m_pages[i].get()); + } + return true; +} + bool MemoryManager::mapRegionsForTask(Task& task) { for (auto& region : task.m_regions) { - auto& zone = *region->zone; - for (size_t i = 0; i < zone.m_pages.size(); ++i) { - auto laddr = region->linearAddress.offset(i * PAGE_SIZE); - auto pte = ensurePTE(laddr); - pte.setPhysicalPageBase(zone.m_pages[i].get()); - pte.setPresent(true); - pte.setWritable(true); - pte.setUserAllowed(!task.isRing0()); - - //kprintf("MM: >> Mapped L%x => P%x <<\n", laddr, zone.m_pages[i].get()); - } + if (!mapRegion(task, *region)) + return false; } return true; } |