riscv: Save boot hart id to the global data
authorBin Meng <bmeng.cn@gmail.com>
Wed, 12 Dec 2018 14:12:45 +0000 (06:12 -0800)
committerAndes <uboot@andestech.com>
Tue, 18 Dec 2018 01:56:27 +0000 (09:56 +0800)
At present the hart id passed via a0 in the U-Boot entry is saved
to s0 at the beginning but does not preserve later. Save it to the
global data structure so that it can be used later.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Anup Patel <anup@brainfault.org>
arch/riscv/cpu/start.S
arch/riscv/include/asm/global_data.h
arch/riscv/lib/asm-offsets.c [new file with mode: 0644]

index 47c3bf04342f89a14297a92b0978a8066600dd0d..81ea52b170f7f898e56b32c2ace08a602609ecf8 100644 (file)
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <elf.h>
 #include <asm/encoding.h>
+#include <generated/asm-offsets.h>
 
 #ifdef CONFIG_32BIT
 #define LREG                   lw
@@ -70,6 +71,9 @@ call_board_init_f_0:
 
        jal     board_init_f_init_reserve
 
+       /* save the boot hart id to global_data */
+       SREG    s0, GD_BOOT_HART(gp)
+
        mv      a0, zero                /* a0 <-- boot_flags = 0 */
        la      t5, board_init_f
        jr      t5                      /* jump to board_init_f() */
index 46fcfab840791ca157bf56706150ecf075414805..a3a342c6e1cbe106ad78137b781537a061c1770d 100644 (file)
@@ -12,6 +12,7 @@
 
 /* Architecture-specific global data */
 struct arch_global_data {
+       long boot_hart;         /* boot hart id */
 #ifdef CONFIG_SIFIVE_CLINT
        void __iomem *clint;    /* clint base address */
 #endif
diff --git a/arch/riscv/lib/asm-offsets.c b/arch/riscv/lib/asm-offsets.c
new file mode 100644 (file)
index 0000000..e0b71f5
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
+ *
+ * From arch/x86/lib/asm-offsets.c
+ *
+ * This program is used to generate definitions needed by
+ * assembly language modules.
+ */
+
+#include <common.h>
+#include <linux/kbuild.h>
+
+int main(void)
+{
+       DEFINE(GD_BOOT_HART, offsetof(gd_t, arch.boot_hart));
+
+       return 0;
+}