source: rtems/c/src/lib/libcpu/powerpc/mpc8260/exceptions/raw_exception.c @ 4adabccd

4.104.114.84.95
Last change on this file since 4adabccd was 4adabccd, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/02/02 at 06:17:39

2002-09-02 Ralf Corsepius <corsepiu@…>

  • mpc8260/exceptions/raw_exception.c: #include <string.h>. #include <bspIo.h>.
  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * raw_exception.c  - This file contains implementation of C function to
3 *                    Instanciate 8xx ppc primary exception entries.
4 *                    More detailled information can be found on motorola
5 *                    site and more precisely in the following book :
6 *
7 *                    MPC860
8 *                    Risc Microporcessor User's Manual
9 *                    Motorola REF : MPC860UM/AD
10 *
11 * Copyright (C) 1999  Eric Valette (valette@crf.canon.fr)
12 *                     Canon Centre Recherche France.
13 *
14 * Modified for mpc8260 by Andy Dachs <a.dachs@sstl.co.uk>
15 * Surrey Satellite Technology Limited (SSTL), 2001
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
24#include <string.h>     /* memcmp */
25#include <rtems/system.h>
26#include <rtems/score/ppc.h>
27#include <rtems/bspIo.h>
28#include <libcpu/raw_exception.h>
29#include <libcpu/cpuIdent.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
35int mpc8260_vector_is_valid(rtems_vector vector)
36{
37  switch(vector) {
38  case ASM_RESET_VECTOR: /* fall through */
39  case ASM_MACH_VECTOR:
40  case ASM_PROT_VECTOR:
41  case ASM_ISI_VECTOR:
42  case ASM_EXT_VECTOR:
43  case ASM_ALIGN_VECTOR:
44  case ASM_PROG_VECTOR:
45  case ASM_FLOAT_VECTOR:
46  case ASM_DEC_VECTOR:
47   
48  case ASM_SYS_VECTOR:
49  case ASM_TRACE_VECTOR:
50  case ASM_FLOATASSIST_VECTOR:
51
52  case ASM_ITLBMISS_VECTOR:
53  case ASM_DTLBLMISS_VECTOR:
54  case ASM_DTLBSMISS_VECTOR:
55
56  case ASM_IBREAK_VECTOR:
57  case ASM_SYSMANAGE_VECTOR:
58    return 1;
59  default: return 0;
60  }
61}
62
63int mpc8xx_vector_is_valid(rtems_vector vector)
64{
65     switch (current_ppc_cpu) {
66        case PPC_8260:
67            if (!mpc8260_vector_is_valid(vector)) {
68                return 0;
69            }
70            break;
71        default:
72            printk("Please complete libcpu/powerpc/mpc8xx/exceptions/raw_exception.c\n");
73            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
74            return 0;
75     }
76     return 1;
77}
78
79int mpc8xx_set_exception  (const rtems_raw_except_connect_data* except)
80{
81    unsigned int level;
82
83    if (!mpc8xx_vector_is_valid(except->exceptIndex)) {
84      return 0;
85    }
86    /*
87     * Check if default handler is actually connected. If not issue an error.
88     * You must first get the current handler via mpc8xx_get_current_exception
89     * and then disconnect it using mpc8xx_delete_exception.
90     * RATIONALE : to always have the same transition by forcing the user
91     * to get the previous handler before accepting to disconnect.
92     */
93    if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
94      return 0;
95    }
96
97    _CPU_ISR_Disable(level);
98   
99    raw_except_table [except->exceptIndex] = *except;
100/*
101    memmove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
102             except->hdl.raw_hdl,
103             except->hdl.raw_hdl_size
104             );
105*/
106    codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
107             except->hdl.raw_hdl,
108             except->hdl.raw_hdl_size,
109             PPC_CACHE_ALIGNMENT);
110
111    except->on(except);
112   
113    _CPU_ISR_Enable(level);
114    return 1;
115}
116
117int mpc8xx_get_current_exception (rtems_raw_except_connect_data* except)
118{
119  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
120    return 0;
121  }
122   
123  *except = raw_except_table [except->exceptIndex];
124   
125  return 1;
126}
127
128int mpc8xx_delete_exception (const rtems_raw_except_connect_data* except)
129{
130  unsigned int level;
131 
132  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
133    return 0;
134  }
135  /*
136   * Check if handler passed is actually connected. If not issue an error.
137   * You must first get the current handler via mpc8xx_get_current_exception
138   * and then disconnect it using mpc8xx_delete_exception.
139   * RATIONALE : to always have the same transition by forcing the user
140   * to get the previous handler before accepting to disconnect.
141   */
142  if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex),
143             (void*)except->hdl.raw_hdl,
144             except->hdl.raw_hdl_size)) {
145      return 0;
146  }
147  _CPU_ISR_Disable(level);
148
149  except->off(except);
150  codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
151           default_raw_except_entry.hdl.raw_hdl,
152           default_raw_except_entry.hdl.raw_hdl_size,
153           PPC_CACHE_ALIGNMENT);
154
155   
156  raw_except_table[except->exceptIndex] = default_raw_except_entry;
157  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
158
159  _CPU_ISR_Enable(level);
160   
161  return 1;
162}
163
164/*
165 * Exception global init.
166 */
167int mpc8xx_init_exceptions (rtems_raw_except_global_settings* config)
168{
169    unsigned                    i;
170    unsigned int level;
171   
172    /*
173     * store various accelerators
174     */
175    raw_except_table            = config->rawExceptHdlTbl;
176    local_settings              = config;
177    default_raw_except_entry    = config->defaultRawEntry;
178
179    _CPU_ISR_Disable(level);
180
181    for (i=0; i <= LAST_VALID_EXC; i++) {
182      if (!mpc8xx_vector_is_valid(i)){
183        continue;
184      }
185      codemove((void*)mpc8xx_get_vector_addr(i),
186             raw_except_table[i].hdl.raw_hdl,
187             raw_except_table[i].hdl.raw_hdl_size,
188             PPC_CACHE_ALIGNMENT);
189      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
190        raw_except_table[i].on(&raw_except_table[i]);
191      }
192      else {
193        raw_except_table[i].off(&raw_except_table[i]);
194      }
195    }
196    _CPU_ISR_Enable(level);
197
198    return 1;
199}
200
201int mpc8xx_get_exception_config (rtems_raw_except_global_settings** config)
202{
203  *config = local_settings;
204  return 1;
205}
206
Note: See TracBrowser for help on using the repository browser.