1/*  *********************************************************************
2    *  Broadcom Common Firmware Environment (CFE)
3    *
4    *  Exception/trap handler defs		File: exception.h
5    *
6    *  This module describes the exception handlers, exception
7    *  trap frames, and dispatch.
8    *
9    *  Author:  Mitch Lichtenberg (mpl@broadcom.com)
10    *
11    *********************************************************************
12    *
13    *  Copyright 2000,2001,2002,2003
14    *  Broadcom Corporation. All rights reserved.
15    *
16    *  This software is furnished under license and may be used and
17    *  copied only in accordance with the following terms and
18    *  conditions.  Subject to these conditions, you may download,
19    *  copy, install, use, modify and distribute modified or unmodified
20    *  copies of this software in source and/or binary form.  No title
21    *  or ownership is transferred hereby.
22    *
23    *  1) Any source code used, modified or distributed must reproduce
24    *     and retain this copyright notice and list of conditions
25    *     as they appear in the source file.
26    *
27    *  2) No right is granted to use any trade name, trademark, or
28    *     logo of Broadcom Corporation.  The "Broadcom Corporation"
29    *     name may not be used to endorse or promote products derived
30    *     from this software without the prior written permission of
31    *     Broadcom Corporation.
32    *
33    *  3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34    *     IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35    *     WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36    *     PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37    *     SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38    *     PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39    *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40    *     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41    *     GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42    *     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43    *     OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44    *     TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45    *     THE POSSIBILITY OF SUCH DAMAGE.
46    ********************************************************************* */
47
48#ifdef __ASSEMBLER__
49#define _XAIDX(x)	(8*(x))
50#else
51#define _XAIDX(x)	(x)
52#endif
53
54
55/*  *********************************************************************
56    *  Exception vectors from the MIPS specification
57    ********************************************************************* */
58
59#define MIPS_ROM_VEC_RESET	0x0000
60#define MIPS_ROM_VEC_TLBFILL	0x0200
61#define MIPS_ROM_VEC_XTLBFILL	0x0280
62#define MIPS_ROM_VEC_CACHEERR	0x0300
63#define MIPS_ROM_VEC_EXCEPTION	0x0380
64#define MIPS_ROM_VEC_INTERRUPT	0x0400
65#define MIPS_ROM_VEC_EJTAG	0x0480
66
67#define MIPS_RAM_VEC_TLBFILL	0x0000
68#define MIPS_RAM_VEC_XTLBFILL	0x0080
69#define MIPS_RAM_VEC_EXCEPTION	0x0180
70#define MIPS_RAM_VEC_INTERRUPT	0x0200
71#define MIPS_RAM_VEC_CACHEERR	0x0100
72#define MIPS_RAM_VEC_END	0x0300
73
74#define MIPS_RAM_EXL_VEC_TLBFILL  0x0100
75#define MIPS_RAM_EXL_VEC_XTLBFILL 0x0180
76
77
78/*  *********************************************************************
79    *  Fixed locations of other low-memory objects.  We stuff some
80    *  important data in the spaces between the vectors.
81    ********************************************************************* */
82
83#define CFE_LOCORE_GLOBAL_GP	0x0040		/* our "handle" */
84#define CFE_LOCORE_GLOBAL_SP	0x0048		/* Stack pointer for exceptions */
85#define CFE_LOCORE_GLOBAL_K0TMP	0x0050		/* Used by cache error handler */
86#define CFE_LOCORE_GLOBAL_K1TMP	0x0058		/* Used by cache error handler */
87#define CFE_LOCORE_GLOBAL_RATMP	0x0060		/* Used by cache error handler */
88#define CFE_LOCORE_GLOBAL_GPTMP	0x0068		/* Used by cache error handler */
89#define CFE_LOCORE_GLOBAL_CERRH	0x0070		/* Pointer to cache error handler */
90
91#define CFE_LOCORE_GLOBAL_T0TMP	0x0240		/* used by cache error handler */
92#define CFE_LOCORE_GLOBAL_T1TMP	0x0248		/* used by cache error handler */
93#define CFE_LOCORE_GLOBAL_T2TMP	0x0250		/* used by cache error handler */
94#define CFE_LOCORE_GLOBAL_T3TMP	0x0258		/* used by cache error handler */
95
96/*  *********************************************************************
97    *  Offsets into our exception handler table.
98    ********************************************************************* */
99
100#define XTYPE_RESET	0
101#define XTYPE_TLBFILL	8
102#define XTYPE_XTLBFILL	16
103#define XTYPE_CACHEERR	24
104#define XTYPE_EXCEPTION	32
105#define XTYPE_INTERRUPT	40
106#define XTYPE_EJTAG	48
107
108/*  *********************************************************************
109    *  Exception frame definitions.
110    ********************************************************************* */
111
112/*
113 * The exception frame is divided up into pieces, representing the different
114 * parts of the processor that the data comes from:
115 *
116 * CP0:		Words 0..7
117 * Int Regs:	Words 8..41
118 * FP Regs:     Words 42..73
119 * Total size:  74 words
120 */
121
122#define EXCEPTION_SIZE	_XAIDX(74)
123
124#define XCP0_BASE	0
125#define XGR_BASE	8
126#define XFR_BASE	42
127
128#define _XCP0IDX(x)	_XAIDX((x)+XCP0_BASE)
129#define XCP0_SR		_XCP0IDX(0)
130#define XCP0_CAUSE	_XCP0IDX(1)
131#define XCP0_EPC	_XCP0IDX(2)
132#define XCP0_VADDR	_XCP0IDX(3)
133#define XCP0_PRID	_XCP0IDX(4)
134
135#define _XGRIDX(x)	_XAIDX((x)+XGR_BASE)
136#define XGR_ZERO       	_XGRIDX(0)
137#define XGR_AT		_XGRIDX(1)
138#define XGR_V0		_XGRIDX(2)
139#define XGR_V1		_XGRIDX(3)
140#define XGR_A0		_XGRIDX(4)
141#define XGR_A1		_XGRIDX(5)
142#define XGR_A2		_XGRIDX(6)
143#define XGR_A3		_XGRIDX(7)
144#define XGR_T0		_XGRIDX(8)
145#define XGR_T1		_XGRIDX(9)
146#define XGR_T2		_XGRIDX(10)
147#define XGR_T3		_XGRIDX(11)
148#define XGR_T4		_XGRIDX(12)
149#define XGR_T5		_XGRIDX(13)
150#define XGR_T6		_XGRIDX(14)
151#define XGR_T7		_XGRIDX(15)
152#define XGR_S0		_XGRIDX(16)
153#define XGR_S1		_XGRIDX(17)
154#define XGR_S2		_XGRIDX(18)
155#define XGR_S3		_XGRIDX(19)
156#define XGR_S4		_XGRIDX(20)
157#define XGR_S5		_XGRIDX(21)
158#define XGR_S6		_XGRIDX(22)
159#define XGR_S7		_XGRIDX(23)
160#define XGR_T8		_XGRIDX(24)
161#define XGR_T9		_XGRIDX(25)
162#define XGR_K0		_XGRIDX(26)
163#define XGR_K1		_XGRIDX(27)
164#define XGR_GP		_XGRIDX(28)
165#define XGR_SP		_XGRIDX(29)
166#define XGR_FP		_XGRIDX(30)
167#define XGR_RA		_XGRIDX(31)
168#define XGR_LO		_XGRIDX(32)
169#define XGR_HI		_XGRIDX(33)
170
171
172#define _XFRIDX(x)	_XAIDX((x)+XFR_BASE)
173#define XR_F0		_XFRIDX(0)
174#define XR_F1		_XFRIDX(1)
175#define XR_F2		_XFRIDX(2)
176#define XR_F3		_XFRIDX(3)
177#define XR_F4		_XFRIDX(4)
178#define XR_F5		_XFRIDX(5)
179#define XR_F6		_XFRIDX(6)
180#define XR_F7		_XFRIDX(7)
181#define XR_F8		_XFRIDX(8)
182#define XR_F9		_XFRIDX(9)
183#define XR_F10		_XFRIDX(10)
184#define XR_F11		_XFRIDX(11)
185#define XR_F12		_XFRIDX(12)
186#define XR_F13		_XFRIDX(13)
187#define XR_F14		_XFRIDX(14)
188#define XR_F15		_XFRIDX(15)
189#define XR_F16		_XFRIDX(16)
190#define XR_F17		_XFRIDX(17)
191#define XR_F18		_XFRIDX(18)
192#define XR_F19		_XFRIDX(19)
193#define XR_F20		_XFRIDX(20)
194#define XR_F21		_XFRIDX(21)
195#define XR_F22		_XFRIDX(22)
196#define XR_F23		_XFRIDX(23)
197#define XR_F24		_XFRIDX(24)
198#define XR_F25		_XFRIDX(25)
199#define XR_F26		_XFRIDX(26)
200#define XR_F27		_XFRIDX(27)
201#define XR_F28		_XFRIDX(28)
202#define XR_F29		_XFRIDX(29)
203#define XR_F30		_XFRIDX(30)
204#define XR_F31		_XFRIDX(31)
205#define XR_FCR		_XFRIDX(32)
206#define XR_FID		_XFRIDX(33)
207
208
209#ifndef __ASSEMBLER__
210extern void _exc_setvector(int vectype, void *vecaddr);
211extern void _exc_crash_sim(void);
212extern void _exc_cache_crash_sim(void);
213extern void _exc_restart(void);
214extern void _exc_clear_sr_exl(void);
215extern void _exc_clear_sr_erl(void);
216void cfe_exception(int code,uint64_t *info);
217void cfe_setup_exceptions(void);
218#endif
219
220
221
222
223
224