blob: 47b5e2cfc8fc092b29febbbc6186aca38df413be [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Rick Chen76c0a242017-12-26 13:55:51 +08002/*
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>
Rick Chen76c0a242017-12-26 13:55:51 +08008 */
9
10#ifndef __ASM_GBL_DATA_H
11#define __ASM_GBL_DATA_H
12
Tom Rini10e6a372023-12-14 13:16:52 -050013#include <linux/types.h>
Lukas Auer83d573d2019-03-17 19:28:32 +010014#include <asm/smp.h>
Sean Anderson5aa00742020-06-24 06:41:16 -040015#include <asm/u-boot.h>
16#include <compiler.h>
Yao Zi73b4c2a2025-04-27 14:50:11 +000017#include <config.h>
Lukas Auer83d573d2019-03-17 19:28:32 +010018
Rick Chen76c0a242017-12-26 13:55:51 +080019/* Architecture-specific global data */
20struct arch_global_data {
Bin Meng89681a72018-12-12 06:12:45 -080021 long boot_hart; /* boot hart id */
Atish Patra111b8042020-04-21 11:15:01 -070022 phys_addr_t firmware_fdt_addr;
Bin Mengb5f03722023-06-21 23:11:46 +080023#if CONFIG_IS_ENABLED(RISCV_ACLINT)
24 void __iomem *aclint; /* aclint base address */
Bin Mengb6ee5e12018-12-12 06:12:30 -080025#endif
Yu Chien Peter Lin739cd6f2022-10-25 23:03:50 +080026#ifdef CONFIG_ANDES_PLICSW
Yu Chien Peter Lin52d54e12023-02-06 10:06:29 +080027 void __iomem *plicsw; /* andes plicsw base address */
Rick Chen6df4ed02019-04-02 15:56:39 +080028#endif
Bin Mengb161f902020-04-16 08:09:30 -070029#if CONFIG_IS_ENABLED(SMP)
Lukas Auer83d573d2019-03-17 19:28:32 +010030 struct ipi_data ipi[CONFIG_NR_CPUS];
31#endif
Nikita Shubin7e5e0292022-09-02 11:47:39 +030032#if !CONFIG_IS_ENABLED(XIP)
Rick Chen9c4d5c12022-09-21 14:34:54 +080033#ifdef CONFIG_AVAILABLE_HARTS
Lukas Auer83d573d2019-03-17 19:28:32 +010034 ulong available_harts;
Rick Chene5e6c362019-04-30 13:49:33 +080035#endif
Rick Chen9c4d5c12022-09-21 14:34:54 +080036#endif
Heinrich Schuchardt565ac632023-12-19 16:04:03 +010037#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
Simon Glass9b388102023-09-19 21:00:15 -060043#ifdef CONFIG_SMBIOS
44 ulong smbios_start; /* Start address of SMBIOS table */
45#endif
Anton Blanchard4cf23372024-08-08 02:14:17 +000046 struct resume_data *resume;
Rick Chen76c0a242017-12-26 13:55:51 +080047};
48
49#include <asm-generic/global_data.h>
50
Yao Zi73b4c2a2025-04-27 14:50:11 +000051#if defined(__clang__) || CONFIG_IS_ENABLED(LTO)
52
53#define DECLARE_GLOBAL_DATA_PTR
54#define gd get_gd()
55
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
Rick Chenb34b4b92018-02-12 11:10:04 +080067#define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("gp")
Rick Chen76c0a242017-12-26 13:55:51 +080068
Yao Zi73b4c2a2025-04-27 14:50:11 +000069#endif
70
Heinrich Schuchardt6e7eb462020-09-10 07:47:39 +020071static inline void set_gd(volatile 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
Rick Chen76c0a242017-12-26 13:55:51 +080080#endif /* __ASM_GBL_DATA_H */