swsusp.S 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .text
  2. /* Originally gcc generated, modified by hand
  3. *
  4. * This may not use any stack, nor any variable that is not "NoSave":
  5. *
  6. * Its rewriting one kernel image with another. What is stack in "old"
  7. * image could very well be data page in "new" image, and overwriting
  8. * your own stack under you is bad idea.
  9. */
  10. #include <linux/linkage.h>
  11. #include <asm/segment.h>
  12. #include <asm/page.h>
  13. #include <asm/asm-offsets.h>
  14. .text
  15. ENTRY(swsusp_arch_suspend)
  16. movl %esp, saved_context_esp
  17. movl %ebx, saved_context_ebx
  18. movl %ebp, saved_context_ebp
  19. movl %esi, saved_context_esi
  20. movl %edi, saved_context_edi
  21. pushfl ; popl saved_context_eflags
  22. call swsusp_save
  23. ret
  24. ENTRY(restore_image)
  25. movl resume_pg_dir, %ecx
  26. subl $__PAGE_OFFSET, %ecx
  27. movl %ecx, %cr3
  28. movl restore_pblist, %edx
  29. .p2align 4,,7
  30. copy_loop:
  31. testl %edx, %edx
  32. jz done
  33. movl pbe_address(%edx), %esi
  34. movl pbe_orig_address(%edx), %edi
  35. movl $1024, %ecx
  36. rep
  37. movsl
  38. movl pbe_next(%edx), %edx
  39. jmp copy_loop
  40. .p2align 4,,7
  41. done:
  42. /* go back to the original page tables */
  43. movl $swapper_pg_dir, %ecx
  44. subl $__PAGE_OFFSET, %ecx
  45. movl %ecx, %cr3
  46. /* Flush TLB, including "global" things (vmalloc) */
  47. movl mmu_cr4_features, %eax
  48. movl %eax, %edx
  49. andl $~(1<<7), %edx; # PGE
  50. movl %edx, %cr4; # turn off PGE
  51. movl %cr3, %ecx; # flush TLB
  52. movl %ecx, %cr3
  53. movl %eax, %cr4; # turn PGE back on
  54. movl saved_context_esp, %esp
  55. movl saved_context_ebp, %ebp
  56. movl saved_context_ebx, %ebx
  57. movl saved_context_esi, %esi
  58. movl saved_context_edi, %edi
  59. pushl saved_context_eflags ; popfl
  60. xorl %eax, %eax
  61. ret