source: rtems/c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c @ d3d9ef37

4.104.114.84.95
Last change on this file since d3d9ef37 was faed5fa, checked in by Jennifer Averett <Jennifer.Averett@…>, on Nov 22, 2004 at 10:15:47 PM

2004-11-22 Jennifer Averett <jennifer@…>

PR 581/bsps

  • mpc6xx/exceptions/raw_exception.c, shared/include/cpuIdent.h: Converting PSIM to new exception model required adding PSIM as PowerPC CPU model.
  • Property mode set to 100644
File size: 8.3 KB
Line 
1/*
2 * raw_exception.c  - This file contains implementation of C function to
3 *                    Instantiate 60x ppc primary exception entries.
4 *                    More detailed information can be found on motorola
5 *                    site and more precisely in the following book :
6 *
7 *                    MPC750
8 *                    Risc Microporcessor User's Manual
9 *                    Motorola REF : MPC750UM/AD 8/97
10 *
11 * Copyright (C) 1999  Eric Valette (valette@crf.canon.fr)
12 *                     Canon Centre Recherche France.
13 *
14 * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
15 * to support 603, 603e, 604, 604e exceptions
16 *
17 *  The license and distribution terms for this file may be
18 *  found in found in the file LICENSE in this distribution or at
19 *  http://www.rtems.com/license/LICENSE.
20 *
21 * $Id$
22 */
23#include <rtems/system.h>
24#include <rtems/score/powerpc.h>
25#include <rtems/bspIo.h>
26#include <libcpu/raw_exception.h>
27#include <libcpu/cpuIdent.h>
28
29#include <string.h>
30
31static rtems_raw_except_connect_data*           raw_except_table;
32static rtems_raw_except_connect_data            default_raw_except_entry;
33static rtems_raw_except_global_settings*        local_settings;
34
35void * codemove(void *, const void *, unsigned int, unsigned long);
36
37void* mpc60x_get_vector_addr(rtems_vector vector)
38{
39  extern rtems_cpu_table Cpu_table;
40
41  if ( Cpu_table.exceptions_in_RAM )
42    return ((void*)  (((unsigned) vector) << 8));
43
44  return ((void*)  (((unsigned) vector) << 8) + 0xfff00000);
45}
46
47int mpc750_vector_is_valid(rtems_vector vector)
48
49{
50  switch(vector) {
51  case ASM_RESET_VECTOR: /* fall through */
52  case ASM_MACH_VECTOR:
53  case ASM_PROT_VECTOR:
54  case ASM_ISI_VECTOR:
55  case ASM_EXT_VECTOR:
56  case ASM_ALIGN_VECTOR:
57  case ASM_PROG_VECTOR:
58  case ASM_FLOAT_VECTOR:
59  case ASM_DEC_VECTOR:
60  case ASM_SYS_VECTOR:
61  case ASM_TRACE_VECTOR:
62  case ASM_ADDR_VECTOR:
63  case ASM_SYSMGMT_VECTOR:
64  case ASM_ITM_VECTOR:
65    return 1;
66  default: return 0;
67  }
68}
69
70int PSIM_vector_is_valid(rtems_vector vector)
71{
72  switch(vector) {
73  case ASM_RESET_VECTOR: /* fall through */
74  case ASM_MACH_VECTOR:
75  case ASM_PROT_VECTOR:
76  case ASM_ISI_VECTOR:
77  case ASM_EXT_VECTOR:
78  case ASM_ALIGN_VECTOR:
79  case ASM_PROG_VECTOR:
80  case ASM_FLOAT_VECTOR:
81  case ASM_DEC_VECTOR:
82    return 1;
83  case ASM_SYS_VECTOR:
84    return 0;
85  case ASM_TRACE_VECTOR:
86    return 1;
87  case ASM_PERFMON_VECTOR:
88    return 0;
89  case ASM_IMISS_VECTOR: /* fall through */
90  case ASM_DLMISS_VECTOR:
91  case ASM_DSMISS_VECTOR:
92  case ASM_ADDR_VECTOR:
93  case ASM_SYSMGMT_VECTOR:
94    return 1;
95  case ASM_ITM_VECTOR:
96    return 0;
97  }
98  return 0;
99}
100
101int mpc603_vector_is_valid(rtems_vector vector)
102{
103  switch(vector) {
104  case ASM_RESET_VECTOR: /* fall through */
105  case ASM_MACH_VECTOR:
106  case ASM_PROT_VECTOR:
107  case ASM_ISI_VECTOR:
108  case ASM_EXT_VECTOR:
109  case ASM_ALIGN_VECTOR:
110  case ASM_PROG_VECTOR:
111  case ASM_FLOAT_VECTOR:
112  case ASM_DEC_VECTOR:
113  case ASM_SYS_VECTOR:
114  case ASM_TRACE_VECTOR:
115    return 1;
116  case ASM_PERFMON_VECTOR:
117    return 0;
118  case ASM_IMISS_VECTOR: /* fall through */
119  case ASM_DLMISS_VECTOR:
120  case ASM_DSMISS_VECTOR:
121  case ASM_ADDR_VECTOR:
122  case ASM_SYSMGMT_VECTOR:
123    return 1;
124  case ASM_ITM_VECTOR:
125    return 0;
126  }
127  return 0;
128}
129
130int mpc604_vector_is_valid(rtems_vector vector)
131{
132  switch(vector) {
133  case ASM_RESET_VECTOR: /* fall through */
134  case ASM_MACH_VECTOR:
135  case ASM_PROT_VECTOR:
136  case ASM_ISI_VECTOR:
137  case ASM_EXT_VECTOR:
138  case ASM_ALIGN_VECTOR:
139  case ASM_PROG_VECTOR:
140  case ASM_FLOAT_VECTOR:
141  case ASM_DEC_VECTOR:
142  case ASM_SYS_VECTOR:
143  case ASM_TRACE_VECTOR:
144  case ASM_PERFMON_VECTOR:
145    return 1;
146  case ASM_IMISS_VECTOR: /* fall through */
147  case ASM_DLMISS_VECTOR:
148  case ASM_DSMISS_VECTOR:
149    return 0;
150  case ASM_ADDR_VECTOR: /* fall through */
151  case ASM_SYSMGMT_VECTOR:
152    return 1;
153  case ASM_ITM_VECTOR:
154    return 0;
155  }
156  return 0;
157}
158
159int mpc60x_vector_is_valid(rtems_vector vector)
160{
161     switch (current_ppc_cpu) {
162        case PPC_7400:
163        case PPC_750:
164            if (!mpc750_vector_is_valid(vector)) {
165                return 0;
166            }
167            break;
168        case PPC_604:
169        case PPC_604e:
170        case PPC_604r:
171        case PPC_7455:   /* Kate Feng */
172            if (!mpc604_vector_is_valid(vector)) {
173                return 0;
174            }
175            break;
176        case PPC_603:
177        case PPC_603e:
178        case PPC_603ev:
179        case PPC_8260:
180        /* case PPC_8240: -- same value as 8260 */
181        case PPC_8245:
182            if (!mpc603_vector_is_valid(vector)) {
183                return 0;
184            }
185            break;
186        case PPC_PSIM:
187            if (!PSIM_vector_is_valid(vector)) {
188                return 0;
189            }
190            break;
191         default:
192            printk("Please complete "
193                   "libcpu/powerpc/mpc6xx/exceptions/raw_exception.c\n"
194                   "current_ppc_cpu = %x\n", current_ppc_cpu);
195            return 0;
196     }
197     return 1;
198}
199
200int mpc60x_set_exception  (const rtems_raw_except_connect_data* except)
201{
202    unsigned int level;
203
204    if (!mpc60x_vector_is_valid(except->exceptIndex)) {
205      printk("mpc60x_set_exception: vector %d is not valid\n",
206              except->exceptIndex);
207      return 0;
208    }
209    /*
210     * Check if default handler is actually connected. If not issue an error.
211     * You must first get the current handler via mpc60x_get_current_exception
212     * and then disconnect it using mpc60x_delete_exception.
213     * RATIONALE : to always have the same transition by forcing the user
214     * to get the previous handler before accepting to disconnect.
215     */
216
217    if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
218               (void*)default_raw_except_entry.hdl.raw_hdl,
219               default_raw_except_entry.hdl.raw_hdl_size)) {
220      printk("mpc60x_set_exception: raw vector not installed\n");
221      return 0;
222    }
223
224    _CPU_ISR_Disable(level);
225   
226    raw_except_table [except->exceptIndex] = *except;
227    codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
228             except->hdl.raw_hdl,
229             except->hdl.raw_hdl_size,
230             PPC_CACHE_ALIGNMENT);
231    except->on(except);
232   
233    _CPU_ISR_Enable(level);
234    return 1;
235}
236
237int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
238{
239  if (!mpc60x_vector_is_valid(except->exceptIndex)){
240    return 0;
241  }
242   
243  *except = raw_except_table [except->exceptIndex];
244   
245  return 1;
246}
247
248int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
249{
250  unsigned int level;
251 
252  if (!mpc60x_vector_is_valid(except->exceptIndex)){
253    return 0;
254  }
255  /*
256   * Check if handler passed is actually connected. If not issue an error.
257   * You must first get the current handler via mpc60x_get_current_exception
258   * and then disconnect it using mpc60x_delete_exception.
259   * RATIONALE : to always have the same transition by forcing the user
260   * to get the previous handler before accepting to disconnect.
261   */
262  if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
263             (void*)except->hdl.raw_hdl,
264             except->hdl.raw_hdl_size)) {
265      return 0;
266  }
267  _CPU_ISR_Disable(level);
268
269  except->off(except);
270  codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
271           default_raw_except_entry.hdl.raw_hdl,
272           default_raw_except_entry.hdl.raw_hdl_size,
273           PPC_CACHE_ALIGNMENT);
274
275   
276  raw_except_table[except->exceptIndex] = default_raw_except_entry;
277  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
278
279  _CPU_ISR_Enable(level);
280   
281  return 1;
282}
283
284/*
285 * Exception global init.
286 */
287int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
288{
289    unsigned                    i;
290    unsigned int level;
291   
292    /*
293     * store various accelerators
294     */
295    raw_except_table            = config->rawExceptHdlTbl;
296    local_settings              = config;
297    default_raw_except_entry    = config->defaultRawEntry;
298
299    _CPU_ISR_Disable(level);
300
301    for (i=0; i <= LAST_VALID_EXC; i++) {
302      if (!mpc60x_vector_is_valid(i)){
303        continue;
304      }
305      codemove((void*)mpc60x_get_vector_addr(i),
306             raw_except_table[i].hdl.raw_hdl,
307             raw_except_table[i].hdl.raw_hdl_size,
308             PPC_CACHE_ALIGNMENT);
309      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
310        raw_except_table[i].on(&raw_except_table[i]);
311      }
312      else {
313        raw_except_table[i].off(&raw_except_table[i]);
314      }
315    }
316    _CPU_ISR_Enable(level);
317
318    return 1;
319}
320
321int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
322{
323  *config = local_settings;
324  return 1;
325}
Note: See TracBrowser for help on using the repository browser.