common.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Common header file for U-Boot
  4. *
  5. * This file still includes quite a bit of stuff that should be in separate
  6. * headers like command.h. Please think before adding more things.
  7. * Patches to remove things are welcome.
  8. *
  9. * (C) Copyright 2000-2009
  10. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  11. */
  12. #ifndef __COMMON_H_
  13. #define __COMMON_H_ 1
  14. #ifndef __ASSEMBLY__ /* put C only stuff in this section */
  15. typedef unsigned char uchar;
  16. typedef volatile unsigned long vu_long;
  17. typedef volatile unsigned short vu_short;
  18. typedef volatile unsigned char vu_char;
  19. #include <config.h>
  20. #include <errno.h>
  21. #include <time.h>
  22. #include <asm-offsets.h>
  23. #include <linux/bitops.h>
  24. #include <linux/bug.h>
  25. #include <linux/delay.h>
  26. #include <linux/types.h>
  27. #include <linux/printk.h>
  28. #include <linux/string.h>
  29. #include <linux/stringify.h>
  30. #include <asm/ptrace.h>
  31. #include <stdarg.h>
  32. #include <stdio.h>
  33. #include <linux/kernel.h>
  34. #include <part.h>
  35. #include <flash.h>
  36. #include <image.h>
  37. #ifdef __LP64__
  38. #define CONFIG_SYS_SUPPORT_64BIT_DATA
  39. #endif
  40. #include <log.h>
  41. #include <asm/u-boot.h> /* boot information for Linux kernel */
  42. #include <asm/global_data.h> /* global data used for startup functions */
  43. /* startup functions, used in:
  44. * common/board_f.c
  45. * common/init/board_init.c
  46. * common/board_r.c
  47. * common/board_info.c
  48. */
  49. #include <init.h>
  50. /*
  51. * Function Prototypes
  52. */
  53. void hang (void) __attribute__ ((noreturn));
  54. #include <display_options.h>
  55. /* common/main.c */
  56. void main_loop (void);
  57. int run_command(const char *cmd, int flag);
  58. int run_command_repeatable(const char *cmd, int flag);
  59. /**
  60. * Run a list of commands separated by ; or even \0
  61. *
  62. * Note that if 'len' is not -1, then the command does not need to be nul
  63. * terminated, Memory will be allocated for the command in that case.
  64. *
  65. * @param cmd List of commands to run, each separated bu semicolon
  66. * @param len Length of commands excluding terminator if known (-1 if not)
  67. * @param flag Execution flags (CMD_FLAG_...)
  68. * @return 0 on success, or != 0 on error.
  69. */
  70. int run_command_list(const char *cmd, int len, int flag);
  71. int checkflash(void);
  72. int checkdram(void);
  73. extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
  74. extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
  75. int mdm_init(void);
  76. /**
  77. * Show the DRAM size in a board-specific way
  78. *
  79. * This is used by boards to display DRAM information in their own way.
  80. *
  81. * @param size Size of DRAM (which should be displayed along with other info)
  82. */
  83. void board_show_dram(phys_size_t size);
  84. /**
  85. * Get the uppermost pointer that is valid to access
  86. *
  87. * Some systems may not map all of their address space. This function allows
  88. * boards to indicate what their highest support pointer value is for DRAM
  89. * access.
  90. *
  91. * @param total_size Size of U-Boot (unused?)
  92. */
  93. ulong board_get_usable_ram_top(ulong total_size);
  94. /**
  95. * arch_fixup_fdt() - Write arch-specific information to fdt
  96. *
  97. * Defined in arch/$(ARCH)/lib/bootm-fdt.c
  98. *
  99. * @blob: FDT blob to write to
  100. * @return 0 if ok, or -ve FDT_ERR_... on failure
  101. */
  102. int arch_fixup_fdt(void *blob);
  103. /* common/flash.c */
  104. void flash_perror (int);
  105. /* common/cmd_source.c */
  106. int source (ulong addr, const char *fit_uname);
  107. extern ulong load_addr; /* Default Load Address */
  108. extern ulong save_addr; /* Default Save Address */
  109. extern ulong save_size; /* Default Save Size */
  110. /* common/cmd_net.c */
  111. int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  112. /* common/cmd_fat.c */
  113. int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
  114. /* common/cmd_ext2.c */
  115. int do_ext2load(cmd_tbl_t *, int, int, char * const []);
  116. void pci_init_board(void);
  117. /* common/exports.c */
  118. void jumptable_init(void);
  119. /* common/kallsysm.c */
  120. const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
  121. /* common/memsize.c */
  122. long get_ram_size (long *, long);
  123. phys_size_t get_effective_memsize(void);
  124. /* $(BOARD)/$(BOARD).c */
  125. void reset_phy (void);
  126. void fdc_hw_init (void);
  127. /* $(BOARD)/eeprom.c */
  128. #ifdef CONFIG_CMD_EEPROM
  129. void eeprom_init (int bus);
  130. int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  131. int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  132. #else
  133. /*
  134. * Some EEPROM code is depecated because it used the legacy I2C interface. Add
  135. * some macros here so we don't have to touch every one of those uses
  136. */
  137. #define eeprom_init(bus)
  138. #define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  139. #define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  140. #endif
  141. #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  142. # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
  143. #endif
  144. /* $(BOARD)/$(BOARD).c */
  145. int board_early_init_f (void);
  146. int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */
  147. int board_late_init (void);
  148. int board_postclk_init (void); /* after clocks/timebase, before env/serial */
  149. int board_early_init_r (void);
  150. #if defined(CONFIG_SYS_DRAM_TEST)
  151. int testdram(void);
  152. #endif /* CONFIG_SYS_DRAM_TEST */
  153. #if defined(CONFIG_ARM)
  154. void relocate_code(ulong);
  155. #else
  156. void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
  157. #endif
  158. ulong get_endaddr (void);
  159. void trap_init (ulong);
  160. void s_init(void);
  161. void upmconfig (unsigned int, unsigned int *, unsigned int);
  162. ulong get_tbclk (void);
  163. void reset_misc (void);
  164. void reset_cpu (ulong addr);
  165. void ft_cpu_setup(void *blob, bd_t *bd);
  166. void ft_pci_setup(void *blob, bd_t *bd);
  167. /* $(CPU)/speed.c */
  168. int get_clocks (void);
  169. ulong get_bus_freq (ulong);
  170. int get_serial_clock(void);
  171. /* lib/uuid.c */
  172. #include <uuid.h>
  173. /* lib/vsprintf.c */
  174. #include <vsprintf.h>
  175. /* lib/net_utils.c */
  176. #include <net.h>
  177. #include <bootstage.h>
  178. #else /* __ASSEMBLY__ */
  179. #endif /* __ASSEMBLY__ */
  180. /* Put only stuff here that the assembler can digest */
  181. #ifdef CONFIG_POST
  182. #define CONFIG_HAS_POST
  183. #ifndef CONFIG_POST_ALT_LIST
  184. #define CONFIG_POST_STD_LIST
  185. #endif
  186. #endif
  187. #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
  188. /*
  189. * check_member() - Check the offset of a structure member
  190. *
  191. * @structure: Name of structure (e.g. global_data)
  192. * @member: Name of member (e.g. baudrate)
  193. * @offset: Expected offset in bytes
  194. */
  195. #define check_member(structure, member, offset) _Static_assert( \
  196. offsetof(struct structure, member) == offset, \
  197. "`struct " #structure "` offset for `" #member "` is not " #offset)
  198. /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
  199. #ifdef CONFIG_EFI_STUB
  200. #define ll_boot_init() false
  201. #else
  202. #define ll_boot_init() true
  203. #endif
  204. /* Pull in stuff for the build system */
  205. #ifdef DO_DEPS_ONLY
  206. # include <env_internal.h>
  207. #endif
  208. #endif /* __COMMON_H_ */