1 /* xtruntime-frames.h - exception stack frames for single-threaded run-time */ 2 /* $Id: //depot/rel/Foxhill/dot.9/Xtensa/OS/include/xtensa/xtruntime-frames.h#1 $ */ 3 4 /* 5 * Copyright (c) 2002-2012 Tensilica Inc. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining 8 * a copy of this software and associated documentation files (the 9 * "Software"), to deal in the Software without restriction, including 10 * without limitation the rights to use, copy, modify, merge, publish, 11 * distribute, sublicense, and/or sell copies of the Software, and to 12 * permit persons to whom the Software is furnished to do so, subject to 13 * the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included 16 * in all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 */ 26 27 #ifndef _XTRUNTIME_FRAMES_H_ 28 #define _XTRUNTIME_FRAMES_H_ 29 30 #include <xtensa/config/core.h> 31 32 /* Macros that help define structures for both C and assembler: */ 33 #if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) 34 #define STRUCT_BEGIN .pushsection .text; .struct 0 35 #define STRUCT_FIELD(ctype,size,pre,name) pre##name: .space size 36 #define STRUCT_AFIELD(ctype,size,pre,name,n) pre##name: .if n ; .space (size)*(n) ; .endif 37 #define STRUCT_AFIELD_A(ctype,size,align,pre,name,n) .balign align ; pre##name: .if n ; .space (size)*(n) ; .endif 38 #define STRUCT_END(sname) sname##Size:; .popsection 39 #else /*_ASMLANGUAGE||__ASSEMBLER__*/ 40 #define STRUCT_BEGIN typedef struct { 41 #define STRUCT_FIELD(ctype,size,pre,name) ctype name; 42 #define STRUCT_AFIELD(ctype,size,pre,name,n) ctype name[n]; 43 #define STRUCT_AFIELD_A(ctype,size,align,pre,name,n) ctype name[n] __attribute__((aligned(align))); 44 #define STRUCT_END(sname) } sname; 45 #endif /*_ASMLANGUAGE||__ASSEMBLER__*/ 46 47 48 /* 49 * Kernel vector mode exception stack frame. 50 * 51 * NOTE: due to the limited range of addi used in the current 52 * kernel exception vector, and the fact that historically 53 * the vector is limited to 12 bytes, the size of this 54 * stack frame is limited to 128 bytes (currently at 64). 55 */ 56 STRUCT_BEGIN 57 STRUCT_FIELD (long,4,KEXC_,pc) /* "parm" */ 58 STRUCT_FIELD (long,4,KEXC_,ps) 59 STRUCT_AFIELD(long,4,KEXC_,areg, 4) /* a12 .. a15 */ 60 STRUCT_FIELD (long,4,KEXC_,sar) /* "save" */ 61 #if XCHAL_HAVE_LOOPS 62 STRUCT_FIELD (long,4,KEXC_,lcount) 63 STRUCT_FIELD (long,4,KEXC_,lbeg) 64 STRUCT_FIELD (long,4,KEXC_,lend) 65 #endif 66 #if XCHAL_HAVE_MAC16 67 STRUCT_FIELD (long,4,KEXC_,acclo) 68 STRUCT_FIELD (long,4,KEXC_,acchi) 69 STRUCT_AFIELD(long,4,KEXC_,mr, 4) 70 #endif 71 STRUCT_END(KernelFrame) 72 73 74 /* 75 * User vector mode exception stack frame: 76 * 77 * WARNING: if you modify this structure, you MUST modify the 78 * computation of the pad size (ALIGNPAD) accordingly. 79 */ 80 STRUCT_BEGIN 81 STRUCT_FIELD (long,4,UEXC_,pc) 82 STRUCT_FIELD (long,4,UEXC_,ps) 83 STRUCT_FIELD (long,4,UEXC_,sar) 84 STRUCT_FIELD (long,4,UEXC_,vpri) 85 #ifdef __XTENSA_CALL0_ABI__ 86 STRUCT_FIELD (long,4,UEXC_,a0) 87 #endif 88 STRUCT_FIELD (long,4,UEXC_,a2) 89 STRUCT_FIELD (long,4,UEXC_,a3) 90 STRUCT_FIELD (long,4,UEXC_,a4) 91 STRUCT_FIELD (long,4,UEXC_,a5) 92 #ifdef __XTENSA_CALL0_ABI__ 93 STRUCT_FIELD (long,4,UEXC_,a6) 94 STRUCT_FIELD (long,4,UEXC_,a7) 95 STRUCT_FIELD (long,4,UEXC_,a8) 96 STRUCT_FIELD (long,4,UEXC_,a9) 97 STRUCT_FIELD (long,4,UEXC_,a10) 98 STRUCT_FIELD (long,4,UEXC_,a11) 99 STRUCT_FIELD (long,4,UEXC_,a12) 100 STRUCT_FIELD (long,4,UEXC_,a13) 101 STRUCT_FIELD (long,4,UEXC_,a14) 102 STRUCT_FIELD (long,4,UEXC_,a15) 103 #endif 104 STRUCT_FIELD (long,4,UEXC_,exccause) /* NOTE: can probably rid of this one (pass direct) */ 105 #if XCHAL_HAVE_LOOPS 106 STRUCT_FIELD (long,4,UEXC_,lcount) 107 STRUCT_FIELD (long,4,UEXC_,lbeg) 108 STRUCT_FIELD (long,4,UEXC_,lend) 109 #endif 110 #if XCHAL_HAVE_MAC16 111 STRUCT_FIELD (long,4,UEXC_,acclo) 112 STRUCT_FIELD (long,4,UEXC_,acchi) 113 STRUCT_AFIELD(long,4,UEXC_,mr, 4) 114 #endif 115 /* ALIGNPAD is the 16-byte alignment padding. */ 116 #ifdef __XTENSA_CALL0_ABI__ 117 # define CALL0_ABI 1 118 #else 119 # define CALL0_ABI 0 120 #endif 121 #define ALIGNPAD ((3 + XCHAL_HAVE_LOOPS*1 + XCHAL_HAVE_MAC16*2 + CALL0_ABI*1) & 3) 122 #if ALIGNPAD 123 STRUCT_AFIELD(long,4,UEXC_,pad, ALIGNPAD) /* 16-byte alignment padding */ 124 #endif 125 /*STRUCT_AFIELD_A(char,1,XCHAL_CPEXTRA_SA_ALIGN,UEXC_,ureg, (XCHAL_CPEXTRA_SA_SIZE+3)&-4)*/ /* not used */ 126 STRUCT_END(UserFrame) 127 128 129 #if defined(_ASMLANGUAGE) || defined(__ASSEMBLER__) 130 131 132 /* Check for UserFrameSize small enough not to require rounding...: */ 133 /* Skip 16-byte save area, then 32-byte space for 8 regs of call12 134 * (which overlaps with 16-byte GCC nested func chaining area), 135 * then exception stack frame: */ 136 .set UserFrameTotalSize, 16+32+UserFrameSize 137 /* Greater than 112 bytes? (max range of ADDI, both signs, when aligned to 16 bytes): */ 138 .ifgt UserFrameTotalSize-112 139 /* Round up to 256-byte multiple to accelerate immediate adds: */ 140 .set UserFrameTotalSize, ((UserFrameTotalSize+255) & 0xFFFFFF00) 141 .endif 142 # define ESF_TOTALSIZE UserFrameTotalSize 143 144 #endif /* _ASMLANGUAGE || __ASSEMBLER__ */ 145 146 147 #if XCHAL_NUM_CONTEXTS > 1 148 /* Structure of info stored on new context's stack for setup: */ 149 STRUCT_BEGIN 150 STRUCT_FIELD (long,4,INFO_,sp) 151 STRUCT_FIELD (long,4,INFO_,arg1) 152 STRUCT_FIELD (long,4,INFO_,funcpc) 153 STRUCT_FIELD (long,4,INFO_,prevps) 154 STRUCT_END(SetupInfo) 155 #endif 156 157 158 #define KERNELSTACKSIZE 1024 159 160 161 #endif /* _XTRUNTIME_FRAMES_H_ */ 162