1 //Original:/proj/frio/dv/testcases/core/c_interr_pending/c_interr_pending.dsp 2 // Spec Reference: CLI STI interrupt on HW TIMER to disable interrupt 3 # mach: bfin 4 # sim: --environment operating 5 6 #include "test.h" 7 .include "testutils.inc" 8 start 9 10 // 11 // Include Files 12 // 13 14 include(std.inc) 15 include(selfcheck.inc) 16 17 // Defines 18 19 #ifndef TCNTL 20 #define TCNTL 0xFFE03000 21 #endif 22 #ifndef TPERIOD 23 #define TPERIOD 0xFFE03004 24 #endif 25 #ifndef TSCALE 26 #define TSCALE 0xFFE03008 27 #endif 28 #ifndef TCOUNT 29 #define TCOUNT 0xFFE0300c 30 #endif 31 #ifndef EVT 32 #define EVT 0xFFE02000 33 #endif 34 #ifndef EVT15 35 #define EVT15 0xFFE0203c 36 #endif 37 #ifndef EVT_OVERRIDE 38 #define EVT_OVERRIDE 0xFFE02100 39 #endif 40 #ifndef ITABLE 41 #define ITABLE 0x000FF000 42 #endif 43 #ifndef PROGRAM_STACK 44 #define PROGRAM_STACK 0x000FF100 45 #endif 46 #ifndef STACKSIZE 47 #define STACKSIZE 0x00000300 48 #endif 49 50 // Boot code 51 52 BOOT : 53 INIT_R_REGS(0); // Initialize Dregs 54 INIT_P_REGS(0); // Initialize Pregs 55 56 // CHECK_INIT(p5, 0x00BFFFFC); 57 // CHECK_INIT(p5, 0xE0000000); 58 include(symtable.inc) 59 CHECK_INIT_DEF(p5); 60 61 LD32(sp, 0x000FF200); 62 LD32(p0, EVT); // Setup Event Vectors and Handlers 63 64 LD32_LABEL(r0, EHANDLE); // Emulation Handler (Int0) 65 [ P0 ++ ] = R0; 66 67 LD32_LABEL(r0, RHANDLE); // Reset Handler (Int1) 68 [ P0 ++ ] = R0; 69 70 LD32_LABEL(r0, NHANDLE); // NMI Handler (Int2) 71 [ P0 ++ ] = R0; 72 73 LD32_LABEL(r0, XHANDLE); // Exception Handler (Int3) 74 [ P0 ++ ] = R0; 75 76 [ P0 ++ ] = R0; // IVT4 not used 77 78 LD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5) 79 [ P0 ++ ] = R0; 80 81 LD32_LABEL(r0, THANDLE); // Timer Handler (Int6) 82 [ P0 ++ ] = R0; 83 84 LD32_LABEL(r0, I7HANDLE); // IVG7 Handler 85 [ P0 ++ ] = R0; 86 87 LD32_LABEL(r0, I8HANDLE); // IVG8 Handler 88 [ P0 ++ ] = R0; 89 90 LD32_LABEL(r0, I9HANDLE); // IVG9 Handler 91 [ P0 ++ ] = R0; 92 93 LD32_LABEL(r0, I10HANDLE); // IVG10 Handler 94 [ P0 ++ ] = R0; 95 96 LD32_LABEL(r0, I11HANDLE); // IVG11 Handler 97 [ P0 ++ ] = R0; 98 99 LD32_LABEL(r0, I12HANDLE); // IVG12 Handler 100 [ P0 ++ ] = R0; 101 102 LD32_LABEL(r0, I13HANDLE); // IVG13 Handler 103 [ P0 ++ ] = R0; 104 105 LD32_LABEL(r0, I14HANDLE); // IVG14 Handler 106 [ P0 ++ ] = R0; 107 108 LD32_LABEL(r0, I15HANDLE); // IVG15 Handler 109 [ P0 ++ ] = R0; 110 111 LD32(p0, EVT_OVERRIDE); 112 R0 = 0; 113 [ P0 ++ ] = R0; 114 R0 = -1; // Change this to mask interrupts (*) 115 [ P0 ] = R0; // IMASK 116 117 LD32_LABEL(p1, START); 118 119 LD32(p0, EVT15); 120 [ P0 ] = P1; // IVG15 (General) handler (Int 15) load with start 121 CSYNC; 122 RAISE 15; // after we RTI, INT 15 should be taken 123 124 LD32_LABEL(r7, START); 125 RETI = r7; 126 NOP; // Workaround for Bug 217 127 RTI; 128 NOP; 129 NOP; 130 NOP; 131 NOP; 132 NOP; 133 NOP; 134 NOP; 135 NOP; 136 DUMMY: 137 NOP; 138 NOP; 139 NOP; 140 NOP; 141 NOP; 142 NOP; 143 NOP; 144 NOP; 145 NOP; 146 NOP; 147 148 //.code 0x200 149 START : 150 P1 = 0x0; 151 R7 = 0x0; 152 R6 = 0x1; 153 [ -- SP ] = RETI; // Enable Nested Interrupts 154 155 CLI R1; // stop interrupt 156 WR_MMR(TCNTL, 0x00000001, p0, r0); // Turn ON TMPWR (active state) 157 WR_MMR(TPERIOD, 0x00000050, p0, r0); 158 WR_MMR(TCOUNT, 0x00000013, p0, r0); 159 WR_MMR(TSCALE, 0x00000000, p0, r0); 160 CSYNC; 161 // Read the contents of the Timer 162 163 RD_MMR(TPERIOD, p0, r2); 164 CHECKREG(r2, 0x00000050); 165 166 // RD_MMR(TCOUNT, p0, r3); 167 // CHECKREG(r3, 0x00000013);// fsim -ro useChecker=regtrace -seed 8b8db910 168 169 170 WR_MMR(TCNTL, 0x00000003, p0, r0); // enable Timer (TMPWR, TMREN) 171 CSYNC; 172 173 RD_MMR(TPERIOD, p0, r4); 174 CHECKREG(r4, 0x00000050); 175 176 // RD_MMR(TCNTL, p0, r5); 177 // CHECKREG(r5, 0x0000000B); // INTERRUPT did happen 178 179 WR_MMR(TCNTL, 0x00000000, p0, r0); // Turn OFF Timer 180 CSYNC; 181 NOP; 182 WR_MMR(TCNTL, 0x00000001, p0, r0); // Turn ON Timer Power 183 WR_MMR(TPERIOD, 0x00000015, p0, r0); 184 WR_MMR(TCOUNT, 0x00000013, p0, r0); 185 WR_MMR(TSCALE, 0x00000002, p0, r0); 186 WR_MMR(TCNTL, 0x00000007, p0, r0); // Turn ON Timer (TAUTORLD=1) 187 CSYNC; 188 NOP; 189 NOP; 190 NOP; 191 NOP; 192 NOP; 193 NOP; 194 NOP; 195 NOP; 196 NOP; 197 NOP; 198 NOP; 199 NOP; 200 NOP; 201 NOP; 202 NOP; 203 JUMP.S label4; 204 R4.L = 0x1111; // Will be killed 205 R4.H = 0x1111; // Will be killed 206 NOP; 207 NOP; 208 NOP; 209 label5: R5.H = 0x7777; 210 R5.L = 0x7888; 211 JUMP.S label6; 212 R5.L = 0x1111; // Will be killed 213 R5.H = 0x1111; // Will be killed 214 NOP; 215 NOP; 216 NOP; 217 NOP; 218 NOP; 219 NOP; 220 label4: R4.H = 0x5555; 221 R4.L = 0x6666; 222 NOP; 223 JUMP.S label5; 224 R5.L = 0x2222; // Will be killed 225 R5.H = 0x2222; // Will be killed 226 NOP; 227 NOP; 228 NOP; 229 NOP; 230 label6: R3.H = 0x7999; 231 R3.L = 0x7aaa; 232 NOP; 233 NOP; 234 NOP; 235 NOP; 236 NOP; 237 NOP; 238 NOP; 239 // With auto reload 240 // Read the contents of the Timer 241 RAISE 7; 242 RD_MMR(TPERIOD, p0, r2); 243 CHECKREG(r2, 0x00000015); 244 245 CHECKREG(p1, 0x00000000); // no interrupt being serviced 246 CHECKREG(r7, 0x00000000); // no interrupt being serviced 247 WR_MMR(TCNTL, 0x00000000, p0, r0); // Turn OFF Timer 248 CSYNC; 249 STI R1; 250 NOP; NOP; NOP; 251 CHECKREG(r7, 0x00000001); // interrupt being serviced 252 CHECKREG(p1, 0x00000001); // interrupt being serviced 253 NOP; 254 255 256 257 258 259 dbg_pass; // Call Endtest Macro 260 261 262 263 //********************************************************************* 264 // 265 // Handlers for Events 266 // 267 //.code ITABLE 268 269 EHANDLE: // Emulation Handler 0 270 RTE; 271 272 RHANDLE: // Reset Handler 1 273 RTI; 274 275 NHANDLE: // NMI Handler 2 276 RTN; 277 278 XHANDLE: // Exception Handler 3 279 RTX; 280 281 HWHANDLE: // HW Error Handler 5 282 RTI; 283 284 THANDLE: // Timer Handler 6 285 R7 = R7 + R6; 286 RTI; 287 288 I7HANDLE: // IVG 7 Handler 289 P1 += 1; 290 291 RTI; 292 293 I8HANDLE: // IVG 8 Handler 294 RTI; 295 296 I9HANDLE: // IVG 9 Handler 297 RTI; 298 299 I10HANDLE: // IVG 10 Handler 300 RTI; 301 302 I11HANDLE: // IVG 11 Handler 303 RTI; 304 305 I12HANDLE: // IVG 12 Handler 306 RTI; 307 308 I13HANDLE: // IVG 13 Handler 309 RTI; 310 311 I14HANDLE: // IVG 14 Handler 312 RTI; 313 314 I15HANDLE: // IVG 15 Handler 315 R5 = RETI; 316 P0 = R5; 317 JUMP ( P0 ); 318 RTI; 319 320 .section MEM_DATA_ADDR_1,"aw" 321 322 .space (STACKSIZE); 323 STACK: 324 NOP;NOP;NOP;NOP;NOP;NOP;NOP; // needed for icache bug 325