patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / i386 / power / swsusp.S
1 .text
2
3 /* Originally gcc generated, modified by hand
4  *
5  * This may not use any stack, nor any variable that is not "NoSave":
6  *
7  * Its rewriting one kernel image with another. What is stack in "old"
8  * image could very well be data page in "new" image, and overwriting
9  * your own stack under you is bad idea.
10  */
11
12 #include <linux/linkage.h>
13 #include <asm/segment.h>
14 #include <asm/page.h>
15
16         .text
17
18 ENTRY(do_magic)
19         pushl %ebx
20         cmpl $0,8(%esp)
21         jne .L1450
22         call do_magic_suspend_1
23         call save_processor_state
24
25         movl %esp, saved_context_esp
26         movl %eax, saved_context_eax
27         movl %ebx, saved_context_ebx
28         movl %ecx, saved_context_ecx
29         movl %edx, saved_context_edx
30         movl %ebp, saved_context_ebp
31         movl %esi, saved_context_esi
32         movl %edi, saved_context_edi
33         pushfl ; popl saved_context_eflags
34
35         call do_magic_suspend_2
36         jmp .L1449
37         .p2align 4,,7
38 .L1450:
39         movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx
40         movl %ecx,%cr3
41
42         call do_magic_resume_1
43         movl $0,loop
44         cmpl $0,nr_copy_pages
45         je .L1453
46         .p2align 4,,7
47 .L1455:
48         movl $0,loop2
49         .p2align 4,,7
50 .L1459:
51         movl pagedir_nosave,%ecx
52         movl loop,%eax
53         movl loop2,%edx
54         sall $4,%eax
55         movl 4(%ecx,%eax),%ebx
56         movl (%ecx,%eax),%eax
57         movb (%edx,%eax),%al
58         movb %al,(%edx,%ebx)
59         movl %cr3, %eax;              
60         movl %eax, %cr3;  # flush TLB 
61
62         movl loop2,%eax
63         leal 1(%eax),%edx
64         movl %edx,loop2
65         movl %edx,%eax
66         cmpl $4095,%eax
67         jbe .L1459
68         movl loop,%eax
69         leal 1(%eax),%edx
70         movl %edx,loop
71         movl %edx,%eax
72         cmpl nr_copy_pages,%eax
73         jb .L1455
74         .p2align 4,,7
75 .L1453:
76         movl $__USER_DS,%eax
77
78         movw %ax, %ds
79         movw %ax, %es
80         movl saved_context_esp, %esp
81         movl saved_context_ebp, %ebp
82         movl saved_context_eax, %eax
83         movl saved_context_ebx, %ebx
84         movl saved_context_ecx, %ecx
85         movl saved_context_edx, %edx
86         movl saved_context_esi, %esi
87         movl saved_context_edi, %edi
88         call restore_processor_state
89         pushl saved_context_eflags ; popfl
90         call do_magic_resume_2
91 .L1449:
92         popl %ebx
93         ret
94
95        .section .data.nosave
96 loop:
97        .quad 0
98 loop2:
99        .quad 0
100        .previous