40#ifndef _RTEMS_SCORE_M68K_H
41#define _RTEMS_SCORE_M68K_H
110#if defined(__mcoldfire__)
112# define CPU_NAME "Motorola ColdFire"
114# if defined(__mcfisaa__)
116# define CPU_MODEL_NAME "mcfisaa"
117# define M68K_HAS_VBR 1
118# define M68K_HAS_BFFFO 0
119# define M68K_HAS_SEPARATE_STACKS 0
120# define M68K_HAS_PREINDEXING 0
121# define M68K_HAS_EXTB_L 1
122# define M68K_HAS_MISALIGNED 1
124# elif defined(__mcfisaaplus__)
126# define CPU_MODEL_NAME "mcfisaaplus"
127# define M68K_HAS_VBR 1
128# define M68K_HAS_BFFFO 0
129# define M68K_HAS_SEPARATE_STACKS 0
130# define M68K_HAS_PREINDEXING 0
131# define M68K_HAS_EXTB_L 1
132# define M68K_HAS_MISALIGNED 1
134# elif defined(__mcfisab__)
136# define CPU_MODEL_NAME "mcfisab"
137# define M68K_HAS_VBR 1
138# define M68K_HAS_BFFFO 0
139# define M68K_HAS_SEPARATE_STACKS 0
140# define M68K_HAS_PREINDEXING 0
141# define M68K_HAS_EXTB_L 1
142# define M68K_HAS_MISALIGNED 1
145# error "Unsupported Coldfire ISA -- Please notify RTEMS"
152# if defined (__mcffpu__)
153# define M68K_HAS_FPU 1
157# define M68K_HAS_EMAC 1
158# define M68K_HAS_FPSP_PACKAGE 0
160# define M68K_HAS_FPU 0
161# define M68K_HAS_FPSP_PACKAGE 0
171# if (defined(__mcf_cpu_52221) || \
172 defined(__mcf_cpu_52223) || \
173 defined(__mcf_cpu_52230) || \
174 defined(__mcf_cpu_52231) || \
175 defined(__mcf_cpu_52232) || \
176 defined(__mcf_cpu_52233) || \
177 defined(__mcf_cpu_52234) || \
178 defined(__mcf_cpu_52235) || \
179 defined(__mcf_cpu_52225) || \
180 defined(__mcf_cpu_52235))
181 #define M68K_CPU_STACK_MINIMUM_SIZE 1024
183 #define M68K_CPU_PRIORITY_MAXIMUM 15
185 #define M68K_CPU_STACK_MINIMUM_SIZE 4096
187 #define M68K_CPU_PRIORITY_MAXIMUM 255
201# define CPU_NAME "Motorola MC68xxx"
206# define M68K_CPU_STACK_MINIMUM_SIZE 4096
208# if (defined(__mc68020__) && !defined(__mcpu32__))
210# define CPU_MODEL_NAME "m68020"
211# define M68K_HAS_VBR 1
212# define M68K_HAS_SEPARATE_STACKS 1
213# define M68K_HAS_BFFFO 1
214# define M68K_HAS_PREINDEXING 1
215# define M68K_HAS_EXTB_L 1
216# define M68K_HAS_MISALIGNED 1
217# if defined (__HAVE_68881__)
218# define M68K_HAS_FPU 1
219# define M68K_HAS_FPSP_PACKAGE 0
221# define M68K_HAS_FPU 0
222# define M68K_HAS_FPSP_PACKAGE 0
225# elif defined(__mc68030__)
227# define CPU_MODEL_NAME "m68030"
228# define M68K_HAS_VBR 1
229# define M68K_HAS_SEPARATE_STACKS 1
230# define M68K_HAS_BFFFO 1
231# define M68K_HAS_PREINDEXING 1
232# define M68K_HAS_EXTB_L 1
233# define M68K_HAS_MISALIGNED 1
234# if defined (__HAVE_68881__)
235# define M68K_HAS_FPU 1
236# define M68K_HAS_FPSP_PACKAGE 0
238# define M68K_HAS_FPU 0
239# define M68K_HAS_FPSP_PACKAGE 0
242# elif defined(__mc68040__)
244# define CPU_MODEL_NAME "m68040"
245# define M68K_HAS_VBR 1
246# define M68K_HAS_SEPARATE_STACKS 1
247# define M68K_HAS_BFFFO 1
248# define M68K_HAS_PREINDEXING 1
249# define M68K_HAS_EXTB_L 1
250# define M68K_HAS_MISALIGNED 1
251# if defined (__HAVE_68881__)
252# define M68K_HAS_FPU 1
253# define M68K_HAS_FPSP_PACKAGE 1
255# define M68K_HAS_FPU 0
256# define M68K_HAS_FPSP_PACKAGE 0
259# elif defined(__mc68060__)
261# define CPU_MODEL_NAME "m68060"
262# define M68K_HAS_VBR 1
263# define M68K_HAS_SEPARATE_STACKS 0
264# define M68K_HAS_BFFFO 1
265# define M68K_HAS_PREINDEXING 1
266# define M68K_HAS_EXTB_L 1
267# define M68K_HAS_MISALIGNED 1
268# if defined (__HAVE_68881__)
269# define M68K_HAS_FPU 1
270# define M68K_HAS_FPSP_PACKAGE 0
272# define M68K_HAS_FPU 0
273# define M68K_HAS_FPSP_PACKAGE 0
276# elif defined(__mc68302__)
278# define CPU_MODEL_NAME "m68302"
279# define M68K_HAS_VBR 0
280# define M68K_HAS_SEPARATE_STACKS 0
281# define M68K_HAS_BFFFO 0
282# define M68K_HAS_PREINDEXING 0
283# define M68K_HAS_EXTB_L 0
284# define M68K_HAS_MISALIGNED 0
285# define M68K_HAS_FPU 0
286# define M68K_HAS_FPSP_PACKAGE 0
289# elif defined(RTEMS__mcpu32p__)
291# define CPU_MODEL_NAME "mcpu32+"
292# define M68K_HAS_VBR 1
293# define M68K_HAS_SEPARATE_STACKS 0
294# define M68K_HAS_BFFFO 0
295# define M68K_HAS_PREINDEXING 1
296# define M68K_HAS_EXTB_L 1
297# define M68K_HAS_MISALIGNED 1
298# define M68K_HAS_FPU 0
299# define M68K_HAS_FPSP_PACKAGE 0
301# elif defined(__mcpu32__)
303# define CPU_MODEL_NAME "mcpu32"
304# define M68K_HAS_VBR 1
305# define M68K_HAS_SEPARATE_STACKS 0
306# define M68K_HAS_BFFFO 0
307# define M68K_HAS_PREINDEXING 1
308# define M68K_HAS_EXTB_L 1
309# define M68K_HAS_MISALIGNED 0
310# define M68K_HAS_FPU 0
311# define M68K_HAS_FPSP_PACKAGE 0
313# elif defined(__mc68000__)
315# define CPU_MODEL_NAME "m68000"
316# define M68K_HAS_VBR 0
317# define M68K_HAS_SEPARATE_STACKS 0
318# define M68K_HAS_BFFFO 0
319# define M68K_HAS_PREINDEXING 0
320# define M68K_HAS_EXTB_L 0
321# define M68K_HAS_MISALIGNED 0
322# if defined (__HAVE_68881__)
323# define M68K_HAS_FPU 1
324# define M68K_HAS_FPSP_PACKAGE 0
326# define M68K_HAS_FPU 0
327# define M68K_HAS_FPSP_PACKAGE 0
332# error "Unsupported 68000 CPU model -- are you sure you're running a 68k compiler?"
339# define M68K_CPU_STACK_MINIMUM_SIZE 4096
340# define M68K_CPU_PRIORITY_MAXIMUM 255
348#if defined(__mcoldfire__)
349#define M68K_COLDFIRE_ARCH 1
351#define M68K_COLDFIRE_ARCH 0
356#if ( defined(__mcoldfire__) )
357#define m68k_disable_interrupts( _level ) \
358 do { uint32_t _tmpsr = 0x0700; \
359 __asm__ volatile ( "move.w %%sr,%0\n\t" \
362 : "=d" (_level), "=d"(_tmpsr) : "1"(_tmpsr) \
366#define m68k_disable_interrupts( _level ) \
367 __asm__ volatile ( "move.w %%sr,%0\n\t" \
368 "or.w #0x0700,%%sr" \
373#define m68k_enable_interrupts( _level ) \
374 __asm__ volatile ( "move.w %0,%%sr " : : "d" (_level) : "cc");
376#if ( defined(__mcoldfire__) )
377#define m68k_flash_interrupts( _level ) \
378 do { uint32_t _tmpsr = 0x0700; \
379 asm volatile ( "move.w %2,%%sr\n\t" \
382 : "=d"(_tmpsr) : "0"(_tmpsr), "d"(_level) \
386#define m68k_flash_interrupts( _level ) \
387 __asm__ volatile ( "move.w %0,%%sr\n\t" \
388 "or.w #0x0700,%%sr" \
393#define m68k_get_interrupt_level( _level ) \
397 __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \
398 _level = (_tmpsr & 0x0700) >> 8; \
401#define m68k_set_interrupt_level( _newlevel ) \
405 __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \
406 _tmpsr = (_tmpsr & 0xf8ff) | ((_newlevel) << 8); \
407 __asm__ volatile( "move.w %0,%%sr" : : "d" (_tmpsr)); \
410#if ( M68K_HAS_VBR == 1 && !defined(__mcoldfire__) )
411#define m68k_get_vbr( vbr ) \
412 __asm__ volatile ( "movec %%vbr,%0 " : "=r" (vbr))
414#define m68k_set_vbr( vbr ) \
415 __asm__ volatile ( "movec %0,%%vbr " : : "r" (vbr))
417#elif ( defined(__mcoldfire__) )
419#define m68k_get_vbr( _vbr ) _vbr = &_VBR
421#define m68k_set_vbr( _vbr ) \
423 __asm__ volatile ( "movec %0,%%vbr " : : "r" (_vbr)); \
424 _VBR = (void *)_vbr; \
428#define m68k_get_vbr( _vbr ) _vbr = (void *)_VBR
429#define m68k_set_vbr( _vbr )
435#define m68k_set_cacr(_cacr) __asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr))
436#define m68k_set_acr0(_acr0) __asm__ volatile ("movec %0,%%acr0" : : "d" (_acr0))
437#define m68k_set_acr1(_acr1) __asm__ volatile ("movec %0,%%acr1" : : "d" (_acr1))
443#if ( defined(__mcoldfire__) )
448static inline uint32_t m68k_swap_u32(
452 uint32_t byte1, byte2, byte3, byte4, swapped;
454 byte4 = (value >> 24) & 0xff;
455 byte3 = (value >> 16) & 0xff;
456 byte2 = (value >> 8) & 0xff;
457 byte1 = value & 0xff;
459 swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
463static inline uint16_t m68k_swap_u16(
467 return (((value & 0xff) << 8) | ((value >> 8) & 0xff));
472static inline uint32_t m68k_swap_u32(
476 uint32_t swapped = value;
478 __asm__
volatile(
"rorw #8,%0" :
"=d" (swapped) :
"0" (swapped) );
479 __asm__
volatile(
"swap %0" :
"=d" (swapped) :
"0" (swapped) );
480 __asm__
volatile(
"rorw #8,%0" :
"=d" (swapped) :
"0" (swapped) );
485static inline uint16_t m68k_swap_u16(
489 uint16_t swapped = value;
491 __asm__
volatile(
"rorw #8,%0" :
"=d" (swapped) :
"0" (swapped) );
497#define CPU_swap_u32( value ) m68k_swap_u32( value )
498#define CPU_swap_u16( value ) m68k_swap_u16( value )
510static inline void * _CPU_virtual_to_physical (
511 const void * d_addr )
513 return (
void *) d_addr;