revision 555:309c97260912
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 555:309c97260912 |
parent | 554:cecd78cb06bd |
child | 556:72dbf70344db |
author | nkeynes |
date | Tue Jan 01 04:32:01 2008 +0000 (16 years ago) |
branch | lxdream-mmu |
Add initial TLB tests
test/Makefile.in | view | annotate | diff | log | ||
test/sh4/inc.s | view | annotate | diff | log | ||
test/sh4/testsh4.c | view | annotate | diff | log | ||
test/sh4/tlb.s | view | annotate | diff | log |
1.1 --- a/test/Makefile.in Tue Jan 01 02:47:20 2008 +00001.2 +++ b/test/Makefile.in Tue Jan 01 04:32:01 2008 +00001.3 @@ -78,7 +78,7 @@1.4 sh4/mac.s \1.5 sh4/rot.so sh4/shl.so sh4/shld.so sh4/sub.so sh4/subc.so \1.6 sh4/trapa.so sh4/tas.so sh4/xtrct.so \1.7 - sh4/excslot.so sh4/undef.so1.8 + sh4/excslot.so sh4/undef.so sh4/tlb.so1.9 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)1.10 $(SH4OBJCOPY) testsh4 testsh4.bin
2.1 --- a/test/sh4/inc.s Tue Jan 01 02:47:20 2008 +00002.2 +++ b/test/sh4/inc.s Tue Jan 01 04:32:01 2008 +00002.3 @@ -240,6 +240,24 @@2.4 L3:2.5 .endm2.7 +.macro assert_tlb_exc_caught testname, expectpc, expectvpn2.8 +LOCAL L1, L2, L32.9 + mov.l L1, r32.10 + mov.l \testname, r42.11 + mov r12, r52.12 + mov.l L2, r62.13 + mov.l \expectvpn, r72.14 + jsr @r32.15 + nop2.16 + add r0, r132.17 + bra L32.18 + nop2.19 +.align 42.20 +L1: .long _assert_exception_caught2.21 +L2: .long \expectpc2.22 +L3:2.23 +.endm2.24 +2.25 .align 22.26 assert_t_set_message:2.27 .string "Expected T=1 but was 0"
3.1 --- a/test/sh4/testsh4.c Tue Jan 01 02:47:20 2008 +00003.2 +++ b/test/sh4/testsh4.c Tue Jan 01 04:32:01 2008 +00003.3 @@ -1,4 +1,5 @@3.4 #include <stdio.h>3.5 +#include "../lib.h"3.7 int total_tests = 0;3.8 int total_fails = 0;3.9 @@ -42,6 +43,29 @@3.10 }3.11 }3.13 +int assert_tlb_exception_caught( char *testname, int number, unsigned int expectedpc,3.14 + unsigned int vpn )3.15 +{3.16 + if( assert_exception_caught(testname, number, expectedpc) == 1 ) {3.17 + return 1;3.18 + }3.19 +3.20 + unsigned int pteh = long_read(0xFF000000);3.21 + if( (pteh & 0xFFFFFC00) != (vpn & 0xFFFFFC00) ) {3.22 + fprintf(stderr, "%s: Test %d failed: Expected PTEH.VPN = %08X, but was %08X\n",3.23 + testname, number, (vpn>>10), (pteh>>10) );3.24 + return 1;3.25 + }3.26 +3.27 + unsigned int tea = long_read(0xFF00000C);3.28 + if( tea != vpn ) {3.29 + fprintf(stderr, "%s: Test %d failed: Expected TEA = %08X, but was %08X\n",3.30 + testname, number, vpn, tea );3.31 + return 1;3.32 + }3.33 + return 0;3.34 +}3.35 +3.36 int main()3.37 {3.38 fprintf( stdout, "Instruction tests...\n" );3.39 @@ -77,6 +101,7 @@3.40 fprintf( stdout, "Exception tests...\n" );3.41 test_slot_illegal();3.42 test_undefined();3.43 + test_tlb();3.44 remove_interrupt_handler();3.46 fprintf( stdout, "Total: %d/%d tests passed (%d%%)\n", total_tests-total_fails,
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00004.2 +++ b/test/sh4/tlb.s Tue Jan 01 04:32:01 2008 +00004.3 @@ -0,0 +1,165 @@4.4 +.section .text4.5 +.include "sh4/inc.s"4.6 +!4.7 +! Test for correct UTLB operation.4.8 +!4.9 +! Note we don't test triggering a TLB multiple-hit exception - it's a reset4.10 +! rather than a regular exception.4.11 +4.12 +.global _test_tlb4.13 +_test_tlb:4.14 + start_test4.15 +4.16 +! Turn on AT, and flush the current TLB (if any)4.17 +! Initialize to SV=0, SQMD=0, URB=URC=LRUI=04.18 + mov.l test_tlb_mmucr, r04.19 + mov #5, r14.20 + mov.l r1, @r04.21 +4.22 +! Privileged mode tests first (much easier)4.23 + add #1, r124.24 + mov.l test_tlb1_pteh, r14.25 + mov.l test_tlb_pteh, r24.26 + mov.l r1, @r24.27 + mov.l test_tlb1_ptel, r14.28 + mov.l test_tlb_ptel, r24.29 + mov.l r1, @r24.30 + ldtlb4.31 +4.32 +! Simple read4.33 + mov.l test_tlb1_direct, r34.34 + mov #42, r24.35 + mov.l r2, @r34.36 + mov.l test_tlb1_mmu, r04.37 + mov.l @r0, r14.38 + cmp/eq r1, r24.39 + bt test_tlb_24.40 + fail test_tlb_str_k4.41 + bra test_tlb_24.42 + nop4.43 +test_tlb1_pteh:4.44 + .long 0x123450124.45 +test_tlb1_ptel:4.46 + .long 0x005F81204.47 +4.48 +test_tlb_2:4.49 + ! Trigger an initial-page-write exception4.50 + add #1, r124.51 + expect_exc 0x000000804.52 + mov.l test_tlb1_mmu, r04.53 +test_tlb2_exc:4.54 + mov.l r0, @r04.55 + assert_tlb_exc_caught test_tlb_str_k test_tlb2_exc test_tlb1_mmu4.56 +4.57 +test_tlb_3:4.58 + ! Trigger a missing page read exception by invalidation4.59 + add #1, r124.60 + mov.l test_tlb3_addr, r14.61 + mov.l test_tlb3_data, r24.62 + mov.l r2, @r14.63 +4.64 + expect_exc 0x000000404.65 + mov.l test_tlb1_mmu, r04.66 +test_tlb3_exc:4.67 + mov.l @r0, r24.68 + assert_tlb_exc_caught test_tlb_str_k, test_tlb3_exc, test_tlb1_mmu4.69 + bra test_tlb_44.70 + nop4.71 +4.72 +test_tlb3_addr:4.73 + .long 0xF6000F804.74 +test_tlb3_data:4.75 + .long 0x123452124.76 +4.77 +test_tlb_4:4.78 + ! Test missing page write exception on the same page4.79 + add #1, r124.80 + expect_exc 0x000000604.81 + mov.l test_tlb1_mmu, r04.82 +test_tlb4_exc:4.83 + mov.l r2, @r04.84 + assert_tlb_exc_caught test_tlb_str_k, test_tlb4_exc, test_tlb1_mmu4.85 +4.86 +test_tlb_5: ! Test initial write exception4.87 + add #1, r124.88 +4.89 + mov.l test_tlb5_addr, r14.90 + mov.l test_tlb5_data, r24.91 + mov.l r2, @r14.92 +4.93 + expect_exc 0x000000804.94 + mov.l test_tlb1_mmu, r04.95 + mov #63, r34.96 +test_tlb5_exc:4.97 + mov.l r3, @r04.98 + assert_tlb_exc_caught test_tlb_str_k, test_tlb5_exc, test_tlb1_mmu4.99 + mov.l test_tlb1_direct, r34.100 + mov.l @r3, r44.101 + mov #42, r24.102 + cmp/eq r2, r44.103 + bf test_tlb5_fail4.104 + mov.l test_tlb1_mmu, r04.105 + mov.l @r0, r34.106 + cmp/eq r2, r34.107 + bt test_tlb_64.108 +test_tlb5_fail:4.109 + fail test_tlb_str_k4.110 +4.111 +test_tlb5_addr:4.112 + .long 0xF6000F804.113 +test_tlb5_data:4.114 + .long 0x123451124.115 +4.116 +test_tlb_6:! Test successful write.4.117 + add #1, r124.118 +4.119 + mov.l test_tlb6_addr, r14.120 + mov.l test_tlb6_data, r24.121 + mov.l r2, @r14.122 +4.123 + mov.l test_tlb1_mmu, r04.124 + mov #77, r34.125 + mov.l r3, @r04.126 + mov.l test_tlb1_direct, r14.127 + mov.l @r1, r24.128 + cmp/eq r2, r34.129 + bt test_tlb_74.130 + fail test_tlb_str_k4.131 + bra test_tlb_74.132 + nop4.133 +4.134 +test_tlb_7:4.135 + bra test_tlb_end4.136 + nop4.137 +4.138 +test_tlb6_addr:4.139 + .long 0xF6000F804.140 +test_tlb6_data:4.141 + .long 0x123453124.142 +4.143 +4.144 +test_tlb1_mmu:4.145 + .long 0x123450404.146 +test_tlb1_direct:4.147 + .long 0xA05F8040 ! Display border colour4.148 +4.149 +test_tlb_end:4.150 + xor r0, r04.151 + mov.l test_tlb_mmucr, r14.152 + mov.l r0, @r14.153 +4.154 + end_test test_tlb_str_k4.155 +4.156 +test_tlb_mmucr:4.157 + .long 0xFF0000104.158 +test_tlb_pteh:4.159 + .long 0xFF0000004.160 +test_tlb_ptel:4.161 + .long 0xFF0000044.162 +test_tlb_tea:4.163 + .long 0xFF00000C4.164 +test_tlb_str:4.165 + .string "TLB"4.166 +.align 44.167 +test_tlb_str_k:4.168 + .long test_tlb_str
.