* int task_prepare(struct task*, u32_t cr3, u32_t eip,
* u32_t esp, u32_t priv)
*
- * priv = 20(%esp)
- * esp = 16(%esp)
+ * priv = 24(%esp)
+ * esp = 20(%esp)
+ * esp0 = 16(%esp)
* eip = 12(%esp)
* cr3 = 8(%esp)
* task = 4(%esp)
subl $64, %eax
/* calculate DS from priv and put it on the new stack */
- movl 20(%esp), %ecx
+ movl 24(%esp), %ecx
shll $4, %ecx
addl $16, %ecx
- orl 20(%esp), %ecx
+ orl 24(%esp), %ecx
movl %ecx, (%eax)
/* Clear general purpose registers (and error/intr) */
movl %ecx, 44(%eax)
/* calculate CS from priv and put it on the new stack */
- movl 20(%esp), %ecx
+ movl 24(%esp), %ecx
shll $4, %ecx
addl $8, %ecx
- orl 20(%esp), %ecx
+ orl 24(%esp), %ecx
movl %ecx, 48(%eax)
/* put EFLAGS on the new stack */
movl $USER_EFLAGS, 52(%eax)
/* put the stack pointer on the stack */
+ movl 20(%esp), %ecx
+ movl %ecx, 56(%eax)
/* put the stack segment on the new stack - use the value from DS */
movl (%eax), %ecx
addl $CPU_SIZE, %eax
jmp 0b
- movl CUR_TASK(%eax), %esi
+1: movl CUR_TASK(%eax), %esi
movl 4(%esp), %edi
cmpl %esi, %edi
- jnz 1f
+ jnz 2f
/* FIXME: Return -EALREADY instead */
movl $-1, %eax
ret
-1: movl OFFSET_CR3(%edi), %ecx
+2: movl OFFSET_CR3(%edi), %ecx
/* check if we can avoid writing to cr3, which would clear the TLB */
movl %cr3, %edx