blob: 665c6b7d2ea93c25740a4b18043d5602d33d9711 [file] [log] [blame]
Jan Beulichec7fd342013-03-11 10:06:12 +00001 .text
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include <linux/linkage.h>
3#include <asm/segment.h>
Jeremy Fitzhardinge0341c142009-02-13 11:14:01 -08004#include <asm/page_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Pavel Macheke44b7b72008-04-10 23:28:10 +02006# Copyright 2003, 2008 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 .code32
9 ALIGN
10
Pavel Macheke44b7b72008-04-10 23:28:10 +020011ENTRY(wakeup_pmode_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012wakeup_pmode_return:
13 movw $__KERNEL_DS, %ax
14 movw %ax, %ss
15 movw %ax, %ds
16 movw %ax, %es
17 movw %ax, %fs
18 movw %ax, %gs
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20 # reload the gdt, as we need the full 32 bit address
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 lidt saved_idt
22 lldt saved_ldt
Pavel Macheke44b7b72008-04-10 23:28:10 +020023 ljmp $(__KERNEL_CS), $1f
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241:
25 movl %cr3, %eax
26 movl %eax, %cr3
27 wbinvd
28
29 # and restore the stack ... but you need gdt for this to work
30 movl saved_context_esp, %esp
31
32 movl %cs:saved_magic, %eax
33 cmpl $0x12345678, %eax
34 jne bogus_magic
35
36 # jump to place where we left off
Pavel Macheke44b7b72008-04-10 23:28:10 +020037 movl saved_eip, %eax
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 jmp *%eax
39
40bogus_magic:
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 jmp bogus_magic
42
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Pavel Macheke44b7b72008-04-10 23:28:10 +020045save_registers:
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 sidt saved_idt
47 sldt saved_ldt
48 str saved_tss
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 leal 4(%esp), %eax
51 movl %eax, saved_context_esp
Pavel Macheke44b7b72008-04-10 23:28:10 +020052 movl %ebx, saved_context_ebx
53 movl %ebp, saved_context_ebp
54 movl %esi, saved_context_esi
55 movl %edi, saved_context_edi
56 pushfl
57 popl saved_context_eflags
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Pavel Macheke44b7b72008-04-10 23:28:10 +020059 movl $ret_point, saved_eip
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 ret
61
62
63restore_registers:
Pavel Macheke44b7b72008-04-10 23:28:10 +020064 movl saved_context_ebp, %ebp
65 movl saved_context_ebx, %ebx
66 movl saved_context_esi, %esi
67 movl saved_context_edi, %edi
68 pushl saved_context_eflags
69 popfl
70 ret
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72ENTRY(do_suspend_lowlevel)
73 call save_processor_state
74 call save_registers
Len Brown3b6961b2012-07-26 19:40:08 -040075 pushl $3
Lv Zheng40bce102013-10-31 09:31:18 +080076 call x86_acpi_enter_sleep_state
Len Brown3b6961b2012-07-26 19:40:08 -040077 addl $4, %esp
William Morrrow4e6e6502006-08-14 22:37:31 -070078
79# In case of S3 failure, we'll emerge here. Jump
80# to ret_point to recover
81 jmp ret_point
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 .p2align 4,,7
83ret_point:
84 call restore_registers
85 call restore_processor_state
86 ret
87
Shaohua Lidaacf8b2006-06-23 02:04:50 -070088.data
Linus Torvalds1da177e2005-04-16 15:20:36 -070089ALIGN
Shaohua Lidaacf8b2006-06-23 02:04:50 -070090ENTRY(saved_magic) .long 0
91ENTRY(saved_eip) .long 0
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093# saved registers
Linus Torvalds1da177e2005-04-16 15:20:36 -070094saved_idt: .long 0,0
95saved_ldt: .long 0
96saved_tss: .long 0
97