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 mmu_cr4_features, %ecx
  26. movl resume_pg_dir, %eax
  27. subl $__PAGE_OFFSET, %eax
  28. movl %eax, %cr3
  29. jecxz 1f # cr4 Pentium and higher, skip if zero
  30. andl $~(X86_CR4_PGE), %ecx
  31. movl %ecx, %cr4; # turn off PGE
  32. movl %cr3, %eax; # flush TLB
  33. movl %eax, %cr3
  34. 1:
  35. movl restore_pblist, %edx
  36. .p2align 4,,7
  37. copy_loop:
  38. testl %edx, %edx
  39. jz done
  40. movl pbe_address(%edx), %esi
  41. movl pbe_orig_address(%edx), %edi
  42. movl $1024, %ecx
  43. rep
  44. movsl
  45. movl pbe_next(%edx), %edx
  46. jmp copy_loop
  47. .p2align 4,,7
  48. done:
  49. /* go back to the original page tables */
  50. movl $swapper_pg_dir, %eax
  51. subl $__PAGE_OFFSET, %eax
  52. movl %eax, %cr3
  53. movl mmu_cr4_features, %ecx
  54. jecxz 1f # cr4 Pentium and higher, skip if zero
  55. movl %ecx, %cr4; # turn PGE back on
  56. 1:
  57. movl saved_context_esp, %esp
  58. movl saved_context_ebp, %ebp
  59. movl saved_context_ebx, %ebx
  60. movl saved_context_esi, %esi
  61. movl saved_context_edi, %edi
  62. pushl saved_context_eflags
  63. popfl
  64. xorl %eax, %eax
  65. ret