blob: 79d2aa4c6f5a91a4f50e13a380f2fc5d2fc2c8e4 [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__
Stefan Roese036f89a2022-09-02 13:57:48 +020023#include <cyclic.h>
Simon Glassaa4bce92022-03-04 08:43:00 -070024#include <event_internal.h>
Stefan Roese85bddff2019-04-12 16:42:28 +020025#include <fdtdec.h>
Simon Glass1bb49232015-11-08 23:47:48 -070026#include <membuff.h>
Simon Glassdd6ab882014-02-26 15:59:18 -070027#include <linux/list.h>
Rasmus Villemoesb8cfd9e2021-05-18 11:19:47 +020028#include <linux/build_bug.h>
29#include <asm-offsets.h>
Simon Glassdd6ab882014-02-26 15:59:18 -070030
Simon Glassde0115a2020-11-04 09:57:19 -070031struct acpi_ctx;
Simon Glasscfd6a002020-10-03 11:31:33 -060032struct driver_rt;
Simon Glass3a028c22024-08-07 16:47:30 -060033struct upl;
Simon Glasscfd6a002020-10-03 11:31:33 -060034
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020035typedef struct global_data gd_t;
36
37/**
38 * struct global_data - global data structure
39 */
40struct global_data {
41 /**
42 * @bd: board information
43 */
Masahiro Yamadad788bba2020-02-25 02:22:27 +090044 struct bd_info *bd;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020045 /**
46 * @flags: global data flags
47 *
48 * See &enum gd_flags
49 */
Simon Glass0e724032012-12-13 20:49:12 +000050 unsigned long flags;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020051 /**
52 * @baudrate: baud rate of the serial interface
53 */
Simon Glass059c54f2013-03-05 14:40:05 +000054 unsigned int baudrate;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020055 /**
56 * @cpu_clk: CPU clock rate in Hz
57 */
58 unsigned long cpu_clk;
59 /**
60 * @bus_clk: platform clock rate in Hz
61 */
Simon Glass0e724032012-12-13 20:49:12 +000062 unsigned long bus_clk;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020063 /**
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020064 * @mem_clk: memory clock rate in Hz
65 */
Simon Glass0e724032012-12-13 20:49:12 +000066 unsigned long mem_clk;
Nikhil M Jain7f561e12023-04-20 17:41:10 +053067#if CONFIG_IS_ENABLED(VIDEO)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020068 /**
69 * @fb_base: base address of frame buffer memory
70 */
71 unsigned long fb_base;
Simon Glass0e724032012-12-13 20:49:12 +000072#endif
Simon Glass49badb92017-12-04 13:48:23 -070073#if defined(CONFIG_POST)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020074 /**
75 * @post_log_word: active POST tests
76 *
77 * @post_log_word is a bit mask defining which POST tests are recorded
78 * (see constants POST_*).
79 */
80 unsigned long post_log_word;
81 /**
82 * @post_log_res: POST results
83 *
84 * @post_log_res is a bit mask with the POST results. A bit with value 1
85 * indicates successful execution.
86 */
87 unsigned long post_log_res;
88 /**
89 * @post_init_f_time: time in ms when post_init_f() started
90 */
91 unsigned long post_init_f_time;
Simon Glass0e724032012-12-13 20:49:12 +000092#endif
93#ifdef CONFIG_BOARD_TYPES
Heinrich Schuchardt50d92862020-10-05 08:30:09 +020094 /**
95 * @board_type: board type
96 *
97 * If a U-Boot configuration supports multiple board types, the actual
98 * board type may be stored in this field.
99 */
Simon Glass0e724032012-12-13 20:49:12 +0000100 unsigned long board_type;
101#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200102 /**
103 * @have_console: console is available
104 *
105 * A value of 1 indicates that serial_init() was called and a console
106 * is available.
107 * A value of 0 indicates that console input and output drivers shall
108 * not be called.
109 */
110 unsigned long have_console;
Simon Glasse304a5e2016-10-17 20:12:36 -0600111#if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200112 /**
113 * @precon_buf_idx: pre-console buffer index
114 *
Rasmus Villemoese406a612022-05-03 15:13:27 +0200115 * @precon_buf_idx indicates the current position of the
116 * buffer used to collect output before the console becomes
117 * available. When negative, the pre-console buffer is
118 * temporarily disabled (used when the pre-console buffer is
119 * being written out, to prevent adding its contents to
120 * itself).
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200121 */
Rasmus Villemoese406a612022-05-03 15:13:27 +0200122 long precon_buf_idx;
Simon Glass0e724032012-12-13 20:49:12 +0000123#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200124 /**
125 * @env_addr: address of environment structure
126 *
127 * @env_addr contains the address of the structure holding the
128 * environment variables.
129 */
130 unsigned long env_addr;
131 /**
132 * @env_valid: environment is valid
133 *
134 * See &enum env_valid
135 */
136 unsigned long env_valid;
137 /**
138 * @env_has_init: bit mask indicating environment locations
139 *
140 * &enum env_location defines which bit relates to which location
141 */
142 unsigned long env_has_init;
143 /**
144 * @env_load_prio: priority of the loaded environment
145 */
146 int env_load_prio;
147 /**
148 * @ram_base: base address of RAM used by U-Boot
149 */
150 unsigned long ram_base;
151 /**
152 * @ram_top: top address of RAM used by U-Boot
153 */
Bin Mengf936cf62021-01-31 20:35:59 +0800154 phys_addr_t ram_top;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200155 /**
156 * @relocaddr: start address of U-Boot in RAM
157 *
158 * After relocation this field indicates the address to which U-Boot
159 * has been relocated. It can be displayed using the bdinfo command.
160 * Its value is needed to display the source code when debugging with
161 * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
162 */
163 unsigned long relocaddr;
164 /**
165 * @ram_size: RAM size in bytes
166 */
167 phys_size_t ram_size;
168 /**
169 * @mon_len: monitor length in bytes
170 */
171 unsigned long mon_len;
172 /**
173 * @irq_sp: IRQ stack pointer
174 */
175 unsigned long irq_sp;
176 /**
177 * @start_addr_sp: initial stack pointer address
178 */
179 unsigned long start_addr_sp;
180 /**
181 * @reloc_off: relocation offset
182 */
Simon Glass0e724032012-12-13 20:49:12 +0000183 unsigned long reloc_off;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200184 /**
185 * @new_gd: pointer to relocated global data
186 */
187 struct global_data *new_gd;
Simon Glassdd6ab882014-02-26 15:59:18 -0700188
189#ifdef CONFIG_DM
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200190 /**
191 * @dm_root: root instance for Driver Model
192 */
193 struct udevice *dm_root;
194 /**
Heinrich Schuchardt18000fe2021-01-24 21:48:00 +0100195 * @uclass_root_s:
196 * head of core tree when uclasses are not in read-only memory.
197 *
198 * When uclasses are in read-only memory, @uclass_root_s is not used and
199 * @uclass_root points to the root node generated by dtoc.
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200200 */
Simon Glass784cd9e2020-12-19 10:40:17 -0700201 struct list_head uclass_root_s;
202 /**
Heinrich Schuchardt18000fe2021-01-24 21:48:00 +0100203 * @uclass_root:
204 * pointer to head of core tree, if uclasses are in read-only memory and
205 * cannot be adjusted to use @uclass_root as a list head.
206 *
207 * When not in read-only memory, @uclass_root_s is used to hold the
208 * uclass root, and @uclass_root points to the address of
209 * @uclass_root_s.
Simon Glass784cd9e2020-12-19 10:40:17 -0700210 */
211 struct list_head *uclass_root;
Simon Glass8beeb282021-03-15 17:25:36 +1300212# if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
Simon Glass9286eb92020-11-29 17:07:05 -0700213 /** @dm_driver_rt: Dynamic info about the driver */
Simon Glasscfd6a002020-10-03 11:31:33 -0600214 struct driver_rt *dm_driver_rt;
215# endif
Simon Glass8beeb282021-03-15 17:25:36 +1300216#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
217 /** @dm_udevice_rt: Dynamic info about the udevice */
218 struct udevice_rt *dm_udevice_rt;
Simon Glass8dee67a2021-03-15 17:25:38 +1300219 /**
220 * @dm_priv_base: Base address of the priv/plat region used when
221 * udevices and uclasses are in read-only memory. This is NULL if not
222 * used
223 */
224 void *dm_priv_base;
Simon Glass8beeb282021-03-15 17:25:36 +1300225# endif
Simon Glassdd6ab882014-02-26 15:59:18 -0700226#endif
Thomas Choufb798b12015-10-09 13:46:34 +0800227#ifdef CONFIG_TIMER
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200228 /**
229 * @timer: timer instance for Driver Model
230 */
231 struct udevice *timer;
Thomas Choufb798b12015-10-09 13:46:34 +0800232#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200233 /**
234 * @fdt_blob: U-Boot's own device tree, NULL if none
235 */
236 const void *fdt_blob;
237 /**
238 * @new_fdt: relocated device tree
239 */
240 void *new_fdt;
241 /**
242 * @fdt_size: space reserved for relocated device space
243 */
244 unsigned long fdt_size;
Simon Glassbed6bc72021-12-16 20:59:33 -0700245 /**
246 * @fdt_src: Source of FDT
247 */
248 enum fdt_source_t fdt_src;
Simon Glass40916e62020-10-03 09:25:22 -0600249#if CONFIG_IS_ENABLED(OF_LIVE)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200250 /**
251 * @of_root: root node of the live tree
252 */
Simon Glassa6eedb82017-05-18 20:08:53 -0600253 struct device_node *of_root;
254#endif
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100255
256#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200257 /**
258 * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
259 */
260 const void *multi_dtb_fit;
Jean-Jacques Hiblot7c530e32018-12-07 14:50:52 +0100261#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200262 /**
263 * @jt: jump table
264 *
265 * The jump table contains pointers to exported functions. A pointer to
266 * the jump table is passed to standalone applications.
267 */
268 struct jt_funcs *jt;
269 /**
270 * @env_buf: buffer for env_get() before reloc
271 */
272 char env_buf[32];
Simon Glass209a1a62013-06-11 11:14:42 -0700273#ifdef CONFIG_TRACE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200274 /**
275 * @trace_buff: trace buffer
276 *
277 * When tracing function in U-Boot this field points to the buffer
278 * recording the function calls.
279 */
280 void *trace_buff;
Simon Glass209a1a62013-06-11 11:14:42 -0700281#endif
Tom Rini52b2e262021-08-18 23:12:24 -0400282#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200283 /**
284 * @cur_i2c_bus: currently used I2C bus
285 */
286 int cur_i2c_bus;
Heiko Schochere7d9c4f2012-01-16 21:12:23 +0000287#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200288 /**
289 * @timebase_h: high 32 bits of timer
290 */
Peng Fan9a60a9e2017-05-09 10:32:03 +0800291 unsigned int timebase_h;
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200292 /**
293 * @timebase_l: low 32 bits of timer
294 */
Peng Fan9a60a9e2017-05-09 10:32:03 +0800295 unsigned int timebase_l;
Simon Glass345c9742023-07-15 21:38:53 -0600296 /**
297 * @malloc_start: start of malloc() region
298 */
299#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
300 unsigned long malloc_start;
301#endif
Simon Glassadad2d02023-09-26 08:14:27 -0600302#if CONFIG_IS_ENABLED(SYS_MALLOC_F)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200303 /**
304 * @malloc_base: base address of early malloc()
305 */
306 unsigned long malloc_base;
307 /**
308 * @malloc_limit: limit address of early malloc()
309 */
310 unsigned long malloc_limit;
311 /**
312 * @malloc_ptr: current address of early malloc()
313 */
314 unsigned long malloc_ptr;
Simon Glass863e4042014-07-10 22:23:28 -0600315#endif
Bin Mengf1b81fc2014-12-30 22:53:21 +0800316#ifdef CONFIG_PCI
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200317 /**
318 * @hose: PCI hose for early use
319 */
320 struct pci_controller *hose;
321 /**
322 * @pci_ram_top: top of region accessible to PCI
323 */
324 phys_addr_t pci_ram_top;
Bin Mengf1b81fc2014-12-30 22:53:21 +0800325#endif
326#ifdef CONFIG_PCI_BOOTDELAY
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200327 /**
328 * @pcidelay_done: delay time before scanning of PIC hose expired
329 *
330 * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
331 * milliseconds defined by environment variable pcidelay before
332 * scanning. Once this delay has expired the flag @pcidelay_done
333 * is set to 1.
334 */
Bin Mengf1b81fc2014-12-30 22:53:21 +0800335 int pcidelay_done;
336#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200337 /**
338 * @cur_serial_dev: current serial device
339 */
340 struct udevice *cur_serial_dev;
341 /**
342 * @arch: architecture-specific data
343 */
344 struct arch_global_data arch;
Simon Glass1bb49232015-11-08 23:47:48 -0700345#ifdef CONFIG_CONSOLE_RECORD
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200346 /**
347 * @console_out: output buffer for console recording
348 *
349 * This buffer is used to collect output during console recording.
350 */
351 struct membuff console_out;
352 /**
353 * @console_in: input buffer for console recording
354 *
355 * If console recording is activated, this buffer can be used to
356 * emulate input.
357 */
358 struct membuff console_in;
Simon Glass1bb49232015-11-08 23:47:48 -0700359#endif
Nikhil M Jain7f561e12023-04-20 17:41:10 +0530360#if CONFIG_IS_ENABLED(VIDEO)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200361 /**
362 * @video_top: top of video frame buffer area
363 */
364 ulong video_top;
365 /**
366 * @video_bottom: bottom of video frame buffer area
367 */
368 ulong video_bottom;
Simon Glassfce58f52016-01-18 19:52:21 -0700369#endif
Simon Glass88200332017-05-22 05:05:25 -0600370#ifdef CONFIG_BOOTSTAGE
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200371 /**
372 * @bootstage: boot stage information
373 */
374 struct bootstage_data *bootstage;
375 /**
376 * @new_bootstage: relocated boot stage information
377 */
378 struct bootstage_data *new_bootstage;
Simon Glass88200332017-05-22 05:05:25 -0600379#endif
Simon Glassd95645d2017-12-04 13:48:24 -0700380#ifdef CONFIG_LOG
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200381 /**
382 * @log_drop_count: number of dropped log messages
383 *
384 * This counter is incremented for each log message which can not
385 * be processed because logging is not yet available as signaled by
386 * flag %GD_FLG_LOG_READY in @flags.
387 */
388 int log_drop_count;
389 /**
390 * @default_log_level: default logging level
391 *
392 * For logging devices without filters @default_log_level defines the
393 * logging level, cf. &enum log_level_t.
394 */
395 int default_log_level;
396 /**
397 * @log_head: list of logging devices
398 */
399 struct list_head log_head;
400 /**
401 * @log_fmt: bit mask for logging format
402 *
403 * The @log_fmt bit mask selects the fields to be shown in log messages.
404 * &enum log_fmt defines the bits of the bit mask.
405 */
406 int log_fmt;
Heinrich Schuchardtfdf55992020-10-17 14:31:57 +0200407
408 /**
409 * @processing_msg: a log message is being processed
410 *
411 * This flag is used to suppress the creation of additional messages
412 * while another message is being processed.
413 */
414 bool processing_msg;
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200415 /**
416 * @logc_prev: logging category of previous message
417 *
418 * This value is used as logging category for continuation messages.
419 */
420 int logc_prev;
421 /**
Heinrich Schuchardt14e77222020-10-30 18:50:31 +0100422 * @logl_prev: logging level of the previous message
Heinrich Schuchardt0fc9f4f2020-10-17 14:31:58 +0200423 *
424 * This value is used as logging level for continuation messages.
425 */
426 int logl_prev;
Simon Glass5fc47e32021-01-20 20:10:53 -0700427 /**
428 * @log_cont: Previous log line did not finished wtih \n
429 *
430 * This allows for chained log messages on the same line
431 */
432 bool log_cont;
Simon Glassd95645d2017-12-04 13:48:24 -0700433#endif
Simon Glassa815dab2018-11-15 18:43:52 -0700434#if CONFIG_IS_ENABLED(BLOBLIST)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200435 /**
436 * @bloblist: blob list information
437 */
438 struct bloblist_hdr *bloblist;
439 /**
440 * @new_bloblist: relocated blob list information
441 */
442 struct bloblist_hdr *new_bloblist;
Ovidiu Panaitc1b30d52020-11-28 10:43:20 +0200443#endif
444#if CONFIG_IS_ENABLED(HANDOFF)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200445 /**
446 * @spl_handoff: SPL hand-off information
447 */
Simon Glasse14f1a22018-11-15 18:44:09 -0700448 struct spl_handoff *spl_handoff;
Simon Glassa815dab2018-11-15 18:43:52 -0700449#endif
Stefan Roese85bddff2019-04-12 16:42:28 +0200450#if defined(CONFIG_TRANSLATION_OFFSET)
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200451 /**
452 * @translation_offset: optional translation offset
453 *
454 * See CONFIG_TRANSLATION_OFFSET.
455 */
456 fdt_addr_t translation_offset;
Stefan Roese85bddff2019-04-12 16:42:28 +0200457#endif
Simon Glasscf1f4bb2023-05-04 16:54:59 -0600458#ifdef CONFIG_ACPI
Simon Glassde0115a2020-11-04 09:57:19 -0700459 /**
460 * @acpi_ctx: ACPI context pointer
461 */
462 struct acpi_ctx *acpi_ctx;
Simon Glassb33f2f92021-12-01 09:02:37 -0700463 /**
464 * @acpi_start: Start address of ACPI tables
465 */
466 ulong acpi_start;
Simon Glassde0115a2020-11-04 09:57:19 -0700467#endif
Simon Glassa05eb042021-02-04 21:17:20 -0700468#if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
469 /**
470 * @smbios_version: Points to SMBIOS type 0 version
471 */
472 char *smbios_version;
473#endif
Simon Glassaa4bce92022-03-04 08:43:00 -0700474#if CONFIG_IS_ENABLED(EVENT)
475 /**
476 * @event_state: Points to the current state of events
477 */
478 struct event_state event_state;
479#endif
Simon Glass0b385222024-07-31 08:44:08 -0600480#if CONFIG_IS_ENABLED(CYCLIC)
Stefan Roese036f89a2022-09-02 13:57:48 +0200481 /**
Rasmus Villemoesc794e492022-10-28 13:50:54 +0200482 * @cyclic_list: list of registered cyclic functions
Stefan Roese036f89a2022-09-02 13:57:48 +0200483 */
Rasmus Villemoesc794e492022-10-28 13:50:54 +0200484 struct hlist_head cyclic_list;
Stefan Roese036f89a2022-09-02 13:57:48 +0200485#endif
AKASHI Takahiroe04f4fb2022-03-08 20:36:46 +0900486 /**
487 * @dmtag_list: List of DM tags
488 */
489 struct list_head dmtag_list;
Simon Glass3a028c22024-08-07 16:47:30 -0600490#if CONFIG_IS_ENABLED(UPL)
491 /**
492 * @upl: Universal Payload-handoff information
493 */
494 struct upl *upl;
495#endif
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200496};
Rasmus Villemoesb8cfd9e2021-05-18 11:19:47 +0200497#ifndef DO_DEPS_ONLY
498static_assert(sizeof(struct global_data) == GD_SIZE);
499#endif
Simon Glass0e724032012-12-13 20:49:12 +0000500
Heinrich Schuchardt50d92862020-10-05 08:30:09 +0200501/**
502 * gd_board_type() - retrieve board type
503 *
504 * Return: global board type
505 */
Simon Glassb4de3f32017-03-31 08:40:24 -0600506#ifdef CONFIG_BOARD_TYPES
507#define gd_board_type() gd->board_type
508#else
509#define gd_board_type() 0
510#endif
511
Simon Glass40916e62020-10-03 09:25:22 -0600512/* These macros help avoid #ifdefs in the code */
513#if CONFIG_IS_ENABLED(OF_LIVE)
514#define gd_of_root() gd->of_root
515#define gd_of_root_ptr() &gd->of_root
516#define gd_set_of_root(_root) gd->of_root = (_root)
517#else
518#define gd_of_root() NULL
519#define gd_of_root_ptr() NULL
520#define gd_set_of_root(_root)
521#endif
522
Simon Glass8beeb282021-03-15 17:25:36 +1300523#if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
Simon Glasscfd6a002020-10-03 11:31:33 -0600524#define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
525#define gd_dm_driver_rt() gd->dm_driver_rt
526#else
527#define gd_set_dm_driver_rt(dyn)
528#define gd_dm_driver_rt() NULL
529#endif
530
Simon Glass8beeb282021-03-15 17:25:36 +1300531#if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
532#define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
533#define gd_dm_udevice_rt() gd->dm_udevice_rt
Simon Glass8dee67a2021-03-15 17:25:38 +1300534#define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
535#define gd_dm_priv_base() gd->dm_priv_base
Simon Glass8beeb282021-03-15 17:25:36 +1300536#else
537#define gd_set_dm_udevice_rt(dyn)
538#define gd_dm_udevice_rt() NULL
Simon Glass8dee67a2021-03-15 17:25:38 +1300539#define gd_set_dm_priv_base(dyn)
540#define gd_dm_priv_base() NULL
Simon Glass8beeb282021-03-15 17:25:36 +1300541#endif
542
Simon Glasscf1f4bb2023-05-04 16:54:59 -0600543#ifdef CONFIG_ACPI
Simon Glassde0115a2020-11-04 09:57:19 -0700544#define gd_acpi_ctx() gd->acpi_ctx
Simon Glassb33f2f92021-12-01 09:02:37 -0700545#define gd_acpi_start() gd->acpi_start
546#define gd_set_acpi_start(addr) gd->acpi_start = addr
Simon Glassde0115a2020-11-04 09:57:19 -0700547#else
548#define gd_acpi_ctx() NULL
Simon Glassb33f2f92021-12-01 09:02:37 -0700549#define gd_acpi_start() 0UL
550#define gd_set_acpi_start(addr)
Simon Glassde0115a2020-11-04 09:57:19 -0700551#endif
552
Simon Glass9b388102023-09-19 21:00:15 -0600553#ifdef CONFIG_SMBIOS
Simon Glass42b7da52023-12-31 08:25:48 -0700554#define gd_smbios_start() gd->arch.smbios_start
Simon Glass9b388102023-09-19 21:00:15 -0600555#define gd_set_smbios_start(addr) gd->arch.smbios_start = addr
556#else
557#define gd_smbios_start() 0UL
558#define gd_set_smbios_start(addr)
559#endif
560
Simon Glass69daf5a2021-12-16 20:59:25 -0700561#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
562#define gd_multi_dtb_fit() gd->multi_dtb_fit
563#define gd_set_multi_dtb_fit(_dtb) gd->multi_dtb_fit = _dtb
564#else
565#define gd_multi_dtb_fit() NULL
566#define gd_set_multi_dtb_fit(_dtb)
567#endif
568
Simon Glassaa4bce92022-03-04 08:43:00 -0700569#if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
570#define gd_event_state() ((struct event_state *)&gd->event_state)
571#else
572#define gd_event_state() NULL
573#endif
574
Simon Glass345c9742023-07-15 21:38:53 -0600575#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
576#define gd_malloc_start() gd->malloc_start
577#define gd_set_malloc_start(_val) gd->malloc_start = (_val)
578#else
579#define gd_malloc_start() 0
580#define gd_set_malloc_start(val)
581#endif
Troy Kiskye143c272023-03-13 14:31:43 -0700582
583#if CONFIG_IS_ENABLED(PCI)
584#define gd_set_pci_ram_top(val) gd->pci_ram_top = val
585#else
586#define gd_set_pci_ram_top(val)
587#endif
588
Simon Glasse8804d72023-09-26 08:14:31 -0600589#if CONFIG_VAL(SYS_MALLOC_F_LEN)
590#define gd_malloc_ptr() gd->malloc_ptr
591#else
592#define gd_malloc_ptr() 0L
593#endif
594
Simon Glass3a028c22024-08-07 16:47:30 -0600595#if CONFIG_IS_ENABLED(UPL)
596#define gd_upl() gd->upl
597#define gd_set_upl(_val) gd->upl = (_val)
598#else
599#define gd_upl() NULL
600#define gd_set_upl(val)
601#endif
602
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200603/**
604 * enum gd_flags - global data flags
605 *
606 * See field flags of &struct global_data.
Simon Glass0e724032012-12-13 20:49:12 +0000607 */
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200608enum gd_flags {
609 /**
610 * @GD_FLG_RELOC: code was relocated to RAM
611 */
612 GD_FLG_RELOC = 0x00001,
613 /**
614 * @GD_FLG_DEVINIT: devices have been initialized
615 */
616 GD_FLG_DEVINIT = 0x00002,
617 /**
618 * @GD_FLG_SILENT: silent mode
619 */
620 GD_FLG_SILENT = 0x00004,
621 /**
622 * @GD_FLG_POSTFAIL: critical POST test failed
623 */
624 GD_FLG_POSTFAIL = 0x00008,
625 /**
626 * @GD_FLG_POSTSTOP: POST sequence aborted
627 */
628 GD_FLG_POSTSTOP = 0x00010,
629 /**
630 * @GD_FLG_LOGINIT: log Buffer has been initialized
631 */
632 GD_FLG_LOGINIT = 0x00020,
633 /**
634 * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
635 */
636 GD_FLG_DISABLE_CONSOLE = 0x00040,
637 /**
638 * @GD_FLG_ENV_READY: environment imported into hash table
639 */
640 GD_FLG_ENV_READY = 0x00080,
641 /**
642 * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
643 */
644 GD_FLG_SERIAL_READY = 0x00100,
645 /**
646 * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
647 */
648 GD_FLG_FULL_MALLOC_INIT = 0x00200,
649 /**
650 * @GD_FLG_SPL_INIT: spl_init() has been called
651 */
652 GD_FLG_SPL_INIT = 0x00400,
653 /**
654 * @GD_FLG_SKIP_RELOC: don't relocate
655 */
656 GD_FLG_SKIP_RELOC = 0x00800,
657 /**
658 * @GD_FLG_RECORD: record console
659 */
660 GD_FLG_RECORD = 0x01000,
661 /**
Simon Glassd6ed4af2021-05-08 06:59:56 -0600662 * @GD_FLG_RECORD_OVF: record console overflow
663 */
664 GD_FLG_RECORD_OVF = 0x02000,
665 /**
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200666 * @GD_FLG_ENV_DEFAULT: default variable flag
667 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600668 GD_FLG_ENV_DEFAULT = 0x04000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200669 /**
670 * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
671 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600672 GD_FLG_SPL_EARLY_INIT = 0x08000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200673 /**
674 * @GD_FLG_LOG_READY: log system is ready for use
675 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600676 GD_FLG_LOG_READY = 0x10000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200677 /**
Stefan Roese5128a872022-11-17 09:20:34 +0100678 * @GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200679 */
Stefan Roese5128a872022-11-17 09:20:34 +0100680 GD_FLG_CYCLIC_RUNNING = 0x20000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200681 /**
682 * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
683 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600684 GD_FLG_SKIP_LL_INIT = 0x40000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200685 /**
686 * @GD_FLG_SMP_READY: SMP initialization is complete
687 */
Simon Glassd6ed4af2021-05-08 06:59:56 -0600688 GD_FLG_SMP_READY = 0x80000,
Simon Glass60f08992022-09-06 20:27:06 -0600689 /**
690 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
691 */
692 GD_FLG_FDT_CHANGED = 0x100000,
Simon Glassc2727e52023-02-13 08:56:32 -0700693 /**
694 * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
695 */
696 GD_FLG_OF_TAG_MIGRATE = 0x200000,
Simon Glass31ef8342023-09-07 09:58:13 -0600697 /**
698 * @GD_FLG_DM_DEAD: Driver model is not accessible. This can be set when
699 * the memory used to holds its tables has been mapped out.
700 */
701 GD_FLG_DM_DEAD = 0x400000,
Simon Glassa28f39c2023-09-26 08:14:51 -0600702 /**
703 * @GD_FLG_BLOBLIST_READY: bloblist is ready for use
704 */
705 GD_FLG_BLOBLIST_READY = 0x800000,
Francis Laniel1239d232023-12-22 22:02:30 +0100706 /**
707 * @GD_FLG_HUSH_OLD_PARSER: Use hush old parser.
708 */
709 GD_FLG_HUSH_OLD_PARSER = 0x1000000,
Francis Laniel3b66e572023-12-22 22:02:32 +0100710 /**
711 * @GD_FLG_HUSH_MODERN_PARSER: Use hush 2021 parser.
712 */
713 GD_FLG_HUSH_MODERN_PARSER = 0x2000000,
Simon Glass9b5bfba2024-08-07 16:47:33 -0600714 /**
715 * @GD_FLG_UPL: Read/write a Universal Payload (UPL) handoff
716 */
717 GD_FLG_UPL = 0x4000000,
Heinrich Schuchardt1e5c4fe2020-10-05 08:30:08 +0200718};
719
720#endif /* __ASSEMBLY__ */
Simon Glass0e724032012-12-13 20:49:12 +0000721
722#endif /* __ASM_GENERIC_GBL_DATA_H */