1
2
3
4
5
6
7
8
9
10
11
12
13#include "ppc_asm.h"
14
15 .text
16
17
18
19
20 .globl _zimage_start_opd
21_zimage_start_opd:
22 .long 0x500000, 0, 0, 0
23
24p_start: .long _start
25p_etext: .long _etext
26p_bss_start: .long __bss_start
27p_end: .long _end
28
29 .weak _platform_stack_top
30p_pstack: .long _platform_stack_top
31
32 .weak _zimage_start
33 .globl _zimage_start
34_zimage_start:
35 .globl _zimage_start_lib
36_zimage_start_lib:
37
38
39 bl .+4
40p_base: mflr r10
41
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
46
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
51
52
53
54RELA = 7
55RELACOUNT = 0x6ffffff9
56 li r9,0
57 li r0,0
589: lwz r8,0(r12)
59 cmpwi r8,0
60 beq 10f
61 cmpwi r8,RELA
62 bne 11f
63 lwz r9,4(r12)
64 b 12f
6511: addis r8,r8,(-RELACOUNT)@ha
66 cmpwi r8,RELACOUNT@l
67 bne 12f
68 lwz r0,4(r12)
6912: addi r12,r12,8
70 b 9b
71
72
73
74
75
76
7710:
78 cmpwi r0,0
79 beq 3f
80 cmpwi r9,0
81 beq 3f
82
83 add r9,r9,r11
84 mtctr r0
852: lbz r0,4+3(r9)
86 cmpwi r0,22
87 bne 3f
88 lwz r12,0(r9)
89 lwz r0,8(r9)
90 add r0,r0,r11
91 stwx r0,r11,r12
92 addi r9,r9,12
93 bdnz 2b
94
95
963: lwz r9,p_start-p_base(r10)
97 lwz r8,p_etext-p_base(r10)
984: dcbf r0,r9
99 icbi r0,r9
100 addi r9,r9,0x20
101 cmplw cr0,r9,r8
102 blt 4b
103 sync
104 isync
105
106
107 lwz r9,p_bss_start-p_base(r10)
108 lwz r8,p_end-p_base(r10)
109 li r0,0
1105: stw r0,0(r9)
111 addi r9,r9,4
112 cmplw cr0,r9,r8
113 blt 5b
114
115
116 lwz r8,p_pstack-p_base(r10)
117 cmpwi r8,0
118 beq 6f
119 lwz r1,0(r8)
120 li r0,0
121 stwu r0,-16(r1)
1226:
123
124
125 bl platform_init
126
127
128 b start
129