2002-11-02 23:30:20 +00:00
|
|
|
/*
|
2004-01-02 14:00:00 +00:00
|
|
|
* (C) Copyright 2000-2004
|
2002-11-02 23:30:20 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2004-01-04 16:28:35 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2002-11-02 23:30:20 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __COMMON_H_
|
|
|
|
#define __COMMON_H_ 1
|
|
|
|
|
2007-07-05 16:01:39 +00:00
|
|
|
#include <stdio.h>
|
2007-10-04 10:37:06 +00:00
|
|
|
#include <module.h>
|
2002-11-02 23:30:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/string.h>
|
2008-08-11 08:00:03 +00:00
|
|
|
#include <linux/kernel.h>
|
2007-07-05 16:02:16 +00:00
|
|
|
#include <asm/common.h>
|
2002-11-02 23:30:20 +00:00
|
|
|
|
2008-10-31 13:02:25 +00:00
|
|
|
#define pr_info(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
#define pr_notice(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
#define pr_err(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
#define pr_warning(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
#define pr_crit(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
#define pr_alert(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
#define pr_emerg(fmt, arg...) printf(fmt, ##arg)
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define pr_debug(fmt, arg...) printf(UBOOT_DEBUG, fmt, ##arg)
|
2002-11-02 23:30:20 +00:00
|
|
|
#else
|
2008-10-31 13:02:25 +00:00
|
|
|
#define pr_debug(fmt, arg...) do {} while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define debug(fmt, arg...) pr_debug(fmt, ##arg)
|
2002-11-02 23:30:20 +00:00
|
|
|
|
2006-09-01 09:59:23 +00:00
|
|
|
#define BUG() do { \
|
2006-10-08 22:42:01 +00:00
|
|
|
printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
|
2006-09-01 09:59:23 +00:00
|
|
|
panic("BUG!"); \
|
|
|
|
} while (0)
|
|
|
|
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
|
|
|
|
|
2004-01-06 22:38:14 +00:00
|
|
|
typedef void (interrupt_handler_t)(void *);
|
2002-11-02 23:30:20 +00:00
|
|
|
|
2004-01-06 22:38:14 +00:00
|
|
|
#include <asm/u-boot.h> /* boot information for Linux kernel */
|
2002-11-02 23:30:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function Prototypes
|
|
|
|
*/
|
2007-07-05 16:02:14 +00:00
|
|
|
void reginfo(void);
|
2002-11-02 23:30:20 +00:00
|
|
|
|
2007-07-05 16:02:16 +00:00
|
|
|
void hang (void) __attribute__ ((noreturn));
|
|
|
|
void panic(const char *fmt, ...);
|
2002-11-02 23:30:20 +00:00
|
|
|
|
|
|
|
/* */
|
|
|
|
long int initdram (int);
|
2007-09-26 13:23:46 +00:00
|
|
|
char *size_human_readable(ulong size);
|
2002-11-02 23:30:20 +00:00
|
|
|
|
|
|
|
/* common/main.c */
|
|
|
|
int run_command (const char *cmd, int flag);
|
2007-07-05 16:01:48 +00:00
|
|
|
int readline (const char *prompt, char *buf, int len);
|
2003-07-24 23:38:38 +00:00
|
|
|
|
2004-01-06 22:38:14 +00:00
|
|
|
/* common/memsize.c */
|
2006-11-06 16:06:36 +00:00
|
|
|
long get_ram_size (volatile long *, long);
|
2004-01-06 22:38:14 +00:00
|
|
|
|
2002-11-02 23:30:20 +00:00
|
|
|
/* $(CPU)/cpu.c */
|
2005-04-03 17:23:39 +00:00
|
|
|
void reset_cpu (ulong addr);
|
2002-11-02 23:30:20 +00:00
|
|
|
|
|
|
|
/* $(CPU)/interrupts.c */
|
2007-07-05 16:01:43 +00:00
|
|
|
//void timer_interrupt (struct pt_regs *);
|
|
|
|
//void external_interrupt (struct pt_regs *);
|
2002-11-02 23:30:20 +00:00
|
|
|
void irq_install_handler(int, interrupt_handler_t *, void *);
|
|
|
|
void irq_free_handler (int);
|
2008-04-04 09:24:38 +00:00
|
|
|
#ifdef CONFIG_USE_IRQ
|
2002-11-02 23:30:20 +00:00
|
|
|
void enable_interrupts (void);
|
|
|
|
int disable_interrupts (void);
|
2007-07-05 16:02:08 +00:00
|
|
|
#else
|
|
|
|
#define enable_interrupts() do {} while (0)
|
|
|
|
#define disable_interrupts() 0
|
|
|
|
#endif
|
2002-11-02 23:30:20 +00:00
|
|
|
|
2003-10-09 19:00:25 +00:00
|
|
|
/* lib_$(ARCH)/time.c */
|
2007-07-05 16:02:16 +00:00
|
|
|
void udelay (unsigned long);
|
|
|
|
void mdelay (unsigned long);
|
2002-11-02 23:30:20 +00:00
|
|
|
|
2007-07-05 20:12:11 +00:00
|
|
|
int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
|
|
|
|
|
2003-10-09 19:00:25 +00:00
|
|
|
/* lib_generic/vsprintf.c */
|
2002-11-02 23:30:20 +00:00
|
|
|
ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
|
2004-03-14 22:25:36 +00:00
|
|
|
#ifdef CFG_64BIT_VSPRINTF
|
2004-03-13 23:29:43 +00:00
|
|
|
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
|
|
|
|
#endif
|
2002-11-02 23:30:20 +00:00
|
|
|
long simple_strtol(const char *cp,char **endp,unsigned int base);
|
|
|
|
|
2003-10-09 19:00:25 +00:00
|
|
|
/* lib_generic/crc32.c */
|
2002-11-02 23:30:20 +00:00
|
|
|
ulong crc32 (ulong, const unsigned char *, uint);
|
|
|
|
ulong crc32_no_comp (ulong, const unsigned char *, uint);
|
|
|
|
|
|
|
|
/* common/console.c */
|
|
|
|
int ctrlc (void);
|
|
|
|
|
2007-07-05 16:01:23 +00:00
|
|
|
#define MEMAREA_SIZE_SPECIFIED 1
|
|
|
|
|
|
|
|
struct memarea_info {
|
|
|
|
struct device_d *device;
|
|
|
|
unsigned long start;
|
|
|
|
unsigned long end;
|
|
|
|
unsigned long size;
|
|
|
|
unsigned long flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
int spec_str_to_info(const char *str, struct memarea_info *info);
|
2007-07-05 16:01:39 +00:00
|
|
|
int parse_area_spec(const char *str, ulong *start, ulong *size);
|
2007-07-05 16:01:23 +00:00
|
|
|
|
|
|
|
/* Just like simple_strtoul(), but this one honors a K/M/G suffix */
|
|
|
|
unsigned long strtoul_suffix(const char *str, char **endp, int base);
|
|
|
|
|
2007-09-16 09:16:08 +00:00
|
|
|
void start_uboot(void);
|
2009-02-21 00:17:10 +00:00
|
|
|
void shutdown_uboot(void);
|
2007-09-16 09:16:08 +00:00
|
|
|
|
|
|
|
int arch_execute(unsigned long address, int argc, char *argv[]);
|
2007-07-05 16:01:29 +00:00
|
|
|
|
2007-09-23 23:40:06 +00:00
|
|
|
int run_shell(void);
|
|
|
|
|
2007-09-28 17:46:37 +00:00
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
|
2007-10-11 13:59:01 +00:00
|
|
|
/**
|
|
|
|
* 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) );})
|
|
|
|
|
2002-11-02 23:30:20 +00:00
|
|
|
#endif /* __COMMON_H_ */
|