OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [score/] [cpu/] [sh/] [rtems/] [score/] [sh.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*  sh.h
2
 *
3
 *  This include file contains information pertaining to the Hitachi SH
4
 *  processor.
5
 *
6
 *  Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and
7
 *           Bernd Becker (becker@faw.uni-ulm.de)
8
 *
9
 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
14
 *
15
 *
16
 *  COPYRIGHT (c) 1998-2001.
17
 *  On-Line Applications Research Corporation (OAR).
18
 *
19
 *  The license and distribution terms for this file may be
20
 *  found in the file LICENSE in this distribution or at
21
 *  http://www.OARcorp.com/rtems/license.html.
22
 *
23
 *  sh.h,v 1.9 2001/10/12 17:46:47 joel Exp
24
 */
25
 
26
#ifndef _sh_h
27
#define _sh_h
28
 
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
 
33
/*
34
 *  This file contains the information required to build
35
 *  RTEMS for a particular member of the "SH" family.
36
 *
37
 *  It does  this by setting variables to indicate which implementation
38
 *  dependent features are present in a particular member of the family.
39
 */
40
 
41
/*
42
 *  Figure out all CPU Model Feature Flags based upon compiler
43
 *  predefines.
44
 */
45
 
46
#if defined(__SH3E__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
47
 
48
/*
49
 * Define this if you want to use XD-registers.
50
 * Then this registers will be saved/restored on context switch.
51
 * ! They will not be saved/restored on interrupts!
52
 */
53
#define SH4_USE_X_REGISTERS     0
54
 
55
#if defined(__LITTLE_ENDIAN__)
56
#define SH_HAS_FPU 1
57
#else
58
/* FIXME: Context_Control_fp does not support big endian */
59
#warning FPU not supported
60
#define SH_HAS_FPU 0
61
#endif
62
 
63
#elif defined(__sh1__) || defined(__sh2__) || defined(__sh3__)
64
#define SH_HAS_FPU 0
65
#else
66
#warning Cannot detect FPU support, assuming no FPU
67
#define SH_HAS_FPU 0
68
#endif
69
 
70
/* this should not be here */
71
#ifndef CPU_MODEL_NAME
72
#define CPU_MODEL_NAME  "SH-Multilib"
73
#endif
74
 
75
/*
76
 * If the following macro is set to 0 there will be no software irq stack
77
 */
78
 
79
#ifndef SH_HAS_SEPARATE_STACKS
80
#define SH_HAS_SEPARATE_STACKS 1
81
#endif
82
 
83
/*
84
 *  Define the name of the CPU family.
85
 */
86
 
87
#define CPU_NAME "Hitachi SH"
88
 
89
#ifndef ASM
90
 
91
#if defined(__sh1__) || defined(__sh2__)
92
 
93
/*
94
 * Mask for disabling interrupts
95
 */
96
#define SH_IRQDIS_VALUE 0xf0
97
 
98
#define sh_disable_interrupts( _level ) \
99
  asm volatile ( \
100
    "stc sr,%0\n\t" \
101
    "ldc %1,sr\n\t"\
102
  : "=&r" (_level ) \
103
  : "r" (SH_IRQDIS_VALUE) );
104
 
105
#define sh_enable_interrupts( _level ) \
106
  asm volatile( "ldc %0,sr\n\t" \
107
    "nop\n\t" \
108
    :: "r" (_level) );
109
 
110
/*
111
 *  This temporarily restores the interrupt to _level before immediately
112
 *  disabling them again.  This is used to divide long RTEMS critical
113
 *  sections into two or more parts.  The parameter _level is not
114
 *  modified.
115
 */
116
 
117
#define sh_flash_interrupts( _level ) \
118
  asm volatile( \
119
    "ldc %1,sr\n\t" \
120
    "nop\n\t" \
121
    "ldc %0,sr\n\t" \
122
    "nop\n\t" \
123
    : : "r" (SH_IRQDIS_VALUE), "r" (_level) );
124
 
125
#else
126
 
127
#define SH_IRQDIS_MASK 0xf0
128
 
129
#define sh_disable_interrupts( _level ) \
130
  asm volatile ( \
131
    "stc sr,%0\n\t" \
132
    "mov %0,r5\n\t" \
133
    "or %1,r5\n\t" \
134
    "ldc r5,sr\n\t"\
135
  : "=&r" (_level ) \
136
  : "r" (SH_IRQDIS_MASK) \
137
  : "r5" );
138
 
139
#define sh_enable_interrupts( _level ) \
140
  asm volatile( "ldc %0,sr\n\t" \
141
    "nop\n\t" \
142
    :: "r" (_level) );
143
 
144
/*
145
 *  This temporarily restores the interrupt to _level before immediately
146
 *  disabling them again.  This is used to divide long RTEMS critical
147
 *  sections into two or more parts.  The parameter _level is not
148
 *  modified.
149
 */
150
 
151
#define sh_flash_interrupts( _level ) \
152
  asm volatile( \
153
    "stc sr,r5\n\t" \
154
    "ldc %1,sr\n\t" \
155
    "nop\n\t" \
156
    "or %0,r5\n\t" \
157
    "ldc r5,sr\n\t" \
158
    "nop\n\t" \
159
    : : "r" (SH_IRQDIS_MASK), "r" (_level) : "r5");
160
 
161
#endif
162
 
163
#define sh_get_interrupt_level( _level ) \
164
{ \
165
  register unsigned32 _tmpsr ; \
166
  \
167
  asm volatile( "stc sr, %0" : "=r" (_tmpsr) ); \
168
  _level = (_tmpsr & 0xf0) >> 4 ; \
169
}
170
 
171
#define sh_set_interrupt_level( _newlevel ) \
172
{ \
173
  register unsigned32 _tmpsr; \
174
  \
175
  asm volatile ( "stc sr, %0" : "=r" (_tmpsr) ); \
176
  _tmpsr = ( _tmpsr & ~0xf0 ) | ((_newlevel) << 4) ; \
177
  asm  volatile( "ldc %0,sr" :: "r" (_tmpsr) ); \
178
}
179
 
180
/*
181
 *  The following routine swaps the endian format of an unsigned int.
182
 *  It must be static because it is referenced indirectly.
183
 */
184
 
185
static inline unsigned int sh_swap_u32(
186
  unsigned int value
187
)
188
{
189
  register unsigned int swapped;
190
 
191
  asm volatile (
192
    "swap.b %1,%0; "
193
    "swap.w %0,%0; "
194
    "swap.b %0,%0"
195
    : "=r" (swapped)
196
    : "r"  (value) );
197
 
198
  return( swapped );
199
}
200
 
201
static inline unsigned int sh_swap_u16(
202
  unsigned int value
203
)
204
{
205
  register unsigned int swapped ;
206
 
207
  asm volatile ( "swap.b %1,%0" : "=r" (swapped) : "r"  (value) );
208
 
209
  return( swapped );
210
}
211
 
212
#define CPU_swap_u32( value ) sh_swap_u32( value )
213
#define CPU_swap_u16( value ) sh_swap_u16( value )
214
 
215
extern unsigned int sh_set_irq_priority(
216
  unsigned int irq,
217
  unsigned int prio );
218
 
219
#endif /* !ASM */
220
 
221
/*
222
 * Bits on SH-4 registers.
223
 * See SH-4 Programming manual for more details.
224
 *
225
 * Added by Alexandra Kossovsky <sasha@oktet.ru>
226
 */
227
 
228
#if defined(__SH4__)
229
#define SH4_SR_MD          0x40000000 /* Priveleged mode */
230
#define SH4_SR_RB          0x20000000 /* General register bank specifier */
231
#define SH4_SR_BL          0x10000000 /* Exeption/interrupt masking bit */
232
#define SH4_SR_FD          0x00008000 /* FPU disable bit */
233
#define SH4_SR_M           0x00000200 /* For signed division:
234
                                         divisor (module) is negative */
235
#define SH4_SR_Q           0x00000100 /* For signed division:
236
                                         dividend (and quotient) is negative */
237
#define SH4_SR_IMASK       0x000000f0 /* Interrupt mask level */
238
#define SH4_SR_IMASK_S     4
239
#define SH4_SR_S           0x00000002 /* Saturation for MAC instruction:
240
                                         if set, data in MACH/L register
241
                                         is restricted to 48/32 bits
242
                                         for MAC.W/L instructions */
243
#define SH4_SR_T           0x00000001 /* 1 if last condiyion was true */
244
#define SH4_SR_RESERV      0x8fff7d0d /* Reserved bits, read/write as 0 */
245
 
246
/* FPSCR -- FPU Starus/Control Register */
247
#define SH4_FPSCR_FR       0x00200000 /* FPU register bank specifier */
248
#define SH4_FPSCR_SZ       0x00100000 /* FMOV 64-bit transfer mode */
249
#define SH4_FPSCR_PR       0x00080000 /* Double-percision floating-point
250
                                         operations flag */
251
                                      /* SH4_FPSCR_SZ & SH4_FPSCR_PR != 1 */
252
#define SH4_FPSCR_DN       0x00040000 /* Treat denormalized number as zero */
253
#define SH4_FPSCR_CAUSE    0x0003f000 /* FPU exeption cause field */
254
#define SH4_FPSCR_CAUSE_S  12
255
#define SH4_FPSCR_ENABLE   0x00000f80 /* FPU exeption enable field */
256
#define SH4_FPSCR_ENABLE_s 7
257
#define SH4_FPSCR_FLAG     0x0000007d /* FPU exeption flag field */
258
#define SH4_FPSCR_FLAG_S   2
259
#define SH4_FPSCR_RM       0x00000001 /* Rounding mode:
260
                                         1/0 -- round to zero/nearest */
261
#define SH4_FPSCR_RESERV   0xffd00000 /* Reserved bits, read/write as 0 */
262
 
263
#endif
264
 
265
#ifdef __cplusplus
266
}
267
#endif
268
 
269
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.