relocate_kernel.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * relocate_kernel.S for kexec
  3. * Created by <nschichan@corp.free.fr> on Thu Oct 12 17:49:57 2006
  4. *
  5. * This source code is licensed under the GNU General Public License,
  6. * Version 2. See the file COPYING for more details.
  7. */
  8. #include <asm/asm.h>
  9. #include <asm/asmmacro.h>
  10. #include <asm/regdef.h>
  11. #include <asm/page.h>
  12. #include <asm/mipsregs.h>
  13. #include <asm/stackframe.h>
  14. #include <asm/addrspace.h>
  15. LEAF(relocate_new_kernel)
  16. PTR_L s0, kexec_indirection_page
  17. PTR_L s1, kexec_start_address
  18. process_entry:
  19. PTR_L s2, (s0)
  20. PTR_ADD s0, s0, SZREG
  21. /* destination page */
  22. and s3, s2, 0x1
  23. beq s3, zero, 1f
  24. and s4, s2, ~0x1 /* store destination addr in s4 */
  25. move a0, s4
  26. b process_entry
  27. 1:
  28. /* indirection page, update s0 */
  29. and s3, s2, 0x2
  30. beq s3, zero, 1f
  31. and s0, s2, ~0x2
  32. b process_entry
  33. 1:
  34. /* done page */
  35. and s3, s2, 0x4
  36. beq s3, zero, 1f
  37. b done
  38. 1:
  39. /* source page */
  40. and s3, s2, 0x8
  41. beq s3, zero, process_entry
  42. and s2, s2, ~0x8
  43. li s6, (1 << PAGE_SHIFT) / SZREG
  44. copy_word:
  45. /* copy page word by word */
  46. REG_L s5, (s2)
  47. REG_S s5, (s4)
  48. PTR_ADD s4, s4, SZREG
  49. PTR_ADD s2, s2, SZREG
  50. LONG_SUB s6, s6, 1
  51. beq s6, zero, process_entry
  52. b copy_word
  53. b process_entry
  54. done:
  55. /* jump to kexec_start_address */
  56. j s1
  57. END(relocate_new_kernel)
  58. kexec_start_address:
  59. EXPORT(kexec_start_address)
  60. PTR 0x0
  61. .size kexec_start_address, PTRSIZE
  62. kexec_indirection_page:
  63. EXPORT(kexec_indirection_page)
  64. PTR 0
  65. .size kexec_indirection_page, PTRSIZE
  66. relocate_new_kernel_end:
  67. relocate_new_kernel_size:
  68. EXPORT(relocate_new_kernel_size)
  69. PTR relocate_new_kernel_end - relocate_new_kernel
  70. .size relocate_new_kernel_size, PTRSIZE