blob: 049f0927416b3331a2c5c7abc9cff3e189e90903 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi11f00792020-03-04 15:10:45 +01002
Aaron Durbin38c326d2013-05-06 12:22:23 -05003.code32
4.text
5
6/*
7 * stack layout after pushad:
8 * +------------+
9 * | save stack | <-- esp + 0x28
10 * +------------+
11 * | new stack | <-- esp + 0x24
12 * +------------+
13 * | ret addr | <-- esp + 0x20
14 * +------------+
15 * | eax | <-- esp + 0x1c
16 * +------------+
17 * | ecx | <-- esp + 0x18
18 * +------------+
19 * | edx | <-- esp + 0x14
20 * +------------+
21 * | ebx | <-- esp + 0x10
22 * +------------+
23 * | orig esp | <-- esp + 0x0c
24 * +------------+
25 * | ebp | <-- esp + 0x08
26 * +------------+
27 * | esi | <-- esp + 0x04
28 * +------------+
29 * | edi | <-- esp + 0x00
30 * +------------+
31 */
32.globl switch_to_thread
33switch_to_thread:
34 pusha
35 /* Save the current stack */
36 movl 0x28(%esp), %ebx
37 movl %esp, (%ebx)
38 /* Switch to the new stack. */
39 movl 0x24(%esp), %eax
40 movl %eax, %esp
41 popa
42 ret