hibernate_asm.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * hibernate_asm.S: Hibernaton support specific for sparc64.
  4. *
  5. * Copyright (C) 2013 Kirill V Tkhai ([email protected])
  6. */
  7. #include <linux/linkage.h>
  8. #include <asm/asm-offsets.h>
  9. #include <asm/cpudata.h>
  10. #include <asm/page.h>
  11. ENTRY(swsusp_arch_suspend)
  12. save %sp, -128, %sp
  13. save %sp, -128, %sp
  14. flushw
  15. setuw saved_context, %g3
  16. /* Save window regs */
  17. rdpr %cwp, %g2
  18. stx %g2, [%g3 + SC_REG_CWP]
  19. rdpr %wstate, %g2
  20. stx %g2, [%g3 + SC_REG_WSTATE]
  21. stx %fp, [%g3 + SC_REG_FP]
  22. /* Save state regs */
  23. rdpr %tick, %g2
  24. stx %g2, [%g3 + SC_REG_TICK]
  25. rdpr %pstate, %g2
  26. stx %g2, [%g3 + SC_REG_PSTATE]
  27. /* Save global regs */
  28. stx %g4, [%g3 + SC_REG_G4]
  29. stx %g5, [%g3 + SC_REG_G5]
  30. stx %g6, [%g3 + SC_REG_G6]
  31. call swsusp_save
  32. nop
  33. mov %o0, %i0
  34. restore
  35. mov %o0, %i0
  36. ret
  37. restore
  38. ENTRY(swsusp_arch_resume)
  39. /* Write restore_pblist to %l0 */
  40. sethi %hi(restore_pblist), %l0
  41. ldx [%l0 + %lo(restore_pblist)], %l0
  42. call __flush_tlb_all
  43. nop
  44. /* Write PAGE_OFFSET to %g7 */
  45. sethi %hi(PAGE_OFFSET), %g7
  46. ldx [%g7 + %lo(PAGE_OFFSET)], %g7
  47. setuw (PAGE_SIZE-8), %g3
  48. /* Use MMU Bypass */
  49. rd %asi, %g1
  50. wr %g0, ASI_PHYS_USE_EC, %asi
  51. ba fill_itlb
  52. nop
  53. pbe_loop:
  54. cmp %l0, %g0
  55. be restore_ctx
  56. sub %l0, %g7, %l0
  57. ldxa [%l0 ] %asi, %l1 /* address */
  58. ldxa [%l0 + 8] %asi, %l2 /* orig_address */
  59. /* phys addr */
  60. sub %l1, %g7, %l1
  61. sub %l2, %g7, %l2
  62. mov %g3, %l3 /* PAGE_SIZE-8 */
  63. copy_loop:
  64. ldxa [%l1 + %l3] ASI_PHYS_USE_EC, %g2
  65. stxa %g2, [%l2 + %l3] ASI_PHYS_USE_EC
  66. cmp %l3, %g0
  67. bne copy_loop
  68. sub %l3, 8, %l3
  69. /* next pbe */
  70. ba pbe_loop
  71. ldxa [%l0 + 16] %asi, %l0
  72. restore_ctx:
  73. setuw saved_context, %g3
  74. /* Restore window regs */
  75. wrpr %g0, 0, %canrestore
  76. wrpr %g0, 0, %otherwin
  77. wrpr %g0, 6, %cansave
  78. wrpr %g0, 0, %cleanwin
  79. ldxa [%g3 + SC_REG_CWP] %asi, %g2
  80. wrpr %g2, %cwp
  81. ldxa [%g3 + SC_REG_WSTATE] %asi, %g2
  82. wrpr %g2, %wstate
  83. ldxa [%g3 + SC_REG_FP] %asi, %fp
  84. /* Restore state regs */
  85. ldxa [%g3 + SC_REG_PSTATE] %asi, %g2
  86. wrpr %g2, %pstate
  87. ldxa [%g3 + SC_REG_TICK] %asi, %g2
  88. wrpr %g2, %tick
  89. /* Restore global regs */
  90. ldxa [%g3 + SC_REG_G4] %asi, %g4
  91. ldxa [%g3 + SC_REG_G5] %asi, %g5
  92. ldxa [%g3 + SC_REG_G6] %asi, %g6
  93. wr %g1, %g0, %asi
  94. restore
  95. restore
  96. wrpr %g0, 14, %pil
  97. retl
  98. mov %g0, %o0
  99. fill_itlb:
  100. ba pbe_loop
  101. wrpr %g0, 15, %pil