summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-17 11:27:59 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-17 11:27:59 +0200
commit1c7c106b06b6a88502801e699ef99e72b7c625cd (patch)
tree5708a229b0d66e8eb82a953861e017915f8176b6
parent5bc8549a8d7f5c9644f878fe3ca55761663a2fd0 (diff)
downloadTCE-1c7c106b06b6a88502801e699ef99e72b7c625cd.tar.gz
TCE-1c7c106b06b6a88502801e699ef99e72b7c625cd.zip
Fixed some nasty bugs.
-rw-r--r--README2
-rw-r--r--gdb-cmd2
-rw-r--r--src/common.make4
-rw-r--r--src/kernel/Makefile2
-rw-r--r--src/kernel/core/kmain.cpp4
-rw-r--r--src/kernel/lib/bitset.h4
-rw-r--r--src/kernel/linker/elf.cpp2
-rw-r--r--src/kernel/mem/paging.cpp4
-rw-r--r--src/kernel/task/task.cpp8
-rw-r--r--src/kernel/task/task.h1
-rw-r--r--src/user/lib/Makefile2
-rw-r--r--src/user/test/main.c8
12 files changed, 23 insertions, 20 deletions
diff --git a/README b/README
index ac7682b..9c2262b 100644
--- a/README
+++ b/README
@@ -4,5 +4,3 @@ Yet another hobby OS project - based on my old Grapes project.
To compile T/CE, you will need a i586-elf gcc cross-compiler.
You can find some scripts to build cross-compilers here :
http://github.com/Alexis211/cross-scripts
-
-You will also need a grub floppy named TCE.fl.img
diff --git a/gdb-cmd b/gdb-cmd
index 4c32a6e..75541f9 100644
--- a/gdb-cmd
+++ b/gdb-cmd
@@ -1,2 +1,2 @@
target remote localhost:1234
-break core/sys.c:panic_do
+break core/sys.cpp:panic_do
diff --git a/src/common.make b/src/common.make
index 5ea9ae9..be6a302 100644
--- a/src/common.make
+++ b/src/common.make
@@ -1,10 +1,10 @@
# ============== ENVIRONMENT VARIABLES
CC = i586-elf-gcc
-CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra
+CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -g
CCFLAGS =
CXX = i586-elf-g++
-CXXFLAGS = -fno-rtti -fno-exceptions -Werror -Wno-write-strings -Wno-error=unused-parameter
+CXXFLAGS = -fno-rtti -fno-exceptions -Werror -Wno-write-strings -Wno-error=unused-parameter -g
LD = i586-elf-ld
.PHONY: clean, mrproper
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;
diff --git a/src/user/lib/Makefile b/src/user/lib/Makefile
index 4019e88..ff916bf 100644
--- a/src/user/lib/Makefile
+++ b/src/user/lib/Makefile
@@ -6,7 +6,7 @@ ExtObj = $(SrcPath)/common/_common.o
include $(SrcPath)/common.make
-CFLAGS = -I$(SrcPath)/common/include -I$(SrcPath)/user/lib/include
+CFLAGS += -I$(SrcPath)/common/include -I$(SrcPath)/user/lib/include
LDFLAGS += -r
diff --git a/src/user/test/main.c b/src/user/test/main.c
index 945c530..ec14c21 100644
--- a/src/user/test/main.c
+++ b/src/user/test/main.c
@@ -28,12 +28,14 @@ void thread_cascade(void* d) {
}
int main() {
- printk("Hi world from test module !\n");
+ printk("(test app) malloc(42) = ");
+ printk_hex((uint32_t)malloc(42));
+ printk("\n");
- printk(" -> Creating thread cascade (total 2**8 = 256 threads)\n");
+ printk("(test app) Creating thread cascade (total 2**8 = 256 threads)\n");
thread_new(thread_cascade, (void*)8);
- printk(" -> Main thread now sleeping... forever...\n");
+ printk("(test app) Main thread now sleeping... forever...\n");
while (1) {
thread_sleep(1000);
}