summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-18 13:42:09 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-18 13:42:09 +0200
commit1ecb3fb821f49450ba4b08ad7d7a23d3acb75c47 (patch)
treecd7f14d2659809286e59c929e91fe5c02c138002 /src/kernel
parentf56aa2f7e4b8e6430e123f714507032a33955a09 (diff)
downloadTCE-1ecb3fb821f49450ba4b08ad7d7a23d3acb75c47.tar.gz
TCE-1ecb3fb821f49450ba4b08ad7d7a23d3acb75c47.zip
Improvements. Next: initrd.
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/core/kmain.cpp6
-rw-r--r--src/kernel/linker/elf.cpp2
-rw-r--r--src/kernel/linker/elf.h2
-rw-r--r--src/kernel/task/sched.cpp1
4 files changed, 6 insertions, 5 deletions
diff --git a/src/kernel/core/kmain.cpp b/src/kernel/core/kmain.cpp
index 314c033..9ec06df 100644
--- a/src/kernel/core/kmain.cpp
+++ b/src/kernel/core/kmain.cpp
@@ -77,15 +77,15 @@ extern "C" void kmain(multiboot_info_t* mbd, int32_t magic) {
*ke_vt << "Loading modules :\n";
for (unsigned i = 0; i < mbd->mods_count; i++) {
*ke_vt << " * " << (char*)mods[i].string;
- if (elf_check((uint8_t*)mods[i].mod_start)) {
- *ke_vt << " : Invalid ELF file\n";
- } else {
+ if (elf_check((uint8_t*)mods[i].mod_start) == 0) {
process *pr = elf_exec((uint8_t*)mods[i].mod_start, PL_USER);
if (pr == 0) {
*ke_vt << " : Error loading\n";
} else {
*ke_vt << " : OK, pid=" << (int)pr->pid << "\n";
}
+ } else {
+ *ke_vt << " : Invalid ELF file\n";
}
}
diff --git a/src/kernel/linker/elf.cpp b/src/kernel/linker/elf.cpp
index c6aebaa..0375e40 100644
--- a/src/kernel/linker/elf.cpp
+++ b/src/kernel/linker/elf.cpp
@@ -7,7 +7,7 @@
int elf_check(uint8_t *data) {
elf_ehdr *h = (elf_ehdr*)data;
if (h->e_ident[0] == 0x7F && h->e_ident[1] == 'E' && h->e_ident[2] == 'L' && h->e_ident[3] == 'F') return 0;
- return 1;
+ return -1;
}
thread_entry elf_load(uint8_t *data, process* process) {
diff --git a/src/kernel/linker/elf.h b/src/kernel/linker/elf.h
index bb61795..184f410 100644
--- a/src/kernel/linker/elf.h
+++ b/src/kernel/linker/elf.h
@@ -56,7 +56,7 @@ struct phdr {
uint8_t* data;
};
-int elf_check(uint8_t *data); //0 if ok, 1 if not a valid ELF
+int elf_check(uint8_t *data); //0 if ok, -1 if not a valid ELF
thread_entry elf_load(uint8_t *data, process* process); //Load an ELF to a process, return entry point
process* elf_exec(uint8_t *data, int privilege); //Creates a new process and a thread for running ELF file
diff --git a/src/kernel/task/sched.cpp b/src/kernel/task/sched.cpp
index 2629a33..d7e16d2 100644
--- a/src/kernel/task/sched.cpp
+++ b/src/kernel/task/sched.cpp
@@ -1,6 +1,7 @@
#include "sched.h"
#include <core/sys.h>
#include <mem/mem.h>
+#include <ui/vt.h>
// Lower priority numbers have high priority. Priorities must start at 0.
#define PRIORITIES 3 // we have 3 priority levels