00001 /***************************************************************************** 00002 *! 00003 *! FILE NAME : lib.h 00004 *! 00005 *! DESCRIPTION: Small practical functions for boot loader. 00006 *! malloc/free 00007 *! memcpy/memset 00008 *! writeb/writew/readb/readw 00009 *! putc/puts/putnybble/putx 00010 *! error/error2 00011 *! serial_init 00012 *! 00013 *! --------------------------------------------------------------------------- 00014 *! 00015 *! malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 00016 *! puts by Nick Holloway 1993, better puts by Martin Mares 1995 00017 *! adoptation for Linux/CRIS Axis Communications AB, 1999 00018 *! 00019 *! Other parts (C) Copyright 2006-2007, Axis Communications AB, LUND, SWEDEN 00020 *! 00021 *! This program is free software; you can redistribute it and/or modify 00022 *! it under the terms of the GNU General Public License as published by 00023 *! the Free Software Foundation; either version 2 of the License, or 00024 *! (at your option) any later version. 00025 *! 00026 *! This program is distributed in the hope that it will be useful, 00027 *! but WITHOUT ANY WARRANTY; without even the implied warranty of 00028 *! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00029 *! GNU General Public License for more details. 00030 *! 00031 *! You should have received a copy of the GNU General Public License 00032 *! along with this program; if not, write to the Free Software 00033 *! Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00034 *! 00035 *!***************************************************************************/ 00036 00037 #ifndef _LIB_H 00038 #define _LIB_H 00039 00040 #include <linux/types.h> 00041 00042 /* nice stuff we need without having any library around */ 00043 00044 void* memset(void* s, int c, size_t n); 00045 void* memcpy(void* __dest, __const void* __src, size_t __n); 00046 00047 #define memzero(s, n) memset((s), 0, (n)) 00048 00049 void *malloc(unsigned int size); 00050 void free(void *where); 00051 void error(const char *m) __attribute__ ((noreturn)); 00052 void error2(const char *m, int l, const char *f) __attribute__ ((noreturn)); 00053 void serial_init(void); 00054 00055 void putc(const char); 00056 void puts(const char *); 00057 void putnybble(unsigned int n); 00058 void putx(unsigned int x); 00059 void putnl(); 00060 00061 #define GPIO_SYNC 0 00062 unsigned char readb(const volatile void *addr); 00063 unsigned short readw(const volatile void *addr); 00064 void writeb(unsigned char b, volatile void *addr); 00065 void writew(unsigned short b, volatile void *addr); 00066 00067 #endif /* _LIB_H */