1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * (C) Copyright 2002 4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 5 * 6 * Copyright (c) 2017 Microsemi Corporation. 7 * Padmarao Begari, Microsemi Corporation <padmarao.begari@microsemi.com> 8 */ 9 10 #ifndef __ASM_GBL_DATA_H 11 #define __ASM_GBL_DATA_H 12 13 #include <linux/types.h> 14 #include <asm/smp.h> 15 #include <asm/u-boot.h> 16 #include <compiler.h> 17 #include <config.h> 18 19 /* Architecture-specific global data */ 20 struct arch_global_data { 21 long boot_hart; /* boot hart id */ 22 phys_addr_t firmware_fdt_addr; 23 #if CONFIG_IS_ENABLED(RISCV_ACLINT) 24 void __iomem *aclint; /* aclint base address */ 25 #endif 26 #ifdef CONFIG_ANDES_PLICSW 27 void __iomem *plicsw; /* andes plicsw base address */ 28 #endif 29 #if CONFIG_IS_ENABLED(SMP) 30 struct ipi_data ipi[CONFIG_NR_CPUS]; 31 #endif 32 #if !CONFIG_IS_ENABLED(XIP) 33 #ifdef CONFIG_AVAILABLE_HARTS 34 ulong available_harts; 35 #endif 36 #endif 37 #if CONFIG_IS_ENABLED(ACPI) 38 ulong table_start; /* Start address of ACPI tables */ 39 ulong table_end; /* End address of ACPI tables */ 40 ulong table_start_high; /* Start address of high ACPI tables */ 41 ulong table_end_high; /* End address of high ACPI tables */ 42 #endif 43 #ifdef CONFIG_SMBIOS 44 ulong smbios_start; /* Start address of SMBIOS table */ 45 #endif 46 struct resume_data *resume; 47 }; 48 49 #include <asm-generic/global_data.h> 50 51 #if defined(__clang__) || CONFIG_IS_ENABLED(LTO) 52 53 #define DECLARE_GLOBAL_DATA_PTR 54 #define gd get_gd() 55 get_gd(void)56static inline gd_t *get_gd(void) 57 { 58 gd_t *gd_ptr; 59 60 __asm__ volatile ("mv %0, gp\n" : "=r" (gd_ptr)); 61 62 return gd_ptr; 63 } 64 65 #else 66 67 #define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("gp") 68 69 #endif 70 set_gd(gd_t * gd_ptr)71static inline void set_gd(gd_t *gd_ptr) 72 { 73 #ifdef CONFIG_64BIT 74 asm volatile("ld gp, %0\n" : : "m"(gd_ptr)); 75 #else 76 asm volatile("lw gp, %0\n" : : "m"(gd_ptr)); 77 #endif 78 } 79 80 #endif /* __ASM_GBL_DATA_H */ 81