Process page fault handler
This commit is contained in:
parent
4ecec1eec6
commit
28c82567a0
@ -21,10 +21,16 @@ struct process *sched_proc = 0;
|
||||
struct process *_proc = 0;
|
||||
|
||||
void procmm_init(struct process *p);
|
||||
registers *proc_pagefault(registers *r);
|
||||
|
||||
uint64_t next_pid = 1;
|
||||
struct process *new_process(void (*function)(void))
|
||||
{
|
||||
if(next_pid == 1)
|
||||
{
|
||||
bind_interrupt(14, proc_pagefault);
|
||||
}
|
||||
|
||||
struct process *proc = P2V(pmm_calloc());
|
||||
proc->pid = next_pid++;
|
||||
proc->stack_ptr = incptr(proc, PAGE_SIZE - sizeof(struct swtch_stack));
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stddef.h>
|
||||
#include <debug.h>
|
||||
#include <memory.h>
|
||||
#include <cpu.h>
|
||||
|
||||
void procmm_init(struct process *p)
|
||||
{
|
||||
@ -22,3 +23,18 @@ uint64_t procmm_brk(struct process *p, void *addr)
|
||||
}
|
||||
return p->brk;
|
||||
}
|
||||
|
||||
registers *proc_pagefault(registers *r)
|
||||
{
|
||||
if(!(r->rflags & (3<<12)))
|
||||
{
|
||||
debug_error("Page fault in kernel!\n");
|
||||
debug("Interrupt number: %d Error code: %d\n", r->int_no, r->err_code);
|
||||
debug_print_registers(r);
|
||||
PANIC("Page fault in kernel\n");
|
||||
}
|
||||
|
||||
PANIC("Page fault in process\n");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user