init.S 2.6 KB

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