se_excpt_ssstep.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. //Original:/proj/frio/dv/testcases/seq/se_excpt_ssstep/se_excpt_ssstep.dsp
  2. // Description: EXCPT instruction vs Single Step Exception Priority
  3. # mach: bfin
  4. # sim: --environment operating
  5. #include "test.h"
  6. .include "testutils.inc"
  7. start
  8. //
  9. // Constants and Defines
  10. //
  11. include(gen_int.inc)
  12. include(selfcheck.inc)
  13. include(std.inc)
  14. //include(mmrs.inc)
  15. include(symtable.inc)
  16. #ifndef STACKSIZE
  17. #define STACKSIZE 0x10
  18. #endif
  19. #ifndef EVT
  20. #define EVT 0xFFE02000
  21. #endif
  22. #ifndef EVT15
  23. #define EVT15 0xFFE0203C
  24. #endif
  25. #ifndef EVT_OVERRIDE
  26. #define EVT_OVERRIDE 0xFFE02100
  27. #endif
  28. #ifndef ITABLE
  29. #define ITABLE 0xF0000000
  30. #endif
  31. GEN_INT_INIT(ITABLE) // set location for interrupt table
  32. //
  33. // Reset/Bootstrap Code
  34. // (Here we should set the processor operating modes, initialize registers,
  35. // etc.)
  36. //
  37. BOOT:
  38. INIT_R_REGS(0); // initialize general purpose regs
  39. INIT_P_REGS(0); // initialize the pointers
  40. INIT_I_REGS(0); // initialize the dsp address regs
  41. INIT_M_REGS(0);
  42. INIT_L_REGS(0);
  43. INIT_B_REGS(0);
  44. LD32_LABEL(sp, KSTACK); // setup the stack pointer
  45. FP = SP; // and frame pointer
  46. LD32(p0, EVT); // Setup Event Vectors and Handlers
  47. LD32_LABEL(r0, EHANDLE); // Emulation Handler (Int0)
  48. [ P0 ++ ] = R0;
  49. LD32_LABEL(r0, RHANDLE); // Reset Handler (Int1)
  50. [ P0 ++ ] = R0;
  51. LD32_LABEL(r0, NHANDLE); // NMI Handler (Int2)
  52. [ P0 ++ ] = R0;
  53. LD32_LABEL(r0, XHANDLE); // Exception Handler (Int3)
  54. [ P0 ++ ] = R0;
  55. [ P0 ++ ] = R0; // IVT4 not used
  56. LD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5)
  57. [ P0 ++ ] = R0;
  58. LD32_LABEL(r0, THANDLE); // Timer Handler (Int6)
  59. [ P0 ++ ] = R0;
  60. LD32_LABEL(r0, I7HANDLE); // IVG7 Handler
  61. [ P0 ++ ] = R0;
  62. LD32_LABEL(r0, I8HANDLE); // IVG8 Handler
  63. [ P0 ++ ] = R0;
  64. LD32_LABEL(r0, I9HANDLE); // IVG9 Handler
  65. [ P0 ++ ] = R0;
  66. LD32_LABEL(r0, I10HANDLE);// IVG10 Handler
  67. [ P0 ++ ] = R0;
  68. LD32_LABEL(r0, I11HANDLE);// IVG11 Handler
  69. [ P0 ++ ] = R0;
  70. LD32_LABEL(r0, I12HANDLE);// IVG12 Handler
  71. [ P0 ++ ] = R0;
  72. LD32_LABEL(r0, I13HANDLE);// IVG13 Handler
  73. [ P0 ++ ] = R0;
  74. LD32_LABEL(r0, I14HANDLE);// IVG14 Handler
  75. [ P0 ++ ] = R0;
  76. LD32_LABEL(r0, I15HANDLE);// IVG15 Handler
  77. [ P0 ++ ] = R0;
  78. LD32(p0, EVT_OVERRIDE);
  79. R0 = 0;
  80. [ P0 ++ ] = R0;
  81. R0 = -1; // Change this to mask interrupts (*)
  82. [ P0 ] = R0; // IMASK
  83. DUMMY:
  84. R0 = 0 (Z);
  85. LT0 = r0; // set loop counters to something deterministic
  86. LB0 = r0;
  87. LC0 = r0;
  88. LT1 = r0;
  89. LB1 = r0;
  90. LC1 = r0;
  91. ASTAT = r0; // reset other internal regs
  92. // The following code sets up the test for running in USER mode
  93. LD32_LABEL(r0, STARTUSER);// One gets to user mode by doing a
  94. // ReturnFromInterrupt (RTI)
  95. RETI = r0; // We need to load the return address
  96. R0 = 1;
  97. SYSCFG = r0; // Enable Supervisor Single Step
  98. CHECK_INIT_DEF(p2); //CHECK_INIT(p2, 0x2000);
  99. // Comment the following line for a USER Mode test
  100. // JUMP STARTSUP; // jump to code start for SUPERVISOR mode
  101. RTI;
  102. STARTSUP:
  103. LD32_LABEL(p1, BEGIN);
  104. LD32(p0, EVT15);
  105. [ P0 ] = P1; // IVG15 (General) handler (Int 15) load with start
  106. RAISE 15; // after we RTI, INT 15 should be taken
  107. NOP; // Workaround for Bug 217
  108. RTI;
  109. //
  110. // The Main Program
  111. //
  112. STARTUSER:
  113. LD32_LABEL(sp, USTACK); // setup the stack pointer
  114. FP = SP; // set frame pointer
  115. JUMP BEGIN;
  116. //*********************************************************************
  117. BEGIN:
  118. // COMMENT the following line for USER MODE tests
  119. // [--sp] = RETI; // enable interrupts in supervisor mode
  120. // **** YOUR CODE GOES HERE ****
  121. R0 = 0;
  122. R0 = 0;
  123. R0 = 0;
  124. R0 = 0;
  125. R0 = 0;
  126. EXCPT 15; // single step shouldn't happen for this.
  127. R0 = 0;
  128. R0 = 0;
  129. R0 = 0;
  130. R0 = 0;
  131. R0 = 0;
  132. EXCPT 3; // turn off single step via handler
  133. CHECKREG(r4, 1); // one EXCPT 15 instruction
  134. CHECKREG(r5, 14); // 14 instructions are executed before we disable single step
  135. // PUT YOUR TEST HERE!
  136. END:
  137. dbg_pass; // End the test
  138. //*********************************************************************
  139. //
  140. // Handlers for Events
  141. //
  142. EHANDLE: // Emulation Handler 0
  143. RTE;
  144. RHANDLE: // Reset Handler 1
  145. RTI;
  146. NHANDLE: // NMI Handler 2
  147. RTN;
  148. XHANDLE: // Exception Handler 3
  149. [ -- SP ] = ASTAT; // save what we damage
  150. [ -- SP ] = ( R7:6 );
  151. R7 = SEQSTAT;
  152. R7 <<= 26;
  153. R7 >>= 26; // only want EXCAUSE
  154. R6 = 0x10; // EXCAUSE 0x10 means Single Step
  155. CC = r7 == r6;
  156. IF CC JUMP SINGLESTEP (BP); // Go to Single Step Handler
  157. R6 = 15; // EXCAUSE 15 means EXCPT 15 instruction
  158. CC = r7 == r6;
  159. IF CC JUMP EXCPT15 (BP);
  160. SYSCFG = r0; // otherwise must be an EXCPT, so turn off singlestep
  161. JUMP.S OUT;
  162. EXCPT15:
  163. R4 += 1; // R4 counts EXCPT 15s
  164. JUMP.S OUT;
  165. SINGLESTEP:
  166. R5 += 1; // R5 counts single step events
  167. OUT:
  168. ( R7:6 ) = [ SP ++ ];
  169. ASTAT = [sp++];
  170. RTX;
  171. HWHANDLE: // HW Error Handler 5
  172. RTI;
  173. THANDLE: // Timer Handler 6
  174. RTI;
  175. I7HANDLE: // IVG 7 Handler
  176. RTI;
  177. I8HANDLE: // IVG 8 Handler
  178. RTI;
  179. I9HANDLE: // IVG 9 Handler
  180. RTI;
  181. I10HANDLE: // IVG 10 Handler
  182. RTI;
  183. I11HANDLE: // IVG 11 Handler
  184. RTI;
  185. I12HANDLE: // IVG 12 Handler
  186. RTI;
  187. I13HANDLE: // IVG 13 Handler
  188. RTI;
  189. I14HANDLE: // IVG 14 Handler
  190. RTI;
  191. I15HANDLE: // IVG 15 Handler
  192. RTI;
  193. NOP;NOP;NOP;NOP;NOP;NOP;NOP; // needed for icache bug
  194. //
  195. // Data Segment
  196. //
  197. .data
  198. DATA:
  199. .space (0x10);
  200. // Stack Segments (Both Kernel and User)
  201. .space (STACKSIZE);
  202. KSTACK:
  203. .space (STACKSIZE);
  204. USTACK: