1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/boot/bootp/init.S
5 * Copyright (C) 2000-2003 Russell King.
7 * "Header" file for splitting kernel + initrd. Note that we pass
8 * r0 through to r3 straight through.
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.
17 .type _start, #function
20 _start: add lr, pc, #-0x8 @ lr = current load addr
22 ldmia r13!, {r4-r6} @ r5 = dest, r6 = length
23 add r4, r4, lr @ r4 = initrd_start + load addr
24 bl move @ move the initrd
27 * Setup the initrd parameters to pass to the kernel. This can only be
28 * passed in via the tagged list.
30 ldmia r13, {r5-r9} @ get size and addr of initrd
35 @ r9 = param_struct address
37 ldr r10, [r9, #4] @ get first tag
38 teq r10, r5 @ is it ATAG_CORE?
40 * If we didn't find a valid tag list, create a dummy ATAG_CORE entry.
42 movne r10, #0 @ terminator
43 movne r4, #2 @ Size of this entry (2 words)
44 stmiane r9, {r4, r5, r10} @ Size, ATAG_CORE, terminator
47 * find the end of the tag list, and then add an INITRD tag on the end.
48 * If there is already an INITRD tag, then we ignore it; the last INITRD
49 * tag takes precedence.
51 taglist: ldr r10, [r9, #0] @ tag length
52 teq r10, #0 @ last tag (zero length)?
53 addne r9, r9, r10, lsl #2
56 mov r5, #4 @ Size of initrd tag (4 words)
57 stmia r9, {r5, r6, r7, r8, r10}
58 b kernel_start @ call kernel
61 * Move the block of memory length r6 from address r4 to address r5
63 move: ldmia r4!, {r7 - r10} @ move 32-bytes at a time
71 .size _start, . - _start
76 data: .word initrd_start @ source initrd address
77 .word initrd_phys @ destination initrd address
78 .word initrd_size @ initrd size
80 .word 0x54410001 @ r5 = ATAG_CORE
81 .word 0x54420005 @ r6 = ATAG_INITRD2
82 .word initrd_phys @ r7
83 .word initrd_size @ r8
84 .word params_phys @ r9