feat: gestion des processus & tâches, compilation ok mais système figé au démarrage

This commit is contained in:
Nicolas Hordé 2018-12-19 12:06:05 +01:00
parent d2f28e6795
commit dd3e40d53e
11 changed files with 308 additions and 269 deletions

42
API.md
View File

@ -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);` `u32 getticks(void);`
*Description:Return the internal value of the timer* *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);` `u8 waitkey(void);`
*Description:Wait for user to press a key and return the ascii code pressed* *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** * syscall id : **5**
* arguments : **3** * arguments : **1**
* * argument 1 : **u32 arg1** *first argument of your choice* * * argument 1 : **u32 resultcode** *Code result of the execution*
* * argument 2 : **u32 arg2** *second argument of your choice* * results : **void**
* * argument 3 : **u32 arg3** *third argument of your choice* * dump of register cpu: **no**
* results : **u32**
* dump of register cpu: **yes**
### LIBVIDEO ### LIBVIDEO

View File

@ -141,23 +141,26 @@ typedef struct task
stack kernel_stack; stack kernel_stack;
u32 status; u32 status;
regs dump; regs dump;
TAILQ_ENTRY(task) tailq;
} task __attribute__ ((packed)); } task __attribute__ ((packed));
typedef struct childs typedef TAILQ_HEAD(task_s, task) task_t;
typedef struct child
{ {
pid_t pid; pid_t pid;
TAILQ_ENTRY(childs) tailq; TAILQ_ENTRY(child) tailq;
} childs __attribute__ ((packed)); } 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; pid_t pid;
TAILQ_ENTRY(others) tailq; TAILQ_ENTRY(other) tailq;
} others __attribute__ ((packed)); } other __attribute__ ((packed));
typedef TAILQ_HEAD(others_s, others) others_t; typedef TAILQ_HEAD(other_s, other) other_t;
typedef struct process typedef struct process
{ {
@ -166,8 +169,6 @@ typedef struct process
bool iskernel; bool iskernel;
pd *pdd; pd *pdd;
s8 priority; s8 priority;
childs *allchilds;
others *allothers;
u32 result; u32 result;
u8 status; u8 status;
u8 *exec_low; u8 *exec_low;
@ -175,30 +176,39 @@ typedef struct process
u8 *bss_low; u8 *bss_low;
u8 *bss_high; u8 *bss_high;
page_t page_head; page_t page_head;
task_t task_head;
child_t child_head;
other_t other_head;
u32 entry; u32 entry;
} process __attribute__ ((packed)); } process __attribute__ ((packed));
pid_t getcurrentpid(void);
pid_t getcurrentpid(); pid_t getparentpid(void);
pid_t getparentpid(); pid_t getfreepid(void);
pid_t getfreepid();
void usepid(pid_t pid); void usepid(pid_t pid);
tid_t getcurrenttid(void);
tid_t maketid(pid_t pid, u32 number);
void stop(); void stop(void);
void wait(); void wait(void);
pid_t fork(); pid_t fork(void);
pid_t clone(); pid_t clone(void);
pid_t exec(u8* entry, u8* args, bool kerneltask); pid_t exec(u8* entry, u8* args, bool kerneltask);
void switchtask(tid_t tid, bool fromkernelmode); void switchtask(tid_t tid);
tid_t getnexttask(); tid_t getnexttask(void);
tid_t createtask(pid_t pid,u8 *entry); task* findtask(tid_t tid);
void deletetask(pid_t pid); 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 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 deleteprocess(pid_t pid);
void runprocess(pid_t pid); void runprocess(pid_t pid);
void stopprocess(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 setpriority(pid_t pid,s8 priority);
void initprocesses(); void initprocesses(void);
u32 iself(u8 * src); u32 iself(u8 * src);
u32 loadelf(u8 * src, pid_t pid); u32 loadelf(u8 * src, pid_t pid);

View File

@ -139,7 +139,7 @@ __attribute__ ((noreturn)) void exception_handler(regs *dump)
case 14: case 14:
if (dump->cr2 >= USER_CODE && dump->cr2 < USER_STACK) if (dump->cr2 >= USER_CODE && dump->cr2 < USER_STACK)
{ {
virtual_range_new(getcurrentprocess()->pdd, virtual_range_new(findcurrentprocess()->pdd,
(u8 *) (dump->cr2 & 0xFFFFF000), (u8 *) (dump->cr2 & 0xFFFFF000),
PAGESIZE, PAGE_ALL); PAGESIZE, PAGE_ALL);
} }

View File

@ -22,13 +22,13 @@ libs.o:$(OBJS) $(OBJASM)
$(ASM) $^ $(ASM) $^
handlers.o:handlers.c handlers.o:handlers.c
$(CC) -mgeneral-regs-only $^ $(CC) -mno-sse $^
keyboard.o:keyboard.c keyboard.o:keyboard.c
$(CC) -mgeneral-regs-only $^ $(CC) -mno-sse $^
mouse.o:mouse.c mouse.o:mouse.c
$(CC) -mgeneral-regs-only $^ $(CC) -mno-sse $^
syscall.o:syscall.c syscall.o:syscall.c
$(CC) -fomit-frame-pointer $^ $(CC) -fomit-frame-pointer $^

View File

@ -8,7 +8,7 @@
#include "gdt.h" #include "gdt.h"
process *processes; process *processes;
pid_t current; tid_t current;
pid_t lastpid; pid_t lastpid;
@ -74,10 +74,10 @@ u32 iself(u8 * src)
} }
END */ END */
void processexit() void processexit(void)
{ {
deletetask(getcurrentpid()); deleteprocess(getcurrentpid());
switchtask(0, false); switchtask(maketid(0,0));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -94,7 +94,7 @@ u32 loadelf(u8 * src, pid_t pid)
header = (elf32 *) src; header = (elf32 *) src;
program = (elf32p *) (src + header->e_phoff); program = (elf32p *) (src + header->e_phoff);
code = elf_test(src); code = iself(src);
if (code != 0) if (code != 0)
{ {
printf("Erreur de chargement ELF, %s !\r\n", printf("Erreur de chargement ELF, %s !\r\n",
@ -142,31 +142,31 @@ u32 loadelf(u8 * src, pid_t pid)
/*******************************************************************************/ /*******************************************************************************/
/* Initialise la liste des processus */ /* Initialise la liste des processus */
void initprocesses() void initprocesses(void)
{ {
u32 i = 1; u32 i = 1;
processes = (process *) vmalloc(sizeof(process) * MAXNUMPROCESS); processes = (process *) vmalloc(sizeof(process) * MAXNUMPROCESS);
while (i < MAXNUMPROCESS) while (i < MAXNUMPROCESS)
{ {
processes[i].pid = NULL; 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].result = 0;
processes[0].status = STATUS_READY; processes[0].status = PROCESS_STATUS_READY;
processes[0].iskernel = true; processes[0].iskernel = true;
current = 0; current = maketid(0,0);
lastpid = NULL; lastpid = NULL;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Récupère un emplacement dans la liste des processus */ /* Récupère un emplacement dans la liste des processus */
pid_t getfreepid() pid_t getfreepid(void)
{ {
u32 i = lastpid; u32 i = lastpid;
u32 parsed = 0; u32 parsed = 0;
while (processes[++i].status != STATUS_FREE while (processes[++i].status != PROCESS_STATUS_FREE
&& ++parsed < MAXNUMPROCESS) && ++parsed < MAXNUMPROCESS)
{ {
if (i >= 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é */ /* Determine le dernier PID occupé */
@ -200,30 +250,55 @@ void usepid(pid_t pid)
/*******************************************************************************/ /*******************************************************************************/
/* Bascule vers une tâche */ /* Bascule vers une tâche */
void switchtask(tid_t pid, bool fromkernelmode) void switchtask(tid_t tid)
{ {
pid_t previous = current; tid_t previous = current;
current = &processes[(u32)pid]; task *atask = findtask(tid);
if (!current->kernel) process *aprocess=findprocess(tid.pid);
setTSS(current->kstack.ss0, current->kstack.esp0); if (!aprocess->iskernel)
setTSS(atask->kernel_stack.ss0, atask->kernel_stack.esp0);
else else
setTSS(0x0, 0x0); setTSS(0x0, 0x0);
current->dump.eflags = (current->dump.eflags | 0x200) & 0xFFFFBFFF; atask->dump.eflags = (atask->dump.eflags | 0x200) & 0xFFFFBFFF;
createdump(current->dump); createdump(atask->dump);
if (current->dump.cs==SEL_KERNEL_CODE) if (atask->dump.cs==SEL_KERNEL_CODE)
restcpu_kernel(); restcpu_kernel();
else else
restcpu_user(); restcpu_user();
iret(); 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 */ /* Détruit une tâche */
void deletetask(tid_t tid) 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) 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; atask->status = TASK_STATUS_RUN;
switchtask(u32)pid, false); switchtask(tid);
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* Initialise une tâche */ /* 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; tid_t tid;
pid_t pid = getfreepid(); tid.pid=pid;
usepid(pid); process* aprocess=findprocess(pid);
page *kstack; task *new = (task *) vmalloc(sizeof(task));
processes[(u32)pid].pid = (u32)pid; TAILQ_INSERT_TAIL(&aprocess->task_head, new, tailq);
processes[(u32)pid].pdd = virtual_pd_create(); page *astack = virtual_page_getfree();
TAILQ_INIT(&processes[(u32)pid].page_head); if (kerneltask)
if (&processes[(u32)pid].iskernel)
{ {
processes[(u32)pid].dump.ss = SEL_KERNEL_STACK; new->dump.ss = SEL_KERNEL_STACK;
processes[(u32)pid].dump.esp = new->dump.esp =
(u32) kstack->vaddr + PAGESIZE - 16; (u32) astack->vaddr + PAGESIZE - 16;
processes[(u32)pid].dump.eflags = 0x0; new->dump.eflags = 0x0;
processes[(u32)pid].dump.cs = SEL_KERNEL_CODE; new->dump.cs = SEL_KERNEL_CODE;
processes[(u32)pid].dump.eip = elf_load(code, pid); new->dump.ds = SEL_KERNEL_DATA;
if (processes[(u32)pid].dump.eip == NULL) new->dump.es = SEL_KERNEL_DATA;
return NULL; new->dump.fs = SEL_KERNEL_DATA;
processes[(u32)pid].dump.ds = SEL_KERNEL_DATA; new->dump.gs = SEL_KERNEL_DATA;
processes[(u32)pid].dump.es = SEL_KERNEL_DATA; new->dump.cr3 = KERNEL_PD_ADDR;
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 else
{ {
current = &processes[(u32)pid]; new->kernel_stack.ss0 = SEL_KERNEL_STACK;
setCR3(processes[(u32)pid].pdd->addr->paddr); new->kernel_stack.esp0 =
kstack = virtual_page_getfree(); (u32) astack->vaddr + PAGESIZE - 16;
processes[(u32)pid].dump.ss = SEL_USER_STACK | RPL_RING3; new->dump.ss = SEL_USER_STACK | RPL_RING3;
processes[(u32)pid].dump.esp = USER_STACK - 16; new->dump.esp = USER_STACK - 16;
processes[(u32)pid].dump.eflags = 0x0; new->dump.eflags = 0x0;
processes[(u32)pid].dump.cs = SEL_USER_CODE | RPL_RING3; new->dump.cs = SEL_USER_CODE | RPL_RING3;
processes[(u32)pid].dump.eip = elf_load(code, pid); new->dump.ds = SEL_USER_DATA | RPL_RING3;
if (processes[(u32)pid].dump.eip == NULL) new->dump.es = SEL_USER_DATA | RPL_RING3;
return NULL; new->dump.fs = SEL_USER_DATA | RPL_RING3;
processes[(u32)pid].dump.ds = SEL_USER_DATA | RPL_RING3; new->dump.gs = SEL_USER_DATA | RPL_RING3;
processes[(u32)pid].dump.es = SEL_USER_DATA | RPL_RING3; new->dump.cr3 = aprocess->pdd->addr->paddr;
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; 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) 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 createprocess(u8 *src, bool kerneltask)
{ {
pid_t previous = current; tid_t previous = current;
pid_t pid = getfreepid(); current.pid = getfreepid();
usepid(pid); current.number = 0;
page *kstack; usepid(current.pid);
processes[(u32)pid].pid = (u32)pid; process* new=findcurrentprocess();
processes[(u32)pid].pdd = virtual_pd_create(); new->pid = current.pid;
TAILQ_INIT(&processes[(u32)pid].page_head); new->pdd = virtual_pd_create();
processes[(u32)pid].entry = elf_load(code, pid); TAILQ_INIT(&new->page_head);
new->iskernel=kerneltask;
if (processes[(u32)pid].dump.eip == NULL) setCR3(new->pdd->addr->paddr);
return NULL; new->entry = loadelf(src, new->pid);
processes[(u32)pid].dump.ds = SEL_KERNEL_DATA; createtask(new->pid,new->entry, new->iskernel);
processes[(u32)pid].dump.es = SEL_KERNEL_DATA; current = previous;
processes[(u32)pid].dump.fs = SEL_KERNEL_DATA; process* old=findcurrentprocess();
processes[(u32)pid].dump.gs = SEL_KERNEL_DATA; setCR3(old->pdd->addr->paddr);
processes[(u32)pid].dump.cr3 = KERNEL_PD_ADDR; return new->pid;
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;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -397,7 +404,13 @@ if (processes[(u32)pid].dump.eip == NULL)
void deleteprocess(pid_t pid) 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) 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) 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;
}
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -19,6 +19,7 @@
#include "3D/man.c" #include "3D/man.c"
#include "memory.h" #include "memory.h"
#include "syscall.h" #include "syscall.h"
#include "process.h"
static command commands[] = { static command commands[] = {
{"reboot", "", &rebootnow}, {"reboot", "", &rebootnow},
@ -95,8 +96,8 @@ int test(void)
int testtask() int testtask()
{ {
print("*** Creation d'une tache\r\n"); print("*** Creation d'une tache\r\n");
u32 pid = task_create(&programs_test, false); pid_t pid = createprocess(&programs_test, false);
task_run(pid); runprocess(pid);
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -62,20 +62,20 @@ __attribute__ ((noreturn)) void sysenter_handler(regs *dump)
sti(); sti();
switch (dump->eax) switch (dump->eax)
{ {
case 4:
dump->eax=(u32) gettimer();
break;
case 5:
exit(dump->ebx);
break;
case 2: case 2:
dump->eax=(u32) print(dump->ebx); dump->eax=(u32) print(dump->ebx);
break; break;
case 0:
dump->eax=(u32) testapi(dump->ebx, dump->esi, dump->edi, dump);
break;
case 4:
dump->eax=(u32) gettimer();
break;
case 1: case 1:
dump->eax=(u32) waitascii(); dump->eax=(u32) waitascii();
break; break;
case 0: case 5:
dump->eax=(u32) testapi(dump->ebx, dump->esi, dump->edi, dump); processexit(dump->ebx);
break; break;
default: default:

View File

@ -4,8 +4,8 @@
#include "types.h"; #include "types.h";
u32 getticks(void);
void exit(u32 resultcode);
u8 waitkey(void);
u32 testapi(u32 arg1, u32 arg2, u32 arg3); u32 testapi(u32 arg1, u32 arg2, u32 arg3);
u32 getticks(void);
u8 waitkey(void);
void exit(u32 resultcode);

View File

@ -6,25 +6,25 @@
#include "syscall.h"; #include "syscall.h";
#include "types.h"; #include "types.h";
u32 testapi(u32 arg1, u32 arg2, u32 arg3)
{
return syscall3(0,(u32) arg1,(u32) arg2,(u32) arg3);
}
u32 getticks(void) u32 getticks(void)
{ {
return syscall0(4); return syscall0(4);
} }
u8 waitkey(void)
{
return syscall0(1);
}
void exit(u32 resultcode) void exit(u32 resultcode)
{ {
syscall1(5,(u32) resultcode); syscall1(5,(u32) resultcode);
return; return;
} }
u8 waitkey(void)
{
return syscall0(1);
}
u32 testapi(u32 arg1, u32 arg2, u32 arg3)
{
return syscall3(0,(u32) arg1,(u32) arg2,(u32) arg3);
}

View File

@ -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, "ID":2,
"LIBRARY":"libvideo", "LIBRARY":"libvideo",
"NAME":"print", "NAME":"print",
@ -35,17 +11,6 @@
"RETURN":"u32" "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, "ID":0,
@ -62,4 +27,39 @@
"DUMP":"yes" "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"
}
] ]

View File

@ -68,7 +68,7 @@ int main(u32 magic, u32 addr)
print("\033[37m\033[0m -Initilisation des processus"); print("\033[37m\033[0m -Initilisation des processus");
inittr(); inittr();
initretry(&&retry); initretry(&&retry);
task_init(); initprocesses();
initsyscall(); initsyscall();
ok(); ok();