init.S 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/boot/bootp/init.S
  4. *
  5. * Copyright (C) 2000-2003 Russell King.
  6. *
  7. * "Header" file for splitting kernel + initrd. Note that we pass
  8. * r0 through to r3 straight through.
  9. *
  10. * This demonstrates how to append code to the start of the kernel
  11. * zImage, and boot the kernel without copying it around. This
  12. * example would be simpler; if we didn't have an object of unknown
  13. * size immediately following the kernel, we could build this into
  14. * a binary blob, and concatenate the zImage using the cat command.
  15. */
  16. .section .start, "ax"
  17. .type _start, #function
  18. .globl _start
  19. _start: add lr, pc, #-0x8 @ lr = current load addr
  20. adr r13, data
  21. ldmia r13!, {r4-r6} @ r5 = dest, r6 = length
  22. add r4, r4, lr @ r4 = initrd_start + load addr
  23. bl move @ move the initrd
  24. /*
  25. * Setup the initrd parameters to pass to the kernel. This can only be
  26. * passed in via the tagged list.
  27. */
  28. ldmia r13, {r5-r9} @ get size and addr of initrd
  29. @ r5 = ATAG_CORE
  30. @ r6 = ATAG_INITRD2
  31. @ r7 = initrd start
  32. @ r8 = initrd end
  33. @ r9 = param_struct address
  34. ldr r10, [r9, #4] @ get first tag
  35. teq r10, r5 @ is it ATAG_CORE?
  36. /*
  37. * If we didn't find a valid tag list, create a dummy ATAG_CORE entry.
  38. */
  39. movne r10, #0 @ terminator
  40. movne r4, #2 @ Size of this entry (2 words)
  41. stmiane r9, {r4, r5, r10} @ Size, ATAG_CORE, terminator
  42. /*
  43. * find the end of the tag list, and then add an INITRD tag on the end.
  44. * If there is already an INITRD tag, then we ignore it; the last INITRD
  45. * tag takes precedence.
  46. */
  47. taglist: ldr r10, [r9, #0] @ tag length
  48. teq r10, #0 @ last tag (zero length)?
  49. addne r9, r9, r10, lsl #2
  50. bne taglist
  51. mov r5, #4 @ Size of initrd tag (4 words)
  52. stmia r9, {r5, r6, r7, r8, r10}
  53. b kernel_start @ call kernel
  54. /*
  55. * Move the block of memory length r6 from address r4 to address r5
  56. */
  57. move: ldmia r4!, {r7 - r10} @ move 32-bytes at a time
  58. stmia r5!, {r7 - r10}
  59. ldmia r4!, {r7 - r10}
  60. stmia r5!, {r7 - r10}
  61. subs r6, r6, #8 * 4
  62. bcs move
  63. mov pc, lr
  64. .size _start, . - _start
  65. .align
  66. .type data,#object
  67. data: .word initrd_start @ source initrd address
  68. .word initrd_phys @ destination initrd address
  69. .word initrd_size @ initrd size
  70. .word 0x54410001 @ r5 = ATAG_CORE
  71. .word 0x54420005 @ r6 = ATAG_INITRD2
  72. .word initrd_phys @ r7
  73. .word initrd_size @ r8
  74. .word params_phys @ r9
  75. .size data, . - data