Linux-libre 3.4.8-gnu1
[librecmc/linux-libre.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         call    acpi_enter_s3
75         /* in case something went wrong, restore the machine status and go on */
76         jmp     resume_point
77
78         .align 4
79 resume_point:
80         /* We don't restore %rax, it must be 0 anyway */
81         movq    $saved_context, %rax
82         movq    saved_context_cr4(%rax), %rbx
83         movq    %rbx, %cr4
84         movq    saved_context_cr3(%rax), %rbx
85         movq    %rbx, %cr3
86         movq    saved_context_cr2(%rax), %rbx
87         movq    %rbx, %cr2
88         movq    saved_context_cr0(%rax), %rbx
89         movq    %rbx, %cr0
90         pushq   pt_regs_flags(%rax)
91         popfq
92         movq    pt_regs_sp(%rax), %rsp
93         movq    pt_regs_bp(%rax), %rbp
94         movq    pt_regs_si(%rax), %rsi
95         movq    pt_regs_di(%rax), %rdi
96         movq    pt_regs_bx(%rax), %rbx
97         movq    pt_regs_cx(%rax), %rcx
98         movq    pt_regs_dx(%rax), %rdx
99         movq    pt_regs_r8(%rax), %r8
100         movq    pt_regs_r9(%rax), %r9
101         movq    pt_regs_r10(%rax), %r10
102         movq    pt_regs_r11(%rax), %r11
103         movq    pt_regs_r12(%rax), %r12
104         movq    pt_regs_r13(%rax), %r13
105         movq    pt_regs_r14(%rax), %r14
106         movq    pt_regs_r15(%rax), %r15
107
108         xorl    %eax, %eax
109         addq    $8, %rsp
110         jmp     restore_processor_state
111 ENDPROC(do_suspend_lowlevel)
112
113 .data
114 ENTRY(saved_rbp)        .quad   0
115 ENTRY(saved_rsi)        .quad   0
116 ENTRY(saved_rdi)        .quad   0
117 ENTRY(saved_rbx)        .quad   0
118
119 ENTRY(saved_rip)        .quad   0
120 ENTRY(saved_rsp)        .quad   0
121
122 ENTRY(saved_magic)      .quad   0