1/* 2 * Copyright (C) 2019-2022 Intel Corporation. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7/* 8 * Function schedule() will finally call arch_switch_to here for x86 platform, which use 9 * the pointer of previous & next thread_obj->host_sp as the input parameters (rdi & rsi). 10 * 11 * Function arch_switch_to will save rflags, rbx, rbp, r12~r15, and rdi in the previous 12 * thread_obj's stack, then switch stack pointer(rsp) from previous to next thread_obj (saved 13 * in thread_obj->host_sp) and restore above registers from next thread_obj's stack. 14 * It make sure the execution context return to the same point of next thread_obj when it got 15 * scheduled last time. 16 */ 17 .text 18 19 .code64 20 .align 8 21 .global arch_switch_to 22arch_switch_to: 23 pushf 24 pushq %rbx 25 pushq %rbp 26 pushq %r12 27 pushq %r13 28 pushq %r14 29 pushq %r15 30 pushq %rdi 31 movq %rsp, (%rdi) 32 movq (%rsi), %rsp 33 popq %rdi 34 popq %r15 35 popq %r14 36 popq %r13 37 popq %r12 38 popq %rbp 39 popq %rbx 40 popf 41 retq 42