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

Last change on this file since 70fefe6 was d700909e, checked in by Joel Sherrill <joel.sherrill@…>, on 11/10/04 at 22:37:57

2004-11-10 Richard Campbell <richard.campbell@…>

  • configure.ac, mpc6xx/exceptions/raw_exception.c, mpc6xx/exceptions/raw_exception.h, mpc6xx/mmu/bat.c, mpc6xx/mmu/bat.h, mpc6xx/mmu/mmuAsm.S, shared/include/cpuIdent.c, shared/include/cpuIdent.h: Add MPC8240 and MPC8245 support. There was also a significant amount of spelling and whitespace cleanup.
  • Property mode set to 100644
File size: 7.5 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/ppc.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 mpc603_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  case ASM_SYS_VECTOR:
83  case ASM_TRACE_VECTOR:
84    return 1;
85  case ASM_PERFMON_VECTOR:
86    return 0;
87  case ASM_IMISS_VECTOR: /* fall through */
88  case ASM_DLMISS_VECTOR:
89  case ASM_DSMISS_VECTOR:
90  case ASM_ADDR_VECTOR:
91  case ASM_SYSMGMT_VECTOR:
92    return 1;
93  case ASM_ITM_VECTOR:
94    return 0;
95  }
96  return 0;
97}
98
99int mpc604_vector_is_valid(rtems_vector vector)
100{
101  switch(vector) {
102  case ASM_RESET_VECTOR: /* fall through */
103  case ASM_MACH_VECTOR:
104  case ASM_PROT_VECTOR:
105  case ASM_ISI_VECTOR:
106  case ASM_EXT_VECTOR:
107  case ASM_ALIGN_VECTOR:
108  case ASM_PROG_VECTOR:
109  case ASM_FLOAT_VECTOR:
110  case ASM_DEC_VECTOR:
111  case ASM_SYS_VECTOR:
112  case ASM_TRACE_VECTOR:
113  case ASM_PERFMON_VECTOR:
114    return 1;
115  case ASM_IMISS_VECTOR: /* fall through */
116  case ASM_DLMISS_VECTOR:
117  case ASM_DSMISS_VECTOR:
118    return 0;
119  case ASM_ADDR_VECTOR: /* fall through */
120  case ASM_SYSMGMT_VECTOR:
121    return 1;
122  case ASM_ITM_VECTOR:
123    return 0;
124  }
125  return 0;
126}
127
128int mpc60x_vector_is_valid(rtems_vector vector)
129{
130     switch (current_ppc_cpu) {
131        case PPC_7400:
132        case PPC_750:
133            if (!mpc750_vector_is_valid(vector)) {
134                return 0;
135            }
136            break;
137        case PPC_604:
138        case PPC_604e:
139        case PPC_604r:
140            if (!mpc604_vector_is_valid(vector)) {
141                return 0;
142            }
143            break;
144        case PPC_603:
145        case PPC_603e:
146        case PPC_603ev:
147        case PPC_8260:
148        /* case PPC_8240: -- same value as 8260 */
149        case PPC_8245:
150            if (!mpc603_vector_is_valid(vector)) {
151                return 0;
152            }
153            break;
154         default:
155            printk("Please complete "
156                   "libcpu/powerpc/mpc6xx/exceptions/raw_exception.c\n"
157                   "current_ppc_cpu = %x\n", current_ppc_cpu);
158            return 0;
159     }
160     return 1;
161}
162
163int mpc60x_set_exception  (const rtems_raw_except_connect_data* except)
164{
165    unsigned int level;
166
167    if (!mpc60x_vector_is_valid(except->exceptIndex)) {
168      printk("mpc60x_set_exception: vector %d is not valid\n",
169              except->exceptIndex);
170      return 0;
171    }
172    /*
173     * Check if default handler is actually connected. If not issue an error.
174     * You must first get the current handler via mpc60x_get_current_exception
175     * and then disconnect it using mpc60x_delete_exception.
176     * RATIONALE : to always have the same transition by forcing the user
177     * to get the previous handler before accepting to disconnect.
178     */
179
180    if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
181               (void*)default_raw_except_entry.hdl.raw_hdl,
182               default_raw_except_entry.hdl.raw_hdl_size)) {
183      printk("mpc60x_set_exception: raw vector not installed\n");
184      return 0;
185    }
186
187    _CPU_ISR_Disable(level);
188   
189    raw_except_table [except->exceptIndex] = *except;
190    codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
191             except->hdl.raw_hdl,
192             except->hdl.raw_hdl_size,
193             PPC_CACHE_ALIGNMENT);
194    except->on(except);
195   
196    _CPU_ISR_Enable(level);
197    return 1;
198}
199
200int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
201{
202  if (!mpc60x_vector_is_valid(except->exceptIndex)){
203    return 0;
204  }
205   
206  *except = raw_except_table [except->exceptIndex];
207   
208  return 1;
209}
210
211int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
212{
213  unsigned int level;
214 
215  if (!mpc60x_vector_is_valid(except->exceptIndex)){
216    return 0;
217  }
218  /*
219   * Check if handler passed is actually connected. If not issue an error.
220   * You must first get the current handler via mpc60x_get_current_exception
221   * and then disconnect it using mpc60x_delete_exception.
222   * RATIONALE : to always have the same transition by forcing the user
223   * to get the previous handler before accepting to disconnect.
224   */
225  if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
226             (void*)except->hdl.raw_hdl,
227             except->hdl.raw_hdl_size)) {
228      return 0;
229  }
230  _CPU_ISR_Disable(level);
231
232  except->off(except);
233  codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
234           default_raw_except_entry.hdl.raw_hdl,
235           default_raw_except_entry.hdl.raw_hdl_size,
236           PPC_CACHE_ALIGNMENT);
237
238   
239  raw_except_table[except->exceptIndex] = default_raw_except_entry;
240  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
241
242  _CPU_ISR_Enable(level);
243   
244  return 1;
245}
246
247/*
248 * Exception global init.
249 */
250int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
251{
252    unsigned                    i;
253    unsigned int level;
254   
255    /*
256     * store various accelerators
257     */
258    raw_except_table            = config->rawExceptHdlTbl;
259    local_settings              = config;
260    default_raw_except_entry    = config->defaultRawEntry;
261
262    _CPU_ISR_Disable(level);
263
264    for (i=0; i <= LAST_VALID_EXC; i++) {
265      if (!mpc60x_vector_is_valid(i)){
266        continue;
267      }
268      codemove((void*)mpc60x_get_vector_addr(i),
269             raw_except_table[i].hdl.raw_hdl,
270             raw_except_table[i].hdl.raw_hdl_size,
271             PPC_CACHE_ALIGNMENT);
272      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
273        raw_except_table[i].on(&raw_except_table[i]);
274      }
275      else {
276        raw_except_table[i].off(&raw_except_table[i]);
277      }
278    }
279    _CPU_ISR_Enable(level);
280
281    return 1;
282}
283
284int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
285{
286  *config = local_settings;
287  return 1;
288}
289
Note: See TracBrowser for help on using the repository browser.