source: rtems/cpukit/score/cpu/sh/rtems/score/sh.h @ 4a238002

4.104.114.84.95
Last change on this file since 4a238002 was 4a238002, checked in by Joel Sherrill <joel.sherrill@…>, on 11/18/99 at 21:22:58

Patch from "John M. Mills" <jmills@…> with subsequent cleanup from
Ralf Corsepius <corsepiu@…> that adds initial Hitachi SH-2
support to RTEMS. Ralf's comments are:

Changes:
------

  1. SH-Port:
  • Many files renamed.
  • CONSOLE_DEVNAME and MHZ defines removed from libcpu.
  • console.c moved to libbsp/sh/shared, build in libbsp/sh/<BSP>/console applying VPATH.
  • CONSOLE_DEVNAME made BSP-specific, replacement is defined in bsp.h
  • MHZ define replaced with HZ (extendent resolution) in custom/*.cfg
  • -DHZ=HZ used in bspstart.c, only
  • Makefile variable HZ used in bsp-dependent directories only.
  1. SH1-Port
  • clock-driver rewritten to provide better resolution for odd CPU frequencies. This driver is only partially tested on hardware, ie. sightly experimental, but I don't expect severe problems with it.
  • Polling SCI-driver added. This driver is experimental and completly untested yet. Therefore it is not yet used for the console (/dev/console is still pointing to /dev/null, cf. gensh1/bsp.h).
  • minor changes to the timer driver
  • SH1 specific delay()/CPU_delay() now is implemented as a function
  1. SH2-Port
  • Merged
  • IMO, the code is still in its infancy. Therefore I have interspersed comments (FIXME) it for items which I think John should look after.
  • sci and console drivers partially rewritten and extended (John, I hope you don't mind).
  • Copyright notices are not yet adapted
  • Property mode set to 100644
File size: 3.6 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
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 
130static 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
146static 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
160extern 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
Note: See TracBrowser for help on using the repository browser.