mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 21:35:06 +00:00
Tidy up the page fault code a bit in preparation.
This commit is contained in:
parent
72cdc62155
commit
e85c22fe58
4 changed files with 19 additions and 18 deletions
|
@ -105,7 +105,8 @@ void MemoryManager::deallocate_page_table(PageDirectory& page_directory, unsigne
|
||||||
{
|
{
|
||||||
auto& physical_page = page_directory.physical_pages[index];
|
auto& physical_page = page_directory.physical_pages[index];
|
||||||
ASSERT(physical_page);
|
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) {
|
for (size_t i = 0; i < MM.m_free_physical_pages.size(); ++i) {
|
||||||
ASSERT(MM.m_free_physical_pages[i].ptr() != physical_page.ptr());
|
ASSERT(MM.m_free_physical_pages[i].ptr() != physical_page.ptr());
|
||||||
}
|
}
|
||||||
|
@ -207,13 +208,13 @@ void MemoryManager::initialize()
|
||||||
s_the = new MemoryManager;
|
s_the = new MemoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageFaultResponse MemoryManager::handlePageFault(const PageFault& fault)
|
PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
|
||||||
{
|
{
|
||||||
ASSERT_INTERRUPTS_DISABLED();
|
ASSERT_INTERRUPTS_DISABLED();
|
||||||
kprintf("MM: handlePageFault(%w) at L%x\n", fault.code(), fault.address().get());
|
kprintf("MM: handle_page_fault(%w) at L%x\n", fault.code(), fault.laddr().get());
|
||||||
if (fault.isNotPresent()) {
|
if (fault.is_not_present()) {
|
||||||
kprintf(" >> NP fault!\n");
|
kprintf(" >> NP fault!\n");
|
||||||
} else if (fault.isProtectionViolation()) {
|
} else if (fault.is_protection_violation()) {
|
||||||
kprintf(" >> PV fault!\n");
|
kprintf(" >> PV fault!\n");
|
||||||
}
|
}
|
||||||
return PageFaultResponse::ShouldCrash;
|
return PageFaultResponse::ShouldCrash;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
static void initialize();
|
static void initialize();
|
||||||
|
|
||||||
PageFaultResponse handlePageFault(const PageFault&);
|
PageFaultResponse handle_page_fault(const PageFault&);
|
||||||
|
|
||||||
bool mapRegion(Process&, Region&);
|
bool mapRegion(Process&, Region&);
|
||||||
bool unmapRegion(Process&, Region&);
|
bool unmapRegion(Process&, Region&);
|
||||||
|
|
|
@ -238,7 +238,7 @@ void exception_14_handler()
|
||||||
if (current->isRing0())
|
if (current->isRing0())
|
||||||
HANG;
|
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) {
|
if (response == PageFaultResponse::ShouldCrash) {
|
||||||
kprintf("Crashing after unresolved page fault\n");
|
kprintf("Crashing after unresolved page fault\n");
|
||||||
|
|
|
@ -126,26 +126,26 @@ enum Flags {
|
||||||
|
|
||||||
class PageFault {
|
class PageFault {
|
||||||
public:
|
public:
|
||||||
PageFault(word code, LinearAddress address)
|
PageFault(word code, LinearAddress laddr)
|
||||||
: m_code(code)
|
: 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; }
|
word code() const { return m_code; }
|
||||||
|
|
||||||
bool isNotPresent() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
|
bool is_not_present() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
|
||||||
bool isProtectionViolation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
|
bool is_protection_violation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
|
||||||
bool isRead() const { return (m_code & 2) == PageFaultFlags::Read; }
|
bool is_read() const { return (m_code & 2) == PageFaultFlags::Read; }
|
||||||
bool isWrite() const { return (m_code & 2) == PageFaultFlags::Write; }
|
bool is_write() const { return (m_code & 2) == PageFaultFlags::Write; }
|
||||||
bool isUser() const { return (m_code & 4) == PageFaultFlags::UserMode; }
|
bool is_user() const { return (m_code & 4) == PageFaultFlags::UserMode; }
|
||||||
bool isSupervisor() const { return (m_code & 4) == PageFaultFlags::SupervisorMode; }
|
bool is_supervisor() const { return (m_code & 4) == PageFaultFlags::SupervisorMode; }
|
||||||
bool isInstructionFetch() const { return (m_code & 8) == PageFaultFlags::InstructionFetch; }
|
bool is_instruction_fetch() const { return (m_code & 8) == PageFaultFlags::InstructionFetch; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
word m_code;
|
word m_code;
|
||||||
LinearAddress m_address;
|
LinearAddress m_laddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RegisterDump {
|
struct RegisterDump {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue