c_progctrl_csync_mmr.S 5.4 KB

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