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

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