Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 2 | |
Aaron Durbin | 38c326d | 2013-05-06 12:22:23 -0500 | [diff] [blame] | 3 | .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 |
| 33 | switch_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 |