From 59038fc67c20a1f04e5d2fd5f9a444e707d1d3ea Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 22 Aug 2018 00:52:30 +0200 Subject: userspace and kernelspace taskswitching --- asm/task.s | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'asm/task.s') diff --git a/asm/task.s b/asm/task.s index 7611d4a..c29bdae 100644 --- a/asm/task.s +++ b/asm/task.s @@ -2,15 +2,21 @@ task_pusha: pushf - - push $0x8 + push $0x8 // code segment push $userfunc pusha + + push %ds + push %es + push %fs + push %gs + /* + now stack looks like: - param // esp+48 + param // esp+64 returnaddy eflags @@ -26,9 +32,14 @@ task_pusha: esi edi + ds + es + fs + gs + */ - mov 48(%esp),%eax // get address of alternative stack where we want to simulate the pusha + mov 64(%esp),%eax // get address of alternative stack where we want to simulate the pusha mov (%esp),%ecx mov %ecx,(%eax) @@ -66,10 +77,24 @@ task_pusha: mov 44(%esp),%ecx mov %ecx,44(%eax) + mov 48(%esp),%ecx + mov %ecx,48(%eax) + + mov 52(%esp),%ecx + mov %ecx,52(%eax) + + mov 56(%esp),%ecx + mov %ecx,56(%eax) + + pop %gs + pop %fs + pop %es + pop %ds + + popa + pop %eax pop %eax pop %eax - popa - ret -- cgit v1.2.3