1 /* SPDX-License-Identifier: GPL-2.0+ */
5 * From coreboot src/arch/x86/wakeup.S
8 #include <acpi/acpi_s3.h>
9 #include <asm/processor.h>
10 #include <asm/processor-flags.h>
12 #define RELOCATED(x) ((x) - __wakeup + WAKEUP_BASE)
14 #define CODE_SEG (X86_GDT_ENTRY_16BIT_CS * X86_GDT_ENTRY_SIZE)
15 #define DATA_SEG (X86_GDT_ENTRY_16BIT_DS * X86_GDT_ENTRY_SIZE)
20 /* First prepare the jmp to the resume vector */
21 mov 0x4(%esp), %eax /* vector */
22 /* last 4 bits of linear addr are taken as offset */
24 movw %ax, (__wakeup_offset)
26 /* the rest is taken as segment */
28 movw %ax, (__wakeup_segment)
30 /* Activate the right segment descriptor real mode */
31 ljmp $CODE_SEG, $RELOCATED(1f)
33 /* 16 bit code from here on... */
37 * Load the segment registers w/ properly configured segment
38 * descriptors. They will retain these configurations (limits,
39 * writability, etc.) once protected mode is turned off.
48 /* Turn off protection */
50 andl $~X86_CR0_PE, %eax
53 /* Now really going into real mode */
54 ljmp $0, $RELOCATED(1f)
64 * This is a FAR JMP to the OS waking vector.
65 * The C code changes the address to be correct.
69 __wakeup_offset = RELOCATED(.)
72 __wakeup_segment = RELOCATED(.)