hibernate_asm_32.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. .text
  2. /*
  3. * This may not use any stack, nor any variable that is not "NoSave":
  4. *
  5. * Its rewriting one kernel image with another. What is stack in "old"
  6. * image could very well be data page in "new" image, and overwriting
  7. * your own stack under you is bad idea.
  8. */
  9. #include <linux/linkage.h>
  10. #include <asm/segment.h>
  11. #include <asm/page.h>
  12. #include <asm/asm-offsets.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 ; popl saved_context_eflags
  21. call swsusp_save
  22. ret
  23. ENTRY(restore_image)
  24. movl resume_pg_dir, %ecx
  25. subl $__PAGE_OFFSET, %ecx
  26. movl %ecx, %cr3
  27. movl restore_pblist, %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. /* go back to the original page tables */
  42. movl $swapper_pg_dir, %ecx
  43. subl $__PAGE_OFFSET, %ecx
  44. movl %ecx, %cr3
  45. /* Flush TLB, including "global" things (vmalloc) */
  46. movl mmu_cr4_features, %eax
  47. movl %eax, %edx
  48. andl $~(1<<7), %edx; # PGE
  49. movl %edx, %cr4; # turn off PGE
  50. movl %cr3, %ecx; # flush TLB
  51. movl %ecx, %cr3
  52. movl %eax, %cr4; # turn PGE back on
  53. movl saved_context_esp, %esp
  54. movl saved_context_ebp, %ebp
  55. movl saved_context_ebx, %ebx
  56. movl saved_context_esi, %esi
  57. movl saved_context_edi, %edi
  58. pushl saved_context_eflags ; popfl
  59. xorl %eax, %eax
  60. ret