4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2004, 2005, 2006, 2007, 2008 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 2004 Giovanni Bajo
33 * \brief CPU-specific attributes.
35 * \author Giovanni Bajo <rasky@develer.com>
36 * \author Bernie Innocenti <bernie@codewiz.org>
37 * \author Stefano Fedrigo <aleph@develer.com>
38 * \author Francesco Sacchi <batt@develer.com>
45 #include "cfg/cfg_attr.h" /* CONFIG_FAST_MEM */
49 * \name Macros for determining CPU endianness.
52 #define CPU_BIG_ENDIAN 0x1234
53 #define CPU_LITTLE_ENDIAN 0x3412 /* Look twice, pal. This is not a bug. */
56 /** Macro to include cpu-specific versions of the headers. */
57 #define CPU_HEADER(module) PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).h)
59 /** Macro to include cpu-specific versions of implementation files. */
60 #define CPU_CSOURCE(module) PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).c)
65 #define NOP nop_instruction()
67 #define CPU_REG_BITS 16
68 #define CPU_REGS_CNT 16
69 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
72 /// Valid pointers should be >= than this value (used for debug)
73 #define CPU_RAM_START 0x100
77 #define CPU_REGS_CNT 7
78 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
82 #define CPU_REG_BITS 64
85 /* WIN64 is an IL32-P64 weirdo. */
89 #define CPU_REG_BITS 32
92 /// Valid pointers should be >= than this value (used for debug)
93 #define CPU_RAM_START 0x1000
96 #define NOP asm volatile ("nop")
97 #define BREAKPOINT asm volatile ("int3" ::)
102 #define CPU_REG_BITS 32
103 #define CPU_REGS_CNT 16
104 #define CPU_HARVARD 0
106 /// Valid pointers should be >= than this value (used for debug)
107 #define CPU_RAM_START 0x200
109 #ifdef __IAR_SYSTEMS_ICC__
110 #warning Check CPU_BYTE_ORDER
111 #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
113 #define NOP __no_operation()
115 #else /* GCC and compatibles */
117 #if defined(__ARMEB__)
118 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
119 #elif defined(__ARMEL__)
120 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
122 #error Unable to detect ARM endianness!
125 #define NOP asm volatile ("mov r0,r0" ::)
126 #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */
130 * Function attribute for use with performance critical code.
132 * On the AT91 family, code residing in flash has wait states.
133 * Moving functions to the data section is a quick & dirty way
134 * to get them transparently copied to SRAM for zero-wait-state
137 #define FAST_FUNC __attribute__((section(".data")))
140 * Data attribute to move constant data to fast memory storage.
144 #define FAST_RODATA __attribute__((section(".data")))
146 #else // !CONFIG_FAST_MEM
147 #define FAST_RODATA /**/
148 #define FAST_FUNC /**/
152 * Function attribute to declare an interrupt service routine.
154 #define ISR_FUNC __attribute__((interrupt))
156 #endif /* !__IAR_SYSTEMS_ICC_ */
160 #define CPU_REG_BITS (CPU_PPC32 ? 32 : 64)
161 #define CPU_REGS_CNT FIXME
162 #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
163 #define CPU_HARVARD 0
165 /// Valid pointers should be >= than this value (used for debug)
166 #define CPU_RAM_START 0x1000
169 #define NOP asm volatile ("nop" ::)
170 #define BREAKPOINT asm volatile ("twge 2,2" ::)
175 #define CPU_REG_BITS 16
176 #define CPU_REGS_CNT FIXME
177 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
178 #define CPU_HARVARD 1
180 /* Memory is word-addessed in the DSP56K */
181 #define CPU_BITS_PER_CHAR 16
182 #define SIZEOF_SHORT 1
184 #define SIZEOF_LONG 2
187 /// Valid pointers should be >= than this value (used for debug)
188 #define CPU_RAM_START 0x200
191 #define BREAKPOINT asm(debug)
195 #define NOP asm volatile ("nop" ::)
197 #define CPU_REG_BITS 8
198 #define CPU_REGS_CNT 33 /* Includes SREG */
199 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
200 #define CPU_HARVARD 1
202 /// Valid pointers should be >= than this value (used for debug)
203 #define CPU_RAM_START 0x100
206 #error No CPU_... defined.
210 #define BREAKPOINT /* nop */
214 /// Function attribute for use with performance critical code.
215 #define FAST_FUNC /* */
219 /// Data attribute to move constant data to fast memory storage.
220 #define FAST_RODATA /* */
223 #endif /* CPU_ATTR_H */