Simplify code, add additional comments

This commit is contained in:
Stefan Lankes 2014-01-22 12:07:29 +01:00
parent eb8859d706
commit c71b6c6c8a
4 changed files with 10 additions and 8 deletions

View file

@ -61,9 +61,6 @@ void switch_context(size_t** stack);
*/
int create_default_frame(task_t* task, entry_point_t ep, void* arg);
/** @brief Copy kernel stack pointer to TSS */
void set_kernel_stack(size_t stack);
/** @brief Register a task's TSS at GDT
*
* @return

View file

@ -263,6 +263,8 @@ ALIGN 4
rollback:
ret
extern set_kernel_stack
ALIGN 4
common_stub:
pusha
@ -290,6 +292,9 @@ common_switch:
or eax, 8
mov cr0, eax
; set esp0 in the task state segment
call set_kernel_stack
; call cleanup code
call finish_task_switch

View file

@ -46,9 +46,11 @@ static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0,
*/
extern void gdt_flush(void);
void set_kernel_stack(size_t stack)
void set_kernel_stack(void)
{
task_state_segment.esp0 = stack;
task_t* curr_task = current_task;
task_state_segment.esp0 = (size_t) curr_task->stack + KERNEL_STACK_SIZE-16;
}
/* Setup a descriptor in the Global Descriptor Table */

View file

@ -65,9 +65,7 @@ static int wrapper(void* arg)
memset(ustack, 0xCD, KERNEL_STACK_SIZE);
*stack-- = (size_t) arg;
*stack = (size_t) leave_user_task; // add dummy return value
set_kernel_stack((size_t) &stack);
*stack = (size_t) leave_user_task; // put exit function as caller on the stack
return jump_to_user_code((uint32_t) userfoo, (uint32_t) stack);
}