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.19  2008/02/15 17:00:24  haraldkipp
00039  * Spport for AT91SAM7SE512 added.
00040  *
00041  * Revision 1.18  2007/10/04 20:29:08  olereinhardt
00042  * Support for SAM7S256 added
00043  *
00044  * Revision 1.17  2007/05/02 11:32:07  haraldkipp
00045  * Mapping of Harvard specific stdio functions moved to stdio.h and io.h.
00046  *
00047  * Revision 1.16  2006/08/31 19:04:08  haraldkipp
00048  * Added support for the AT91SAM9260 and Atmel's AT91SAM9260 Evaluation Kit.
00049  *
00050  * Revision 1.15  2006/08/05 11:58:22  haraldkipp
00051  * Missing brackets may result in unexpected expansion of the _BV() macro.
00052  *
00053  * Revision 1.14  2006/08/01 07:35:59  haraldkipp
00054  * Exclude function prototypes when included by assembler.
00055  *
00056  * Revision 1.13  2006/07/21 09:08:58  haraldkipp
00057  * Map puts_P to puts and _write_P to _write for non-Harvard architectures.
00058  *
00059  * Revision 1.12  2006/07/10 14:27:03  haraldkipp
00060  * C++ will use main instead of NutAppMain. Contributed by Matthias Wilde.
00061  *
00062  * Revision 1.11  2006/07/05 07:45:25  haraldkipp
00063  * Split on-chip interface definitions.
00064  *
00065  * Revision 1.10  2006/06/28 17:22:34  haraldkipp
00066  * Make it compile for AT91SAM7X256.
00067  *
00068  * Revision 1.9  2006/05/25 09:35:27  haraldkipp
00069  * Dummy macros added to support the avr-libc special function register
00070  * definitions.
00071  *
00072  * Revision 1.8  2006/03/16 15:25:26  haraldkipp
00073  * Changed human readable strings from u_char to char to stop GCC 4 from
00074  * nagging about signedness.
00075  *
00076  * Revision 1.7  2006/03/02 20:02:05  haraldkipp
00077  * Added a few macros to allow compilation with ICCARM.
00078  *
00079  * Revision 1.6  2006/02/23 15:34:00  haraldkipp
00080  * Support for Philips LPC2xxx Family and LPC-E2294 Board from Olimex added.
00081  * Many thanks to Michael Fischer for this port.
00082  *
00083  * Revision 1.5  2005/11/20 14:45:15  haraldkipp
00084  * Define printf_P for non Harvard architectures.
00085  *
00086  * Revision 1.4  2005/10/24 18:03:02  haraldkipp
00087  * GameBoy header file added.
00088  *
00089  * Revision 1.3  2005/10/24 10:35:05  haraldkipp
00090  * Port I/O macros added.
00091  *
00092  * Revision 1.2  2004/09/08 10:24:26  haraldkipp
00093  * RAMSTART is too platform dependant
00094  *
00095  * Revision 1.1  2004/03/16 16:48:28  haraldkipp
00096  * Added Jan Dubiec's H8/300 port.
00097  *
00098  * Revision 1.1  2004/02/01 18:49:47  haraldkipp
00099  * Added CPU family support
00100  *
00101  */
00102 
00103 #include <cfg/arch.h>
00104 #if defined (MCU_AT91R40008) || defined (MCU_AT91SAM7X256) || defined (MCU_AT91SAM9260) || defined (MCU_AT91SAM7S256) || defined(MCU_AT91SAM7SE512)
00105 #include <arch/arm/at91.h>
00106 #elif defined (MCU_GBA)
00107 #include <arch/arm/gba.h>
00108 #elif defined (MCU_LPC2XXX)
00109 #include <arch/arm/lpc2xxx.h>
00110 #endif
00111 
00112 #ifndef __ASSEMBLER__
00113 #include <dev/mweeprom.h>
00114 #endif
00115 
00116 #define ARM_MODE_USER       0x10
00117 #define ARM_MODE_FIQ        0x11
00118 #define ARM_MODE_IRQ        0x12
00119 #define ARM_MODE_SVC        0x13
00120 #define ARM_MODE_ABORT      0x17
00121 #define ARM_MODE_UNDEF      0x1B
00122 #define ARM_MODE_SYS        0x1F
00123 #define ARM_MODE_MASK       0x1F
00124 
00125 #define I_BIT               0x80
00126 #define F_BIT               0x40
00127 #define T_BIT               0x20
00128 
00129 #ifdef __GNUC__
00130 #define CONST      const
00131 #define INLINE     inline
00132 #else
00133 #ifndef CONST
00134 #define CONST      const
00135 #endif
00136 #ifndef INLINE
00137 #define INLINE
00138 #endif
00139 #endif
00140 
00141 #define PSTR(p)    (p)
00142 #define PRG_RDB(p) (*((const char *)(p)))
00143 
00144 #define prog_char  const char
00145 #define PGM_P      prog_char *
00146 
00147 #define SIGNAL(x)  __attribute__((interrupt_handler)) void x(void)
00148 #define RAMFUNC __attribute__ ((long_call, section (".ramfunc")))
00149 
00150 #if !defined(__arm__) && !defined(__cplusplus)
00151 #define main       NutAppMain
00152 #endif
00153 
00154 #define strlen_P(x)             strlen((char *)(x))
00155 #define strcpy_P(x,y)           strcpy(x,(char *)(y))
00156 
00157 #define strcmp_P(x, y)          strcmp((char *)(x), (char *)(y))
00158 #define memcpy_P(x, y, z)       memcpy(x, y, z)
00159 
00160 #ifndef __ASSEMBLER__
00161 
00164 extern void *__bss_end;
00165 
00169 extern void *__stack;
00170 #endif
00171 
00172 #ifndef _NOP
00173 #ifdef __GNUC__
00174 #define _NOP() __asm__ __volatile__ ("mov r0, r0")
00175 #else
00176 #define _NOP() asm("mov r0, r0")
00177 #endif
00178 #endif
00179 
00180 #define outb(_reg, _val)  (*((volatile unsigned char *)(_reg)) = (_val))
00181 #define outw(_reg, _val)  (*((volatile unsigned short *)(_reg)) = (_val))
00182 #define outr(_reg, _val)  (*((volatile unsigned int *)(_reg)) = (_val))
00183 
00184 #define inb(_reg)   (*((volatile unsigned char *)(_reg)))
00185 #define inw(_reg)   (*((volatile unsigned short *)(_reg)))
00186 #define inr(_reg)   (*((volatile unsigned int *)(_reg)))
00187 
00188 #define _BV(bit)    (1 << (bit))
00189 
00190 #ifdef __IMAGECRAFT__
00191 #define __attribute__(x)
00192 #endif
00193 
00194 #define _SFR_MEM8(addr)     (addr)
00195 #define _SFR_MEM16(addr)    (addr)
00196 
00197 #endif

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