source: rtems/cpukit/score/cpu/sh/rtems/score/sh.h @ 97c465c

4.104.114.84.95
Last change on this file since 97c465c was 97c465c, checked in by Joel Sherrill <joel.sherrill@…>, on 11/18/99 at 21:30:12

Minor cleanup to reduce the code space.

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