diff options
author | Alexis211 <alexis211@gmail.com> | 2010-02-09 12:44:06 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2010-02-09 12:44:06 +0100 |
commit | 4886faa3dce410543eda2139221e03959e73a747 (patch) | |
tree | e74cedd7b8a89005c802ddd3ce38f7ab5b8c4fb4 /src/kernel/core | |
parent | 6a52d123672b7a00af6e22b4c138205be2042a94 (diff) | |
download | TCE-4886faa3dce410543eda2139221e03959e73a747.tar.gz TCE-4886faa3dce410543eda2139221e03959e73a747.zip |
Added user mode support and monitor_writeDec
Diffstat (limited to 'src/kernel/core')
-rw-r--r-- | src/kernel/core/kmain.c | 2 | ||||
-rw-r--r-- | src/kernel/core/monitor.c | 21 | ||||
-rw-r--r-- | src/kernel/core/monitor.h | 3 | ||||
-rw-r--r-- | src/kernel/core/sys.c | 3 | ||||
-rw-r--r-- | src/kernel/core/sys.h | 2 |
5 files changed, 29 insertions, 2 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c index ef92dff..4a4da05 100644 --- a/src/kernel/core/kmain.c +++ b/src/kernel/core/kmain.c @@ -49,7 +49,7 @@ void kmain(struct multiboot_info_t* mbd, int32_t magic) { if (elf_check((uint8_t*)mods[i].mod_start)) { monitor_write(" : Invalid ELF file\n"); } else { - if (elf_exec((uint8_t*)mods[i].mod_start) == 0) { + if (elf_exec((uint8_t*)mods[i].mod_start, PL_SERVICE) == 0) { monitor_write(" : Error loading\n"); } else { monitor_write(" : OK\n"); diff --git a/src/kernel/core/monitor.c b/src/kernel/core/monitor.c index 8c4744a..6660fe0 100644 --- a/src/kernel/core/monitor.c +++ b/src/kernel/core/monitor.c @@ -88,3 +88,24 @@ void monitor_writeHex(uint32_t v) { v = v << 4; } } + +void monitor_writeDec(uint32_t v) { + if (v == 0) { + monitor_put('0'); + return; + } + + char numbers[] = "0123456789"; + while (v > 0) { + int order = 1, no = 1; + while (v / order > 0) order *= 10; + order /= 10; + monitor_put(numbers[v / order]); + v = v - (v / order * order); + while (v / no > 0) no *= 10; + while (no < order) { + monitor_put('0'); + no *= 10; + } + } +} diff --git a/src/kernel/core/monitor.h b/src/kernel/core/monitor.h index 3abe072..19201ed 100644 --- a/src/kernel/core/monitor.h +++ b/src/kernel/core/monitor.h @@ -7,6 +7,9 @@ void monitor_put(char c); void monitor_clear(); void monitor_write(char *s); void monitor_writeHex(uint32_t v); +void monitor_writeDec(uint32_t v); + +#define NL monitor_put("\n"); #endif diff --git a/src/kernel/core/sys.c b/src/kernel/core/sys.c index d31c20e..1045cff 100644 --- a/src/kernel/core/sys.c +++ b/src/kernel/core/sys.c @@ -23,7 +23,8 @@ uint16_t inw(uint16_t port) { void panic(char* message, char* file, int line) { monitor_write("\n>> PANIC: >>"); - monitor_write(message); monitor_write("<< in file "); monitor_write(file); + monitor_write(message); monitor_write("<< at "); monitor_write(file); + monitor_write(":"); monitor_writeDec(line); monitor_write("\nSystem halted T_T"); asm volatile("cli; hlt"); } diff --git a/src/kernel/core/sys.h b/src/kernel/core/sys.h index 76e3560..2f8cd5e 100644 --- a/src/kernel/core/sys.h +++ b/src/kernel/core/sys.h @@ -14,4 +14,6 @@ void panic(char* message, char* file, int line); void sti(); //GLOBAL SYSTEM MUTEX void cli(); +#define WHERE { monitor_write("(kernel:"); monitor_write(__FILE__); monitor_write(":"); monitor_writeDec(__LINE__); monitor_write(") "); } + #endif |