global_data.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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. unsigned long 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: head of core tree
  190. */
  191. struct list_head uclass_root;
  192. # if CONFIG_IS_ENABLED(OF_PLATDATA)
  193. /** @dm_driver_rt: Dynamic info about the driver */
  194. struct driver_rt *dm_driver_rt;
  195. # endif
  196. #endif
  197. #ifdef CONFIG_TIMER
  198. /**
  199. * @timer: timer instance for Driver Model
  200. */
  201. struct udevice *timer;
  202. #endif
  203. /**
  204. * @fdt_blob: U-Boot's own device tree, NULL if none
  205. */
  206. const void *fdt_blob;
  207. /**
  208. * @new_fdt: relocated device tree
  209. */
  210. void *new_fdt;
  211. /**
  212. * @fdt_size: space reserved for relocated device space
  213. */
  214. unsigned long fdt_size;
  215. #if CONFIG_IS_ENABLED(OF_LIVE)
  216. /**
  217. * @of_root: root node of the live tree
  218. */
  219. struct device_node *of_root;
  220. #endif
  221. #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
  222. /**
  223. * @multi_dtb_fit: pointer to uncompressed multi-dtb FIT image
  224. */
  225. const void *multi_dtb_fit;
  226. #endif
  227. /**
  228. * @jt: jump table
  229. *
  230. * The jump table contains pointers to exported functions. A pointer to
  231. * the jump table is passed to standalone applications.
  232. */
  233. struct jt_funcs *jt;
  234. /**
  235. * @env_buf: buffer for env_get() before reloc
  236. */
  237. char env_buf[32];
  238. #ifdef CONFIG_TRACE
  239. /**
  240. * @trace_buff: trace buffer
  241. *
  242. * When tracing function in U-Boot this field points to the buffer
  243. * recording the function calls.
  244. */
  245. void *trace_buff;
  246. #endif
  247. #if defined(CONFIG_SYS_I2C)
  248. /**
  249. * @cur_i2c_bus: currently used I2C bus
  250. */
  251. int cur_i2c_bus;
  252. #endif
  253. /**
  254. * @timebase_h: high 32 bits of timer
  255. */
  256. unsigned int timebase_h;
  257. /**
  258. * @timebase_l: low 32 bits of timer
  259. */
  260. unsigned int timebase_l;
  261. #if CONFIG_VAL(SYS_MALLOC_F_LEN)
  262. /**
  263. * @malloc_base: base address of early malloc()
  264. */
  265. unsigned long malloc_base;
  266. /**
  267. * @malloc_limit: limit address of early malloc()
  268. */
  269. unsigned long malloc_limit;
  270. /**
  271. * @malloc_ptr: current address of early malloc()
  272. */
  273. unsigned long malloc_ptr;
  274. #endif
  275. #ifdef CONFIG_PCI
  276. /**
  277. * @hose: PCI hose for early use
  278. */
  279. struct pci_controller *hose;
  280. /**
  281. * @pci_ram_top: top of region accessible to PCI
  282. */
  283. phys_addr_t pci_ram_top;
  284. #endif
  285. #ifdef CONFIG_PCI_BOOTDELAY
  286. /**
  287. * @pcidelay_done: delay time before scanning of PIC hose expired
  288. *
  289. * If CONFIG_PCI_BOOTDELAY=y, pci_hose_scan() waits for the number of
  290. * milliseconds defined by environment variable pcidelay before
  291. * scanning. Once this delay has expired the flag @pcidelay_done
  292. * is set to 1.
  293. */
  294. int pcidelay_done;
  295. #endif
  296. /**
  297. * @cur_serial_dev: current serial device
  298. */
  299. struct udevice *cur_serial_dev;
  300. /**
  301. * @arch: architecture-specific data
  302. */
  303. struct arch_global_data arch;
  304. #ifdef CONFIG_CONSOLE_RECORD
  305. /**
  306. * @console_out: output buffer for console recording
  307. *
  308. * This buffer is used to collect output during console recording.
  309. */
  310. struct membuff console_out;
  311. /**
  312. * @console_in: input buffer for console recording
  313. *
  314. * If console recording is activated, this buffer can be used to
  315. * emulate input.
  316. */
  317. struct membuff console_in;
  318. #endif
  319. #ifdef CONFIG_DM_VIDEO
  320. /**
  321. * @video_top: top of video frame buffer area
  322. */
  323. ulong video_top;
  324. /**
  325. * @video_bottom: bottom of video frame buffer area
  326. */
  327. ulong video_bottom;
  328. #endif
  329. #ifdef CONFIG_BOOTSTAGE
  330. /**
  331. * @bootstage: boot stage information
  332. */
  333. struct bootstage_data *bootstage;
  334. /**
  335. * @new_bootstage: relocated boot stage information
  336. */
  337. struct bootstage_data *new_bootstage;
  338. #endif
  339. #ifdef CONFIG_LOG
  340. /**
  341. * @log_drop_count: number of dropped log messages
  342. *
  343. * This counter is incremented for each log message which can not
  344. * be processed because logging is not yet available as signaled by
  345. * flag %GD_FLG_LOG_READY in @flags.
  346. */
  347. int log_drop_count;
  348. /**
  349. * @default_log_level: default logging level
  350. *
  351. * For logging devices without filters @default_log_level defines the
  352. * logging level, cf. &enum log_level_t.
  353. */
  354. int default_log_level;
  355. /**
  356. * @log_head: list of logging devices
  357. */
  358. struct list_head log_head;
  359. /**
  360. * @log_fmt: bit mask for logging format
  361. *
  362. * The @log_fmt bit mask selects the fields to be shown in log messages.
  363. * &enum log_fmt defines the bits of the bit mask.
  364. */
  365. int log_fmt;
  366. /**
  367. * @processing_msg: a log message is being processed
  368. *
  369. * This flag is used to suppress the creation of additional messages
  370. * while another message is being processed.
  371. */
  372. bool processing_msg;
  373. /**
  374. * @logc_prev: logging category of previous message
  375. *
  376. * This value is used as logging category for continuation messages.
  377. */
  378. int logc_prev;
  379. /**
  380. * @logl_prev: logging level of the previous message
  381. *
  382. * This value is used as logging level for continuation messages.
  383. */
  384. int logl_prev;
  385. #endif
  386. #if CONFIG_IS_ENABLED(BLOBLIST)
  387. /**
  388. * @bloblist: blob list information
  389. */
  390. struct bloblist_hdr *bloblist;
  391. /**
  392. * @new_bloblist: relocated blob list information
  393. */
  394. struct bloblist_hdr *new_bloblist;
  395. # ifdef CONFIG_SPL
  396. /**
  397. * @spl_handoff: SPL hand-off information
  398. */
  399. struct spl_handoff *spl_handoff;
  400. # endif
  401. #endif
  402. #if defined(CONFIG_TRANSLATION_OFFSET)
  403. /**
  404. * @translation_offset: optional translation offset
  405. *
  406. * See CONFIG_TRANSLATION_OFFSET.
  407. */
  408. fdt_addr_t translation_offset;
  409. #endif
  410. #if CONFIG_IS_ENABLED(WDT)
  411. /**
  412. * @watchdog_dev: watchdog device
  413. */
  414. struct udevice *watchdog_dev;
  415. #endif
  416. #ifdef CONFIG_GENERATE_ACPI_TABLE
  417. /**
  418. * @acpi_ctx: ACPI context pointer
  419. */
  420. struct acpi_ctx *acpi_ctx;
  421. #endif
  422. };
  423. /**
  424. * gd_board_type() - retrieve board type
  425. *
  426. * Return: global board type
  427. */
  428. #ifdef CONFIG_BOARD_TYPES
  429. #define gd_board_type() gd->board_type
  430. #else
  431. #define gd_board_type() 0
  432. #endif
  433. /* These macros help avoid #ifdefs in the code */
  434. #if CONFIG_IS_ENABLED(OF_LIVE)
  435. #define gd_of_root() gd->of_root
  436. #define gd_of_root_ptr() &gd->of_root
  437. #define gd_set_of_root(_root) gd->of_root = (_root)
  438. #else
  439. #define gd_of_root() NULL
  440. #define gd_of_root_ptr() NULL
  441. #define gd_set_of_root(_root)
  442. #endif
  443. #if CONFIG_IS_ENABLED(OF_PLATDATA)
  444. #define gd_set_dm_driver_rt(dyn) gd->dm_driver_rt = dyn
  445. #define gd_dm_driver_rt() gd->dm_driver_rt
  446. #else
  447. #define gd_set_dm_driver_rt(dyn)
  448. #define gd_dm_driver_rt() NULL
  449. #endif
  450. #ifdef CONFIG_GENERATE_ACPI_TABLE
  451. #define gd_acpi_ctx() gd->acpi_ctx
  452. #else
  453. #define gd_acpi_ctx() NULL
  454. #endif
  455. /**
  456. * enum gd_flags - global data flags
  457. *
  458. * See field flags of &struct global_data.
  459. */
  460. enum gd_flags {
  461. /**
  462. * @GD_FLG_RELOC: code was relocated to RAM
  463. */
  464. GD_FLG_RELOC = 0x00001,
  465. /**
  466. * @GD_FLG_DEVINIT: devices have been initialized
  467. */
  468. GD_FLG_DEVINIT = 0x00002,
  469. /**
  470. * @GD_FLG_SILENT: silent mode
  471. */
  472. GD_FLG_SILENT = 0x00004,
  473. /**
  474. * @GD_FLG_POSTFAIL: critical POST test failed
  475. */
  476. GD_FLG_POSTFAIL = 0x00008,
  477. /**
  478. * @GD_FLG_POSTSTOP: POST sequence aborted
  479. */
  480. GD_FLG_POSTSTOP = 0x00010,
  481. /**
  482. * @GD_FLG_LOGINIT: log Buffer has been initialized
  483. */
  484. GD_FLG_LOGINIT = 0x00020,
  485. /**
  486. * @GD_FLG_DISABLE_CONSOLE: disable console (in & out)
  487. */
  488. GD_FLG_DISABLE_CONSOLE = 0x00040,
  489. /**
  490. * @GD_FLG_ENV_READY: environment imported into hash table
  491. */
  492. GD_FLG_ENV_READY = 0x00080,
  493. /**
  494. * @GD_FLG_SERIAL_READY: pre-relocation serial console ready
  495. */
  496. GD_FLG_SERIAL_READY = 0x00100,
  497. /**
  498. * @GD_FLG_FULL_MALLOC_INIT: full malloc() is ready
  499. */
  500. GD_FLG_FULL_MALLOC_INIT = 0x00200,
  501. /**
  502. * @GD_FLG_SPL_INIT: spl_init() has been called
  503. */
  504. GD_FLG_SPL_INIT = 0x00400,
  505. /**
  506. * @GD_FLG_SKIP_RELOC: don't relocate
  507. */
  508. GD_FLG_SKIP_RELOC = 0x00800,
  509. /**
  510. * @GD_FLG_RECORD: record console
  511. */
  512. GD_FLG_RECORD = 0x01000,
  513. /**
  514. * @GD_FLG_ENV_DEFAULT: default variable flag
  515. */
  516. GD_FLG_ENV_DEFAULT = 0x02000,
  517. /**
  518. * @GD_FLG_SPL_EARLY_INIT: early SPL initialization is done
  519. */
  520. GD_FLG_SPL_EARLY_INIT = 0x04000,
  521. /**
  522. * @GD_FLG_LOG_READY: log system is ready for use
  523. */
  524. GD_FLG_LOG_READY = 0x08000,
  525. /**
  526. * @GD_FLG_WDT_READY: watchdog is ready for use
  527. */
  528. GD_FLG_WDT_READY = 0x10000,
  529. /**
  530. * @GD_FLG_SKIP_LL_INIT: don't perform low-level initialization
  531. */
  532. GD_FLG_SKIP_LL_INIT = 0x20000,
  533. /**
  534. * @GD_FLG_SMP_READY: SMP initialization is complete
  535. */
  536. GD_FLG_SMP_READY = 0x40000,
  537. };
  538. #endif /* __ASSEMBLY__ */
  539. #endif /* __ASM_GENERIC_GBL_DATA_H */