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
25 movw $0x0e00 + 'L', %fs:(0x10)
32 movw %ax, %ds # Make ds:0 point to wakeup_start
34 mov $(wakeup_stack - wakeup_code), %sp # Private stack is needed for ASUS board
35 movw $0x0e00 + 'S', %fs:(0x12)
37 pushl $0 # Kill any dangerous flags
40 movl real_magic - wakeup_code, %eax
41 cmpl $0x12345678, %eax
44 testl $1, video_flags - wakeup_code
48 movw %ax, %ds # Bios might have played with that
52 testl $2, video_flags - wakeup_code
54 mov video_mode - wakeup_code, %ax
59 movl $swapper_pg_dir-__PAGE_OFFSET, %eax
62 testl $1, real_efer_save_restore - wakeup_code
64 # restore efer setting
65 movl real_save_efer_edx - wakeup_code, %edx
66 movl real_save_efer_eax - wakeup_code, %eax
70 # make sure %cr4 is set correctly (features, etc)
71 movl real_save_cr4 - wakeup_code, %eax
75 movw $0x0e00 + 'i', %fs:(0x12)
78 lgdt real_save_gdt - wakeup_code
80 movl real_save_cr0 - wakeup_code, %eax
84 movw $0x0e00 + 'n', %fs:(0x14)
86 movl real_magic - wakeup_code, %eax
87 cmpl $0x12345678, %eax
90 ljmpl $__KERNEL_CS,$wakeup_pmode_return
92 real_save_gdt: .word 0
94 real_save_cr0: .long 0
95 real_save_cr3: .long 0
96 real_save_cr4: .long 0
100 real_efer_save_restore: .long 0
101 real_save_efer_edx: .long 0
102 real_save_efer_eax: .long 0
105 movw $0x0e00 + 'B', %fs:(0x12)
108 /* This code uses an extended set of video mode numbers. These include:
109 * Aliases for standard modes
113 * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
114 * of compatibility when extending the table. These are between 0x00 and 0xff.
116 #define VIDEO_FIRST_MENU 0x0000
118 /* Standard BIOS video modes (BIOS number + 0x0100) */
119 #define VIDEO_FIRST_BIOS 0x0100
121 /* VESA BIOS video modes (VESA number + 0x0200) */
122 #define VIDEO_FIRST_VESA 0x0200
124 /* Video7 special modes (BIOS number + 0x0900) */
125 #define VIDEO_FIRST_V7 0x0900
127 # Setting of user mode (AX=mode ID) => CF=success
134 testb $VIDEO_RECALC>>8, %ah
137 cmpb $VIDEO_FIRST_RESOLUTION>>8, %ah
140 cmpb $VIDEO_FIRST_SPECIAL>>8, %ah
143 cmpb $VIDEO_FIRST_V7>>8, %ah
147 cmpb $VIDEO_FIRST_VESA>>8, %ah
155 # jz setbios Add bios modes later
161 subb $VIDEO_FIRST_VESA>>8, %bh
162 orw $0x4000, %bx # Use linear frame buffer
163 movw $0x4f02, %ax # VESA BIOS mode set call
165 cmpw $0x004f, %ax # AL=4f if implemented
166 jnz _setbad # AH=0 if OK
177 wakeup_stack_begin: # Stack grows down
179 .org 0xff0 # Just below end of page
186 movw $__KERNEL_DS, %ax
192 movw $0x0e00 + 'u', 0xb8016
194 # reload the gdt, as we need the full 32 bit address
198 ljmp $(__KERNEL_CS),$1f
204 # and restore the stack ... but you need gdt for this to work
205 movl saved_context_esp, %esp
207 movl %cs:saved_magic, %eax
208 cmpl $0x12345678, %eax
211 # jump to place where we left off
216 movw $0x0e00 + 'B', 0xb8018
221 # acpi_copy_wakeup_routine
223 # Copy the above routine to low memory.
226 # %eax: place to copy wakeup routine to
228 # Returned address is location of code in low memory (past data and stack)
230 ENTRY(acpi_copy_wakeup_routine)
237 movl nx_enabled, %edx
238 movl %edx, real_efer_save_restore - wakeup_start (%eax)
239 testl $1, real_efer_save_restore - wakeup_start (%eax)
244 mov $0xc0000080, %ecx
246 movl %edx, real_save_efer_edx - wakeup_start (%ebx)
247 movl %eax, real_save_efer_eax - wakeup_start (%ebx)
252 movl %edx, real_save_cr3 - wakeup_start (%eax)
254 movl %edx, real_save_cr4 - wakeup_start (%eax)
256 movl %edx, real_save_cr0 - wakeup_start (%eax)
257 sgdt real_save_gdt - wakeup_start (%eax)
259 movl saved_videomode, %edx
260 movl %edx, video_mode - wakeup_start (%eax)
261 movl acpi_video_flags, %edx
262 movl %edx, video_flags - wakeup_start (%eax)
263 movl $0x12345678, real_magic - wakeup_start (%eax)
264 movl $0x12345678, saved_magic
269 ENTRY(saved_magic) .long 0
270 ENTRY(saved_eip) .long 0
274 movl %eax, saved_context_esp
275 movl %ebx, saved_context_ebx
276 movl %ebp, saved_context_ebp
277 movl %esi, saved_context_esi
278 movl %edi, saved_context_edi
279 pushfl ; popl saved_context_eflags
281 movl $ret_point, saved_eip
286 movl saved_context_ebp, %ebp
287 movl saved_context_ebx, %ebx
288 movl saved_context_esi, %esi
289 movl saved_context_edi, %edi
290 pushl saved_context_eflags ; popfl
293 ENTRY(do_suspend_lowlevel)
294 call save_processor_state
297 call acpi_enter_sleep_state
302 call restore_registers
303 call restore_processor_state
306 ENTRY(do_suspend_lowlevel_s4bios)
307 call save_processor_state
309 call acpi_enter_sleep_state_s4bios