summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/crt0.S
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/crt0.S')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/crt0.S65
1 files changed, 37 insertions, 28 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S
index e619022fc8..6ac40c2f52 100644
--- a/firmware/target/mips/ingenic_jz47xx/crt0.S
+++ b/firmware/target/mips/ingenic_jz47xx/crt0.S
@@ -43,14 +43,16 @@
43 .set mips32 43 .set mips32
44 44
45 .extern system_main 45 .extern system_main
46 .extern main
47 .global _start
46 48
47 .global _start
48 .section .init.text 49 .section .init.text
49 .set noreorder 50 .set noreorder
50 .set noat 51 .set noat
51 52
52#ifdef BOOTLOADER 53#ifdef BOOTLOADER
53 .word 0 /* Unknown */ 54 /* These will get filled in scramble */
55 .word 0 /* Unknown */
54 .word 0 /* Filesize */ 56 .word 0 /* Filesize */
55 57
56 /* Relocate bootloader */ 58 /* Relocate bootloader */
@@ -64,12 +66,12 @@ _relocate_loop:
64 bne t1, t2, _relocate_loop 66 bne t1, t2, _relocate_loop
65 addiu t0, 4 67 addiu t0, 4
66#endif 68#endif
67 69
68_start: 70_start:
69 la ra, _start 71 la ra, _start
70 /* 72 /*
71 ---------------------------------------------------- 73 ----------------------------------------------------
72 init cp0 registers. 74 Init CP0 registers.
73 ---------------------------------------------------- 75 ----------------------------------------------------
74 */ 76 */
75 mtc0 zero, C0_WATCHLO 77 mtc0 zero, C0_WATCHLO
@@ -90,21 +92,21 @@ _start:
90 92
91 /* 93 /*
92 ---------------------------------------------------- 94 ----------------------------------------------------
93 init caches, assumes a 4way*128set*32byte i/d cache 95 Init caches, assumes a 4way*128set*32byte I/D cache
94 ---------------------------------------------------- 96 ----------------------------------------------------
95 */ 97 */
96 li t0, 3 // enable cache for kseg0 accesses 98 li t0, 3 # enable cache for kseg0 accesses
97 mtc0 t0, C0_CONFIG // CONFIG reg 99 mtc0 t0, C0_CONFIG # CONFIG reg
98 la t0, 0x80000000 // an idx op should use an unmappable address 100 la t0, 0x80000000 # an idx op should use an unmappable address
99 ori t1, t0, 0x4000 // 16kB cache 101 ori t1, t0, 0x4000 # 16kB cache
100 mtc0 zero, C0_TAGLO // TAGLO reg 102 mtc0 zero, C0_TAGLO # TAGLO reg
101 mtc0 zero, C0_TAGHI // TAGHI reg 103 mtc0 zero, C0_TAGHI # TAGHI reg
102 104
103_init_cache_loop: 105_init_cache_loop:
104 cache 0x8, 0(t0) // index store icache tag 106 cache 0x8, 0(t0) # index store icache tag
105 cache 0x9, 0(t0) // index store dcache tag 107 cache 0x9, 0(t0) # index store dcache tag
106 bne t0, t1, _init_cache_loop 108 bne t0, t1, _init_cache_loop
107 addiu t0, t0, 0x20 // 32 bytes per cache line 109 addiu t0, t0, 0x20 # 32 bytes per cache line
108 nop 110 nop
109 111
110 /* 112 /*
@@ -120,7 +122,7 @@ _init_cache_loop:
120 122
121 /* 123 /*
122 ---------------------------------------------------- 124 ----------------------------------------------------
123 clear BSS section 125 Clear BSS section
124 ---------------------------------------------------- 126 ----------------------------------------------------
125 */ 127 */
126 la t0, _edata 128 la t0, _edata
@@ -132,7 +134,7 @@ _init_bss_loop:
132 134
133 /* 135 /*
134 ---------------------------------------------------- 136 ----------------------------------------------------
135 clear IBSS section 137 Clear IBSS section
136 ---------------------------------------------------- 138 ----------------------------------------------------
137 */ 139 */
138 la t0, _iedata 140 la t0, _iedata
@@ -144,7 +146,7 @@ _init_ibss_loop:
144 146
145 /* 147 /*
146 ---------------------------------------------------- 148 ----------------------------------------------------
147 copy IRAM section 149 Copy IRAM section
148 ---------------------------------------------------- 150 ----------------------------------------------------
149 */ 151 */
150 la t0, _iramcopy 152 la t0, _iramcopy
@@ -159,7 +161,7 @@ _init_iram_loop:
159 161
160 /* 162 /*
161 ---------------------------------------------------- 163 ----------------------------------------------------
162 setup stack, jump to C code 164 Setup stack
163 ---------------------------------------------------- 165 ----------------------------------------------------
164 */ 166 */
165 la sp, stackend 167 la sp, stackend
@@ -171,7 +173,15 @@ _init_stack_loop:
171 bne t0, sp, _init_stack_loop 173 bne t0, sp, _init_stack_loop
172 addiu t0, t0, 4 174 addiu t0, t0, 4
173 175
174 la t0, system_main 176 /*
177 ----------------------------------------------------
178 Jump to C code
179 ----------------------------------------------------
180 */
181 la t0, system_main /* Init clocks etc first */
182 jalr t0
183 nop
184 la t0, main
175 jr t0 185 jr t0
176 nop 186 nop
177 187
@@ -182,11 +192,10 @@ _init_stack_loop:
182 * 0x180 - Exception/Interrupt handler 192 * 0x180 - Exception/Interrupt handler
183 * 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) 193 * 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE)
184 */ 194 */
185
186 195
187 .section .vectors.1, "ax", %progbits 196 .section .vectors.1, "ax", %progbits
188 la k0, tlb_refill_handler 197 la k0, tlb_refill_handler
189 jr k0 198 jr k0
190 nop 199 nop
191 200
192 .section .vectors.2, "ax", %progbits 201 .section .vectors.2, "ax", %progbits
@@ -235,10 +244,10 @@ real_exception_handler:
235 sw v1, 0x64(sp) 244 sw v1, 0x64(sp)
236 sw v0, 0x68(sp) 245 sw v0, 0x68(sp)
237 sw $1, 0x6C(sp) 246 sw $1, 0x6C(sp)
238 mflo k0 # Move From LO 247 mflo k0
239 nop 248 nop
240 sw k0, 0x70(sp) 249 sw k0, 0x70(sp)
241 mfhi k0 # Move From HI 250 mfhi k0
242 nop 251 nop
243 sw k0, 0x74(sp) 252 sw k0, 0x74(sp)
244 mfc0 k0, C0_STATUS # Status register 253 mfc0 k0, C0_STATUS # Status register
@@ -294,10 +303,10 @@ _int:
294 lw v0, 0x68(sp) 303 lw v0, 0x68(sp)
295 lw $1, 0x6C(sp) 304 lw $1, 0x6C(sp)
296 lw k0, 0x70(sp) 305 lw k0, 0x70(sp)
297 mtlo k0 # Move To LO 306 mtlo k0
298 nop 307 nop
299 lw k0, 0x74(sp) 308 lw k0, 0x74(sp)
300 mthi k0 # Move To HI 309 mthi k0
301 nop 310 nop
302 lw k0, 0x78(sp) 311 lw k0, 0x78(sp)
303 nop 312 nop
@@ -360,10 +369,10 @@ _exception:
360 lw v0, 0x68(sp) 369 lw v0, 0x68(sp)
361 lw $1, 0x6C(sp) 370 lw $1, 0x6C(sp)
362 lw k0, 0x70(sp) 371 lw k0, 0x70(sp)
363 mtlo k0 # Move To LO 372 mtlo k0
364 nop 373 nop
365 lw k0, 0x74(sp) 374 lw k0, 0x74(sp)
366 mthi k0 # Move To HI 375 mthi k0
367 nop 376 nop
368 lw k0, 0x78(sp) 377 lw k0, 0x78(sp)
369 nop 378 nop