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 # make sure %cr4 is set correctly (features, etc)
63 movl real_save_cr4 - wakeup_code, %eax
67 movw $0x0e00 + 'i', %fs:(0x12)
70 lgdt real_save_gdt - wakeup_code
72 movl real_save_cr0 - wakeup_code, %eax
76 movw $0x0e00 + 'n', %fs:(0x14)
78 movl real_magic - wakeup_code, %eax
79 cmpl $0x12345678, %eax
82 ljmpl $__KERNEL_CS,$wakeup_pmode_return
84 real_save_gdt: .word 0
86 real_save_cr0: .long 0
87 real_save_cr3: .long 0
88 real_save_cr4: .long 0
94 movw $0x0e00 + 'B', %fs:(0x12)
97 /* This code uses an extended set of video mode numbers. These include:
98 * Aliases for standard modes
102 * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
103 * of compatibility when extending the table. These are between 0x00 and 0xff.
105 #define VIDEO_FIRST_MENU 0x0000
107 /* Standard BIOS video modes (BIOS number + 0x0100) */
108 #define VIDEO_FIRST_BIOS 0x0100
110 /* VESA BIOS video modes (VESA number + 0x0200) */
111 #define VIDEO_FIRST_VESA 0x0200
113 /* Video7 special modes (BIOS number + 0x0900) */
114 #define VIDEO_FIRST_V7 0x0900
116 # Setting of user mode (AX=mode ID) => CF=success
123 testb $VIDEO_RECALC>>8, %ah
126 cmpb $VIDEO_FIRST_RESOLUTION>>8, %ah
129 cmpb $VIDEO_FIRST_SPECIAL>>8, %ah
132 cmpb $VIDEO_FIRST_V7>>8, %ah
136 cmpb $VIDEO_FIRST_VESA>>8, %ah
144 # jz setbios Add bios modes later
150 subb $VIDEO_FIRST_VESA>>8, %bh
151 orw $0x4000, %bx # Use linear frame buffer
152 movw $0x4f02, %ax # VESA BIOS mode set call
154 cmpw $0x004f, %ax # AL=4f if implemented
155 jnz _setbad # AH=0 if OK
166 wakeup_stack_begin: # Stack grows down
168 .org 0xff0 # Just below end of page
175 movw $__KERNEL_DS, %ax
181 movw $0x0e00 + 'u', 0xb8016
183 # reload the gdt, as we need the full 32 bit address
187 ljmp $(__KERNEL_CS),$1f
193 # and restore the stack ... but you need gdt for this to work
194 movl saved_context_esp, %esp
196 movl %cs:saved_magic, %eax
197 cmpl $0x12345678, %eax
200 # jump to place where we left off
205 movw $0x0e00 + 'B', 0xb8018
210 # acpi_copy_wakeup_routine
212 # Copy the above routine to low memory.
215 # %eax: place to copy wakeup routine to
217 # Returned address is location of code in low memory (past data and stack)
219 ENTRY(acpi_copy_wakeup_routine)
227 movl %edx, real_save_cr3 - wakeup_start (%eax)
229 movl %edx, real_save_cr4 - wakeup_start (%eax)
231 movl %edx, real_save_cr0 - wakeup_start (%eax)
232 sgdt real_save_gdt - wakeup_start (%eax)
234 movl saved_videomode, %edx
235 movl %edx, video_mode - wakeup_start (%eax)
236 movl acpi_video_flags, %edx
237 movl %edx, video_flags - wakeup_start (%eax)
238 movl $0x12345678, real_magic - wakeup_start (%eax)
239 movl $0x12345678, saved_magic
244 ENTRY(saved_magic) .long 0
245 ENTRY(saved_eip) .long 0
249 movl %eax, saved_context_esp
250 movl %ebx, saved_context_ebx
251 movl %ebp, saved_context_ebp
252 movl %esi, saved_context_esi
253 movl %edi, saved_context_edi
254 pushfl ; popl saved_context_eflags
256 movl $ret_point,saved_eip
261 movl saved_context_ebp, %ebp
262 movl saved_context_ebx, %ebx
263 movl saved_context_esi, %esi
264 movl saved_context_edi, %edi
265 pushl saved_context_eflags ; popfl
268 ENTRY(do_suspend_lowlevel)
269 call save_processor_state
272 call acpi_enter_sleep_state
277 call restore_registers
278 call restore_processor_state
281 ENTRY(do_suspend_lowlevel_s4bios)
282 call save_processor_state
284 call acpi_enter_sleep_state_s4bios