blob: 8ea5164cbd0451a27b9048699f60c2420057edb3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001.text
2#include <linux/linkage.h>
3#include <asm/segment.h>
Jeremy Fitzhardinge0341c142009-02-13 11:14:01 -08004#include <asm/pgtable_types.h>
5#include <asm/page_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/msr.h>
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +02007#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9# Copyright 2003 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11.code64
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 /*
Pavel Macheke44b7b72008-04-10 23:28:10 +020013 * Hooray, we are in Long 64-bit mode (but still running in low memory)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 */
Pavel Macheke44b7b72008-04-10 23:28:10 +020015ENTRY(wakeup_long64)
Pavel Macheke44b7b72008-04-10 23:28:10 +020016 movq saved_magic, %rax
17 movq $0x123456789abcdef0, %rdx
18 cmpq %rdx, %rax
19 jne bogus_64_magic
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 movw $__KERNEL_DS, %ax
22 movw %ax, %ss
23 movw %ax, %ds
24 movw %ax, %es
25 movw %ax, %fs
26 movw %ax, %gs
Vivek Goyal7db681d2007-05-02 19:27:07 +020027 movq saved_rsp, %rsp
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Vivek Goyal7db681d2007-05-02 19:27:07 +020029 movq saved_rbx, %rbx
30 movq saved_rdi, %rdi
31 movq saved_rsi, %rsi
32 movq saved_rbp, %rbp
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Vivek Goyal7db681d2007-05-02 19:27:07 +020034 movq saved_rip, %rax
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 jmp *%rax
Jiri Slabye6bd6762009-02-15 22:45:49 +010036ENDPROC(wakeup_long64)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Vivek Goyald8e1baf2007-05-02 19:27:07 +020038bogus_64_magic:
Pavel Macheke44b7b72008-04-10 23:28:10 +020039 jmp bogus_64_magic
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Jiri Slabye6bd6762009-02-15 22:45:49 +010041ENTRY(do_suspend_lowlevel)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 subq $8, %rsp
43 xorl %eax, %eax
44 call save_processor_state
45
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +020046 movq $saved_context, %rax
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010047 movq %rsp, pt_regs_sp(%rax)
48 movq %rbp, pt_regs_bp(%rax)
49 movq %rsi, pt_regs_si(%rax)
50 movq %rdi, pt_regs_di(%rax)
51 movq %rbx, pt_regs_bx(%rax)
52 movq %rcx, pt_regs_cx(%rax)
53 movq %rdx, pt_regs_dx(%rax)
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +020054 movq %r8, pt_regs_r8(%rax)
55 movq %r9, pt_regs_r9(%rax)
56 movq %r10, pt_regs_r10(%rax)
57 movq %r11, pt_regs_r11(%rax)
58 movq %r12, pt_regs_r12(%rax)
59 movq %r13, pt_regs_r13(%rax)
60 movq %r14, pt_regs_r14(%rax)
61 movq %r15, pt_regs_r15(%rax)
62 pushfq
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010063 popq pt_regs_flags(%rax)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Jiri Slabye6bd6762009-02-15 22:45:49 +010065 movq $resume_point, saved_rip(%rip)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +020067 movq %rsp, saved_rsp
68 movq %rbp, saved_rbp
69 movq %rbx, saved_rbx
70 movq %rdi, saved_rdi
71 movq %rsi, saved_rsi
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73 addq $8, %rsp
74 movl $3, %edi
75 xorl %eax, %eax
Jiri Slaby6defa2f2009-02-15 22:46:45 +010076 call acpi_enter_sleep_state
77 /* in case something went wrong, restore the machine status and go on */
78 jmp resume_point
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +020079
Jiri Slabye6bd6762009-02-15 22:45:49 +010080 .align 4
81resume_point:
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +020082 /* We don't restore %rax, it must be 0 anyway */
83 movq $saved_context, %rax
84 movq saved_context_cr4(%rax), %rbx
85 movq %rbx, %cr4
86 movq saved_context_cr3(%rax), %rbx
87 movq %rbx, %cr3
88 movq saved_context_cr2(%rax), %rbx
89 movq %rbx, %cr2
90 movq saved_context_cr0(%rax), %rbx
91 movq %rbx, %cr0
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010092 pushq pt_regs_flags(%rax)
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +020093 popfq
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010094 movq pt_regs_sp(%rax), %rsp
95 movq pt_regs_bp(%rax), %rbp
96 movq pt_regs_si(%rax), %rsi
97 movq pt_regs_di(%rax), %rdi
98 movq pt_regs_bx(%rax), %rbx
99 movq pt_regs_cx(%rax), %rcx
100 movq pt_regs_dx(%rax), %rdx
Rafael J. Wysocki0de80bc2007-10-23 22:37:24 +0200101 movq pt_regs_r8(%rax), %r8
102 movq pt_regs_r9(%rax), %r9
103 movq pt_regs_r10(%rax), %r10
104 movq pt_regs_r11(%rax), %r11
105 movq pt_regs_r12(%rax), %r12
106 movq pt_regs_r13(%rax), %r13
107 movq pt_regs_r14(%rax), %r14
108 movq pt_regs_r15(%rax), %r15
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110 xorl %eax, %eax
111 addq $8, %rsp
112 jmp restore_processor_state
Jiri Slabye6bd6762009-02-15 22:45:49 +0100113ENDPROC(do_suspend_lowlevel)
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115.data
Vivek Goyal7db681d2007-05-02 19:27:07 +0200116ENTRY(saved_rbp) .quad 0
117ENTRY(saved_rsi) .quad 0
118ENTRY(saved_rdi) .quad 0
119ENTRY(saved_rbx) .quad 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Vivek Goyal7db681d2007-05-02 19:27:07 +0200121ENTRY(saved_rip) .quad 0
122ENTRY(saved_rsp) .quad 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
124ENTRY(saved_magic) .quad 0