source: rtems/c/src/lib/libcpu/powerpc/mpc8260/exceptions/raw_exception.c @ f0f1641

4.104.114.84.95
Last change on this file since f0f1641 was f0f1641, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/13/04 at 10:03:32

2004-04-13 Ralf Corsepius <ralf_corsepius@…>

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