wakeup_32.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. .text
  3. #include <linux/linkage.h>
  4. #include <asm/segment.h>
  5. #include <asm/page_types.h>
  6. # Copyright 2003, 2008 Pavel Machek <[email protected]
  7. .code32
  8. ALIGN
  9. SYM_CODE_START(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. SYM_CODE_END(wakeup_pmode_return)
  34. bogus_magic:
  35. jmp bogus_magic
  36. save_registers:
  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. SYM_CODE_START(do_suspend_lowlevel)
  59. call save_processor_state
  60. call save_registers
  61. pushl $3
  62. call x86_acpi_enter_sleep_state
  63. addl $4, %esp
  64. # In case of S3 failure, we'll emerge here. Jump
  65. # to ret_point to recover
  66. jmp ret_point
  67. .p2align 4,,7
  68. ret_point:
  69. call restore_registers
  70. call restore_processor_state
  71. RET
  72. SYM_CODE_END(do_suspend_lowlevel)
  73. .data
  74. ALIGN
  75. SYM_DATA(saved_magic, .long 0)
  76. saved_eip: .long 0
  77. # saved registers
  78. saved_idt: .long 0,0
  79. saved_ldt: .long 0
  80. saved_tss: .long 0