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>
12 .section ".jump", "ax"
18 /* This should match the structure in wakeup.h */
19 .section ".header", "a"
22 video_mode: .short 0 /* Video mode number */
23 pmode_return: .byte 0x66, 0xea /* ljmpl */
24 .long 0 /* offset goes here */
26 pmode_cr0: .long 0 /* Saved %cr0 */
27 pmode_cr3: .long 0 /* Saved %cr3 */
28 pmode_cr4: .long 0 /* Saved %cr4 */
29 pmode_efer: .quad 0 /* Saved EFER */
31 pmode_misc_en: .quad 0 /* Saved MISC_ENABLE MSR */
32 pmode_behavior: .long 0 /* Wakeup behavior flags */
33 realmode_flags: .long 0
35 trampoline_segment: .word 0
37 wakeup_jmp: .byte 0xea /* ljmpw */
38 wakeup_jmp_off: .word 3f
39 wakeup_jmp_seg: .word 0
40 wakeup_gdt: .quad 0, 0, 0
41 signature: .long WAKEUP_HEADER_SIGNATURE
48 /* Apparently some dimwit BIOS programmers don't know how to
49 program a PM to RM transition, and we might end up here with
50 junk in the data segment descriptor registers. The only way
51 to repair that is to go into PM and fix it ourselves... */
66 andb $~X86_CR0_PE, %al
77 movl $wakeup_stack_end, %esp
79 /* Clear the EFLAGS */
83 /* Check header signature... */
85 cmpl $WAKEUP_HEADER_SIGNATURE, %eax
88 /* Check we really have everything... */
89 movl end_signature, %eax
90 cmpl $WAKEUP_END_SIGNATURE, %eax
96 /* Restore MISC_ENABLE before entering protected mode, in case
97 BIOS decided to clear XD_DISABLE during S3. */
98 movl pmode_behavior, %eax
99 btl $WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE, %eax
102 movl pmode_misc_en, %eax
103 movl pmode_misc_en + 4, %edx
104 movl $MSR_IA32_MISC_ENABLE, %ecx
108 /* Do any other stuff... */
111 /* This could also be done in C code... */
119 movl pmode_efer, %eax
120 movl pmode_efer + 4, %edx
130 /* This really couldn't... */
136 pushw trampoline_segment
149 /* This is the standard real-mode IDT */
151 .word 0xffff /* limit */
152 .long 0 /* address */
155 .globl HEAP, heap_end
168 .section ".signature","a"
170 .long WAKEUP_END_SIGNATURE