common.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. 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 checkflash(void);
  58. int checkdram(void);
  59. extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
  60. extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
  61. int mdm_init(void);
  62. /**
  63. * arch_fixup_fdt() - Write arch-specific information to fdt
  64. *
  65. * Defined in arch/$(ARCH)/lib/bootm-fdt.c
  66. *
  67. * @blob: FDT blob to write to
  68. * @return 0 if ok, or -ve FDT_ERR_... on failure
  69. */
  70. int arch_fixup_fdt(void *blob);
  71. /* common/flash.c */
  72. void flash_perror (int);
  73. /* common/cmd_source.c */
  74. int source (ulong addr, const char *fit_uname);
  75. extern ulong load_addr; /* Default Load Address */
  76. extern ulong save_addr; /* Default Save Address */
  77. extern ulong save_size; /* Default Save Size */
  78. /* common/cmd_net.c */
  79. int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  80. /* common/cmd_fat.c */
  81. int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
  82. /* common/cmd_ext2.c */
  83. int do_ext2load(cmd_tbl_t *, int, int, char * const []);
  84. /* common/exports.c */
  85. void jumptable_init(void);
  86. /* common/kallsysm.c */
  87. const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
  88. /* common/memsize.c */
  89. long get_ram_size (long *, long);
  90. phys_size_t get_effective_memsize(void);
  91. /* $(BOARD)/$(BOARD).c */
  92. void reset_phy (void);
  93. void fdc_hw_init (void);
  94. /* $(BOARD)/eeprom.c */
  95. #ifdef CONFIG_CMD_EEPROM
  96. void eeprom_init (int bus);
  97. int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  98. int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  99. #else
  100. /*
  101. * Some EEPROM code is depecated because it used the legacy I2C interface. Add
  102. * some macros here so we don't have to touch every one of those uses
  103. */
  104. #define eeprom_init(bus)
  105. #define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  106. #define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  107. #endif
  108. #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  109. # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
  110. #endif
  111. #if defined(CONFIG_SYS_DRAM_TEST)
  112. int testdram(void);
  113. #endif /* CONFIG_SYS_DRAM_TEST */
  114. #if defined(CONFIG_ARM)
  115. void relocate_code(ulong);
  116. #else
  117. void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
  118. #endif
  119. ulong get_endaddr (void);
  120. void trap_init (ulong);
  121. void s_init(void);
  122. void upmconfig (unsigned int, unsigned int *, unsigned int);
  123. ulong get_tbclk (void);
  124. void reset_misc (void);
  125. void reset_cpu (ulong addr);
  126. void ft_cpu_setup(void *blob, bd_t *bd);
  127. void ft_pci_setup(void *blob, bd_t *bd);
  128. /* $(CPU)/speed.c */
  129. int get_clocks (void);
  130. ulong get_bus_freq (ulong);
  131. int get_serial_clock(void);
  132. /* lib/uuid.c */
  133. #include <uuid.h>
  134. /* lib/vsprintf.c */
  135. #include <vsprintf.h>
  136. /* lib/net_utils.c */
  137. #include <net.h>
  138. #include <bootstage.h>
  139. #else /* __ASSEMBLY__ */
  140. #endif /* __ASSEMBLY__ */
  141. /* Put only stuff here that the assembler can digest */
  142. #ifdef CONFIG_POST
  143. #define CONFIG_HAS_POST
  144. #ifndef CONFIG_POST_ALT_LIST
  145. #define CONFIG_POST_STD_LIST
  146. #endif
  147. #endif
  148. #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
  149. /*
  150. * check_member() - Check the offset of a structure member
  151. *
  152. * @structure: Name of structure (e.g. global_data)
  153. * @member: Name of member (e.g. baudrate)
  154. * @offset: Expected offset in bytes
  155. */
  156. #define check_member(structure, member, offset) _Static_assert( \
  157. offsetof(struct structure, member) == offset, \
  158. "`struct " #structure "` offset for `" #member "` is not " #offset)
  159. /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
  160. #ifdef CONFIG_EFI_STUB
  161. #define ll_boot_init() false
  162. #else
  163. #define ll_boot_init() true
  164. #endif
  165. /* Pull in stuff for the build system */
  166. #ifdef DO_DEPS_ONLY
  167. # include <env_internal.h>
  168. #endif
  169. #endif /* __COMMON_H_ */