From e87aedb02e5f49f347d76515d06c216b52716338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Tue, 4 Dec 2018 00:05:55 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20debut=20impl=C3=A9mentation=20de=20syse?= =?UTF-8?q?nter=20/=20sysexit=20et=20test=20depuis=20shell.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/shell.h | 1 + include/syscall.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++ lib/shell.c | 12 +++++++- 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/include/shell.h b/include/shell.h index e983d98..4219f15 100644 --- a/include/shell.h +++ b/include/shell.h @@ -30,3 +30,4 @@ int logo(); int detectpci(); int mem(); int testmem(); +int testsyscall(); diff --git a/include/syscall.h b/include/syscall.h index 04f53ae..4910067 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -1,5 +1,79 @@ /*******************************************************************************/ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* */ + +#define sysexit \ + asm volatile ("sysexit"::"c"); + + +static inline long syscall(long syscall) { +long ret; +asm volatile ( +"mov %%esp,%%ecx;\ +mov $1f,%%edx;\ +sysenter;\ +1:" : "=a" (ret) : "a" (syscall): "ecx","edx","memory"); +return ret; +} + +static inline long syscall1(long syscall, long arg1) { +long ret; +asm volatile ( +"mov %%esp,%%ecx;\ +mov $1f,%%edx;\ +sysenter;\ +1:" : "=a" (ret) : "a" (syscall), "b" (arg1) : "ecx","edx","memory"); +return ret; +} + +static inline long syscall2(long syscall, long arg1, long arg2) { +long ret; +asm volatile ( +"mov %%esp,%%ecx;\ +mov $1f,%%edx;\ +sysenter;\ +1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2) : "ecx","edx","memory"); +return ret; +} + +static inline long syscall3(long syscall, long arg1, long arg2, long arg3) { +long ret; +asm volatile ( +"mov %%esp,%%ecx;\ +mov $1f,%%edx;\ +sysenter;\ +1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory"); +return ret; +} + +/*static inline long syscall4(long syscall, long arg1, long arg2, long arg3, long arg4) { +long ret; +asm volatile ("mov %%esp,%%ecx; +"mov $1f,%%edx; +"sysenter; +1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "c" (arg2), +"d" (arg3), "S" (arg4) : “memory”); +return ret; +} + +static inline long syscall5(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5) { +long ret; +asm volatile ("mov %%esp,%%ecx; +"mov $1f,%%edx; +"sysenter; +1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "c" (arg2), +"d" (arg3), "S" (arg4), "D" (arg5) : “memory”); +return ret; +} + +static inline long syscall6(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) { +long ret; +asm volatile ("mov %%esp,%%ecx; +"mov $1f,%%edx; +"sysenter; +1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "c" (arg2), +"d" (arg3), "S" (arg4), "D", (arg5), "d" (arg6) : “memory”); +return ret; +}*/ void initsyscall(void); void sysenter_handler(void); diff --git a/lib/shell.c b/lib/shell.c index 2e98678..ccc30a2 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -18,6 +18,7 @@ #include "3D/sphere.c" #include "3D/man.c" #include "memory.h" +#include "syscall.h" static command commands[] = { {"reboot" , "", &rebootnow}, @@ -42,7 +43,7 @@ static command commands[] = { {"detectpci" , "", &detectpci}, {"mem" , "", &mem}, {"testmem" , "", &testmem}, - + {"testsyscall" , "", &testsyscall}, }; /*******************************************************************************/ @@ -82,6 +83,15 @@ int test(void) return; } +/*******************************************************************************/ +/* Test l'usage de syscall */ +int testsyscall() +{ + print("*** avant appel"); + syscall2(0x0, 0x1980, 0x2505); + print("*** apres appel"); +} + /*******************************************************************************/ /* Test la memoire */ int testmem()