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
40 movw $0x0e00 + 'L', %fs:(0x10)
47 movw %ax, %ds # Make ds:0 point to wakeup_start
50 testl $4, realmode_flags - wakeup_code
54 mov $(wakeup_stack - wakeup_code), %sp # Private stack is needed for ASUS board
55 movw $0x0e00 + 'S', %fs:(0x12)
57 pushl $0 # Kill any dangerous flags
60 movl real_magic - wakeup_code, %eax
61 cmpl $0x12345678, %eax
64 testl $1, realmode_flags - wakeup_code
68 movw %ax, %ds # Bios might have played with that
72 testl $2, realmode_flags - wakeup_code
74 mov video_mode - wakeup_code, %ax
79 movl $swsusp_pg_dir-__PAGE_OFFSET, %eax
82 testl $1, real_efer_save_restore - wakeup_code
84 # restore efer setting
85 movl real_save_efer_edx - wakeup_code, %edx
86 movl real_save_efer_eax - wakeup_code, %eax
90 # make sure %cr4 is set correctly (features, etc)
91 movl real_save_cr4 - wakeup_code, %eax
95 movw $0x0e00 + 'i', %fs:(0x12)
97 # need a gdt -- use lgdtl to force 32-bit operands, in case
98 # the GDT is located past 16 megabytes.
99 lgdtl real_save_gdt - wakeup_code
101 movl real_save_cr0 - wakeup_code, %eax
105 movw $0x0e00 + 'n', %fs:(0x14)
107 movl real_magic - wakeup_code, %eax
108 cmpl $0x12345678, %eax
111 testl $8, realmode_flags - wakeup_code
115 ljmpl $__KERNEL_CS, $wakeup_pmode_return
117 real_save_gdt: .word 0
119 real_save_cr0: .long 0
120 real_save_cr3: .long 0
121 real_save_cr4: .long 0
124 realmode_flags: .long 0
126 real_efer_save_restore: .long 0
127 real_save_efer_edx: .long 0
128 real_save_efer_eax: .long 0
131 movw $0x0e00 + 'B', %fs:(0x12)
134 /* This code uses an extended set of video mode numbers. These include:
135 * Aliases for standard modes
139 * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
140 * of compatibility when extending the table. These are between 0x00 and 0xff.
142 #define VIDEO_FIRST_MENU 0x0000
144 /* Standard BIOS video modes (BIOS number + 0x0100) */
145 #define VIDEO_FIRST_BIOS 0x0100
147 /* VESA BIOS video modes (VESA number + 0x0200) */
148 #define VIDEO_FIRST_VESA 0x0200
150 /* Video7 special modes (BIOS number + 0x0900) */
151 #define VIDEO_FIRST_V7 0x0900
153 # Setting of user mode (AX=mode ID) => CF=success
155 # For now, we only handle VESA modes (0x0200..0x03ff). To handle other
156 # modes, we should probably compile in the video code from the boot
160 subb $VIDEO_FIRST_VESA>>8, %bh
169 orw $0x4000, %bx # Use linear frame buffer
170 movw $0x4f02, %ax # VESA BIOS mode set call
172 cmpw $0x004f, %ax # AL=4f if implemented
173 jnz setbad # AH=0 if OK
182 wakeup_stack_begin: # Stack grows down
184 .org 0xff0 # Just below end of page
191 movw $__KERNEL_DS, %ax
197 movw $0x0e00 + 'u', 0xb8016
199 # reload the gdt, as we need the full 32 bit address
203 ljmp $(__KERNEL_CS),$1f
209 # and restore the stack ... but you need gdt for this to work
210 movl saved_context_esp, %esp
212 movl %cs:saved_magic, %eax
213 cmpl $0x12345678, %eax
216 # jump to place where we left off
221 movw $0x0e00 + 'B', 0xb8018
226 # acpi_copy_wakeup_routine
228 # Copy the above routine to low memory.
231 # %eax: place to copy wakeup routine to
233 # Returned address is location of code in low memory (past data and stack)
235 ENTRY(acpi_copy_wakeup_routine)
243 movl nx_enabled, %edx
244 movl %edx, real_efer_save_restore - wakeup_start (%eax)
245 testl $1, real_efer_save_restore - wakeup_start (%eax)
250 mov $0xc0000080, %ecx
252 movl %edx, real_save_efer_edx - wakeup_start (%ebx)
253 movl %eax, real_save_efer_eax - wakeup_start (%ebx)
258 movl %edx, real_save_cr3 - wakeup_start (%eax)
260 movl %edx, real_save_cr4 - wakeup_start (%eax)
262 movl %edx, real_save_cr0 - wakeup_start (%eax)
263 sgdt real_save_gdt - wakeup_start (%eax)
265 movl saved_videomode, %edx
266 movl %edx, video_mode - wakeup_start (%eax)
267 movl acpi_realmode_flags, %edx
268 movl %edx, realmode_flags - wakeup_start (%eax)
269 movl $0x12345678, real_magic - wakeup_start (%eax)
270 movl $0x12345678, saved_magic
276 movl %eax, saved_context_esp
277 movl %ebx, saved_context_ebx
278 movl %ebp, saved_context_ebp
279 movl %esi, saved_context_esi
280 movl %edi, saved_context_edi
281 pushfl ; popl saved_context_eflags
283 movl $ret_point, saved_eip
288 movl saved_context_ebp, %ebp
289 movl saved_context_ebx, %ebx
290 movl saved_context_esi, %esi
291 movl saved_context_edi, %edi
292 pushl saved_context_eflags ; popfl
295 ENTRY(do_suspend_lowlevel)
296 call save_processor_state
299 call acpi_enter_sleep_state
302 # In case of S3 failure, we'll emerge here. Jump
303 # to ret_point to recover
307 call restore_registers
308 call restore_processor_state
313 ENTRY(saved_magic) .long 0
314 ENTRY(saved_eip) .long 0