wakeup_32.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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, %fs
  13. movw %ax, %gs
  14. movw $__USER_DS, %ax
  15. movw %ax, %ds
  16. movw %ax, %es
  17. # reload the gdt, as we need the full 32 bit address
  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. sidt saved_idt
  37. sldt saved_ldt
  38. str saved_tss
  39. leal 4(%esp), %eax
  40. movl %eax, saved_context_esp
  41. movl %ebx, saved_context_ebx
  42. movl %ebp, saved_context_ebp
  43. movl %esi, saved_context_esi
  44. movl %edi, saved_context_edi
  45. pushfl
  46. popl saved_context_eflags
  47. movl $ret_point, saved_eip
  48. ret
  49. restore_registers:
  50. movl saved_context_ebp, %ebp
  51. movl saved_context_ebx, %ebx
  52. movl saved_context_esi, %esi
  53. movl saved_context_edi, %edi
  54. pushl saved_context_eflags
  55. popfl
  56. ret
  57. ENTRY(do_suspend_lowlevel)
  58. call save_processor_state
  59. call save_registers
  60. pushl $3
  61. call x86_acpi_enter_sleep_state
  62. addl $4, %esp
  63. # In case of S3 failure, we'll emerge here. Jump
  64. # to ret_point to recover
  65. jmp ret_point
  66. .p2align 4,,7
  67. ret_point:
  68. call restore_registers
  69. call restore_processor_state
  70. ret
  71. .data
  72. ALIGN
  73. ENTRY(saved_magic) .long 0
  74. ENTRY(saved_eip) .long 0
  75. # saved registers
  76. saved_idt: .long 0,0
  77. saved_ldt: .long 0
  78. saved_tss: .long 0