Heinrich Schuchardt | fd57449 | 2020-10-05 08:30:10 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Global data |
| 4 | =========== |
| 5 | |
| 6 | Globally required fields are held in the global data structure. A pointer to the |
| 7 | structure is available as symbol gd. The symbol is made available by the macro |
| 8 | %DECLARE_GLOBAL_DATA_PTR. |
| 9 | |
| 10 | Register pointing to global data |
| 11 | -------------------------------- |
| 12 | |
| 13 | On 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 | +------------+----------+ |
Heinrich Schuchardt | fd57449 | 2020-10-05 08:30:10 +0200 | [diff] [blame] | 26 | | Nios II | gp | |
| 27 | +------------+----------+ |
| 28 | | PowerPC | r2 | |
| 29 | +------------+----------+ |
| 30 | | RISC-V | gp (x3) | |
| 31 | +------------+----------+ |
| 32 | | SuperH | r13 | |
| 33 | +------------+----------+ |
Heinrich Schuchardt | 4362241 | 2020-10-15 07:40:57 +0200 | [diff] [blame] | 34 | | x86 32bit | fs | |
| 35 | +------------+----------+ |
Heinrich Schuchardt | fd57449 | 2020-10-05 08:30:10 +0200 | [diff] [blame] | 36 | |
Heinrich Schuchardt | 4362241 | 2020-10-15 07:40:57 +0200 | [diff] [blame] | 37 | The sandbox, x86_64, and Xtensa are notable exceptions. |
Heinrich Schuchardt | fd57449 | 2020-10-05 08:30:10 +0200 | [diff] [blame] | 38 | |
| 39 | Clang for ARM does not support assigning a global register. When using Clang |
| 40 | gd is defined as an inline function using assembly code. This adds a few bytes |
| 41 | to the code size. |
| 42 | |
| 43 | Binaries called by U-Boot are not aware of the register usage and will not |
| 44 | conserve gd. UEFI binaries call the API provided by U-Boot and may return to |
| 45 | U-Boot. The value of gd has to be saved every time U-Boot is left and restored |
| 46 | whenever U-Boot is reentered. This is also relevant for the implementation of |
| 47 | function tracing. For setting the value of gd function set_gd() can be used. |
| 48 | |
| 49 | Global data structure |
| 50 | --------------------- |
| 51 | |
| 52 | .. kernel-doc:: include/asm-generic/global_data.h |
| 53 | :internal: |