@@ -287,28 +287,22 @@ not_angel:
287
287
* /
288
288
mov r0 , pc
289
289
cmp r0 , r4
290
- ldrcc r0 , LC0 + 28
290
+ ldrcc r0 , .Lheadroom
291
291
addcc r0 , r0 , pc
292
292
cmpcc r4 , r0
293
293
orrcc r4 , r4 , # 1 @ remember we skipped cache_on
294
294
blcs cache_on
295
295
296
- restart: adr r0 , LC0
297
- ldmia r0 , {r1 , r2 , r3 , r6 , r11 , r12 }
298
- ldr sp , [ r0 , # 24 ]
299
-
300
- / *
301
- * We might be running at a different address. We need
302
- * to fix up various pointers.
303
- * /
304
- sub r0 , r0 , r1 @ calculate the delta offset
305
- add r6 , r6 , r0 @ _edata
296
+ restart: adr r0 , LC1
297
+ ldr sp , [ r0 ]
298
+ ldr r6 , [ r0 , # 4 ]
299
+ add sp , sp , r0
300
+ add r6 , r6 , r0
306
301
307
302
get_inflated_image_size r9 , r10 , lr
308
303
309
304
#ifndef CONFIG_ZBOOT_ROM
310
305
/ * malloc space is above the relocated stack (64k max) * /
311
- add sp , sp , r0
312
306
add r10 , sp , # 0x10000
313
307
#else
314
308
/ *
@@ -322,18 +316,13 @@ restart: adr r0, LC0
322
316
mov r5 , # 0 @ init dtb size to 0
323
317
#ifdef CONFIG_ARM_APPENDED_DTB
324
318
/ *
325
- * r0 = delta
326
- * r2 = BSS start
327
- * r3 = BSS end
328
319
* r4 = final kernel address (possibly with LSB set)
329
320
* r5 = appended dtb size (still unknown)
330
321
* r6 = _edata
331
322
* r7 = architecture ID
332
323
* r8 = atags/device tree pointer
333
324
* r9 = size of decompressed image
334
325
* r10 = end of this image , including bss/stack/malloc space if non XIP
335
- * r11 = GOT start
336
- * r12 = GOT end
337
326
* sp = stack pointer
338
327
*
339
328
* if there are device trees (dtb) appended to zImage , advance r10 so th at the
@@ -381,7 +370,6 @@ restart: adr r0, LC0
381
370
/ * temporarily relocate the stack past the DTB work space * /
382
371
add sp , sp , r5
383
372
384
- stmfd sp ! , {r0 - r3 , ip , lr}
385
373
mov r0 , r8
386
374
mov r1 , r6
387
375
mov r2 , r5
@@ -400,7 +388,6 @@ restart: adr r0, LC0
400
388
mov r2 , r5
401
389
bleq atags_to_fdt
402
390
403
- ldmfd sp ! , {r0 - r3 , ip , lr}
404
391
sub sp , sp , r5
405
392
#endif
406
393
@@ -537,6 +524,10 @@ dtb_check_done:
537
524
mov pc , r0
538
525
539
526
wont_overwrite:
527
+ adr r0 , LC0
528
+ ldmia r0 , {r1 , r2 , r3 , r11 , r12 }
529
+ sub r0 , r0 , r1 @ calculate the delta offset
530
+
540
531
/ *
541
532
* If delta is zero , we are running at the address we were linked at .
542
533
* r0 = delta
@@ -660,13 +651,18 @@ not_relocated: mov r0, #0
660
651
LC0: .word LC0 @ r1
661
652
. word __bss_start @ r2
662
653
. word _end @ r3
663
- . word _edata @ r6
664
654
. word _got_start @ r11
665
655
. word _got_end @ ip
666
- . word .L_user_stack_end @ sp
667
- . word _end - restart + 16384 + 1024 * 1024
668
656
.size LC0 , . - LC0
669
657
658
+ .type LC1 , #object
659
+ LC1: .word .L_user_stack_end - LC1 @ sp
660
+ . word _edata - LC1 @ r6
661
+ .size LC1 , . - LC1
662
+
663
+ .Lheadroom:
664
+ . word _end - restart + 16384 + 1024 * 1024
665
+
670
666
.Linflated_image_size_offset:
671
667
.long (input_data_end - 4 ) - .
672
668
@@ -1434,37 +1430,26 @@ reloc_code_end:
1434
1430
1435
1431
#ifdef CONFIG_EFI_STUB
1436
1432
ENTRY(efi_enter_kernel)
1437
- mov r7 , r0 @ preserve image base
1438
- mov r4 , r1 @ preserve DT pointer
1433
+ mov r4 , r0 @ preserve image base
1434
+ mov r8 , r1 @ preserve DT pointer
1439
1435
1440
- mov r0, r4 @ DT start
1441
- add r1 , r4 , r2 @ DT end
1442
- bl cache_clean_flush
1436
+ mrc p15 , 0 , r0, c1 , c0 , 0 @ read SCTLR
1437
+ tst r0 , # 0x1 @ MMU enabled?
1438
+ orreq r4 , r4 , # 1 @ set LSB if not
1443
1439
1444
- mov r0 , r7 @ relocated zImage
1445
- ldr r1 , =_edata @ size of zImage
1446
- add r1 , r1 , r0 @ end of zImage
1440
+ mov r0 , r8 @ DT start
1441
+ add r1 , r8 , r2 @ DT end
1447
1442
bl cache_clean_flush
1448
1443
1449
- @ The PE/COFF loader might not have cleaned the code we are
1450
- @ running beyond the PoU , and so calling cache_off below from
1451
- @ inside the PE/COFF loader allocated region is unsafe unless
1452
- @ we explicitly clean it to the PoC.
1453
- adr r0 , call_cache_fn @ region of code we will
1454
- adr r1 , 0f @ run with MMU off
1455
- bl cache_clean_flush
1456
- bl cache_off
1444
+ adr r0 , 0f @ switch to our stack
1445
+ ldr sp , [ r0 ]
1446
+ add sp , sp , r0
1457
1447
1458
- @ Set parameters for booting zImage according to boot protocol
1459
- @ put FDT address in r2 , it was returned by efi_entry()
1460
- @ r1 is the machine type , and r0 needs to be 0
1461
- mov r0 , # 0
1462
- mov r1 , # 0xFFFFFFFF
1463
- mov r2 , r4
1464
- add r7 , r7 , #(__efi_start - start)
1465
- mov pc , r7 @ no mode switch
1448
+ mov r5 , # 0 @ appended DTB size
1449
+ mov r7 , # 0xFFFFFFFF @ machine ID
1450
+ b wont_overwrite
1466
1451
ENDPROC(efi_enter_kernel)
1467
- 0 :
1452
+ 0 : .long .L_user_stack_end - .
1468
1453
#endif
1469
1454
1470
1455
. align
0 commit comments