entry: rework sched_save_state
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
c6dea48b5f
commit
1f7fd24961
3 changed files with 10 additions and 8 deletions
|
|
@ -88,11 +88,9 @@ irq_common:
|
||||||
swapgs
|
swapgs
|
||||||
1:
|
1:
|
||||||
push_all /* pushes 15 registers */
|
push_all /* pushes 15 registers */
|
||||||
mov gs:[28], rsp /* save RSP after push_all for scheduler */
|
|
||||||
mov rdi, [rsp + 120] /* irq no */
|
mov rdi, [rsp + 120] /* irq no */
|
||||||
|
|
||||||
call irq_handler
|
call irq_handler
|
||||||
irq_epilogue:
|
|
||||||
pop_all
|
pop_all
|
||||||
test qword ptr [rsp + 24], 3 /* from userspace? */
|
test qword ptr [rsp + 24], 3 /* from userspace? */
|
||||||
jz 2f
|
jz 2f
|
||||||
|
|
@ -101,10 +99,17 @@ irq_epilogue:
|
||||||
add rsp, 8
|
add rsp, 8
|
||||||
iretq
|
iretq
|
||||||
|
|
||||||
|
.global sched_save_state
|
||||||
|
sched_save_state:
|
||||||
|
push_all
|
||||||
|
mov [rdi + 8], rsp /* save RSP to thread->kstack_ptr */
|
||||||
|
ret
|
||||||
|
|
||||||
.global sched_restore_state
|
.global sched_restore_state
|
||||||
sched_restore_state:
|
sched_restore_state:
|
||||||
mov rsp, [rdi + 8] /* load from thread->kstack_ptr */
|
mov rsp, [rdi + 8] /* load RSP from thread->kstack_ptr */
|
||||||
jmp irq_epilogue
|
pop_all
|
||||||
|
ret
|
||||||
|
|
||||||
.global _syscall_enter
|
.global _syscall_enter
|
||||||
_syscall_enter:
|
_syscall_enter:
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,7 @@ u32 cpu_id()
|
||||||
return tls_get()->cpu_id;
|
return tls_get()->cpu_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sched_save_state(struct thread *t)
|
void fork_trampoline();
|
||||||
{
|
|
||||||
t->kstack_ptr = tls_get()->irq_rsp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the thread that calls this will be lost, so it should only be called
|
/* the thread that calls this will be lost, so it should only be called
|
||||||
* on the initial process, and while doing an exec
|
* on the initial process, and while doing an exec
|
||||||
|
|
|
||||||
BIN
usr.bin/init/init
Executable file
BIN
usr.bin/init/init
Executable file
Binary file not shown.
Loading…
Reference in a new issue