source: rtems/c/src/lib/libcpu/powerpc/mpc8260/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: 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 <rtems/system.h>
25#include <rtems/score/ppc.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 mpc8260_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   
46  case ASM_SYS_VECTOR:
47  case ASM_TRACE_VECTOR:
48  case ASM_FLOATASSIST_VECTOR:
49
50  case ASM_ITLBMISS_VECTOR:
51  case ASM_DTLBLMISS_VECTOR:
52  case ASM_DTLBSMISS_VECTOR:
53
54  case ASM_IBREAK_VECTOR:
55  case ASM_SYSMANAGE_VECTOR:
56    return 1;
57  default: return 0;
58  }
59}
60
61int mpc8xx_vector_is_valid(rtems_vector vector)
62{
63     switch (current_ppc_cpu) {
64        case PPC_8260:
65            if (!mpc8260_vector_is_valid(vector)) {
66                return 0;
67            }
68            break;
69        default:
70            printk("Please complete libcpu/powerpc/mpc8xx/exceptions/raw_exception.c\n");
71            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
72            return 0;
73     }
74     return 1;
75}
76
77int mpc8xx_set_exception  (const rtems_raw_except_connect_data* except)
78{
79    unsigned int level;
80
81    if (!mpc8xx_vector_is_valid(except->exceptIndex)) {
82      return 0;
83    }
84    /*
85     * Check if default handler is actually connected. If not issue an error.
86     * You must first get the current handler via mpc8xx_get_current_exception
87     * and then disconnect it using mpc8xx_delete_exception.
88     * RATIONALE : to always have the same transition by forcing the user
89     * to get the previous handler before accepting to disconnect.
90     */
91    if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
92      return 0;
93    }
94
95    _CPU_ISR_Disable(level);
96   
97    raw_except_table [except->exceptIndex] = *except;
98/*
99    memmove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
100             except->hdl.raw_hdl,
101             except->hdl.raw_hdl_size
102             );
103*/
104    codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
105             except->hdl.raw_hdl,
106             except->hdl.raw_hdl_size,
107             PPC_CACHE_ALIGNMENT);
108
109    except->on(except);
110   
111    _CPU_ISR_Enable(level);
112    return 1;
113}
114
115int mpc8xx_get_current_exception (rtems_raw_except_connect_data* except)
116{
117  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
118    return 0;
119  }
120   
121  *except = raw_except_table [except->exceptIndex];
122   
123  return 1;
124}
125
126int mpc8xx_delete_exception (const rtems_raw_except_connect_data* except)
127{
128  unsigned int level;
129 
130  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
131    return 0;
132  }
133  /*
134   * Check if handler passed is actually connected. If not issue an error.
135   * You must first get the current handler via mpc8xx_get_current_exception
136   * and then disconnect it using mpc8xx_delete_exception.
137   * RATIONALE : to always have the same transition by forcing the user
138   * to get the previous handler before accepting to disconnect.
139   */
140  if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex),
141             (void*)except->hdl.raw_hdl,
142             except->hdl.raw_hdl_size)) {
143      return 0;
144  }
145  _CPU_ISR_Disable(level);
146
147  except->off(except);
148  codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
149           default_raw_except_entry.hdl.raw_hdl,
150           default_raw_except_entry.hdl.raw_hdl_size,
151           PPC_CACHE_ALIGNMENT);
152
153   
154  raw_except_table[except->exceptIndex] = default_raw_except_entry;
155  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
156
157  _CPU_ISR_Enable(level);
158   
159  return 1;
160}
161
162/*
163 * Exception global init.
164 */
165int mpc8xx_init_exceptions (rtems_raw_except_global_settings* config)
166{
167    unsigned                    i;
168    unsigned int level;
169   
170    /*
171     * store various accelerators
172     */
173    raw_except_table            = config->rawExceptHdlTbl;
174    local_settings              = config;
175    default_raw_except_entry    = config->defaultRawEntry;
176
177    _CPU_ISR_Disable(level);
178
179    for (i=0; i <= LAST_VALID_EXC; i++) {
180      if (!mpc8xx_vector_is_valid(i)){
181        continue;
182      }
183      codemove((void*)mpc8xx_get_vector_addr(i),
184             raw_except_table[i].hdl.raw_hdl,
185             raw_except_table[i].hdl.raw_hdl_size,
186             PPC_CACHE_ALIGNMENT);
187      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
188        raw_except_table[i].on(&raw_except_table[i]);
189      }
190      else {
191        raw_except_table[i].off(&raw_except_table[i]);
192      }
193    }
194    _CPU_ISR_Enable(level);
195
196    return 1;
197}
198
199int mpc8xx_get_exception_config (rtems_raw_except_global_settings** config)
200{
201  *config = local_settings;
202  return 1;
203}
204
Note: See TracBrowser for help on using the repository browser.