X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fcommon.h;h=09a131da0b967b5d56dae953f0e1a543b39cea82;hb=e4aa8edb6e5cae256a5c5a3c5cd30e05e8f5a2b4;hp=6df05b8bb1a81bb7f8d1deed78f49a8927088a6a;hpb=65f3151f85cb3fe91b91153dce6e03798ef3bc85;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/common.h b/include/common.h index 6df05b8..09a131d 100644 --- a/include/common.h +++ b/include/common.h @@ -76,6 +76,12 @@ typedef volatile unsigned char vu_char; #ifdef CONFIG_SOC_DA8XX #include #endif +#ifdef CONFIG_FSL_LSCH3 +#include +#endif +#ifdef CONFIG_FSL_LSCH2 +#include +#endif #include #include @@ -192,22 +198,8 @@ int cpu_init(void); /* */ phys_size_t initdram (int); -int display_options (void); - -/** - * print_size() - Print a size with a suffic - * - * print sizes as "xxx KiB", "xxx.y KiB", "xxx MiB", "xxx.y MiB", - * xxx GiB, xxx.y GiB, etc as needed; allow for optional trailing string - * (like "\n") - * - * @size: Size to print - * @suffix String to print after the size - */ -void print_size(uint64_t size, const char *suffix); -int print_buffer(ulong addr, const void *data, uint width, uint count, - uint linelen); +#include /* common/main.c */ void main_loop (void); @@ -231,6 +223,49 @@ extern char console_buffer[]; /* arch/$(ARCH)/lib/board.c */ 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 + * + * 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. + * + * 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. + * + * [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. + * + * @top: Top of available memory, also normally the top of the stack + * @return: New stack location + */ +ulong board_init_f_mem(ulong top); + +/** + * arch_setup_gd() - Set up the global_data pointer + * + * This pointer is special in some architectures and cannot easily be assigned + * to. For example on x86 it is implemented by adding a specific record to its + * Global Descriptor Table! So we we provide a function to carry out this task. + * For most architectures this can simply be: + * + * gd = gd_ptr; + * + * @gd_ptr: Pointer to global data + */ +void arch_setup_gd(gd_t *gd_ptr); + int checkboard(void); int show_board_info(void); int checkflash(void); @@ -253,6 +288,17 @@ int update_flash_size(int flash_size); int arch_early_init_r(void); /** + * arch_cpu_init_dm() - init CPU after driver model is available + * + * This is called immediately after driver model is available before + * relocation. This is similar to arch_cpu_init() but is able to reference + * devices + * + * @return 0 if OK, -ve on error + */ +int arch_cpu_init_dm(void); + +/** * Reserve all necessary stacks * * This is used in generic board init sequence in common/board_f.c. Each @@ -277,7 +323,7 @@ __weak int arch_reserve_stacks(void); * * @param size Size of DRAM (which should be displayed along with other info) */ -void board_show_dram(ulong size); +void board_show_dram(phys_size_t size); /** * arch_fixup_fdt() - Write arch-specific information to fdt @@ -471,7 +517,6 @@ int testdram(void); defined(CONFIG_8xx) uint get_immr (uint); #endif -uint get_pir (void); #if defined(CONFIG_MPC5xxx) uint get_svr (void); #endif @@ -718,6 +763,21 @@ void invalidate_dcache_range(unsigned long start, unsigned long stop); void invalidate_dcache_all(void); void invalidate_icache_all(void); +enum { + /* Disable caches (else flush caches but leave them active) */ + CBL_DISABLE_CACHES = 1 << 0, + CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1, + + CBL_ALL = 3, +}; + +/** + * Clean up ready for linux + * + * @param flags Flags to control what is done + */ +int cleanup_before_linux_select(int flags); + /* arch/$(ARCH)/lib/ticks.S */ uint64_t get_ticks(void); void wait_ticks (unsigned long); @@ -733,6 +793,48 @@ int gunzip(void *, int, unsigned char *, unsigned long *); int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, int stoponerr, int offset); +/** + * gzwrite progress indicators: defined weak to allow board-specific + * overrides: + * + * gzwrite_progress_init called on startup + * gzwrite_progress called during decompress/write loop + * gzwrite_progress_finish called at end of loop to + * indicate success (retcode=0) or failure + */ +void gzwrite_progress_init(u64 expected_size); + +void gzwrite_progress(int iteration, + u64 bytes_written, + u64 total_bytes); + +void gzwrite_progress_finish(int retcode, + u64 totalwritten, + u64 totalsize, + u32 expected_crc, + u32 calculated_crc); + +/** + * decompress and write gzipped image from memory to block device + * + * @param src compressed image address + * @param len compressed image length in bytes + * @param dev block device descriptor + * @param szwritebuf bytes per write (pad to erase size) + * @param startoffs offset in bytes of first write + * @param szexpected expected uncompressed length + * may be zero to use gzip trailer + * for files under 4GiB + */ +int gzwrite(unsigned char *src, int len, + struct block_dev_desc *dev, + unsigned long szwritebuf, + u64 startoffs, + u64 szexpected); + +/* lib/lz4_wrapper.c */ +int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn); + /* lib/qsort.c */ void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); @@ -780,11 +882,18 @@ 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 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); +#endif /* stderr */ #define eputc(c) fputc(stderr, c) @@ -815,7 +924,7 @@ int zzip(void *dst, unsigned long *lenp, unsigned char *src, /* lib/net_utils.c */ #include -static inline IPaddr_t getenv_IPaddr(char *var) +static inline struct in_addr getenv_ip(char *var) { return string_to_ip(getenv(var)); } @@ -847,23 +956,6 @@ int cpu_disable(int nr); int cpu_release(int nr, int argc, char * const argv[]); #endif -/* Define a null map_sysmem() if the architecture doesn't use it */ -# ifndef CONFIG_ARCH_MAP_SYSMEM -static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) -{ - return (void *)(uintptr_t)paddr; -} - -static inline void unmap_sysmem(const void *vaddr) -{ -} - -static inline phys_addr_t map_to_sysmem(const void *ptr) -{ - return (phys_addr_t)(uintptr_t)ptr; -} -# endif - #endif /* __ASSEMBLY__ */ #ifdef CONFIG_PPC @@ -891,91 +983,22 @@ static inline phys_addr_t map_to_sysmem(const void *ptr) #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) /* - * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It - * is used to align DMA buffers. - */ -#ifndef __ASSEMBLY__ -#include -#endif - -/* - * The ALLOC_CACHE_ALIGN_BUFFER macro is used to allocate a buffer on the - * stack that meets the minimum architecture alignment requirements for DMA. - * Such a buffer is useful for DMA operations where flushing and invalidating - * the cache before and after a read and/or write operation is required for - * correct operations. - * - * When called the macro creates an array on the stack that is sized such - * that: - * - * 1) The beginning of the array can be advanced enough to be aligned. - * - * 2) The size of the aligned portion of the array is a multiple of the minimum - * architecture alignment required for DMA. - * - * 3) The aligned portion contains enough space for the original number of - * elements requested. - * - * The macro then creates a pointer to the aligned portion of this array and - * assigns to the pointer the address of the first element in the aligned - * portion of the array. - * - * Calling the macro as: - * - * ALLOC_CACHE_ALIGN_BUFFER(uint32_t, buffer, 1024); - * - * Will result in something similar to saying: + * check_member() - Check the offset of a structure member * - * uint32_t buffer[1024]; - * - * The following differences exist: - * - * 1) The resulting buffer is guaranteed to be aligned to the value of - * ARCH_DMA_MINALIGN. - * - * 2) The buffer variable created by the macro is a pointer to the specified - * type, and NOT an array of the specified type. This can be very important - * if you want the address of the buffer, which you probably do, to pass it - * to the DMA hardware. The value of &buffer is different in the two cases. - * In the macro case it will be the address of the pointer, not the address - * of the space reserved for the buffer. However, in the second case it - * would be the address of the buffer. So if you are replacing hard coded - * stack buffers with this macro you need to make sure you remove the & from - * the locations where you are taking the address of the buffer. - * - * Note that the size parameter is the number of array elements to allocate, - * not the number of bytes. - * - * This macro can not be used outside of function scope, or for the creation - * of a function scoped static buffer. It can not be used to create a cache - * line aligned global buffer. + * @structure: Name of structure (e.g. global_data) + * @member: Name of member (e.g. baudrate) + * @offset: Expected offset in bytes */ -#define PAD_COUNT(s, pad) (((s) - 1) / (pad) + 1) -#define PAD_SIZE(s, pad) (PAD_COUNT(s, pad) * pad) -#define ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad) \ - char __##name[ROUND(PAD_SIZE((size) * sizeof(type), pad), align) \ - + (align - 1)]; \ - \ - type *name = (type *) ALIGN((uintptr_t)__##name, align) -#define ALLOC_ALIGN_BUFFER(type, name, size, align) \ - ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, 1) -#define ALLOC_CACHE_ALIGN_BUFFER_PAD(type, name, size, pad) \ - ALLOC_ALIGN_BUFFER_PAD(type, name, size, ARCH_DMA_MINALIGN, pad) -#define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \ - ALLOC_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN) +#define check_member(structure, member, offset) _Static_assert( \ + offsetof(struct structure, member) == offset, \ + "`struct " #structure "` offset for `" #member "` is not " #offset) -/* - * DEFINE_CACHE_ALIGN_BUFFER() is similar to ALLOC_CACHE_ALIGN_BUFFER, but it's - * purpose is to allow allocating aligned buffers outside of function scope. - * Usage of this macro shall be avoided or used with extreme care! - */ -#define DEFINE_ALIGN_BUFFER(type, name, size, align) \ - static char __##name[ALIGN(size * sizeof(type), align)] \ - __aligned(align); \ - \ - static type *name = (type *)__##name -#define DEFINE_CACHE_ALIGN_BUFFER(type, name, size) \ - DEFINE_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN) +/* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ +#ifdef CONFIG_EFI_STUB +#define ll_boot_init() false +#else +#define ll_boot_init() true +#endif /* Pull in stuff for the build system */ #ifdef DO_DEPS_ONLY