From e72b6a00ee64f00bc38e3a64d16330d8c101c3ff Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Mon, 17 Nov 2014 17:34:27 +0100 Subject: hardcoded shell as task1 --- kernel/task.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'kernel') diff --git a/kernel/task.c b/kernel/task.c index 094c74d..29ccaa4 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -18,12 +18,14 @@ static uint32_t c1,c2,c3; void task_test1() { - // ext2_check(EXT2_RAM_ADDRESS); - // syscall_execve(15,0,0); + ext2_check(EXT2_RAM_ADDRESS); + syscall_execve(15,0,0); + /* while(1) { c1++; } + */ } @@ -54,7 +56,7 @@ typedef struct{ //Simple structure for a thread } Thread; -Thread Threads[3]; //Space for our simple threads. Just 2! +Thread Threads[3]; //Space for our simple threads. volatile int CurrentTask; //The thread currenlty running (-1 == none) @@ -63,8 +65,8 @@ void task_create(int pid,void(*thread)()) unsigned int *stack; Threads[pid].esp0 = pmmngr_alloc_block(); - stack = (unsigned int*)Threads[pid].esp0+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); + stack = (unsigned int*)Threads[pid].esp0+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); //First, this stuff is pushed by the processor *--stack = 0x0202; //This is EFLAGS @@ -89,8 +91,6 @@ void task_create(int pid,void(*thread)()) *--stack = 0x10; //GS */ - -log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"new task : stack: 0x%08X ", stack); Threads[pid].esp0 = (uint32_t)stack; //Update the stack pointer @@ -109,12 +109,13 @@ uint32_t task_switch_next(uint32_t oldesp) log( FOOLOS_MODULE_NAME, - FOOLOS_LOG_INFO, + FOOLOS_LOG_FINE, "oldesp: 0x%08X saved / next task: %d (esp: 0x%08X) ", oldesp, CurrentTask, Threads[CurrentTask].esp0); +// return oldesp; return Threads[CurrentTask].esp0; //Return new stack pointer to ASM } @@ -131,12 +132,13 @@ void stack_trace(uint32_t *stack,int size) void task_init() { + CurrentTask=-1; + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"init multitasking."); task_create(0,task_test1); task_create(1,task_test2); task_create(2,task_test3); started=0xabcde; - CurrentTask=-1; } -- cgit v1.2.3