diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-17 11:27:59 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-17 11:27:59 +0200 |
commit | 1c7c106b06b6a88502801e699ef99e72b7c625cd (patch) | |
tree | 5708a229b0d66e8eb82a953861e017915f8176b6 /src/kernel | |
parent | 5bc8549a8d7f5c9644f878fe3ca55761663a2fd0 (diff) | |
download | TCE-1c7c106b06b6a88502801e699ef99e72b7c625cd.tar.gz TCE-1c7c106b06b6a88502801e699ef99e72b7c625cd.zip |
Fixed some nasty bugs.
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/Makefile | 2 | ||||
-rw-r--r-- | src/kernel/core/kmain.cpp | 4 | ||||
-rw-r--r-- | src/kernel/lib/bitset.h | 4 | ||||
-rw-r--r-- | src/kernel/linker/elf.cpp | 2 | ||||
-rw-r--r-- | src/kernel/mem/paging.cpp | 4 | ||||
-rw-r--r-- | src/kernel/task/task.cpp | 8 | ||||
-rw-r--r-- | src/kernel/task/task.h | 1 |
7 files changed, 14 insertions, 11 deletions
diff --git a/src/kernel/Makefile b/src/kernel/Makefile index 1103a7d..2a18bc8 100644 --- a/src/kernel/Makefile +++ b/src/kernel/Makefile @@ -10,7 +10,7 @@ ExtObj = $(SrcPath)/common/_common.o include $(SrcPath)/common.make -CFLAGS += -g -I $(SrcPath)/common/include -I . -I ./lib +CFLAGS += -I $(SrcPath)/common/include -I . -I ./lib LDFLAGS += -T link.ld -Map kernel.map diff --git a/src/kernel/core/kmain.cpp b/src/kernel/core/kmain.cpp index 0a5f2d8..8b77bcf 100644 --- a/src/kernel/core/kmain.cpp +++ b/src/kernel/core/kmain.cpp @@ -48,9 +48,9 @@ extern "C" void kmain(multiboot_info_t* mbd, int32_t magic) { totalRam = ((mbd->mem_upper + mbd->mem_lower) * 1024); paging_init(totalRam); - _no_more_ksbrk = true; gdt_init(); paging_cleanup(); + _no_more_ksbrk = true; //kheap_init(); timer_init(30); @@ -72,7 +72,7 @@ extern "C" void kmain(multiboot_info_t* mbd, int32_t magic) { } } - monitor_write("Modules now RULE THE WORLD !\n\n"); + monitor_write("Giving control to userland processes.\n\n"); sti(); schedule(); PANIC("Should never happen. Something probably went wrong with multitasking."); diff --git a/src/kernel/lib/bitset.h b/src/kernel/lib/bitset.h index f2441ce..efdb61d 100644 --- a/src/kernel/lib/bitset.h +++ b/src/kernel/lib/bitset.h @@ -14,6 +14,10 @@ struct bitset { void clear(uint32_t num); uint32_t test(uint32_t num); uint32_t firstFree(); + + size_t mem_size() { + return size/8; + } }; diff --git a/src/kernel/linker/elf.cpp b/src/kernel/linker/elf.cpp index 9477e8a..29689a2 100644 --- a/src/kernel/linker/elf.cpp +++ b/src/kernel/linker/elf.cpp @@ -27,7 +27,7 @@ thread_entry elf_load(uint8_t *data, process* process) { (new simpleseg(phdr[i].p_vaddr, phdr[i].p_memsz, (phdr[i].p_flags & PF_W) != 0))->map(process->pagedir, 0); memcpy((uint8_t*)phdr[i].p_vaddr, data + phdr[i].p_offset, phdr[i].p_filesz); if (phdr[i].p_memsz > phdr[i].p_filesz) { - memset((uint8_t*)phdr[i].p_vaddr + phdr[i].p_memsz, 0, phdr[i].p_memsz - phdr[i].p_filesz); + memset((uint8_t*)((size_t)phdr[i].p_vaddr + phdr[i].p_filesz), 0, phdr[i].p_memsz - phdr[i].p_filesz); } if (phdr[i].p_vaddr + phdr[i].p_memsz > dataseg) { dataseg = phdr[i].p_vaddr + phdr[i].p_memsz; diff --git a/src/kernel/mem/paging.cpp b/src/kernel/mem/paging.cpp index 8beee16..206cc08 100644 --- a/src/kernel/mem/paging.cpp +++ b/src/kernel/mem/paging.cpp @@ -38,8 +38,8 @@ void paging_init(size_t totalRam) { uint32_t i; frames.size = totalRam / 0x1000; - frames.bits = (uint32_t*)ksbrk(INDEX_FROM_BIT(frames.size)); - memset(frames.bits, 0, INDEX_FROM_BIT(frames.size)); + frames.bits = (uint32_t*)ksbrk(frames.mem_size()); + memset(frames.bits, 0, frames.mem_size()); kernel_pagedir = (page_directory*)ksbrk(sizeof(page_directory)); kernel_pagedir->mappedSegs = 0; diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp index 51219e0..92820f9 100644 --- a/src/kernel/task/task.cpp +++ b/src/kernel/task/task.cpp @@ -272,13 +272,13 @@ thread::thread(class process *proc, thread_entry entry_point, void *data, void * } /* Creates a new process. Creates a struct process and fills it up. */ -process::process(process* parent, uint32_t uid, uint32_t privilege) { +process::process(process* _parent, uint32_t _uid, uint32_t _privilege) { pid = (nextpid++); - uid = uid; + uid = _uid; thread_count = 0; threads = 0; - privilege = privilege; - parent = parent; + privilege = _privilege; + parent = _parent; pagedir = pagedir_new(); next = processes; data = 0; diff --git a/src/kernel/task/task.h b/src/kernel/task/task.h index 69b431d..301f8be 100644 --- a/src/kernel/task/task.h +++ b/src/kernel/task/task.h @@ -44,7 +44,6 @@ class thread { class process *process; uint32_t esp, ebp, eip; uint8_t state; - uint32_t timeWait; void* kernelStack_addr; uint32_t kernelStack_size; |