wakeup_32.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. .text
  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. lidt saved_idt
  18. lldt saved_ldt
  19. ljmp $(__KERNEL_CS), $1f
  20. 1:
  21. movl %cr3, %eax
  22. movl %eax, %cr3
  23. wbinvd
  24. # and restore the stack ... but you need gdt for this to work
  25. movl saved_context_esp, %esp
  26. movl %cs:saved_magic, %eax
  27. cmpl $0x12345678, %eax
  28. jne bogus_magic
  29. # jump to place where we left off
  30. movl saved_eip, %eax
  31. jmp *%eax
  32. bogus_magic:
  33. jmp bogus_magic
  34. save_registers:
  35. sidt saved_idt
  36. sldt saved_ldt
  37. str saved_tss
  38. leal 4(%esp), %eax
  39. movl %eax, saved_context_esp
  40. movl %ebx, saved_context_ebx
  41. movl %ebp, saved_context_ebp
  42. movl %esi, saved_context_esi
  43. movl %edi, saved_context_edi
  44. pushfl
  45. popl saved_context_eflags
  46. movl $ret_point, saved_eip
  47. ret
  48. restore_registers:
  49. movl saved_context_ebp, %ebp
  50. movl saved_context_ebx, %ebx
  51. movl saved_context_esi, %esi
  52. movl saved_context_edi, %edi
  53. pushl saved_context_eflags
  54. popfl
  55. ret
  56. ENTRY(do_suspend_lowlevel)
  57. call save_processor_state
  58. call save_registers
  59. pushl $3
  60. call acpi_enter_sleep_state
  61. addl $4, %esp
  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_idt: .long 0,0
  76. saved_ldt: .long 0
  77. saved_tss: .long 0