se_bug_ui3.S 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. //Original:/proj/frio/dv/testcases/seq/se_bug_ui3/se_bug_ui3.dsp
  2. // Description: 32 bit special cases Undefined Instructions in Supervisor Mode
  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 // change for how much stack you need
  18. #endif
  19. #ifndef ITABLE
  20. #define ITABLE 0xF0000000
  21. #endif
  22. GEN_INT_INIT(ITABLE) // set location for interrupt table
  23. //
  24. // Reset/Bootstrap Code
  25. // (Here we should set the processor operating modes, initialize registers,
  26. // etc.)
  27. //
  28. BOOT:
  29. INIT_R_REGS(0); // initialize general purpose regs
  30. INIT_P_REGS(0); // initialize the pointers
  31. INIT_I_REGS(0); // initialize the dsp address regs
  32. INIT_M_REGS(0);
  33. INIT_L_REGS(0);
  34. INIT_B_REGS(0);
  35. CLI R1; // inhibit events during MMR writes
  36. LD32_LABEL(sp, USTACK); // setup the user stack pointer
  37. USP = SP;
  38. LD32_LABEL(sp, KSTACK); // setup the kernel stack pointer
  39. FP = SP; // and frame pointer
  40. LD32(p0, EVT0); // Setup Event Vectors and Handlers
  41. P0 += 4; // EVT0 not used (Emulation)
  42. P0 += 4; // EVT1 not used (Reset)
  43. LD32_LABEL(r0, NHANDLE); // NMI Handler (Int2)
  44. [ P0 ++ ] = R0;
  45. LD32_LABEL(r0, XHANDLE); // Exception Handler (Int3)
  46. [ P0 ++ ] = R0;
  47. P0 += 4; // EVT4 not used (Global Interrupt Enable)
  48. LD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5)
  49. [ P0 ++ ] = R0;
  50. LD32_LABEL(r0, THANDLE); // Timer Handler (Int6)
  51. [ P0 ++ ] = R0;
  52. LD32_LABEL(r0, I7HANDLE); // IVG7 Handler
  53. [ P0 ++ ] = R0;
  54. LD32_LABEL(r0, I8HANDLE); // IVG8 Handler
  55. [ P0 ++ ] = R0;
  56. LD32_LABEL(r0, I9HANDLE); // IVG9 Handler
  57. [ P0 ++ ] = R0;
  58. LD32_LABEL(r0, I10HANDLE);// IVG10 Handler
  59. [ P0 ++ ] = R0;
  60. LD32_LABEL(r0, I11HANDLE);// IVG11 Handler
  61. [ P0 ++ ] = R0;
  62. LD32_LABEL(r0, I12HANDLE);// IVG12 Handler
  63. [ P0 ++ ] = R0;
  64. LD32_LABEL(r0, I13HANDLE);// IVG13 Handler
  65. [ P0 ++ ] = R0;
  66. LD32_LABEL(r0, I14HANDLE);// IVG14 Handler
  67. [ P0 ++ ] = R0;
  68. LD32_LABEL(r0, I15HANDLE);// IVG15 Handler
  69. [ P0 ++ ] = R0;
  70. LD32(p0, EVT_OVERRIDE);
  71. R0 = 0;
  72. [ P0 ++ ] = R0;
  73. R1 = -1; // Change this to mask interrupts (*)
  74. CSYNC; // wait for MMR writes to finish
  75. STI R1; // sync and reenable events (implicit write to IMASK)
  76. DUMMY:
  77. R0 = 0 (Z);
  78. LT0 = r0; // set loop counters to something deterministic
  79. LB0 = r0;
  80. LC0 = r0;
  81. LT1 = r0;
  82. LB1 = r0;
  83. LC1 = r0;
  84. ASTAT = r0; // reset other internal regs
  85. SYSCFG = r0;
  86. RETS = r0; // prevent X's breaking LINK instruction
  87. // The following code sets up the test for running in USER mode
  88. LD32_LABEL(r0, STARTUSER);// One gets to user mode by doing a
  89. // ReturnFromInterrupt (RTI)
  90. RETI = r0; // We need to load the return address
  91. // Comment the following line for a USER Mode test
  92. JUMP STARTSUP; // jump to code start for SUPERVISOR mode
  93. RTI;
  94. STARTSUP:
  95. LD32_LABEL(p1, BEGIN);
  96. LD32(p0, EVT15);
  97. CLI R1; // inhibit events during write to MMR
  98. [ P0 ] = P1; // IVG15 (General) handler (Int 15) load with start
  99. CSYNC; // wait for it
  100. STI R1; // reenable events with proper imask
  101. RAISE 15; // after we RTI, INT 15 should be taken
  102. RTI;
  103. //
  104. // The Main Program
  105. //
  106. STARTUSER:
  107. LINK 0; // change for how much stack frame space you need.
  108. JUMP BEGIN;
  109. //*********************************************************************
  110. BEGIN:
  111. // COMMENT the following line for USER MODE tests
  112. [ -- SP ] = RETI; // enable interrupts in supervisor mode
  113. // **** YOUR CODE GOES HERE ****
  114. // count of UI's will be in r5, which was initialized to 0 by header
  115. .dw 0xC0E0 ;
  116. .dw 0x2000 ;
  117. .dw 0xC140 ;
  118. .dw 0x2000 ;
  119. .dw 0xC1A0 ;
  120. .dw 0x2000 ;
  121. .dw 0xC1C0 ;
  122. .dw 0x2000 ;
  123. .dw 0xC1E0 ;
  124. .dw 0x2000 ;
  125. .dw 0xC0E4 ;
  126. .dw 0x0 ;
  127. .dw 0xC144 ;
  128. .dw 0x0 ;
  129. .dw 0xC1A4 ;
  130. .dw 0x0 ;
  131. .dw 0xC1C4 ;
  132. .dw 0x0 ;
  133. .dw 0xC1E4 ;
  134. .dw 0x0 ;
  135. .dw 0xC0E4 ;
  136. .dw 0x2000 ;
  137. .dw 0xC144 ;
  138. .dw 0x2000 ;
  139. .dw 0xC1A4 ;
  140. .dw 0x2000 ;
  141. .dw 0xC1C4 ;
  142. .dw 0x2000 ;
  143. .dw 0xC1E4 ;
  144. .dw 0x2000 ;
  145. CHECK_INIT_DEF(p0); //CHECK_INIT(p0, 0xFF7FFFFC);
  146. // Xhandler counts all EXCAUSE = 0x21;
  147. CHECKREG(r5, 15); // count of all 16 bit UI's.
  148. END:
  149. dbg_pass; // End the test
  150. //*********************************************************************
  151. //
  152. // Handlers for Events
  153. //
  154. NHANDLE: // NMI Handler 2
  155. RTN;
  156. XHANDLE: // Exception Handler 3
  157. // 32 bit illegal opcode handler - skips bad instruction
  158. // handler MADE LEAN and destructive so test runs more quckly
  159. // se_undefinedinstruction1.dsp tests using a "nice" handler
  160. // [--sp] = ASTAT; // save what we damage
  161. // [--sp] = (r7 - r6);
  162. R7 = SEQSTAT;
  163. R7 <<= 26;
  164. R7 >>= 26; // only want EXCAUSE
  165. R6 = 0x21; // EXCAUSE 0x21 means I-Fetch Undefined Instruction
  166. CC = r7 == r6;
  167. IF !CC JUMP OUT; // If EXCAUSE != 0x21 then leave
  168. UNDEFINEDINSTRUCTION:
  169. R7 = RETX; // Fix up return address
  170. R7 += 4; // skip offending 32 bit instruction
  171. RETX = r7; // and put back in RETX
  172. R5 += 1; // Increment global counter
  173. OUT:
  174. // (r7 - r6) = [sp++];
  175. // ASTAT = [sp++];
  176. RTX;
  177. HWHANDLE: // HW Error Handler 5
  178. RTI;
  179. THANDLE: // Timer Handler 6
  180. RTI;
  181. I7HANDLE: // IVG 7 Handler
  182. RTI;
  183. I8HANDLE: // IVG 8 Handler
  184. RTI;
  185. I9HANDLE: // IVG 9 Handler
  186. RTI;
  187. I10HANDLE: // IVG 10 Handler
  188. RTI;
  189. I11HANDLE: // IVG 11 Handler
  190. RTI;
  191. I12HANDLE: // IVG 12 Handler
  192. RTI;
  193. I13HANDLE: // IVG 13 Handler
  194. RTI;
  195. I14HANDLE: // IVG 14 Handler
  196. RTI;
  197. I15HANDLE: // IVG 15 Handler
  198. RTI;
  199. // padding for the icache
  200. EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0;
  201. //
  202. // Data Segment
  203. //
  204. .data
  205. DATA:
  206. .space (0x10);
  207. // Stack Segments (Both Kernel and User)
  208. .space (STACKSIZE);
  209. KSTACK:
  210. .space (STACKSIZE);
  211. USTACK: