OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [libgloss/] [bfin/] [include/] [sys/] [exception.h] - Blame information for rev 455

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * The authors hereby grant permission to use, copy, modify, distribute,
3
 * and license this software and its documentation for any purpose, provided
4
 * that existing copyright notices are retained in all copies and that this
5
 * notice is included verbatim in any distributions. No written agreement,
6
 * license, or royalty fee is required for any of the authorized uses.
7
 * Modifications to this software may be copyrighted by their authors
8
 * and need not follow the licensing terms described here, provided that
9
 * the new terms are clearly indicated on the first page of each file where
10
 * they apply.
11
 */
12
 
13
#pragma once
14
#ifndef __NO_BUILTIN
15
#pragma system_header /* exception.h */
16
#endif
17
/************************************************************************
18
 *
19
 * exception.h
20
 *
21
 * Copyright (C) 2008 Analog Devices, Inc.
22
 *
23
 ************************************************************************/
24
 
25
#ifndef _EXCEPTION_H
26
#define _EXCEPTION_H
27
 
28
#ifdef _MISRA_RULES
29
#pragma diag(push)
30
#pragma diag(suppress:misra_rule_5_7)
31
#pragma diag(suppress:misra_rule_6_3)
32
#pragma diag(suppress:misra_rule_19_4)
33
#pragma diag(suppress:misra_rule_19_7)
34
#pragma diag(suppress:misra_rule_19_10)
35
#pragma diag(suppress:misra_rule_19_13)
36
#endif /* _MISRA_RULES */
37
 
38
 
39
 
40
/*
41
** Definitions for user-friendly interrupt handling.
42
*/
43
 
44
/*
45
** Memory-Mapped Registers (MMRs) - these record what causes address
46
** exceptions.
47
*/
48
 
49
#define EX_DATA_FAULT_STATUS    0xFFE00008
50
#define EX_DATA_FAULT_ADDR      0xFFE0000C
51
#define EX_CODE_FAULT_STATUS    0xFFE01008
52
#define EX_CODE_FAULT_ADDR      0xFFE0100C
53
 
54
/*
55
** Event Vector Table
56
*/
57
 
58
#define EX_EVENT_VECTOR_TABLE   0xFFE02000
59
 
60
/*
61
** Meaning of the various bits in EXCAUSE field in SEQSTAT register.
62
*/
63
 
64
#define EX_BITS         0x3F    /* All EXCAUSE bits */
65
#define EX_TYPE         0x30    /* The bits which define the type */
66
#define EX_DEBUG        0x10    /* If set, is a debug exception type */
67
#define EX_SYS          0x20    /* If set, is a system exception type */
68
                                /* If neither set, is from EXCPT instr */
69
 
70
#define EX_IS_DEBUG_EXCEPTION(E)        (((E)&EX_TYPE)==EX_DEBUG)
71
#define EX_IS_SYSTEM_EXCEPTION(E)       (((E)&EX_TYPE)==EX_SYS)
72
#define EX_IS_USER_EXCEPTION(E)         (((E)&EX_TYPE)==0)
73
 
74
/*
75
** Service exceptions continue from the instruction after the one
76
** that raised the exception.
77
** Error exceptions restart the instruction that raised the exception.
78
*/
79
 
80
#define EX_IS_SERVICE_EXCEPTION(E)      (!EX_IS_SYSTEM_EXCEPTION(E))
81
#define EX_IS_ERROR_EXCEPTION(E)        (EX_IS_SYSTEM_EXCEPTION(E))
82
 
83
#define EX_DB_SINGLE_STEP 0x10  /* Processor is single-stepping */
84
#define EX_DB_EMTRCOVRFLW 0x11  /* Emulation Trace buffer overflowed */
85
 
86
#define EX_SYS_UNDEFINSTR 0x21  /* Undefined instruction */
87
#define EX_SYS_ILLINSTRC  0x22  /* Illegal instruction combination */
88
#define EX_SYS_DCPLBPROT  0x23  /* Data CPLB Protection violation */
89
#define EX_SYS_DALIGN     0x24  /* Data access misaligned address violation */
90
#define EX_SYS_UNRECEVT   0x25  /* Unrecoverable event */
91
#define EX_SYS_DCPLBMISS  0x26  /* Data access CPLB Miss */
92
#define EX_SYS_DCPLBMHIT  0x27  /* Data access CPLB Multiple Hits */
93
#define EX_SYS_EMWATCHPT  0x28  /* Emulation watch point match */
94
#define EX_SYS_CACCESSEX  0x29  /* Code fetch access exception */
95
#define EX_SYS_CALIGN     0x2A  /* Attempted misaligned instr cache fetch */
96
#define EX_SYS_CCPLBPROT  0x2B  /* Code fetch CPLB Protection */
97
#define EX_SYS_CCPLBMISS  0x2C  /* CPLB miss on an instruction fetch */
98
#define EX_SYS_CCPLBMHIT  0x2D  /* Code fetch CPLB Multiple Hits */
99
#define EX_SYS_ILLUSESUP  0x2E  /* Illegal use of Supervisor Resource */
100
 
101
/*
102
** Meaning of the various bits in HWERRCAUSE in SEQSTAT
103
*/
104
 
105
#define EX_HWBITS (0x1F<<14)    /* bits 18:14 */
106
 
107
#if !defined(__ADSPLPBLACKFIN__)
108
#define EX_HW_NOMEM1    (0x16<<14)
109
#define EX_HW_NOMEM2    (0x17<<14)
110
#else
111
#define EX_HW_SYSMMR    (0x02<<14)
112
#define EX_HW_EXTMEM    (0x03<<14)
113
#endif
114
#define EX_HW_DMAHIT    (0x01<<14)
115
#define EX_HW_PERFMON (0x12<<14)
116
#define EX_HW_RAISE     (0x18<<14)
117
 
118
/*
119
** Meaning of the bits in DATA_FAULT_STATUS and CODE_FAULT_STATUS
120
*/
121
 
122
#define EX_DATA_FAULT_ILLADDR   (1<<19) /* non-existent memory */
123
#define EX_DATA_FAULT_DAG       (1<<18) /* 0=>DAG0, 1=>DAG1 */
124
#define EX_DATA_FAULT_USERSUPV  (1<<17) /* 0=>user mode, 1=> supervisor */
125
#define EX_DATA_FAULT_READWRITE (1<<16) /* 0=>read, 1=>write */
126
#define EX_DATA_FAULT_CPLB       0xFFFF /* 0=>CPLB0, 1=>CPLB1, etc */
127
 
128
#define EX_CODE_FAULT_ILLADDR   (1<<19) /* non-existent memory */
129
#define EX_CODE_FAULT_USERSUPV  (1<<17) /* 0=>user mode, 1=> supervisor */
130
#define EX_CODE_FAULT_CPLB       0xFFFF /* 0=>CPLB0, 1=>CPLB1, etc */
131
 
132
/*
133
** The kinds of interrupt that can occur. These are also the
134
** indices into the Event Vector Table.
135
*/
136
 
137
#ifdef __cplusplus
138
extern "C" {
139
#endif
140
 
141
typedef enum {
142
  ik_err=-1,
143
  ik_emulation,
144
  ik_reset,
145
  ik_nmi,
146
  ik_exception,
147
  ik_global_int_enable,
148
  ik_hardware_err,
149
  ik_timer,
150
  ik_ivg7,
151
  ik_ivg8,
152
  ik_ivg9,
153
  ik_ivg10,
154
  ik_ivg11,
155
  ik_ivg12,
156
  ik_ivg13,
157
  ik_ivg14,
158
  ik_ivg15,
159
  num_interrupt_kind
160
} interrupt_kind;
161
 
162
/*
163
** Structure for recording details of an exception or interrupt
164
** that has occurred.
165
*/
166
 
167
typedef struct {
168
  interrupt_kind kind;          /* whether interrupt, exception, etc. */
169
  int value;                    /* interrupt number, exception type, etc. */
170
  void *pc;                     /* PC at point where exception occurred */
171
  void *addr;                   /* if an address faulted, which one. */
172
  unsigned status;              /* if an address faulted, why. */
173
} interrupt_info;
174
 
175
/*
176
** Macro for defining an interrupt routine
177
*/
178
 
179
typedef void (*ex_handler_fn)();
180
 
181
#define EX_HANDLER(KIND,NAME) \
182
_Pragma(#KIND) \
183
void NAME ()
184
 
185
#define EX_HANDLER_PROTO(KIND, NAME) EX_HANDLER(KIND, NAME)
186
 
187
#define EX_INTERRUPT_HANDLER(NAME)      EX_HANDLER(interrupt,NAME)
188
#define EX_EXCEPTION_HANDLER(NAME)      EX_HANDLER(exception,NAME)
189
#define EX_NMI_HANDLER(NAME)            EX_HANDLER(nmi,NAME)
190
#define EX_REENTRANT_HANDLER(NAME) \
191
_Pragma("interrupt_reentrant") \
192
EX_HANDLER(interrupt,NAME)
193
 
194
/*
195
** A convenience function for setting up the interrupt_info contents.
196
** Must be called from immediately with the interrupt handler.
197
*/
198
 
199
void get_interrupt_info(interrupt_kind int_kind, interrupt_info *int_info);
200
 
201
/*
202
** Diagnostics function for reporting unexpected events.
203
*/
204
 
205
void _ex_report_event(interrupt_info *int_info);
206
 
207
/*
208
** Register an interrupt handler within the EVT.
209
** Return previous value if there was one.
210
*/
211
ex_handler_fn register_handler(interrupt_kind int_kind, ex_handler_fn handler);
212
 
213
/*
214
** Some magic values for registering default and null handlers.
215
*/
216
 
217
#define EX_INT_DEFAULT ((ex_handler_fn)-1)
218
#define EX_INT_IGNORE  ((ex_handler_fn)0)
219
 
220
/*
221
** Extended function to register an interrupt handler within the EVT.
222
** Returns the old handler.
223
**
224
** If enabled == EX_INT_ALWAYS_ENABLE, install fn (if fn != EX_INT_IGNORE
225
** and fn != EX_INT_DISABLE), and then enable the interrupt in IMASK then
226
** return
227
**
228
** If fn == EX_INT_IGNORE, disable the interrupt
229
** If fn == EX_INT_DEFAULT, delete the handler entry in the EVT and disable
230
**   the interrupt in IMASK
231
** Otherwise, install the new interrupt handler.  Then,
232
**  If enabled == EX_INT_DISABLE, disable the interrupt in IMASK
233
**  If enabled == EX_INT_ENABLE, enable the interrupt in IMASK
234
**  otherwise leave the interrupt status alone.
235
*/
236
ex_handler_fn register_handler_ex(interrupt_kind kind, ex_handler_fn fn,
237
                                  int enable);
238
 
239
/* Constants for the enabled parameter of register_handler_ex */
240
#define EX_INT_DISABLE 0
241
#define EX_INT_ENABLE 1
242
#define EX_INT_KEEP_IMASK -1
243
#define EX_INT_ALWAYS_ENABLE 2
244
 
245
/*
246
** Allow the user to raise exceptions from C.
247
*/
248
 
249
int raise_interrupt(interrupt_kind kind, int which,
250
   int cmd, int arg1, int arg2);
251
 
252
#ifdef __cplusplus
253
  } /* extern "C" */
254
#endif
255
 
256
#ifdef _MISRA_RULES
257
#pragma diag(pop)
258
#endif /* _MISRA_RULES */
259
 
260
#endif /* _EXCEPTION_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.