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

4.104.114.84.95
Last change on this file since 83d7232 was 83d7232, checked in by Eric Norum <WENorum@…>, on Oct 20, 2004 at 3:42:24 PM

Add Kate Feng's MVME5500 BSP.

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