X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/bffa3430fbbaaad29bec0b5bee9c1f0bfc7fd068..34f6af4f61e0eec9c96113e07f140b609b4113c8:/lunaix-os/arch/x86/mm/fault.c diff --git a/lunaix-os/arch/x86/mm/fault.c b/lunaix-os/arch/x86/mm/fault.c index 62f9d80..899fe2f 100644 --- a/lunaix-os/arch/x86/mm/fault.c +++ b/lunaix-os/arch/x86/mm/fault.c @@ -1,10 +1,6 @@ #include -#include -#include #include -#include - bool __arch_prepare_fault_context(struct fault_context* fault) { @@ -21,4 +17,30 @@ __arch_prepare_fault_context(struct fault_context* fault) fault->fault_va = ptr; return true; +} + + +void +intr_routine_page_fault(const struct hart_state* hstate) +{ + if (hstate->depth > 10) { + // Too many nested fault! we must messed up something + // XXX should we failed silently? + spin(); + } + + struct fault_context fault = { .hstate = hstate }; + + if (!__arch_prepare_fault_context(&fault)) { + goto failed; + } + + if (!handle_page_fault(&fault)) { + goto failed; + } + + return; + +failed: + fault_resolving_failed(&fault); } \ No newline at end of file