OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [cpu/] [i960/] [cpu.c] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  Intel i960CA Dependent Source
3
 *
4
 *
5
 *  COPYRIGHT (c) 1989-1999.
6
 *  On-Line Applications Research Corporation (OAR).
7
 *
8
 *  The license and distribution terms for this file may be
9
 *  found in the file LICENSE in this distribution or at
10
 *  http://www.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: cpu.c,v 1.2 2001-09-27 11:59:27 chris Exp $
13
 */
14
/*
15
 * 1999/04/26: added support for Intel i960RP
16
 */
17
 
18
#if defined(__i960CA__) || defined(__i960_CA__) || defined(__i960CA)
19
#elif defined(__i960RP__)
20
#elif defined(__i960KA__)
21
#else
22
#warning "***  ENTIRE FILE IMPLEMENTED & TESTED FOR CA & RP ONLY  ***"
23
#warning "*** THIS FILE WILL NOT COMPILE ON ANOTHER FAMILY MEMBER ***"
24
#endif
25
 
26
#include <rtems/system.h>
27
#include <rtems/score/isr.h>
28
 
29
/*  _CPU_Initialize
30
 *
31
 *  This routine performs processor dependent initialization.
32
 *
33
 *  INPUT PARAMETERS:
34
 *    cpu_table       - CPU table to initialize
35
 *    thread_dispatch - address of disptaching routine
36
 *
37
 *  OUTPUT PARAMETERS: NONE
38
 */
39
 
40
void _CPU_Initialize(
41
  rtems_cpu_table  *cpu_table,
42
  void      (*thread_dispatch)      /* ignored on this CPU */
43
)
44
{
45
 
46
  _CPU_Table = *cpu_table;
47
 
48
}
49
 
50
/*PAGE
51
 *
52
 *  _CPU_ISR_Get_level
53
 */
54
 
55
unsigned32 _CPU_ISR_Get_level( void )
56
{
57
  unsigned32 level;
58
 
59
  i960_get_interrupt_level( level );
60
 
61
  return level;
62
}
63
 
64
/*PAGE
65
 *
66
 *  _CPU_ISR_install_raw_handler
67
 */
68
 
69
#if defined(__i960CA__) || defined(__i960_CA__) || defined(__i960CA)
70
#define i960_vector_caching_enabled( _prcb ) \
71
   ((_prcb)->control_tbl->icon & 0x2000)
72
#elif defined(__i960RP__)
73
#define i960_vector_caching_enabled( _prcb ) \
74
   ((*((unsigned int *) ICON_ADDR)) & 0x2000)
75
#elif defined(__i960KA__)
76
#define i960_vector_caching_enabled( _prcb )  0 /* XXX fix me */
77
#endif
78
 
79
void _CPU_ISR_install_raw_handler(
80
  unsigned32  vector,
81
  proc_ptr    new_handler,
82
  proc_ptr   *old_handler
83
)
84
{
85
  i960_PRCB   *prcb = _CPU_Table.Prcb;
86
  proc_ptr    *cached_intr_tbl = NULL;
87
 
88
  /*  The i80960CA does not support vectors 0-7.  The first 9 entries
89
   *  in the Interrupt Table are used to manage pending interrupts.
90
   *  Thus vector 8, the first valid vector number, is actually in
91
   *  slot 9 in the table.
92
   */
93
 
94
  *old_handler = prcb->intr_tbl[ vector + 1 ];
95
 
96
  prcb->intr_tbl[ vector + 1 ] = new_handler;
97
 
98
  if ( i960_vector_caching_enabled( prcb ) )
99
    if ( (vector & 0xf) == 0x2 )       /* cacheable? */
100
      cached_intr_tbl[ vector >> 4 ] = new_handler;
101
}
102
 
103
/*PAGE
104
 *
105
 *  _CPU__ISR_install_vector
106
 *
107
 *  Install the RTEMS vector wrapper in the CPU's interrupt table.
108
 *
109
 *  Input parameters:
110
 *    vector      - interrupt vector number
111
 *    old_handler - former ISR for this vector number
112
 *    new_handler - replacement ISR for this vector number
113
 *
114
 *  Output parameters:  NONE
115
 *
116
 */
117
 
118
void _CPU_ISR_install_vector(
119
  unsigned32  vector,
120
  proc_ptr    new_handler,
121
  proc_ptr   *old_handler
122
)
123
{
124
  proc_ptr ignored;
125
 
126
  *old_handler = _ISR_Vector_table[ vector ];
127
 
128
  _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored );
129
 
130
  _ISR_Vector_table[ vector ] = new_handler;
131
}
132
 
133
/*PAGE
134
 *
135
 *  _CPU_Install_interrupt_stack
136
 */
137
 
138
#if defined(__i960CA__) || defined(__i960_CA__) || defined(__i960CA)
139
#define soft_reset( prcb ) \
140
 { register i960_PRCB *_prcb = (prcb); \
141
   register unsigned32  *_next=0; \
142
   register unsigned32   _cmd  = 0x30000; \
143
   asm volatile( "lda    next,%1; \
144
                  sysctl %0,%1,%2; \
145
            next: mov    g0,g0" \
146
                  : "=d" (_cmd), "=d" (_next), "=d" (_prcb) \
147
                  : "0"  (_cmd), "1"  (_next), "2"  (_prcb) ); \
148
 }
149
#elif defined(__i960RP__) || defined(__i960_RP__) || defined(__i960RP)
150
#define soft_reset( prcb ) \
151
 { register i960_PRCB *_prcb = (prcb); \
152
   register unsigned32  *_next=0; \
153
   register unsigned32   _cmd  = 0x300; \
154
   asm volatile( "lda    next,%1; \
155
                  sysctl %0,%1,%2; \
156
            next: mov    g0,g0" \
157
                  : "=d" (_cmd), "=d" (_next), "=d" (_prcb) \
158
                  : "0"  (_cmd), "1"  (_next), "2"  (_prcb) ); \
159
 }
160
#elif defined(__i960KA__)
161
#define soft_reset( prcb ) /* XXX fix me */
162
#endif
163
 
164
void _CPU_Install_interrupt_stack( void )
165
{
166
  i960_PRCB *prcb = _CPU_Table.Prcb;
167
  unsigned32   level;
168
#if defined(__i960RP__) || defined(__i960_RP__)
169
  unsigned32 *isp = (int *) ISP_ADDR;
170
#endif
171
 
172
  /*
173
   *  Set the Interrupt Stack in the PRCB and force a reload of it.
174
   *  Interrupts are disabled for safety.
175
   */
176
 
177
  _CPU_ISR_Disable( level );
178
 
179
#if !defined(__i960_KA__)
180
    prcb->intr_stack = _CPU_Interrupt_stack_low;
181
#endif
182
 
183
#if defined(__i960CA__) || defined(__i960_CA__) || defined(__i960CA)
184
    soft_reset( prcb );
185
#elif defined(__i960RP__) || defined(__i960_RP__) || defined(__i960RP)
186
    *isp = (unsigned32) prcb->intr_stack;
187
#endif
188
 
189
  _CPU_ISR_Enable( level );
190
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.