common.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 volatile unsigned long vu_long;
  16. typedef volatile unsigned short vu_short;
  17. typedef volatile unsigned char vu_char;
  18. #include <config.h>
  19. #include <errno.h>
  20. #include <time.h>
  21. #include <asm-offsets.h>
  22. #include <linux/bitops.h>
  23. #include <linux/bug.h>
  24. #include <linux/delay.h>
  25. #include <linux/types.h>
  26. #include <linux/printk.h>
  27. #include <linux/string.h>
  28. #include <linux/stringify.h>
  29. #include <asm/ptrace.h>
  30. #include <stdarg.h>
  31. #include <stdio.h>
  32. #include <linux/kernel.h>
  33. #include <part.h>
  34. #include <flash.h>
  35. #include <image.h>
  36. #ifdef __LP64__
  37. #define CONFIG_SYS_SUPPORT_64BIT_DATA
  38. #endif
  39. #include <log.h>
  40. #include <asm/u-boot.h> /* boot information for Linux kernel */
  41. #include <asm/global_data.h> /* global data used for startup functions */
  42. /* startup functions, used in:
  43. * common/board_f.c
  44. * common/init/board_init.c
  45. * common/board_r.c
  46. * common/board_info.c
  47. */
  48. #include <init.h>
  49. /*
  50. * Function Prototypes
  51. */
  52. void hang (void) __attribute__ ((noreturn));
  53. #include <display_options.h>
  54. /* common/main.c */
  55. void main_loop (void);
  56. int checkflash(void);
  57. int checkdram(void);
  58. extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
  59. extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
  60. int mdm_init(void);
  61. /**
  62. * arch_fixup_fdt() - Write arch-specific information to fdt
  63. *
  64. * Defined in arch/$(ARCH)/lib/bootm-fdt.c
  65. *
  66. * @blob: FDT blob to write to
  67. * @return 0 if ok, or -ve FDT_ERR_... on failure
  68. */
  69. int arch_fixup_fdt(void *blob);
  70. /* common/flash.c */
  71. void flash_perror (int);
  72. /* common/cmd_source.c */
  73. int source (ulong addr, const char *fit_uname);
  74. extern ulong load_addr; /* Default Load Address */
  75. extern ulong save_addr; /* Default Save Address */
  76. extern ulong save_size; /* Default Save Size */
  77. /* common/cmd_net.c */
  78. int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  79. /* common/cmd_fat.c */
  80. int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
  81. /* common/cmd_ext2.c */
  82. int do_ext2load(cmd_tbl_t *, int, int, char * const []);
  83. /* common/exports.c */
  84. void jumptable_init(void);
  85. /* common/kallsysm.c */
  86. const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
  87. /* common/memsize.c */
  88. long get_ram_size (long *, long);
  89. phys_size_t get_effective_memsize(void);
  90. /* $(BOARD)/$(BOARD).c */
  91. void reset_phy (void);
  92. void fdc_hw_init (void);
  93. #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  94. # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
  95. #endif
  96. #if defined(CONFIG_SYS_DRAM_TEST)
  97. int testdram(void);
  98. #endif /* CONFIG_SYS_DRAM_TEST */
  99. #if defined(CONFIG_ARM)
  100. void relocate_code(ulong);
  101. #else
  102. void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
  103. #endif
  104. void s_init(void);
  105. void upmconfig (unsigned int, unsigned int *, unsigned int);
  106. ulong get_tbclk (void);
  107. void reset_misc (void);
  108. void reset_cpu (ulong addr);
  109. void ft_cpu_setup(void *blob, bd_t *bd);
  110. void ft_pci_setup(void *blob, bd_t *bd);
  111. /* $(CPU)/speed.c */
  112. int get_clocks (void);
  113. ulong get_bus_freq (ulong);
  114. int get_serial_clock(void);
  115. /* lib/uuid.c */
  116. #include <uuid.h>
  117. /* lib/vsprintf.c */
  118. #include <vsprintf.h>
  119. /* lib/net_utils.c */
  120. #include <net.h>
  121. #include <bootstage.h>
  122. #else /* __ASSEMBLY__ */
  123. #endif /* __ASSEMBLY__ */
  124. /* Put only stuff here that the assembler can digest */
  125. #ifdef CONFIG_POST
  126. #define CONFIG_HAS_POST
  127. #ifndef CONFIG_POST_ALT_LIST
  128. #define CONFIG_POST_STD_LIST
  129. #endif
  130. #endif
  131. #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
  132. /*
  133. * check_member() - Check the offset of a structure member
  134. *
  135. * @structure: Name of structure (e.g. global_data)
  136. * @member: Name of member (e.g. baudrate)
  137. * @offset: Expected offset in bytes
  138. */
  139. #define check_member(structure, member, offset) _Static_assert( \
  140. offsetof(struct structure, member) == offset, \
  141. "`struct " #structure "` offset for `" #member "` is not " #offset)
  142. /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
  143. #ifdef CONFIG_EFI_STUB
  144. #define ll_boot_init() false
  145. #else
  146. #define ll_boot_init() true
  147. #endif
  148. /* Pull in stuff for the build system */
  149. #ifdef DO_DEPS_ONLY
  150. # include <env_internal.h>
  151. #endif
  152. #endif /* __COMMON_H_ */