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

4.104.114.84.95
Last change on this file since d25d17b was 37731c2b, checked in by Joel Sherrill <joel.sherrill@…>, on 04/06/01 at 15:54:20

2001-03-30 Eric Valette <valette@…>

  • mpc8xx/exceptions/.cvsignore, mpc8xx/exceptions/Makefile.am, mpc8xx/exceptions/asm_utils.S, mpc8xx/exceptions/raw_exception.c, mpc8xx/exceptions/raw_exception.h: New files.
  • configure.in, mpc6xx/mmu/bat.h, mpc8xx/Makefile.am, mpc8xx/clock/clock.c, mpc8xx/console-generic/console-generic.c, mpc8xx/include/mpc8xx.h, mpc8xx/mmu/mmu.c, new_exception_processing/cpu.h, shared/include/byteorder.h, wrapup/Makefile.am: This is conversion of the mpc8xx CPU to the "new exception processing model."
  • 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
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 mpc860_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   
44  case ASM_SYS_VECTOR:
45  case ASM_TRACE_VECTOR:
46  case ASM_FLOATASSIST_VECTOR:
47
48  case ASM_SOFTEMUL_VECTOR:
49  case ASM_ITLBMISS_VECTOR:
50  case ASM_DTLBMISS_VECTOR:
51  case ASM_ITLBERROR_VECTOR:
52  case ASM_DTLBERROR_VECTOR:
53
54  case ASM_DBREAK_VECTOR:
55  case ASM_IBREAK_VECTOR:
56  case ASM_PERIFBREAK_VECTOR:
57  case ASM_DEVPORT_VECTOR:
58    return 1;
59  default: return 0;
60  }
61}
62
63int mpc8xx_vector_is_valid(rtems_vector vector)
64{
65     switch (current_ppc_cpu) {
66        case PPC_860:
67            if (!mpc860_vector_is_valid(vector)) {
68                return 0;
69            }
70            break;
71        default:
72            printk("Please complete libcpu/powerpc/mpc8xx/exceptions/raw_exception.c\n");
73            printk("current_ppc_cpu = %x\n", current_ppc_cpu);
74            return 0;
75     }
76     return 1;
77}
78
79int mpc8xx_set_exception  (const rtems_raw_except_connect_data* except)
80{
81    unsigned int level;
82
83    if (!mpc8xx_vector_is_valid(except->exceptIndex)) {
84      return 0;
85    }
86    /*
87     * Check if default handler is actually connected. If not issue an error.
88     * You must first get the current handler via mpc8xx_get_current_exception
89     * and then disconnect it using mpc8xx_delete_exception.
90     * RATIONALE : to always have the same transition by forcing the user
91     * to get the previous handler before accepting to disconnect.
92     */
93    if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex), (void*)default_raw_except_entry.hdl.raw_hdl,default_raw_except_entry.hdl.raw_hdl_size)) {
94      return 0;
95    }
96
97    _CPU_ISR_Disable(level);
98   
99    raw_except_table [except->exceptIndex] = *except;
100    codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
101             except->hdl.raw_hdl,
102             except->hdl.raw_hdl_size,
103             PPC_CACHE_ALIGNMENT);
104    except->on(except);
105   
106    _CPU_ISR_Enable(level);
107    return 1;
108}
109
110int mpc8xx_get_current_exception (rtems_raw_except_connect_data* except)
111{
112  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
113    return 0;
114  }
115   
116  *except = raw_except_table [except->exceptIndex];
117   
118  return 1;
119}
120
121int mpc8xx_delete_exception (const rtems_raw_except_connect_data* except)
122{
123  unsigned int level;
124 
125  if (!mpc8xx_vector_is_valid(except->exceptIndex)){
126    return 0;
127  }
128  /*
129   * Check if handler passed is actually connected. If not issue an error.
130   * You must first get the current handler via mpc8xx_get_current_exception
131   * and then disconnect it using mpc8xx_delete_exception.
132   * RATIONALE : to always have the same transition by forcing the user
133   * to get the previous handler before accepting to disconnect.
134   */
135  if (memcmp(mpc8xx_get_vector_addr(except->exceptIndex),
136             (void*)except->hdl.raw_hdl,
137             except->hdl.raw_hdl_size)) {
138      return 0;
139  }
140  _CPU_ISR_Disable(level);
141
142  except->off(except);
143  codemove((void*)mpc8xx_get_vector_addr(except->exceptIndex),
144           default_raw_except_entry.hdl.raw_hdl,
145           default_raw_except_entry.hdl.raw_hdl_size,
146           PPC_CACHE_ALIGNMENT);
147
148   
149  raw_except_table[except->exceptIndex] = default_raw_except_entry;
150  raw_except_table[except->exceptIndex].exceptIndex = except->exceptIndex;
151
152  _CPU_ISR_Enable(level);
153   
154  return 1;
155}
156
157/*
158 * Exception global init.
159 */
160int mpc8xx_init_exceptions (rtems_raw_except_global_settings* config)
161{
162    unsigned                    i;
163    unsigned int level;
164   
165    /*
166     * store various accelerators
167     */
168    raw_except_table            = config->rawExceptHdlTbl;
169    local_settings              = config;
170    default_raw_except_entry    = config->defaultRawEntry;
171
172    _CPU_ISR_Disable(level);
173
174    for (i=0; i <= LAST_VALID_EXC; i++) {
175      if (!mpc8xx_vector_is_valid(i)){
176        continue;
177      }
178      codemove((void*)mpc8xx_get_vector_addr(i),
179             raw_except_table[i].hdl.raw_hdl,
180             raw_except_table[i].hdl.raw_hdl_size,
181             PPC_CACHE_ALIGNMENT);
182      if (raw_except_table[i].hdl.raw_hdl != default_raw_except_entry.hdl.raw_hdl) {
183        raw_except_table[i].on(&raw_except_table[i]);
184      }
185      else {
186        raw_except_table[i].off(&raw_except_table[i]);
187      }
188    }
189    _CPU_ISR_Enable(level);
190
191    return 1;
192}
193
194int mpc8xx_get_exception_config (rtems_raw_except_global_settings** config)
195{
196  *config = local_settings;
197  return 1;
198}
199
Note: See TracBrowser for help on using the repository browser.