summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/tcb_switch.c
blob: bc8808d16a45a41bda69b2cbe556807499e27143 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "tasking.h"
#include "arch/processor.h"

extern void _arch_context_restore(uintptr_t rsp);

void
tcb_switch(tcb_t *to)
{
    processor_t *proc = processor_current();
    tcb_t *from = proc->tcb;

    proc->tcb = to;
    if(from != to) {
        pd_switch(to->pd);
    }
    tss_set_rsp(&proc->_tss, 0, to->ksp);
    _arch_context_restore(to->ksp);
}