xtruntime-frames.h 5.6 KB

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