]> git.sur5r.net Git - u-boot/blobdiff - include/common.h
RTC: Fix Makefile problem with COBJS-$(CONFIG_RTC_DS1307 || CONFIG_RTC_DS1338)
[u-boot] / include / common.h
index c4ee3e2df68247b545c6dc300deaa8439639f9d6..de3d595ed25c5ae63d6f1a5ba42bcabcc96bd903 100644 (file)
@@ -103,6 +103,9 @@ typedef volatile unsigned char      vu_char;
 #ifdef CONFIG_ARM
 #define asmlinkage     /* nothing */
 #endif
+#ifdef CONFIG_BLACKFIN
+#include <asm/blackfin.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
@@ -116,11 +119,13 @@ typedef volatile unsigned char    vu_char;
 #define debugX(level,fmt,args...)
 #endif /* DEBUG */
 
+#ifndef BUG
 #define BUG() do { \
        printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
        panic("BUG!"); \
 } while (0)
 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
+#endif /* BUG */
 
 typedef void (interrupt_handler_t)(void *);
 
@@ -173,6 +178,17 @@ typedef void (interrupt_handler_t)(void *);
                (__x > __y) ? __x : __y; })
 
 
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:       the pointer to the member.
+ * @type:      the type of the container struct this is embedded in.
+ * @member:    the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({                     \
+       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+       (type *)( (char *)__mptr - offsetof(type,member) );})
+
 /*
  * Function Prototypes
  */
@@ -188,9 +204,9 @@ int serial_buffered_tstc (void);
 void   hang            (void) __attribute__ ((noreturn));
 
 /* */
-long int initdram (int);
+phys_size_t initdram (int);
 int    display_options (void);
-void   print_size (ulong, const char *);
+void   print_size (phys_size_t, const char *);
 int    print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);
 
 /* common/main.c */
@@ -203,26 +219,20 @@ void      init_cmd_timeout(void);
 void   reset_cmd_timeout(void);
 
 /* lib_$(ARCH)/board.c */
-void   board_init_f  (ulong);
-void   board_init_r  (gd_t *, ulong);
+void   board_init_f  (ulong) __attribute__ ((noreturn));
+void   board_init_r  (gd_t *, ulong) __attribute__ ((noreturn));
 int    checkboard    (void);
 int    checkflash    (void);
 int    checkdram     (void);
-char * strmhz(char *buf, long hz);
 int    last_stage_init(void);
 extern ulong monitor_flash_len;
-#ifdef CFG_ID_EEPROM
 int mac_read_from_eeprom(void);
-#endif
 
 /* common/flash.c */
 void flash_perror (int);
 
 /* common/cmd_autoscript.c */
-int    autoscript (ulong addr);
-
-/* common/cmd_bootm.c */
-void   print_image_hdr (image_header_t *hdr);
+int    autoscript (ulong addr, const char *fit_uname);
 
 extern ulong load_addr;                /* Default Load Address */
 
@@ -234,9 +244,9 @@ char        *getenv      (char *);
 int    getenv_r     (char *name, char *buf, unsigned len);
 int    saveenv      (void);
 #ifdef CONFIG_PPC              /* ARM version to be fixed! */
-void inline setenv   (char *, char *);
+int inline setenv   (char *, char *);
 #else
-void   setenv       (char *, char *);
+int    setenv       (char *, char *);
 #ifdef CONFIG_HAS_UID
 void   forceenv     (char *, char *);
 #endif
@@ -270,7 +280,9 @@ void        pciinfo       (int, int);
        void    pci_master_init      (struct pci_controller *);
 #   endif
     int            is_pci_host         (struct pci_controller *);
-#if defined(CONFIG_440SPE) || defined(CONFIG_405EX)
+#if defined(CONFIG_440SPE) || \
+    defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
+    defined(CONFIG_405EX)
    void pcie_setup_hoses(int busno);
 #endif
 #endif
@@ -388,7 +400,7 @@ void        icache_disable(void);
 int    dcache_status (void);
 void   dcache_enable (void);
 void   dcache_disable(void);
-void   relocate_code (ulong, gd_t *, ulong);
+void   relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
 ulong  get_endaddr   (void);
 void   trap_init     (ulong);
 #if defined (CONFIG_4xx)       || \
@@ -596,13 +608,19 @@ ulong     simple_strtoul(const char *cp,char **endp,unsigned int base);
 unsigned long long     simple_strtoull(const char *cp,char **endp,unsigned int base);
 #endif
 long   simple_strtol(const char *cp,char **endp,unsigned int base);
-void   panic(const char *fmt, ...);
-int    sprintf(char * buf, const char *fmt, ...);
+void   panic(const char *fmt, ...)
+               __attribute__ ((format (__printf__, 1, 2)));
+int    sprintf(char * buf, const char *fmt, ...)
+               __attribute__ ((format (__printf__, 2, 3)));
 int    vsprintf(char *buf, const char *fmt, va_list args);
 
+/* lib_generic/strmhz.c */
+char * strmhz(char *buf, long hz);
+
 /* lib_generic/crc32.c */
-ulong crc32 (ulong, const unsigned char *, uint);
-ulong crc32_no_comp (ulong, const unsigned char *, uint);
+uint32_t crc32 (uint32_t, const unsigned char *, uint);
+uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
+uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
 
 /* common/console.c */
 int    console_init_f(void);   /* Before relocation; uses the serial  stuff    */
@@ -618,7 +636,8 @@ int disable_ctrlc (int);    /* 1 to disable, 0 to enable Control-C detect */
  */
 
 /* serial stuff */
-void   serial_printf (const char *fmt, ...);
+void   serial_printf (const char *fmt, ...)
+               __attribute__ ((format (__printf__, 1, 2)));
 
 /* stdin */
 int    getc(void);
@@ -627,7 +646,8 @@ int tstc(void);
 /* stdout */
 void   putc(const char c);
 void   puts(const char *s);
-void   printf(const char *fmt, ...);
+void   printf(const char *fmt, ...)
+               __attribute__ ((format (__printf__, 1, 2)));
 void   vprintf(const char *fmt, va_list args);
 
 /* stderr */
@@ -644,7 +664,8 @@ void        vprintf(const char *fmt, va_list args);
 #define stderr         2
 #define MAX_FILES      3
 
-void   fprintf(int file, const char *fmt, ...);
+void   fprintf(int file, const char *fmt, ...)
+               __attribute__ ((format (__printf__, 2, 3)));
 void   fputs(int file, const char *s);
 void   fputc(int file, const char c);
 int    ftstc(int file);
@@ -658,11 +679,30 @@ int       pcmcia_init (void);
 /*
  * Board-specific Platform code can reimplement show_boot_progress () if needed
  */
-void inline show_boot_progress (int val);
+void __attribute__((weak)) show_boot_progress (int val);
 
 #ifdef CONFIG_INIT_CRITICAL
 #error CONFIG_INIT_CRITICAL is deprecated!
 #error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
 #endif
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+
+#define ALIGN(x,a)             __ALIGN_MASK((x),(typeof(x))(a)-1)
+#define __ALIGN_MASK(x,mask)   (((x)+(mask))&~(mask))
+
+/* Multicore arch functions */
+#ifdef CONFIG_MP
+int cpu_status(int nr);
+int cpu_reset(int nr);
+int cpu_release(int nr, int argc, char *argv[]);
+#endif
+
+#ifdef CONFIG_POST
+#define CONFIG_HAS_POST
+#endif
+
 #endif /* __COMMON_H_ */