diff --git a/API.md b/API.md index 70f8531..0cf463b 100644 --- a/API.md +++ b/API.md @@ -9,6 +9,20 @@ All fonctions in the "libsys" library. ------ +`u32 testapi(u32 arg1, u32 arg2, u32 arg3);` + +*Description:Simple function to test if SYSCALL API is correctly running* + +* syscall id : **0** +* arguments : **3** +* * argument 1 : **u32 arg1** *first argument of your choice* +* * argument 2 : **u32 arg2** *second argument of your choice* +* * argument 3 : **u32 arg3** *third argument of your choice* +* results : **u32** +* dump of register cpu: **yes** + +------ + `u32 getticks(void);` *Description:Return the internal value of the timer* @@ -20,18 +34,6 @@ All fonctions in the "libsys" library. ------ -`void exit(u32 resultcode);` - -*Description:End a task for user or kernel domain* - -* syscall id : **5** -* arguments : **1** -* * argument 1 : **u32 resultcode** *Code result of the execution* -* results : **void** -* dump of register cpu: **no** - ------- - `u8 waitkey(void);` *Description:Wait for user to press a key and return the ascii code pressed* @@ -43,17 +45,15 @@ All fonctions in the "libsys" library. ------ -`u32 testapi(u32 arg1, u32 arg2, u32 arg3);` +`void exit(u32 resultcode);` -*Description:Simple function to test if SYSCALL API is correctly running* +*Description:End a task for user or kernel domain* -* syscall id : **0** -* arguments : **3** -* * argument 1 : **u32 arg1** *first argument of your choice* -* * argument 2 : **u32 arg2** *second argument of your choice* -* * argument 3 : **u32 arg3** *third argument of your choice* -* results : **u32** -* dump of register cpu: **yes** +* syscall id : **5** +* arguments : **1** +* * argument 1 : **u32 resultcode** *Code result of the execution* +* results : **void** +* dump of register cpu: **no** ### LIBVIDEO diff --git a/include/process.h b/include/process.h index 35df93b..62667b2 100644 --- a/include/process.h +++ b/include/process.h @@ -141,23 +141,26 @@ typedef struct task stack kernel_stack; u32 status; regs dump; + TAILQ_ENTRY(task) tailq; } task __attribute__ ((packed)); -typedef struct childs +typedef TAILQ_HEAD(task_s, task) task_t; + +typedef struct child { pid_t pid; - TAILQ_ENTRY(childs) tailq; -} childs __attribute__ ((packed)); + TAILQ_ENTRY(child) tailq; +} child __attribute__ ((packed)); -typedef TAILQ_HEAD(childs_s, childs) childs_t; +typedef TAILQ_HEAD(child_s, child) child_t; -typedef struct others +typedef struct other { pid_t pid; - TAILQ_ENTRY(others) tailq; -} others __attribute__ ((packed)); + TAILQ_ENTRY(other) tailq; +} other __attribute__ ((packed)); -typedef TAILQ_HEAD(others_s, others) others_t; +typedef TAILQ_HEAD(other_s, other) other_t; typedef struct process { @@ -166,8 +169,6 @@ typedef struct process bool iskernel; pd *pdd; s8 priority; - childs *allchilds; - others *allothers; u32 result; u8 status; u8 *exec_low; @@ -175,30 +176,39 @@ typedef struct process u8 *bss_low; u8 *bss_high; page_t page_head; + task_t task_head; + child_t child_head; + other_t other_head; u32 entry; } process __attribute__ ((packed)); - -pid_t getcurrentpid(); -pid_t getparentpid(); -pid_t getfreepid(); +pid_t getcurrentpid(void); +pid_t getparentpid(void); +pid_t getfreepid(void); void usepid(pid_t pid); +tid_t getcurrenttid(void); +tid_t maketid(pid_t pid, u32 number); -void stop(); -void wait(); -pid_t fork(); -pid_t clone(); +void stop(void); +void wait(void); +pid_t fork(void); +pid_t clone(void); pid_t exec(u8* entry, u8* args, bool kerneltask); -void switchtask(tid_t tid, bool fromkernelmode); -tid_t getnexttask(); +void switchtask(tid_t tid); +tid_t getnexttask(void); -tid_t createtask(pid_t pid,u8 *entry); -void deletetask(pid_t pid); +task* findtask(tid_t tid); +task* findcurrenttask(void); +process* findprocess(pid_t pid); +process* findcurrentprocess(void); + +tid_t createtask(pid_t pid,u8 *entry, bool kerneltask); +void deletetask(tid_t tid); void runtask(tid_t tid); -void stoptask(pid_t pid); +void stoptask(tid_t tid); -pid_t createprocess(u8 src, bool kerneltask); +pid_t createprocess(u8 *src, bool kerneltask); void deleteprocess(pid_t pid); void runprocess(pid_t pid); void stopprocess(pid_t pid); @@ -206,7 +216,7 @@ void stopprocess(pid_t pid); void setpriority(pid_t pid,s8 priority); -void initprocesses(); +void initprocesses(void); u32 iself(u8 * src); u32 loadelf(u8 * src, pid_t pid); diff --git a/lib/handlers.c b/lib/handlers.c index 49d610f..f32db15 100644 --- a/lib/handlers.c +++ b/lib/handlers.c @@ -139,7 +139,7 @@ __attribute__ ((noreturn)) void exception_handler(regs *dump) case 14: if (dump->cr2 >= USER_CODE && dump->cr2 < USER_STACK) { - virtual_range_new(getcurrentprocess()->pdd, + virtual_range_new(findcurrentprocess()->pdd, (u8 *) (dump->cr2 & 0xFFFFF000), PAGESIZE, PAGE_ALL); } diff --git a/lib/makefile b/lib/makefile index 68e0cd6..d3fd2b9 100755 --- a/lib/makefile +++ b/lib/makefile @@ -22,13 +22,13 @@ libs.o:$(OBJS) $(OBJASM) $(ASM) $^ handlers.o:handlers.c - $(CC) -mgeneral-regs-only $^ + $(CC) -mno-sse $^ keyboard.o:keyboard.c - $(CC) -mgeneral-regs-only $^ + $(CC) -mno-sse $^ mouse.o:mouse.c - $(CC) -mgeneral-regs-only $^ + $(CC) -mno-sse $^ syscall.o:syscall.c $(CC) -fomit-frame-pointer $^ diff --git a/lib/process.c b/lib/process.c index 24da76e..916c4a5 100644 --- a/lib/process.c +++ b/lib/process.c @@ -8,7 +8,7 @@ #include "gdt.h" process *processes; -pid_t current; +tid_t current; pid_t lastpid; @@ -74,10 +74,10 @@ u32 iself(u8 * src) } END */ -void processexit() +void processexit(void) { - deletetask(getcurrentpid()); - switchtask(0, false); + deleteprocess(getcurrentpid()); + switchtask(maketid(0,0)); } /*******************************************************************************/ @@ -94,7 +94,7 @@ u32 loadelf(u8 * src, pid_t pid) header = (elf32 *) src; program = (elf32p *) (src + header->e_phoff); - code = elf_test(src); + code = iself(src); if (code != 0) { printf("Erreur de chargement ELF, %s !\r\n", @@ -142,31 +142,31 @@ u32 loadelf(u8 * src, pid_t pid) /*******************************************************************************/ /* Initialise la liste des processus */ -void initprocesses() +void initprocesses(void) { u32 i = 1; processes = (process *) vmalloc(sizeof(process) * MAXNUMPROCESS); while (i < MAXNUMPROCESS) { processes[i].pid = NULL; - processes[i++].status = STATUS_FREE; + processes[i++].status = PROCESS_STATUS_FREE; } - createtask(0,getinitretry()); + createtask(0,getinitretry(),true); processes[0].result = 0; - processes[0].status = STATUS_READY; + processes[0].status = PROCESS_STATUS_READY; processes[0].iskernel = true; - current = 0; + current = maketid(0,0); lastpid = NULL; } /*******************************************************************************/ /* Récupère un emplacement dans la liste des processus */ -pid_t getfreepid() +pid_t getfreepid(void) { u32 i = lastpid; u32 parsed = 0; - while (processes[++i].status != STATUS_FREE + while (processes[++i].status != PROCESS_STATUS_FREE && ++parsed < MAXNUMPROCESS) { if (i >= MAXNUMPROCESS) @@ -181,13 +181,63 @@ pid_t getfreepid() } /*******************************************************************************/ -/* Récupère le PID du processus courant */ +/* Récupère un emplacement dans la liste des tâche du processus donné */ -pid_t getcurrentpid() +tid_t getfreeptid(pid_t pid) { - return current->pid; + tid_t new; + new.pid=pid; + task_t *task_head= &processes[(u32)pid].task_head; + task *next; + TAILQ_FOREACH(next, task_head, tailq) + if (next->tid.number>new.number) + new.number=next->tid.number; + next->tid.number++; + return new; } +/*******************************************************************************/ +/* Récupère le PID du processus courant */ + +pid_t getcurrentpid(void) +{ + return current.pid; +} + +/*******************************************************************************/ +/* Récupère le TID de la tâche courante */ + +tid_t getcurrenttid(void) +{ + return current; +} + +/*******************************************************************************/ +/* Change la tâche désigné dans le TID */ + +tid_t maketid(pid_t pid, u32 number) +{ + tid_t newtid; + newtid.pid=pid; + newtid.number=number; + return newtid; +} + +/*******************************************************************************/ +/* Récupère l'adresse d'un processus */ + +process* findprocess(pid_t pid) +{ + return &processes[(u32)pid]; +} + +/*******************************************************************************/ +/* Récupère l'adresse du processus courant */ + +process* findcurrentprocess(void) +{ + return &processes[(u32)getcurrentpid()]; +} /*******************************************************************************/ /* Determine le dernier PID occupé */ @@ -200,30 +250,55 @@ void usepid(pid_t pid) /*******************************************************************************/ /* Bascule vers une tâche */ -void switchtask(tid_t pid, bool fromkernelmode) +void switchtask(tid_t tid) { - pid_t previous = current; - current = &processes[(u32)pid]; - if (!current->kernel) - setTSS(current->kstack.ss0, current->kstack.esp0); + tid_t previous = current; + task *atask = findtask(tid); + process *aprocess=findprocess(tid.pid); + if (!aprocess->iskernel) + setTSS(atask->kernel_stack.ss0, atask->kernel_stack.esp0); else setTSS(0x0, 0x0); - current->dump.eflags = (current->dump.eflags | 0x200) & 0xFFFFBFFF; - createdump(current->dump); - if (current->dump.cs==SEL_KERNEL_CODE) + atask->dump.eflags = (atask->dump.eflags | 0x200) & 0xFFFFBFFF; + createdump(atask->dump); + if (atask->dump.cs==SEL_KERNEL_CODE) restcpu_kernel(); else restcpu_user(); iret(); } +/*******************************************************************************/ +/* Cherche l'adresse d'une tâche */ + +task* findtask(tid_t tid) +{ + task_t *task_head= &processes[(u32)tid.pid].task_head; + task *next; + TAILQ_FOREACH(next, task_head, tailq) + if (next->tid.number==tid.number) + return next; +} + +/*******************************************************************************/ +/* Cherche l'adresse de la tâche courante */ + +task* findcurrenttask(void) +{ + return findtask(getcurrenttid()); +} + + /*******************************************************************************/ /* Détruit une tâche */ void deletetask(tid_t tid) { - stoptask - + stoptask(tid); + process* aprocess=findprocess(tid.pid); + task *atask=findtask(tid); + TAILQ_REMOVE(&aprocess->task_head, atask, tailq); + vfree(atask); } /*******************************************************************************/ @@ -231,87 +306,65 @@ void deletetask(tid_t tid) void runtask(tid_t tid) { - if (processes[(u32)pid].status == STATUS_READY) + task *atask=findtask(tid); + if (atask->status == TASK_STATUS_READY) { - processes[(u32)pid].status = STATUS_RUN; - switchtask(u32)pid, false); + atask->status = TASK_STATUS_RUN; + switchtask(tid); } } /*******************************************************************************/ /* Initialise une tâche */ -tid_t createtask(pid_t pid,u8 *entry) +tid_t createtask(pid_t pid,u8 *entry, bool kerneltask) { - pid_t previous = current; - pid_t pid = getfreepid(); - usepid(pid); - page *kstack; - processes[(u32)pid].pid = (u32)pid; - processes[(u32)pid].pdd = virtual_pd_create(); - TAILQ_INIT(&processes[(u32)pid].page_head); - if (&processes[(u32)pid].iskernel) + tid_t tid; + tid.pid=pid; + process* aprocess=findprocess(pid); + task *new = (task *) vmalloc(sizeof(task)); + TAILQ_INSERT_TAIL(&aprocess->task_head, new, tailq); + page *astack = virtual_page_getfree(); + if (kerneltask) { - processes[(u32)pid].dump.ss = SEL_KERNEL_STACK; - processes[(u32)pid].dump.esp = - (u32) kstack->vaddr + PAGESIZE - 16; - processes[(u32)pid].dump.eflags = 0x0; - processes[(u32)pid].dump.cs = SEL_KERNEL_CODE; - processes[(u32)pid].dump.eip = elf_load(code, pid); - if (processes[(u32)pid].dump.eip == NULL) - return NULL; - processes[(u32)pid].dump.ds = SEL_KERNEL_DATA; - processes[(u32)pid].dump.es = SEL_KERNEL_DATA; - processes[(u32)pid].dump.fs = SEL_KERNEL_DATA; - processes[(u32)pid].dump.gs = SEL_KERNEL_DATA; - processes[(u32)pid].dump.cr3 = KERNEL_PD_ADDR; - processes[(u32)pid].dump.eax = 0; - processes[(u32)pid].dump.ecx = 0; - processes[(u32)pid].dump.edx = 0; - processes[(u32)pid].dump.ebx = 0; - processes[(u32)pid].dump.ebp = 0; - processes[(u32)pid].dump.esi = 0; - processes[(u32)pid].dump.edi = 0; - processes[(u32)pid].result = 0; - processes[(u32)pid].status = STATUS_READY; - processes[(u32)pid].kernel = true; - current = previous; + new->dump.ss = SEL_KERNEL_STACK; + new->dump.esp = + (u32) astack->vaddr + PAGESIZE - 16; + new->dump.eflags = 0x0; + new->dump.cs = SEL_KERNEL_CODE; + new->dump.ds = SEL_KERNEL_DATA; + new->dump.es = SEL_KERNEL_DATA; + new->dump.fs = SEL_KERNEL_DATA; + new->dump.gs = SEL_KERNEL_DATA; + new->dump.cr3 = KERNEL_PD_ADDR; } else { - current = &processes[(u32)pid]; - setCR3(processes[(u32)pid].pdd->addr->paddr); - kstack = virtual_page_getfree(); - processes[(u32)pid].dump.ss = SEL_USER_STACK | RPL_RING3; - processes[(u32)pid].dump.esp = USER_STACK - 16; - processes[(u32)pid].dump.eflags = 0x0; - processes[(u32)pid].dump.cs = SEL_USER_CODE | RPL_RING3; - processes[(u32)pid].dump.eip = elf_load(code, pid); - if (processes[(u32)pid].dump.eip == NULL) - return NULL; - processes[(u32)pid].dump.ds = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.es = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.fs = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.gs = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.cr3 = - (u32) processes[(u32)pid].pdd->addr->paddr; - processes[(u32)pid].kstack.ss0 = SEL_KERNEL_STACK; - processes[(u32)pid].kstack.esp0 = - (u32) kstack->vaddr + PAGESIZE - 16; - processes[(u32)pid].dump.eax = 0; - processes[(u32)pid].dump.ecx = 0; - processes[(u32)pid].dump.edx = 0; - processes[(u32)pid].dump.ebx = 0; - processes[(u32)pid].dump.ebp = 0; - processes[(u32)pid].dump.esi = 0; - processes[(u32)pid].dump.edi = 0; - processes[(u32)pid].result = 0; - processes[(u32)pid].status = STATUS_READY; - processes[(u32)pid].kernel = false; - current = previous; - setCR3(current->dump.cr3); + new->kernel_stack.ss0 = SEL_KERNEL_STACK; + new->kernel_stack.esp0 = + (u32) astack->vaddr + PAGESIZE - 16; + new->dump.ss = SEL_USER_STACK | RPL_RING3; + new->dump.esp = USER_STACK - 16; + new->dump.eflags = 0x0; + new->dump.cs = SEL_USER_CODE | RPL_RING3; + new->dump.ds = SEL_USER_DATA | RPL_RING3; + new->dump.es = SEL_USER_DATA | RPL_RING3; + new->dump.fs = SEL_USER_DATA | RPL_RING3; + new->dump.gs = SEL_USER_DATA | RPL_RING3; + new->dump.cr3 = aprocess->pdd->addr->paddr; } - return pid; + new->tid=getfreeptid(pid); + new->dump.eip = aprocess->entry; + new->status=TASK_STATUS_READY; + new->dump.eax = 0; + new->dump.ecx = 0; + new->dump.edx = 0; + new->dump.ebx = 0; + new->dump.ebp = 0; + new->dump.esi = 0; + new->dump.edi = 0; + new->status = TASK_STATUS_READY; + return new->tid; } /*******************************************************************************/ @@ -319,7 +372,8 @@ tid_t createtask(pid_t pid,u8 *entry) void stoptask(tid_t tid) { - + task *current=findtask(tid); + current->status=TASK_STATUS_STOP; } /*******************************************************************************/ @@ -327,69 +381,22 @@ void stoptask(tid_t tid) pid_t createprocess(u8 *src, bool kerneltask) { - pid_t previous = current; - pid_t pid = getfreepid(); - usepid(pid); - page *kstack; - processes[(u32)pid].pid = (u32)pid; - processes[(u32)pid].pdd = virtual_pd_create(); - TAILQ_INIT(&processes[(u32)pid].page_head); - processes[(u32)pid].entry = elf_load(code, pid); - -if (processes[(u32)pid].dump.eip == NULL) - return NULL; - processes[(u32)pid].dump.ds = SEL_KERNEL_DATA; - processes[(u32)pid].dump.es = SEL_KERNEL_DATA; - processes[(u32)pid].dump.fs = SEL_KERNEL_DATA; - processes[(u32)pid].dump.gs = SEL_KERNEL_DATA; - processes[(u32)pid].dump.cr3 = KERNEL_PD_ADDR; - processes[(u32)pid].dump.eax = 0; - processes[(u32)pid].dump.ecx = 0; - processes[(u32)pid].dump.edx = 0; - processes[(u32)pid].dump.ebx = 0; - processes[(u32)pid].dump.ebp = 0; - processes[(u32)pid].dump.esi = 0; - processes[(u32)pid].dump.edi = 0; - processes[(u32)pid].result = 0; - processes[(u32)pid].status = STATUS_READY; - processes[(u32)pid].kernel = true; - current = previous; - } - else - { - current = &processes[(u32)pid]; - setCR3(processes[(u32)pid].pdd->addr->paddr); - kstack = virtual_page_getfree(); - processes[(u32)pid].dump.ss = SEL_USER_STACK | RPL_RING3; - processes[(u32)pid].dump.esp = USER_STACK - 16; - processes[(u32)pid].dump.eflags = 0x0; - processes[(u32)pid].dump.cs = SEL_USER_CODE | RPL_RING3; - processes[(u32)pid].dump.eip = elf_load(code, pid); - if (processes[(u32)pid].dump.eip == NULL) - return NULL; - processes[(u32)pid].dump.ds = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.es = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.fs = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.gs = SEL_USER_DATA | RPL_RING3; - processes[(u32)pid].dump.cr3 = - (u32) processes[(u32)pid].pdd->addr->paddr; - processes[(u32)pid].kstack.ss0 = SEL_KERNEL_STACK; - processes[(u32)pid].kstack.esp0 = - (u32) kstack->vaddr + PAGESIZE - 16; - processes[(u32)pid].dump.eax = 0; - processes[(u32)pid].dump.ecx = 0; - processes[(u32)pid].dump.edx = 0; - processes[(u32)pid].dump.ebx = 0; - processes[(u32)pid].dump.ebp = 0; - processes[(u32)pid].dump.esi = 0; - processes[(u32)pid].dump.edi = 0; - processes[(u32)pid].result = 0; - processes[(u32)pid].status = STATUS_READY; - processes[(u32)pid].kernel = false; - current = previous; - setCR3(current->dump.cr3); - } - return pid; + tid_t previous = current; + current.pid = getfreepid(); + current.number = 0; + usepid(current.pid); + process* new=findcurrentprocess(); + new->pid = current.pid; + new->pdd = virtual_pd_create(); + TAILQ_INIT(&new->page_head); + new->iskernel=kerneltask; + setCR3(new->pdd->addr->paddr); + new->entry = loadelf(src, new->pid); + createtask(new->pid,new->entry, new->iskernel); + current = previous; + process* old=findcurrentprocess(); + setCR3(old->pdd->addr->paddr); + return new->pid; } /*******************************************************************************/ @@ -397,7 +404,13 @@ if (processes[(u32)pid].dump.eip == NULL) void deleteprocess(pid_t pid) { - + stopprocess(pid); + process* aprocess=findprocess(pid); + task *next; + TAILQ_FOREACH(next, &aprocess->task_head, tailq) + deletetask(next->tid); + aprocess->status = PROCESS_STATUS_FREE; + } /*******************************************************************************/ @@ -405,7 +418,15 @@ void deleteprocess(pid_t pid) void runprocess(pid_t pid) { - + process* aprocess=findprocess(pid); + if (aprocess->status == PROCESS_STATUS_READY) + { + aprocess->status = PROCESS_STATUS_RUN; + tid_t tid=maketid(pid,0); + task *atask=findtask(tid); + atask->status=TASK_STATUS_RUN; + switchtask(tid); + } } /*******************************************************************************/ @@ -413,7 +434,14 @@ void runprocess(pid_t pid) void stopprocess(pid_t pid) { - + process* aprocess=findprocess(pid); + if (aprocess->status == PROCESS_STATUS_RUN) + { + aprocess->status = PROCESS_STATUS_READY; + task *next; + TAILQ_FOREACH(next, &aprocess->task_head, tailq) + next->status=TASK_STATUS_READY; + } } /*******************************************************************************/ diff --git a/lib/shell.c b/lib/shell.c index 28efe85..b3674e7 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -19,6 +19,7 @@ #include "3D/man.c" #include "memory.h" #include "syscall.h" +#include "process.h" static command commands[] = { {"reboot", "", &rebootnow}, @@ -95,8 +96,8 @@ int test(void) int testtask() { print("*** Creation d'une tache\r\n"); - u32 pid = task_create(&programs_test, false); - task_run(pid); + pid_t pid = createprocess(&programs_test, false); + runprocess(pid); } /*******************************************************************************/ diff --git a/lib/syscall.c b/lib/syscall.c index 5acaf69..fbc96e3 100644 --- a/lib/syscall.c +++ b/lib/syscall.c @@ -62,20 +62,20 @@ __attribute__ ((noreturn)) void sysenter_handler(regs *dump) sti(); switch (dump->eax) { - case 4: - dump->eax=(u32) gettimer(); - break; - case 5: - exit(dump->ebx); - break; case 2: dump->eax=(u32) print(dump->ebx); break; + case 0: + dump->eax=(u32) testapi(dump->ebx, dump->esi, dump->edi, dump); + break; + case 4: + dump->eax=(u32) gettimer(); + break; case 1: dump->eax=(u32) waitascii(); break; - case 0: - dump->eax=(u32) testapi(dump->ebx, dump->esi, dump->edi, dump); + case 5: + processexit(dump->ebx); break; default: diff --git a/programs/include/libsys.h b/programs/include/libsys.h index 1f6bcf6..9f68378 100644 --- a/programs/include/libsys.h +++ b/programs/include/libsys.h @@ -4,8 +4,8 @@ #include "types.h"; -u32 getticks(void); -void exit(u32 resultcode); -u8 waitkey(void); u32 testapi(u32 arg1, u32 arg2, u32 arg3); +u32 getticks(void); +u8 waitkey(void); +void exit(u32 resultcode); diff --git a/programs/lib/libsys.c b/programs/lib/libsys.c index 362745c..6ba6c83 100644 --- a/programs/lib/libsys.c +++ b/programs/lib/libsys.c @@ -6,25 +6,25 @@ #include "syscall.h"; #include "types.h"; +u32 testapi(u32 arg1, u32 arg2, u32 arg3) +{ + return syscall3(0,(u32) arg1,(u32) arg2,(u32) arg3); +} + u32 getticks(void) { return syscall0(4); } +u8 waitkey(void) +{ + return syscall0(1); +} + void exit(u32 resultcode) { syscall1(5,(u32) resultcode); return; } -u8 waitkey(void) -{ - return syscall0(1); -} - -u32 testapi(u32 arg1, u32 arg2, u32 arg3) -{ - return syscall3(0,(u32) arg1,(u32) arg2,(u32) arg3); -} - diff --git a/syscalls.txt b/syscalls.txt index e7aa728..fdf2395 100644 --- a/syscalls.txt +++ b/syscalls.txt @@ -1,29 +1,5 @@ [ { -"ID":4, -"NAME":"getticks", -"LIBRARY":"libsys", -"INTERNALNAME":"gettimer", -"DESCRIPTION":"Return the internal value of the timer", -"ARGS": [], -"RETURN":"u32" -} - -, -{ -"ID":5, -"LIBRARY":"libsys", -"NAME":"exit", -"INTERNALNAME":"exit", -"DESCRIPTION":"End a task for user or kernel domain", -"ARGS": [ -{"TYPE":"u32","NAME":"resultcode","DESCRIPTION":"Code result of the execution"} -], -"RETURN":"void" -} - -, -{ "ID":2, "LIBRARY":"libvideo", "NAME":"print", @@ -35,17 +11,6 @@ "RETURN":"u32" } -, -{ -"ID":1, -"LIBRARY":"libsys", -"NAME":"waitkey", -"INTERNALNAME":"waitascii", -"DESCRIPTION":"Wait for user to press a key and return the ascii code pressed", -"ARGS": [], -"RETURN":"u8" -} - , { "ID":0, @@ -62,4 +27,39 @@ "DUMP":"yes" } +, +{ +"ID":4, +"NAME":"getticks", +"LIBRARY":"libsys", +"INTERNALNAME":"gettimer", +"DESCRIPTION":"Return the internal value of the timer", +"ARGS": [], +"RETURN":"u32" +} + +, +{ +"ID":1, +"LIBRARY":"libsys", +"NAME":"waitkey", +"INTERNALNAME":"waitascii", +"DESCRIPTION":"Wait for user to press a key and return the ascii code pressed", +"ARGS": [], +"RETURN":"u8" +} + +, +{ +"ID":5, +"LIBRARY":"libsys", +"NAME":"exit", +"INTERNALNAME":"processexit", +"DESCRIPTION":"End a task for user or kernel domain", +"ARGS": [ +{"TYPE":"u32","NAME":"resultcode","DESCRIPTION":"Code result of the execution"} +], +"RETURN":"void" +} + ] \ No newline at end of file diff --git a/system/system.c b/system/system.c index 768bf8b..dab3c5e 100644 --- a/system/system.c +++ b/system/system.c @@ -68,7 +68,7 @@ int main(u32 magic, u32 addr) print("\033[37m\033[0m -Initilisation des processus"); inittr(); initretry(&&retry); - task_init(); + initprocesses(); initsyscall(); ok();