riscv: define function set_gd()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 10 Sep 2020 05:47:39 +0000 (07:47 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 14 Sep 2020 21:28:52 +0000 (23:28 +0200)
Function set_gd() is needed in the UEFI sub-system if the global data
pointer is stored in a register.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
arch/riscv/include/asm/global_data.h

index 2eb1481..b711fcc 100644 (file)
@@ -39,4 +39,13 @@ struct arch_global_data {
 
 #define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("gp")
 
+static inline void set_gd(volatile gd_t *gd_ptr)
+{
+#ifdef CONFIG_64BIT
+       asm volatile("ld gp, %0\n" : : "m"(gd_ptr));
+#else
+       asm volatile("lw gp, %0\n" : : "m"(gd_ptr));
+#endif
+}
+
 #endif /* __ASM_GBL_DATA_H */