common.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /*
  2. * (C) Copyright 2000-2009
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __COMMON_H_
  8. #define __COMMON_H_ 1
  9. #ifndef __ASSEMBLY__ /* put C only stuff in this section */
  10. typedef unsigned char uchar;
  11. typedef volatile unsigned long vu_long;
  12. typedef volatile unsigned short vu_short;
  13. typedef volatile unsigned char vu_char;
  14. /* Allow sharing constants with type modifiers between C and assembly. */
  15. #define _AC(X, Y) (X##Y)
  16. #include <config.h>
  17. #include <errno.h>
  18. #include <time.h>
  19. #include <asm-offsets.h>
  20. #include <linux/bitops.h>
  21. #include <linux/bug.h>
  22. #include <linux/delay.h>
  23. #include <linux/types.h>
  24. #include <linux/printk.h>
  25. #include <linux/string.h>
  26. #include <linux/stringify.h>
  27. #include <asm/ptrace.h>
  28. #include <stdarg.h>
  29. #include <stdio.h>
  30. #include <linux/kernel.h>
  31. #include <part.h>
  32. #include <flash.h>
  33. #include <image.h>
  34. /* Bring in printf format macros if inttypes.h is included */
  35. #define __STDC_FORMAT_MACROS
  36. #ifdef __LP64__
  37. #define CONFIG_SYS_SUPPORT_64BIT_DATA
  38. #endif
  39. #include <log.h>
  40. typedef void (interrupt_handler_t)(void *);
  41. #include <asm/u-boot.h> /* boot information for Linux kernel */
  42. #include <asm/global_data.h> /* global data used for startup functions */
  43. #if defined(CONFIG_ENV_IS_EMBEDDED)
  44. #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
  45. #elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \
  46. (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \
  47. defined(CONFIG_ENV_IS_IN_NVRAM)
  48. #define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
  49. #else
  50. #define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
  51. #endif
  52. /* startup functions */
  53. #include <init.h>
  54. /*
  55. * Function Prototypes
  56. */
  57. int dram_init(void);
  58. /**
  59. * dram_init_banksize() - Set up DRAM bank sizes
  60. *
  61. * This can be implemented by boards to set up the DRAM bank information in
  62. * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
  63. * is called.
  64. *
  65. * If this is not provided, a default implementation will try to set up a
  66. * single bank. It will do this if CONFIG_NR_DRAM_BANKS and
  67. * CONFIG_SYS_SDRAM_BASE are set. The bank will have a start address of
  68. * CONFIG_SYS_SDRAM_BASE and the size will be determined by a call to
  69. * get_effective_memsize().
  70. *
  71. * @return 0 if OK, -ve on error
  72. */
  73. int dram_init_banksize(void);
  74. void hang (void) __attribute__ ((noreturn));
  75. int timer_init(void);
  76. int cpu_init(void);
  77. #include <display_options.h>
  78. /* common/main.c */
  79. void main_loop (void);
  80. int run_command(const char *cmd, int flag);
  81. int run_command_repeatable(const char *cmd, int flag);
  82. /**
  83. * Run a list of commands separated by ; or even \0
  84. *
  85. * Note that if 'len' is not -1, then the command does not need to be nul
  86. * terminated, Memory will be allocated for the command in that case.
  87. *
  88. * @param cmd List of commands to run, each separated bu semicolon
  89. * @param len Length of commands excluding terminator if known (-1 if not)
  90. * @param flag Execution flags (CMD_FLAG_...)
  91. * @return 0 on success, or != 0 on error.
  92. */
  93. int run_command_list(const char *cmd, int len, int flag);
  94. /* arch/$(ARCH)/lib/board.c */
  95. void board_init_f(ulong);
  96. void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
  97. /**
  98. * ulong board_init_f_alloc_reserve - allocate reserved area
  99. *
  100. * This function is called by each architecture very early in the start-up
  101. * code to allow the C runtime to reserve space on the stack for writable
  102. * 'globals' such as GD and the malloc arena.
  103. *
  104. * @top: top of the reserve area, growing down.
  105. * @return: bottom of reserved area
  106. */
  107. ulong board_init_f_alloc_reserve(ulong top);
  108. /**
  109. * board_init_f_init_reserve - initialize the reserved area(s)
  110. *
  111. * This function is called once the C runtime has allocated the reserved
  112. * area on the stack. It must initialize the GD at the base of that area.
  113. *
  114. * @base: top from which reservation was done
  115. */
  116. void board_init_f_init_reserve(ulong base);
  117. /**
  118. * arch_setup_gd() - Set up the global_data pointer
  119. *
  120. * This pointer is special in some architectures and cannot easily be assigned
  121. * to. For example on x86 it is implemented by adding a specific record to its
  122. * Global Descriptor Table! So we we provide a function to carry out this task.
  123. * For most architectures this can simply be:
  124. *
  125. * gd = gd_ptr;
  126. *
  127. * @gd_ptr: Pointer to global data
  128. */
  129. void arch_setup_gd(gd_t *gd_ptr);
  130. int checkboard(void);
  131. int show_board_info(void);
  132. int last_stage_init(void);
  133. extern ulong monitor_flash_len;
  134. int mac_read_from_eeprom(void);
  135. extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
  136. extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
  137. int set_cpu_clk_info(void);
  138. int print_cpuinfo(void);
  139. int update_flash_size(int flash_size);
  140. int arch_early_init_r(void);
  141. /**
  142. * arch_fsp_init() - perform firmware support package init
  143. *
  144. * Where U-Boot relies on binary blobs to handle part of the system init, this
  145. * function can be used to set up the blobs. This is used on some Intel
  146. * platforms.
  147. */
  148. int arch_fsp_init(void);
  149. /**
  150. * arch_cpu_init_dm() - init CPU after driver model is available
  151. *
  152. * This is called immediately after driver model is available before
  153. * relocation. This is similar to arch_cpu_init() but is able to reference
  154. * devices
  155. *
  156. * @return 0 if OK, -ve on error
  157. */
  158. int arch_cpu_init_dm(void);
  159. /**
  160. * Reserve all necessary stacks
  161. *
  162. * This is used in generic board init sequence in common/board_f.c. Each
  163. * architecture could provide this function to tailor the required stacks.
  164. *
  165. * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
  166. * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
  167. * require only this can leave it untouched.
  168. *
  169. * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
  170. * positions of the stack. The stack pointer(s) will be set to this later.
  171. * gd->irq_sp is only required, if the architecture needs it.
  172. *
  173. * @return 0 if no error
  174. */
  175. __weak int arch_reserve_stacks(void);
  176. /**
  177. * Show the DRAM size in a board-specific way
  178. *
  179. * This is used by boards to display DRAM information in their own way.
  180. *
  181. * @param size Size of DRAM (which should be displayed along with other info)
  182. */
  183. void board_show_dram(phys_size_t size);
  184. /**
  185. * arch_fixup_fdt() - Write arch-specific information to fdt
  186. *
  187. * Defined in arch/$(ARCH)/lib/bootm-fdt.c
  188. *
  189. * @blob: FDT blob to write to
  190. * @return 0 if ok, or -ve FDT_ERR_... on failure
  191. */
  192. int arch_fixup_fdt(void *blob);
  193. int reserve_mmu(void);
  194. /* common/flash.c */
  195. void flash_perror (int);
  196. /* common/cmd_source.c */
  197. int source (ulong addr, const char *fit_uname);
  198. extern ulong load_addr; /* Default Load Address */
  199. extern ulong save_addr; /* Default Save Address */
  200. extern ulong save_size; /* Default Save Size */
  201. /* common/cmd_net.c */
  202. int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  203. /* common/cmd_fat.c */
  204. int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
  205. /* common/cmd_ext2.c */
  206. int do_ext2load(cmd_tbl_t *, int, int, char * const []);
  207. /* common/cmd_nvedit.c */
  208. int env_init (void);
  209. void env_relocate (void);
  210. int envmatch (uchar *, int);
  211. /**
  212. * env_get() - Look up the value of an environment variable
  213. *
  214. * In U-Boot proper this can be called before relocation (which is when the
  215. * environment is loaded from storage, i.e. GD_FLG_ENV_READY is 0). In that
  216. * case this function calls env_get_f().
  217. *
  218. * @varname: Variable to look up
  219. * @return value of variable, or NULL if not found
  220. */
  221. char *env_get(const char *varname);
  222. /**
  223. * env_get_f() - Look up the value of an environment variable (early)
  224. *
  225. * This function is called from env_get() if the environment has not been
  226. * loaded yet (GD_FLG_ENV_READY flag is 0). Some environment locations will
  227. * support reading the value (slowly) and some will not.
  228. *
  229. * @varname: Variable to look up
  230. * @return value of variable, or NULL if not found
  231. */
  232. int env_get_f(const char *name, char *buf, unsigned len);
  233. /**
  234. * env_get_ulong() - Return an environment variable as an integer value
  235. *
  236. * Most U-Boot environment variables store hex values. For those which store
  237. * (e.g.) base-10 integers, this function can be used to read the value.
  238. *
  239. * @name: Variable to look up
  240. * @base: Base to use (e.g. 10 for base 10, 2 for binary)
  241. * @default_val: Default value to return if no value is found
  242. * @return the value found, or @default_val if none
  243. */
  244. ulong env_get_ulong(const char *name, int base, ulong default_val);
  245. /**
  246. * env_get_hex() - Return an environment variable as a hex value
  247. *
  248. * Decode an environment as a hex number (it may or may not have a 0x
  249. * prefix). If the environment variable cannot be found, or does not start
  250. * with hex digits, the default value is returned.
  251. *
  252. * @varname: Variable to decode
  253. * @default_val: Value to return on error
  254. */
  255. ulong env_get_hex(const char *varname, ulong default_val);
  256. /*
  257. * Read an environment variable as a boolean
  258. * Return -1 if variable does not exist (default to true)
  259. */
  260. int env_get_yesno(const char *var);
  261. /**
  262. * env_set() - set an environment variable
  263. *
  264. * This sets or deletes the value of an environment variable. For setting the
  265. * value the variable is created if it does not already exist.
  266. *
  267. * @varname: Variable to adjust
  268. * @value: Value to set for the variable, or NULL or "" to delete the variable
  269. * @return 0 if OK, 1 on error
  270. */
  271. int env_set(const char *varname, const char *value);
  272. /**
  273. * env_set_ulong() - set an environment variable to an integer
  274. *
  275. * @varname: Variable to adjust
  276. * @value: Value to set for the variable (will be converted to a string)
  277. * @return 0 if OK, 1 on error
  278. */
  279. int env_set_ulong(const char *varname, ulong value);
  280. /**
  281. * env_set_hex() - set an environment variable to a hex value
  282. *
  283. * @varname: Variable to adjust
  284. * @value: Value to set for the variable (will be converted to a hex string)
  285. * @return 0 if OK, 1 on error
  286. */
  287. int env_set_hex(const char *varname, ulong value);
  288. /**
  289. * env_set_addr - Set an environment variable to an address in hex
  290. *
  291. * @varname: Environment variable to set
  292. * @addr: Value to set it to
  293. * @return 0 if ok, 1 on error
  294. */
  295. static inline int env_set_addr(const char *varname, const void *addr)
  296. {
  297. return env_set_hex(varname, (ulong)addr);
  298. }
  299. #ifdef CONFIG_AUTO_COMPLETE
  300. int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
  301. #endif
  302. int get_env_id (void);
  303. void pci_init (void);
  304. void pci_init_board(void);
  305. #if defined(CONFIG_DTB_RESELECT)
  306. int embedded_dtb_select(void);
  307. #endif
  308. int misc_init_f (void);
  309. int misc_init_r (void);
  310. #if defined(CONFIG_VID)
  311. int init_func_vid(void);
  312. #endif
  313. /* common/exports.c */
  314. void jumptable_init(void);
  315. /* common/kallsysm.c */
  316. const char *symbol_lookup(unsigned long addr, unsigned long *caddr);
  317. /* common/memsize.c */
  318. long get_ram_size (long *, long);
  319. phys_size_t get_effective_memsize(void);
  320. /* $(BOARD)/$(BOARD).c */
  321. void reset_phy (void);
  322. void fdc_hw_init (void);
  323. /* $(BOARD)/eeprom.c */
  324. #ifdef CONFIG_CMD_EEPROM
  325. void eeprom_init (int bus);
  326. int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  327. int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
  328. #else
  329. /*
  330. * Some EEPROM code is depecated because it used the legacy I2C interface. Add
  331. * some macros here so we don't have to touch every one of those uses
  332. */
  333. #define eeprom_init(bus)
  334. #define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  335. #define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
  336. #endif
  337. /*
  338. * Set this up regardless of board
  339. * type, to prevent errors.
  340. */
  341. #if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  342. # define CONFIG_SYS_DEF_EEPROM_ADDR 0
  343. #else
  344. #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
  345. # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
  346. #endif
  347. #endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
  348. #if defined(CONFIG_SPI)
  349. extern void spi_init_f (void);
  350. extern void spi_init_r (void);
  351. extern ssize_t spi_read (uchar *, int, uchar *, int);
  352. extern ssize_t spi_write (uchar *, int, uchar *, int);
  353. #endif
  354. /* $(BOARD)/$(BOARD).c */
  355. int board_early_init_f (void);
  356. int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */
  357. int board_late_init (void);
  358. int board_postclk_init (void); /* after clocks/timebase, before env/serial */
  359. int board_early_init_r (void);
  360. #if defined(CONFIG_SYS_DRAM_TEST)
  361. int testdram(void);
  362. #endif /* CONFIG_SYS_DRAM_TEST */
  363. /* $(CPU)/start.S */
  364. int icache_status (void);
  365. void icache_enable (void);
  366. void icache_disable(void);
  367. int dcache_status (void);
  368. void dcache_enable (void);
  369. void dcache_disable(void);
  370. void mmu_disable(void);
  371. #if defined(CONFIG_ARM)
  372. void relocate_code(ulong);
  373. #else
  374. void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
  375. #endif
  376. ulong get_endaddr (void);
  377. void trap_init (ulong);
  378. /* $(CPU)/cpu.c */
  379. static inline int cpumask_next(int cpu, unsigned int mask)
  380. {
  381. for (cpu++; !((1 << cpu) & mask); cpu++)
  382. ;
  383. return cpu;
  384. }
  385. #define for_each_cpu(iter, cpu, num_cpus, mask) \
  386. for (iter = 0, cpu = cpumask_next(-1, mask); \
  387. iter < num_cpus; \
  388. iter++, cpu = cpumask_next(cpu, mask)) \
  389. int cpu_numcores (void);
  390. int cpu_num_dspcores(void);
  391. u32 cpu_mask (void);
  392. u32 cpu_dsp_mask(void);
  393. int is_core_valid (unsigned int);
  394. void s_init(void);
  395. int checkcpu (void);
  396. int checkicache (void);
  397. int checkdcache (void);
  398. void upmconfig (unsigned int, unsigned int *, unsigned int);
  399. ulong get_tbclk (void);
  400. void reset_misc (void);
  401. void reset_cpu (ulong addr);
  402. void ft_cpu_setup(void *blob, bd_t *bd);
  403. void ft_pci_setup(void *blob, bd_t *bd);
  404. void smp_set_core_boot_addr(unsigned long addr, int corenr);
  405. void smp_kick_all_cpus(void);
  406. /* $(CPU)/serial.c */
  407. int serial_init (void);
  408. void serial_setbrg (void);
  409. void serial_putc (const char);
  410. void serial_putc_raw(const char);
  411. void serial_puts (const char *);
  412. int serial_getc (void);
  413. int serial_tstc (void);
  414. /* $(CPU)/speed.c */
  415. int get_clocks (void);
  416. ulong get_bus_freq (ulong);
  417. int get_serial_clock(void);
  418. int cpu_init_r (void);
  419. /* $(CPU)/interrupts.c */
  420. int interrupt_init (void);
  421. void timer_interrupt (struct pt_regs *);
  422. void external_interrupt (struct pt_regs *);
  423. void irq_install_handler(int, interrupt_handler_t *, void *);
  424. void irq_free_handler (int);
  425. void reset_timer (void);
  426. /* Return value of monotonic microsecond timer */
  427. unsigned long timer_get_us(void);
  428. void enable_interrupts (void);
  429. int disable_interrupts (void);
  430. /* $(CPU)/.../commproc.c */
  431. int dpram_init (void);
  432. uint dpram_base(void);
  433. uint dpram_base_align(uint align);
  434. uint dpram_alloc(uint size);
  435. uint dpram_alloc_align(uint size,uint align);
  436. void bootcount_store (ulong);
  437. ulong bootcount_load (void);
  438. #define BOOTCOUNT_MAGIC 0xB001C041
  439. /* $(CPU)/.../<eth> */
  440. void mii_init (void);
  441. /* $(CPU)/.../lcd.c */
  442. ulong lcd_setmem (ulong);
  443. /* $(CPU)/.../video.c */
  444. ulong video_setmem (ulong);
  445. /* arch/$(ARCH)/lib/cache.c */
  446. void enable_caches(void);
  447. void flush_cache (unsigned long, unsigned long);
  448. void flush_dcache_all(void);
  449. void flush_dcache_range(unsigned long start, unsigned long stop);
  450. void invalidate_dcache_range(unsigned long start, unsigned long stop);
  451. void invalidate_dcache_all(void);
  452. void invalidate_icache_all(void);
  453. enum {
  454. /* Disable caches (else flush caches but leave them active) */
  455. CBL_DISABLE_CACHES = 1 << 0,
  456. CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1,
  457. CBL_ALL = 3,
  458. };
  459. /**
  460. * Clean up ready for linux
  461. *
  462. * @param flags Flags to control what is done
  463. */
  464. int cleanup_before_linux_select(int flags);
  465. /* arch/$(ARCH)/lib/ticks.S */
  466. uint64_t get_ticks(void);
  467. void wait_ticks (unsigned long);
  468. /* arch/$(ARCH)/lib/time.c */
  469. ulong usec2ticks (unsigned long usec);
  470. ulong ticks2usec (unsigned long ticks);
  471. /* lib/gunzip.c */
  472. int gzip_parse_header(const unsigned char *src, unsigned long len);
  473. int gunzip(void *, int, unsigned char *, unsigned long *);
  474. int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
  475. int stoponerr, int offset);
  476. /**
  477. * gzwrite progress indicators: defined weak to allow board-specific
  478. * overrides:
  479. *
  480. * gzwrite_progress_init called on startup
  481. * gzwrite_progress called during decompress/write loop
  482. * gzwrite_progress_finish called at end of loop to
  483. * indicate success (retcode=0) or failure
  484. */
  485. void gzwrite_progress_init(u64 expected_size);
  486. void gzwrite_progress(int iteration,
  487. u64 bytes_written,
  488. u64 total_bytes);
  489. void gzwrite_progress_finish(int retcode,
  490. u64 totalwritten,
  491. u64 totalsize,
  492. u32 expected_crc,
  493. u32 calculated_crc);
  494. /**
  495. * decompress and write gzipped image from memory to block device
  496. *
  497. * @param src compressed image address
  498. * @param len compressed image length in bytes
  499. * @param dev block device descriptor
  500. * @param szwritebuf bytes per write (pad to erase size)
  501. * @param startoffs offset in bytes of first write
  502. * @param szexpected expected uncompressed length
  503. * may be zero to use gzip trailer
  504. * for files under 4GiB
  505. */
  506. int gzwrite(unsigned char *src, int len,
  507. struct blk_desc *dev,
  508. unsigned long szwritebuf,
  509. u64 startoffs,
  510. u64 szexpected);
  511. /* lib/lz4_wrapper.c */
  512. int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
  513. /* lib/qsort.c */
  514. void qsort(void *base, size_t nmemb, size_t size,
  515. int(*compar)(const void *, const void *));
  516. int strcmp_compar(const void *, const void *);
  517. /* lib/uuid.c */
  518. #include <uuid.h>
  519. /* lib/vsprintf.c */
  520. #include <vsprintf.h>
  521. /* lib/strmhz.c */
  522. char * strmhz(char *buf, unsigned long hz);
  523. /* lib/crc32.c */
  524. #include <u-boot/crc.h>
  525. /* lib/rand.c */
  526. #define RAND_MAX -1U
  527. void srand(unsigned int seed);
  528. unsigned int rand(void);
  529. unsigned int rand_r(unsigned int *seedp);
  530. /*
  531. * STDIO based functions (can always be used)
  532. */
  533. /* serial stuff */
  534. int serial_printf (const char *fmt, ...)
  535. __attribute__ ((format (__printf__, 1, 2)));
  536. /* lib/gzip.c */
  537. int gzip(void *dst, unsigned long *lenp,
  538. unsigned char *src, unsigned long srclen);
  539. int zzip(void *dst, unsigned long *lenp, unsigned char *src,
  540. unsigned long srclen, int stoponerr,
  541. int (*func)(unsigned long, unsigned long));
  542. /* lib/net_utils.c */
  543. #include <net.h>
  544. static inline struct in_addr env_get_ip(char *var)
  545. {
  546. return string_to_ip(env_get(var));
  547. }
  548. int pcmcia_init (void);
  549. #ifdef CONFIG_LED_STATUS
  550. # include <status_led.h>
  551. #endif
  552. #include <bootstage.h>
  553. #ifdef CONFIG_SHOW_ACTIVITY
  554. void show_activity(int arg);
  555. #endif
  556. /* Multicore arch functions */
  557. #ifdef CONFIG_MP
  558. int cpu_status(int nr);
  559. int cpu_reset(int nr);
  560. int cpu_disable(int nr);
  561. int cpu_release(int nr, int argc, char * const argv[]);
  562. #endif
  563. #else /* __ASSEMBLY__ */
  564. /* Drop a C type modifier (like in 3UL) for constants used in assembly. */
  565. #define _AC(X, Y) X
  566. #endif /* __ASSEMBLY__ */
  567. /* Put only stuff here that the assembler can digest */
  568. /* Declare an unsigned long constant digestable both by C and an assembler. */
  569. #define UL(x) _AC(x, UL)
  570. #ifdef CONFIG_POST
  571. #define CONFIG_HAS_POST
  572. #ifndef CONFIG_POST_ALT_LIST
  573. #define CONFIG_POST_STD_LIST
  574. #endif
  575. #endif
  576. #ifdef CONFIG_INIT_CRITICAL
  577. #error CONFIG_INIT_CRITICAL is deprecated!
  578. #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
  579. #endif
  580. #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
  581. /*
  582. * check_member() - Check the offset of a structure member
  583. *
  584. * @structure: Name of structure (e.g. global_data)
  585. * @member: Name of member (e.g. baudrate)
  586. * @offset: Expected offset in bytes
  587. */
  588. #define check_member(structure, member, offset) _Static_assert( \
  589. offsetof(struct structure, member) == offset, \
  590. "`struct " #structure "` offset for `" #member "` is not " #offset)
  591. /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
  592. #ifdef CONFIG_EFI_STUB
  593. #define ll_boot_init() false
  594. #else
  595. #define ll_boot_init() true
  596. #endif
  597. /* Pull in stuff for the build system */
  598. #ifdef DO_DEPS_ONLY
  599. # include <environment.h>
  600. #endif
  601. #endif /* __COMMON_H_ */