~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to arch/powerpc/boot/crt0.S

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * as published by the Free Software Foundation; either version
7
7
 * 2 of the License, or (at your option) any later version.
8
8
 *
9
 
 * NOTE: this code runs in 32 bit mode and is packaged as ELF32.
 
9
 * NOTE: this code runs in 32 bit mode, is position-independent,
 
10
 * and is packaged as ELF32.
10
11
 */
11
12
 
12
13
#include "ppc_asm.h"
13
14
 
14
15
        .text
15
 
        /* a procedure descriptor used when booting this as a COFF file */
 
16
        /* A procedure descriptor used when booting this as a COFF file.
 
17
         * When making COFF, this comes first in the link and we're
 
18
         * linked at 0x500000.
 
19
         */
16
20
        .globl  _zimage_start_opd
17
21
_zimage_start_opd:
18
 
        .long   _zimage_start, 0, 0, 0
 
22
        .long   0x500000, 0, 0, 0
 
23
 
 
24
p_start:        .long   _start
 
25
p_etext:        .long   _etext
 
26
p_bss_start:    .long   __bss_start
 
27
p_end:          .long   _end
 
28
 
 
29
        .weak   _platform_stack_top
 
30
p_pstack:       .long   _platform_stack_top
19
31
 
20
32
        .weak   _zimage_start
21
33
        .globl  _zimage_start
24
36
_zimage_start_lib:
25
37
        /* Work out the offset between the address we were linked at
26
38
           and the address where we're running. */
27
 
        bl      1f
28
 
1:      mflr    r0
29
 
        lis     r9,1b@ha
30
 
        addi    r9,r9,1b@l
31
 
        subf.   r0,r9,r0
32
 
        beq     3f              /* if running at same address as linked */
33
 
 
34
 
        /* The .got2 section contains a list of addresses, so add
35
 
           the address offset onto each entry. */
36
 
        lis     r9,__got2_start@ha
37
 
        addi    r9,r9,__got2_start@l
38
 
        lis     r8,__got2_end@ha
39
 
        addi    r8,r8,__got2_end@l
40
 
        subf.   r8,r9,r8
41
 
        beq     3f
42
 
        srwi.   r8,r8,2
43
 
        mtctr   r8
44
 
        add     r9,r0,r9
45
 
2:      lwz     r8,0(r9)
46
 
        add     r8,r8,r0
47
 
        stw     r8,0(r9)
48
 
        addi    r9,r9,4
 
39
        bl      .+4
 
40
p_base: mflr    r10             /* r10 now points to runtime addr of p_base */
 
41
        /* grab the link address of the dynamic section in r11 */
 
42
        addis   r11,r10,(_GLOBAL_OFFSET_TABLE_-p_base)@ha
 
43
        lwz     r11,(_GLOBAL_OFFSET_TABLE_-p_base)@l(r11)
 
44
        cmpwi   r11,0
 
45
        beq     3f              /* if not linked -pie */
 
46
        /* get the runtime address of the dynamic section in r12 */
 
47
        .weak   __dynamic_start
 
48
        addis   r12,r10,(__dynamic_start-p_base)@ha
 
49
        addi    r12,r12,(__dynamic_start-p_base)@l
 
50
        subf    r11,r11,r12     /* runtime - linktime offset */
 
51
 
 
52
        /* The dynamic section contains a series of tagged entries.
 
53
         * We need the RELA and RELACOUNT entries. */
 
54
RELA = 7
 
55
RELACOUNT = 0x6ffffff9
 
56
        li      r9,0
 
57
        li      r0,0
 
58
9:      lwz     r8,0(r12)       /* get tag */
 
59
        cmpwi   r8,0
 
60
        beq     10f             /* end of list */
 
61
        cmpwi   r8,RELA
 
62
        bne     11f
 
63
        lwz     r9,4(r12)       /* get RELA pointer in r9 */
 
64
        b       12f
 
65
11:     addis   r8,r8,(-RELACOUNT)@ha
 
66
        cmpwi   r8,RELACOUNT@l
 
67
        bne     12f
 
68
        lwz     r0,4(r12)       /* get RELACOUNT value in r0 */
 
69
12:     addi    r12,r12,8
 
70
        b       9b
 
71
 
 
72
        /* The relocation section contains a list of relocations.
 
73
         * We now do the R_PPC_RELATIVE ones, which point to words
 
74
         * which need to be initialized with addend + offset.
 
75
         * The R_PPC_RELATIVE ones come first and there are RELACOUNT
 
76
         * of them. */
 
77
10:     /* skip relocation if we don't have both */
 
78
        cmpwi   r0,0
 
79
        beq     3f
 
80
        cmpwi   r9,0
 
81
        beq     3f
 
82
 
 
83
        add     r9,r9,r11       /* Relocate RELA pointer */
 
84
        mtctr   r0
 
85
2:      lbz     r0,4+3(r9)      /* ELF32_R_INFO(reloc->r_info) */
 
86
        cmpwi   r0,22           /* R_PPC_RELATIVE */
 
87
        bne     3f
 
88
        lwz     r12,0(r9)       /* reloc->r_offset */
 
89
        lwz     r0,8(r9)        /* reloc->r_addend */
 
90
        add     r0,r0,r11
 
91
        stwx    r0,r11,r12
 
92
        addi    r9,r9,12
49
93
        bdnz    2b
50
94
 
51
95
        /* Do a cache flush for our text, in case the loader didn't */
52
 
3:      lis     r9,_start@ha
53
 
        addi    r9,r9,_start@l
54
 
        add     r9,r0,r9
55
 
        lis     r8,_etext@ha
56
 
        addi    r8,r8,_etext@l
57
 
        add     r8,r0,r8
 
96
3:      lwz     r9,p_start-p_base(r10)  /* note: these are relocated now */
 
97
        lwz     r8,p_etext-p_base(r10)
58
98
4:      dcbf    r0,r9
59
99
        icbi    r0,r9
60
100
        addi    r9,r9,0x20
64
104
        isync
65
105
 
66
106
        /* Clear the BSS */
67
 
        lis     r9,__bss_start@ha
68
 
        addi    r9,r9,__bss_start@l
69
 
        add     r9,r0,r9
70
 
        lis     r8,_end@ha
71
 
        addi    r8,r8,_end@l
72
 
        add     r8,r0,r8
73
 
        li      r10,0
74
 
5:      stw     r10,0(r9)
 
107
        lwz     r9,p_bss_start-p_base(r10)
 
108
        lwz     r8,p_end-p_base(r10)
 
109
        li      r0,0
 
110
5:      stw     r0,0(r9)
75
111
        addi    r9,r9,4
76
112
        cmplw   cr0,r9,r8
77
113
        blt     5b
78
114
 
79
115
        /* Possibly set up a custom stack */
80
 
.weak   _platform_stack_top
81
 
        lis     r8,_platform_stack_top@ha
82
 
        addi    r8,r8,_platform_stack_top@l
 
116
        lwz     r8,p_pstack-p_base(r10)
83
117
        cmpwi   r8,0
84
118
        beq     6f
85
 
        add     r8,r0,r8
86
119
        lwz     r1,0(r8)
87
 
        add     r1,r0,r1
88
120
        li      r0,0
89
121
        stwu    r0,-16(r1)      /* establish a stack frame */
90
122
6: