1 //Original:/proj/frio/dv/testcases/core/c_mmr_loop/c_mmr_loop.dsp 2 // Spec Reference: mmr loop (interr control) no exception 3 # mach: bfin 4 # sim: --environment operating 5 6 #include "test.h" 7 .include "testutils.inc" 8 start 9 10 include(gen_int.inc) 11 include(selfcheck.inc) 12 include(std.inc) 13 include(mmrs.inc) 14 15 #ifndef STACKSIZE 16 #define STACKSIZE 0x10 17 #endif 18 // 19 20 ////MY_GEN_INT_INIT(0xF0000000) // set location for interrupt table 21 22 // 23 // Reset/Bootstrap Code 24 // (Here we set the processor operating modes, initialize registers 25 // etc.) 26 // 27 28 BOOT: 29 30 INIT_R_REGS(0); 31 INIT_P_REGS(0); 32 INIT_I_REGS(0); // initialize the dsp address regs 33 INIT_M_REGS(0); 34 INIT_L_REGS(0); 35 INIT_B_REGS(0); 36 //CHECK_INIT(p5, 0xe0000000); 37 include(symtable.inc) 38 CHECK_INIT_DEF(p5); 39 40 CLI R1; // inhibit events during MMR writes 41 42 LD32_LABEL(sp, USTACK); // setup the user stack pointer 43 USP = SP; // and frame pointer 44 45 LD32_LABEL(sp, KSTACK); // setup the stack pointer 46 FP = SP; // and frame pointer 47 48 LD32(p0, EVT0); // Setup Event Vectors and Handlers 49 LD32_LABEL(r0, EHANDLE); // Emulation Handler (Int0) 50 [ P0 ++ ] = R0; 51 52 LD32_LABEL(r0, RHANDLE); // Reset Handler (Int1) 53 [ P0 ++ ] = R0; 54 55 LD32_LABEL(r0, NHANDLE); // NMI Handler (Int2) 56 [ P0 ++ ] = R0; 57 58 LD32_LABEL(r0, XHANDLE); // Exception Handler (Int3) 59 [ P0 ++ ] = R0; 60 61 [ P0 ++ ] = R0; // EVT4 not used global Interr Enable (INT4) 62 63 LD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5) 64 [ P0 ++ ] = R0; 65 66 LD32_LABEL(r0, THANDLE); // Timer Handler (Int6) 67 [ P0 ++ ] = R0; 68 69 LD32_LABEL(r0, I7HANDLE); // IVG7 Handler 70 [ P0 ++ ] = R0; 71 72 LD32_LABEL(r0, I8HANDLE); // IVG8 Handler 73 [ P0 ++ ] = R0; 74 75 LD32_LABEL(r0, I9HANDLE); // IVG9 Handler 76 [ P0 ++ ] = R0; 77 78 LD32_LABEL(r0, I10HANDLE);// IVG10 Handler 79 [ P0 ++ ] = R0; 80 81 LD32_LABEL(r0, I11HANDLE);// IVG11 Handler 82 [ P0 ++ ] = R0; 83 84 LD32_LABEL(r0, I12HANDLE);// IVG12 Handler 85 [ P0 ++ ] = R0; 86 87 LD32_LABEL(r0, I13HANDLE);// IVG13 Handler 88 [ P0 ++ ] = R0; 89 90 LD32_LABEL(r0, I14HANDLE);// IVG14 Handler 91 [ P0 ++ ] = R0; 92 93 LD32_LABEL(r0, I15HANDLE);// IVG15 Handler 94 [ P0 ++ ] = R0; 95 96 LD32(p0, EVT_OVERRIDE); 97 R0 = 0; 98 [ P0 ++ ] = R0; 99 100 R1 = -1; // Change this to mask interrupts (*) 101 CSYNC; // wait for MMR writes to finish 102 STI R1; // sync and reenable events (implicit write to IMASK) 103 104 DUMMY: 105 106 R0 = 0 (Z); 107 108 LT0 = r0; // set loop counters to something deterministic 109 LB0 = r0; 110 LC0 = r0; 111 LT1 = r0; 112 LB1 = r0; 113 LC1 = r0; 114 115 ASTAT = r0; // reset other internal regs 116 SYSCFG = r0; 117 RETS = r0; // prevent X's breaking LINK instruction 118 119 // The following code sets up the test for running in USER mode 120 121 LD32_LABEL(r0, STARTUSER);// One gets to user mode by doing a 122 // ReturnFromInterrupt (RTI) 123 RETI = r0; // We need to load the return address 124 125 // Comment the following line for a USER Mode test 126 127 JUMP STARTSUP; // jump to code start for SUPERVISOR mode 128 129 RTI; 130 131 STARTSUP: 132 LD32_LABEL(p1, BEGIN); 133 134 LD32(p0, EVT15); 135 136 CLI R1; // inhibit events during write to MMR 137 [ P0 ] = P1; // IVG15 (General) handler (Int 15) load with start 138 CSYNC; // wait for it 139 STI R1; // reenable events with proper imask 140 141 RAISE 15; // after we RTI, INT 15 should be taken 142 143 RTI; 144 145 // 146 // The Main Program 147 // 148 STARTUSER: 149 LINK 0; // change for how much stack frame space you need. 150 151 JUMP BEGIN; 152 153 154 155 //********************************************************************* 156 157 BEGIN: 158 159 // COMMENT the following line for USER MODE tests 160 [ -- SP ] = RETI; // enable interrupts in supervisor mode 161 162 // **** YOUR CODE GOES HERE **** 163 // EVTx 164 // wrt-rd EVT0: 0 bits, rw=0 = 0xFFE02000 165 LD32(p0, 0xFFE02000); 166 LD32(r0, 0x00000000); 167 [ P0 ] = R0; 168 169 // wrt-rd EVT1: 32 bits, rw=0 = 0xFFE02004 170 LD32(p0, 0xFFE02004); 171 LD32(r0, 0x00000000); 172 [ P0 ] = R0; 173 174 // wrt-rd EVT2 = 0xFFE02008 175 LD32(p0, 0xFFE02008); 176 LD32(r0, 0xE1DE5D1C); 177 [ P0 ] = R0; 178 179 // wrt-rd EVT3 = 0xFFE0200C 180 LD32(p0, 0xFFE0200C); 181 LD32(r0, 0x9CC20332); 182 [ P0 ] = R0; 183 184 // wrt-rd EVT4 = 0xFFE02010 185 LD32(p0, 0xFFE02010); 186 LD32(r0, 0x00000000); // not implemented 187 [ P0 ] = R0; 188 189 // wrt-rd EVT5 = 0xFFE02014 190 LD32(p0, 0xFFE02014); 191 LD32(r0, 0x55552345); 192 [ P0 ] = R0; 193 194 // wrt-rd EVT6 = 0xFFE02018 195 LD32(p0, 0xFFE02018); 196 LD32(r0, 0x66663456); 197 [ P0 ] = R0; 198 199 // wrt-rd EVT7 = 0xFFE0201C 200 LD32(p0, 0xFFE0201C); 201 LD32(r0, 0x77774567); 202 [ P0 ] = R0; 203 204 // wrt-rd EVT8 = 0xFFE02020 205 LD32(p0, 0xFFE02020); 206 LD32(r0, 0x88885678); 207 [ P0 ] = R0; 208 209 // wrt-rd EVT9 = 0xFFE02024 210 LD32(p0, 0xFFE02024); 211 LD32(r0, 0x99996789); 212 [ P0 ] = R0; 213 214 // wrt-rd EVT10 = 0xFFE02028 215 LD32(p0, 0xFFE02028); 216 LD32(r0, 0xaaaa1234); 217 [ P0 ] = R0; 218 219 // wrt-rd EVT11 = 0xFFE0202C 220 LD32(p0, 0xFFE0202C); 221 LD32(r0, 0xBBBBABC6); 222 [ P0 ] = R0; 223 224 // wrt-rd EVT12 = 0xFFE02030 225 LD32(p0, 0xFFE02030); 226 LD32(r0, 0xCCCCABC6); 227 [ P0 ] = R0; 228 229 // wrt-rd EVT13 = 0xFFE02034 230 LD32(p0, 0xFFE02034); 231 LD32(r0, 0xDDDDABC6); 232 [ P0 ] = R0; 233 234 // wrt-rd EVT14 = 0xFFE02038 235 LD32(p0, 0xFFE02038); 236 LD32(r0, 0xEEEEABC6); 237 [ P0 ] = R0; 238 239 // wrt-rd EVT15 = 0xFFE0203C 240 LD32(p0, 0xFFE0203C); 241 LD32(r0, 0xFFFFABC6); 242 [ P0 ] = R0; 243 244 // wrt-rd EVT_OVERRIDE:9 bits = 0xFFE02100 245 LD32(p0, 0xFFE02100); 246 LD32(r0, 0x000001ff); 247 [ P0 ] = R0; 248 249 // wrt-rd IMASK: 16 bits = 0xFFE02104 250 LD32(p0, 0xFFE02104); 251 LD32(r0, 0x00000fe0); 252 [ P0 ] = R0; 253 254 255 // wrt-rd IPEND: 16 bits, rw=0 = 0xFFE02108 256 LD32(p0, 0xFFE02108); 257 LD32(r0, 0x00000000); 258 //[p0] = r0; 259 RAISE 12; 260 RAISE 13; 261 262 // wrt-rd ILAT: 16 bits, rw=0 = 0xFFE0210C 263 LD32(p0, 0xFFE0210C); 264 LD32(r0, 0x00000000); 265 //[p0] = r0; 266 CSYNC; 267 //*** read ops 268 P1.L = DATA0; 269 P1.H = DATA0; 270 271 LD32(p0, 0xFFE02000); 272 P2 = 16; 273 LSETUP ( start1 , end1 ) LC0 = P2; 274 start1: 275 R0 = [ P0 ++ ]; 276 end1: [ P1 ++ ] = R0; 277 //nop; 278 P1.L = DATA0; 279 P1.H = DATA0; 280 R0 = [ P1 ++ ]; 281 R1 = [ P1 ++ ]; 282 R2 = [ P1 ++ ]; 283 R3 = [ P1 ++ ]; 284 R4 = [ P1 ++ ]; 285 R5 = [ P1 ++ ]; 286 R6 = [ P1 ++ ]; 287 R7 = [ P1 ++ ]; 288 CHECKREG(r0, 0x00000000); 289 CHECKREG(r1, 0x00000000); 290 CHECKREG(r2, 0xE1DE5D1C); 291 CHECKREG(r3, 0x9CC20332); 292 CHECKREG(r4, 0x00000000); 293 CHECKREG(r5, 0x55552345); 294 CHECKREG(r6, 0x66663456); 295 CHECKREG(r7, 0x77774567); 296 R0 = [ P1 ++ ]; 297 R1 = [ P1 ++ ]; 298 R2 = [ P1 ++ ]; 299 R3 = [ P1 ++ ]; 300 R4 = [ P1 ++ ]; 301 R5 = [ P1 ++ ]; 302 R6 = [ P1 ++ ]; 303 R7 = [ P1 ++ ]; 304 CHECKREG(r0, 0x88885678); 305 CHECKREG(r1, 0x99996789); 306 CHECKREG(r2, 0xAAAA1234); 307 CHECKREG(r3, 0xBBBBABC6); 308 CHECKREG(r4, 0xCCCCABC6); 309 CHECKREG(r5, 0xDDDDABC6); 310 CHECKREG(r6, 0xEEEEABC6); 311 CHECKREG(r7, 0xFFFFABC6); 312 313 dbg_pass; // End the test 314 315 //********************************************************************* 316 317 // 318 // Handlers for Events 319 // 320 321 EHANDLE: // Emulation Handler 0 322 RTE; 323 324 RHANDLE: // Reset Handler 1 325 RTI; 326 327 NHANDLE: // NMI Handler 2 328 R0 = 2; 329 RTN; 330 331 XHANDLE: // Exception Handler 3 332 R7 = 0x00006789 (X); 333 RTX; 334 335 HWHANDLE: // HW Error Handler 5 336 R2 = 5; 337 RTI; 338 339 THANDLE: // Timer Handler 6 340 R3 = 6; 341 RTI; 342 343 I7HANDLE: // IVG 7 Handler 344 R4 = 7; 345 RTI; 346 347 I8HANDLE: // IVG 8 Handler 348 R5 = 8; 349 RTI; 350 351 I9HANDLE: // IVG 9 Handler 352 R6 = 9; 353 RTI; 354 355 I10HANDLE: // IVG 10 Handler 356 R7 = 10; 357 RTI; 358 359 I11HANDLE: // IVG 11 Handler 360 R0 = 11; 361 RTI; 362 363 I12HANDLE: // IVG 12 Handler 364 R1 = 12; 365 RTI; 366 367 I13HANDLE: // IVG 13 Handler 368 R2 = 13; 369 RTI; 370 371 I14HANDLE: // IVG 14 Handler 372 R3 = 14; 373 RTI; 374 375 I15HANDLE: // IVG 15 Handler 376 R4 = 15; 377 RTI; 378 379 NOP;NOP;NOP;NOP;NOP;NOP;NOP; // needed for icache bug 380 381 // 382 // Data Segment 383 // 384 385 .section MEM_DATA_ADDR_1,"aw" 386 DATA0: 387 .dd 0x000a0000 388 .dd 0x000b0001 389 .dd 0x000c0002 390 .dd 0x000d0003 391 .dd 0x000e0004 392 .dd 0x000f0005 393 .dd 0x00100006 394 .dd 0x00200007 395 .dd 0x00300008 396 .dd 0x00400009 397 .dd 0x0050000a 398 .dd 0x0060000b 399 .dd 0x0070000c 400 .dd 0x0080000d 401 .dd 0x0090000e 402 .dd 0x0100000f 403 .dd 0x02000010 404 .dd 0x03000011 405 .dd 0x04000012 406 .dd 0x05000013 407 .dd 0x06000014 408 .dd 0x001a0000 409 .dd 0x001b0001 410 .dd 0x001c0002 411 // Stack Segments (Both Kernel and User) 412 413 .space (STACKSIZE); 414 KSTACK: 415 416 .space (STACKSIZE); 417 USTACK: 418