hibernate_asm.S 2.3 KB

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