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 $1, beep_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, video_flags - wakeup_code
68 movw %ax, %ds # Bios might have played with that
72 testl $2, video_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 $2, beep_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
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
160 testb $VIDEO_RECALC>>8, %ah
163 cmpb $VIDEO_FIRST_RESOLUTION>>8, %ah
166 cmpb $VIDEO_FIRST_SPECIAL>>8, %ah
169 cmpb $VIDEO_FIRST_V7>>8, %ah
173 cmpb $VIDEO_FIRST_VESA>>8, %ah
181 # jz setbios Add bios modes later
187 subb $VIDEO_FIRST_VESA>>8, %bh
188 orw $0x4000, %bx # Use linear frame buffer
189 movw $0x4f02, %ax # VESA BIOS mode set call
191 cmpw $0x004f, %ax # AL=4f if implemented
192 jnz _setbad # AH=0 if OK
203 wakeup_stack_begin: # Stack grows down
205 .org 0xff0 # Just below end of page
212 movw $__KERNEL_DS, %ax
218 movw $0x0e00 + 'u', 0xb8016
220 # reload the gdt, as we need the full 32 bit address
224 ljmp $(__KERNEL_CS),$1f
230 # and restore the stack ... but you need gdt for this to work
231 movl saved_context_esp, %esp
233 movl %cs:saved_magic, %eax
234 cmpl $0x12345678, %eax
237 # jump to place where we left off
242 movw $0x0e00 + 'B', 0xb8018
247 # acpi_copy_wakeup_routine
249 # Copy the above routine to low memory.
252 # %eax: place to copy wakeup routine to
254 # Returned address is location of code in low memory (past data and stack)
256 ENTRY(acpi_copy_wakeup_routine)
264 movl nx_enabled, %edx
265 movl %edx, real_efer_save_restore - wakeup_start (%eax)
266 testl $1, real_efer_save_restore - wakeup_start (%eax)
271 mov $0xc0000080, %ecx
273 movl %edx, real_save_efer_edx - wakeup_start (%ebx)
274 movl %eax, real_save_efer_eax - wakeup_start (%ebx)
279 movl %edx, real_save_cr3 - wakeup_start (%eax)
281 movl %edx, real_save_cr4 - wakeup_start (%eax)
283 movl %edx, real_save_cr0 - wakeup_start (%eax)
284 sgdt real_save_gdt - wakeup_start (%eax)
286 movl saved_videomode, %edx
287 movl %edx, video_mode - wakeup_start (%eax)
288 movl acpi_video_flags, %edx
289 movl %edx, video_flags - wakeup_start (%eax)
290 movl s2ram_beep, %edx
291 movl %edx, beep_flags - wakeup_start (%eax)
292 movl $0x12345678, real_magic - wakeup_start (%eax)
293 movl $0x12345678, saved_magic
299 movl %eax, saved_context_esp
300 movl %ebx, saved_context_ebx
301 movl %ebp, saved_context_ebp
302 movl %esi, saved_context_esi
303 movl %edi, saved_context_edi
304 pushfl ; popl saved_context_eflags
306 movl $ret_point, saved_eip
311 movl saved_context_ebp, %ebp
312 movl saved_context_ebx, %ebx
313 movl saved_context_esi, %esi
314 movl saved_context_edi, %edi
315 pushl saved_context_eflags ; popfl
318 ENTRY(do_suspend_lowlevel)
319 call save_processor_state
322 call acpi_enter_sleep_state
325 # In case of S3 failure, we'll emerge here. Jump
326 # to ret_point to recover
330 call restore_registers
331 call restore_processor_state
336 ENTRY(saved_magic) .long 0
337 ENTRY(saved_eip) .long 0