Parcourir la source

Tidy up the page fault code a bit in preparation.

Andreas Kling il y a 6 ans
Parent
commit
e85c22fe58
4 fichiers modifiés avec 19 ajouts et 18 suppressions
  1. 6 5
      Kernel/MemoryManager.cpp
  2. 1 1
      Kernel/MemoryManager.h
  3. 1 1
      Kernel/i386.cpp
  4. 11 11
      Kernel/i386.h

+ 6 - 5
Kernel/MemoryManager.cpp

@@ -105,7 +105,8 @@ void MemoryManager::deallocate_page_table(PageDirectory& page_directory, unsigne
 {
     auto& physical_page = page_directory.physical_pages[index];
     ASSERT(physical_page);
-    ASSERT(!m_free_physical_pages.contains_slow(physical_page));
+    //FIXME: This line is buggy and effectful somehow :(
+    //ASSERT(!m_free_physical_pages.contains_slow(physical_page));
     for (size_t i = 0; i < MM.m_free_physical_pages.size(); ++i) {
         ASSERT(MM.m_free_physical_pages[i].ptr() != physical_page.ptr());
     }
@@ -207,13 +208,13 @@ void MemoryManager::initialize()
     s_the = new MemoryManager;
 }
 
-PageFaultResponse MemoryManager::handlePageFault(const PageFault& fault)
+PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
 {
     ASSERT_INTERRUPTS_DISABLED();
-    kprintf("MM: handlePageFault(%w) at L%x\n", fault.code(), fault.address().get());
-    if (fault.isNotPresent()) { 
+    kprintf("MM: handle_page_fault(%w) at L%x\n", fault.code(), fault.laddr().get());
+    if (fault.is_not_present()) {
         kprintf("  >> NP fault!\n");
-    } else if (fault.isProtectionViolation()) {
+    } else if (fault.is_protection_violation()) {
         kprintf("  >> PV fault!\n");
     }
     return PageFaultResponse::ShouldCrash;

+ 1 - 1
Kernel/MemoryManager.h

@@ -79,7 +79,7 @@ public:
 
     static void initialize();
 
-    PageFaultResponse handlePageFault(const PageFault&);
+    PageFaultResponse handle_page_fault(const PageFault&);
 
     bool mapRegion(Process&, Region&);
     bool unmapRegion(Process&, Region&);

+ 1 - 1
Kernel/i386.cpp

@@ -238,7 +238,7 @@ void exception_14_handler()
     if (current->isRing0())
         HANG;
 
-    auto response = MM.handlePageFault(PageFault(exception_code, LinearAddress(faultAddress)));
+    auto response = MM.handle_page_fault(PageFault(exception_code, LinearAddress(faultAddress)));
 
     if (response == PageFaultResponse::ShouldCrash) {
         kprintf("Crashing after unresolved page fault\n");

+ 11 - 11
Kernel/i386.h

@@ -126,26 +126,26 @@ enum Flags {
 
 class PageFault {
 public:
-    PageFault(word code, LinearAddress address)
+    PageFault(word code, LinearAddress laddr)
         : m_code(code)
-        , m_address(address)
+        , m_laddr(laddr)
     {
     }
 
-    LinearAddress address() const { return m_address; }
+    LinearAddress laddr() const { return m_laddr; }
     word code() const { return m_code; }
 
-    bool isNotPresent() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
-    bool isProtectionViolation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
-    bool isRead() const { return (m_code & 2) == PageFaultFlags::Read; }
-    bool isWrite() const { return (m_code & 2) == PageFaultFlags::Write; }
-    bool isUser() const { return (m_code & 4) == PageFaultFlags::UserMode; }
-    bool isSupervisor() const { return (m_code & 4) == PageFaultFlags::SupervisorMode; }
-    bool isInstructionFetch() const { return (m_code & 8) == PageFaultFlags::InstructionFetch; }
+    bool is_not_present() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
+    bool is_protection_violation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
+    bool is_read() const { return (m_code & 2) == PageFaultFlags::Read; }
+    bool is_write() const { return (m_code & 2) == PageFaultFlags::Write; }
+    bool is_user() const { return (m_code & 4) == PageFaultFlags::UserMode; }
+    bool is_supervisor() const { return (m_code & 4) == PageFaultFlags::SupervisorMode; }
+    bool is_instruction_fetch() const { return (m_code & 8) == PageFaultFlags::InstructionFetch; }
 
 private:
     word m_code;
-    LinearAddress m_address;
+    LinearAddress m_laddr;
 };
 
 struct RegisterDump {