21 #ifndef _RTEMS_SCORE_M68K_H 22 #define _RTEMS_SCORE_M68K_H 91 #if defined(__mcoldfire__) 93 # define CPU_NAME "Motorola ColdFire" 95 # if defined(__mcfisaa__) 97 # define CPU_MODEL_NAME "mcfisaa" 98 # define M68K_HAS_VBR 1 99 # define M68K_HAS_BFFFO 0 100 # define M68K_HAS_SEPARATE_STACKS 0 101 # define M68K_HAS_PREINDEXING 0 102 # define M68K_HAS_EXTB_L 1 103 # define M68K_HAS_MISALIGNED 1 105 # elif defined(__mcfisaaplus__) 107 # define CPU_MODEL_NAME "mcfisaaplus" 108 # define M68K_HAS_VBR 1 109 # define M68K_HAS_BFFFO 0 110 # define M68K_HAS_SEPARATE_STACKS 0 111 # define M68K_HAS_PREINDEXING 0 112 # define M68K_HAS_EXTB_L 1 113 # define M68K_HAS_MISALIGNED 1 115 # elif defined(__mcfisab__) 117 # define CPU_MODEL_NAME "mcfisab" 118 # define M68K_HAS_VBR 1 119 # define M68K_HAS_BFFFO 0 120 # define M68K_HAS_SEPARATE_STACKS 0 121 # define M68K_HAS_PREINDEXING 0 122 # define M68K_HAS_EXTB_L 1 123 # define M68K_HAS_MISALIGNED 1 126 # error "Unsupported Coldfire ISA -- Please notify RTEMS" 133 # if defined (__mcffpu__) 134 # define M68K_HAS_FPU 1 138 # define M68K_HAS_EMAC 1 139 # define M68K_HAS_FPSP_PACKAGE 0 141 # define M68K_HAS_FPU 0 142 # define M68K_HAS_FPSP_PACKAGE 0 152 # if (defined(__mcf_cpu_52221) || \ 153 defined(__mcf_cpu_52223) || \ 154 defined(__mcf_cpu_52230) || \ 155 defined(__mcf_cpu_52231) || \ 156 defined(__mcf_cpu_52232) || \ 157 defined(__mcf_cpu_52233) || \ 158 defined(__mcf_cpu_52234) || \ 159 defined(__mcf_cpu_52235) || \ 160 defined(__mcf_cpu_52225) || \ 161 defined(__mcf_cpu_52235)) 162 #define M68K_CPU_STACK_MINIMUM_SIZE 1024 164 #define M68K_CPU_PRIORITY_MAXIMUM 15 166 #define M68K_CPU_STACK_MINIMUM_SIZE 4096 168 #define M68K_CPU_PRIORITY_MAXIMUM 255 182 # define CPU_NAME "Motorola MC68xxx" 187 # define M68K_CPU_STACK_MINIMUM_SIZE 4096 189 # if (defined(__mc68020__) && !defined(__mcpu32__)) 191 # define CPU_MODEL_NAME "m68020" 192 # define M68K_HAS_VBR 1 193 # define M68K_HAS_SEPARATE_STACKS 1 194 # define M68K_HAS_BFFFO 1 195 # define M68K_HAS_PREINDEXING 1 196 # define M68K_HAS_EXTB_L 1 197 # define M68K_HAS_MISALIGNED 1 198 # if defined (__HAVE_68881__) 199 # define M68K_HAS_FPU 1 200 # define M68K_HAS_FPSP_PACKAGE 0 202 # define M68K_HAS_FPU 0 203 # define M68K_HAS_FPSP_PACKAGE 0 206 # elif defined(__mc68030__) 208 # define CPU_MODEL_NAME "m68030" 209 # define M68K_HAS_VBR 1 210 # define M68K_HAS_SEPARATE_STACKS 1 211 # define M68K_HAS_BFFFO 1 212 # define M68K_HAS_PREINDEXING 1 213 # define M68K_HAS_EXTB_L 1 214 # define M68K_HAS_MISALIGNED 1 215 # if defined (__HAVE_68881__) 216 # define M68K_HAS_FPU 1 217 # define M68K_HAS_FPSP_PACKAGE 0 219 # define M68K_HAS_FPU 0 220 # define M68K_HAS_FPSP_PACKAGE 0 223 # elif defined(__mc68040__) 225 # define CPU_MODEL_NAME "m68040" 226 # define M68K_HAS_VBR 1 227 # define M68K_HAS_SEPARATE_STACKS 1 228 # define M68K_HAS_BFFFO 1 229 # define M68K_HAS_PREINDEXING 1 230 # define M68K_HAS_EXTB_L 1 231 # define M68K_HAS_MISALIGNED 1 232 # if defined (__HAVE_68881__) 233 # define M68K_HAS_FPU 1 234 # define M68K_HAS_FPSP_PACKAGE 1 236 # define M68K_HAS_FPU 0 237 # define M68K_HAS_FPSP_PACKAGE 0 240 # elif defined(__mc68060__) 242 # define CPU_MODEL_NAME "m68060" 243 # define M68K_HAS_VBR 1 244 # define M68K_HAS_SEPARATE_STACKS 0 245 # define M68K_HAS_BFFFO 1 246 # define M68K_HAS_PREINDEXING 1 247 # define M68K_HAS_EXTB_L 1 248 # define M68K_HAS_MISALIGNED 1 249 # if defined (__HAVE_68881__) 250 # define M68K_HAS_FPU 1 251 # define M68K_HAS_FPSP_PACKAGE 0 253 # define M68K_HAS_FPU 0 254 # define M68K_HAS_FPSP_PACKAGE 0 257 # elif defined(__mc68302__) 259 # define CPU_MODEL_NAME "m68302" 260 # define M68K_HAS_VBR 0 261 # define M68K_HAS_SEPARATE_STACKS 0 262 # define M68K_HAS_BFFFO 0 263 # define M68K_HAS_PREINDEXING 0 264 # define M68K_HAS_EXTB_L 0 265 # define M68K_HAS_MISALIGNED 0 266 # define M68K_HAS_FPU 0 267 # define M68K_HAS_FPSP_PACKAGE 0 270 # elif defined(RTEMS__mcpu32p__) 272 # define CPU_MODEL_NAME "mcpu32+" 273 # define M68K_HAS_VBR 1 274 # define M68K_HAS_SEPARATE_STACKS 0 275 # define M68K_HAS_BFFFO 0 276 # define M68K_HAS_PREINDEXING 1 277 # define M68K_HAS_EXTB_L 1 278 # define M68K_HAS_MISALIGNED 1 279 # define M68K_HAS_FPU 0 280 # define M68K_HAS_FPSP_PACKAGE 0 282 # elif defined(__mcpu32__) 284 # define CPU_MODEL_NAME "mcpu32" 285 # define M68K_HAS_VBR 1 286 # define M68K_HAS_SEPARATE_STACKS 0 287 # define M68K_HAS_BFFFO 0 288 # define M68K_HAS_PREINDEXING 1 289 # define M68K_HAS_EXTB_L 1 290 # define M68K_HAS_MISALIGNED 0 291 # define M68K_HAS_FPU 0 292 # define M68K_HAS_FPSP_PACKAGE 0 294 # elif defined(__mc68000__) 296 # define CPU_MODEL_NAME "m68000" 297 # define M68K_HAS_VBR 0 298 # define M68K_HAS_SEPARATE_STACKS 0 299 # define M68K_HAS_BFFFO 0 300 # define M68K_HAS_PREINDEXING 0 301 # define M68K_HAS_EXTB_L 0 302 # define M68K_HAS_MISALIGNED 0 303 # if defined (__HAVE_68881__) 304 # define M68K_HAS_FPU 1 305 # define M68K_HAS_FPSP_PACKAGE 0 307 # define M68K_HAS_FPU 0 308 # define M68K_HAS_FPSP_PACKAGE 0 313 # error "Unsupported 68000 CPU model -- are you sure you're running a 68k compiler?" 320 # define M68K_CPU_STACK_MINIMUM_SIZE 4096 321 # define M68K_CPU_PRIORITY_MAXIMUM 255 329 #if defined(__mcoldfire__) 330 #define M68K_COLDFIRE_ARCH 1 332 #define M68K_COLDFIRE_ARCH 0 337 #if ( defined(__mcoldfire__) ) 338 #define m68k_disable_interrupts( _level ) \ 339 do { uint32_t _tmpsr = 0x0700; \ 340 __asm__ volatile ( "move.w %%sr,%0\n\t" \ 343 : "=d" (_level), "=d"(_tmpsr) : "1"(_tmpsr) \ 347 #define m68k_disable_interrupts( _level ) \ 348 __asm__ volatile ( "move.w %%sr,%0\n\t" \ 349 "or.w #0x0700,%%sr" \ 354 #define m68k_enable_interrupts( _level ) \ 355 __asm__ volatile ( "move.w %0,%%sr " : : "d" (_level) : "cc"); 357 #if ( defined(__mcoldfire__) ) 358 #define m68k_flash_interrupts( _level ) \ 359 do { uint32_t _tmpsr = 0x0700; \ 360 asm volatile ( "move.w %2,%%sr\n\t" \ 363 : "=d"(_tmpsr) : "0"(_tmpsr), "d"(_level) \ 367 #define m68k_flash_interrupts( _level ) \ 368 __asm__ volatile ( "move.w %0,%%sr\n\t" \ 369 "or.w #0x0700,%%sr" \ 374 #define m68k_get_interrupt_level( _level ) \ 378 __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \ 379 _level = (_tmpsr & 0x0700) >> 8; \ 382 #define m68k_set_interrupt_level( _newlevel ) \ 386 __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \ 387 _tmpsr = (_tmpsr & 0xf8ff) | ((_newlevel) << 8); \ 388 __asm__ volatile( "move.w %0,%%sr" : : "d" (_tmpsr)); \ 391 #if ( M68K_HAS_VBR == 1 && !defined(__mcoldfire__) ) 392 #define m68k_get_vbr( vbr ) \ 393 __asm__ volatile ( "movec %%vbr,%0 " : "=r" (vbr)) 395 #define m68k_set_vbr( vbr ) \ 396 __asm__ volatile ( "movec %0,%%vbr " : : "r" (vbr)) 398 #elif ( defined(__mcoldfire__) ) 400 #define m68k_get_vbr( _vbr ) _vbr = &_VBR 402 #define m68k_set_vbr( _vbr ) \ 404 __asm__ volatile ( "movec %0,%%vbr " : : "r" (_vbr)); \ 405 _VBR = (void *)_vbr; \ 409 #define m68k_get_vbr( _vbr ) _vbr = (void *)_VBR 410 #define m68k_set_vbr( _vbr ) 416 #define m68k_set_cacr(_cacr) __asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr)) 417 #define m68k_set_acr0(_acr0) __asm__ volatile ("movec %0,%%acr0" : : "d" (_acr0)) 418 #define m68k_set_acr1(_acr1) __asm__ volatile ("movec %0,%%acr1" : : "d" (_acr1)) 424 #if ( defined(__mcoldfire__) ) 429 static inline uint32_t m68k_swap_u32(
433 uint32_t byte1, byte2, byte3, byte4, swapped;
435 byte4 = (value >> 24) & 0xff;
436 byte3 = (value >> 16) & 0xff;
437 byte2 = (value >> 8) & 0xff;
438 byte1 = value & 0xff;
440 swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
444 static inline uint16_t m68k_swap_u16(
448 return (((value & 0xff) << 8) | ((value >> 8) & 0xff));
453 static inline uint32_t m68k_swap_u32(
457 uint32_t swapped = value;
459 __asm__ volatile(
"rorw #8,%0" :
"=d" (swapped) :
"0" (swapped) );
460 __asm__ volatile(
"swap %0" :
"=d" (swapped) :
"0" (swapped) );
461 __asm__ volatile(
"rorw #8,%0" :
"=d" (swapped) :
"0" (swapped) );
466 static inline uint16_t m68k_swap_u16(
470 uint16_t swapped = value;
472 __asm__ volatile(
"rorw #8,%0" :
"=d" (swapped) :
"0" (swapped) );
478 #define CPU_swap_u32( value ) m68k_swap_u32( value ) 479 #define CPU_swap_u16( value ) m68k_swap_u16( value ) 491 static inline void * _CPU_virtual_to_physical (
492 const void * d_addr )
494 return (
void *) d_addr;
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.