source: rtems/c/src/lib/libcpu/powerpc/mpc8xx/exceptions/raw_exception.c @ 73b5bd5d

4.104.114.84.95
Last change on this file since 73b5bd5d was 73b5bd5d, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 15, 2004 at 1:33:58 PM

Remove stray white spaces.

  • 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 *  The license and distribution terms for this file may be
15 *  found in found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 * $Id$
19 */
20
21#include <rtems/system.h>
22#include <rtems/score/cpu.h>
23#include <rtems/score/powerpc.h>
24#include <libcpu/raw_exception.h>
25#include <libcpu/cpuIdent.h>
26#include <rtems/bspIo.h>        /* for printk */
27#include <string.h>
28
29void * codemove(void *, const void *, unsigned int, unsigned long);
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 mpc860_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_SOFTEMUL_VECTOR:
53  case ASM_ITLBMISS_VECTOR:
54  case ASM_DTLBMISS_VECTOR:
55  case ASM_ITLBERROR_VECTOR:
56  case ASM_DTLBERROR_VECTOR:
57
58  case ASM_DBREAK_VECTOR:
59  case ASM_IBREAK_VECTOR:
60  case ASM_PERIFBREAK_VECTOR:
61  case ASM_DEVPORT_VECTOR:
62    return 1;
63  default: return 0;
64  }
65}
66
67int mpc8xx_vector_is_valid(rtems_vector vector)
68{
69     switch (current_ppc_cpu) {
70        case PPC_860:
71            if (!mpc860_vector_is_valid(vector)) {
72                return 0;
73            }
74            break;
75        default:
76            printk("Please complete libcpu/powerpc/mpc8xx/exceptions/raw_exception.c\n");
77            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
78            return 0;
79     }
80     return 1;
81}
82
83int mpc8xx_set_exception  (const rtems_raw_except_connect_data* except)
84{
85    unsigned int level;
86
87    if (!mpc8xx_vector_is_valid(except->exceptIndex)) {
88      return 0;
89    }
90    /*
91     * Check if default handler is actually connected. If not issue an error.
92     * You must first get the current handler via mpc8xx_get_current_exception
93     * and then disconnect it using mpc8xx_delete_exception.
94     * RATIONALE : to always have the same transition by forcing the user
95     * to get the previous handler before accepting to disconnect.
96     */
97    if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
98      return 0;
99    }
100
101    _CPU_ISR_Disable(level);
102   
103    raw_except_table [except->exceptIndex] = *except;
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    except->on(except);
109   
110    _CPU_ISR_Enable(level);
111    return 1;
112}
113
114int mpc8xx_get_current_exception (rtems_raw_except_connect_data* except)
115{
116  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
117    return 0;
118  }
119   
120  *except = raw_except_table [except->exceptIndex];
121   
122  return 1;
123}
124
125int mpc8xx_delete_exception (const rtems_raw_except_connect_data* except)
126{
127  unsigned int level;
128 
129  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
130    return 0;
131  }
132  /*
133   * Check if handler passed is actually connected. If not issue an error.
134   * You must first get the current handler via mpc8xx_get_current_exception
135   * and then disconnect it using mpc8xx_delete_exception.
136   * RATIONALE : to always have the same transition by forcing the user
137   * to get the previous handler before accepting to disconnect.
138   */
139  if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex),
140             (void*)except->hdl.raw_hdl,
141             except->hdl.raw_hdl_size)) {
142      return 0;
143  }
144  _CPU_ISR_Disable(level);
145
146  except->off(except);
147  codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
148           default_raw_except_entry.hdl.raw_hdl,
149           default_raw_except_entry.hdl.raw_hdl_size,
150           PPC_CACHE_ALIGNMENT);
151
152   
153  raw_except_table[except->exceptIndex] = default_raw_except_entry;
154  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
155
156  _CPU_ISR_Enable(level);
157   
158  return 1;
159}
160
161/*
162 * Exception global init.
163 */
164int mpc8xx_init_exceptions (rtems_raw_except_global_settings* config)
165{
166    unsigned                    i;
167    unsigned int level;
168   
169    /*
170     * store various accelerators
171     */
172    raw_except_table            = config->rawExceptHdlTbl;
173    local_settings              = config;
174    default_raw_except_entry    = config->defaultRawEntry;
175
176    _CPU_ISR_Disable(level);
177
178    for (i=0; i <= LAST_VALID_EXC; i++) {
179      if (!mpc8xx_vector_is_valid(i)){
180        continue;
181      }
182      codemove((void*)mpc8xx_get_vector_addr(i),
183             raw_except_table[i].hdl.raw_hdl,
184             raw_except_table[i].hdl.raw_hdl_size,
185             PPC_CACHE_ALIGNMENT);
186      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
187        raw_except_table[i].on(&raw_except_table[i]);
188      }
189      else {
190        raw_except_table[i].off(&raw_except_table[i]);
191      }
192    }
193    _CPU_ISR_Enable(level);
194
195    return 1;
196}
197
198int mpc8xx_get_exception_config (rtems_raw_except_global_settings** config)
199{
200  *config = local_settings;
201  return 1;
202}
Note: See TracBrowser for help on using the repository browser.