relocate_kernel.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. .globl relocate_new_kernel
  16. relocate_new_kernel:
  17. PTR_L s0, kexec_indirection_page
  18. PTR_L s1, kexec_start_address
  19. process_entry:
  20. PTR_L s2, (s0)
  21. PTR_ADD s0, s0, SZREG
  22. /* destination page */
  23. and s3, s2, 0x1
  24. beq s3, zero, 1f
  25. and s4, s2, ~0x1 /* store destination addr in s4 */
  26. move a0, s4
  27. b process_entry
  28. 1:
  29. /* indirection page, update s0 */
  30. and s3, s2, 0x2
  31. beq s3, zero, 1f
  32. and s0, s2, ~0x2
  33. b process_entry
  34. 1:
  35. /* done page */
  36. and s3, s2, 0x4
  37. beq s3, zero, 1f
  38. b done
  39. 1:
  40. /* source page */
  41. and s3, s2, 0x8
  42. beq s3, zero, process_entry
  43. and s2, s2, ~0x8
  44. li s6, (1 << PAGE_SHIFT) / SZREG
  45. copy_word:
  46. /* copy page word by word */
  47. REG_L s5, (s2)
  48. REG_S s5, (s4)
  49. INT_ADD s4, s4, SZREG
  50. INT_ADD s2, s2, SZREG
  51. INT_SUB s6, s6, 1
  52. beq s6, zero, process_entry
  53. b copy_word
  54. b process_entry
  55. done:
  56. /* jump to kexec_start_address */
  57. j s1
  58. .globl kexec_start_address
  59. kexec_start_address:
  60. .long 0x0
  61. .globl kexec_indirection_page
  62. kexec_indirection_page:
  63. .long 0x0
  64. relocate_new_kernel_end:
  65. .globl relocate_new_kernel_size
  66. relocate_new_kernel_size:
  67. .long relocate_new_kernel_end - relocate_new_kernel