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

4.104.114.84.95
Last change on this file since b929c2de was b929c2de, checked in by Joel Sherrill <joel.sherrill@…>, on 04/17/02 at 19:39:16

2001-04-17 Joel Sherrill <joel@…>

  • shared/include/cpu.h: Added ifndef ASM.
  • Property mode set to 100644
File size: 5.4 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.OARcorp.com/rtems/license.html.
17 *
18 * $Id$
19 */
20#include <rtems/score/targopts.h>
21#include <rtems/score/ppc.h>
22#include <rtems/system.h>
23#include <rtems/score/cpu.h>
24#include <libcpu/raw_exception.h>
25#include <libcpu/cpu.h>
26#include <libcpu/cpuIdent.h>
27
28static rtems_raw_except_connect_data*           raw_except_table;
29static rtems_raw_except_connect_data            default_raw_except_entry;
30static rtems_raw_except_global_settings*        local_settings;
31
32int mpc860_vector_is_valid(rtems_vector vector)
33{
34  switch(vector) {
35  case ASM_RESET_VECTOR: /* fall through */
36  case ASM_MACH_VECTOR:
37  case ASM_PROT_VECTOR:
38  case ASM_ISI_VECTOR:
39  case ASM_EXT_VECTOR:
40  case ASM_ALIGN_VECTOR:
41  case ASM_PROG_VECTOR:
42  case ASM_FLOAT_VECTOR:
43  case ASM_DEC_VECTOR:
44   
45  case ASM_SYS_VECTOR:
46  case ASM_TRACE_VECTOR:
47  case ASM_FLOATASSIST_VECTOR:
48
49  case ASM_SOFTEMUL_VECTOR:
50  case ASM_ITLBMISS_VECTOR:
51  case ASM_DTLBMISS_VECTOR:
52  case ASM_ITLBERROR_VECTOR:
53  case ASM_DTLBERROR_VECTOR:
54
55  case ASM_DBREAK_VECTOR:
56  case ASM_IBREAK_VECTOR:
57  case ASM_PERIFBREAK_VECTOR:
58  case ASM_DEVPORT_VECTOR:
59    return 1;
60  default: return 0;
61  }
62}
63
64int mpc8xx_vector_is_valid(rtems_vector vector)
65{
66     switch (current_ppc_cpu) {
67        case PPC_860:
68            if (!mpc860_vector_is_valid(vector)) {
69                return 0;
70            }
71            break;
72        default:
73            printk("Please complete libcpu/powerpc/mpc8xx/exceptions/raw_exception.c\n");
74            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
75            return 0;
76     }
77     return 1;
78}
79
80int mpc8xx_set_exception  (const rtems_raw_except_connect_data* except)
81{
82    unsigned int level;
83
84    if (!mpc8xx_vector_is_valid(except->exceptIndex)) {
85      return 0;
86    }
87    /*
88     * Check if default handler is actually connected. If not issue an error.
89     * You must first get the current handler via mpc8xx_get_current_exception
90     * and then disconnect it using mpc8xx_delete_exception.
91     * RATIONALE : to always have the same transition by forcing the user
92     * to get the previous handler before accepting to disconnect.
93     */
94    if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
95      return 0;
96    }
97
98    _CPU_ISR_Disable(level);
99   
100    raw_except_table [except->exceptIndex] = *except;
101    codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
102             except->hdl.raw_hdl,
103             except->hdl.raw_hdl_size,
104             PPC_CACHE_ALIGNMENT);
105    except->on(except);
106   
107    _CPU_ISR_Enable(level);
108    return 1;
109}
110
111int mpc8xx_get_current_exception (rtems_raw_except_connect_data* except)
112{
113  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
114    return 0;
115  }
116   
117  *except = raw_except_table [except->exceptIndex];
118   
119  return 1;
120}
121
122int mpc8xx_delete_exception (const rtems_raw_except_connect_data* except)
123{
124  unsigned int level;
125 
126  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
127    return 0;
128  }
129  /*
130   * Check if handler passed is actually connected. If not issue an error.
131   * You must first get the current handler via mpc8xx_get_current_exception
132   * and then disconnect it using mpc8xx_delete_exception.
133   * RATIONALE : to always have the same transition by forcing the user
134   * to get the previous handler before accepting to disconnect.
135   */
136  if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex),
137             (void*)except->hdl.raw_hdl,
138             except->hdl.raw_hdl_size)) {
139      return 0;
140  }
141  _CPU_ISR_Disable(level);
142
143  except->off(except);
144  codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
145           default_raw_except_entry.hdl.raw_hdl,
146           default_raw_except_entry.hdl.raw_hdl_size,
147           PPC_CACHE_ALIGNMENT);
148
149   
150  raw_except_table[except->exceptIndex] = default_raw_except_entry;
151  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
152
153  _CPU_ISR_Enable(level);
154   
155  return 1;
156}
157
158/*
159 * Exception global init.
160 */
161int mpc8xx_init_exceptions (rtems_raw_except_global_settings* config)
162{
163    unsigned                    i;
164    unsigned int level;
165   
166    /*
167     * store various accelerators
168     */
169    raw_except_table            = config->rawExceptHdlTbl;
170    local_settings              = config;
171    default_raw_except_entry    = config->defaultRawEntry;
172
173    _CPU_ISR_Disable(level);
174
175    for (i=0; i <= LAST_VALID_EXC; i++) {
176      if (!mpc8xx_vector_is_valid(i)){
177        continue;
178      }
179      codemove((void*)mpc8xx_get_vector_addr(i),
180             raw_except_table[i].hdl.raw_hdl,
181             raw_except_table[i].hdl.raw_hdl_size,
182             PPC_CACHE_ALIGNMENT);
183      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
184        raw_except_table[i].on(&raw_except_table[i]);
185      }
186      else {
187        raw_except_table[i].off(&raw_except_table[i]);
188      }
189    }
190    _CPU_ISR_Enable(level);
191
192    return 1;
193}
194
195int mpc8xx_get_exception_config (rtems_raw_except_global_settings** config)
196{
197  *config = local_settings;
198  return 1;
199}
200
Note: See TracBrowser for help on using the repository browser.