hibernate_asm.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * linux/arch/unicore32/kernel/hibernate_asm.S
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn>
  7. * Copyright (C) 2001-2010 Guan Xuetao
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/sys.h>
  14. #include <linux/errno.h>
  15. #include <linux/linkage.h>
  16. #include <generated/asm-offsets.h>
  17. #include <asm/page.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/assembler.h>
  20. @ restore_image(pgd_t *resume_pg_dir, struct pbe *restore_pblist)
  21. @ r0: resume_pg_dir
  22. @ r1: restore_pblist
  23. @ copy restore_pblist pages
  24. @ restore registers from swsusp_arch_regs_cpu0
  25. @
  26. ENTRY(restore_image)
  27. sub r0, r0, #PAGE_OFFSET
  28. mov r5, #0
  29. movc p0.c6, r5, #6 @invalidate ITLB & DTLB
  30. movc p0.c2, r0, #0
  31. nop
  32. nop
  33. nop
  34. nop
  35. nop
  36. nop
  37. nop
  38. .p2align 4,,7
  39. 101:
  40. csub.a r1, #0
  41. beq 109f
  42. ldw r6, [r1+], #PBE_ADDRESS
  43. ldw r7, [r1+], #PBE_ORIN_ADDRESS
  44. movl ip, #128
  45. 102: ldm.w (r8 - r15), [r6]+
  46. stm.w (r8 - r15), [r7]+
  47. sub.a ip, ip, #1
  48. bne 102b
  49. ldw r1, [r1+], #PBE_NEXT
  50. b 101b
  51. .p2align 4,,7
  52. 109:
  53. /* go back to the original page tables */
  54. ldw r0, =swapper_pg_dir
  55. sub r0, r0, #PAGE_OFFSET
  56. mov r5, #0
  57. movc p0.c6, r5, #6
  58. movc p0.c2, r0, #0
  59. nop
  60. nop
  61. nop
  62. nop
  63. nop
  64. nop
  65. nop
  66. #ifdef CONFIG_UNICORE_FPU_F64
  67. ldw ip, 1f
  68. add ip, ip, #SWSUSP_FPSTATE
  69. lfm.w (f0 - f7 ), [ip]+
  70. lfm.w (f8 - f15), [ip]+
  71. lfm.w (f16 - f23), [ip]+
  72. lfm.w (f24 - f31), [ip]+
  73. ldw r4, [ip]
  74. ctf r4, s31
  75. #endif
  76. mov r0, #0x0
  77. ldw ip, 1f
  78. add ip, ip, #SWSUSP_CPU
  79. ldm.w (r4 - r15), [ip]+
  80. ldm (r16 - r27, sp, pc), [ip]+ @ Load all regs saved previously
  81. .align 2
  82. 1: .long swsusp_arch_regs_cpu0
  83. @ swsusp_arch_suspend()
  84. @ - prepare pc for resume, return from function without swsusp_save on resume
  85. @ - save registers in swsusp_arch_regs_cpu0
  86. @ - call swsusp_save write suspend image
  87. ENTRY(swsusp_arch_suspend)
  88. ldw ip, 1f
  89. add ip, ip, #SWSUSP_CPU
  90. stm.w (r4 - r15), [ip]+
  91. stm.w (r16 - r27, sp, lr), [ip]+
  92. #ifdef CONFIG_UNICORE_FPU_F64
  93. ldw ip, 1f
  94. add ip, ip, #SWSUSP_FPSTATE
  95. sfm.w (f0 - f7 ), [ip]+
  96. sfm.w (f8 - f15), [ip]+
  97. sfm.w (f16 - f23), [ip]+
  98. sfm.w (f24 - f31), [ip]+
  99. cff r4, s31
  100. stw r4, [ip]
  101. #endif
  102. b swsusp_save @ no return
  103. 1: .long swsusp_arch_regs_cpu0