Debian Codegraph @

src/arch/x86/thread_switch_32.S

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #if ENV_X86_64
4 #error COOP_MULTITASKING does not currently support x86_64
5 #endif
6
7 .code32
8 .text
9
10 /*
11 * stack layout after pushad:
12 * +------------+
13 * | save stack | <-- esp + 0x28
14 * +------------+
15 * | new stack | <-- esp + 0x24
16 * +------------+
17 * | ret addr | <-- esp + 0x20
18 * +------------+
19 * | eax | <-- esp + 0x1c
20 * +------------+
21 * | ecx | <-- esp + 0x18
22 * +------------+
23 * | edx | <-- esp + 0x14
24 * +------------+
25 * | ebx | <-- esp + 0x10
26 * +------------+
27 * | orig esp | <-- esp + 0x0c
28 * +------------+
29 * | ebp | <-- esp + 0x08
30 * +------------+
31 * | esi | <-- esp + 0x04
32 * +------------+
33 * | edi | <-- esp + 0x00
34 * +------------+
35 */
36 .globl switch_to_thread
37 switch_to_thread:
38 pusha
39 /* Save the current stack */
40 movl 0x28(%esp), %ebx
41 movl %esp, (%ebx)
42 /* Switch to the new stack. */
43 movl 0x24(%esp), %eax
44 movl %eax, %esp
45 popa
46 ret