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

4.104.114.84.95
Last change on this file since cebb89b was cebb89b, checked in by Joel Sherrill <joel.sherrill@…>, on 10/31/02 at 20:12:46

2002-10-31 Joel Sherrill <joel@…>

  • mpc6xx/clock/c_clock.c, mpc6xx/exceptions/raw_exception.c, mpc6xx/mmu/bat.c: Removed warnings.
  • Property mode set to 100644
File size: 6.9 KB
RevLine 
[acc25ee]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 *
[95273a6]14 * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
15 * to support 603, 603e, 604, 604e exceptions
16 *
[acc25ee]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 */
[a73a977]23#include <rtems/system.h>
[acc25ee]24#include <rtems/score/ppc.h>
[c0af822e]25#include <rtems/bspIo.h>
[acc25ee]26#include <libcpu/raw_exception.h>
[e05f4315]27#include <libcpu/cpuIdent.h>
[acc25ee]28
[cebb89b]29#include <string.h>
30
[acc25ee]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
[cebb89b]35void * codemove(void *, const void *, unsigned int, unsigned long);
[acc25ee]36int mpc750_vector_is_valid(rtems_vector vector)
[cebb89b]37
[acc25ee]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
[95273a6]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
[acc25ee]88int mpc604_vector_is_valid(rtems_vector vector)
89{
[95273a6]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  }
[acc25ee]114  return 0;
115}
116
[55e4dcf3]117int mpc60x_vector_is_valid(rtems_vector vector)
[acc25ee]118{
[55e4dcf3]119     switch (current_ppc_cpu) {
[0d776cd2]120        case PPC_7400:
[95273a6]121        case PPC_750:
[55e4dcf3]122            if (!mpc750_vector_is_valid(vector)) {
[95273a6]123                return 0;
124            }
125            break;
126        case PPC_604:
127        case PPC_604e:
[c0af822e]128        /* case PPC_604r: -- same value as PPC_750 */
[55e4dcf3]129            if (!mpc604_vector_is_valid(vector)) {
[95273a6]130                return 0;
131            }
132            break;
133        case PPC_603:
134        case PPC_603e:
[55e4dcf3]135            if (!mpc603_vector_is_valid(vector)) {
[95273a6]136                return 0;
137            }
138            break;
139        default:
140            printk("Please complete libcpu/powerpc/mpc6xx/raw_exception.c\n");
141            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
142            return 0;
[55e4dcf3]143     }
144     return 1;
145}
[95273a6]146
[55e4dcf3]147int mpc60x_set_exception  (const rtems_raw_except_connect_data* except)
148{
149    unsigned int level;
150
151    if (!mpc60x_vector_is_valid(except->exceptIndex)) {
152      return 0;
153    }
[acc25ee]154    /*
155     * Check if default handler is actually connected. If not issue an error.
156     * You must first get the current handler via mpc60x_get_current_exception
157     * and then disconnect it using mpc60x_delete_exception.
158     * RATIONALE : to always have the same transition by forcing the user
159     * to get the previous handler before accepting to disconnect.
160     */
161    if (memcmp(mpc60x_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
162      return 0;
163    }
164
165    _CPU_ISR_Disable(level);
166   
167    raw_except_table [except->exceptIndex] = *except;
168    codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
169             except->hdl.raw_hdl,
170             except->hdl.raw_hdl_size,
171             PPC_CACHE_ALIGNMENT);
172    except->on(except);
173   
174    _CPU_ISR_Enable(level);
175    return 1;
176}
177
178int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
179{
[55e4dcf3]180  if (!mpc60x_vector_is_valid(except->exceptIndex)){
[acc25ee]181    return 0;
182  }
183   
184  *except = raw_except_table [except->exceptIndex];
185   
186  return 1;
187}
188
189int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
190{
191  unsigned int level;
192 
[55e4dcf3]193  if (!mpc60x_vector_is_valid(except->exceptIndex)){
[acc25ee]194    return 0;
195  }
196  /*
197   * Check if handler passed is actually connected. If not issue an error.
198   * You must first get the current handler via mpc60x_get_current_exception
199   * and then disconnect it using mpc60x_delete_exception.
200   * RATIONALE : to always have the same transition by forcing the user
201   * to get the previous handler before accepting to disconnect.
202   */
203  if (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
204             (void*)except->hdl.raw_hdl,
205             except->hdl.raw_hdl_size)) {
206      return 0;
207  }
208  _CPU_ISR_Disable(level);
209
210  except->off(except);
211  codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
212           default_raw_except_entry.hdl.raw_hdl,
213           default_raw_except_entry.hdl.raw_hdl_size,
214           PPC_CACHE_ALIGNMENT);
215
216   
217  raw_except_table[except->exceptIndex] = default_raw_except_entry;
218  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
219
220  _CPU_ISR_Enable(level);
221   
222  return 1;
223}
224
225/*
226 * Exception global init.
227 */
228int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
229{
230    unsigned                    i;
231    unsigned int level;
232   
233    /*
234     * store various accelerators
235     */
236    raw_except_table            = config->rawExceptHdlTbl;
237    local_settings              = config;
238    default_raw_except_entry    = config->defaultRawEntry;
239
240    _CPU_ISR_Disable(level);
241
242    for (i=0; i <= LAST_VALID_EXC; i++) {
[55e4dcf3]243      if (!mpc60x_vector_is_valid(i)){
[acc25ee]244        continue;
245      }
246      codemove((void*)mpc60x_get_vector_addr(i),
247             raw_except_table[i].hdl.raw_hdl,
248             raw_except_table[i].hdl.raw_hdl_size,
249             PPC_CACHE_ALIGNMENT);
250      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
251        raw_except_table[i].on(&raw_except_table[i]);
252      }
253      else {
254        raw_except_table[i].off(&raw_except_table[i]);
255      }
256    }
257    _CPU_ISR_Enable(level);
258
259    return 1;
260}
261
262int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
263{
264  *config = local_settings;
265  return 1;
266}
267
Note: See TracBrowser for help on using the repository browser.