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

4.104.114.84.95
Last change on this file since e05f4315 was e05f4315, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 17, 2002 at 1:54:49 PM

2002-04-16 Ralf Corsepius <corsepiu@…>

  • exceptions/raw_exception.c: Include <libcpu/cpuIdent.h>.
  • Property mode set to 100644
File size: 6.9 KB
Line 
1/*
2 * raw_exception.c  - This file contains implementation of C function to
3 *                    Instanciate 60x ppc primary exception entries.
4 *                    More detailled 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.OARcorp.com/rtems/license.html.
20 *
21 * $Id$
22 */
23#include <rtems/score/targopts.h>
24#include <rtems/score/ppc.h>
25#include <rtems/system.h>
26#include <rtems/score/cpu.h>
27#include <libcpu/raw_exception.h>
28#include <libcpu/cpu.h>
29#include <libcpu/cpuIdent.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
35int mpc750_vector_is_valid(rtems_vector vector)
36{
37  switch(vector) {
38  case ASM_RESET_VECTOR: /* fall through */
39  case ASM_MACH_VECTOR:
40  case ASM_PROT_VECTOR:
41  case ASM_ISI_VECTOR:
42  case ASM_EXT_VECTOR:
43  case ASM_ALIGN_VECTOR:
44  case ASM_PROG_VECTOR:
45  case ASM_FLOAT_VECTOR:
46  case ASM_DEC_VECTOR:
47  case ASM_SYS_VECTOR:
48  case ASM_TRACE_VECTOR:
49  case ASM_ADDR_VECTOR:
50  case ASM_SYSMGMT_VECTOR:
51  case ASM_ITM_VECTOR:
52    return 1;
53  default: return 0;
54  }
55}
56
57int mpc603_vector_is_valid(rtems_vector vector)
58{
59  switch(vector) {
60  case ASM_RESET_VECTOR: /* fall through */
61  case ASM_MACH_VECTOR:
62  case ASM_PROT_VECTOR:
63  case ASM_ISI_VECTOR:
64  case ASM_EXT_VECTOR:
65  case ASM_ALIGN_VECTOR:
66  case ASM_PROG_VECTOR:
67  case ASM_FLOAT_VECTOR:
68  case ASM_DEC_VECTOR:
69  case ASM_SYS_VECTOR:
70  case ASM_TRACE_VECTOR:
71    return 1;
72  case ASM_PERFMON_VECTOR:
73    return 0;
74  case ASM_IMISS_VECTOR: /* fall through */
75  case ASM_DLMISS_VECTOR:
76  case ASM_DSMISS_VECTOR:
77  case ASM_ADDR_VECTOR:
78  case ASM_SYSMGMT_VECTOR:
79    return 1;
80  case ASM_ITM_VECTOR:
81    return 0;
82  }
83  return 0;
84}
85
86int mpc604_vector_is_valid(rtems_vector vector)
87{
88  switch(vector) {
89  case ASM_RESET_VECTOR: /* fall through */
90  case ASM_MACH_VECTOR:
91  case ASM_PROT_VECTOR:
92  case ASM_ISI_VECTOR:
93  case ASM_EXT_VECTOR:
94  case ASM_ALIGN_VECTOR:
95  case ASM_PROG_VECTOR:
96  case ASM_FLOAT_VECTOR:
97  case ASM_DEC_VECTOR:
98  case ASM_SYS_VECTOR:
99  case ASM_TRACE_VECTOR:
100  case ASM_PERFMON_VECTOR:
101    return 1;
102  case ASM_IMISS_VECTOR: /* fall through */
103  case ASM_DLMISS_VECTOR:
104  case ASM_DSMISS_VECTOR:
105    return 0;
106  case ASM_ADDR_VECTOR: /* fall through */
107  case ASM_SYSMGMT_VECTOR:
108    return 1;
109  case ASM_ITM_VECTOR:
110    return 0;
111  }
112  return 0;
113}
114
115int mpc60x_vector_is_valid(rtems_vector vector)
116{
117     switch (current_ppc_cpu) {
118        case PPC_750:
119            if (!mpc750_vector_is_valid(vector)) {
120                return 0;
121            }
122            break;
123        case PPC_604:
124        case PPC_604e:
125        case PPC_604r:
126            if (!mpc604_vector_is_valid(vector)) {
127                return 0;
128            }
129            break;
130        case PPC_603:
131        case PPC_603e:
132            if (!mpc603_vector_is_valid(vector)) {
133                return 0;
134            }
135            break;
136        default:
137            printk("Please complete libcpu/powerpc/mpc6xx/raw_exception.c\n");
138            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
139            return 0;
140     }
141     return 1;
142}
143
144int mpc60x_set_exception  (const rtems_raw_except_connect_data* except)
145{
146    unsigned int level;
147
148    if (!mpc60x_vector_is_valid(except->exceptIndex)) {
149      return 0;
150    }
151    /*
152     * Check if default handler is actually connected. If not issue an error.
153     * You must first get the current handler via mpc60x_get_current_exception
154     * and then disconnect it using mpc60x_delete_exception.
155     * RATIONALE : to always have the same transition by forcing the user
156     * to get the previous handler before accepting to disconnect.
157     */
158    if (memcmp(mpc60x_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
159      return 0;
160    }
161
162    _CPU_ISR_Disable(level);
163   
164    raw_except_table [except->exceptIndex] = *except;
165    codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
166             except->hdl.raw_hdl,
167             except->hdl.raw_hdl_size,
168             PPC_CACHE_ALIGNMENT);
169    except->on(except);
170   
171    _CPU_ISR_Enable(level);
172    return 1;
173}
174
175int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
176{
177  if (!mpc60x_vector_is_valid(except->exceptIndex)){
178    return 0;
179  }
180   
181  *except = raw_except_table [except->exceptIndex];
182   
183  return 1;
184}
185
186int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
187{
188  unsigned int level;
189 
190  if (!mpc60x_vector_is_valid(except->exceptIndex)){
191    return 0;
192  }
193  /*
194   * Check if handler passed is actually connected. If not issue an error.
195   * You must first get the current handler via mpc60x_get_current_exception
196   * and then disconnect it using mpc60x_delete_exception.
197   * RATIONALE : to always have the same transition by forcing the user
198   * to get the previous handler before accepting to disconnect.
199   */
200  if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
201             (void*)except->hdl.raw_hdl,
202             except->hdl.raw_hdl_size)) {
203      return 0;
204  }
205  _CPU_ISR_Disable(level);
206
207  except->off(except);
208  codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
209           default_raw_except_entry.hdl.raw_hdl,
210           default_raw_except_entry.hdl.raw_hdl_size,
211           PPC_CACHE_ALIGNMENT);
212
213   
214  raw_except_table[except->exceptIndex] = default_raw_except_entry;
215  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
216
217  _CPU_ISR_Enable(level);
218   
219  return 1;
220}
221
222/*
223 * Exception global init.
224 */
225int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
226{
227    unsigned                    i;
228    unsigned int level;
229   
230    /*
231     * store various accelerators
232     */
233    raw_except_table            = config->rawExceptHdlTbl;
234    local_settings              = config;
235    default_raw_except_entry    = config->defaultRawEntry;
236
237    _CPU_ISR_Disable(level);
238
239    for (i=0; i <= LAST_VALID_EXC; i++) {
240      if (!mpc60x_vector_is_valid(i)){
241        continue;
242      }
243      codemove((void*)mpc60x_get_vector_addr(i),
244             raw_except_table[i].hdl.raw_hdl,
245             raw_except_table[i].hdl.raw_hdl_size,
246             PPC_CACHE_ALIGNMENT);
247      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
248        raw_except_table[i].on(&raw_except_table[i]);
249      }
250      else {
251        raw_except_table[i].off(&raw_except_table[i]);
252      }
253    }
254    _CPU_ISR_Enable(level);
255
256    return 1;
257}
258
259int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
260{
261  *config = local_settings;
262  return 1;
263}
264
Note: See TracBrowser for help on using the repository browser.