diff options
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/mm.c | 11 | ||||
-rw-r--r-- | kernel/features/proc.c | 6 | ||||
-rw-r--r-- | kernel/features/syscall.c | 4 |
3 files changed, 14 insertions, 7 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 76049ef..a0ed280 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -84,6 +84,9 @@ void page_fault_handler(struct regs *r) // Print! printf("%s process tried to %s a %s page at [vaddr=%x; paddr=%x]\n", super, operation, type, vaddr, paddr); + if (proc && vaddr > proc->regs.ebp - PROC_STACK_SIZE - PAGE_SIZE && + vaddr < proc->regs.ebp + PAGE_SIZE) + print("Probably a stack overflow\n"); printf("Sections: [vaddr_section=%s; paddr_section=%s; eip_section=%s]\n", page_fault_section(vaddr), page_fault_section(paddr), page_fault_section(r->eip)); @@ -667,10 +670,13 @@ CLEAR void memory_install(struct mem_info *mem_info, struct vid_info *vid_info) /* printf("Memory region: %x-%x\n", p->lbase, p->lbase + size); */ if (p->type == MEMORY_AVAILABLE) { - physical_set_free(memory_range_around(p->lbase, size / PAGE_SIZE)); + physical_set_free(memory_range_around(p->lbase, size)); memory_total += size; } else if (p->type == MEMORY_DEFECT) { printf("Defect memory at 0x%x-0x%x!\n", p->lbase, p->lbase + size); + physical_set_used(memory_range_around(p->lbase, size)); + } else { + physical_set_used(memory_range_around(p->lbase, size)); } } @@ -685,6 +691,9 @@ CLEAR void memory_install(struct mem_info *mem_info, struct vid_info *vid_info) memory_used = 0; printf("Detected memory: %dKiB (%dMiB)\n", memory_total >> 10, memory_total >> 20); + // Set first MiB 'used' (bootloader(s), VESA tables, memory maps, ...) + physical_set_used(memory_range(0, 0x00100000)); + // Map kernel memory_map_identity(&kernel_dir, kernel_ro_memory_range(), MEMORY_READONLY); memory_map_identity(&kernel_dir, kernel_rw_memory_range(), MEMORY_NONE); diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 21e63b3..0cca50f 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -183,6 +183,7 @@ void proc_yield(struct regs *r) scheduler(r); } +// TODO: Rewrite block/unblock mechanisms void proc_block(u32 id, enum proc_block_type type, u32 func_ptr) { u8 already_exists = 0; @@ -298,8 +299,6 @@ struct proc *proc_make(enum proc_priv priv) void proc_stack_push(struct proc *proc, u32 data) { - assert(proc->regs.useresp > sizeof(data)); - struct page_dir *prev; memory_backup_dir(&prev); memory_switch_dir(proc->page_dir); @@ -560,6 +559,8 @@ NORETURN void proc_init(void) // TODO: Reimplement hlt privileges in idle proc (SMEP!) struct proc *kernel_proc = proc_make(PROC_PRIV_NONE); assert(elf_load("/bin/idle", kernel_proc) == EOK); + proc_stack_push(kernel_proc, 0); + proc_stack_push(kernel_proc, 0); kernel_proc->state = PROC_BLOCKED; kernel_proc->quantum.val = 0; kernel_proc->quantum.cnt = 0; @@ -570,6 +571,7 @@ NORETURN void proc_init(void) struct proc *init = proc_make(PROC_PRIV_ROOT); assert(elf_load("/bin/init", init) == EOK); proc_stack_push(init, 0); + proc_stack_push(init, 0); current = list_first_data(proc_list_running, init); _eip = init->regs.eip; diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index b5c08da..98a7ff9 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -121,10 +121,6 @@ static void syscall_handler(struct regs *r) proc_yield(r); break; } - case SYS_TIME: { - r->eax = timer_get(); - break; - } // TODO: Reimplement network functions using VFS default: { printf("Unknown syscall %d!\n", num); |