From b6924d994ccdbe86ea67351d3c94600e14f5ed1f Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 17 May 2012 09:55:40 +0200 Subject: Nothing, just reverted some shit. --- Makefile | 4 ++-- doc/syscalls.txt | 24 ++++++++++++------------ src/kernel/task/syscall.cpp | 26 +++++++++++--------------- src/user/lib/tce/syscall.c | 22 +++++++++++----------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index c5667d0..d63478d 100644 --- a/Makefile +++ b/Makefile @@ -48,8 +48,8 @@ bochs: all floppy bochs -f bochs.cfg qemu: all floppy - $(QemuCmd) -fda $(Floppy) -m 16 + $(QemuCmd) -fda $(Floppy) -m 32 qemu-gdb: all floppy - $(QemuCmd) -fda $(Floppy) -m 16 -s -S & gdb src/kernel/kernel.elf -x gdb-cmd + $(QemuCmd) -fda $(Floppy) -m 32 -s -S & gdb src/kernel/kernel.elf -x gdb-cmd diff --git a/doc/syscalls.txt b/doc/syscalls.txt index bb53a45..952b95e 100644 --- a/doc/syscalls.txt +++ b/doc/syscalls.txt @@ -1,22 +1,22 @@ -Syscalls pass by int64. The identifier of the called function is in ebx, with -eax = 0, parameters are in ecx, edx, esi, edi. +Syscalls pass by int64. The identifier of the called function is in eax, +parameters are in ebx, ecx, edx, esi, edi. Syscall list : -id=ebx Name Parameters Description +id=eax Name Parameters Description 1 thread_exit none Signal kernel that current thread has finished 2 schedule none Switch to next thread (might be the current one) - 3 thread_sleep ecx: time (int) msecs Tell kernel to put current thread to sleep - 4 process_exit ecx: return value (int) Tell kernel to end current process, cleaning up everything - 5 printk ecx: addr of a string Print a message to screen - 6 thread_new ecx: entry point Creates a new thread - edx: data pointer - esi: stack pointer - 7 irq_wait ecx: irq number Waits for an IRQ (requires privilege PL_DRIVER) + 3 thread_sleep ebx: time (int) msecs Tell kernel to put current thread to sleep + 4 process_exit ebx: return value (int) Tell kernel to end current process, cleaning up everything + 5 printk ebx: addr of a string Print a message to screen + 6 thread_new ebx: entry point Creates a new thread + ecx: data pointer + edx: stack pointer + 7 irq_wait ebx: irq number Waits for an IRQ (requires privilege PL_DRIVER) 8 proc_priv none Returns current process privilege level - 9 sbrk ecx: size Allocates some memory - 10 brk ecx: new_end Allocates/frees some memory + 9 sbrk ebx: size Allocates some memory + 10 brk ebx: new_end Allocates/frees some memory 11 mmap (see linux specs) not implemented 12 munmap (see linux specs) not implemented diff --git a/src/kernel/task/syscall.cpp b/src/kernel/task/syscall.cpp index 7938e76..678677d 100644 --- a/src/kernel/task/syscall.cpp +++ b/src/kernel/task/syscall.cpp @@ -6,16 +6,16 @@ #define CALL0(name, scname) static void scname(registers* r) { r->eax = name(); } #define CALL1(name, scname) static void scname(registers* r) { \ - r->eax = name(r->ecx); } + r->eax = name(r->ebx); } #define CALL2(name, scname) static void scname(registers* r) { \ - r->eax = name(r->ecx, r->edx); } + r->eax = name(r->ebx, r->ecx); } #define CALL3(name, scname) static void scname(registers* r) { \ - r->eax = name(r->ecx, r->edx, r->esi); } + r->eax = name(r->ebx, r->ecx, r->edx); } #define CALL0V(name, scname) static void scname(registers* r) { name(); } -#define CALL1V(name, scname) static void scname(registers* r) { name(r->ecx); } -#define CALL2V(name, scname) static void scname(registers* r) { name(r->ecx, r->edx); } -#define CALL3V(name, scname) static void scname(registers* r) { name(r->ecx, r->edx, r->esi); } -#define CALL4V(name, scname) static void scname(registers* r) { name(r->ecx, r->edx, r->esi, r->edi); } +#define CALL1V(name, scname) static void scname(registers* r) { name(r->ebx); } +#define CALL2V(name, scname) static void scname(registers* r) { name(r->ebx, r->ecx); } +#define CALL3V(name, scname) static void scname(registers* r) { name(r->ebx, r->ecx, r->edx); } +#define CALL4V(name, scname) static void scname(registers* r) { name(r->ebx, r->ecx, r->edx, r->esi); } CALL0V(thread_exit, thread_exit_sc); CALL0V(schedule, schedule_sc); @@ -27,12 +27,12 @@ CALL1(process_sbrk, proc_sbrk_sc); CALL1V(process_brk, proc_brk_sc); static void printk_sc(registers *r) { - monitor_write((char*)r->ecx); + monitor_write((char*)r->ebx); } static void thread_new_sc(registers* r) { cli(); - new thread(current_thread->process, (thread_entry)r->ecx, (void*)r->edx, (void*)r->esi); + new thread(current_thread->process, (thread_entry)r->ebx, (void*)r->ecx, (void*)r->edx); sti(); } @@ -54,11 +54,7 @@ int_callback syscalls[NUMBER_OF_SYSCALLS] = { // This must correspond to common /* Called in idt_.asm on a system call (interrupt 64). Calls the correct syscall handler (if any). */ extern "C" void idt_syscallHandler(registers regs) { - if (regs.eax == 0) { - if (regs.ebx < NUMBER_OF_SYSCALLS && syscalls[regs.ebx] != 0) { - syscalls[regs.ebx](®s); - } - } else { - monitor_write("Hello. Object calls not implemented.\n"); + if (regs.eax < NUMBER_OF_SYSCALLS && syscalls[regs.eax] != 0) { + syscalls[regs.eax](®s); } } diff --git a/src/user/lib/tce/syscall.c b/src/user/lib/tce/syscall.c index d606491..c7965a9 100644 --- a/src/user/lib/tce/syscall.c +++ b/src/user/lib/tce/syscall.c @@ -9,23 +9,23 @@ static size_t call(size_t a, size_t b, size_t c, size_t d, size_t e, size_t f) { } void thread_exit() { - call(0, SC_THREAD_EXIT, 0, 0, 0, 0); + call(SC_THREAD_EXIT, 0, 0, 0, 0, 0); } void schedule() { - call(0, SC_SCHEDULE, 0, 0,0, 0); + call(SC_SCHEDULE, 0, 0,0, 0, 0); } void thread_sleep(int time) { - call(0, SC_THREAD_SLEEP, time, 0, 0, 0); + call(SC_THREAD_SLEEP, time, 0, 0, 0, 0); } void process_exit(int retval) { - call(0, SC_PROCESS_EXIT, retval, 0, 0, 0); + call(SC_PROCESS_EXIT, retval, 0, 0, 0, 0); } void printk(char* str) { - call(0, SC_PRINTK, (unsigned)str, 0, 0, 0); + call(SC_PRINTK, (unsigned)str, 0, 0, 0, 0); } //THREAD CREATION @@ -44,28 +44,28 @@ void thread_start(void *data) { if (_stack_to_free != 0) free(_stack_to_free); _stack_to_free = tsd->stack; asm volatile("movl %0, (_stack_freeing_mutex); int $64;" :: - "a"(0), "b"(SC_THREAD_EXIT), "r"(MUTEX_UNLOCKED)); + "a"(SC_THREAD_EXIT), "r"(MUTEX_UNLOCKED)); } void thread_new(void (*entry)(void*), void *data) { struct thread_start_data *tsd = malloc(sizeof(struct thread_start_data)); tsd->entry = entry; tsd->data = data; tsd->stack = malloc(NEW_STACK_SIZE); - call(0, SC_THREAD_NEW, (unsigned)thread_start, (unsigned)tsd, (unsigned)(tsd->stack + NEW_STACK_SIZE), 0); + call(SC_THREAD_NEW, (unsigned)thread_start, (unsigned)tsd, (unsigned)(tsd->stack + NEW_STACK_SIZE), 0, 0); } void irq_wait(int number) { - call(0, SC_IRQ_WAIT, number, 0, 0, 0); + call(SC_IRQ_WAIT, number, 0, 0, 0, 0); } int proc_priv() { - return call(0, SC_PROC_PRIV, 0, 0, 0, 0); + return call(SC_PROC_PRIV, 0, 0, 0, 0, 0); } void* sbrk(size_t s) { - return (void*)call(0, SC_SBRK, s, 0, 0, 0); + return (void*)call(SC_SBRK, s, 0, 0, 0, 0); } void brk(void* ptr) { - return call (0, SC_BRK, ptr, 0, 0, 0); + return call (SC_BRK, ptr, 0, 0, 0, 0); } -- cgit v1.2.3