wakeup_32.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. .section .text..page_aligned
  2. #include <linux/linkage.h>
  3. #include <asm/segment.h>
  4. #include <asm/page_types.h>
  5. # Copyright 2003, 2008 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
  6. .code32
  7. ALIGN
  8. ENTRY(wakeup_pmode_return)
  9. wakeup_pmode_return:
  10. movw $__KERNEL_DS, %ax
  11. movw %ax, %ss
  12. movw %ax, %ds
  13. movw %ax, %es
  14. movw %ax, %fs
  15. movw %ax, %gs
  16. # reload the gdt, as we need the full 32 bit address
  17. lgdt saved_gdt
  18. lidt saved_idt
  19. lldt saved_ldt
  20. ljmp $(__KERNEL_CS), $1f
  21. 1:
  22. movl %cr3, %eax
  23. movl %eax, %cr3
  24. wbinvd
  25. # and restore the stack ... but you need gdt for this to work
  26. movl saved_context_esp, %esp
  27. movl %cs:saved_magic, %eax
  28. cmpl $0x12345678, %eax
  29. jne bogus_magic
  30. # jump to place where we left off
  31. movl saved_eip, %eax
  32. jmp *%eax
  33. bogus_magic:
  34. jmp bogus_magic
  35. save_registers:
  36. sgdt saved_gdt
  37. sidt saved_idt
  38. sldt saved_ldt
  39. str saved_tss
  40. leal 4(%esp), %eax
  41. movl %eax, saved_context_esp
  42. movl %ebx, saved_context_ebx
  43. movl %ebp, saved_context_ebp
  44. movl %esi, saved_context_esi
  45. movl %edi, saved_context_edi
  46. pushfl
  47. popl saved_context_eflags
  48. movl $ret_point, saved_eip
  49. ret
  50. restore_registers:
  51. movl saved_context_ebp, %ebp
  52. movl saved_context_ebx, %ebx
  53. movl saved_context_esi, %esi
  54. movl saved_context_edi, %edi
  55. pushl saved_context_eflags
  56. popfl
  57. ret
  58. ENTRY(do_suspend_lowlevel)
  59. call save_processor_state
  60. call save_registers
  61. call acpi_enter_s3
  62. # In case of S3 failure, we'll emerge here. Jump
  63. # to ret_point to recover
  64. jmp ret_point
  65. .p2align 4,,7
  66. ret_point:
  67. call restore_registers
  68. call restore_processor_state
  69. ret
  70. .data
  71. ALIGN
  72. ENTRY(saved_magic) .long 0
  73. ENTRY(saved_eip) .long 0
  74. # saved registers
  75. saved_gdt: .long 0,0
  76. saved_idt: .long 0,0
  77. saved_ldt: .long 0
  78. saved_tss: .long 0