1.. SPDX-License-Identifier: GPL-2.0+
2
3Global data
4===========
5
6Globally required fields are held in the global data structure. A pointer to the
7structure is available as symbol gd. The symbol is made available by the macro
8%DECLARE_GLOBAL_DATA_PTR.
9
10Register pointing to global data
11--------------------------------
12
13On most architectures the global data pointer is stored in a register.
14
15+------------+----------+
16| ARC        | r25      |
17+------------+----------+
18| ARM 32bit  | r9       |
19+------------+----------+
20| ARM 64bit  | x18      |
21+------------+----------+
22| M68000     | d7       |
23+------------+----------+
24| MicroBlaze | r31      |
25+------------+----------+
26| NDS32      | r10      |
27+------------+----------+
28| Nios II    | gp       |
29+------------+----------+
30| PowerPC    | r2       |
31+------------+----------+
32| RISC-V     | gp (x3)  |
33+------------+----------+
34| SuperH     | r13      |
35+------------+----------+
36| x86 32bit  | fs       |
37+------------+----------+
38
39The sandbox, x86_64, and Xtensa are notable exceptions.
40
41Clang for ARM does not support assigning a global register. When using Clang
42gd is defined as an inline function using assembly code. This adds a few bytes
43to the code size.
44
45Binaries called by U-Boot are not aware of the register usage and will not
46conserve gd. UEFI binaries call the API provided by U-Boot and may return to
47U-Boot. The value of gd has to be saved every time U-Boot is left and restored
48whenever U-Boot is reentered. This is also relevant for the implementation of
49function tracing. For setting the value of gd function set_gd() can be used.
50
51Global data structure
52---------------------
53
54.. kernel-doc:: include/asm-generic/global_data.h
55   :internal:
56