revision 233:f8333b94f503
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 233:f8333b94f503 |
parent | 232:9c8ef78376ed |
child | 234:8759d0067e9d |
author | nkeynes |
date | Wed Sep 27 10:21:34 2006 +0000 (17 years ago) |
Add user mode/system mode switch
Add undefined instruction tests
Add undefined instruction tests
test/Makefile | view | annotate | diff | log | ||
test/interrupt.s | view | annotate | diff | log | ||
test/sh4/excslot.s | view | annotate | diff | log | ||
test/sh4/inc.s | view | annotate | diff | log | ||
test/sh4/testsh4.c | view | annotate | diff | log | ||
test/sh4/undef.s | view | annotate | diff | log |
1.1 --- a/test/Makefile Tue Sep 26 11:09:13 2006 +00001.2 +++ b/test/Makefile Wed Sep 27 10:21:34 2006 +00001.3 @@ -74,7 +74,7 @@1.4 testsh4: crt0.so sh4/testsh4.so timer.so interrupt.so \1.5 sh4/add.so sh4/addc.so sh4/addv.so sh4/and.so sh4/andi.so \1.6 sh4/bf.so sh4/bt.so sh4/cmp.so \1.7 - sh4/excslot.so1.8 + sh4/excslot.so sh4/undef.so1.9 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)1.10 $(SH4OBJCOPY) testsh4 testsh4.bin
2.1 --- a/test/interrupt.s Tue Sep 26 11:09:13 2006 +00002.2 +++ b/test/interrupt.s Wed Sep 27 10:21:34 2006 +00002.3 @@ -177,6 +177,26 @@2.4 nop2.6 ex_dontcare: ! Not the event we were waiting for.2.7 +! Check if its a trapa #42 ("Switch to system mode")2.8 + mov.l trapa_exc_k, r02.9 + cmp/eq r0,r12.10 + bf ex_chain2.11 + mov.l trapa_k, r02.12 + mov.l @r0, r02.13 + shlr2 r02.14 + cmp/eq #42, r02.15 + bf ex_chain2.16 +! Yes, yes it is - update SSR and return without chaining2.17 + stc ssr, r02.18 + mov #0x40, r12.19 + mov #24, r22.20 + shld r2, r12.21 + or r0, r12.22 + ldc r1, ssr2.23 + bra ex_nochain2.24 + nop2.25 +2.26 +ex_chain:2.27 mov.l old_vbr_k, r22.28 mov.l @r2, r22.29 xor r0, r02.30 @@ -213,9 +233,9 @@2.31 mov.l @r15+, r22.32 mov.l @r15+, r12.33 mov.l @r15+, r02.34 + stc sgr, r152.35 rte2.36 - stc sgr, r152.37 -2.38 + nop2.39 .align 42.40 expected_intevt_k:2.41 .long expected_intevt
3.1 --- a/test/sh4/excslot.s Tue Sep 26 11:09:13 2006 +00003.2 +++ b/test/sh4/excslot.s Wed Sep 27 10:21:34 2006 +00003.3 @@ -31,10 +31,6 @@3.4 bsr test_slot_fail3.5 jsr @r33.6 assert_exc_caught test_slot_str_k1 test_slot_2_pc3.7 - bra test_slot_33.8 - nop3.9 -test_slot_str_k1:3.10 - .long test_slot_str3.12 test_slot_3: ! BRA3.13 add #1, r123.14 @@ -42,7 +38,7 @@3.15 test_slot_3_pc:3.16 bsr test_slot_fail3.17 bra test_slot_fail3.18 - assert_exc_caught test_slot_str_k test_slot_3_pc3.19 + assert_exc_caught test_slot_str_k1 test_slot_3_pc3.21 test_slot_4: ! BRAF3.22 add #1, r123.23 @@ -103,7 +99,12 @@3.24 bt/s test_slot_10_fail3.25 test_slot_10_fail:3.26 assert_exc_caught test_slot_str_k test_slot_10_pc3.27 + bra test_slot_113.28 + nop3.29 +test_slot_str_k1:3.30 + .long test_slot_str3.32 +3.33 test_slot_11: ! TRAPA3.34 add #1, r123.35 expect_exc 0x000001A03.36 @@ -171,8 +172,19 @@3.37 !3.38 ! Ok now the privilege tests. These should raise SLOT_ILLEGAL when executed3.39 ! in a delay slot (otherwise it's GENERAL_ILLEGAL)3.40 -! TODO: need mode-switch code3.41 +3.42 +test_slot_18: ! LDC Rn, SPC in user mode3.43 + add #1, r123.44 + expect_exc 0x000001A03.45 + stc spc, r43.46 + usermode3.47 +test_slot_18_pc:3.48 + bsr test_slot_fail3.49 + ldc r4, spc3.50 + systemmode3.51 + assert_exc_caught test_slot_str_k test_slot_18_pc3.53 +3.54 test_slot_end:3.55 end_test test_slot_str_k
4.1 --- a/test/sh4/inc.s Tue Sep 26 11:09:13 2006 +00004.2 +++ b/test/sh4/inc.s Wed Sep 27 10:21:34 2006 +00004.3 @@ -140,6 +140,25 @@4.4 addc r0, r04.5 .endm4.7 +! Switch to user-mode4.8 +.macro usermode4.9 + stc sr, r04.10 + mov #64, r14.11 + mov #24, r24.12 + shld r2, r14.13 + not r1, r14.14 + and r0, r14.15 + ldc r1, sr4.16 +.endm4.17 +4.18 +! Switch to system-mode4.19 +! NB: implemented as a trap to the interrupt handler, as obviously4.20 +! we can't just update SR...4.21 +.macro systemmode4.22 + trapa #424.23 + nop4.24 +.endm4.25 +4.26 .macro clearbl4.27 LOCAL L14.28 LOCAL L2
5.1 --- a/test/sh4/testsh4.c Tue Sep 26 11:09:13 2006 +00005.2 +++ b/test/sh4/testsh4.c Wed Sep 27 10:21:34 2006 +00005.3 @@ -60,6 +60,7 @@5.5 fprintf( stdout, "Exception tests...\n" );5.6 test_slot_illegal();5.7 + test_undefined();5.8 remove_interrupt_handler();5.10 fprintf( stdout, "Total: %d/%d tests passed (%d%%)\n", total_tests-total_fails,
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00006.2 +++ b/test/sh4/undef.s Wed Sep 27 10:21:34 2006 +00006.3 @@ -0,0 +1,57 @@6.4 +.section .text6.5 +.include "sh4/inc.s"6.6 +!6.7 +! Test for undefined/unknown instructions. The only "official"6.8 +! undefined instruction is 0xFFFD, but this tests everything6.9 +! that doesn't match a known instruction pattern. Undefined6.10 +! instructions are expected to raise general-illegal when not6.11 +! in a delay slot, and slot-illegal when in a delay slot.6.12 +6.13 +.global _test_undefined6.14 +_test_undefined:6.15 + start_test6.16 +6.17 +test_undef_1: ! First the official one6.18 + add #1, r126.19 + expect_exc 0x000001806.20 +test_undef_1_pc:6.21 + .word 0xFFFD6.22 + assert_exc_caught test_undef_str_k test_undef_1_pc6.23 +6.24 +! Gaps in the STC range (0x0nn2)6.25 +test_undef_2: ! 0x526.26 + add #1, r126.27 + expect_exc 0x000001806.28 +test_undef_2_pc:6.29 + .word 0x00526.30 + assert_exc_caught test_undef_str_k test_undef_2_pc6.31 +6.32 +test_undef_3: ! 0x626.33 + add #1, r126.34 + expect_exc 0x000001806.35 +test_undef_3_pc:6.36 + .word 0x00626.37 + assert_exc_caught test_undef_str_k test_undef_3_pc6.38 +6.39 +test_undef_4: ! 0x726.40 + add #1, r126.41 + expect_exc 0x000001806.42 +test_undef_4_pc:6.43 + .word 0x00726.44 + assert_exc_caught test_undef_str_k test_undef_4_pc6.45 +6.46 +! Test undefined FP instructions w/ and w/o FP disable6.47 +test_undef_fpu_1:6.48 + add #1, r126.49 + expect_exc 0x000001806.50 +test_undef_fpu_1_pc:6.51 + .word 0xF0CD6.52 + assert_exc_caught test_undef_str_k test_undef_fpu_1_pc6.53 +6.54 +test_undef_end:6.55 + end_test test_undef_str_k6.56 +6.57 +test_undef_str_k:6.58 + .long test_undef_str6.59 +test_undef_str:6.60 + .string "UNDEFINED-INSTRUCTION"
.