source: rtems/c/src/lib/libcpu/powerpc/mpc5xx/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.1 KB
Line 
1/*
2 * raw_exception.c  - This file contains implementation of C functions to
3 *                    Instantiate mpc5xx primary exception entries.
4 *                    More detailled information can be found on the Motorola
5 *                    site and more precisely in the following book:
6 *
7 *                   MPC555/MPC556 User's Manual
8 *                   Motorola REF : MPC555UM/D Rev. 3, 2000 October 15
9 *
10 *
11 * MPC5xx port sponsored by Defence Research and Development Canada - Suffield
12 * Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
13 *
14 * Derived from libcpu/powerpc/mpc8xx/exceptions/raw_exception.c:
15 *
16 * Copyright (C) 1999  Eric Valette (valette@crf.canon.fr)
17 *                     Canon Centre Recherche France.
18 *
19 *  The license and distribution terms for this file may be
20 *  found in found in the file LICENSE in this distribution or at
21 *  http://www.rtems.com/license/LICENSE.
22 *
23 * $Id$
24 */
25
26#include <rtems/system.h>
27#include <rtems/score/cpu.h>
28#include <rtems/score/powerpc.h>
29#include <libcpu/raw_exception.h>
30#include <libcpu/cpuIdent.h>
31#include <rtems/bspIo.h>        /* for printk */
32#include <string.h>
33
34static rtems_raw_except_connect_data*           raw_except_table;
35static rtems_raw_except_connect_data            default_raw_except_entry;
36static rtems_raw_except_global_settings*        local_settings;
37
38int mpc5xx_vector_is_valid(rtems_vector vector)
39{
40  switch (current_ppc_cpu) {
41    case PPC_5XX:
42      switch(vector) {
43        case ASM_RESET_VECTOR:
44        case ASM_MACH_VECTOR:
45
46        case ASM_EXT_VECTOR:
47        case ASM_ALIGN_VECTOR:
48        case ASM_PROG_VECTOR:
49        case ASM_FLOAT_VECTOR:
50        case ASM_DEC_VECTOR:
51
52        case ASM_SYS_VECTOR:
53        case ASM_TRACE_VECTOR:
54        case ASM_FLOATASSIST_VECTOR:
55
56        case ASM_SOFTEMUL_VECTOR:
57
58        case ASM_IPROT_VECTOR:
59        case ASM_DPROT_VECTOR:
60
61        case ASM_DBREAK_VECTOR:
62        case ASM_IBREAK_VECTOR:
63        case ASM_MEBREAK_VECTOR:
64        case ASM_NMEBREAK_VECTOR:
65          return 1;
66        default: 
67          return 0;
68      }
69    default:
70      printk("Please complete libcpu/powerpc/mpc5xx/exceptions/raw_exception.c\n");
71      printk("current_ppc_cpu = %x\n", current_ppc_cpu);
72      return 0;
73  }
74}
75
76int mpc5xx_set_exception  (const rtems_raw_except_connect_data* except)
77{
78  unsigned int level;
79
80  if (!mpc5xx_vector_is_valid(except->exceptIndex)) {
81    return 0;
82  }
83  /*
84   * Check if default handler is actually connected. If not issue an error.
85   * You must first get the current handler via mpc5xx_get_current_exception
86   * and then disconnect it using mpc5xx_delete_exception.
87   * RATIONALE : to always have the same transition by forcing the user
88   * to get the previous handler before accepting to disconnect.
89   */
90  if (exception_handler_table[except->exceptIndex] != 
91      default_raw_except_entry.hdl.raw_hdl) {
92    return 0;
93  }
94
95  _CPU_ISR_Disable(level);
96 
97  raw_except_table[except->exceptIndex] = *except;
98
99  exception_handler_table[except->exceptIndex] = except->hdl.raw_hdl;
100  except->on(except);
101 
102  _CPU_ISR_Enable(level);
103  return 1;
104}
105
106int mpc5xx_get_current_exception (rtems_raw_except_connect_data* except)
107{
108  if (!mpc5xx_vector_is_valid(except->exceptIndex)){
109    return 0;
110  }
111   
112  *except = raw_except_table[except->exceptIndex];
113   
114  return 1;
115}
116
117int mpc5xx_delete_exception (const rtems_raw_except_connect_data* except)
118{
119  unsigned int level;
120 
121  if (!mpc5xx_vector_is_valid(except->exceptIndex)){
122    return 0;
123  }
124  /*
125   * Check if handler passed is actually connected. If not issue an error.
126   * You must first get the current handler via mpc5xx_get_current_exception
127   * and then disconnect it using mpc5xx_delete_exception.
128   * RATIONALE : to always have the same transition by forcing the user
129   * to get the previous handler before accepting to disconnect.
130   */
131  if (exception_handler_table[except->exceptIndex] != except->hdl.raw_hdl) {
132    return 0;
133  }
134
135  _CPU_ISR_Disable(level);
136
137  except->off(except);
138  exception_handler_table[except->exceptIndex] = 
139    default_raw_except_entry.hdl.raw_hdl;
140 
141  raw_except_table[except->exceptIndex] = default_raw_except_entry;
142  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
143
144  _CPU_ISR_Enable(level);
145   
146  return 1;
147}
148
149/*
150 * Exception global init.
151 *
152 * Install exception handler pointers from the raw exception table into the
153 * exception handler table.
154 */
155int mpc5xx_init_exceptions (rtems_raw_except_global_settings* config)
156{
157  unsigned                      i;
158  unsigned int level;
159 
160  /*
161   * store various accelerators
162   */
163  raw_except_table              = config->rawExceptHdlTbl;
164  local_settings                = config;
165  default_raw_except_entry      = config->defaultRawEntry;
166
167  _CPU_ISR_Disable(level);
168
169  for (i = 0; i < NUM_EXCEPTIONS; i++) {
170    exception_handler_table[i] = raw_except_table[i].hdl.raw_hdl;
171
172    if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
173      raw_except_table[i].on(&raw_except_table[i]);
174    }
175    else {
176      raw_except_table[i].off(&raw_except_table[i]);
177    }
178  }
179  _CPU_ISR_Enable(level);
180
181  return 1;
182}
183
184int mpc5xx_get_exception_config (rtems_raw_except_global_settings** config)
185{
186  *config = local_settings;
187  return 1;
188}
Note: See TracBrowser for help on using the repository browser.