relocate_kernel.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * relocate_kernel.S - put the kernel image in place to boot
  3. */
  4. #include <asm/kexec.h>
  5. .globl relocate_new_kernel
  6. relocate_new_kernel:
  7. /* Move boot params back to where the kernel expects them */
  8. ldr r0,kexec_boot_params_address
  9. teq r0,#0
  10. beq 8f
  11. ldr r1,kexec_boot_params_copy
  12. mov r6,#KEXEC_BOOT_PARAMS_SIZE/4
  13. 7:
  14. ldr r5,[r1],#4
  15. str r5,[r0],#4
  16. subs r6,r6,#1
  17. bne 7b
  18. 8:
  19. /* Boot params moved, now go on with the kernel */
  20. ldr r0,kexec_indirection_page
  21. ldr r1,kexec_start_address
  22. 0: /* top, read another word for the indirection page */
  23. ldr r3, [r0],#4
  24. /* Is it a destination page. Put destination address to r4 */
  25. tst r3,#1,0
  26. beq 1f
  27. bic r4,r3,#1
  28. b 0b
  29. 1:
  30. /* Is it an indirection page */
  31. tst r3,#2,0
  32. beq 1f
  33. bic r0,r3,#2
  34. b 0b
  35. 1:
  36. /* are we done ? */
  37. tst r3,#4,0
  38. beq 1f
  39. b 2f
  40. 1:
  41. /* is it source ? */
  42. tst r3,#8,0
  43. beq 0b
  44. bic r3,r3,#8
  45. mov r6,#1024
  46. 9:
  47. ldr r5,[r3],#4
  48. str r5,[r4],#4
  49. subs r6,r6,#1
  50. bne 9b
  51. b 0b
  52. 2:
  53. /* Jump to relocated kernel */
  54. mov lr,r1
  55. mov r0,#0
  56. ldr r1,kexec_mach_type
  57. ldr r2,kexec_boot_params_address
  58. mov pc,lr
  59. .globl kexec_start_address
  60. kexec_start_address:
  61. .long 0x0
  62. .globl kexec_indirection_page
  63. kexec_indirection_page:
  64. .long 0x0
  65. .globl kexec_mach_type
  66. kexec_mach_type:
  67. .long 0x0
  68. /* phy addr where new kernel will expect to find boot params */
  69. .globl kexec_boot_params_address
  70. kexec_boot_params_address:
  71. .long 0x0
  72. /* phy addr where old kernel put a copy of orig boot params */
  73. .globl kexec_boot_params_copy
  74. kexec_boot_params_copy:
  75. .long 0x0
  76. relocate_new_kernel_end:
  77. .globl relocate_new_kernel_size
  78. relocate_new_kernel_size:
  79. .long relocate_new_kernel_end - relocate_new_kernel