X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fcommon.h;h=a8d833b9891fe09c7121c637a7f1f84a8b764d2b;hb=0b060eefd951fc111ecb77c7b1932b158e6a4f2c;hp=75c78d5ac2f77cfa03894d3841dd5726b1f8a08a;hpb=cab24b3407189a120066b82da2376679bf203eae;p=u-boot diff --git a/include/common.h b/include/common.h index 75c78d5ac2..a8d833b989 100644 --- a/include/common.h +++ b/include/common.h @@ -16,6 +16,7 @@ typedef volatile unsigned short vu_short; typedef volatile unsigned char vu_char; #include +#include #include #include #include @@ -100,6 +101,13 @@ typedef volatile unsigned char vu_char; #define _DEBUG 0 #endif +#ifdef CONFIG_SPL_BUILD +#define _SPL_BUILD 1 +#else +#define _SPL_BUILD 0 +#endif + +/* Define this at the top of a file to add a prefix to debug messages */ #ifndef pr_fmt #define pr_fmt(fmt) fmt #endif @@ -115,9 +123,14 @@ typedef volatile unsigned char vu_char; printf(pr_fmt(fmt), ##args); \ } while (0) +/* Show a message if DEBUG is defined in a file */ #define debug(fmt, args...) \ debug_cond(_DEBUG, fmt, ##args) +/* Show a message if not in SPL */ +#define warn_non_spl(fmt, args...) \ + debug_cond(!_SPL_BUILD, fmt, ##args) + /* * An assertion is run-time check done in debug mode only. If DEBUG is not * defined then it is skipped. If DEBUG is defined and the assertion fails, @@ -146,9 +159,6 @@ void __assert_fail(const char *assertion, const char *file, unsigned line, #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #endif /* BUG */ -/* Force a compilation error if condition is true */ -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) - typedef void (interrupt_handler_t)(void *); #include /* boot information for Linux kernel */ @@ -224,32 +234,26 @@ void board_init_f(ulong); void board_init_r(gd_t *, ulong) __attribute__ ((noreturn)); /** - * board_init_f_mem() - Allocate global data and set stack position + * ulong board_init_f_alloc_reserve - allocate reserved area * * This function is called by each architecture very early in the start-up - * code to set up the environment for board_init_f(). It allocates space for - * global_data (see include/asm-generic/global_data.h) and places the stack - * below this. + * code to allow the C runtime to reserve space on the stack for writable + * 'globals' such as GD and the malloc arena. * - * This function requires a stack[1] Normally this is at @top. The function - * starts allocating space from 64 bytes below @top. First it creates space - * for global_data. Then it calls arch_setup_gd() which sets gd to point to - * the global_data space and can reserve additional bytes of space if - * required). Finally it allocates early malloc() memory - * (CONFIG_SYS_MALLOC_F_LEN). The new top of the stack is just below this, - * and it returned by this function. + * @top: top of the reserve area, growing down. + * @return: bottom of reserved area + */ +ulong board_init_f_alloc_reserve(ulong top); + +/** + * board_init_f_init_reserve - initialize the reserved area(s) * - * [1] Strictly speaking it would be possible to implement this function - * in C on many archs such that it does not require a stack. However this - * does not seem hugely important as only 64 byte are wasted. The 64 bytes - * are used to handle the calling standard which generally requires pushing - * addresses or registers onto the stack. We should be able to get away with - * less if this becomes important. + * This function is called once the C runtime has allocated the reserved + * area on the stack. It must initialize the GD at the base of that area. * - * @top: Top of available memory, also normally the top of the stack - * @return: New stack location + * @base: top from which reservation was done */ -ulong board_init_f_mem(ulong top); +void board_init_f_init_reserve(ulong base); /** * arch_setup_gd() - Set up the global_data pointer @@ -605,12 +609,8 @@ void upmconfig (unsigned int, unsigned int *, unsigned int); ulong get_tbclk (void); void reset_misc (void); void reset_cpu (ulong addr); -#if defined (CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP) void ft_cpu_setup(void *blob, bd_t *bd); -#ifdef CONFIG_PCI void ft_pci_setup(void *blob, bd_t *bd); -#endif -#endif void smp_set_core_boot_addr(unsigned long addr, int corenr); void smp_kick_all_cpus(void); @@ -669,10 +669,8 @@ int get_serial_clock(void); #if defined(CONFIG_MPC85xx) typedef MPC85xx_SYS_INFO sys_info_t; void get_sys_info ( sys_info_t * ); -# if defined(CONFIG_OF_LIBFDT) - void ft_fixup_cpu(void *, u64); - void ft_fixup_num_cores(void *); -# endif +void ft_fixup_cpu(void *, u64); +void ft_fixup_num_cores(void *); #endif #if defined(CONFIG_MPC86xx) typedef MPC86xx_SYS_INFO sys_info_t; @@ -822,7 +820,7 @@ void gzwrite_progress_finish(int retcode, * for files under 4GiB */ int gzwrite(unsigned char *src, int len, - struct block_dev_desc *dev, + struct blk_desc *dev, unsigned long szwritebuf, u64 startoffs, u64 szexpected); @@ -868,17 +866,20 @@ int getc(void); int tstc(void); /* stdout */ -#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SERIAL_SUPPORT) -#define putc(...) do { } while (0) -#define puts(...) do { } while (0) -#define printf(...) do { } while (0) -#define vprintf(...) do { } while (0) -#else +#if !defined(CONFIG_SPL_BUILD) || \ + (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL_SUPPORT)) || \ + (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \ + defined(CONFIG_SPL_SERIAL_SUPPORT)) void putc(const char c); void puts(const char *s); int printf(const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); int vprintf(const char *fmt, va_list args); +#else +#define putc(...) do { } while (0) +#define puts(...) do { } while (0) +#define printf(...) do { } while (0) +#define vprintf(...) do { } while (0) #endif /* stderr */