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)
77 # need a gdt -- use lgdtl to force 32-bit operands, in case
78 # the GDT is located past 16 megabytes.
79 lgdtl real_save_gdt - wakeup_code
81 movl real_save_cr0 - wakeup_code, %eax
85 movw $0x0e00 + 'n', %fs:(0x14)
87 movl real_magic - wakeup_code, %eax
88 cmpl $0x12345678, %eax
91 ljmpl $__KERNEL_CS,$wakeup_pmode_return
93 real_save_gdt: .word 0
95 real_save_cr0: .long 0
96 real_save_cr3: .long 0
97 real_save_cr4: .long 0
101 real_efer_save_restore: .long 0
102 real_save_efer_edx: .long 0
103 real_save_efer_eax: .long 0
106 movw $0x0e00 + 'B', %fs:(0x12)
109 /* This code uses an extended set of video mode numbers. These include:
110 * Aliases for standard modes
114 * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
115 * of compatibility when extending the table. These are between 0x00 and 0xff.
117 #define VIDEO_FIRST_MENU 0x0000
119 /* Standard BIOS video modes (BIOS number + 0x0100) */
120 #define VIDEO_FIRST_BIOS 0x0100
122 /* VESA BIOS video modes (VESA number + 0x0200) */
123 #define VIDEO_FIRST_VESA 0x0200
125 /* Video7 special modes (BIOS number + 0x0900) */
126 #define VIDEO_FIRST_V7 0x0900
128 # Setting of user mode (AX=mode ID) => CF=success
135 testb $VIDEO_RECALC>>8, %ah
138 cmpb $VIDEO_FIRST_RESOLUTION>>8, %ah
141 cmpb $VIDEO_FIRST_SPECIAL>>8, %ah
144 cmpb $VIDEO_FIRST_V7>>8, %ah
148 cmpb $VIDEO_FIRST_VESA>>8, %ah
156 # jz setbios Add bios modes later
162 subb $VIDEO_FIRST_VESA>>8, %bh
163 orw $0x4000, %bx # Use linear frame buffer
164 movw $0x4f02, %ax # VESA BIOS mode set call
166 cmpw $0x004f, %ax # AL=4f if implemented
167 jnz _setbad # AH=0 if OK
178 wakeup_stack_begin: # Stack grows down
180 .org 0xff0 # Just below end of page
187 movw $__KERNEL_DS, %ax
193 movw $0x0e00 + 'u', 0xb8016
195 # reload the gdt, as we need the full 32 bit address
199 ljmp $(__KERNEL_CS),$1f
205 # and restore the stack ... but you need gdt for this to work
206 movl saved_context_esp, %esp
208 movl %cs:saved_magic, %eax
209 cmpl $0x12345678, %eax
212 # jump to place where we left off
217 movw $0x0e00 + 'B', 0xb8018
222 # acpi_copy_wakeup_routine
224 # Copy the above routine to low memory.
227 # %eax: place to copy wakeup routine to
229 # Returned address is location of code in low memory (past data and stack)
231 ENTRY(acpi_copy_wakeup_routine)
238 movl nx_enabled, %edx
239 movl %edx, real_efer_save_restore - wakeup_start (%eax)
240 testl $1, real_efer_save_restore - wakeup_start (%eax)
245 mov $0xc0000080, %ecx
247 movl %edx, real_save_efer_edx - wakeup_start (%ebx)
248 movl %eax, real_save_efer_eax - wakeup_start (%ebx)
253 movl %edx, real_save_cr3 - wakeup_start (%eax)
255 movl %edx, real_save_cr4 - wakeup_start (%eax)
257 movl %edx, real_save_cr0 - wakeup_start (%eax)
258 sgdt real_save_gdt - wakeup_start (%eax)
260 movl saved_videomode, %edx
261 movl %edx, video_mode - wakeup_start (%eax)
262 movl acpi_video_flags, %edx
263 movl %edx, video_flags - wakeup_start (%eax)
264 movl $0x12345678, real_magic - wakeup_start (%eax)
265 movl $0x12345678, saved_magic
270 ENTRY(saved_magic) .long 0
271 ENTRY(saved_eip) .long 0
275 movl %eax, saved_context_esp
276 movl %ebx, saved_context_ebx
277 movl %ebp, saved_context_ebp
278 movl %esi, saved_context_esi
279 movl %edi, saved_context_edi
280 pushfl ; popl saved_context_eflags
282 movl $ret_point, saved_eip
287 movl saved_context_ebp, %ebp
288 movl saved_context_ebx, %ebx
289 movl saved_context_esi, %esi
290 movl saved_context_edi, %edi
291 pushl saved_context_eflags ; popfl
294 ENTRY(do_suspend_lowlevel)
295 call save_processor_state
298 call acpi_enter_sleep_state
303 call restore_registers
304 call restore_processor_state