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 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 49#if CPUCFG_REGS32 50 51#ifdef __ASSEMBLER__ 52#define _XAIDX(x) (4*(x)) 53#else 54typedef uint32_t mips_reg_t; 55#define _XAIDX(x) (x) 56#endif 57 58#else 59 60#ifdef __ASSEMBLER__ 61#define _XAIDX(x) (8*(x)) 62#else 63typedef uint64_t mips_reg_t; 64#define _XAIDX(x) (x) 65#endif 66 67#endif 68 69 70/* ********************************************************************* 71 * Exception vectors from the MIPS specification 72 ********************************************************************* */ 73 74#define MIPS_ROM_VEC_RESET 0x0000 75#define MIPS_ROM_VEC_TLBFILL 0x0200 76#define MIPS_ROM_VEC_XTLBFILL 0x0280 77#define MIPS_ROM_VEC_CACHEERR 0x0300 78#define MIPS_ROM_VEC_EXCEPTION 0x0380 79#define MIPS_ROM_VEC_INTERRUPT 0x0400 80#define MIPS_ROM_VEC_EJTAG 0x0480 81 82#define MIPS_RAM_VEC_TLBFILL 0x0000 83#define MIPS_RAM_VEC_XTLBFILL 0x0080 84#define MIPS_RAM_VEC_EXCEPTION 0x0180 85#define MIPS_RAM_VEC_INTERRUPT 0x0200 86#define MIPS_RAM_VEC_CACHEERR 0x0100 87#define MIPS_RAM_VEC_END 0x0300 88 89#define MIPS_RAM_EXL_VEC_TLBFILL 0x0100 90#define MIPS_RAM_EXL_VEC_XTLBFILL 0x0180 91 92 93/* ********************************************************************* 94 * Fixed locations of other low-memory objects. We stuff some 95 * important data in the spaces between the vectors. 96 ********************************************************************* */ 97 98#define CFE_LOCORE_GLOBAL_GP 0x0040 /* our "handle" */ 99#define CFE_LOCORE_GLOBAL_SP 0x0048 /* Stack pointer for exceptions */ 100#define CFE_LOCORE_GLOBAL_K0TMP 0x0050 /* Used by cache error handler */ 101#define CFE_LOCORE_GLOBAL_K1TMP 0x0058 /* Used by cache error handler */ 102#define CFE_LOCORE_GLOBAL_RATMP 0x0060 /* Used by cache error handler */ 103#define CFE_LOCORE_GLOBAL_GPTMP 0x0068 /* Used by cache error handler */ 104#define CFE_LOCORE_GLOBAL_CERRH 0x0070 /* Pointer to cache error handler */ 105 106#define CFE_LOCORE_GLOBAL_T0TMP 0x0240 /* used by cache error handler */ 107#define CFE_LOCORE_GLOBAL_T1TMP 0x0248 /* used by cache error handler */ 108#define CFE_LOCORE_GLOBAL_T2TMP 0x0250 /* used by cache error handler */ 109#define CFE_LOCORE_GLOBAL_T3TMP 0x0258 /* used by cache error handler */ 110 111#define CFE_LOCORE_GLOBAL_APIEPT 0x300 /* API entry point */ 112#define CFE_LOCORE_GLOBAL_NMIEPT 0x308 /* NMI handler entry point */ 113#define CFE_LOCORE_GLOBAL_CPUEPT 0x310 /* Alternate CPU entry point */ 114 115#define CFE_LOCORE_GLOBAL_END 0x500 /* End of CFE's locore area */ 116 117#define CFE_LOCORE_VXWORKS_BOOTLINE 0x700 /* Offset of VxWorks boot line */ 118/* Size of boot line is 256 bytes, so don't put any more locore before offset 0x800 */ 119 120/* ********************************************************************* 121 * Offsets into our exception handler table. 122 ********************************************************************* */ 123 124#define XTYPE_RESET 0 125#define XTYPE_TLBFILL 8 126#define XTYPE_XTLBFILL 16 127#define XTYPE_CACHEERR 24 128#define XTYPE_EXCEPTION 32 129#define XTYPE_INTERRUPT 40 130#define XTYPE_EJTAG 48 131 132/* ********************************************************************* 133 * Exception frame definitions. 134 ********************************************************************* */ 135 136/* 137 * The exception frame is divided up into pieces, representing the different 138 * parts of the processor that the data comes from: 139 * 140 * CP0: Words 0..7 141 * Int Regs: Words 8..41 142 * FP Regs: Words 42..73 143 * Total size: 74 words 144 */ 145 146#define EXCEPTION_SIZE _XAIDX(74) 147 148#define XCP0_BASE 0 149#define XGR_BASE 8 150#define XFR_BASE 42 151 152#define _XCP0IDX(x) _XAIDX((x)+XCP0_BASE) 153#define XCP0_SR _XCP0IDX(0) 154#define XCP0_CAUSE _XCP0IDX(1) 155#define XCP0_EPC _XCP0IDX(2) 156#define XCP0_VADDR _XCP0IDX(3) 157#define XCP0_PRID _XCP0IDX(4) 158 159#define _XGRIDX(x) _XAIDX((x)+XGR_BASE) 160#define XGR_ZERO _XGRIDX(0) 161#define XGR_AT _XGRIDX(1) 162#define XGR_V0 _XGRIDX(2) 163#define XGR_V1 _XGRIDX(3) 164#define XGR_A0 _XGRIDX(4) 165#define XGR_A1 _XGRIDX(5) 166#define XGR_A2 _XGRIDX(6) 167#define XGR_A3 _XGRIDX(7) 168#define XGR_T0 _XGRIDX(8) 169#define XGR_T1 _XGRIDX(9) 170#define XGR_T2 _XGRIDX(10) 171#define XGR_T3 _XGRIDX(11) 172#define XGR_T4 _XGRIDX(12) 173#define XGR_T5 _XGRIDX(13) 174#define XGR_T6 _XGRIDX(14) 175#define XGR_T7 _XGRIDX(15) 176#define XGR_S0 _XGRIDX(16) 177#define XGR_S1 _XGRIDX(17) 178#define XGR_S2 _XGRIDX(18) 179#define XGR_S3 _XGRIDX(19) 180#define XGR_S4 _XGRIDX(20) 181#define XGR_S5 _XGRIDX(21) 182#define XGR_S6 _XGRIDX(22) 183#define XGR_S7 _XGRIDX(23) 184#define XGR_T8 _XGRIDX(24) 185#define XGR_T9 _XGRIDX(25) 186#define XGR_K0 _XGRIDX(26) 187#define XGR_K1 _XGRIDX(27) 188#define XGR_GP _XGRIDX(28) 189#define XGR_SP _XGRIDX(29) 190#define XGR_FP _XGRIDX(30) 191#define XGR_RA _XGRIDX(31) 192#define XGR_LO _XGRIDX(32) 193#define XGR_HI _XGRIDX(33) 194 195 196#define _XFRIDX(x) _XAIDX((x)+XFR_BASE) 197#define XR_F0 _XFRIDX(0) 198#define XR_F1 _XFRIDX(1) 199#define XR_F2 _XFRIDX(2) 200#define XR_F3 _XFRIDX(3) 201#define XR_F4 _XFRIDX(4) 202#define XR_F5 _XFRIDX(5) 203#define XR_F6 _XFRIDX(6) 204#define XR_F7 _XFRIDX(7) 205#define XR_F8 _XFRIDX(8) 206#define XR_F9 _XFRIDX(9) 207#define XR_F10 _XFRIDX(10) 208#define XR_F11 _XFRIDX(11) 209#define XR_F12 _XFRIDX(12) 210#define XR_F13 _XFRIDX(13) 211#define XR_F14 _XFRIDX(14) 212#define XR_F15 _XFRIDX(15) 213#define XR_F16 _XFRIDX(16) 214#define XR_F17 _XFRIDX(17) 215#define XR_F18 _XFRIDX(18) 216#define XR_F19 _XFRIDX(19) 217#define XR_F20 _XFRIDX(20) 218#define XR_F21 _XFRIDX(21) 219#define XR_F22 _XFRIDX(22) 220#define XR_F23 _XFRIDX(23) 221#define XR_F24 _XFRIDX(24) 222#define XR_F25 _XFRIDX(25) 223#define XR_F26 _XFRIDX(26) 224#define XR_F27 _XFRIDX(27) 225#define XR_F28 _XFRIDX(28) 226#define XR_F29 _XFRIDX(29) 227#define XR_F30 _XFRIDX(30) 228#define XR_F31 _XFRIDX(31) 229#define XR_FCR _XFRIDX(32) 230#define XR_FID _XFRIDX(33) 231 232 233#ifndef __ASSEMBLER__ 234extern void _exc_setvector(int vectype, void *vecaddr); 235extern void _exc_crash_sim(void); 236extern void _exc_cache_crash_sim(void); 237extern void _exc_restart(void); 238extern void _exc_clear_sr_exl(void); 239extern void _exc_clear_sr_erl(void); 240void cfe_exception(int code,mips_reg_t *info); 241void cfe_setup_exceptions(void); 242#endif 243 244 245 246 247 248