hibernate_asm_32.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This may not use any stack, nor any variable that is not "NoSave":
  3. *
  4. * Its rewriting one kernel image with another. What is stack in "old"
  5. * image could very well be data page in "new" image, and overwriting
  6. * your own stack under you is bad idea.
  7. */
  8. #include <linux/linkage.h>
  9. #include <asm/segment.h>
  10. #include <asm/page_types.h>
  11. #include <asm/asm-offsets.h>
  12. #include <asm/processor-flags.h>
  13. .text
  14. ENTRY(swsusp_arch_suspend)
  15. movl %esp, saved_context_esp
  16. movl %ebx, saved_context_ebx
  17. movl %ebp, saved_context_ebp
  18. movl %esi, saved_context_esi
  19. movl %edi, saved_context_edi
  20. pushfl
  21. popl saved_context_eflags
  22. call swsusp_save
  23. ret
  24. ENTRY(restore_image)
  25. movl resume_pg_dir, %eax
  26. subl $__PAGE_OFFSET, %eax
  27. movl %eax, %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, %eax
  44. subl $__PAGE_OFFSET, %eax
  45. movl %eax, %cr3
  46. /* Flush TLB, including "global" things (vmalloc) */
  47. movl mmu_cr4_features, %ecx
  48. jecxz 1f # cr4 Pentium and higher, skip if zero
  49. movl %ecx, %edx
  50. andl $~(X86_CR4_PGE), %edx
  51. movl %edx, %cr4; # turn off PGE
  52. 1:
  53. movl %cr3, %eax; # flush TLB
  54. movl %eax, %cr3
  55. jecxz 1f # cr4 Pentium and higher, skip if zero
  56. movl %ecx, %cr4; # turn PGE back on
  57. 1:
  58. movl saved_context_esp, %esp
  59. movl saved_context_ebp, %ebp
  60. movl saved_context_ebx, %ebx
  61. movl saved_context_esi, %esi
  62. movl saved_context_edi, %edi
  63. pushl saved_context_eflags
  64. popfl
  65. xorl %eax, %eax
  66. ret