arm.h

Go to the documentation of this file.
00001 #ifndef _ARCH_ARM_H_
00002 #define _ARCH_ARM_H_
00003 
00004 /*
00005  * Copyright (C) 2001-2006 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00024  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  */
00035 
00036 /*
00037  * $Log: arm.h,v $
00038  * Revision 1.20  2008/08/06 12:51:09  haraldkipp
00039  * Added support for Ethernut 5 (AT91SAM9XE reference design).
00040  *
00041  * Revision 1.19  2008/02/15 17:00:24  haraldkipp
00042  * Spport for AT91SAM7SE512 added.
00043  *
00044  * Revision 1.18  2007/10/04 20:29:08  olereinhardt
00045  * Support for SAM7S256 added
00046  *
00047  * Revision 1.17  2007/05/02 11:32:07  haraldkipp
00048  * Mapping of Harvard specific stdio functions moved to stdio.h and io.h.
00049  *
00050  * Revision 1.16  2006/08/31 19:04:08  haraldkipp
00051  * Added support for the AT91SAM9260 and Atmel's AT91SAM9260 Evaluation Kit.
00052  *
00053  * Revision 1.15  2006/08/05 11:58:22  haraldkipp
00054  * Missing brackets may result in unexpected expansion of the _BV() macro.
00055  *
00056  * Revision 1.14  2006/08/01 07:35:59  haraldkipp
00057  * Exclude function prototypes when included by assembler.
00058  *
00059  * Revision 1.13  2006/07/21 09:08:58  haraldkipp
00060  * Map puts_P to puts and _write_P to _write for non-Harvard architectures.
00061  *
00062  * Revision 1.12  2006/07/10 14:27:03  haraldkipp
00063  * C++ will use main instead of NutAppMain. Contributed by Matthias Wilde.
00064  *
00065  * Revision 1.11  2006/07/05 07:45:25  haraldkipp
00066  * Split on-chip interface definitions.
00067  *
00068  * Revision 1.10  2006/06/28 17:22:34  haraldkipp
00069  * Make it compile for AT91SAM7X256.
00070  *
00071  * Revision 1.9  2006/05/25 09:35:27  haraldkipp
00072  * Dummy macros added to support the avr-libc special function register
00073  * definitions.
00074  *
00075  * Revision 1.8  2006/03/16 15:25:26  haraldkipp
00076  * Changed human readable strings from u_char to char to stop GCC 4 from
00077  * nagging about signedness.
00078  *
00079  * Revision 1.7  2006/03/02 20:02:05  haraldkipp
00080  * Added a few macros to allow compilation with ICCARM.
00081  *
00082  * Revision 1.6  2006/02/23 15:34:00  haraldkipp
00083  * Support for Philips LPC2xxx Family and LPC-E2294 Board from Olimex added.
00084  * Many thanks to Michael Fischer for this port.
00085  *
00086  * Revision 1.5  2005/11/20 14:45:15  haraldkipp
00087  * Define printf_P for non Harvard architectures.
00088  *
00089  * Revision 1.4  2005/10/24 18:03:02  haraldkipp
00090  * GameBoy header file added.
00091  *
00092  * Revision 1.3  2005/10/24 10:35:05  haraldkipp
00093  * Port I/O macros added.
00094  *
00095  * Revision 1.2  2004/09/08 10:24:26  haraldkipp
00096  * RAMSTART is too platform dependant
00097  *
00098  * Revision 1.1  2004/03/16 16:48:28  haraldkipp
00099  * Added Jan Dubiec's H8/300 port.
00100  *
00101  * Revision 1.1  2004/02/01 18:49:47  haraldkipp
00102  * Added CPU family support
00103  *
00104  */
00105 
00106 #include <cfg/arch.h>
00107 #if defined (MCU_AT91R40008) || defined (MCU_AT91SAM7X256) || defined (MCU_AT91SAM9260) || defined (MCU_AT91SAM7S256) || defined(MCU_AT91SAM7SE512) || defined(MCU_AT91SAM9XE512)
00108 #include <arch/arm/at91.h>
00109 #elif defined (MCU_GBA)
00110 #include <arch/arm/gba.h>
00111 #elif defined (MCU_LPC2XXX)
00112 #include <arch/arm/lpc2xxx.h>
00113 #endif
00114 
00115 #ifndef __ASSEMBLER__
00116 #include <dev/mweeprom.h>
00117 #endif
00118 
00119 #define ARM_MODE_USER       0x10
00120 #define ARM_MODE_FIQ        0x11
00121 #define ARM_MODE_IRQ        0x12
00122 #define ARM_MODE_SVC        0x13
00123 #define ARM_MODE_ABORT      0x17
00124 #define ARM_MODE_UNDEF      0x1B
00125 #define ARM_MODE_SYS        0x1F
00126 #define ARM_MODE_MASK       0x1F
00127 
00128 #define I_BIT               0x80
00129 #define F_BIT               0x40
00130 #define T_BIT               0x20
00131 
00132 #ifdef __GNUC__
00133 #define CONST      const
00134 #define INLINE     inline
00135 #else
00136 #ifndef CONST
00137 #define CONST      const
00138 #endif
00139 #ifndef INLINE
00140 #define INLINE
00141 #endif
00142 #endif
00143 
00144 #define PSTR(p)    (p)
00145 #define PRG_RDB(p) (*((const char *)(p)))
00146 
00147 #define prog_char  const char
00148 #define PGM_P      prog_char *
00149 
00150 #define SIGNAL(x)  __attribute__((interrupt_handler)) void x(void)
00151 #define RAMFUNC __attribute__ ((long_call, section (".ramfunc")))
00152 
00153 #if !defined(__arm__) && !defined(__cplusplus)
00154 #define main       NutAppMain
00155 #endif
00156 
00157 #define strlen_P(x)             strlen((char *)(x))
00158 #define strcpy_P(x,y)           strcpy(x,(char *)(y))
00159 
00160 #define strcmp_P(x, y)          strcmp((char *)(x), (char *)(y))
00161 #define memcpy_P(x, y, z)       memcpy(x, y, z)
00162 
00163 #ifndef __ASSEMBLER__
00164 
00167 extern void *__bss_end;
00168 
00172 extern void *__stack;
00173 #endif
00174 
00175 #ifndef _NOP
00176 #ifdef __GNUC__
00177 #define _NOP() __asm__ __volatile__ ("mov r0, r0")
00178 #else
00179 #define _NOP() asm("mov r0, r0")
00180 #endif
00181 #endif
00182 
00183 #define outb(_reg, _val)  (*((volatile unsigned char *)(_reg)) = (_val))
00184 #define outw(_reg, _val)  (*((volatile unsigned short *)(_reg)) = (_val))
00185 #define outr(_reg, _val)  (*((volatile unsigned int *)(_reg)) = (_val))
00186 
00187 #define inb(_reg)   (*((volatile unsigned char *)(_reg)))
00188 #define inw(_reg)   (*((volatile unsigned short *)(_reg)))
00189 #define inr(_reg)   (*((volatile unsigned int *)(_reg)))
00190 
00191 #define _BV(bit)    (1 << (bit))
00192 
00193 #ifdef __IMAGECRAFT__
00194 #define __attribute__(x)
00195 #endif
00196 
00197 #define _SFR_MEM8(addr)     (addr)
00198 #define _SFR_MEM16(addr)    (addr)
00199 
00200 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/