1 // User-level page fault handler support.
2 // We use an assembly language wrapper around a C function.
3 // The assembly wrapper is in pfentry.S.
8 // Assembly language pgfault entrypoint defined in lib/pgfaultentry.S.
9 extern void _pgfault_entry(void);
11 // Pointer to currently installed C-language pgfault handler.
12 void (*_pgfault_handler
)(u_int
, u_int
);
15 // Set the page fault handler function.
16 // If there isn't one yet, _pgfault_handler will be 0.
17 // The first time we register a handler, we need to
18 // allocate an exception stack and tell the kernel to
19 // call _asm_pgfault_handler on it.
22 set_pgfault_handler(void (*fn
)(u_int va
, u_int err
))
26 if (_pgfault_handler
== 0) {
28 // map one page of exception stack with top at UXSTACKTOP
29 // register assembly pgfault entrypoint with JOS kernel
30 panic("set_pgfault_handler not implemented");
33 // Save handler pointer for assembly to call.
34 _pgfault_handler
= fn
;