Global data

Globally required fields are held in the global data structure. A pointer to the structure is available as symbol gd. The symbol is made available by the macro %DECLARE_GLOBAL_DATA_PTR.

Register pointing to global data

On most architectures the global data pointer is stored in a register.

ARC

r25

ARM 32bit

r9

ARM 64bit

x18

M68000

d7

MicroBlaze

r31

Nios II

gp

PowerPC

r2

RISC-V

gp (x3)

SuperH

r13

x86 32bit

fs

The sandbox, x86_64, and Xtensa are notable exceptions.

Clang for ARM does not support assigning a global register. When using Clang gd is defined as an inline function using assembly code. This adds a few bytes to the code size.

Binaries called by U-Boot are not aware of the register usage and will not conserve gd. UEFI binaries call the API provided by U-Boot and may return to U-Boot. The value of gd has to be saved every time U-Boot is left and restored whenever U-Boot is reentered. This is also relevant for the implementation of function tracing. For setting the value of gd function set_gd() can be used.

Global data structure

struct global_data

global data structure

Definition

struct global_data {
  struct bd_info *bd;
  unsigned long flags;
  unsigned int baudrate;
  unsigned long cpu_clk;
  unsigned long bus_clk;
  unsigned long pci_clk;
  unsigned long mem_clk;
#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO);
  unsigned long fb_base;
#endif;
#if defined(CONFIG_POST);
  unsigned long post_log_word;
  unsigned long post_log_res;
  unsigned long post_init_f_time;
#endif;
#ifdef CONFIG_BOARD_TYPES;
  unsigned long board_type;
#endif;
  unsigned long have_console;
#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER);
  long precon_buf_idx;
#endif;
  unsigned long env_addr;
  unsigned long env_valid;
  unsigned long env_has_init;
  int env_load_prio;
  unsigned long ram_base;
  phys_addr_t ram_top;
  unsigned long relocaddr;
  phys_size_t ram_size;
  unsigned long mon_len;
  unsigned long irq_sp;
  unsigned long start_addr_sp;
  unsigned long reloc_off;
  struct global_data *new_gd;
#ifdef CONFIG_DM;
  struct udevice *dm_root;
  struct udevice *dm_root_f;
  struct list_head uclass_root_s;
  struct list_head *uclass_root;
# if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT);
  struct driver_rt *dm_driver_rt;
# endif;
#if CONFIG_IS_ENABLED(OF_PLATDATA_RT);
  struct udevice_rt *dm_udevice_rt;
  void *dm_priv_base;
# endif;
#endif;
#ifdef CONFIG_TIMER;
  struct udevice *timer;
#endif;
  const void *fdt_blob;
  void *new_fdt;
  unsigned long fdt_size;
  enum fdt_source_t fdt_src;
#if CONFIG_IS_ENABLED(OF_LIVE);
  struct device_node *of_root;
#endif;
#if CONFIG_IS_ENABLED(MULTI_DTB_FIT);
  const void *multi_dtb_fit;
#endif;
  struct jt_funcs *jt;
  char env_buf[32];
#ifdef CONFIG_TRACE;
  void *trace_buff;
#endif;
#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY);
  int cur_i2c_bus;
#endif;
  unsigned int timebase_h;
  unsigned int timebase_l;
#if CONFIG_VAL(SYS_MALLOC_F_LEN);
  unsigned long malloc_base;
  unsigned long malloc_limit;
  unsigned long malloc_ptr;
#endif;
#ifdef CONFIG_PCI;
  struct pci_controller *hose;
  phys_addr_t pci_ram_top;
#endif;
#ifdef CONFIG_PCI_BOOTDELAY;
  int pcidelay_done;
#endif;
  struct udevice *cur_serial_dev;
  struct arch_global_data arch;
#ifdef CONFIG_CONSOLE_RECORD;
  struct membuff console_out;
  struct membuff console_in;
#endif;
#ifdef CONFIG_DM_VIDEO;
  ulong video_top;
  ulong video_bottom;
#endif;
#ifdef CONFIG_BOOTSTAGE;
  struct bootstage_data *bootstage;
  struct bootstage_data *new_bootstage;
#endif;
#ifdef CONFIG_LOG;
  int log_drop_count;
  int default_log_level;
  struct list_head log_head;
  int log_fmt;
  bool processing_msg;
  int logc_prev;
  int logl_prev;
  bool log_cont;
#endif;
#if CONFIG_IS_ENABLED(BLOBLIST);
  struct bloblist_hdr *bloblist;
  struct bloblist_hdr *new_bloblist;
#endif;
#if CONFIG_IS_ENABLED(HANDOFF);
  struct spl_handoff *spl_handoff;
#endif;
#if defined(CONFIG_TRANSLATION_OFFSET);
  fdt_addr_t translation_offset;
#endif;
#ifdef CONFIG_GENERATE_ACPI_TABLE;
  struct acpi_ctx *acpi_ctx;
  ulong acpi_start;
#endif;
#if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE);
  char *smbios_version;
#endif;
#if CONFIG_IS_ENABLED(EVENT);
  struct event_state event_state;
#endif;
#ifdef CONFIG_CYCLIC;
  struct cyclic_drv *cyclic;
#endif;
  struct list_head dmtag_list;
};

Members

bd

board information

flags

global data flags

See enum gd_flags

baudrate

baud rate of the serial interface

cpu_clk

CPU clock rate in Hz

bus_clk

platform clock rate in Hz

pci_clk

PCI clock rate in Hz

mem_clk

memory clock rate in Hz

fb_base

base address of frame buffer memory

post_log_word

active POST tests

post_log_word is a bit mask defining which POST tests are recorded (see constants POST_*).

post_log_res

POST results

post_log_res is a bit mask with the POST results. A bit with value 1 indicates successful execution.

post_init_f_time

time in ms when post_init_f() started

board_type

board type

If a U-Boot configuration supports multiple board types, the actual board type may be stored in this field.

have_console

console is available

A value of 1 indicates that serial_init() was called and a console is available. A value of 0 indicates that console input and output drivers shall not be called.

precon_buf_idx

pre-console buffer index

precon_buf_idx indicates the current position of the buffer used to collect output before the console becomes available. When negative, the pre-console buffer is temporarily disabled (used when the pre-console buffer is being written out, to prevent adding its contents to itself).

env_addr

address of environment structure

env_addr contains the address of the structure holding the environment variables.

env_valid

environment is valid

See enum env_valid

env_has_init

bit mask indicating environment locations

enum env_location defines which bit relates to which location

env_load_prio

priority of the loaded environment

ram_base

base address of RAM used by U-Boot

ram_top

top address of RAM used by U-Boot

relocaddr

start address of U-Boot in RAM

After relocation this field indicates the address to which U-Boot has been relocated. It can be displayed using the bdinfo command. Its value is needed to display the source code when debugging with GDB using the ‘add-symbol-file u-boot <relocaddr>’ command.

ram_size

RAM size in bytes

mon_len

monitor length in bytes

irq_sp

IRQ stack pointer

start_addr_sp

initial stack pointer address

reloc_off

relocation offset

new_gd

pointer to relocated global data

dm_root

root instance for Driver Model

dm_root_f

pre-relocation root instance

uclass_root_s

head of core tree when uclasses are not in read-only memory.

When uclasses are in read-only memory, uclass_root_s is not used and uclass_root points to the root node generated by dtoc.

uclass_root

pointer to head of core tree, if uclasses are in read-only memory and cannot be adjusted to use uclass_root as a list head.

When not in read-only memory, uclass_root_s is used to hold the uclass root, and uclass_root points to the address of uclass_root_s.

dm_driver_rt

Dynamic info about the driver

dm_udevice_rt

Dynamic info about the udevice

dm_priv_base

Base address of the priv/plat region used when udevices and uclasses are in read-only memory. This is NULL if not used

timer

timer instance for Driver Model

fdt_blob

U-Boot’s own device tree, NULL if none

new_fdt

relocated device tree

fdt_size

space reserved for relocated device space

fdt_src

Source of FDT

of_root

root node of the live tree

multi_dtb_fit

pointer to uncompressed multi-dtb FIT image

jt

jump table

The jump table contains pointers to exported functions. A pointer to the jump table is passed to standalone applications.

env_buf

buffer for env_get() before reloc

trace_buff

trace buffer

When tracing function in U-Boot this field points to the buffer recording the function calls.

cur_i2c_bus

currently used I2C bus

timebase_h

high 32 bits of timer

timebase_l

low 32 bits of timer

malloc_base

base address of early malloc()

malloc_limit

limit address of early malloc()

malloc_ptr

current address of early malloc()

hose

PCI hose for early use

pci_ram_top

top of region accessible to PCI

pcidelay_done

delay time before scanning of PIC hose expired

If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of milliseconds defined by environment variable pcidelay before scanning. Once this delay has expired the flag pcidelay_done is set to 1.

cur_serial_dev

current serial device

arch

architecture-specific data

console_out

output buffer for console recording

This buffer is used to collect output during console recording.

console_in

input buffer for console recording

If console recording is activated, this buffer can be used to emulate input.

video_top

top of video frame buffer area

video_bottom

bottom of video frame buffer area

bootstage

boot stage information

new_bootstage

relocated boot stage information

log_drop_count

number of dropped log messages

This counter is incremented for each log message which can not be processed because logging is not yet available as signaled by flag GD_FLG_LOG_READY in flags.

default_log_level

default logging level

For logging devices without filters default_log_level defines the logging level, cf. enum log_level_t.

log_head

list of logging devices

log_fmt

bit mask for logging format

The log_fmt bit mask selects the fields to be shown in log messages. enum log_fmt defines the bits of the bit mask.

processing_msg

a log message is being processed

This flag is used to suppress the creation of additional messages while another message is being processed.

logc_prev

logging category of previous message

This value is used as logging category for continuation messages.

logl_prev

logging level of the previous message

This value is used as logging level for continuation messages.

log_cont

Previous log line did not finished wtih n

This allows for chained log messages on the same line

bloblist

blob list information

new_bloblist

relocated blob list information

spl_handoff

SPL hand-off information

translation_offset

optional translation offset

See CONFIG_TRANSLATION_OFFSET.

acpi_ctx

ACPI context pointer

acpi_start

Start address of ACPI tables

smbios_version

Points to SMBIOS type 0 version

event_state

Points to the current state of events

cyclic

cyclic driver data

dmtag_list

List of DM tags

gd_board_type

gd_board_type ()

retrieve board type

Parameters

Return

global board type

enum gd_flags

global data flags

Constants

GD_FLG_RELOC

code was relocated to RAM

GD_FLG_DEVINIT

devices have been initialized

GD_FLG_SILENT

silent mode

GD_FLG_POSTFAIL

critical POST test failed

GD_FLG_POSTSTOP

POST sequence aborted

GD_FLG_LOGINIT

log Buffer has been initialized

GD_FLG_DISABLE_CONSOLE

disable console (in & out)

GD_FLG_ENV_READY

environment imported into hash table

GD_FLG_SERIAL_READY

pre-relocation serial console ready

GD_FLG_FULL_MALLOC_INIT

full malloc() is ready

GD_FLG_SPL_INIT

spl_init() has been called

GD_FLG_SKIP_RELOC

don’t relocate

GD_FLG_RECORD

record console

GD_FLG_RECORD_OVF

record console overflow

GD_FLG_ENV_DEFAULT

default variable flag

GD_FLG_SPL_EARLY_INIT

early SPL initialization is done

GD_FLG_LOG_READY

log system is ready for use

GD_FLG_WDT_READY

watchdog is ready for use

GD_FLG_SKIP_LL_INIT

don’t perform low-level initialization

GD_FLG_SMP_READY

SMP initialization is complete

GD_FLG_FDT_CHANGED

Device tree change has been detected by tests

Description

See field flags of struct global_data.