Merge branch 'locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / arch / x86 / kernel / acpi / wakeup_64.S
1 .text
2 #include <linux/linkage.h>
3 #include <asm/segment.h>
4 #include <asm/pgtable_types.h>
5 #include <asm/page_types.h>
6 #include <asm/msr.h>
7 #include <asm/asm-offsets.h>
8
9 # Copyright 2003 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
10
11 .code64
12         /*
13          * Hooray, we are in Long 64-bit mode (but still running in low memory)
14          */
15 ENTRY(wakeup_long64)
16         movq    saved_magic, %rax
17         movq    $0x123456789abcdef0, %rdx
18         cmpq    %rdx, %rax
19         jne     bogus_64_magic
20
21         movw    $__KERNEL_DS, %ax
22         movw    %ax, %ss        
23         movw    %ax, %ds
24         movw    %ax, %es
25         movw    %ax, %fs
26         movw    %ax, %gs
27         movq    saved_rsp, %rsp
28
29         movq    saved_rbx, %rbx
30         movq    saved_rdi, %rdi
31         movq    saved_rsi, %rsi
32         movq    saved_rbp, %rbp
33
34         movq    saved_rip, %rax
35         jmp     *%rax
36 ENDPROC(wakeup_long64)
37
38 bogus_64_magic:
39         jmp     bogus_64_magic
40
41 ENTRY(do_suspend_lowlevel)
42         subq    $8, %rsp
43         xorl    %eax, %eax
44         call    save_processor_state
45
46         movq    $saved_context, %rax
47         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)
54         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
63         popq    pt_regs_flags(%rax)
64
65         movq    $resume_point, saved_rip(%rip)
66
67         movq    %rsp, saved_rsp
68         movq    %rbp, saved_rbp
69         movq    %rbx, saved_rbx
70         movq    %rdi, saved_rdi
71         movq    %rsi, saved_rsi
72
73         addq    $8, %rsp
74         movl    $3, %edi
75         xorl    %eax, %eax
76         call    acpi_enter_sleep_state
77         /* in case something went wrong, restore the machine status and go on */
78         jmp     resume_point
79
80         .align 4
81 resume_point:
82         /* 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
92         pushq   pt_regs_flags(%rax)
93         popfq
94         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
101         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
109
110         xorl    %eax, %eax
111         addq    $8, %rsp
112         jmp     restore_processor_state
113 ENDPROC(do_suspend_lowlevel)
114
115 .data
116 ENTRY(saved_rbp)        .quad   0
117 ENTRY(saved_rsi)        .quad   0
118 ENTRY(saved_rdi)        .quad   0
119 ENTRY(saved_rbx)        .quad   0
120
121 ENTRY(saved_rip)        .quad   0
122 ENTRY(saved_rsp)        .quad   0
123
124 ENTRY(saved_magic)      .quad   0