Patrick Rudolph | b14b96d | 2023-12-27 10:59:25 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* Functions to call MRC.bin from x86_64 */ |
| 3 | |
| 4 | .text |
| 5 | .code32 |
| 6 | .section ".text.mrc_wrapper", "ax", @progbits |
| 7 | .globl mrc_wrapper |
| 8 | mrc_wrapper: |
| 9 | /* Set up new stack frame */ |
| 10 | pushal |
| 11 | mov %esp, %ebp |
| 12 | |
| 13 | /* Align stack */ |
| 14 | andl $0xfffffff0, %esp |
| 15 | |
| 16 | movl 36(%ebp), %ebx /* Get function pointer */ |
| 17 | movl 40(%ebp), %eax /* Get argument */ |
| 18 | |
| 19 | call *%ebx |
| 20 | |
| 21 | /* Place return value on stack so that popal fetches it */ |
| 22 | movl %eax, 28(%ebp) |
| 23 | |
| 24 | /* Restore stack pointer */ |
| 25 | mov %ebp, %esp |
| 26 | popal |
| 27 | ret |
Patrick Rudolph | 1d718de | 2023-12-28 19:39:11 +0100 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * Callback for MRC to print a character on the console. |
| 31 | * As MRC is x86_32 call into long mode and use the x86_64 |
| 32 | * function do_putchar to print to console. |
| 33 | */ |
| 34 | |
| 35 | #include <src/cpu/x86/64bit/prot2long.inc> |
| 36 | |
| 37 | prot2lm_wrapper do_putchar |