source: rtems/c/src/exec/score/cpu/sh/rtems/score/sh.h @ df49c60

4.104.114.84.95
Last change on this file since df49c60 was df49c60, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/00 at 15:00:15

Merged from 4.5.0-beta3a

  • Property mode set to 100644
File size: 3.7 KB
Line 
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
31extern "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(rtems_multilib)
43/*
44 *  Figure out all CPU Model Feature Flags based upon compiler
45 *  predefines.
46 */
47
48#define CPU_MODEL_NAME  "rtems_multilib"
49#define SH_HAS_FPU      0
50#define SH_HAS_SEPARATE_STACKS 1
51
52#elif defined(sh7032)
53#define CPU_MODEL_NAME  "SH7032"
54#define SH_HAS_FPU      0
55
56#elif defined (sh7045)
57#define CPU_MODEL_NAME  "SH7045"
58#define SH_HAS_FPU      0
59
60#else
61#error "Unsupported CPU Model"
62 
63#endif
64
65/*
66 * If the following macro is set to 0 there will be no software irq stack
67 */
68
69#ifndef SH_HAS_SEPARATE_STACKS
70#define SH_HAS_SEPARATE_STACKS 1
71#endif
72
73/*
74 *  Define the name of the CPU family.
75 */
76
77#define CPU_NAME "Hitachi SH"
78
79#ifndef ASM
80
81/*
82 * Mask for disabling interrupts
83 */
84#define SH_IRQDIS_VALUE 0xf0
85
86#define sh_disable_interrupts( _level ) \
87  asm volatile ( \
88    "stc sr,%0\n\t" \
89    "ldc %1,sr\n\t"\
90  : "=&r" (_level ) \
91  : "r" (SH_IRQDIS_VALUE) );
92
93#define sh_enable_interrupts( _level ) \
94  asm volatile( "ldc %0,sr\n\t" \
95    "nop\n\t" \
96    :: "r" (_level) );
97
98/*
99 *  This temporarily restores the interrupt to _level before immediately
100 *  disabling them again.  This is used to divide long RTEMS critical
101 *  sections into two or more parts.  The parameter _level is not
102 *  modified.
103 */
104     
105#define sh_flash_interrupts( _level ) \
106  asm volatile( \
107    "ldc %1,sr\n\t" \
108    "nop\n\t" \
109    "ldc %0,sr\n\t" \
110    "nop\n\t" \
111    : : "r" (SH_IRQDIS_VALUE), "r" (_level) );
112
113#define sh_get_interrupt_level( _level ) \
114{ \
115  register unsigned32 _tmpsr ; \
116  \
117  asm volatile( "stc sr, %0" : "=r" (_tmpsr) ); \
118  _level = (_tmpsr & 0xf0) >> 4 ; \
119}
120
121#define sh_set_interrupt_level( _newlevel ) \
122{ \
123  register unsigned32 _tmpsr; \
124  \
125  asm volatile ( "stc sr, %0" : "=r" (_tmpsr) ); \
126  _tmpsr = ( _tmpsr & ~0xf0 ) | ((_newlevel) << 4) ; \
127  asm  volatile( "ldc %0,sr" :: "r" (_tmpsr) ); \
128}
129
130/*
131 *  The following routine swaps the endian format of an unsigned int.
132 *  It must be static because it is referenced indirectly.
133 */
134 
135static inline unsigned int sh_swap_u32(
136  unsigned int value
137)
138{
139  register unsigned int swapped;
140 
141  asm volatile (
142    "swap.b %1,%0; "
143    "swap.w %0,%0; "
144    "swap.b %0,%0"
145    : "=r" (swapped)
146    : "r"  (value) );
147
148  return( swapped );
149}
150
151static inline unsigned int sh_swap_u16(
152  unsigned int value
153)
154{
155  register unsigned int swapped ;
156
157  asm volatile ( "swap.b %1,%0" : "=r" (swapped) : "r"  (value) );
158
159  return( swapped );
160}
161
162#define CPU_swap_u32( value ) sh_swap_u32( value )
163#define CPU_swap_u16( value ) sh_swap_u16( value )
164
165extern unsigned int sh_set_irq_priority(
166  unsigned int irq,
167  unsigned int prio );
168
169#endif /* !ASM */
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif
Note: See TracBrowser for help on using the repository browser.