blob: d6c15e2c406397ef224e0abced34ccb04c16de3b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass0e724032012-12-13 20:49:12 +00002/*
3 * Copyright (c) 2012 The Chromium OS Authors.
4 * (C) Copyright 2002-2010
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Simon Glass0e724032012-12-13 20:49:12 +00006 */
7
8#ifndef __ASM_GENERIC_GBL_DATA_H
9#define __ASM_GENERIC_GBL_DATA_H
10/*
11 * The following data structure is placed in some memory which is
12 * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
13 * some locked parts of the data cache) to allow for a minimum set of
14 * global variables during system initialization (until we have set
15 * up the memory controller so that we can use RAM).
16 *
17 * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
18 *
19 * Each architecture has its own private fields. For now all are private
20 */
21
22#ifndef __ASSEMBLY__
Simon Glass7f67b372024-08-21 10:19:09 -060023#include <board_f.h>
Stefan Roese036f89a2022-09-02 13:57:48 +020024#include <cyclic.h>
Simon Glassaa4bce92022-03-04 08:43:00 -070025#include <event_internal.h>
Stefan Roese85bddff2019-04-12 16:42:28 +020026#include <fdtdec.h>
Simon Glass1bb49232015-11-08 23:47:48 -070027#include <membuff.h>
Simon Glassdd6ab882014-02-26 15:59:18 -070028#include <linux/list.h>
Rasmus Villemoesb8cfd9e2021-05-18 11:19:47 +020029#include <linux/build_bug.h>
30#include <asm-offsets.h>
Simon Glassdd6ab882014-02-26 15:59:18 -070031
Simon Glassde0115a2020-11-04 09:57:19 -070032struct acpi_ctx;
Simon Glasscfd6a002020-10-03 11:31:33 -060033struct driver_rt;
Simon Glass3a028c22024-08-07 16:47:30 -060034struct upl;
Simon Glasscfd6a002020-10-03 11:31:33 -060035
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020036typedef struct global_data gd_t;
37
38/**
39 * struct global_data - global data structure
40 */
41struct global_data {
42 /**
43 * @bd: board information
44 */
Masahiro Yamadad788bba2020-02-25 02:22:27 +090045 struct bd_info *bd;
Simon Glass68524672024-08-21 10:19:23 -060046 /**
47 * @new_gd: pointer to relocated global data
48 */
49 struct global_data *new_gd;
50 /**
51 * @fdt_blob: U-Boot's own device tree, NULL if none
52 */
53 const void *fdt_blob;
54 /**
Simon Glass8a0417f2024-08-21 10:19:24 -060055 * @cur_serial_dev: current serial device
56 */
57 struct udevice *cur_serial_dev;
58#ifndef CONFIG_SPL_BUILD
59 /**
Simon Glass68524672024-08-21 10:19:23 -060060 * @jt: jump table
61 *
62 * The jump table contains pointers to exported functions. A pointer to
63 * the jump table is passed to standalone applications.
64 */
65 struct jt_funcs *jt;
66 /**
Simon Glass7f67b372024-08-21 10:19:09 -060067 * @boardf: information only used before relocation
68 */
69 struct board_f *boardf;
70#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020071 /**
Simon Glass04b480a2024-08-21 10:19:21 -060072 * @ram_size: RAM size in bytes
73 */
74 phys_size_t ram_size;
75 /**
76 * @ram_top: top address of RAM used by U-Boot
77 */
78 phys_addr_t ram_top;
79 /**
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020080 * @flags: global data flags
81 *
82 * See &enum gd_flags
83 */
Simon Glass0e724032012-12-13 20:49:12 +000084 unsigned long flags;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020085 /**
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020086 * @cpu_clk: CPU clock rate in Hz
87 */
88 unsigned long cpu_clk;
Simon Glassee8e6a62024-08-21 10:19:25 -060089#if CONFIG_IS_ENABLED(ENV_SUPPORT)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020090 /**
Simon Glassfe616842024-08-21 10:19:20 -060091 * @env_addr: address of environment structure
92 *
93 * @env_addr contains the address of the structure holding the
94 * environment variables.
95 */
96 unsigned long env_addr;
Simon Glassee8e6a62024-08-21 10:19:25 -060097#endif /* ENV_SUPPORT */
Simon Glassfe616842024-08-21 10:19:20 -060098 /**
Simon Glassdbd8eb22024-08-21 10:19:22 -060099 * @ram_base: base address of RAM used by U-Boot
100 */
101 unsigned long ram_base;
102 /**
103 * @relocaddr: start address of U-Boot in RAM
104 *
105 * After relocation this field indicates the address to which U-Boot
106 * has been relocated. It can be displayed using the bdinfo command.
107 * Its value is needed to display the source code when debugging with
108 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
109 */
110 unsigned long relocaddr;
111 /**
112 * @irq_sp: IRQ stack pointer
113 */
114 unsigned long irq_sp;
115 /**
116 * @start_addr_sp: initial stack pointer address
117 */
118 unsigned long start_addr_sp;
119 /**
120 * @reloc_off: relocation offset
121 */
122 unsigned long reloc_off;
123 /**
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200124 * @bus_clk: platform clock rate in Hz
125 */
Simon Glassf782d542024-08-21 10:19:15 -0600126 unsigned int bus_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200127 /**
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200128 * @mem_clk: memory clock rate in Hz
129 */
Simon Glassf782d542024-08-21 10:19:15 -0600130 unsigned int mem_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200131 /**
Simon Glass0b6675d2024-08-21 10:19:16 -0600132 * @mon_len: monitor length in bytes
133 */
134 unsigned int mon_len;
135 /**
Simon Glassdf71aab2024-08-21 10:19:19 -0600136 * @baudrate: baud rate of the serial interface
137 */
138 unsigned int baudrate;
Simon Glassee8e6a62024-08-21 10:19:25 -0600139#if CONFIG_IS_ENABLED(ENV_SUPPORT)
Simon Glassdf71aab2024-08-21 10:19:19 -0600140 /**
Simon Glassc726f282024-08-21 10:19:08 -0600141 * @env_has_init: bit mask indicating environment locations
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200142 *
Simon Glassc726f282024-08-21 10:19:08 -0600143 * &enum env_location defines which bit relates to which location
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200144 */
Simon Glassc726f282024-08-21 10:19:08 -0600145 unsigned short env_has_init;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200146 /**
Simon Glassc726f282024-08-21 10:19:08 -0600147 * @env_valid: environment is valid
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200148 *
Simon Glassc726f282024-08-21 10:19:08 -0600149 * See &enum env_valid
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200150 */
Simon Glassc726f282024-08-21 10:19:08 -0600151 unsigned char env_valid;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200152 /**
153 * @env_load_prio: priority of the loaded environment
154 */
Simon Glassc726f282024-08-21 10:19:08 -0600155 char env_load_prio;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200156 /**
Simon Glassa9ffc542024-08-21 10:19:14 -0600157 * @env_buf: buffer for env_get() before reloc
158 */
159 char env_buf[32];
Simon Glassee8e6a62024-08-21 10:19:25 -0600160#endif /* ENV_SUPPORT */
161 /**
162 * @fdt_src: Source of FDT
163 */
164 enum fdt_source_t fdt_src;
Simon Glassa9ffc542024-08-21 10:19:14 -0600165 /**
Simon Glassa9ffc542024-08-21 10:19:14 -0600166 * @arch: architecture-specific data
167 */
168 struct arch_global_data arch;
169 /**
170 * @dmtag_list: List of DM tags
171 */
172 struct list_head dmtag_list;
173 /**
174 * @timebase_h: high 32 bits of timer
175 */
176 unsigned int timebase_h;
177 /**
178 * @timebase_l: low 32 bits of timer
179 */
180 unsigned int timebase_l;
181#if defined(CONFIG_POST)
182 /**
183 * @post_log_word: active POST tests
184 *
185 * @post_log_word is a bit mask defining which POST tests are recorded
186 * (see constants POST_*).
187 */
188 unsigned long post_log_word;
189 /**
190 * @post_log_res: POST results
191 *
192 * @post_log_res is a bit mask with the POST results. A bit with value 1
193 * indicates successful execution.
194 */
195 unsigned long post_log_res;
196 /**
197 * @post_init_f_time: time in ms when post_init_f() started
198 */
199 unsigned long post_init_f_time;
200#endif
201#ifdef CONFIG_BOARD_TYPES
202 /**
203 * @board_type: board type
204 *
205 * If a U-Boot configuration supports multiple board types, the actual
206 * board type may be stored in this field.
207 */
208 unsigned long board_type;
209#endif
210#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
211 /**
212 * @precon_buf_idx: pre-console buffer index
213 *
214 * @precon_buf_idx indicates the current position of the
215 * buffer used to collect output before the console becomes
216 * available. When negative, the pre-console buffer is
217 * temporarily disabled (used when the pre-console buffer is
218 * being written out, to prevent adding its contents to
219 * itself).
220 */
221 long precon_buf_idx;
222#endif
Simon Glassdd6ab882014-02-26 15:59:18 -0700223#ifdef CONFIG_DM
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200224 /**
225 * @dm_root: root instance for Driver Model
226 */
227 struct udevice *dm_root;
228 /**
Heinrich Schuchardt18000fe2021-01-24 21:48:00 +0100229 * @uclass_root_s:
230 * head of core tree when uclasses are not in read-only memory.
231 *
232 * When uclasses are in read-only memory, @uclass_root_s is not used and
233 * @uclass_root points to the root node generated by dtoc.
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200234 */
Simon Glass784cd9e2020-12-19 10:40:17 -0700235 struct list_head uclass_root_s;
236 /**
Heinrich Schuchardt18000fe2021-01-24 21:48:00 +0100237 * @uclass_root:
238 * pointer to head of core tree, if uclasses are in read-only memory and
239 * cannot be adjusted to use @uclass_root as a list head.
240 *
241 * When not in read-only memory, @uclass_root_s is used to hold the
242 * uclass root, and @uclass_root points to the address of
243 * @uclass_root_s.
Simon Glass784cd9e2020-12-19 10:40:17 -0700244 */
245 struct list_head *uclass_root;
Simon Glass8beeb282021-03-15 17:25:36 +1300246# if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
Simon Glass9286eb92020-11-29 17:07:05 -0700247 /** @dm_driver_rt: Dynamic info about the driver */
Simon Glasscfd6a002020-10-03 11:31:33 -0600248 struct driver_rt *dm_driver_rt;
249# endif
Simon Glass8beeb282021-03-15 17:25:36 +1300250#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
251 /** @dm_udevice_rt: Dynamic info about the udevice */
252 struct udevice_rt *dm_udevice_rt;
Simon Glass8dee67a2021-03-15 17:25:38 +1300253 /**
254 * @dm_priv_base: Base address of the priv/plat region used when
255 * udevices and uclasses are in read-only memory. This is NULL if not
256 * used
257 */
258 void *dm_priv_base;
Simon Glass8beeb282021-03-15 17:25:36 +1300259# endif
Simon Glassdd6ab882014-02-26 15:59:18 -0700260#endif
Thomas Choufb798b12015-10-09 13:46:34 +0800261#ifdef CONFIG_TIMER
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200262 /**
263 * @timer: timer instance for Driver Model
264 */
265 struct udevice *timer;
Thomas Choufb798b12015-10-09 13:46:34 +0800266#endif
Simon Glass40916e62020-10-03 09:25:22 -0600267#if CONFIG_IS_ENABLED(OF_LIVE)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200268 /**
269 * @of_root: root node of the live tree
270 */
Simon Glassa6eedb82017-05-18 20:08:53 -0600271 struct device_node *of_root;
272#endif
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100273#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200274 /**
275 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
276 */
277 const void *multi_dtb_fit;
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100278#endif
Simon Glass209a1a62013-06-11 11:14:42 -0700279#ifdef CONFIG_TRACE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200280 /**
281 * @trace_buff: trace buffer
282 *
283 * When tracing function in U-Boot this field points to the buffer
284 * recording the function calls.
285 */
286 void *trace_buff;
Simon Glass209a1a62013-06-11 11:14:42 -0700287#endif
Tom Rini52b2e262021-08-18 23:12:24 -0400288#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200289 /**
290 * @cur_i2c_bus: currently used I2C bus
291 */
292 int cur_i2c_bus;
Heiko Schochere7d9c4f2012-01-16 21:12:23 +0000293#endif
Simon Glassa9ffc542024-08-21 10:19:14 -0600294#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
Simon Glass345c9742023-07-15 21:38:53 -0600295 /**
296 * @malloc_start: start of malloc() region
297 */
Simon Glass345c9742023-07-15 21:38:53 -0600298 unsigned long malloc_start;
299#endif
Simon Glassadad2d02023-09-26 08:14:27 -0600300#if CONFIG_IS_ENABLED(SYS_MALLOC_F)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200301 /**
302 * @malloc_base: base address of early malloc()
303 */
304 unsigned long malloc_base;
305 /**
Simon Glass91bbb3b2024-08-23 14:27:04 -0600306 * @malloc_limit: maximum size of early malloc()
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200307 */
Simon Glass91bbb3b2024-08-23 14:27:04 -0600308 unsigned int malloc_limit;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200309 /**
Simon Glass91bbb3b2024-08-23 14:27:04 -0600310 * @malloc_ptr: currently used bytes of early malloc()
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200311 */
Simon Glass91bbb3b2024-08-23 14:27:04 -0600312 unsigned int malloc_ptr;
Simon Glass863e4042014-07-10 22:23:28 -0600313#endif
Simon Glass1bb49232015-11-08 23:47:48 -0700314#ifdef CONFIG_CONSOLE_RECORD
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200315 /**
316 * @console_out: output buffer for console recording
317 *
318 * This buffer is used to collect output during console recording.
319 */
320 struct membuff console_out;
321 /**
322 * @console_in: input buffer for console recording
323 *
324 * If console recording is activated, this buffer can be used to
325 * emulate input.
326 */
327 struct membuff console_in;
Simon Glass1bb49232015-11-08 23:47:48 -0700328#endif
Nikhil M Jain7f561e12023-04-20 17:41:10 +0530329#if CONFIG_IS_ENABLED(VIDEO)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200330 /**
331 * @video_top: top of video frame buffer area
332 */
333 ulong video_top;
334 /**
335 * @video_bottom: bottom of video frame buffer area
336 */
337 ulong video_bottom;
Simon Glassfce58f52016-01-18 19:52:21 -0700338#endif
Simon Glass88200332017-05-22 05:05:25 -0600339#ifdef CONFIG_BOOTSTAGE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200340 /**
341 * @bootstage: boot stage information
342 */
343 struct bootstage_data *bootstage;
Simon Glass88200332017-05-22 05:05:25 -0600344#endif
Simon Glassd95645d2017-12-04 13:48:24 -0700345#ifdef CONFIG_LOG
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200346 /**
Simon Glass9113dd32024-08-21 10:19:17 -0600347 * @log_head: list of logging devices
348 */
349 struct list_head log_head;
350 /**
351 * @log_fmt: bit mask for logging format
352 *
353 * The @log_fmt bit mask selects the fields to be shown in log messages.
354 * &enum log_fmt defines the bits of the bit mask.
355 */
356 /**
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200357 * @log_drop_count: number of dropped log messages
358 *
359 * This counter is incremented for each log message which can not
360 * be processed because logging is not yet available as signaled by
361 * flag %GD_FLG_LOG_READY in @flags.
362 */
363 int log_drop_count;
364 /**
365 * @default_log_level: default logging level
366 *
367 * For logging devices without filters @default_log_level defines the
368 * logging level, cf. &enum log_level_t.
369 */
Simon Glass9113dd32024-08-21 10:19:17 -0600370 char default_log_level;
371 char log_fmt;
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200372 /**
373 * @logc_prev: logging category of previous message
374 *
375 * This value is used as logging category for continuation messages.
376 */
Simon Glass9113dd32024-08-21 10:19:17 -0600377 unsigned char logc_prev;
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200378 /**
Heinrich Schuchardt14e77222020-10-30 18:50:31 +0100379 * @logl_prev: logging level of the previous message
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200380 *
381 * This value is used as logging level for continuation messages.
382 */
Simon Glass9113dd32024-08-21 10:19:17 -0600383 unsigned char logl_prev;
Simon Glass5fc47e32021-01-20 20:10:53 -0700384 /**
385 * @log_cont: Previous log line did not finished wtih \n
386 *
387 * This allows for chained log messages on the same line
388 */
389 bool log_cont;
Simon Glass9113dd32024-08-21 10:19:17 -0600390 /**
391 * @processing_msg: a log message is being processed
392 *
393 * This flag is used to suppress the creation of additional messages
394 * while another message is being processed.
395 */
396 bool processing_msg;
Simon Glassd95645d2017-12-04 13:48:24 -0700397#endif
Simon Glassa815dab2018-11-15 18:43:52 -0700398#if CONFIG_IS_ENABLED(BLOBLIST)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200399 /**
400 * @bloblist: blob list information
401 */
402 struct bloblist_hdr *bloblist;
Ovidiu Panaitc1b30d52020-11-28 10:43:20 +0200403#endif
Stefan Roese85bddff2019-04-12 16:42:28 +0200404#if defined(CONFIG_TRANSLATION_OFFSET)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200405 /**
406 * @translation_offset: optional translation offset
407 *
408 * See CONFIG_TRANSLATION_OFFSET.
409 */
410 fdt_addr_t translation_offset;
Stefan Roese85bddff2019-04-12 16:42:28 +0200411#endif
Simon Glasscf1f4bb2023-05-04 16:54:59 -0600412#ifdef CONFIG_ACPI
Simon Glassde0115a2020-11-04 09:57:19 -0700413 /**
414 * @acpi_ctx: ACPI context pointer
415 */
416 struct acpi_ctx *acpi_ctx;
Simon Glassb33f2f92021-12-01 09:02:37 -0700417 /**
418 * @acpi_start: Start address of ACPI tables
419 */
420 ulong acpi_start;
Simon Glassde0115a2020-11-04 09:57:19 -0700421#endif
Simon Glassa05eb042021-02-04 21:17:20 -0700422#if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
423 /**
424 * @smbios_version: Points to SMBIOS type 0 version
425 */
426 char *smbios_version;
427#endif
Simon Glassaa4bce92022-03-04 08:43:00 -0700428#if CONFIG_IS_ENABLED(EVENT)
429 /**
430 * @event_state: Points to the current state of events
431 */
432 struct event_state event_state;
433#endif
Simon Glass0b385222024-07-31 08:44:08 -0600434#if CONFIG_IS_ENABLED(CYCLIC)
Stefan Roese036f89a2022-09-02 13:57:48 +0200435 /**
Rasmus Villemoesc794e492022-10-28 13:50:54 +0200436 * @cyclic_list: list of registered cyclic functions
Stefan Roese036f89a2022-09-02 13:57:48 +0200437 */
Rasmus Villemoesc794e492022-10-28 13:50:54 +0200438 struct hlist_head cyclic_list;
Stefan Roese036f89a2022-09-02 13:57:48 +0200439#endif
Simon Glass3a028c22024-08-07 16:47:30 -0600440#if CONFIG_IS_ENABLED(UPL)
441 /**
442 * @upl: Universal Payload-handoff information
443 */
444 struct upl *upl;
445#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200446};
Rasmus Villemoesb8cfd9e2021-05-18 11:19:47 +0200447#ifndef DO_DEPS_ONLY
448static_assert(sizeof(struct global_data) == GD_SIZE);
449#endif
Simon Glass0e724032012-12-13 20:49:12 +0000450
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200451/**
452 * gd_board_type() - retrieve board type
453 *
454 * Return: global board type
455 */
Simon Glassb4de3f32017-03-31 08:40:24 -0600456#ifdef CONFIG_BOARD_TYPES
457#define gd_board_type() gd->board_type
458#else
459#define gd_board_type() 0
460#endif
461
Simon Glass40916e62020-10-03 09:25:22 -0600462/* These macros help avoid #ifdefs in the code */
463#if CONFIG_IS_ENABLED(OF_LIVE)
464#define gd_of_root() gd->of_root
465#define gd_of_root_ptr() &gd->of_root
466#define gd_set_of_root(_root) gd->of_root = (_root)
467#else
468#define gd_of_root() NULL
469#define gd_of_root_ptr() NULL
470#define gd_set_of_root(_root)
471#endif
472
Simon Glass8beeb282021-03-15 17:25:36 +1300473#if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
Simon Glasscfd6a002020-10-03 11:31:33 -0600474#define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
475#define gd_dm_driver_rt() gd->dm_driver_rt
476#else
477#define gd_set_dm_driver_rt(dyn)
478#define gd_dm_driver_rt() NULL
479#endif
480
Simon Glass8beeb282021-03-15 17:25:36 +1300481#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
482#define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
483#define gd_dm_udevice_rt() gd->dm_udevice_rt
Simon Glass8dee67a2021-03-15 17:25:38 +1300484#define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
485#define gd_dm_priv_base() gd->dm_priv_base
Simon Glass8beeb282021-03-15 17:25:36 +1300486#else
487#define gd_set_dm_udevice_rt(dyn)
488#define gd_dm_udevice_rt() NULL
Simon Glass8dee67a2021-03-15 17:25:38 +1300489#define gd_set_dm_priv_base(dyn)
490#define gd_dm_priv_base() NULL
Simon Glass8beeb282021-03-15 17:25:36 +1300491#endif
492
Simon Glasscf1f4bb2023-05-04 16:54:59 -0600493#ifdef CONFIG_ACPI
Simon Glassde0115a2020-11-04 09:57:19 -0700494#define gd_acpi_ctx() gd->acpi_ctx
Simon Glassb33f2f92021-12-01 09:02:37 -0700495#define gd_acpi_start() gd->acpi_start
496#define gd_set_acpi_start(addr) gd->acpi_start = addr
Simon Glassde0115a2020-11-04 09:57:19 -0700497#else
498#define gd_acpi_ctx() NULL
Simon Glassb33f2f92021-12-01 09:02:37 -0700499#define gd_acpi_start() 0UL
500#define gd_set_acpi_start(addr)
Simon Glassde0115a2020-11-04 09:57:19 -0700501#endif
502
Simon Glass9b388102023-09-19 21:00:15 -0600503#ifdef CONFIG_SMBIOS
Simon Glass42b7da52023-12-31 08:25:48 -0700504#define gd_smbios_start() gd->arch.smbios_start
Simon Glass9b388102023-09-19 21:00:15 -0600505#define gd_set_smbios_start(addr) gd->arch.smbios_start = addr
506#else
507#define gd_smbios_start() 0UL
508#define gd_set_smbios_start(addr)
509#endif
510
Simon Glass69daf5a2021-12-16 20:59:25 -0700511#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
512#define gd_multi_dtb_fit() gd->multi_dtb_fit
513#define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
514#else
515#define gd_multi_dtb_fit() NULL
516#define gd_set_multi_dtb_fit(_dtb)
517#endif
518
Simon Glassaa4bce92022-03-04 08:43:00 -0700519#if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
520#define gd_event_state() ((struct event_state *)&gd->event_state)
521#else
522#define gd_event_state() NULL
523#endif
524
Simon Glass345c9742023-07-15 21:38:53 -0600525#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
526#define gd_malloc_start() gd->malloc_start
527#define gd_set_malloc_start(_val) gd->malloc_start = (_val)
528#else
529#define gd_malloc_start() 0
530#define gd_set_malloc_start(val)
531#endif
Troy Kiskye143c272023-03-13 14:31:43 -0700532
Simon Glasse8804d72023-09-26 08:14:31 -0600533#if CONFIG_VAL(SYS_MALLOC_F_LEN)
534#define gd_malloc_ptr() gd->malloc_ptr
535#else
536#define gd_malloc_ptr() 0L
537#endif
538
Simon Glass3a028c22024-08-07 16:47:30 -0600539#if CONFIG_IS_ENABLED(UPL)
540#define gd_upl() gd->upl
541#define gd_set_upl(_val) gd->upl = (_val)
542#else
543#define gd_upl() NULL
544#define gd_set_upl(val)
545#endif
546
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200547/**
548 * enum gd_flags - global data flags
549 *
550 * See field flags of &struct global_data.
Simon Glass0e724032012-12-13 20:49:12 +0000551 */
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200552enum gd_flags {
553 /**
554 * @GD_FLG_RELOC: code was relocated to RAM
555 */
556 GD_FLG_RELOC = 0x00001,
557 /**
558 * @GD_FLG_DEVINIT: devices have been initialized
559 */
560 GD_FLG_DEVINIT = 0x00002,
561 /**
562 * @GD_FLG_SILENT: silent mode
563 */
564 GD_FLG_SILENT = 0x00004,
565 /**
566 * @GD_FLG_POSTFAIL: critical POST test failed
567 */
568 GD_FLG_POSTFAIL = 0x00008,
569 /**
570 * @GD_FLG_POSTSTOP: POST sequence aborted
571 */
572 GD_FLG_POSTSTOP = 0x00010,
573 /**
574 * @GD_FLG_LOGINIT: log Buffer has been initialized
575 */
576 GD_FLG_LOGINIT = 0x00020,
577 /**
578 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
579 */
580 GD_FLG_DISABLE_CONSOLE = 0x00040,
581 /**
582 * @GD_FLG_ENV_READY: environment imported into hash table
583 */
584 GD_FLG_ENV_READY = 0x00080,
585 /**
586 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
587 */
588 GD_FLG_SERIAL_READY = 0x00100,
589 /**
590 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
591 */
592 GD_FLG_FULL_MALLOC_INIT = 0x00200,
593 /**
594 * @GD_FLG_SPL_INIT: spl_init() has been called
595 */
596 GD_FLG_SPL_INIT = 0x00400,
597 /**
598 * @GD_FLG_SKIP_RELOC: don't relocate
599 */
600 GD_FLG_SKIP_RELOC = 0x00800,
601 /**
602 * @GD_FLG_RECORD: record console
603 */
604 GD_FLG_RECORD = 0x01000,
605 /**
Simon Glassd6ed4af2021-05-08 06:59:56 -0600606 * @GD_FLG_RECORD_OVF: record console overflow
607 */
608 GD_FLG_RECORD_OVF = 0x02000,
609 /**
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200610 * @GD_FLG_ENV_DEFAULT: default variable flag
611 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600612 GD_FLG_ENV_DEFAULT = 0x04000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200613 /**
614 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
615 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600616 GD_FLG_SPL_EARLY_INIT = 0x08000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200617 /**
618 * @GD_FLG_LOG_READY: log system is ready for use
619 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600620 GD_FLG_LOG_READY = 0x10000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200621 /**
Stefan Roese5128a872022-11-17 09:20:34 +0100622 * @GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200623 */
Stefan Roese5128a872022-11-17 09:20:34 +0100624 GD_FLG_CYCLIC_RUNNING = 0x20000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200625 /**
626 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
627 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600628 GD_FLG_SKIP_LL_INIT = 0x40000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200629 /**
630 * @GD_FLG_SMP_READY: SMP initialization is complete
631 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600632 GD_FLG_SMP_READY = 0x80000,
Simon Glass60f08992022-09-06 20:27:06 -0600633 /**
634 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
635 */
636 GD_FLG_FDT_CHANGED = 0x100000,
Simon Glassc2727e52023-02-13 08:56:32 -0700637 /**
638 * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
639 */
640 GD_FLG_OF_TAG_MIGRATE = 0x200000,
Simon Glass31ef8342023-09-07 09:58:13 -0600641 /**
642 * @GD_FLG_DM_DEAD: Driver model is not accessible. This can be set when
643 * the memory used to holds its tables has been mapped out.
644 */
645 GD_FLG_DM_DEAD = 0x400000,
Simon Glassa28f39c2023-09-26 08:14:51 -0600646 /**
647 * @GD_FLG_BLOBLIST_READY: bloblist is ready for use
648 */
649 GD_FLG_BLOBLIST_READY = 0x800000,
Francis Laniel1239d232023-12-22 22:02:30 +0100650 /**
651 * @GD_FLG_HUSH_OLD_PARSER: Use hush old parser.
652 */
653 GD_FLG_HUSH_OLD_PARSER = 0x1000000,
Francis Laniel3b66e572023-12-22 22:02:32 +0100654 /**
655 * @GD_FLG_HUSH_MODERN_PARSER: Use hush 2021 parser.
656 */
657 GD_FLG_HUSH_MODERN_PARSER = 0x2000000,
Simon Glass9b5bfba2024-08-07 16:47:33 -0600658 /**
659 * @GD_FLG_UPL: Read/write a Universal Payload (UPL) handoff
660 */
661 GD_FLG_UPL = 0x4000000,
Simon Glassd4b0fdb2024-08-21 10:19:04 -0600662 /**
663 * @GD_FLG_HAVE_CONSOLE: serial_init() was called and a console
664 * is available. When not set, indicates that console input and output
665 * drivers shall not be called.
666 */
667 GD_FLG_HAVE_CONSOLE = 0x8000000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200668};
669
670#endif /* __ASSEMBLY__ */
Simon Glass0e724032012-12-13 20:49:12 +0000671
672#endif /* __ASM_GENERIC_GBL_DATA_H */