global_data.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2012 The Chromium OS Authors.
  4. * (C) Copyright 2002-2010
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. */
  7. #ifndef __ASM_GENERIC_GBL_DATA_H
  8. #define __ASM_GENERIC_GBL_DATA_H
  9. /*
  10. * The following data structure is placed in some memory which is
  11. * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
  12. * some locked parts of the data cache) to allow for a minimum set of
  13. * global variables during system initialization (until we have set
  14. * up the memory controller so that we can use RAM).
  15. *
  16. * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
  17. *
  18. * Each architecture has its own private fields. For now all are private
  19. */
  20. #ifndef __ASSEMBLY__
  21. #include <fdtdec.h>
  22. #include <membuff.h>
  23. #include <linux/list.h>
  24. struct acpi_ctx;
  25. struct driver_rt;
  26. typedef struct global_data gd_t;
  27. /**
  28. * struct global_data - global data structure
  29. */
  30. struct global_data {
  31. /**
  32. * @bd: board information
  33. */
  34. struct bd_info *bd;
  35. /**
  36. * @flags: global data flags
  37. *
  38. * See &enum gd_flags
  39. */
  40. unsigned long flags;
  41. /**
  42. * @baudrate: baud rate of the serial interface
  43. */
  44. unsigned int baudrate;
  45. /**
  46. * @cpu_clk: CPU clock rate in Hz
  47. */
  48. unsigned long cpu_clk;
  49. /**
  50. * @bus_clk: platform clock rate in Hz
  51. */
  52. unsigned long bus_clk;
  53. /**
  54. * @pci_clk: PCI clock rate in Hz
  55. */
  56. /* We cannot bracket this with CONFIG_PCI due to mpc5xxx */
  57. unsigned long pci_clk;
  58. /**
  59. * @mem_clk: memory clock rate in Hz
  60. */
  61. unsigned long mem_clk;
  62. #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
  63. /**
  64. * @fb_base: base address of frame buffer memory
  65. */
  66. unsigned long fb_base;
  67. #endif
  68. #if defined(CONFIG_POST)
  69. /**
  70. * @post_log_word: active POST tests
  71. *
  72. * @post_log_word is a bit mask defining which POST tests are recorded
  73. * (see constants POST_*).
  74. */
  75. unsigned long post_log_word;
  76. /**
  77. * @post_log_res: POST results
  78. *
  79. * @post_log_res is a bit mask with the POST results. A bit with value 1
  80. * indicates successful execution.
  81. */
  82. unsigned long post_log_res;
  83. /**
  84. * @post_init_f_time: time in ms when post_init_f() started
  85. */
  86. unsigned long post_init_f_time;
  87. #endif
  88. #ifdef CONFIG_BOARD_TYPES
  89. /**
  90. * @board_type: board type
  91. *
  92. * If a U-Boot configuration supports multiple board types, the actual
  93. * board type may be stored in this field.
  94. */
  95. unsigned long board_type;
  96. #endif
  97. /**
  98. * @have_console: console is available
  99. *
  100. * A value of 1 indicates that serial_init() was called and a console
  101. * is available.
  102. * A value of 0 indicates that console input and output drivers shall
  103. * not be called.
  104. */
  105. unsigned long have_console;
  106. #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
  107. /**
  108. * @precon_buf_idx: pre-console buffer index
  109. *
  110. * @precon_buf_idx indicates the current position of the buffer used to
  111. * collect output before the console becomes available
  112. */
  113. unsigned long precon_buf_idx;
  114. #endif
  115. /**
  116. * @env_addr: address of environment structure
  117. *
  118. * @env_addr contains the address of the structure holding the
  119. * environment variables.
  120. */
  121. unsigned long env_addr;
  122. /**
  123. * @env_valid: environment is valid
  124. *
  125. * See &enum env_valid
  126. */
  127. unsigned long env_valid;
  128. /**
  129. * @env_has_init: bit mask indicating environment locations
  130. *
  131. * &enum env_location defines which bit relates to which location
  132. */
  133. unsigned long env_has_init;
  134. /**
  135. * @env_load_prio: priority of the loaded environment
  136. */
  137. int env_load_prio;
  138. /**
  139. * @ram_base: base address of RAM used by U-Boot
  140. */
  141. unsigned long ram_base;
  142. /**
  143. * @ram_top: top address of RAM used by U-Boot
  144. */
  145. phys_addr_t ram_top;
  146. /**
  147. * @relocaddr: start address of U-Boot in RAM
  148. *
  149. * After relocation this field indicates the address to which U-Boot
  150. * has been relocated. It can be displayed using the bdinfo command.
  151. * Its value is needed to display the source code when debugging with
  152. * GDB using the 'add-symbol-file u-boot <relocaddr>' command.
  153. */
  154. unsigned long relocaddr;
  155. /**
  156. * @ram_size: RAM size in bytes
  157. */
  158. phys_size_t ram_size;
  159. /**
  160. * @mon_len: monitor length in bytes
  161. */
  162. unsigned long mon_len;
  163. /**
  164. * @irq_sp: IRQ stack pointer
  165. */
  166. unsigned long irq_sp;
  167. /**
  168. * @start_addr_sp: initial stack pointer address
  169. */
  170. unsigned long start_addr_sp;
  171. /**
  172. * @reloc_off: relocation offset
  173. */
  174. unsigned long reloc_off;
  175. /**
  176. * @new_gd: pointer to relocated global data
  177. */
  178. struct global_data *new_gd;
  179. #ifdef CONFIG_DM
  180. /**
  181. * @dm_root: root instance for Driver Model
  182. */
  183. struct udevice *dm_root;
  184. /**
  185. * @dm_root_f: pre-relocation root instance
  186. */
  187. struct udevice *dm_root_f;
  188. /**
  189. * @uclass_root_s:
  190. * head of core tree when uclasses are not in read-only memory.
  191. *
  192. * When uclasses are in read-only memory, @uclass_root_s is not used and
  193. * @uclass_root points to the root node generated by dtoc.
  194. */
  195. struct list_head uclass_root_s;
  196. /**
  197. * @uclass_root:
  198. * pointer to head of core tree, if uclasses are in read-only memory and
  199. * cannot be adjusted to use @uclass_root as a list head.
  200. *
  201. * When not in read-only memory, @uclass_root_s is used to hold the
  202. * uclass root, and @uclass_root points to the address of
  203. * @uclass_root_s.
  204. */
  205. struct list_head *uclass_root;
  206. # if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
  207. /** @dm_driver_rt: Dynamic info about the driver */
  208. struct driver_rt *dm_driver_rt;
  209. # endif
  210. #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
  211. /** @dm_udevice_rt: Dynamic info about the udevice */
  212. struct udevice_rt *dm_udevice_rt;
  213. /**
  214. * @dm_priv_base: Base address of the priv/plat region used when
  215. * udevices and uclasses are in read-only memory. This is NULL if not
  216. * used
  217. */
  218. void *dm_priv_base;
  219. # endif
  220. #endif
  221. #ifdef CONFIG_TIMER
  222. /**
  223. * @timer: timer instance for Driver Model
  224. */
  225. struct udevice *timer;
  226. #endif
  227. /**
  228. * @fdt_blob: U-Boot's own device tree, NULL if none
  229. */
  230. const void *fdt_blob;
  231. /**
  232. * @new_fdt: relocated device tree
  233. */
  234. void *new_fdt;
  235. /**
  236. * @fdt_size: space reserved for relocated device space
  237. */
  238. unsigned long fdt_size;
  239. #if CONFIG_IS_ENABLED(OF_LIVE)
  240. /**
  241. * @of_root: root node of the live tree
  242. */
  243. struct device_node *of_root;
  244. #endif
  245. #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
  246. /**
  247. * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
  248. */
  249. const void *multi_dtb_fit;
  250. #endif
  251. /**
  252. * @jt: jump table
  253. *
  254. * The jump table contains pointers to exported functions. A pointer to
  255. * the jump table is passed to standalone applications.
  256. */
  257. struct jt_funcs *jt;
  258. /**
  259. * @env_buf: buffer for env_get() before reloc
  260. */
  261. char env_buf[32];
  262. #ifdef CONFIG_TRACE
  263. /**
  264. * @trace_buff: trace buffer
  265. *
  266. * When tracing function in U-Boot this field points to the buffer
  267. * recording the function calls.
  268. */
  269. void *trace_buff;
  270. #endif
  271. #if defined(CONFIG_SYS_I2C)
  272. /**
  273. * @cur_i2c_bus: currently used I2C bus
  274. */
  275. int cur_i2c_bus;
  276. #endif
  277. /**
  278. * @timebase_h: high 32 bits of timer
  279. */
  280. unsigned int timebase_h;
  281. /**
  282. * @timebase_l: low 32 bits of timer
  283. */
  284. unsigned int timebase_l;
  285. #if CONFIG_VAL(SYS_MALLOC_F_LEN)
  286. /**
  287. * @malloc_base: base address of early malloc()
  288. */
  289. unsigned long malloc_base;
  290. /**
  291. * @malloc_limit: limit address of early malloc()
  292. */
  293. unsigned long malloc_limit;
  294. /**
  295. * @malloc_ptr: current address of early malloc()
  296. */
  297. unsigned long malloc_ptr;
  298. #endif
  299. #ifdef CONFIG_PCI
  300. /**
  301. * @hose: PCI hose for early use
  302. */
  303. struct pci_controller *hose;
  304. /**
  305. * @pci_ram_top: top of region accessible to PCI
  306. */
  307. phys_addr_t pci_ram_top;
  308. #endif
  309. #ifdef CONFIG_PCI_BOOTDELAY
  310. /**
  311. * @pcidelay_done: delay time before scanning of PIC hose expired
  312. *
  313. * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
  314. * milliseconds defined by environment variable pcidelay before
  315. * scanning. Once this delay has expired the flag @pcidelay_done
  316. * is set to 1.
  317. */
  318. int pcidelay_done;
  319. #endif
  320. /**
  321. * @cur_serial_dev: current serial device
  322. */
  323. struct udevice *cur_serial_dev;
  324. /**
  325. * @arch: architecture-specific data
  326. */
  327. struct arch_global_data arch;
  328. #ifdef CONFIG_CONSOLE_RECORD
  329. /**
  330. * @console_out: output buffer for console recording
  331. *
  332. * This buffer is used to collect output during console recording.
  333. */
  334. struct membuff console_out;
  335. /**
  336. * @console_in: input buffer for console recording
  337. *
  338. * If console recording is activated, this buffer can be used to
  339. * emulate input.
  340. */
  341. struct membuff console_in;
  342. #endif
  343. #ifdef CONFIG_DM_VIDEO
  344. /**
  345. * @video_top: top of video frame buffer area
  346. */
  347. ulong video_top;
  348. /**
  349. * @video_bottom: bottom of video frame buffer area
  350. */
  351. ulong video_bottom;
  352. #endif
  353. #ifdef CONFIG_BOOTSTAGE
  354. /**
  355. * @bootstage: boot stage information
  356. */
  357. struct bootstage_data *bootstage;
  358. /**
  359. * @new_bootstage: relocated boot stage information
  360. */
  361. struct bootstage_data *new_bootstage;
  362. #endif
  363. #ifdef CONFIG_LOG
  364. /**
  365. * @log_drop_count: number of dropped log messages
  366. *
  367. * This counter is incremented for each log message which can not
  368. * be processed because logging is not yet available as signaled by
  369. * flag %GD_FLG_LOG_READY in @flags.
  370. */
  371. int log_drop_count;
  372. /**
  373. * @default_log_level: default logging level
  374. *
  375. * For logging devices without filters @default_log_level defines the
  376. * logging level, cf. &enum log_level_t.
  377. */
  378. int default_log_level;
  379. /**
  380. * @log_head: list of logging devices
  381. */
  382. struct list_head log_head;
  383. /**
  384. * @log_fmt: bit mask for logging format
  385. *
  386. * The @log_fmt bit mask selects the fields to be shown in log messages.
  387. * &enum log_fmt defines the bits of the bit mask.
  388. */
  389. int log_fmt;
  390. /**
  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;
  397. /**
  398. * @logc_prev: logging category of previous message
  399. *
  400. * This value is used as logging category for continuation messages.
  401. */
  402. int logc_prev;
  403. /**
  404. * @logl_prev: logging level of the previous message
  405. *
  406. * This value is used as logging level for continuation messages.
  407. */
  408. int logl_prev;
  409. /**
  410. * @log_cont: Previous log line did not finished wtih \n
  411. *
  412. * This allows for chained log messages on the same line
  413. */
  414. bool log_cont;
  415. #endif
  416. #if CONFIG_IS_ENABLED(BLOBLIST)
  417. /**
  418. * @bloblist: blob list information
  419. */
  420. struct bloblist_hdr *bloblist;
  421. /**
  422. * @new_bloblist: relocated blob list information
  423. */
  424. struct bloblist_hdr *new_bloblist;
  425. #endif
  426. #if CONFIG_IS_ENABLED(HANDOFF)
  427. /**
  428. * @spl_handoff: SPL hand-off information
  429. */
  430. struct spl_handoff *spl_handoff;
  431. #endif
  432. #if defined(CONFIG_TRANSLATION_OFFSET)
  433. /**
  434. * @translation_offset: optional translation offset
  435. *
  436. * See CONFIG_TRANSLATION_OFFSET.
  437. */
  438. fdt_addr_t translation_offset;
  439. #endif
  440. #if CONFIG_IS_ENABLED(WDT)
  441. /**
  442. * @watchdog_dev: watchdog device
  443. */
  444. struct udevice *watchdog_dev;
  445. #endif
  446. #ifdef CONFIG_GENERATE_ACPI_TABLE
  447. /**
  448. * @acpi_ctx: ACPI context pointer
  449. */
  450. struct acpi_ctx *acpi_ctx;
  451. #endif
  452. #if CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)
  453. /**
  454. * @smbios_version: Points to SMBIOS type 0 version
  455. */
  456. char *smbios_version;
  457. #endif
  458. };
  459. /**
  460. * gd_board_type() - retrieve board type
  461. *
  462. * Return: global board type
  463. */
  464. #ifdef CONFIG_BOARD_TYPES
  465. #define gd_board_type() gd->board_type
  466. #else
  467. #define gd_board_type() 0
  468. #endif
  469. /* These macros help avoid #ifdefs in the code */
  470. #if CONFIG_IS_ENABLED(OF_LIVE)
  471. #define gd_of_root() gd->of_root
  472. #define gd_of_root_ptr() &gd->of_root
  473. #define gd_set_of_root(_root) gd->of_root = (_root)
  474. #else
  475. #define gd_of_root() NULL
  476. #define gd_of_root_ptr() NULL
  477. #define gd_set_of_root(_root)
  478. #endif
  479. #if CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)
  480. #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
  481. #define gd_dm_driver_rt() gd->dm_driver_rt
  482. #else
  483. #define gd_set_dm_driver_rt(dyn)
  484. #define gd_dm_driver_rt() NULL
  485. #endif
  486. #if CONFIG_IS_ENABLED(OF_PLATDATA_RT)
  487. #define gd_set_dm_udevice_rt(dyn) gd->dm_udevice_rt = dyn
  488. #define gd_dm_udevice_rt() gd->dm_udevice_rt
  489. #define gd_set_dm_priv_base(dyn) gd->dm_priv_base = dyn
  490. #define gd_dm_priv_base() gd->dm_priv_base
  491. #else
  492. #define gd_set_dm_udevice_rt(dyn)
  493. #define gd_dm_udevice_rt() NULL
  494. #define gd_set_dm_priv_base(dyn)
  495. #define gd_dm_priv_base() NULL
  496. #endif
  497. #ifdef CONFIG_GENERATE_ACPI_TABLE
  498. #define gd_acpi_ctx() gd->acpi_ctx
  499. #else
  500. #define gd_acpi_ctx() NULL
  501. #endif
  502. /**
  503. * enum gd_flags - global data flags
  504. *
  505. * See field flags of &struct global_data.
  506. */
  507. enum gd_flags {
  508. /**
  509. * @GD_FLG_RELOC: code was relocated to RAM
  510. */
  511. GD_FLG_RELOC = 0x00001,
  512. /**
  513. * @GD_FLG_DEVINIT: devices have been initialized
  514. */
  515. GD_FLG_DEVINIT = 0x00002,
  516. /**
  517. * @GD_FLG_SILENT: silent mode
  518. */
  519. GD_FLG_SILENT = 0x00004,
  520. /**
  521. * @GD_FLG_POSTFAIL: critical POST test failed
  522. */
  523. GD_FLG_POSTFAIL = 0x00008,
  524. /**
  525. * @GD_FLG_POSTSTOP: POST sequence aborted
  526. */
  527. GD_FLG_POSTSTOP = 0x00010,
  528. /**
  529. * @GD_FLG_LOGINIT: log Buffer has been initialized
  530. */
  531. GD_FLG_LOGINIT = 0x00020,
  532. /**
  533. * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
  534. */
  535. GD_FLG_DISABLE_CONSOLE = 0x00040,
  536. /**
  537. * @GD_FLG_ENV_READY: environment imported into hash table
  538. */
  539. GD_FLG_ENV_READY = 0x00080,
  540. /**
  541. * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
  542. */
  543. GD_FLG_SERIAL_READY = 0x00100,
  544. /**
  545. * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
  546. */
  547. GD_FLG_FULL_MALLOC_INIT = 0x00200,
  548. /**
  549. * @GD_FLG_SPL_INIT: spl_init() has been called
  550. */
  551. GD_FLG_SPL_INIT = 0x00400,
  552. /**
  553. * @GD_FLG_SKIP_RELOC: don't relocate
  554. */
  555. GD_FLG_SKIP_RELOC = 0x00800,
  556. /**
  557. * @GD_FLG_RECORD: record console
  558. */
  559. GD_FLG_RECORD = 0x01000,
  560. /**
  561. * @GD_FLG_RECORD_OVF: record console overflow
  562. */
  563. GD_FLG_RECORD_OVF = 0x02000,
  564. /**
  565. * @GD_FLG_ENV_DEFAULT: default variable flag
  566. */
  567. GD_FLG_ENV_DEFAULT = 0x04000,
  568. /**
  569. * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
  570. */
  571. GD_FLG_SPL_EARLY_INIT = 0x08000,
  572. /**
  573. * @GD_FLG_LOG_READY: log system is ready for use
  574. */
  575. GD_FLG_LOG_READY = 0x10000,
  576. /**
  577. * @GD_FLG_WDT_READY: watchdog is ready for use
  578. */
  579. GD_FLG_WDT_READY = 0x20000,
  580. /**
  581. * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
  582. */
  583. GD_FLG_SKIP_LL_INIT = 0x40000,
  584. /**
  585. * @GD_FLG_SMP_READY: SMP initialization is complete
  586. */
  587. GD_FLG_SMP_READY = 0x80000,
  588. };
  589. #endif /* __ASSEMBLY__ */
  590. #endif /* __ASM_GENERIC_GBL_DATA_H */