diff options
author | Marvin Borner | 2021-03-20 18:46:33 +0100 |
---|---|---|
committer | Marvin Borner | 2021-03-20 18:46:33 +0100 |
commit | 635751fc2a75f66d1541469b3204efb1701bd91c (patch) | |
tree | 2cb5ac0484acb2427504b681a021d6c2fe19d0f8 /kernel/features | |
parent | c97a50ba7baa70b40431594f410ca18e14af3b76 (diff) |
Even more fixes! :^)
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/load.c | 4 | ||||
-rw-r--r-- | kernel/features/mm.c | 14 | ||||
-rw-r--r-- | kernel/features/proc.c | 8 |
3 files changed, 12 insertions, 14 deletions
diff --git a/kernel/features/load.c b/kernel/features/load.c index 079cbbe..d3f3495 100644 --- a/kernel/features/load.c +++ b/kernel/features/load.c @@ -119,8 +119,8 @@ s32 elf_load(const char *path, struct proc *proc) memory_switch_dir(proc->page_dir); u32 stack = (u32)memory_alloc(proc->page_dir, PROC_STACK_SIZE, MEMORY_USER | MEMORY_CLEAR); - proc->regs.ebp = stack + PROC_STACK_SIZE - 1; - proc->regs.useresp = stack + PROC_STACK_SIZE - 1; + proc->regs.ebp = stack + PROC_STACK_SIZE; + proc->regs.useresp = stack + PROC_STACK_SIZE; proc->regs.eip = header.entry; proc->entry = header.entry; diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 01e21e7..b06657f 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -48,8 +48,8 @@ void page_fault_handler(struct regs *r) struct page_dir *dir = NULL; if (proc && proc->page_dir) { dir = proc->page_dir; - printf("Stack is at %x, entry at %x\n", virtual_to_physical(dir, proc->regs.ebp), - virtual_to_physical(dir, proc->entry)); + /* printf("Stack is at %x, entry at %x\n", virtual_to_physical(dir, proc->regs.ebp), */ + /* virtual_to_physical(dir, proc->entry)); */ } else { dir = &kernel_dir; } @@ -165,7 +165,7 @@ void physical_free(struct memory_range range) * Virtual */ -#define PDI(vaddr) (((vaddr) >> 22) & 0x03ff) +#define PDI(vaddr) ((vaddr) >> 22) #define PTI(vaddr) (((vaddr) >> 12) & 0x03ff) u8 virtual_present(struct page_dir *dir, u32 vaddr) @@ -210,15 +210,11 @@ void virtual_map(struct page_dir *dir, struct memory_range prange, u32 vaddr, u3 struct page_table *table = (struct page_table *)(dir_entry->bits.address * PAGE_SIZE); - if (dir_entry->bits.present) { - // TODO: Is this a security risk? - if (flags & MEMORY_USER) - dir_entry->bits.user = 1; - } else { + if (!dir_entry->bits.present) { table = memory_alloc_identity(dir, MEMORY_CLEAR); dir_entry->bits.present = 1; dir_entry->bits.writable = 1; - dir_entry->bits.user = flags & MEMORY_USER; + dir_entry->bits.user = 1; dir_entry->bits.address = (u32)(table) >> 12; } diff --git a/kernel/features/proc.c b/kernel/features/proc.c index aa595ff..5d3c8aa 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -81,11 +81,13 @@ void proc_print(void) { struct node *node = proc_list->head; - printf("\nPROCESSES\n"); + printf("--- PROCESSES ---\n"); struct proc *proc = NULL; while (node && (proc = node->data)) { - printf("Process %d: %s [%s]\n", proc->pid, proc->name, - proc->state == PROC_RUNNING ? "RUNNING" : "SLEEPING"); + printf("Process %d: %s [%s] [entry: %x; stack: %x]\n", proc->pid, proc->name, + proc->state == PROC_RUNNING ? "RUNNING" : "SLEEPING", + virtual_to_physical(proc->page_dir, proc->entry), + virtual_to_physical(proc->page_dir, proc->regs.ebp)); node = node->next; } printf("\n"); |