1 .section .text.page_aligned
2 #include <linux/linkage.h>
3 #include <asm/segment.h>
7 # wakeup_code runs in real mode, and at unknown address (determined at run-time).
8 # Therefore it must only use relative jumps/calls.
10 # Do we need to deal with A20? It is okay: ACPI specs says A20 must be enabled
12 # If physical address of wakeup_code is 0x12345, BIOS should call us with
13 # cs = 0x1234, eip = 0x05
43 movw %ax, %ds # Make ds:0 point to wakeup_start
46 testl $4, realmode_flags - wakeup_code
50 mov $(wakeup_stack - wakeup_code), %sp # Private stack is needed for ASUS board
52 pushl $0 # Kill any dangerous flags
55 movl real_magic - wakeup_code, %eax
56 cmpl $0x12345678, %eax
59 testl $1, realmode_flags - wakeup_code
63 movw %ax, %ds # Bios might have played with that
67 testl $2, realmode_flags - wakeup_code
69 mov video_mode - wakeup_code, %ax
74 movl $swsusp_pg_dir-__PAGE_OFFSET, %eax
77 testl $1, real_efer_save_restore - wakeup_code
79 # restore efer setting
80 movl real_save_efer_edx - wakeup_code, %edx
81 movl real_save_efer_eax - wakeup_code, %eax
85 # make sure %cr4 is set correctly (features, etc)
86 movl real_save_cr4 - wakeup_code, %eax
89 # need a gdt -- use lgdtl to force 32-bit operands, in case
90 # the GDT is located past 16 megabytes.
91 lgdtl real_save_gdt - wakeup_code
93 movl real_save_cr0 - wakeup_code, %eax
97 movl real_magic - wakeup_code, %eax
98 cmpl $0x12345678, %eax
101 testl $8, realmode_flags - wakeup_code
105 ljmpl $__KERNEL_CS, $wakeup_pmode_return
107 real_save_gdt: .word 0
109 real_save_cr0: .long 0
110 real_save_cr3: .long 0
111 real_save_cr4: .long 0
114 realmode_flags: .long 0
115 real_efer_save_restore: .long 0
116 real_save_efer_edx: .long 0
117 real_save_efer_eax: .long 0
122 /* This code uses an extended set of video mode numbers. These include:
123 * Aliases for standard modes
127 * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
128 * of compatibility when extending the table. These are between 0x00 and 0xff.
130 #define VIDEO_FIRST_MENU 0x0000
132 /* Standard BIOS video modes (BIOS number + 0x0100) */
133 #define VIDEO_FIRST_BIOS 0x0100
135 /* VESA BIOS video modes (VESA number + 0x0200) */
136 #define VIDEO_FIRST_VESA 0x0200
138 /* Video7 special modes (BIOS number + 0x0900) */
139 #define VIDEO_FIRST_V7 0x0900
141 # Setting of user mode (AX=mode ID) => CF=success
143 # For now, we only handle VESA modes (0x0200..0x03ff). To handle other
144 # modes, we should probably compile in the video code from the boot
148 subb $VIDEO_FIRST_VESA>>8, %bh
157 orw $0x4000, %bx # Use linear frame buffer
158 movw $0x4f02, %ax # VESA BIOS mode set call
160 cmpw $0x004f, %ax # AL=4f if implemented
161 jnz setbad # AH=0 if OK
170 wakeup_stack_begin: # Stack grows down
172 .org 0xff0 # Just below end of page
179 movw $__KERNEL_DS, %ax
186 # reload the gdt, as we need the full 32 bit address
190 ljmp $(__KERNEL_CS),$1f
196 # and restore the stack ... but you need gdt for this to work
197 movl saved_context_esp, %esp
199 movl %cs:saved_magic, %eax
200 cmpl $0x12345678, %eax
203 # jump to place where we left off
212 # acpi_copy_wakeup_routine
214 # Copy the above routine to low memory.
217 # %eax: place to copy wakeup routine to
219 # Returned address is location of code in low memory (past data and stack)
221 ENTRY(acpi_copy_wakeup_routine)
229 movl nx_enabled, %edx
230 movl %edx, real_efer_save_restore - wakeup_start (%eax)
231 testl $1, real_efer_save_restore - wakeup_start (%eax)
236 mov $0xc0000080, %ecx
238 movl %edx, real_save_efer_edx - wakeup_start (%ebx)
239 movl %eax, real_save_efer_eax - wakeup_start (%ebx)
244 movl %edx, real_save_cr3 - wakeup_start (%eax)
246 movl %edx, real_save_cr4 - wakeup_start (%eax)
248 movl %edx, real_save_cr0 - wakeup_start (%eax)
249 sgdt real_save_gdt - wakeup_start (%eax)
251 movl saved_videomode, %edx
252 movl %edx, video_mode - wakeup_start (%eax)
253 movl acpi_realmode_flags, %edx
254 movl %edx, realmode_flags - wakeup_start (%eax)
255 movl $0x12345678, real_magic - wakeup_start (%eax)
256 movl $0x12345678, saved_magic
262 movl %eax, saved_context_esp
263 movl %ebx, saved_context_ebx
264 movl %ebp, saved_context_ebp
265 movl %esi, saved_context_esi
266 movl %edi, saved_context_edi
267 pushfl ; popl saved_context_eflags
269 movl $ret_point, saved_eip
274 movl saved_context_ebp, %ebp
275 movl saved_context_ebx, %ebx
276 movl saved_context_esi, %esi
277 movl saved_context_edi, %edi
278 pushl saved_context_eflags ; popfl
281 ENTRY(do_suspend_lowlevel)
282 call save_processor_state
285 call acpi_enter_sleep_state
288 # In case of S3 failure, we'll emerge here. Jump
289 # to ret_point to recover
293 call restore_registers
294 call restore_processor_state
299 ENTRY(saved_magic) .long 0
300 ENTRY(saved_eip) .long 0