1 | /* 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. |
---|
17 | * On-Line Applications Research Corporation (OAR). |
---|
18 | * Copyright assigned to U.S. Government, 1994. |
---|
19 | * |
---|
20 | * The license and distribution terms for this file may be |
---|
21 | * found in the file LICENSE in this distribution or at |
---|
22 | * http://www.OARcorp.com/rtems/license.html. |
---|
23 | * |
---|
24 | * $Id$ |
---|
25 | */ |
---|
26 | |
---|
27 | #ifndef _sh_h |
---|
28 | #define _sh_h |
---|
29 | |
---|
30 | #ifdef __cplusplus |
---|
31 | extern "C" { |
---|
32 | #endif |
---|
33 | |
---|
34 | /* |
---|
35 | * This file contains the information required to build |
---|
36 | * RTEMS for a particular member of the "SH" family. |
---|
37 | * |
---|
38 | * It does this by setting variables to indicate which implementation |
---|
39 | * dependent features are present in a particular member of the family. |
---|
40 | */ |
---|
41 | |
---|
42 | #if defined(sh7032) |
---|
43 | |
---|
44 | #define CPU_MODEL_NAME "SH 7032" |
---|
45 | #define SH_HAS_FPU 0 |
---|
46 | |
---|
47 | /* |
---|
48 | * If the following macro is set to 0 there will be no software irq stack |
---|
49 | */ |
---|
50 | #define SH_HAS_SEPARATE_STACKS 1 |
---|
51 | |
---|
52 | #elif defined (sh7045) |
---|
53 | |
---|
54 | #define CPU_MODEL_NAME "SH 7045" |
---|
55 | #define SH_HAS_FPU 0 |
---|
56 | |
---|
57 | /* |
---|
58 | * If the following macro is set to 0 there will be no software irq stack |
---|
59 | */ |
---|
60 | #define SH_HAS_SEPARATE_STACKS 1 |
---|
61 | |
---|
62 | #else |
---|
63 | |
---|
64 | #error "Unsupported CPU Model" |
---|
65 | |
---|
66 | #endif |
---|
67 | |
---|
68 | /* |
---|
69 | * Define the name of the CPU family. |
---|
70 | */ |
---|
71 | |
---|
72 | #define CPU_NAME "Hitachi SH" |
---|
73 | |
---|
74 | #ifndef ASM |
---|
75 | |
---|
76 | /* |
---|
77 | * Mask for disabling interrupts |
---|
78 | */ |
---|
79 | #define SH_IRQDIS_VALUE 0xf0 |
---|
80 | |
---|
81 | #define sh_disable_interrupts( _level ) \ |
---|
82 | asm volatile ( \ |
---|
83 | "stc sr,%0\n\t" \ |
---|
84 | "ldc %1,sr\n\t"\ |
---|
85 | : "=r" (_level ) \ |
---|
86 | : "r" (SH_IRQDIS_VALUE) ); |
---|
87 | |
---|
88 | #define sh_enable_interrupts( _level ) \ |
---|
89 | asm volatile( "ldc %0,sr\n\t" \ |
---|
90 | "nop\n\t" \ |
---|
91 | :: "r" (_level) ); |
---|
92 | |
---|
93 | /* |
---|
94 | * This temporarily restores the interrupt to _level before immediately |
---|
95 | * disabling them again. This is used to divide long RTEMS critical |
---|
96 | * sections into two or more parts. The parameter _level is not |
---|
97 | * modified. |
---|
98 | */ |
---|
99 | |
---|
100 | #define sh_flash_interrupts( _level ) \ |
---|
101 | asm volatile( \ |
---|
102 | "ldc %1,sr\n\t" \ |
---|
103 | "nop\n\t" \ |
---|
104 | "ldc %0,sr\n\t" \ |
---|
105 | "nop\n\t" \ |
---|
106 | : : "r" (SH_IRQDIS_VALUE), "r" (_level) ); |
---|
107 | |
---|
108 | #define sh_get_interrupt_level( _level ) \ |
---|
109 | { \ |
---|
110 | register unsigned32 _tmpsr ; \ |
---|
111 | \ |
---|
112 | asm volatile( "stc sr, %0" : "=r" (_tmpsr) ); \ |
---|
113 | _level = (_tmpsr & 0xf0) >> 4 ; \ |
---|
114 | } |
---|
115 | |
---|
116 | #define sh_set_interrupt_level( _newlevel ) \ |
---|
117 | { \ |
---|
118 | register unsigned32 _tmpsr; \ |
---|
119 | \ |
---|
120 | asm volatile ( "stc sr, %0" : "=r" (_tmpsr) ); \ |
---|
121 | _tmpsr = ( _tmpsr & ~0xf0 ) | ((_newlevel) << 4) ; \ |
---|
122 | asm volatile( "ldc %0,sr" :: "r" (_tmpsr) ); \ |
---|
123 | } |
---|
124 | |
---|
125 | /* |
---|
126 | * The following routine swaps the endian format of an unsigned int. |
---|
127 | * It must be static because it is referenced indirectly. |
---|
128 | */ |
---|
129 | |
---|
130 | static inline unsigned int sh_swap_u32( |
---|
131 | unsigned int value |
---|
132 | ) |
---|
133 | { |
---|
134 | register unsigned int swapped; |
---|
135 | |
---|
136 | asm volatile ( |
---|
137 | "swap.b %1,%0; " |
---|
138 | "swap.w %0,%0; " |
---|
139 | "swap.b %0,%0" |
---|
140 | : "=r" (swapped) |
---|
141 | : "r" (value) ); |
---|
142 | |
---|
143 | return( swapped ); |
---|
144 | } |
---|
145 | |
---|
146 | static inline unsigned int sh_swap_u16( |
---|
147 | unsigned int value |
---|
148 | ) |
---|
149 | { |
---|
150 | register unsigned int swapped ; |
---|
151 | |
---|
152 | asm volatile ( "swap.b %1,%0" : "=r" (swapped) : "r" (value) ); |
---|
153 | |
---|
154 | return( swapped ); |
---|
155 | } |
---|
156 | |
---|
157 | #define CPU_swap_u32( value ) sh_swap_u32( value ) |
---|
158 | #define CPU_swap_u16( value ) sh_swap_u16( value ) |
---|
159 | |
---|
160 | extern unsigned int sh_set_irq_priority( |
---|
161 | unsigned int irq, |
---|
162 | unsigned int prio ); |
---|
163 | |
---|
164 | #endif /* !ASM */ |
---|
165 | |
---|
166 | #ifdef __cplusplus |
---|
167 | } |
---|
168 | #endif |
---|
169 | |
---|
170 | #endif |
---|