2 * ACPI wakeup real mode startup stub
4 #include <asm/segment.h>
5 #include <asm/msr-index.h>
6 #include <asm/page_types.h>
7 #include <asm/pgtable_types.h>
8 #include <asm/processor-flags.h>
9 #include "../realmode.h"
14 /* This should match the structure in wakeup.h */
15 .section ".data", "aw"
18 video_mode: .short 0 /* Video mode number */
20 pmode_cs: .short __KERNEL_CS
21 pmode_cr0: .long 0 /* Saved %cr0 */
22 pmode_cr3: .long 0 /* Saved %cr3 */
23 pmode_cr4: .long 0 /* Saved %cr4 */
24 pmode_efer: .quad 0 /* Saved EFER */
26 pmode_misc_en: .quad 0 /* Saved MISC_ENABLE MSR */
27 pmode_behavior: .long 0 /* Wakeup behavior flags */
28 realmode_flags: .long 0
30 signature: .long WAKEUP_HEADER_SIGNATURE
31 .size wakeup_header, .-wakeup_header
42 /* Apparently some dimwit BIOS programmers don't know how to
43 program a PM to RM transition, and we might end up here with
44 junk in the data segment descriptor registers. The only way
45 to repair that is to go into PM and fix it ourselves... */
59 andb $~X86_CR0_PE, %al
70 movl $wakeup_stack_end, %esp
72 /* Clear the EFLAGS */
76 /* Check header signature... */
78 cmpl $WAKEUP_HEADER_SIGNATURE, %eax
81 /* Check we really have everything... */
82 movl end_signature, %eax
83 cmpl $WAKEUP_END_SIGNATURE, %eax
89 /* Restore MISC_ENABLE before entering protected mode, in case
90 BIOS decided to clear XD_DISABLE during S3. */
91 movl pmode_behavior, %eax
92 btl $WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE, %eax
95 movl pmode_misc_en, %eax
96 movl pmode_misc_en + 4, %edx
97 movl $MSR_IA32_MISC_ENABLE, %ecx
101 /* Do any other stuff... */
104 /* This could also be done in C code... */
112 movl pmode_efer, %eax
113 movl pmode_efer + 4, %edx
123 /* This really couldn't... */
124 movl pmode_entry, %eax
127 ljmpl $__KERNEL_CS, $pa_startup_32
128 /* -> jmp *%eax in trampoline_32.S */
138 .section ".rodata","a"
141 * Set up the wakeup GDT. We set these up as Big Real Mode,
142 * that is, with limits set to 4 GB. At least the Lenovo
143 * Thinkpad X61 is known to need this for the video BIOS
144 * initialization quirk to work; this is likely to also
145 * be the case for other laptops or integrated video devices.
151 .word 3*8-1 /* Self-descriptor */
155 .word 0xffff /* 16-bit code segment @ real_mode_base */
156 .long 0x9b000000 + pa_real_mode_base
157 .word 0x008f /* big real mode */
159 .word 0xffff /* 16-bit data segment @ real_mode_base */
160 .long 0x93000000 + pa_real_mode_base
161 .word 0x008f /* big real mode */
162 .size wakeup_gdt, .-wakeup_gdt
167 /* This is the standard real-mode IDT */
169 .word 0xffff /* limit */
170 .long 0 /* address */
173 .globl HEAP, heap_end
186 .section ".signature","a"
188 .long WAKEUP_END_SIGNATURE