]> Git Repo - J-u-boot.git/blobdiff - arch/riscv/cpu/start.S
riscv: prior_stage_fdt_address should only be used when OF_PRIOR_STAGE is enabled
[J-u-boot.git] / arch / riscv / cpu / start.S
index f55b8cbc371f2dc26e8e3b92c14101dd2e8835d8..60ac8c621e4d20df2d1a6662725091983a6f5e5d 100644 (file)
 #define SYM_SIZE               0x18
 #endif
 
+.section .data
+secondary_harts_relocation_error:
+       .ascii "Relocation of secondary harts has failed, error %d\n"
+
 .section .text
 .globl _start
 _start:
+#ifdef CONFIG_RISCV_MMODE
+       csrr    a0, mhartid
+#endif
+
        /* save hart id and dtb pointer */
        mv      tp, a0
        mv      s1, a1
@@ -90,6 +98,7 @@ call_board_init_f_0:
        mv      sp, a0
 #endif
 
+#ifndef CONFIG_XIP
        /*
         * Pick hart to initialize global data and run U-Boot. The other harts
         * wait for initialization to complete.
@@ -98,15 +107,21 @@ call_board_init_f_0:
        li      s2, 1
        amoswap.w s2, t1, 0(t0)
        bnez    s2, wait_for_gd_init
+#else
+       bnez    tp, secondary_hart_loop
+#endif
 
+#ifdef CONFIG_OF_PRIOR_STAGE
        la      t0, prior_stage_fdt_address
        SREG    s1, 0(t0)
+#endif
 
        jal     board_init_f_init_reserve
 
        /* save the boot hart id to global_data */
        SREG    tp, GD_BOOT_HART(gp)
 
+#ifndef CONFIG_XIP
        la      t0, available_harts_lock
        fence   rw, w
        amoswap.w zero, zero, 0(t0)
@@ -133,6 +148,7 @@ wait_for_gd_init:
         * secondary_hart_loop.
         */
        bnez    s2, secondary_hart_loop
+#endif
 
        /* Enable cache */
        jal     icache_enable
@@ -270,8 +286,15 @@ relocate_secondary_harts:
        mv      a2, s3
        jal     smp_call_function
 
+       /* hang if relocation of secondary harts has failed */
+       beqz    a0, 1f
+       mv      a1, a0
+       la      a0, secondary_harts_relocation_error
+       jal     printf
+       jal     hang
+
        /* restore relocation offset */
-       mv      t6, s5
+1:     mv      t6, s5
 #endif
 
 /*
This page took 0.027515 seconds and 4 git commands to generate.