Aaron Durbin | 38c326d | 2013-05-06 12:22:23 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Aaron Durbin | 38c326d | 2013-05-06 12:22:23 -0500 | [diff] [blame] | 14 | */ |
| 15 | .code32 |
| 16 | .text |
| 17 | |
| 18 | /* |
| 19 | * stack layout after pushad: |
| 20 | * +------------+ |
| 21 | * | save stack | <-- esp + 0x28 |
| 22 | * +------------+ |
| 23 | * | new stack | <-- esp + 0x24 |
| 24 | * +------------+ |
| 25 | * | ret addr | <-- esp + 0x20 |
| 26 | * +------------+ |
| 27 | * | eax | <-- esp + 0x1c |
| 28 | * +------------+ |
| 29 | * | ecx | <-- esp + 0x18 |
| 30 | * +------------+ |
| 31 | * | edx | <-- esp + 0x14 |
| 32 | * +------------+ |
| 33 | * | ebx | <-- esp + 0x10 |
| 34 | * +------------+ |
| 35 | * | orig esp | <-- esp + 0x0c |
| 36 | * +------------+ |
| 37 | * | ebp | <-- esp + 0x08 |
| 38 | * +------------+ |
| 39 | * | esi | <-- esp + 0x04 |
| 40 | * +------------+ |
| 41 | * | edi | <-- esp + 0x00 |
| 42 | * +------------+ |
| 43 | */ |
| 44 | .globl switch_to_thread |
| 45 | switch_to_thread: |
| 46 | pusha |
| 47 | /* Save the current stack */ |
| 48 | movl 0x28(%esp), %ebx |
| 49 | movl %esp, (%ebx) |
| 50 | /* Switch to the new stack. */ |
| 51 | movl 0x24(%esp), %eax |
| 52 | movl %eax, %esp |
| 53 | popa |
| 54 | ret |