5 * This file is part of BeRTOS.
7 * Bertos is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * As a special exception, you may use this file as part of a free software
22 * library without restriction. Specifically, if other files instantiate
23 * templates or use macros or inline functions from this file, or you compile
24 * this file and link it with other files to produce an executable, this
25 * file does not by itself cause the resulting executable to be covered by
26 * the GNU General Public License. This exception does not however
27 * invalidate any other reasons why the executable file might be covered by
28 * the GNU General Public License.
30 * Copyright 2004, 2005, 2006, 2007, 2008 Develer S.r.l. (http://www.develer.com/)
31 * Copyright 2004 Giovanni Bajo
34 * \brief CPU-specific attributes.
36 * \author Giovanni Bajo <rasky@develer.com>
37 * \author Bernie Innocenti <bernie@codewiz.org>
38 * \author Stefano Fedrigo <aleph@develer.com>
39 * \author Francesco Sacchi <batt@develer.com>
46 #include "cfg/cfg_proc.h" /* CONFIG_KERN_PREEMPT */
47 #include "cfg/cfg_attr.h" /* CONFIG_FAST_MEM */
51 * \name Macros for determining CPU endianness.
54 #define CPU_BIG_ENDIAN 0x1234
55 #define CPU_LITTLE_ENDIAN 0x3412 /* Look twice, pal. This is not a bug. */
58 /** Macro to include cpu-specific versions of the headers. */
59 #define CPU_HEADER(module) PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).h)
61 /** Macro to include cpu-specific versions of implementation files. */
62 #define CPU_CSOURCE(module) PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).c)
67 #define NOP nop_instruction()
69 #define CPU_REG_BITS 16
70 #define CPU_REGS_CNT 16
71 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
74 /// Valid pointers should be >= than this value (used for debug)
75 #define CPU_RAM_START 0x100
79 #define CPU_REGS_CNT 7
80 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
84 #define CPU_REG_BITS 64
87 /* WIN64 is an IL32-P64 weirdo. */
91 #define CPU_REG_BITS 32
94 /// Valid pointers should be >= than this value (used for debug)
95 #define CPU_RAM_START 0x1000
98 #define NOP asm volatile ("nop")
99 /* This is a good thing to insert into busy-wait loops. */
100 #define PAUSE asm volatile ("rep; nop" ::: "memory")
101 #define BREAKPOINT asm volatile ("int3" ::)
106 #define CPU_REG_BITS 32
107 #define CPU_REGS_CNT 16
108 #define CPU_HARVARD 0
110 /// Valid pointers should be >= than this value (used for debug)
112 #define CPU_RAM_START 0x00200000
114 #define CPU_RAM_START 0x40000000
116 #warning Fix CPU_RAM_START address for your ARM, default value set to 0x200
117 #define CPU_RAM_START 0x200
120 #ifdef __IAR_SYSTEMS_ICC__
121 #warning Check CPU_BYTE_ORDER
122 #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
124 #define NOP __no_operation()
126 #else /* GCC and compatibles */
128 #if defined(__ARMEB__)
129 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
130 #elif defined(__ARMEL__)
131 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
133 #error Unable to detect ARM endianness!
136 #define NOP asm volatile ("mov r0,r0" ::)
137 #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */
141 * Function attribute for use with performance critical code.
143 * On the AT91 family, code residing in flash has wait states.
144 * Moving functions to the data section is a quick & dirty way
145 * to get them transparently copied to SRAM for zero-wait-state
148 #define FAST_FUNC __attribute__((section(".data")))
151 * Data attribute to move constant data to fast memory storage.
155 #define FAST_RODATA __attribute__((section(".data")))
157 #else // !CONFIG_FAST_MEM
158 #define FAST_RODATA /**/
159 #define FAST_FUNC /**/
163 * Function attribute to move it into ram memory.
165 #define RAM_FUNC __attribute__((section(".data")))
167 #endif /* !__IAR_SYSTEMS_ICC_ */
170 #define CPU_REG_BITS 32
171 #define CPU_REGS_CNT 16
172 #define CPU_HARVARD 0
174 /// Valid pointers should be >= than this value (used for debug)
175 #if (CPU_CM3_LM3S1968 || CPU_CM3_LM3S8962 || CPU_CM3_STM32F103R8)
176 #define CPU_RAM_START 0x20000000
178 #warning Fix CPU_RAM_START address for your Cortex-M3, default value set to 0x200
179 #define CPU_RAM_START 0x200
182 #if defined(__ARMEB__)
183 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
184 #elif defined(__ARMEL__)
185 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
187 #error Unable to detect Cortex-M3 endianess!
190 #define NOP asm volatile ("nop")
191 #define PAUSE asm volatile ("wfi" ::: "memory")
192 #define BREAKPOINT /* asm("bkpt 0") DOES NOT WORK */
196 #define CPU_REG_BITS (CPU_PPC32 ? 32 : 64)
197 #define CPU_REGS_CNT FIXME
198 #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
199 #define CPU_HARVARD 0
201 /// Valid pointers should be >= than this value (used for debug)
202 #define CPU_RAM_START 0x1000
205 #define NOP asm volatile ("nop" ::)
206 #define BREAKPOINT asm volatile ("twge 2,2" ::)
211 #define CPU_REG_BITS 16
212 #define CPU_REGS_CNT FIXME
213 #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
214 #define CPU_HARVARD 1
216 /* Memory is word-addessed in the DSP56K */
217 #define CPU_BITS_PER_CHAR 16
218 #define SIZEOF_SHORT 1
220 #define SIZEOF_LONG 2
223 /// Valid pointers should be >= than this value (used for debug)
224 #define CPU_RAM_START 0x200
227 #define BREAKPOINT asm(debug)
231 #define NOP asm volatile ("nop" ::)
233 #define CPU_REG_BITS 8
234 #define CPU_REGS_CNT 33 /* Includes SREG */
235 #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
236 #define CPU_HARVARD 1
238 /// Valid pointers should be >= than this value (used for debug)
239 #if CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA103
240 #define CPU_RAM_START 0x60
241 #elif CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P
242 #define CPU_RAM_START 0x100
243 #elif CPU_AVR_ATMEGA1281
244 #define CPU_RAM_START 0x200
246 #warning Fix CPU_RAM_START address for your AVR, default value set to 0x100
247 #define CPU_RAM_START 0x100
251 #error No CPU_... defined.
255 #define BREAKPOINT /* nop */
259 /// Function attribute for use with performance critical code.
260 #define FAST_FUNC /* */
264 /// Data attribute to move constant data to fast memory storage.
265 #define FAST_RODATA /* */
269 /// Generic PAUSE implementation.
270 #define PAUSE {NOP; MEMORY_BARRIER;}
273 #endif /* CPU_ATTR_H */