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

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