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_proc.h" /* CONFIG_KERN_PREEMPT */
46 #include "cfg/cfg_attr.h" /* CONFIG_FAST_MEM */
50 * \name Macros for determining CPU endianness.
53 #define CPU_BIG_ENDIAN 0x1234
54 #define CPU_LITTLE_ENDIAN 0x3412 /* Look twice, pal. This is not a bug. */
57 /** Macro to include cpu-specific versions of the headers. */
58 #define CPU_HEADER(module) PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).h)
60 /** Macro to include cpu-specific versions of implementation files. */
61 #define CPU_CSOURCE(module) PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).c)
66 #define NOP nop_instruction()
68 #define CPU_REG_BITS 16
69 #define CPU_REGS_CNT 16
70 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
73 /// Valid pointers should be >= than this value (used for debug)
74 #define CPU_RAM_START 0x100
78 #define CPU_REGS_CNT 7
79 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
83 #define CPU_REG_BITS 64
86 /* WIN64 is an IL32-P64 weirdo. */
90 #define CPU_REG_BITS 32
93 /// Valid pointers should be >= than this value (used for debug)
94 #define CPU_RAM_START 0x1000
97 #define NOP asm volatile ("nop")
98 /* This is a good thing to insert into busy-wait loops. */
99 #define PAUSE asm volatile ("rep; nop" ::: "memory")
100 #define BREAKPOINT asm volatile ("int3" ::)
105 #define CPU_REG_BITS 32
106 #define CPU_REGS_CNT 16
107 #define CPU_HARVARD 0
109 /// Valid pointers should be >= than this value (used for debug)
111 #define CPU_RAM_START 0x00200000
113 #define CPU_RAM_START 0x40000000
115 #warning Fix CPU_RAM_START address for your ARM, default value set to 0x200
116 #define CPU_RAM_START 0x200
119 #ifdef __IAR_SYSTEMS_ICC__
120 #warning Check CPU_BYTE_ORDER
121 #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
123 #define NOP __no_operation()
125 #else /* GCC and compatibles */
127 #if defined(__ARMEB__)
128 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
129 #elif defined(__ARMEL__)
130 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
132 #error Unable to detect ARM endianness!
135 #define NOP asm volatile ("mov r0,r0" ::)
136 #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */
140 * Function attribute for use with performance critical code.
142 * On the AT91 family, code residing in flash has wait states.
143 * Moving functions to the data section is a quick & dirty way
144 * to get them transparently copied to SRAM for zero-wait-state
147 #define FAST_FUNC __attribute__((section(".ramfunc")))
150 * Data attribute to move constant data to fast memory storage.
154 #define FAST_RODATA __attribute__((section(".data")))
156 #else // !CONFIG_FAST_MEM
157 #define FAST_RODATA /**/
158 #define FAST_FUNC /**/
162 * Function attribute to move it into ram memory.
164 #define RAM_FUNC __attribute__((section(".ramfunc")))
166 #endif /* !__IAR_SYSTEMS_ICC_ */
169 #define CPU_REG_BITS 32
170 #define CPU_REGS_CNT 16
171 #define CPU_HARVARD 0
173 /// Valid pointers should be >= than this value (used for debug)
174 #if (CPU_CM3_LM3S1968 || CPU_CM3_LM3S8962 || CPU_CM3_STM32 || CPU_CM3_SAM3)
175 #define CPU_RAM_START 0x20000000
177 #warning Fix CPU_RAM_START address for your Cortex-M3, default value set to 0x20000000
178 #define CPU_RAM_START 0x20000000
181 #if defined(__ARMEB__)
182 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
183 #elif defined(__ARMEL__)
184 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
186 #error Unable to detect Cortex-M3 endianess!
189 #define NOP asm volatile ("nop")
190 #define PAUSE asm volatile ("wfi" ::: "memory")
191 #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */
194 * Function attribute to move it into ram memory.
196 #define RAM_FUNC __attribute__((section(".ramfunc")))
200 #define CPU_REG_BITS (CPU_PPC32 ? 32 : 64)
201 #define CPU_REGS_CNT FIXME
202 #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
203 #define CPU_HARVARD 0
205 /// Valid pointers should be >= than this value (used for debug)
206 #define CPU_RAM_START 0x1000
209 #define NOP asm volatile ("nop" ::)
210 #define BREAKPOINT asm volatile ("twge 2,2" ::)
215 #define CPU_REG_BITS 16
216 #define CPU_REGS_CNT FIXME
217 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
218 #define CPU_HARVARD 1
220 /* Memory is word-addessed in the DSP56K */
221 #define CPU_BITS_PER_CHAR 16
222 #define SIZEOF_SHORT 1
224 #define SIZEOF_LONG 2
227 /// Valid pointers should be >= than this value (used for debug)
228 #define CPU_RAM_START 0x200
231 #define BREAKPOINT asm(debug)
235 #define NOP asm volatile ("nop" ::)
237 #define CPU_REG_BITS 8
238 #define CPU_REGS_CNT 33 /* Includes SREG */
239 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
240 #define CPU_HARVARD 1
242 /// Valid pointers should be >= than this value (used for debug)
243 #if CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA103
244 #define CPU_RAM_START 0x60
245 #elif CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P
246 #define CPU_RAM_START 0x100
247 #elif CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA1280 || CPU_AVR_ATMEGA2560
248 #define CPU_RAM_START 0x200
250 #warning Fix CPU_RAM_START address for your AVR, default value set to 0x100
251 #define CPU_RAM_START 0x100
256 #define CPU_REG_BITS 16
257 #define CPU_REGS_CNT 12
258 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
259 #define CPU_HARVARD 0
261 /// Valid pointers should be >= than this value (used for debug)
262 #define CPU_RAM_START 0x200
264 #define NOP __asm__ __volatile__ ("nop")
267 #error No CPU_... defined.
271 #define BREAKPOINT /* nop */
275 /// Function attribute for use with performance critical code.
276 #define FAST_FUNC /* */
280 /// Data attribute to move constant data to fast memory storage.
281 #define FAST_RODATA /* */
285 /// Generic PAUSE implementation.
286 #define PAUSE {NOP; MEMORY_BARRIER;}
289 #endif /* CPU_ATTR_H */