source: rtems/c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c @ acc25ee

4.104.114.84.95
Last change on this file since acc25ee was acc25ee, checked in by Joel Sherrill <joel.sherrill@…>, on 12/02/99 at 14:31:19

Merged of mcp750 and mvme2307 BSP by Eric Valette <valette@…>.
As part of this effort, the mpc750 libcpu code is now shared with the
ppc6xx.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 * raw_exception.c  - This file contains implementation of C function to
3 *                    Instanciate 60x ppc primary exception entries.
4 *                    More detailled information can be found on motorola
5 *                    site and more precisely in the following book :
6 *
7 *                    MPC750
8 *                    Risc Microporcessor User's Manual
9 *                    Motorola REF : MPC750UM/AD 8/97
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
27static rtems_raw_except_connect_data*           raw_except_table;
28static rtems_raw_except_connect_data            default_raw_except_entry;
29static rtems_raw_except_global_settings*        local_settings;
30
31int mpc750_vector_is_valid(rtems_vector vector)
32{
33  switch(vector) {
34  case ASM_RESET_VECTOR: /* fall through */
35  case ASM_MACH_VECTOR:
36  case ASM_PROT_VECTOR:
37  case ASM_ISI_VECTOR:
38  case ASM_EXT_VECTOR:
39  case ASM_ALIGN_VECTOR:
40  case ASM_PROG_VECTOR:
41  case ASM_FLOAT_VECTOR:
42  case ASM_DEC_VECTOR:
43  case ASM_SYS_VECTOR:
44  case ASM_TRACE_VECTOR:
45  case ASM_ADDR_VECTOR:
46  case ASM_SYSMGMT_VECTOR:
47  case ASM_ITM_VECTOR:
48    return 1;
49  default: return 0;
50  }
51}
52
53int mpc604_vector_is_valid(rtems_vector vector)
54{
55  /*
56   * Please fill this for MVME2307
57   */
58  printk("Please complete libcpu/powerpc/XXX/raw_exception.c\n");
59  return 0;
60}
61
62int mpc60x_set_exception  (const rtems_raw_except_connect_data* except)
63{
64    unsigned int level;
65
66    if (current_ppc_cpu == PPC_750) {
67      if (!mpc750_vector_is_valid(except->exceptIndex)){
68        return 0;
69      }
70      goto exception_ok;
71    }
72    if (current_ppc_cpu == PPC_604) {
73      if (!mpc604_vector_is_valid(except->exceptIndex)){
74        return 0;
75      }
76      goto exception_ok;
77    }
78    printk("Please complete libcpu/powerpc/XXX/raw_exception.c\n");
79    return 0;
80   
81exception_ok:
82    /*
83     * Check if default handler is actually connected. If not issue an error.
84     * You must first get the current handler via mpc60x_get_current_exception
85     * and then disconnect it using mpc60x_delete_exception.
86     * RATIONALE : to always have the same transition by forcing the user
87     * to get the previous handler before accepting to disconnect.
88     */
89    if (memcmp(mpc60x_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
90      return 0;
91    }
92
93    _CPU_ISR_Disable(level);
94   
95    raw_except_table [except->exceptIndex] = *except;
96    codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
97             except->hdl.raw_hdl,
98             except->hdl.raw_hdl_size,
99             PPC_CACHE_ALIGNMENT);
100    except->on(except);
101   
102    _CPU_ISR_Enable(level);
103    return 1;
104}
105
106int mpc60x_get_current_exception (rtems_raw_except_connect_data* except)
107{
108  if (!mpc750_vector_is_valid(except->exceptIndex)){
109    return 0;
110  }
111   
112  *except = raw_except_table [except->exceptIndex];
113   
114  return 1;
115}
116
117int mpc60x_delete_exception (const rtems_raw_except_connect_data* except)
118{
119  unsigned int level;
120 
121  if (!mpc750_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 mpc60x_get_current_exception
127   * and then disconnect it using mpc60x_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 (memcmp(mpc60x_get_vector_addr(except->exceptIndex),
132             (void*)except->hdl.raw_hdl,
133             except->hdl.raw_hdl_size)) {
134      return 0;
135  }
136  _CPU_ISR_Disable(level);
137
138  except->off(except);
139  codemove((void*)mpc60x_get_vector_addr(except->exceptIndex),
140           default_raw_except_entry.hdl.raw_hdl,
141           default_raw_except_entry.hdl.raw_hdl_size,
142           PPC_CACHE_ALIGNMENT);
143
144   
145  raw_except_table[except->exceptIndex] = default_raw_except_entry;
146  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
147
148  _CPU_ISR_Enable(level);
149   
150  return 1;
151}
152
153/*
154 * Exception global init.
155 */
156int mpc60x_init_exceptions (rtems_raw_except_global_settings* config)
157{
158    unsigned                    i;
159    unsigned int level;
160   
161    /*
162     * store various accelerators
163     */
164    raw_except_table            = config->rawExceptHdlTbl;
165    local_settings              = config;
166    default_raw_except_entry    = config->defaultRawEntry;
167
168    _CPU_ISR_Disable(level);
169
170    for (i=0; i <= LAST_VALID_EXC; i++) {
171      if (!mpc750_vector_is_valid(i)){
172        continue;
173      }
174      codemove((void*)mpc60x_get_vector_addr(i),
175             raw_except_table[i].hdl.raw_hdl,
176             raw_except_table[i].hdl.raw_hdl_size,
177             PPC_CACHE_ALIGNMENT);
178      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
179        raw_except_table[i].on(&raw_except_table[i]);
180      }
181      else {
182        raw_except_table[i].off(&raw_except_table[i]);
183      }
184    }
185    _CPU_ISR_Enable(level);
186
187    return 1;
188}
189
190int mpc60x_get_exception_config (rtems_raw_except_global_settings** config)
191{
192  *config = local_settings;
193  return 1;
194}
195
Note: See TracBrowser for help on using the repository browser.