summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-02-09 17:48:38 +0100
committerAlexis211 <alexis211@gmail.com>2010-02-09 17:48:38 +0100
commit3e1998280319e8060e797ca39b3b0b1bc766d569 (patch)
tree045c5a3e7d12a499a8f107e1223ae6880600a8c1 /src/kernel
parent4886faa3dce410543eda2139221e03959e73a747 (diff)
downloadTCE-3e1998280319e8060e797ca39b3b0b1bc766d569.tar.gz
TCE-3e1998280319e8060e797ca39b3b0b1bc766d569.zip
Added thread_new syscall
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/core/kmain.c2
-rw-r--r--src/kernel/core/monitor.h2
-rw-r--r--src/kernel/task/syscall.c16
-rw-r--r--src/kernel/task/task.c9
4 files changed, 21 insertions, 8 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index 4a4da05..0a94fde 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, PL_SERVICE) == 0) {
+ if (elf_exec((uint8_t*)mods[i].mod_start, PL_DRIVER) == 0) {
monitor_write(" : Error loading\n");
} else {
monitor_write(" : OK\n");
diff --git a/src/kernel/core/monitor.h b/src/kernel/core/monitor.h
index 19201ed..f4605cf 100644
--- a/src/kernel/core/monitor.h
+++ b/src/kernel/core/monitor.h
@@ -9,7 +9,7 @@ void monitor_write(char *s);
void monitor_writeHex(uint32_t v);
void monitor_writeDec(uint32_t v);
-#define NL monitor_put("\n");
+#define NL monitor_put('\n');
#endif
diff --git a/src/kernel/task/syscall.c b/src/kernel/task/syscall.c
index 5aab011..8195dd0 100644
--- a/src/kernel/task/syscall.c
+++ b/src/kernel/task/syscall.c
@@ -1,21 +1,29 @@
#include "syscall.h"
+#include "task.h"
#define CALL0(name, scname) static void scname(struct registers* r) { r->eax = name(); }
#define CALL1(name, scname) static void scname(struct registers* r) { \
r->eax = name(r->ebx); }
#define CALL2(name, scname) static void scname(struct registers* r) { \
r->eax = name(r->ebx, r->ecx); }
+#define CALL0V(name, scname) static void scname(struct registers* r) { name(); }
+#define CALL1V(name, scname) static void scname(struct registers* r) { name(r->ebx); }
-CALL0(thread_exit, thread_exit_sc);
-CALL0(tasking_switch, schedule_sc);
-CALL1(thread_sleep, thread_sleep_sc);
-CALL1(process_exit, process_exit_sc);
+CALL0V(thread_exit, thread_exit_sc);
+CALL0V(tasking_switch, schedule_sc);
+CALL1V(thread_sleep, thread_sleep_sc);
+CALL1V(process_exit, process_exit_sc);
CALL1(monitor_write, printk_sc);
+static void thread_new_sc(struct registers* r) {
+ thread_new(current_thread->process, (thread_entry)r->ebx, (void*)r->ecx);
+}
+
int_callback syscalls[] = {
thread_exit_sc,
schedule_sc,
thread_sleep_sc,
process_exit_sc,
printk_sc,
+ thread_new_sc,
0 };
diff --git a/src/kernel/task/task.c b/src/kernel/task/task.c
index a37d44b..8cdf7b3 100644
--- a/src/kernel/task/task.c
+++ b/src/kernel/task/task.c
@@ -107,8 +107,13 @@ uint32_t tasking_handleException(struct registers *regs) {
"Page Fault","Unknown Interrupt","Coprocessor Fault","Alignment Check","Machine Check"};
monitor_write(exception_messages[regs->int_no]);
monitor_write(" at "); monitor_writeHex(regs->eip);
- monitor_write("\n>>> Thread exiting.\n");
- thread_exit_stackJmp(EX_TH_EXCEPTION);
+ if (regs->int_no == 14) {
+ monitor_write("\n>>> Process exiting.\n");
+ thread_exit_stackJmp(EX_PR_EXCEPTION);
+ } else {
+ monitor_write("\n>>> Thread exiting.\n");
+ thread_exit_stackJmp(EX_TH_EXCEPTION);
+ }
PANIC("This should never have happened. Please report this.");
}