diff options
Diffstat (limited to 'firmware/target/arm/crt0-pp.S')
-rw-r--r-- | firmware/target/arm/crt0-pp.S | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/firmware/target/arm/crt0-pp.S b/firmware/target/arm/crt0-pp.S index 12c885068d..4a9d4232b4 100644 --- a/firmware/target/arm/crt0-pp.S +++ b/firmware/target/arm/crt0-pp.S | |||
@@ -262,17 +262,6 @@ cpu_init: | |||
262 | strhi r4, [r2], #4 | 262 | strhi r4, [r2], #4 |
263 | bhi 1b | 263 | bhi 1b |
264 | 264 | ||
265 | /* Load stack munge value */ | ||
266 | ldr r4, =0xdeadbeef | ||
267 | |||
268 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
269 | ldr r2, =stackbegin | ||
270 | ldr sp, =stackend | ||
271 | 1: | ||
272 | cmp sp, r2 | ||
273 | strhi r4, [r2], #4 | ||
274 | bhi 1b | ||
275 | |||
276 | #if NUM_CORES > 1 | 265 | #if NUM_CORES > 1 |
277 | /* Set up idle stack and munge it with 0xdeadbeef */ | 266 | /* Set up idle stack and munge it with 0xdeadbeef */ |
278 | ldr r2, =cpu_idlestackbegin | 267 | ldr r2, =cpu_idlestackbegin |
@@ -289,14 +278,28 @@ cpu_init: | |||
289 | /* Set up stack for FIQ mode */ | 278 | /* Set up stack for FIQ mode */ |
290 | msr cpsr_c, #0xd1 /* IRQ/FIQ disabled */ | 279 | msr cpsr_c, #0xd1 /* IRQ/FIQ disabled */ |
291 | ldr sp, =fiq_stack | 280 | ldr sp, =fiq_stack |
292 | /* Let abort and undefined modes use IRQ stack */ | 281 | |
282 | /* Let svc, abort and undefined modes use irq stack */ | ||
283 | msr cpsr_c, #0xd3 /* IRQ/FIQ disabled */ | ||
284 | ldr sp, =irq_stack | ||
293 | msr cpsr_c, #0xd7 /* IRQ/FIQ disabled */ | 285 | msr cpsr_c, #0xd7 /* IRQ/FIQ disabled */ |
294 | ldr sp, =irq_stack | 286 | ldr sp, =irq_stack |
295 | msr cpsr_c, #0xdb /* IRQ/FIQ disabled */ | 287 | msr cpsr_c, #0xdb /* IRQ/FIQ disabled */ |
296 | ldr sp, =irq_stack | 288 | ldr sp, =irq_stack |
297 | 289 | ||
298 | /* Switch back to supervisor mode */ | 290 | /* Switch to sys mode */ |
299 | msr cpsr_c, #0xd3 | 291 | msr cpsr_c, #0xdf |
292 | |||
293 | /* Load stack munge value */ | ||
294 | ldr r4, =0xdeadbeef | ||
295 | |||
296 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
297 | ldr r2, =stackbegin | ||
298 | ldr sp, =stackend | ||
299 | 1: | ||
300 | cmp sp, r2 | ||
301 | strhi r4, [r2], #4 | ||
302 | bhi 1b | ||
300 | 303 | ||
301 | /* Delay waking the COP until thread initialization is complete unless dual-core | 304 | /* Delay waking the COP until thread initialization is complete unless dual-core |
302 | support is not enabled in which case the cop_main function does not perform | 305 | support is not enabled in which case the cop_main function does not perform |
@@ -320,15 +323,6 @@ cop_init: | |||
320 | beq 1b | 323 | beq 1b |
321 | #endif | 324 | #endif |
322 | 325 | ||
323 | /* Set up idle stack for COP and munge it with 0xdeadbeef */ | ||
324 | ldr sp, =cop_idlestackend | ||
325 | ldr r2, =cop_idlestackbegin | ||
326 | ldr r4, =0xdeadbeef | ||
327 | 2: | ||
328 | cmp sp, r2 | ||
329 | strhi r4, [r2], #4 | ||
330 | bhi 2b | ||
331 | |||
332 | /* Set up stack for IRQ mode */ | 326 | /* Set up stack for IRQ mode */ |
333 | msr cpsr_c, #0x92 /* IRQ disabled, FIQ enabled */ | 327 | msr cpsr_c, #0x92 /* IRQ disabled, FIQ enabled */ |
334 | ldr sp, =cop_irq_stack | 328 | ldr sp, =cop_irq_stack |
@@ -336,15 +330,26 @@ cop_init: | |||
336 | msr cpsr_c, #0xd1 /* IRQ/FIQ disabled */ | 330 | msr cpsr_c, #0xd1 /* IRQ/FIQ disabled */ |
337 | ldr sp, =cop_fiq_stack | 331 | ldr sp, =cop_fiq_stack |
338 | 332 | ||
339 | /* Let abort and undefined modes use IRQ stack */ | 333 | /* Let svc, abort and undefined modes use irq stack */ |
334 | msr cpsr_c, #0xd3 /* IRQ/FIQ disabled */ | ||
335 | ldr sp, =cop_irq_stack | ||
340 | msr cpsr_c, #0xd7 /* IRQ/FIQ disabled */ | 336 | msr cpsr_c, #0xd7 /* IRQ/FIQ disabled */ |
341 | ldr sp, =cop_irq_stack | 337 | ldr sp, =cop_irq_stack |
342 | msr cpsr_c, #0xdb /* IRQ/FIQ disabled */ | 338 | msr cpsr_c, #0xdb /* IRQ/FIQ disabled */ |
343 | ldr sp, =cop_irq_stack | 339 | ldr sp, =cop_irq_stack |
344 | 340 | ||
345 | /* Switch back to supervisor mode */ | 341 | /* Switch to sys mode */ |
346 | msr cpsr_c, #0xd3 | 342 | msr cpsr_c, #0xdf |
347 | 343 | ||
344 | /* Set up idle stack for COP and munge it with 0xdeadbeef */ | ||
345 | ldr sp, =cop_idlestackend | ||
346 | ldr r2, =cop_idlestackbegin | ||
347 | ldr r4, =0xdeadbeef | ||
348 | 2: | ||
349 | cmp sp, r2 | ||
350 | strhi r4, [r2], #4 | ||
351 | bhi 2b | ||
352 | |||
348 | /* Run cop_main() in apps/main.c */ | 353 | /* Run cop_main() in apps/main.c */ |
349 | ldr pc, =cop_main | 354 | ldr pc, =cop_main |
350 | 355 | ||
@@ -383,12 +388,15 @@ undef_instr_handler: | |||
383 | mov r1, #0 | 388 | mov r1, #0 |
384 | b UIE | 389 | b UIE |
385 | 390 | ||
386 | /* We run supervisor mode most of the time, and should never see a software | 391 | /* We run sys mode most of the time, and should never see a software |
387 | exception being thrown. Perhaps make it illegal and call UIE? | 392 | exception being thrown. Make it illegal and call UIE. |
388 | */ | 393 | */ |
389 | software_int_handler: | 394 | software_int_handler: |
390 | reserved_handler: | 395 | reserved_handler: |
391 | movs pc, lr | 396 | sub r0, lr, #4 |
397 | mov r1, #4 | ||
398 | b UIE | ||
399 | |||
392 | prefetch_abort_handler: | 400 | prefetch_abort_handler: |
393 | sub r0, lr, #4 | 401 | sub r0, lr, #4 |
394 | mov r1, #1 | 402 | mov r1, #1 |