diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 13 | ||||
-rw-r--r-- | sys/include/sys/machdep.h | 1 | ||||
-rw-r--r-- | sys/kern/kern_sched.c | 4 |
3 files changed, 18 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 0789f5a..5327189 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -179,6 +179,19 @@ processor_init_pcb(struct proc *proc) amd64_fxsave(pcb->fpu_state); return 0; } + +void +processor_switch_to(struct proc *old_td, struct proc *new_td) +{ + struct pcb *old_pcb = (old_td != NULL) ? &old_td->pcb : NULL; + struct pcb *new_pcb = &new_td->pcb; + + if (old_pcb != NULL) { + amd64_fxsave(old_pcb->fpu_state); + } + amd64_fxrstor(new_pcb->fpu_state); +} + void processor_init(void) { diff --git a/sys/include/sys/machdep.h b/sys/include/sys/machdep.h index 151d5f8..b6edf14 100644 --- a/sys/include/sys/machdep.h +++ b/sys/include/sys/machdep.h @@ -39,6 +39,7 @@ #define MAXCPUS 32 int processor_init_pcb(struct proc *proc); +void processor_switch_to(struct proc *old_td, struct proc *new_td); void processor_init(void); void processor_halt(void); void intr_mask(void); diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index f8f09c4..bc96146 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -311,6 +311,10 @@ sched_context_switch(struct trapframe *tf) sched_enqueue_td(td); } + /* Do architecture specific context switch logic */ + processor_switch_to(td, next_td); + + /* Done, switch out our vas and oneshot */ pmap_switch_vas(vm_get_ctx(), next_td->addrsp); sched_oneshot(); } |