1 #ifndef CYGONCE_HAL_ARCH_INC
2 #define CYGONCE_HAL_ARCH_INC
3 |=============================================================================
7 | ColdFire architecture assembler header file
9 |=============================================================================
10 |###ECOSGPLCOPYRIGHTBEGIN####
11 | -------------------------------------------
12 | This file is part of eCos, the Embedded Configurable Operating System.
13 | Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 | Copyright (C) 2006 eCosCentric Ltd.
16 | eCos is free software; you can redistribute it and/or modify it under
17 | the terms of the GNU General Public License as published by the Free
18 | Software Foundation; either version 2 or (at your option) any later version.
20 | eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 | You should have received a copy of the GNU General Public License along
26 | with eCos; if not, write to the Free Software Foundation, Inc.,
27 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29 | As a special exception, if other files instantiate templates or use macros
30 | or inline functions from this file, or you compile this file and link it
31 | with other works to produce a work based on this file, this file does not
32 | by itself cause the resulting work to be covered by the GNU General Public
33 | License. However the source code for this file must still be made available
34 | in accordance with section (3) of the GNU General Public License.
36 | This exception does not invalidate any other reasons why a work based on
37 | this file might be covered by the GNU General Public License.
38 | -------------------------------------------
39 |###ECOSGPLCOPYRIGHTEND####
40 |=============================================================================
41 |#####DESCRIPTIONBEGIN####
43 | Author(s): Enrico Piria
46 | Purpose: MCF5272 variant definitions.
47 | Description: This file contains macro definitions used in the
48 | architecture HAL assembler file.
50 |####DESCRIPTIONEND####
51 |==========================================================================
54 #define FUNC_START(name) \
57 .type name,@function; \
62 | ----------------------------------------------------------------------------
63 | Macros to deal with the interrupt priority level in the status register.
65 .macro hal_cpu_int_disable
70 .macro hal_cpu_int_enable work
77 .macro hal_cpu_int_merge from work
85 | ----------------------------------------------------------------------------
86 | Macro to find the value the SP register had before an exception.
88 .macro find_original_sp out
89 move.b CYGARC_CF_FMTVECWORD(%sp),\out
91 and.l #0x00000003,\out
92 add.l #CYGARC_CF_EXCEPTION_SIZE,\out
97 | ----------------------------------------------------------------------------
98 | Macros used to save and restore MAC registers during interrupts/exceptions.
100 #ifdef CYGHWR_HAL_COLDFIRE_MAC
101 .macro save_mac_registers work
102 | Store MACSR register
104 move.l \work,CYGARC_CFREG_MACSR(%sp)
106 | Switch to integer mode. This allows to save the contents of ACC
108 and.l #0x000000df,\work
113 move.l \work,CYGARC_CFREG_MACC(%sp)
115 | Store MASK register
117 move.l \work,CYGARC_CFREG_MASK(%sp)
121 .macro restore_mac_registers work
122 | Load MACSR register
123 move.l CYGARC_CFREG_MACSR(%sp),\work
127 move.l CYGARC_CFREG_MACC(%sp),\work
131 move.l CYGARC_CFREG_MASK(%sp),\work
137 | ----------------------------------------------------------------------------
138 | Macros used to save registers in interrupt handlers. During an interrupt,
139 | we save registers %d0-%d1 and %a0-%a1 because of the GNU C calling
140 | conventions. During the handler we also need register %d2.
142 #ifdef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
144 lea.l -CYGARC_CF_EXCEPTION_DECREMENT(%sp),%sp
145 movem.l %d0-%d2,CYGARC_CFREG_DREGS(%sp)
146 movem.l %a0-%a1,CYGARC_CFREG_AREGS(%sp)
151 movem.l CYGARC_CFREG_AREGS(%sp),%a0-%a1
152 movem.l CYGARC_CFREG_DREGS(%sp),%d0-%d2
153 lea.l CYGARC_CF_EXCEPTION_DECREMENT(%sp),%sp
156 #else /* CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT */
159 lea.l -CYGARC_CF_EXCEPTION_DECREMENT(%sp),%sp
160 movem.l %d0-%d7,CYGARC_CFREG_DREGS(%sp)
161 movem.l %a0-%a6,CYGARC_CFREG_AREGS(%sp)
163 #ifdef CYGHWR_HAL_COLDFIRE_MAC
164 save_mac_registers %d0
167 | Save old SP (before interrupt)
169 move.l %d0,CYGARC_CFREG_SP(%sp)
175 #ifdef CYGHWR_HAL_COLDFIRE_MAC
176 restore_mac_registers %d0
179 movem.l CYGARC_CFREG_AREGS(%sp),%a0-%a6
180 movem.l CYGARC_CFREG_DREGS(%sp),%d0-%d7
181 lea.l CYGARC_CF_EXCEPTION_DECREMENT(%sp),%sp
184 #endif /* CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT */
187 | ----------------------------------------------------------------------------
188 | Macros used to save/restore registers during context switches.
189 | We don't save registers %d0-%d1 and %a0-%a1 because of the GNU C calling
190 | conventions: these macros are used in a routine called by C code.
192 #ifdef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
194 .macro ctx_save_registers
195 lea -CYGARC_CF_CONTEXT_SIZE(%sp),%sp
196 movem.l %d2-%d7,CYGARC_CFREG_D2(%sp)
197 movem.l %a2-%a6,CYGARC_CFREG_A2(%sp)
198 #ifdef CYGHWR_HAL_COLDFIRE_MAC
199 save_mac_registers %d0
201 | Save SR and interrupt level
203 move.w %d0,CYGARC_CF_SR(%sp)
207 .macro ctx_restore_registers
208 | Restore SR and interrupt level
209 move.w CYGARC_CF_SR(%sp),%d0
212 #ifdef CYGHWR_HAL_COLDFIRE_MAC
213 restore_mac_registers %d0
215 movem.l CYGARC_CFREG_D2(%sp),%d2-%d7
216 movem.l CYGARC_CFREG_A2(%sp), %a2-%a6
217 lea CYGARC_CF_CONTEXT_SIZE(%sp),%sp
220 #else /* CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM */
222 .macro ctx_save_registers
223 | Save all of the registers
224 lea -CYGARC_CF_CONTEXT_SIZE(%sp),%sp
225 movem.l %d0-%d7,CYGARC_CFREG_DREGS(%sp)
226 movem.l %a0-%a7,CYGARC_CFREG_AREGS(%sp)
227 #ifdef CYGHWR_HAL_COLDFIRE_MAC
228 save_mac_registers %d0
231 | Save pc (useful during debugging with GDB)
233 move.l %a0,CYGARC_CFREG_PC(%sp)
235 | Save SR and interrupt level
237 move.w %d0,CYGARC_CF_SR(%sp)
241 .macro ctx_restore_registers
242 | Restore SR and interrupt level
243 move.w CYGARC_CF_SR(%sp),%d0
246 #ifdef CYGHWR_HAL_COLDFIRE_MAC
247 restore_mac_registers %d0
249 movem.l CYGARC_CFREG_DREGS(%sp),%d0-%d7
250 movem.l CYGARC_CFREG_AREGS(%sp),%a0-%a6
251 lea CYGARC_CF_CONTEXT_SIZE(%sp),%sp
253 #endif /* CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM */
255 | ----------------------------------------------------------------------------
257 #endif /* ifndef CYGONCE_HAL_ARCH_INC */