source: rtems/c/src/exec/score/cpu/m68k/m68k.h @ 924e17a

4.104.114.84.95
Last change on this file since 924e17a was 924e17a, checked in by Joel Sherrill <joel.sherrill@…>, on 06/25/98 at 16:10:45

Patch from Robin Kirkham <Robin.Kirkham@…> to distinguish
between CPU32 and CPU32+ cores. Commentary follows:

Unfortunately c/src/exec/score/cpu/m68k/m68k.h incorrectly defines
M68K_HAS_MISALIGNED for the plain old CPU32 (it is correct for the CPU32+).
As a consequence, the recently-relocated m68k memcpy() may still attempt
misaligned memory accesses.

I suggest that until such time as egcs/gcc differentiates these cores
that we invent a new preprocessor symbol, RTEMSmcpu32p for this
purpose, on the assumption that egcs may one day grow a -mcpu32+ option
which will define a mcpu32p symbol (whether this option would also
define mcpu32 is yet to be resolved).

BSPs that have a CPU32+ (like gen68360) would for the time being define
RTEMSmcpu32p using -D. The symbol is `RTEMSmcpu32p' because
symbols of the form xxx should only be defined by the compiler
itself.

Note that the patch tests for RTEMSmcpu32p *before* mcpu32, since
mcpu32 is still defined for the CPU32+. It does not change the
gen68360 BSP.

An aside:
Note that in egcs-1.0.3a, the option -m68332 is identical to -mcpu32,
except it defines mc68332 as well as mcpu32. This is only
for the sake of compatibility. The story with -m68302 is similar;
it defines mc68302 and mc68000. In my opinion these options
are depreciated and ought to be avoided in RTEMS.

  • Property mode set to 100644
File size: 8.3 KB
Line 
1/*  m68k.h
2 *
3 *  This include file contains information pertaining to the Motorola
4 *  m68xxx processor family.
5 *
6 *  COPYRIGHT (c) 1989-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#ifndef __M68k_h
18#define __M68k_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/*
25 *  This section contains the information required to build
26 *  RTEMS for a particular member of the Motorola MC68xxx
27 *  family.  It does this by setting variables to indicate
28 *  which implementation dependent features are present in
29 *  a particular member of the family.
30 *
31 *  Currently recognized:
32 *     -m68000
33 *     -m68000 -msoft-float
34 *     -m68020
35 *     -m68020 -msoft-float
36 *     -m68030
37 *     -m68040 -msoft-float
38 *     -m68040
39 *     -m68040 -msoft-float
40 *     -m68302        (no FP) (deprecated, use -m68000)
41 *     -m68332        (no FP) (deprecated, use -mcpu32)
42 *     -mcpu32        (no FP)
43 *
44 *  As of gcc 2.8.1 and egcs 1.1, there is no distinction made between
45 *  the CPU32 and CPU32+.  The option -mcpu32 generates code which can
46 *  be run on either core.  RTEMS distinguishes between these two cores
47 *  because they have different alignment rules which impact performance.
48 *  If you are using a CPU32+, then the symbol RTEMS__mcpu32p__ should
49 *  be defined in your custom file (see make/custom/gen68360.cfg for an
50 *  example of how to do this.  If gcc ever distinguishes between these
51 *  two cores, then RTEMS__mcpu32p__ usage will be replaced with the
52 *  appropriate compiler defined predefine.
53 *
54 *  Here is some information on the 040 variants (courtesy of Doug McBride,
55 *  mcbride@rodin.colorado.edu):
56 *
57 *    "The 68040 is a superset of the 68EC040 and the 68LC040.  The
58 *    68EC040 and 68LC040 do not have FPU's.  The 68LC040 and the
59 *    68EC040 have renamed the DLE pin as JS0 which must be tied to
60 *    Gnd or Vcc. The 68EC040 has renamed the MDIS pin as JS1.  The
61 *    68EC040 has access control units instead of memory management units.
62 *    The 68EC040 should not have the PFLUSH or PTEST instructions executed
63 *    (cause an indeterminate result).  The 68EC040 and 68LC040 do not
64 *    implement the DLE or multiplexed bus modes.  The 68EC040 does not
65 *    implement the output buffer impedance selection mode of operation."
66 *
67 *  M68K_HAS_EXTB_L is used to enable/disable usage of the extb.l instruction
68 *  which is not available for 68000 or 68ec000 cores (68000, 68001, 68008,
69 *  68010, 68302, 68306, 68307).  This instruction is available on the 68020
70 *  up and the cpu32 based models. 
71 *
72 *  M68K_HAS_MISALIGNED is non-zero if the CPU allows byte-misaligned
73 *  data access (68020, 68030, 68040, 68060, CPU32+).
74 *
75 *  NOTE:
76 *    Eventually it would be nice to evaluate doing a lot of this section
77 *    by having each model specify which core it uses and then go from there.
78 */
79
80#if defined(__mc68020__)
81 
82#define CPU_MODEL_NAME          "m68020"
83#define M68K_HAS_VBR             1
84#define M68K_HAS_SEPARATE_STACKS 1
85#define M68K_HAS_BFFFO           1
86#define M68K_HAS_PREINDEXING     1
87#define M68K_HAS_EXTB_L          1
88#define M68K_HAS_MISALIGNED      1
89# if defined (__HAVE_68881__)
90# define M68K_HAS_FPU            1
91# define M68K_HAS_FPSP_PACKAGE   0
92# else
93# define M68K_HAS_FPU            0
94# define M68K_HAS_FPSP_PACKAGE   0
95# endif
96 
97#elif defined(__mc68030__)
98 
99#define CPU_MODEL_NAME          "m68030"
100#define M68K_HAS_VBR             1
101#define M68K_HAS_SEPARATE_STACKS 1
102#define M68K_HAS_BFFFO           1
103#define M68K_HAS_PREINDEXING     1
104#define M68K_HAS_EXTB_L          1
105#define M68K_HAS_MISALIGNED      1
106# if defined (__HAVE_68881__)
107# define M68K_HAS_FPU            1
108# define M68K_HAS_FPSP_PACKAGE   0
109# else
110# define M68K_HAS_FPU            0
111# define M68K_HAS_FPSP_PACKAGE   0
112# endif
113 
114#elif defined(__mc68040__)
115
116#define CPU_MODEL_NAME          "m68040"
117#define M68K_HAS_VBR             1
118#define M68K_HAS_SEPARATE_STACKS 1
119#define M68K_HAS_BFFFO           1
120#define M68K_HAS_PREINDEXING     1
121#define M68K_HAS_EXTB_L          1
122#define M68K_HAS_MISALIGNED      1
123# if defined (__HAVE_68881__)
124# define M68K_HAS_FPU            1
125# define M68K_HAS_FPSP_PACKAGE   1
126# else
127# define M68K_HAS_FPU            0
128# define M68K_HAS_FPSP_PACKAGE   0
129# endif
130 
131#elif defined(__mc68302__)
132#define CPU_MODEL_NAME          "m68302"
133#define M68K_HAS_VBR             0
134#define M68K_HAS_SEPARATE_STACKS 0
135#define M68K_HAS_BFFFO           0
136#define M68K_HAS_PREINDEXING     0
137#define M68K_HAS_EXTB_L          0
138#define M68K_HAS_MISALIGNED      0
139#define M68K_HAS_FPU             0
140#define M68K_HAS_FPSP_PACKAGE    0
141
142  /* gcc and egcs do not distinguish between CPU32 and CPU32+ */
143#elif defined(RTEMS__mcpu32p__)
144 
145#define CPU_MODEL_NAME          "mcpu32+"
146#define M68K_HAS_VBR             1
147#define M68K_HAS_SEPARATE_STACKS 0
148#define M68K_HAS_BFFFO           0
149#define M68K_HAS_PREINDEXING     1
150#define M68K_HAS_EXTB_L          1
151#define M68K_HAS_MISALIGNED      1
152#define M68K_HAS_FPU             0
153#define M68K_HAS_FPSP_PACKAGE    0
154
155#elif defined(__mcpu32__)
156 
157#define CPU_MODEL_NAME          "mcpu32"
158#define M68K_HAS_VBR             1
159#define M68K_HAS_SEPARATE_STACKS 0
160#define M68K_HAS_BFFFO           0
161#define M68K_HAS_PREINDEXING     1
162#define M68K_HAS_EXTB_L          1
163#define M68K_HAS_MISALIGNED      0
164#define M68K_HAS_FPU             0
165#define M68K_HAS_FPSP_PACKAGE    0
166
167#elif defined(__mc68000__)
168 
169#define CPU_MODEL_NAME          "m68000"
170#define M68K_HAS_VBR             0
171#define M68K_HAS_SEPARATE_STACKS 0
172#define M68K_HAS_BFFFO           0
173#define M68K_HAS_PREINDEXING     0
174#define M68K_HAS_EXTB_L          0
175#define M68K_HAS_MISALIGNED      0
176# if defined (__HAVE_68881__)
177# define M68K_HAS_FPU            1
178# define M68K_HAS_FPSP_PACKAGE   0
179# else
180# define M68K_HAS_FPU            0
181# define M68K_HAS_FPSP_PACKAGE   0
182# endif
183
184#else
185
186#error "Unsupported CPU model -- are you sure you're running a 68k compiler?"
187
188#endif
189
190/*
191 *  Define the name of the CPU family.
192 */
193
194#define CPU_NAME "Motorola MC68xxx"
195
196#ifndef ASM
197
198#define m68k_disable_interrupts( _level ) \
199  asm volatile ( "movew   %%sr,%0\n\t" \
200                 "orw     #0x0700,%%sr" \
201                    : "=d" (_level))
202
203#define m68k_enable_interrupts( _level ) \
204  asm volatile ( "movew   %0,%%sr " : : "d" (_level));
205
206#define m68k_flash_interrupts( _level ) \
207  asm volatile ( "movew   %0,%%sr\n\t" \
208                 "orw     #0x0700,%%sr" \
209                    : : "d" (_level))
210
211#define m68k_get_interrupt_level( _level ) \
212  do { \
213    register unsigned32 _tmpsr; \
214    \
215    asm volatile( "movw  %%sr,%0" : "=d" (_tmpsr)); \
216    _level = (_tmpsr & 0x0700) >> 8; \
217  } while (0)
218   
219#define m68k_set_interrupt_level( _newlevel ) \
220  do { \
221    register unsigned32 _tmpsr; \
222    \
223    asm volatile( "movw  %%sr,%0" : "=d" (_tmpsr)); \
224    _tmpsr = (_tmpsr & 0xf8ff) | ((_newlevel) << 8); \
225    asm volatile( "movw  %0,%%sr" : : "d" (_tmpsr)); \
226  } while (0)
227
228#if ( M68K_HAS_VBR == 1 )
229#define m68k_get_vbr( vbr ) \
230  asm volatile ( "movec   %%vbr,%0 " : "=r" (vbr))
231
232#define m68k_set_vbr( vbr ) \
233  asm volatile ( "movec   %0,%%vbr " : : "r" (vbr))
234#else
235#define m68k_get_vbr( _vbr ) _vbr = (void *)_VBR
236#define m68k_set_vbr( _vbr )
237#endif
238
239/*
240 *  The following routine swaps the endian format of an unsigned int.
241 *  It must be static because it is referenced indirectly.
242 */
243
244static inline unsigned int m68k_swap_u32(
245  unsigned int value
246)
247{
248  unsigned int swapped = value;
249
250  asm volatile( "rorw  #8,%0" : "=d" (swapped) : "0" (swapped) );
251  asm volatile( "swap  %0"    : "=d" (swapped) : "0" (swapped) );
252  asm volatile( "rorw  #8,%0" : "=d" (swapped) : "0" (swapped) );
253
254  return( swapped );
255}
256
257static inline unsigned int m68k_swap_u16(
258  unsigned int value
259)
260{
261  unsigned short swapped = value;
262
263  asm volatile( "rorw  #8,%0" : "=d" (swapped) : "0" (swapped) );
264
265  return( swapped );
266}
267
268/* XXX this is only valid for some m68k family members and should be fixed */
269
270#define m68k_enable_caching() \
271  { register unsigned32 _ctl=0x01; \
272    asm volatile ( "movec   %0,%%cacr" \
273                       : "=d" (_ctl) : "0" (_ctl) ); \
274  }
275
276#define CPU_swap_u32( value )  m68k_swap_u32( value )
277#define CPU_swap_u16( value )  m68k_swap_u16( value )
278
279#endif  /* !ASM */
280
281#ifdef __cplusplus
282}
283#endif
284
285#endif
286/* end of include file */
Note: See TracBrowser for help on using the repository browser.