swsusp.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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(swsusp_arch_resume)
  25. movl $swsusp_pg_dir-__PAGE_OFFSET, %ecx
  26. movl %ecx, %cr3
  27. movl pagedir_nosave, %edx
  28. .p2align 4,,7
  29. copy_loop:
  30. testl %edx, %edx
  31. jz done
  32. movl pbe_address(%edx), %esi
  33. movl pbe_orig_address(%edx), %edi
  34. movl $1024, %ecx
  35. rep
  36. movsl
  37. movl pbe_next(%edx), %edx
  38. jmp copy_loop
  39. .p2align 4,,7
  40. done:
  41. /* Flush TLB, including "global" things (vmalloc) */
  42. movl mmu_cr4_features, %eax
  43. movl %eax, %edx
  44. andl $~(1<<7), %edx; # PGE
  45. movl %edx, %cr4; # turn off PGE
  46. movl %cr3, %ecx; # flush TLB
  47. movl %ecx, %cr3
  48. movl %eax, %cr4; # turn PGE back on
  49. movl saved_context_esp, %esp
  50. movl saved_context_ebp, %ebp
  51. movl saved_context_ebx, %ebx
  52. movl saved_context_esi, %esi
  53. movl saved_context_edi, %edi
  54. pushl saved_context_eflags ; popfl
  55. xorl %eax, %eax
  56. ret