| 1 |
Run generated ELFs using a more normal OS-style exec startup/teardown |
| 2 |
procedure. |
| 3 |
|
| 4 |
This allows generated executables to properly support running in U-Boot. |
| 5 |
Without this, executables will run but never return execution control to U-Boot |
| 6 |
on completion. |
| 7 |
|
| 8 |
In addition, this also returns the exit status of the program so u-boot can use |
| 9 |
it as necessary. |
| 10 |
|
| 11 |
Note that this patch was generated against the 2015.2 release of the Xilinx SDK |
| 12 |
so it may need to be re-rolled for future versions. |
| 13 |
|
| 14 |
--- sdk/bsp/ps7_cortexa9_0/libsrc/standalone_v5_1/src/asm_vectors.S |
| 15 |
+++ sdk/bsp/ps7_cortexa9_0/libsrc/standalone_v5_1/src/asm_vectors.S |
| 16 |
@@ -68,6 +68,10 @@ |
| 17 |
|
| 18 |
.section .vectors |
| 19 |
_vector_table: |
| 20 |
+ /* Save u-boot state */ |
| 21 |
+ stmfd sp!, {fp, lr} |
| 22 |
+ add fp, sp, #4 |
| 23 |
+ |
| 24 |
B _boot |
| 25 |
B Undefined |
| 26 |
B SVCHandler |
| 27 |
--- sdk/bsp/ps7_cortexa9_0/libsrc/standalone_v5_1/src/boot.S |
| 28 |
+++ sdk/bsp/ps7_cortexa9_0/libsrc/standalone_v5_1/src/boot.S |
| 29 |
@@ -192,11 +192,11 @@ |
| 30 |
str r6, [r7] |
| 31 |
|
| 32 |
/* Invalidate caches and TLBs */ |
| 33 |
- mov r0,#0 /* r0 = 0 */ |
| 34 |
- mcr p15, 0, r0, c8, c7, 0 /* invalidate TLBs */ |
| 35 |
- mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */ |
| 36 |
- mcr p15, 0, r0, c7, c5, 6 /* Invalidate branch predictor array */ |
| 37 |
- bl invalidate_dcache /* invalidate dcache */ |
| 38 |
+ //mov r0,#0 /* r0 = 0 */ |
| 39 |
+ //mcr p15, 0, r0, c8, c7, 0 /* invalidate TLBs */ |
| 40 |
+ //mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */ |
| 41 |
+ //mcr p15, 0, r0, c7, c5, 6 /* Invalidate branch predictor array */ |
| 42 |
+ //bl invalidate_dcache /* invalidate dcache */ |
| 43 |
|
| 44 |
/* Disable MMU, if enabled */ |
| 45 |
mrc p15, 0, r0, c1, c0, 0 /* read CP15 register 1 */ |
| 46 |
--- sdk/bsp/ps7_cortexa9_0/libsrc/standalone_v5_1/src/xil-crt0.S |
| 47 |
+++ sdk/bsp/ps7_cortexa9_0/libsrc/standalone_v5_1/src/xil-crt0.S |
| 48 |
@@ -127,6 +127,9 @@ |
| 49 |
/* Let her rip */ |
| 50 |
bl main |
| 51 |
|
| 52 |
+ /* Save the return value for u-boot */ |
| 53 |
+ push {r0} |
| 54 |
+ |
| 55 |
/* Cleanup global constructors */ |
| 56 |
bl __libc_fini_array |
| 57 |
|
| 58 |
@@ -135,6 +138,11 @@ |
| 59 |
bl _profile_clean |
| 60 |
#endif /* PROFILING */ |
| 61 |
|
| 62 |
+ /* Return status and control to u-boot */ |
| 63 |
+ pop {r0} |
| 64 |
+ sub sp, fp, #4 |
| 65 |
+ ldmfd sp!, {fp, pc} |
| 66 |
+ |
| 67 |
/* All done */ |
| 68 |
bl exit |
| 69 |
|