diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/abort.h | 2 | ||||
-rw-r--r-- | include/asm-generic/barebox.lds.h | 9 | ||||
-rw-r--r-- | include/common.h | 3 | ||||
-rw-r--r-- | include/console.h | 6 | ||||
-rw-r--r-- | include/driver.h | 5 | ||||
-rw-r--r-- | include/efi.h | 10 | ||||
-rw-r--r-- | include/fb.h | 5 | ||||
-rw-r--r-- | include/gui/graphic_utils.h | 19 | ||||
-rw-r--r-- | include/gui/gui.h | 4 | ||||
-rw-r--r-- | include/init.h | 15 | ||||
-rw-r--r-- | include/linux/compiler-clang.h | 12 | ||||
-rw-r--r-- | include/linux/compiler-gcc.h | 227 | ||||
-rw-r--r-- | include/linux/compiler-gcc3.h | 31 | ||||
-rw-r--r-- | include/linux/compiler-gcc4.h | 61 | ||||
-rw-r--r-- | include/linux/compiler-intel.h | 15 | ||||
-rw-r--r-- | include/linux/compiler.h | 99 | ||||
-rw-r--r-- | include/linux/font.h | 35 | ||||
-rw-r--r-- | include/linux/phy.h | 1 | ||||
-rw-r--r-- | include/net.h | 2 | ||||
-rw-r--r-- | include/regulator.h | 1 | ||||
-rw-r--r-- | include/serial/imx-uart.h | 40 | ||||
-rw-r--r-- | include/spi/imx-spi.h | 83 | ||||
-rw-r--r-- | include/tlsf.h | 2 | ||||
-rw-r--r-- | include/xfuncs.h | 8 |
24 files changed, 542 insertions, 153 deletions
diff --git a/include/abort.h b/include/abort.h index 7f14cb0bb5..326467c25f 100644 --- a/include/abort.h +++ b/include/abort.h @@ -3,7 +3,7 @@ #include <asm/barebox.h> -#ifdef ARCH_HAS_DATA_ABORT_MASK +#if defined ARCH_HAS_DATA_ABORT_MASK && !defined __PBL__ /* * data_abort_mask - ignore data aborts diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h index 00d6ecaf54..772058e77d 100644 --- a/include/asm-generic/barebox.lds.h +++ b/include/asm-generic/barebox.lds.h @@ -38,6 +38,15 @@ KEEP(*(.initcall.13)) \ KEEP(*(.initcall.14)) +#define EXITCALLS \ + KEEP(*(.exitcall.0)) \ + KEEP(*(.exitcall.1)) \ + KEEP(*(.exitcall.2)) \ + KEEP(*(.exitcall.3)) \ + KEEP(*(.exitcall.4)) \ + KEEP(*(.exitcall.5)) \ + KEEP(*(.exitcall.6)) + #define BAREBOX_CMDS KEEP(*(SORT_BY_NAME(.barebox_cmd*))) #define BAREBOX_SYMS KEEP(*(__usymtab)) diff --git a/include/common.h b/include/common.h index eef371c4bf..6b9dd4d799 100644 --- a/include/common.h +++ b/include/common.h @@ -116,7 +116,6 @@ extern int (*barebox_main)(void); void __noreturn start_barebox(void); void shutdown_barebox(void); -extern void (*board_shutdown)(void); /* * architectures which have special calling conventions for @@ -124,8 +123,6 @@ extern void (*board_shutdown)(void); */ extern void (*do_execute)(void *func, int argc, char *argv[]); -void arch_shutdown(void); - int run_shell(void); #ifdef CONFIG_SHELL_HUSH diff --git a/include/console.h b/include/console.h index 839ec17e50..a6737c8581 100644 --- a/include/console.h +++ b/include/console.h @@ -83,4 +83,10 @@ unsigned console_get_active(struct console_device *cdev); int console_set_baudrate(struct console_device *cdev, unsigned baudrate); unsigned console_get_baudrate(struct console_device *cdev); +#ifdef CONFIG_PBL_CONSOLE +void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx); +#else +static inline void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx) {} +#endif + #endif diff --git a/include/driver.h b/include/driver.h index 9c6005454c..728f8abb49 100644 --- a/include/driver.h +++ b/include/driver.h @@ -339,11 +339,6 @@ int mem_memmap(struct cdev *cdev, void **map, int flags); /* Use this if you have nothing to do in your drivers probe function */ int dummy_probe(struct device_d *); -/* Iterate over all activated devices (i.e. the ones with drivers and shut - * them down. - */ -void devices_shutdown(void); - int generic_memmap_ro(struct cdev *dev, void **map, int flags); int generic_memmap_rw(struct cdev *dev, void **map, int flags); diff --git a/include/efi.h b/include/efi.h index 9b4f16bd9f..b2e965bae1 100644 --- a/include/efi.h +++ b/include/efi.h @@ -211,7 +211,7 @@ typedef struct { unsigned long *exitdata_size, s16 **exitdata); efi_status_t(EFIAPI *exit)(efi_handle_t handle, efi_status_t exit_status, unsigned long exitdata_size, s16 *exitdata); - void *unload_image; + efi_status_t (EFIAPI *unload_image)(efi_handle_t handle); efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long); void *get_next_monotonic_count; efi_status_t (EFIAPI *stall)(unsigned long usecs); @@ -473,6 +473,10 @@ extern efi_runtime_services_t *RT; #define EFI_BAREBOX_VENDOR_GUID \ EFI_GUID(0x5b91f69c, 0x8b88, 0x4a2b, 0x92, 0x69, 0x5f, 0x1d, 0x80, 0x2b, 0x51, 0x75) +/* for systemd */ +#define EFI_SYSTEMD_VENDOR_GUID \ + EFI_GUID(0x4a67b082, 0x0a4c, 0x41cf, 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f) + extern efi_guid_t efi_file_info_id; extern efi_guid_t efi_simple_file_system_protocol_guid; extern efi_guid_t efi_device_path_protocol_guid; @@ -481,6 +485,8 @@ extern efi_guid_t efi_unknown_device_guid; extern efi_guid_t efi_null_guid; extern efi_guid_t efi_global_variable_guid; extern efi_guid_t efi_block_io_protocol_guid; +extern efi_guid_t efi_barebox_vendor_guid; +extern efi_guid_t efi_systemd_vendor_guid; #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) @@ -622,8 +628,10 @@ static inline int efi_compare_guid(efi_guid_t *a, efi_guid_t *b) return memcmp(a, b, sizeof(efi_guid_t)); } +struct efi_device_path *device_path_from_handle(efi_handle_t Handle); char *device_path_to_str(struct efi_device_path *dev_path); u8 device_path_to_type(struct efi_device_path *dev_path); +char *device_path_to_partuuid(struct efi_device_path *dev_path); const char *efi_guid_string(efi_guid_t *g); diff --git a/include/fb.h b/include/fb.h index 2db6ad6f37..27894db981 100644 --- a/include/fb.h +++ b/include/fb.h @@ -146,6 +146,9 @@ struct display_timings *of_get_display_timings(struct device_node *np); int register_framebuffer(struct fb_info *info); +int fb_enable(struct fb_info *info); +int fb_disable(struct fb_info *info); + #define FBIOGET_SCREENINFO _IOR('F', 1, loff_t) #define FBIO_ENABLE _IO('F', 2) #define FBIO_DISABLE _IO('F', 3) @@ -160,4 +163,6 @@ int edid_to_display_timings(struct display_timings *, unsigned char *edid); void *edid_read_i2c(struct i2c_adapter *adapter); void fb_edid_add_modes(struct fb_info *info); +int register_fbconsole(struct fb_info *fb); + #endif /* __FB_H */ diff --git a/include/gui/graphic_utils.h b/include/gui/graphic_utils.h index 33e0cbfb2f..ab8c3fcff3 100644 --- a/include/gui/graphic_utils.h +++ b/include/gui/graphic_utils.h @@ -11,14 +11,19 @@ #include <gui/image.h> #include <gui/gui.h> -void rgba_blend(struct fb_info *info, struct image *img, void* dest, int height, +u32 gu_hex_to_pixel(struct fb_info *info, u32 color); +u32 gu_rgb_to_pixel(struct fb_info *info, u8 r, u8 g, u8 b, u8 t); +void gu_rgba_blend(struct fb_info *info, struct image *img, void* dest, int height, int width, int startx, int starty, bool is_rgba); -void set_pixel(struct fb_info *info, void *adr, u32 px); -void set_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b); -void set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a); -void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size); -int fb_open(const char * fbdev, struct screen *sc, bool offscreen); +void gu_set_pixel(struct fb_info *info, void *adr, u32 px); +void gu_set_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b); +void gu_set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a); +void gu_memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size); +struct screen *fb_create_screen(struct fb_info *info, bool offscreen); +struct screen *fb_open(const char *fbdev, bool offscreen); void fb_close(struct screen *sc); -void screen_blit(struct screen *sc); +void gu_screen_blit(struct screen *sc); +void gu_invert_area(struct fb_info *info, void *buf, int startx, int starty, int width, + int height); #endif /* __GRAPHIC_UTILS_H__ */ diff --git a/include/gui/gui.h b/include/gui/gui.h index 829d156842..03e60aa0de 100644 --- a/include/gui/gui.h +++ b/include/gui/gui.h @@ -18,7 +18,7 @@ struct surface { struct screen { int fd; - struct fb_info info; + struct fb_info *info; struct surface s; @@ -27,7 +27,7 @@ struct screen { int fbsize; }; -static inline void* gui_screen_redering_buffer(struct screen *sc) +static inline void *gui_screen_render_buffer(struct screen *sc) { if (sc->offscreenbuf) return sc->offscreenbuf; diff --git a/include/init.h b/include/init.h index f619c951d3..527d49afec 100644 --- a/include/init.h +++ b/include/init.h @@ -7,17 +7,24 @@ #define __init #define __initdata #define __initconst +#define __exit +#define __exitdata /* For assembly routines */ #define __BARE_INIT .section ".text_bare_init.text","ax" #ifndef __ASSEMBLY__ typedef int (*initcall_t)(void); +typedef void (*exitcall_t)(void); #define __define_initcall(level,fn,id) \ static initcall_t __initcall_##fn##id __attribute__((__used__)) \ __attribute__((__section__(".initcall." level))) = fn +#define __define_exitcall(level,fn,id) \ + static exitcall_t __exitcall_##fn##id __attribute__((__used__)) \ + __attribute__((__section__(".exitcall." level))) = fn + /* * A "pure" initcall has no dependencies on anything else, and purely @@ -42,6 +49,14 @@ typedef int (*initcall_t)(void); #define environment_initcall(fn) __define_initcall("13",fn,13) #define postenvironment_initcall(fn) __define_initcall("14",fn,14) +#define early_exitcall(fn) __define_exitcall("0",fn,0) +#define predevshutdown_exitcall(fn) __define_exitcall("1",fn,1) +#define devshutdown_exitcall(fn) __define_exitcall("2",fn,2) +#define postdevshutdown_exitcall(fn) __define_exitcall("3",fn,3) +#define prearchshutdown_exitcall(fn) __define_exitcall("4",fn,4) +#define archshutdown_exitcall(fn) __define_exitcall("5",fn,5) +#define postarchshutdown_exitcall(fn) __define_exitcall("6",fn,6) + /* section for code used very early when * - we're not running from where we linked at * - bss not cleared diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h new file mode 100644 index 0000000000..d1e49d52b6 --- /dev/null +++ b/include/linux/compiler-clang.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_COMPILER_H +#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead." +#endif + +/* Some compiler specific definitions are overwritten here + * for Clang compiler + */ + +#ifdef uninitialized_var +#undef uninitialized_var +#define uninitialized_var(x) x = *(&(x)) +#endif diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 73dcf804bc..dfaa7b3e9a 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -5,11 +5,28 @@ /* * Common definitions for all gcc versions go here. */ - +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) /* Optimization barrier */ + /* The "volatile" is due to gcc bugs */ #define barrier() __asm__ __volatile__("": : :"memory") +/* + * This version is i.e. to prevent dead stores elimination on @ptr + * where gcc and llvm may behave differently when otherwise using + * normal barrier(): while gcc behavior gets along with a normal + * barrier(), llvm needs an explicit input variable to be assumed + * clobbered. The issue is as follows: while the inline asm might + * access any memory it wants, the compiler could have fit all of + * @ptr into memory registers instead, and since @ptr never escaped + * from that, it proofed that the inline asm wasn't touching any of + * it. This version works well with both compilers, i.e. we're telling + * the compiler that the inline asm absolutely may see the contents + * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495 + */ +#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory") /* * This macro obfuscates arithmetic on a variable address so that gcc @@ -29,39 +46,63 @@ * the inline assembly constraint from =g to =r, in this particular * case either is valid. */ -#define RELOC_HIDE(ptr, off) \ - ({ unsigned long __ptr; \ - __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ - (typeof(ptr)) (__ptr + (off)); }) +#define RELOC_HIDE(ptr, off) \ +({ \ + unsigned long __ptr; \ + __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ + (typeof(ptr)) (__ptr + (off)); \ +}) +/* Make the optimizer believe the variable can be manipulated arbitrarily. */ +#define OPTIMIZER_HIDE_VAR(var) \ + __asm__ ("" : "=r" (var) : "0" (var)) + +#ifdef __CHECKER__ +#define __must_be_array(a) 0 +#else /* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) +#endif /* * Force always-inline if the user requests it so via the .config, * or if gcc is too old: */ -#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ +#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) -# define inline inline __attribute__((always_inline)) -# define __inline__ __inline__ __attribute__((always_inline)) -# define __inline __inline __attribute__((always_inline)) +#define inline inline __attribute__((always_inline)) notrace +#define __inline__ __inline__ __attribute__((always_inline)) notrace +#define __inline __inline __attribute__((always_inline)) notrace +#else +/* A lot of inline functions can cause havoc with function tracing */ +#define inline inline notrace +#define __inline__ __inline__ notrace +#define __inline __inline notrace #endif -#define __deprecated __attribute__((deprecated)) -#define __packed __attribute__((packed)) -#define __weak __attribute__((weak)) +#define __always_inline inline __attribute__((always_inline)) +#define noinline __attribute__((noinline)) + +#define __deprecated __attribute__((deprecated)) +#define __packed __attribute__((packed)) +#define __weak __attribute__((weak)) +#define __alias(symbol) __attribute__((alias(#symbol))) /* - * it doesn't make sense on ARM (currently the only user of __naked) to trace - * naked functions because then mcount is called without stack and frame pointer - * being set up and there is no chance to restore the lr register to the value - * before mcount was called. + * it doesn't make sense on ARM (currently the only user of __naked) + * to trace naked functions because then mcount is called without + * stack and frame pointer being set up and there is no chance to + * restore the lr register to the value before mcount was called. + * + * The asm() bodies of naked functions often depend on standard calling + * conventions, therefore they must be noinline and noclone. + * + * GCC 4.[56] currently fail to enforce this, so we must do so ourselves. + * See GCC PR44290. */ -#define __naked __attribute__((naked)) notrace +#define __naked __attribute__((naked)) noinline __noclone notrace -#define __noreturn __attribute__((noreturn)) +#define __noreturn __attribute__((noreturn)) /* * From the GCC manual: @@ -73,15 +114,137 @@ * would be. * [...] */ -#define __pure __attribute__((pure)) -#define __aligned(x) __attribute__((aligned(x))) -#define __printf(a,b) __attribute__((format(printf,a,b))) -#define noinline __attribute__((noinline)) -#define __attribute_const__ __attribute__((__const__)) -#define __maybe_unused __attribute__((unused)) -#define __always_unused __attribute__((unused)) - -#define __gcc_header(x) #x -#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h) -#define gcc_header(x) _gcc_header(x) -#include gcc_header(__GNUC__) +#define __pure __attribute__((pure)) +#define __aligned(x) __attribute__((aligned(x))) +#define __printf(a, b) __attribute__((format(printf, a, b))) +#define __scanf(a, b) __attribute__((format(scanf, a, b))) +#define __attribute_const__ __attribute__((__const__)) +#define __maybe_unused __attribute__((unused)) +#define __always_unused __attribute__((unused)) + +/* gcc version specific checks */ + +#if GCC_VERSION < 30200 +# error Sorry, your compiler is too old - please upgrade it. +#endif + +#if GCC_VERSION < 30300 +# define __used __attribute__((__unused__)) +#else +# define __used __attribute__((__used__)) +#endif + +#ifdef CONFIG_GCOV_KERNEL +# if GCC_VERSION < 30400 +# error "GCOV profiling support for gcc versions below 3.4 not included" +# endif /* __GNUC_MINOR__ */ +#endif /* CONFIG_GCOV_KERNEL */ + +#if GCC_VERSION >= 30400 +#define __must_check __attribute__((warn_unused_result)) +#endif + +#if GCC_VERSION >= 40000 + +/* GCC 4.1.[01] miscompiles __weak */ +#ifdef __KERNEL__ +# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101 +# error Your version of gcc miscompiles the __weak directive +# endif +#endif + +#define __used __attribute__((__used__)) +#define __compiler_offsetof(a, b) \ + __builtin_offsetof(a, b) + +#if GCC_VERSION >= 40100 && GCC_VERSION < 40600 +# define __compiletime_object_size(obj) __builtin_object_size(obj, 0) +#endif + +#if GCC_VERSION >= 40300 +/* Mark functions as cold. gcc will assume any path leading to a call + * to them will be unlikely. This means a lot of manual unlikely()s + * are unnecessary now for any paths leading to the usual suspects + * like BUG(), printk(), panic() etc. [but let's keep them for now for + * older compilers] + * + * Early snapshots of gcc 4.3 don't support this and we can't detect this + * in the preprocessor, but we can live with this because they're unreleased. + * Maketime probing would be overkill here. + * + * gcc also has a __attribute__((__hot__)) to move hot functions into + * a special section, but I don't see any sense in this right now in + * the kernel context + */ +#define __cold __attribute__((__cold__)) + +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) + +#ifndef __CHECKER__ +# define __compiletime_warning(message) __attribute__((warning(message))) +# define __compiletime_error(message) __attribute__((error(message))) +#endif /* __CHECKER__ */ +#endif /* GCC_VERSION >= 40300 */ + +#if GCC_VERSION >= 40500 +/* + * Mark a position in code as unreachable. This can be used to + * suppress control flow warnings after asm blocks that transfer + * control elsewhere. + * + * Early snapshots of gcc 4.5 don't support this and we can't detect + * this in the preprocessor, but we can live with this because they're + * unreleased. Really, we need to have autoconf for the kernel. + */ +#define unreachable() __builtin_unreachable() + +/* Mark a function definition as prohibited from being cloned. */ +#define __noclone __attribute__((__noclone__)) + +#endif /* GCC_VERSION >= 40500 */ + +#if GCC_VERSION >= 40600 +/* + * Tell the optimizer that something else uses this function or variable. + */ +#define __visible __attribute__((externally_visible)) +#endif + +/* + * GCC 'asm goto' miscompiles certain code sequences: + * + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 + * + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. + * + * (asm goto is automatically volatile - the naming reflects this.) + */ +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) + +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP +#if GCC_VERSION >= 40400 +#define __HAVE_BUILTIN_BSWAP32__ +#define __HAVE_BUILTIN_BSWAP64__ +#endif +#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600) +#define __HAVE_BUILTIN_BSWAP16__ +#endif +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ + +#if GCC_VERSION >= 50000 +#define KASAN_ABI_VERSION 4 +#elif GCC_VERSION >= 40902 +#define KASAN_ABI_VERSION 3 +#endif + +#endif /* gcc version >= 40000 specific checks */ + +#if !defined(__noclone) +#define __noclone /* not needed */ +#endif + +/* + * A trick to suppress uninitialized variable warning without generating any + * code + */ +#define uninitialized_var(x) x = x diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h deleted file mode 100644 index b721129e04..0000000000 --- a/include/linux/compiler-gcc3.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __LINUX_COMPILER_H -#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead." -#endif - -#if __GNUC_MINOR__ < 2 -# error Sorry, your compiler is too old - please upgrade it. -#endif - -#if __GNUC_MINOR__ >= 3 -# define __used __attribute__((__used__)) -#else -# define __used __attribute__((__unused__)) -#endif - -#if __GNUC_MINOR__ >= 4 -#define __must_check __attribute__((warn_unused_result)) -#endif - -#ifdef CONFIG_GCOV_KERNEL -# if __GNUC_MINOR__ < 4 -# error "GCOV profiling support for gcc versions below 3.4 not included" -# endif /* __GNUC_MINOR__ */ -#endif /* CONFIG_GCOV_KERNEL */ - -/* - * A trick to suppress uninitialized variable warning without generating any - * code - */ -#define uninitialized_var(x) x = x - -#define __always_inline inline __attribute__((always_inline)) diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h deleted file mode 100644 index 94dea3ffbf..0000000000 --- a/include/linux/compiler-gcc4.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __LINUX_COMPILER_H -#error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead." -#endif - -/* GCC 4.1.[01] miscompiles __weak */ -#ifdef __KERNEL__ -# if __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1 -# error Your version of gcc miscompiles the __weak directive -# endif -#endif - -#define __used __attribute__((__used__)) -#define __must_check __attribute__((warn_unused_result)) -#define __compiler_offsetof(a,b) __builtin_offsetof(a,b) -#define __always_inline inline __attribute__((always_inline)) - -/* - * A trick to suppress uninitialized variable warning without generating any - * code - */ -#define uninitialized_var(x) x = x - -#if __GNUC_MINOR__ >= 3 -/* Mark functions as cold. gcc will assume any path leading to a call - to them will be unlikely. This means a lot of manual unlikely()s - are unnecessary now for any paths leading to the usual suspects - like BUG(), printk(), panic() etc. [but let's keep them for now for - older compilers] - - Early snapshots of gcc 4.3 don't support this and we can't detect this - in the preprocessor, but we can live with this because they're unreleased. - Maketime probing would be overkill here. - - gcc also has a __attribute__((__hot__)) to move hot functions into - a special section, but I don't see any sense in this right now in - the kernel context */ -#define __cold __attribute__((__cold__)) - - -#if __GNUC_MINOR__ >= 5 -/* - * Mark a position in code as unreachable. This can be used to - * suppress control flow warnings after asm blocks that transfer - * control elsewhere. - * - * Early snapshots of gcc 4.5 don't support this and we can't detect - * this in the preprocessor, but we can live with this because they're - * unreleased. Really, we need to have autoconf for the kernel. - */ -#define unreachable() __builtin_unreachable() -#endif - -#endif - -#if __GNUC_MINOR__ > 0 -#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) -#endif -#if __GNUC_MINOR__ >= 4 -#define __compiletime_warning(message) __attribute__((warning(message))) -#define __compiletime_error(message) __attribute__((error(message))) -#endif diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index d8e636e560..58daccca90 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -14,18 +14,31 @@ * It uses intrinsics to do the equivalent things. */ #undef barrier +#undef barrier_data #undef RELOC_HIDE +#undef OPTIMIZER_HIDE_VAR #define barrier() __memory_barrier() +#define barrier_data(ptr) barrier() #define RELOC_HIDE(ptr, off) \ ({ unsigned long __ptr; \ __ptr = (unsigned long) (ptr); \ (typeof(ptr)) (__ptr + (off)); }) +/* This should act as an optimization barrier on var. + * Given that this compiler does not have inline assembly, a compiler barrier + * is the best we can do. + */ +#define OPTIMIZER_HIDE_VAR(var) barrier() + /* Intel ECC compiler doesn't support __builtin_types_compatible_p() */ #define __must_be_array(a) 0 #endif -#define uninitialized_var(x) x +#ifndef __HAVE_BUILTIN_BSWAP16__ +/* icc has this, but it's called _bswap16 */ +#define __HAVE_BUILTIN_BSWAP16__ +#define __builtin_bswap16 _bswap16 +#endif diff --git a/include/linux/compiler.h b/include/linux/compiler.h index cc8c4de43e..8f0c292038 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -10,6 +10,7 @@ # define __force __attribute__((force)) # define __nocast __attribute__((nocast)) # define __iomem __attribute__((noderef, address_space(2))) +# define __must_hold(x) __attribute__((context(x,1,1))) # define __acquires(x) __attribute__((context(x,0,1))) # define __releases(x) __attribute__((context(x,1,0))) # define __acquire(x) __context__(x,1) @@ -27,6 +28,7 @@ extern void __chk_io_ptr(const volatile void __iomem *); # define __chk_user_ptr(x) (void)0 # define __chk_io_ptr(x) (void)0 # define __builtin_warning(x, y...) (1) +# define __must_hold(x) # define __acquires(x) # define __releases(x) # define __acquire(x) (void)0 @@ -34,6 +36,10 @@ extern void __chk_io_ptr(const volatile void __iomem *); # define __cond_lock(x,c) (c) #endif +/* Indirect macros required for expanded argument pasting, eg. __LINE__. */ +#define ___PASTE(a,b) a##b +#define __PASTE(a,b) ___PASTE(a,b) + #ifdef __KERNEL__ #ifdef __GNUC__ @@ -49,6 +55,13 @@ extern void __chk_io_ptr(const volatile void __iomem *); # include <linux/compiler-intel.h> #endif +/* Clang compiler defines __GNUC__. So we will overwrite implementations + * coming from above header files here + */ +#ifdef __clang__ +#include <linux/compiler-clang.h> +#endif + /* * Generic compiler-dependent macros required for kernel * build go below this comment. Actual compiler/compiler version @@ -144,6 +157,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); # define barrier() __memory_barrier() #endif +#ifndef barrier_data +# define barrier_data(ptr) barrier() +#endif + /* Unreachable code */ #ifndef unreachable # define unreachable() do { } while (1) @@ -156,6 +173,15 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); (typeof(ptr)) (__ptr + (off)); }) #endif +#ifndef OPTIMIZER_HIDE_VAR +#define OPTIMIZER_HIDE_VAR(var) barrier() +#endif + +/* Not-quite-unique ID. */ +#ifndef __UNIQUE_ID +# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) +#endif + #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ @@ -228,7 +254,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); /* * Rather then using noinline to prevent stack consumption, use - * noinline_for_stack instead. For documentaiton reasons. + * noinline_for_stack instead. For documentation reasons. */ #define noinline_for_stack noinline @@ -270,11 +296,20 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); # define __section(S) __attribute__ ((__section__(#S))) #endif +#ifndef __visible +#define __visible +#endif + /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) #endif +/* Is this type a native word size -- useful for atomic operations */ +#ifndef __native_word +# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) +#endif + /* Compile time object size, -1 for unknown */ #ifndef __compiletime_object_size # define __compiletime_object_size(obj) -1 @@ -284,8 +319,49 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); #endif #ifndef __compiletime_error # define __compiletime_error(message) +/* + * Sparse complains of variable sized arrays due to the temporary variable in + * __compiletime_assert. Unfortunately we can't just expand it out to make + * sparse see a constant array size without breaking compiletime_assert on old + * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether. + */ +# ifndef __CHECKER__ +# define __compiletime_error_fallback(condition) \ + do { ((void)sizeof(char[1 - 2 * condition])); } while (0) +# endif +#endif +#ifndef __compiletime_error_fallback +# define __compiletime_error_fallback(condition) do { } while (0) #endif +#define __compiletime_assert(condition, msg, prefix, suffix) \ + do { \ + bool __cond = !(condition); \ + extern void prefix ## suffix(void) __compiletime_error(msg); \ + if (__cond) \ + prefix ## suffix(); \ + __compiletime_error_fallback(__cond); \ + } while (0) + +#define _compiletime_assert(condition, msg, prefix, suffix) \ + __compiletime_assert(condition, msg, prefix, suffix) + +/** + * compiletime_assert - break build and emit msg if condition is false + * @condition: a compile-time constant condition to check + * @msg: a message to emit if condition is false + * + * In tradition of POSIX assert, this macro will break the build if the + * supplied condition is *false*, emitting the supplied error message if the + * compiler has support to do so. + */ +#define compiletime_assert(condition, msg) \ + _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) + +#define compiletime_assert_atomic_type(t) \ + compiletime_assert(__native_word(t), \ + "Need native word sized stores/loads for atomicity.") + /* * Prevent the compiler from merging or refetching accesses. The compiler * is also forbidden from reordering successive instances of ACCESS_ONCE(), @@ -293,11 +369,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); * to make the compiler aware of ordering is to put the two invocations of * ACCESS_ONCE() in different C statements. * - * This macro does absolutely -nothing- to prevent the CPU from reordering, - * merging, or refetching absolutely anything at any time. Its main intended - * use is to mediate communication between process-level code and irq/NMI - * handlers, all running on the same CPU. + * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE + * on a union member will work as long as the size of the member matches the + * size of the union and the size is smaller than word size. + * + * The major use cases of ACCESS_ONCE used to be (1) Mediating communication + * between process-level code and irq/NMI handlers, all running on the same CPU, + * and (2) Ensuring that the compiler does not fold, spindle, or otherwise + * mutilate accesses that either do not require ordering or that interact + * with an explicit memory barrier or atomic instruction that provides the + * required ordering. + * + * If possible use READ_ONCE()/WRITE_ONCE() instead. */ -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) +#define __ACCESS_ONCE(x) ({ \ + __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \ + (volatile typeof(x) *)&(x); }) +#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) #endif /* __LINUX_COMPILER_H */ diff --git a/include/linux/font.h b/include/linux/font.h new file mode 100644 index 0000000000..62b1879da6 --- /dev/null +++ b/include/linux/font.h @@ -0,0 +1,35 @@ +/* + * font.h -- `Soft' font definitions + * + * Created 1995 by Geert Uytterhoeven + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ + +#ifndef _VIDEO_FONT_H +#define _VIDEO_FONT_H + +#include <param.h> + +struct font_desc { + const char *name; + int width, height; + const void *data; +}; + +extern const struct font_desc font_vga_8x16, + font_7x14, + font_mini_4x6; + +/* Max. length for the name of a predefined font */ +#define MAX_FONT_NAME 32 + +extern const struct font_desc *find_font_enum(int n); +extern struct param_d *add_param_font(struct device_d *dev, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + int *value, void *priv); + +#endif /* _VIDEO_FONT_H */ diff --git a/include/linux/phy.h b/include/linux/phy.h index 9a451a62d8..a64b9b5671 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -297,6 +297,7 @@ int phy_update_status(struct phy_device *phydev); int phy_wait_aneg_done(struct phy_device *phydev); /* Generic PHY support and helper functions */ +int genphy_config_init(struct phy_device *phydev); int genphy_restart_aneg(struct phy_device *phydev); int genphy_config_aneg(struct phy_device *phydev); int genphy_aneg_done(struct phy_device *phydev); diff --git a/include/net.h b/include/net.h index b93e264f54..d7a475132a 100644 --- a/include/net.h +++ b/include/net.h @@ -445,7 +445,7 @@ struct net_connection *net_icmp_new(IPaddr_t dest, rx_handler_f *handler, void net_unregister(struct net_connection *con); -static inline int net_udp_bind(struct net_connection *con, int sport) +static inline int net_udp_bind(struct net_connection *con, uint16_t sport) { con->udp->uh_sport = ntohs(sport); return 0; diff --git a/include/regulator.h b/include/regulator.h index a43d3df540..367e13f05b 100644 --- a/include/regulator.h +++ b/include/regulator.h @@ -6,6 +6,7 @@ struct regulator; struct regulator_dev { struct regulator_ops *ops; + int boot_on; }; struct regulator_ops { diff --git a/include/serial/imx-uart.h b/include/serial/imx-uart.h index 7275e6ac38..d0e5bcc2b8 100644 --- a/include/serial/imx-uart.h +++ b/include/serial/imx-uart.h @@ -125,4 +125,44 @@ static inline int refclock_to_ubmr(int clock_hz) return clock_hz / 1600 - 1; } +static inline void imx_uart_setup(void __iomem *uartbase, + unsigned int refclock) +{ + writel(0x00000000, uartbase + UCR1); + + writel(UCR2_IRTS | UCR2_WS | UCR2_TXEN | UCR2_RXEN | UCR2_SRST, + uartbase + UCR2); + writel(UCR3_DSR | UCR3_DCD | UCR3_RI | UCR3_ADNIMP | UCR3_RXDMUXSEL, + uartbase + UCR3); + writel((0b10 << UFCR_TXTL_SHF) | UFCR_RFDIV1 | (1 << UFCR_RXTL_SHF), + uartbase + UFCR); + + writel(baudrate_to_ubir(CONFIG_BAUDRATE), + uartbase + UBIR); + writel(refclock_to_ubmr(refclock), + uartbase + UBMR); + + writel(UCR1_UARTEN, uartbase + UCR1); +} + +static inline void imx51_uart_setup(void __iomem *uartbase) +{ + imx_uart_setup(uartbase, 54000000); +} + +static inline void imx6_uart_setup(void __iomem *uartbase) +{ + imx_uart_setup(uartbase, 80000000); +} + +static inline void imx_uart_putc(void *base, int c) +{ + if (!(readl(base + UCR1) & UCR1_UARTEN)) + return; + + while (!(readl(base + USR2) & USR2_TXDC)); + + writel(c, base + URTX0); +} + #endif /* __IMX_UART_H__ */ diff --git a/include/spi/imx-spi.h b/include/spi/imx-spi.h new file mode 100644 index 0000000000..560b092bd2 --- /dev/null +++ b/include/spi/imx-spi.h @@ -0,0 +1,83 @@ +#ifndef __SPI_IMX_SPI_H +#define __SPI_IMX_SPI_H + +#define CSPI_0_0_RXDATA 0x00 +#define CSPI_0_0_TXDATA 0x04 +#define CSPI_0_0_CTRL 0x08 +#define CSPI_0_0_INT 0x0C +#define CSPI_0_0_DMA 0x18 +#define CSPI_0_0_STAT 0x0C +#define CSPI_0_0_PERIOD 0x14 +#define CSPI_0_0_TEST 0x10 +#define CSPI_0_0_RESET 0x1C + +#define CSPI_0_0_CTRL_ENABLE (1 << 10) +#define CSPI_0_0_CTRL_MASTER (1 << 11) +#define CSPI_0_0_CTRL_XCH (1 << 9) +#define CSPI_0_0_CTRL_LOWPOL (1 << 5) +#define CSPI_0_0_CTRL_PHA (1 << 6) +#define CSPI_0_0_CTRL_SSCTL (1 << 7) +#define CSPI_0_0_CTRL_HIGHSSPOL (1 << 8) +#define CSPI_0_0_CTRL_CS(x) (((x) & 0x3) << 19) +#define CSPI_0_0_CTRL_BITCOUNT(x) (((x) & 0x1f) << 0) +#define CSPI_0_0_CTRL_DATARATE(x) (((x) & 0x7) << 14) + +#define CSPI_0_0_CTRL_MAXDATRATE 0x10 +#define CSPI_0_0_CTRL_DATAMASK 0x1F +#define CSPI_0_0_CTRL_DATASHIFT 14 + +#define CSPI_0_0_STAT_TE (1 << 0) +#define CSPI_0_0_STAT_TH (1 << 1) +#define CSPI_0_0_STAT_TF (1 << 2) +#define CSPI_0_0_STAT_RR (1 << 4) +#define CSPI_0_0_STAT_RH (1 << 5) +#define CSPI_0_0_STAT_RF (1 << 6) +#define CSPI_0_0_STAT_RO (1 << 7) + +#define CSPI_0_0_PERIOD_32KHZ (1 << 15) + +#define CSPI_0_0_TEST_LBC (1 << 14) + +#define CSPI_0_0_RESET_START (1 << 0) + +#define CSPI_0_7_RXDATA 0x00 +#define CSPI_0_7_TXDATA 0x04 +#define CSPI_0_7_CTRL 0x08 +#define CSPI_0_7_CTRL_ENABLE (1 << 0) +#define CSPI_0_7_CTRL_MASTER (1 << 1) +#define CSPI_0_7_CTRL_XCH (1 << 2) +#define CSPI_0_7_CTRL_POL (1 << 4) +#define CSPI_0_7_CTRL_PHA (1 << 5) +#define CSPI_0_7_CTRL_SSCTL (1 << 6) +#define CSPI_0_7_CTRL_SSPOL (1 << 7) +#define CSPI_0_7_CTRL_CS_SHIFT 12 +#define CSPI_0_7_CTRL_DR_SHIFT 16 +#define CSPI_0_7_CTRL_BL_SHIFT 20 +#define CSPI_0_7_STAT 0x14 +#define CSPI_0_7_STAT_RR (1 << 3) + +#define CSPI_2_3_RXDATA 0x00 +#define CSPI_2_3_TXDATA 0x04 +#define CSPI_2_3_CTRL 0x08 +#define CSPI_2_3_CTRL_ENABLE (1 << 0) +#define CSPI_2_3_CTRL_XCH (1 << 2) +#define CSPI_2_3_CTRL_MODE(cs) (1 << ((cs) + 4)) +#define CSPI_2_3_CTRL_POSTDIV_OFFSET 8 +#define CSPI_2_3_CTRL_PREDIV_OFFSET 12 +#define CSPI_2_3_CTRL_CS(cs) ((cs) << 18) +#define CSPI_2_3_CTRL_BL_OFFSET 20 + +#define CSPI_2_3_CONFIG 0x0c +#define CSPI_2_3_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0)) +#define CSPI_2_3_CONFIG_SCLKPOL(cs) (1 << ((cs) + 4)) +#define CSPI_2_3_CONFIG_SBBCTRL(cs) (1 << ((cs) + 8)) +#define CSPI_2_3_CONFIG_SSBPOL(cs) (1 << ((cs) + 12)) + +#define CSPI_2_3_INT 0x10 +#define CSPI_2_3_INT_TEEN (1 << 0) +#define CSPI_2_3_INT_RREN (1 << 3) + +#define CSPI_2_3_STAT 0x18 +#define CSPI_2_3_STAT_RR (1 << 3) + +#endif /* __SPI_IMX_SPI_H */ diff --git a/include/tlsf.h b/include/tlsf.h index d575e165bf..1917fa111b 100644 --- a/include/tlsf.h +++ b/include/tlsf.h @@ -16,8 +16,6 @@ ** of the document, therefore no GPL restrictions apply. */ -#include <stddef.h> - #if defined(__cplusplus) extern "C" { #endif diff --git a/include/xfuncs.h b/include/xfuncs.h index 940a1d67ed..e3f120a040 100644 --- a/include/xfuncs.h +++ b/include/xfuncs.h @@ -2,6 +2,8 @@ #define __XFUNCS_H #include <linux/types.h> +#include <stdarg.h> +#include <wchar.h> void *xmalloc(size_t size); void *xrealloc(void *ptr, size_t size); @@ -10,5 +12,11 @@ char *xstrdup(const char *s); char *xstrndup(const char *s, size_t size); void* xmemalign(size_t alignment, size_t bytes); void* xmemdup(const void *orig, size_t size); +char *xasprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); +char *xvasprintf(const char *fmt, va_list ap); + +wchar_t *xstrdup_wchar(const wchar_t *src); +wchar_t *xstrdup_char_to_wchar(const char *src); +char *xstrdup_wchar_to_char(const wchar_t *src); #endif /* __XFUNCS_H */ |