From: Matthias Kruk Date: Thu, 19 Sep 2019 10:34:19 +0000 (+0900) Subject: Keep a pointer to the kernel stack in struct task, instead of the entire stack X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=2afddfe26671d73db5dd6bbad766c378c349a93a;p=corax Keep a pointer to the kernel stack in struct task, instead of the entire stack --- diff --git a/kernel/arch/task.S b/kernel/arch/task.S index 31d2f62..4cad113 100644 --- a/kernel/arch/task.S +++ b/kernel/arch/task.S @@ -49,12 +49,11 @@ task_prepare: /* store cr3 in task structure */ movl 8(%esp), %eax - movl %eax, 4(%edi) + movl %eax, OFFSET_CR3(%edi) /* calculate stack start (since it grows down) */ - movl $CONFIG_KERNEL_STACK_SIZE, %ecx - movl (%esp), %eax - leal OFFSET_KSTACK(%eax, %ecx, 1), %eax + movl OFFSET_KSTACK(%edi), %eax + addl $CONFIG_KERNEL_STACK_SIZE, %eax /* * We will use _int_restore (the lower half of the interrupt handler) @@ -130,9 +129,8 @@ task_prepare: movl (%eax), %ecx movl %ecx, 60(%eax) - /* put EAX into the task structure */ - movl 4(%esp), %ecx - movl %eax, OFFSET_ESP0(%ecx) + /* put EAX into the task structure - task pointer is still in EDI */ + movl %eax, OFFSET_ESP0(%edi) /* that should be it */ ret diff --git a/kernel/include/arch.h b/kernel/include/arch.h index 06f1932..787cdf8 100644 --- a/kernel/include/arch.h +++ b/kernel/include/arch.h @@ -24,8 +24,7 @@ struct task { u32_t t_sp; u32_t t_pgdir; - - u8_t t_kstack[CONFIG_KERNEL_STACK_SIZE]; + void *t_kstack; } __attribute__((packed)); int cpu_get_id(void);