VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[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 resume
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         popl %ebx
37         ret
38
39 resume:
40         movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx
41         movl %ecx,%cr3
42
43         call do_magic_resume_1
44         movl $0,loop
45         cmpl $0,nr_copy_pages
46         je copy_done
47 copy_loop:
48         movl $0,loop2
49         .p2align 4,,7
50 copy_one_page:
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
60         movl loop2,%eax
61         leal 1(%eax),%edx
62         movl %edx,loop2
63         movl %edx,%eax
64         cmpl $4095,%eax
65         jbe copy_one_page
66         movl loop,%eax
67         leal 1(%eax),%edx
68         movl %edx,loop
69         movl %edx,%eax
70         cmpl nr_copy_pages,%eax
71         jb copy_loop
72
73 copy_done:
74         movl $__USER_DS,%eax
75
76         movw %ax, %ds
77         movw %ax, %es
78         movl saved_context_esp, %esp
79         movl saved_context_ebp, %ebp
80         movl saved_context_eax, %eax
81         movl saved_context_ebx, %ebx
82         movl saved_context_ecx, %ecx
83         movl saved_context_edx, %edx
84         movl saved_context_esi, %esi
85         movl saved_context_edi, %edi
86         call restore_processor_state
87         pushl saved_context_eflags ; popfl
88         call do_magic_resume_2
89         popl %ebx
90         ret
91
92        .section .data.nosave
93 loop:
94        .quad 0
95 loop2:
96        .quad 0
97        .previous