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.
Current implementation uses a register for the GD pointer because this results in smaller code. However, using plain global data for the GD pointer would be possible too (and simpler, as it does not require the reservation of a specific register for it), but the resulting code is bigger.
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 CONFIG_IS_ENABLED(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_IS_ENABLED(CMD_BDINFO_EXTRA);
unsigned long malloc_start;
#endif;
#if CONFIG_IS_ENABLED(SYS_MALLOC_F);
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;
#if CONFIG_IS_ENABLED(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_ACPI;
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 hlist_head cyclic_list;
#endif;
struct list_head dmtag_list;
};
Members
bdboard information
flagsglobal data flags
See
enum gd_flagsbaudratebaud rate of the serial interface
cpu_clkCPU clock rate in Hz
bus_clkplatform clock rate in Hz
pci_clkPCI clock rate in Hz
mem_clkmemory clock rate in Hz
fb_basebase address of frame buffer memory
post_log_wordactive POST tests
post_log_word is a bit mask defining which POST tests are recorded (see constants POST_*).
post_log_resPOST results
post_log_res is a bit mask with the POST results. A bit with value 1 indicates successful execution.
post_init_f_timetime in ms when post_init_f() started
board_typeboard type
If a U-Boot configuration supports multiple board types, the actual board type may be stored in this field.
have_consoleconsole 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_idxpre-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_addraddress of environment structure
env_addr contains the address of the structure holding the environment variables.
env_validenvironment is valid
See
enum env_validenv_has_initbit mask indicating environment locations
enum env_locationdefines which bit relates to which locationenv_load_priopriority of the loaded environment
ram_basebase address of RAM used by U-Boot
ram_toptop address of RAM used by U-Boot
relocaddrstart 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_sizeRAM size in bytes
mon_lenmonitor length in bytes
irq_spIRQ stack pointer
start_addr_spinitial stack pointer address
reloc_offrelocation offset
new_gdpointer to relocated global data
dm_rootroot instance for Driver Model
dm_root_fpre-relocation root instance
uclass_root_shead 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_rootpointer 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_rtDynamic info about the driver
dm_udevice_rtDynamic info about the udevice
dm_priv_baseBase address of the priv/plat region used when udevices and uclasses are in read-only memory. This is NULL if not used
timertimer instance for Driver Model
fdt_blobU-Boot’s own device tree, NULL if none
new_fdtrelocated device tree
fdt_sizespace reserved for relocated device space
fdt_srcSource of FDT
of_rootroot node of the live tree
multi_dtb_fitpointer to uncompressed multi-dtb FIT image
jtjump table
The jump table contains pointers to exported functions. A pointer to the jump table is passed to standalone applications.
env_bufbuffer for env_get() before reloc
trace_bufftrace buffer
When tracing function in U-Boot this field points to the buffer recording the function calls.
cur_i2c_buscurrently used I2C bus
timebase_hhigh 32 bits of timer
timebase_llow 32 bits of timer
malloc_startstart of malloc() region
malloc_basebase address of early malloc()
malloc_limitlimit address of early malloc()
malloc_ptrcurrent address of early malloc()
hosePCI hose for early use
pci_ram_toptop of region accessible to PCI
pcidelay_donedelay 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_devcurrent serial device
archarchitecture-specific data
console_outoutput buffer for console recording
This buffer is used to collect output during console recording.
console_ininput buffer for console recording
If console recording is activated, this buffer can be used to emulate input.
video_toptop of video frame buffer area
video_bottombottom of video frame buffer area
bootstageboot stage information
new_bootstagerelocated boot stage information
log_drop_countnumber 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_READYin flags.default_log_leveldefault logging level
For logging devices without filters default_log_level defines the logging level, cf.
enum log_level_t.log_headlist of logging devices
log_fmtbit mask for logging format
The log_fmt bit mask selects the fields to be shown in log messages.
enum log_fmtdefines the bits of the bit mask.processing_msga log message is being processed
This flag is used to suppress the creation of additional messages while another message is being processed.
logc_prevlogging category of previous message
This value is used as logging category for continuation messages.
logl_prevlogging level of the previous message
This value is used as logging level for continuation messages.
log_contPrevious log line did not finished wtih n
This allows for chained log messages on the same line
bloblistblob list information
new_bloblistrelocated blob list information
spl_handoffSPL hand-off information
translation_offsetoptional translation offset
See CONFIG_TRANSLATION_OFFSET.
acpi_ctxACPI context pointer
acpi_startStart address of ACPI tables
smbios_versionPoints to SMBIOS type 0 version
event_statePoints to the current state of events
cyclic_listlist of registered cyclic functions
dmtag_listList 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_RELOCcode was relocated to RAM
GD_FLG_DEVINITdevices have been initialized
GD_FLG_SILENTsilent mode
GD_FLG_POSTFAILcritical POST test failed
GD_FLG_POSTSTOPPOST sequence aborted
GD_FLG_LOGINITlog Buffer has been initialized
GD_FLG_DISABLE_CONSOLEdisable console (in & out)
GD_FLG_ENV_READYenvironment imported into hash table
GD_FLG_SERIAL_READYpre-relocation serial console ready
GD_FLG_FULL_MALLOC_INITfull malloc() is ready
GD_FLG_SPL_INITspl_init() has been called
GD_FLG_SKIP_RELOCdon’t relocate
GD_FLG_RECORDrecord console
GD_FLG_RECORD_OVFrecord console overflow
GD_FLG_ENV_DEFAULTdefault variable flag
GD_FLG_SPL_EARLY_INITearly SPL initialization is done
GD_FLG_LOG_READYlog system is ready for use
GD_FLG_CYCLIC_RUNNINGcyclic_run is in progress
GD_FLG_SKIP_LL_INITdon’t perform low-level initialization
GD_FLG_SMP_READYSMP initialization is complete
GD_FLG_FDT_CHANGEDDevice tree change has been detected by tests
GD_FLG_OF_TAG_MIGRATEDevice tree has old u-boot,dm- tags
GD_FLG_DM_DEADDriver model is not accessible. This can be set when the memory used to holds its tables has been mapped out.
GD_FLG_BLOBLIST_READYbloblist is ready for use
GD_FLG_HUSH_OLD_PARSERUse hush old parser.
GD_FLG_HUSH_MODERN_PARSERUse hush 2021 parser.
Description
See field flags of struct global_data.