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

4.104.114.84.95
Last change on this file since a73a977 was a73a977, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/02 at 20:55:37

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

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