summaryrefslogtreecommitdiff
path: root/kernel/task.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/task.c')
-rw-r--r--kernel/task.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/kernel/task.c b/kernel/task.c
index a7f5bc2..c9554b5 100644
--- a/kernel/task.c
+++ b/kernel/task.c
@@ -30,9 +30,14 @@ static volatile struct task_list_struct
void task_create(int pid,void(*thread)())
{
+ task_list[pid].vmem=vmem_new_space_dir();
+ if(pid==0)x86_set_pdbr(0x0D08000);
+ if(pid==1)x86_set_pdbr(0x150E000);
+
unsigned int *stack;
- task_list[pid].esp = pmmngr_alloc_block();
+
+ task_list[pid].esp = 0x8248000-4095;
stack = (unsigned int*)task_list[pid].esp+4095; //This makes a pointer to the stack for us
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"new task: stack: 0x%08X thread: 0x%08X", stack, thread);
@@ -59,10 +64,13 @@ void task_create(int pid,void(*thread)())
*--stack = 0x10; //FS
*--stack = 0x10; //GS
*/
-
+
+
task_list[pid].esp = (uint32_t)stack; //Update the stack pointer
task_list[pid].active=true;
+ x86_set_pdbr(0x0502000);
+
};
// this gets called by our clock interrupt regularly!
@@ -79,8 +87,12 @@ uint32_t task_switch_next(uint32_t oldesp)
if(task_list[pid].active)
{
- // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"switch from %d to pid: %d (0x%08X)", current_task,pid,task_list[pid].esp);
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"switch from %d to pid: %d (0x%08X) vmem: %d ", current_task,pid,task_list[pid].esp,task_list[pid].vmem);
current_task=pid;
+
+ if(pid==0)x86_set_pdbr(0x0D08000);
+ if(pid==1)x86_set_pdbr(0x150E000);
+
return task_list[pid].esp;
}
@@ -94,6 +106,14 @@ uint32_t task_switch_next(uint32_t oldesp)
// task testing //
volatile void test1()
{
+
+
+
+ static char *argv[]={"/bin/foolshell",NULL};
+ static char *env[]={"PATH=/bin","PWD=/home/miguel","PS1=$ ",NULL};
+ syscall_execve("/bin/task1",argv,env);
+
+
while(1)
{
syscall_write(1,">",1);
@@ -102,9 +122,16 @@ volatile void test1()
volatile void test2()
{
+
+ static char *argv[]={"/bin/foolshell",NULL};
+ static char *env[]={"PATH=/bin","PWD=/home/miguel","PS1=$ ",NULL};
+ syscall_execve("/bin/task2",argv,env);
+
+
+
while(1)
{
- for(int i='a';i<='z';i++)
+ for(int i='a';i<'z';i++)
{
syscall_write(1,&i,1);
}
@@ -121,9 +148,9 @@ volatile void test3()
}
void task_init()
{
- task_create(0,test1);
- task_create(1,test2);
- task_create(2,test3);
+ task_create(0,test2);
+ task_create(1,test1);
+// task_create(2,test3);
current_task=-1;
}