source: rtems/cpukit/score/cpu/sh/cpu.c @ 510fbfc3

5
Last change on this file since 510fbfc3 was 510fbfc3, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/18 at 14:31:03

sh: Remove use of proc_ptr

Update #3585.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief SuperH CPU Support
5 *
6 * This file contains information pertaining to the Hitachi SH
7 * processor.
8 */
9
10/*
11 *  Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and
12 *           Bernd Becker (becker@faw.uni-ulm.de)
13 *
14 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
15 *
16 *  This program is distributed in the hope that it will be useful,
17 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 *
21 *  COPYRIGHT (c) 1998-2001.
22 *  On-Line Applications Research Corporation (OAR).
23 *
24 *  The license and distribution terms for this file may be
25 *  found in the file LICENSE in this distribution or at
26 *  http://www.rtems.org/license/LICENSE.
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <rtems/system.h>
34#include <rtems/score/isr.h>
35#include <rtems/score/sh_io.h>
36#include <rtems/score/cpu.h>
37#include <rtems/score/sh.h>
38
39/* referenced in start.S */
40CPU_ISR_raw_handler vectab[256] ;
41
42#if SH_HAS_FPU
43Context_Control_fp _CPU_Null_fp_context;
44#endif
45
46/*  _CPU_Initialize
47 *
48 *  This routine performs processor dependent initialization.
49 *
50 *  INPUT PARAMETERS: NONE
51 */
52
53void _CPU_Initialize(void)
54{
55  register uint32_t   level = 0;
56
57  /*
58   *  If there is not an easy way to initialize the FP context
59   *  during Context_Initialize, then it is usually easier to
60   *  save an "uninitialized" FP context here and copy it to
61   *  the task's during Context_Initialize.
62   */
63
64  /* FP context initialization support goes here */
65#if SH_HAS_FPU
66  /* FIXME: When not to use SH4_FPSCR_PR ? */
67#ifdef __SH4__
68  _CPU_Null_fp_context.fpscr = SH4_FPSCR_DN | SH4_FPSCR_RM | SH4_FPSCR_PR;
69#endif
70#ifdef __SH3E__
71  /* FIXME: Wild guess :) */
72  _CPU_Null_fp_context.fpscr = SH4_FPSCR_DN | SH4_FPSCR_RM;
73#endif
74#endif
75
76  /* enable interrupts */
77  _CPU_ISR_Set_level( level ) ;
78}
79
80/*
81 *  _CPU_ISR_Get_level
82 */
83
84uint32_t   _CPU_ISR_Get_level( void )
85{
86  /*
87   *  This routine returns the current interrupt level.
88   */
89
90  register uint32_t   _mask ;
91
92  sh_get_interrupt_level( _mask );
93
94  return ( _mask);
95}
96
97void _CPU_ISR_install_raw_handler(
98  uint32_t             vector,
99  CPU_ISR_raw_handler  new_handler,
100  CPU_ISR_raw_handler *old_handler
101)
102
103{
104  /*
105   *  This is where we install the interrupt handler into the "raw" interrupt
106   *  table used by the CPU to dispatch interrupt handlers.
107   */
108  volatile CPU_ISR_raw_handler *vbr ;
109
110#if SH_PARANOID_ISR
111  uint32_t              level ;
112
113  sh_disable_interrupts( level );
114#endif
115
116  /* get vbr */
117  __asm__ ( "stc vbr,%0" : "=r" (vbr) );
118
119  *old_handler = vbr[vector] ;
120  vbr[vector]  = new_handler ;
121
122#if SH_PARANOID_ISR
123  sh_enable_interrupts( level );
124#endif
125}
126
127void _CPU_ISR_install_vector(
128  uint32_t         vector,
129  CPU_ISR_handler  new_handler,
130  CPU_ISR_handler *old_handler
131)
132{
133#if defined(__sh1__) || defined(__sh2__)
134   CPU_ISR_raw_handler ignored ;
135#endif
136   *old_handler = _ISR_Vector_table[ vector ];
137
138 /*
139  *  If the interrupt vector table is a table of pointer to isr entry
140  *  points, then we need to install the appropriate RTEMS interrupt
141  *  handler for this vector number.
142  */
143#if defined(__sh1__) || defined(__sh2__)
144  _CPU_ISR_install_raw_handler(vector, _Hardware_isr_Table[vector], &ignored );
145#endif
146
147 /*
148  *  We put the actual user ISR address in '_ISR_Vector_table'.
149  *  This will be used by __ISR_Handler so the user gets control.
150  */
151
152 _ISR_Vector_table[ vector ] = new_handler;
153}
154
155void _CPU_Context_Initialize(
156  Context_Control       *_the_context,
157  void                  *_stack_base,
158  uint32_t              _size,
159  uint32_t              _isr,
160  void  (*_entry_point)(void),
161  int                   _is_fp,
162  void                  *_tls_base)
163{
164  _the_context->r15 = (uint32_t *) ((uint32_t) (_stack_base) + (_size) );
165#if defined(__sh1__) || defined(__sh2__) || defined(__SH2E__)
166  _the_context->sr  = (_isr << 4) & 0x00f0 ;
167#else
168  _the_context->sr  = SH4_SR_MD | ((_isr << 4) & 0x00f0);
169#endif
170  _the_context->pr  = (uint32_t *) _entry_point ;
171
172
173#if 0 && SH_HAS_FPU
174   /* Disable FPU if it is non-fp task */
175  if(!_is_fp)
176    _the_context->sr |= SH4_SR_FD;
177#endif
178}
Note: See TracBrowser for help on using the repository browser.