ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / arm / boot / bootp / init.S
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
23 _start:         adr     r12, kernel_start       @ offset of kernel zImage
24                 ldr     r4, [r12, #0x2c]        @ length of zImage
25                 adr     r13, data
26                 add     r4, r4, r12             @ end of zImage, start of initrd
27                 ldmia   r13!, {r5-r6}           @ r5 = dest, r6 = length
28                 bl      move                    @ move the initrd
29
30 /*
31  * Setup the initrd parameters to pass to the kernel.  This can only be
32  * passed in via the tagged list.
33  */
34                 ldmia   r13, {r5-r9}            @ get size and addr of initrd
35                                                 @ r5 = ATAG_CORE
36                                                 @ r6 = ATAG_INITRD2
37                                                 @ r7 = initrd start
38                                                 @ r8 = initrd end
39                                                 @ r9 = param_struct address
40
41                 ldr     r10, [r9, #4]           @ get first tag
42                 teq     r10, r5                 @ is it ATAG_CORE?
43 /*
44  * If we didn't find a valid tag list, create a dummy ATAG_CORE entry.
45  */
46                 movne   r10, #0                 @ terminator
47                 movne   r4, #2                  @ Size of this entry (2 words)
48                 stmneia r8, {r4, r5, r10}       @ Size, ATAG_CORE, terminator
49
50 /*
51  * find the end of the tag list, and then add an INITRD tag on the end.
52  * If there is already an INITRD tag, then we ignore it; the last INITRD
53  * tag takes precidence.
54  */
55 taglist:        ldr     r10, [r9, #0]           @ tag length
56                 teq     r10, #0                 @ last tag (zero length)?
57                 addne   r9, r9, r10, lsl #2
58                 bne     taglist
59
60                 mov     r5, #4                  @ Size of initrd tag (4 words)
61                 stmia   r9, {r5, r6, r7, r8, r10}
62                 mov     pc, r12                 @ call kernel
63
64 /*
65  * Move the block of memory length r6 from address r4 to address r5
66  */
67 move:           ldmia   r4!, {r7 - r10}         @ move 32-bytes at a time
68                 stmia   r5!, {r7 - r10}
69                 ldmia   r4!, {r7 - r10}
70                 stmia   r5!, {r7 - r10}
71                 subs    r6, r6, #8 * 4
72                 bcs     move
73                 mov     pc, lr
74
75                 .size   _start, . - _start
76
77                 .type   data,#object
78 data:           .word   initrd_addr             @ destination initrd address
79                 .word   initrd_len              @ initrd size
80
81                 .word   0x54410001              @ r4 = ATAG_CORE
82                 .word   0x54420005              @ r5 = ATAG_INITRD2
83                 .word   initrd_addr             @ r6
84                 .word   initrd_len              @ r7
85                 .word   params                  @ r8
86                 .size   data, . - _data
87
88                 .type   initrd_start,#object
89
90 kernel_start: