1/*
2 * Copyright (c) 2015 Travis Geiselbrecht
3 *
4 * Use of this source code is governed by a MIT-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/MIT
7 */
8#include <lk/asm.h>
9
10/* void x86_64_context_switch(uint64_t *oldsp, uint64_t newsp) */
11FUNCTION(x86_64_context_switch)
12    /* save the old context and restore the new */
13    pushf
14    pushq %rbx
15    pushq %rbp
16    pushq %r12
17    pushq %r13
18    pushq %r14
19    pushq %r15
20
21    movq %rsp,(%rdi)
22    movq %rsi,%rsp
23
24    popq %r15
25    popq %r14
26    popq %r13
27    popq %r12
28    popq %rbp
29    popq %rbx
30    popf
31
32    retq
33
34