global_data.rst 1.7 KB

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