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

4.104.114.84.95
Last change on this file since a84392d was a84392d, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 10, 2004 at 11:51:57 PM

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/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 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        case PPC_7455:   /* Kate Feng */
141            if (!mpc604_vector_is_valid(vector)) {
142                return 0;
143            }
144            break;
145        case PPC_603:
146        case PPC_603e:
147        case PPC_603ev:
148        case PPC_8260:
149        /* case PPC_8240: -- same value as 8260 */
150        case PPC_8245:
151            if (!mpc603_vector_is_valid(vector)) {
152                return 0;
153            }
154            break;
155         default:
156            printk("Please complete "
157                   "libcpu/powerpc/mpc6xx/exceptions/raw_exception.c\n"
158                   "current_ppc_cpu = %x\n", current_ppc_cpu);
159            return 0;
160     }
161     return 1;
162}
163
164int mpc60x_set_exception  (const rtems_raw_except_connect_data* except)
165{
166    unsigned int level;
167
168    if (!mpc60x_vector_is_valid(except->exceptIndex)) {
169      printk("mpc60x_set_exception: vector %d is not valid\n",
170              except->exceptIndex);
171      return 0;
172    }
173    /*
174     * Check if default handler is actually connected. If not issue an error.
175     * You must first get the current handler via mpc60x_get_current_exception
176     * and then disconnect it using mpc60x_delete_exception.
177     * RATIONALE : to always have the same transition by forcing the user
178     * to get the previous handler before accepting to disconnect.
179     */
180
181    if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
182               (void*)default_raw_except_entry.hdl.raw_hdl,
183               default_raw_except_entry.hdl.raw_hdl_size)) {
184      printk("mpc60x_set_exception: raw vector not installed\n");
185      return 0;
186    }
187
188    _CPU_ISR_Disable(level);
189   
190    raw_except_table [except->exceptIndex] = *except;
191    codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
192             except->hdl.raw_hdl,
193             except->hdl.raw_hdl_size,
194             PPC_CACHE_ALIGNMENT);
195    except->on(except);
196   
197    _CPU_ISR_Enable(level);
198    return 1;
199}
200
201int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
202{
203  if (!mpc60x_vector_is_valid(except->exceptIndex)){
204    return 0;
205  }
206   
207  *except = raw_except_table [except->exceptIndex];
208   
209  return 1;
210}
211
212int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
213{
214  unsigned int level;
215 
216  if (!mpc60x_vector_is_valid(except->exceptIndex)){
217    return 0;
218  }
219  /*
220   * Check if handler passed is actually connected. If not issue an error.
221   * You must first get the current handler via mpc60x_get_current_exception
222   * and then disconnect it using mpc60x_delete_exception.
223   * RATIONALE : to always have the same transition by forcing the user
224   * to get the previous handler before accepting to disconnect.
225   */
226  if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
227             (void*)except->hdl.raw_hdl,
228             except->hdl.raw_hdl_size)) {
229      return 0;
230  }
231  _CPU_ISR_Disable(level);
232
233  except->off(except);
234  codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
235           default_raw_except_entry.hdl.raw_hdl,
236           default_raw_except_entry.hdl.raw_hdl_size,
237           PPC_CACHE_ALIGNMENT);
238
239   
240  raw_except_table[except->exceptIndex] = default_raw_except_entry;
241  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
242
243  _CPU_ISR_Enable(level);
244   
245  return 1;
246}
247
248/*
249 * Exception global init.
250 */
251int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
252{
253    unsigned                    i;
254    unsigned int level;
255   
256    /*
257     * store various accelerators
258     */
259    raw_except_table            = config->rawExceptHdlTbl;
260    local_settings              = config;
261    default_raw_except_entry    = config->defaultRawEntry;
262
263    _CPU_ISR_Disable(level);
264
265    for (i=0; i <= LAST_VALID_EXC; i++) {
266      if (!mpc60x_vector_is_valid(i)){
267        continue;
268      }
269      codemove((void*)mpc60x_get_vector_addr(i),
270             raw_except_table[i].hdl.raw_hdl,
271             raw_except_table[i].hdl.raw_hdl_size,
272             PPC_CACHE_ALIGNMENT);
273      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
274        raw_except_table[i].on(&raw_except_table[i]);
275      }
276      else {
277        raw_except_table[i].off(&raw_except_table[i]);
278      }
279    }
280    _CPU_ISR_Enable(level);
281
282    return 1;
283}
284
285int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
286{
287  *config = local_settings;
288  return 1;
289}
Note: See TracBrowser for help on using the repository browser.