Search
lxdream.org :: lxdream :: r976:e57a25d9eb7d
lxdream 0.9.1
released Jun 29
Download Now
changeset976:e57a25d9eb7d
parent975:007bf7eb944f
child977:8514fb4bc101
authornkeynes
dateMon Jan 26 12:32:23 2009 +0000 (15 years ago)
Add some initial TLB test cases
test/Makefile.in
test/lib.h
test/lib/crt0.s
test/sh4/ldc.s
test/sh4/mmummio.c
test/sh4/testmmu.c
test/sh4/testsh4.c
test/sh4/testutlb.s
test/sh4/tlb.s
test/sh4/utlb.c
test/sh4/utlb.h
1.1 --- a/test/Makefile.in Mon Jan 26 07:26:24 2009 +0000
1.2 +++ b/test/Makefile.in Mon Jan 26 12:32:23 2009 +0000
1.3 @@ -75,7 +75,7 @@
1.4 # $(RUNTEST) testide -d ../disc/test.nrg
1.5
1.6
1.7 -build-tests: testsh4 testmath testide testta testregs testrend testdisp testspu testmmu
1.8 +build-tests: testsh4 testmmu testmath testide testta testregs testrend testdisp testspu testmmu
1.9
1.10 lib/crt0.so: lib/crt0.s
1.11 $(mkdir_p) lib
1.12 @@ -97,14 +97,15 @@
1.13 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.14 $(SH4OBJCOPY) testsh4 testsh4.bin
1.15
1.16 +testmmu: lib/crt0.so sh4/testmmu.so sh4/utlb.so sh4/testutlb.so sh4/mmummio.so
1.17 + $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.18 + $(SH4OBJCOPY) testmmu testmmu.bin
1.19 +
1.20 +
1.21 testide: lib/crt0.so $(SHARED_OBJECTS) testide.so ide.so
1.22 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.23 $(SH4OBJCOPY) testide testide.bin
1.24
1.25 -testmmu: lib/crt0.so $(SHARED_OBJECTS) testmmu.so
1.26 - $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.27 - $(SH4OBJCOPY) testmmu testmmu.bin
1.28 -
1.29 testmath: lib/crt0.so $(SHARED_OBJECTS) testmath.so math.so
1.30 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.31
2.1 --- a/test/lib.h Mon Jan 26 07:26:24 2009 +0000
2.2 +++ b/test/lib.h Mon Jan 26 12:32:23 2009 +0000
2.3 @@ -61,4 +61,23 @@
2.4 #define CHECK_IEQUALS( a, b ) if( a != b ) { fprintf(stderr, "Assertion failed at %s:%d: expected %08X, but was %08X\n", __FILE__, __LINE__, a, b ); return -1; }
2.5 #define DMA_ALIGN(x) ((void *)((((unsigned int)(x))+0x1F)&0xFFFFFFE0))
2.6
2.7 +
2.8 +/* SH4 Exceptions */
2.9 +#define POWERON 0x000 /* reset vector */
2.10 +#define MANRESET 0x020 /* reset vector */
2.11 +#define OTLBMULTIHIT 0x140 /* reset vector */
2.12 +#define RTLBMISS 0x040 /* TLB vector */
2.13 +#define WTLBMISS 0x060 /* TLB vector */
2.14 +#define FIRSTWRITE 0x080
2.15 +#define READPROT 0x0A0
2.16 +#define WRITEPROT 0x0C0
2.17 +#define RADDERR 0x0E0
2.18 +#define WADDERR 0x100
2.19 +#define FPUEXC 0x120
2.20 +#define ILLSLOT 0x1A0
2.21 +#define RESINST 0x180
2.22 +#define TRAP 0x160
2.23 +#define FPUDIS 0x800
2.24 +#define SLOTFPUDIS 0x820
2.25 +
2.26 #endif
3.1 --- a/test/lib/crt0.s Mon Jan 26 07:26:24 2009 +0000
3.2 +++ b/test/lib/crt0.s Mon Jan 26 12:32:23 2009 +0000
3.3 @@ -47,6 +47,9 @@
3.4 lds r3,fpscr
3.5 #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) */
3.6
3.7 + mov.l sr_data, r1
3.8 + ldc r1, sr
3.9 +
3.10 ! call the mainline
3.11 mov.l main_k,r0
3.12 jsr @r0
3.13 @@ -103,6 +106,8 @@
3.14 .long start_2
3.15 p2_mask:
3.16 .long 0xa0000000
3.17 +sr_data:
3.18 + .long 0x400000f0
3.19 ccr_addr:
3.20 .long 0xff00001c
3.21 ccr_data:
4.1 --- a/test/sh4/ldc.s Mon Jan 26 07:26:24 2009 +0000
4.2 +++ b/test/sh4/ldc.s Mon Jan 26 12:32:23 2009 +0000
4.3 @@ -4,17 +4,19 @@
4.4 .global _test_ldc
4.5 _test_ldc:
4.6 start_test
4.7 + mov.l r8, @-r15
4.8 + mov.l r9, @-r15
4.9
4.10 test_ldcsr_1:
4.11 add #1, r12
4.12
4.13 - stc sr, r0
4.14 + stc sr, r8
4.15 mov #-1, r1
4.16 ldc r1, sr
4.17 - stc sr, r2
4.18 - ldc r0, sr
4.19 + stc sr, r9
4.20 + ldc r8, sr
4.21 mov.l sr_mask, r3
4.22 - cmp/eq r2, r3
4.23 + cmp/eq r9, r3
4.24 bt test_ldsfpscr_1
4.25 fail test_ldc_str_k
4.26
4.27 @@ -31,6 +33,8 @@
4.28 fail test_ldc_str_k
4.29
4.30 test_ldc_end:
4.31 + mov.l @r15+, r9
4.32 + mov.l @r15+, r8
4.33 end_test test_ldc_str_k
4.34
4.35 test_ldc_str:
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/test/sh4/mmummio.c Mon Jan 26 12:32:23 2009 +0000
5.3 @@ -0,0 +1,61 @@
5.4 +#include <assert.h>
5.5 +#include <stdio.h>
5.6 +#include "../lib.h"
5.7 +
5.8 +#define PTEH 0xFF000000
5.9 +#define PTEL 0xFF000004
5.10 +#define TTB 0xFF000008
5.11 +#define TEA 0xFF00000C
5.12 +#define MMUCR 0xFF000010
5.13 +#define PTEA 0xFF000034
5.14 +
5.15 +#define ITLB_ADDR(entry) (0xF2000000 + (entry<<8))
5.16 +#define ITLB_DATA(entry) (0xF3000000 + (entry<<8))
5.17 +#define UTLB_ADDR(entry) (0xF6000000 + (entry<<8))
5.18 +#define UTLB_DATA1(entry) (0xF7000000 + (entry<<8))
5.19 +#define UTLB_DATA2(entry) (0xF7800000 + (entry<<8))
5.20 +
5.21 +/* Bang on the mmio side of the TLBs to make sure the bits
5.22 + * respond appropriately (with AT disabled so we don't risk
5.23 + * doing a hard crash) */
5.24 +void test_tlb_mmio()
5.25 +{
5.26 + int entry;
5.27 + for( entry=0; entry<64; entry++ ) {
5.28 + long_write( UTLB_DATA1(entry), 0 );
5.29 + long_write( UTLB_ADDR(entry), 0xFFFFFFFF );
5.30 + assert( long_read( UTLB_ADDR(entry) ) == 0xFFFFFFFF );
5.31 + assert( long_read( UTLB_DATA1(entry) ) == 0x00000104 );
5.32 + long_write( UTLB_ADDR(entry), 0x00000000 );
5.33 + assert( long_read( UTLB_ADDR(entry) ) == 0x00000000 );
5.34 + assert( long_read( UTLB_DATA1(entry) ) == 0x00000000 );
5.35 + long_write( UTLB_DATA1(entry), 0xFFFFFFFF );
5.36 + assert( long_read( UTLB_DATA1(entry) ) == 0x1FFFFDFF );
5.37 + assert( long_read( UTLB_ADDR(entry) ) == 0x00000300 );
5.38 + long_write( UTLB_DATA1(entry), 0x00000000 );
5.39 + assert( long_read( UTLB_DATA1(entry) ) == 0x00000000 );
5.40 + assert( long_read( UTLB_ADDR(entry) ) == 0x00000000 );
5.41 + long_write( UTLB_DATA2(entry), 0xFFFFFFFF );
5.42 + assert( long_read( UTLB_DATA2(entry) ) == 0x0000000F );
5.43 + long_write( UTLB_DATA2(entry), 0x00000000 );
5.44 + assert( long_read( UTLB_DATA2(entry) ) == 0x00000000 );
5.45 + }
5.46 +
5.47 + for( entry=0; entry<4; entry++ ) {
5.48 + long_write( ITLB_DATA(entry), 0 );
5.49 + long_write( ITLB_ADDR(entry), 0xFFFFFFFF );
5.50 + assert( long_read( ITLB_ADDR(entry) ) == 0xFFFFFDFF );
5.51 + assert( long_read( ITLB_DATA(entry) ) == 0x00000100 );
5.52 + long_write( ITLB_ADDR(entry), 0x00000000 );
5.53 + assert( long_read( ITLB_ADDR(entry) ) == 0x00000000 );
5.54 + assert( long_read( ITLB_DATA(entry) ) == 0x00000000 );
5.55 + long_write( ITLB_DATA(entry), 0xFFFFFFFF );
5.56 + assert( long_read( ITLB_DATA(entry) ) == 0x1FFFFDDA );
5.57 + assert( long_read( ITLB_ADDR(entry) ) == 0x00000100 );
5.58 + long_write( ITLB_DATA(entry), 0x00000000 );
5.59 + assert( long_read( ITLB_DATA(entry) ) == 0x00000000 );
5.60 + assert( long_read( ITLB_ADDR(entry) ) == 0x00000000 );
5.61 +
5.62 + }
5.63 +}
5.64 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/test/sh4/testmmu.c Mon Jan 26 12:32:23 2009 +0000
6.3 @@ -0,0 +1,117 @@
6.4 +#include "utlb.h"
6.5 +#include "../lib.h"
6.6 +
6.7 +struct utlb_test_case {
6.8 + const char *name;
6.9 + uint32_t vma;
6.10 + uint32_t pma;
6.11 + int read_exc;
6.12 + int write_exc;
6.13 +};
6.14 +
6.15 +#define OK 0
6.16 +
6.17 +#define MAX_BATCH_ENTRIES 4
6.18 +#define MAX_BATCH_TESTS 8
6.19 +
6.20 +uint32_t dummy;
6.21 +
6.22 +#define LOAD(ent,asid,vpn,ppn,mode) load_utlb_entry( ent, vpn, ppn, asid, mode )
6.23 +#define TEST(name,asid,vma,pma,sr,sw,ur,uw) run_utlb_test_case(name,asid,vma,pma,sr,sw,ur,uw)
6.24 +
6.25 +int run_utlb_priv_test( struct utlb_test_case *test );
6.26 +int run_utlb_user_test( struct utlb_test_case *test );
6.27 +
6.28 +int cases_failed;
6.29 +int cases_run;
6.30 +int tests_failed;
6.31 +int tests_run;
6.32 +int tests_skipped;
6.33 +
6.34 +int run_utlb_test_case( const char *name, int asid, unsigned int vma, unsigned int pma,
6.35 + int sr, int sw, int ur, int uw )
6.36 +{
6.37 + char tmp[64];
6.38 + struct utlb_test_case test = { tmp, vma, pma, sr, sw };
6.39 + int fails = 0;
6.40 +
6.41 + cases_run++;
6.42 +
6.43 + set_asid( asid );
6.44 + if( sr == OTLBMULTIHIT || sw == OTLBMULTIHIT ) {
6.45 + fprintf( stderr, "%s: Skipping system test (multihit)\n", name );
6.46 + tests_skipped += 2;
6.47 + } else {
6.48 + snprintf(tmp,sizeof(tmp), "%s (System)", name );
6.49 + tests_run += 2;
6.50 + fails += run_utlb_priv_test( &test );
6.51 + }
6.52 +
6.53 + if( ur == OTLBMULTIHIT || uw == OTLBMULTIHIT ) {
6.54 + fprintf( stderr, "%s: Skipping user test '%s' (multihit)\n", name );
6.55 + tests_skipped += 2;
6.56 + } else {
6.57 + snprintf(tmp,sizeof(tmp), "%s (User)", name );
6.58 + test.read_exc = ur;
6.59 + test.write_exc = uw;
6.60 + tests_run += 2;
6.61 + fails += run_utlb_user_test( &test );
6.62 + }
6.63 + if( fails != 0 ) {
6.64 + cases_failed++;
6.65 + tests_failed += fails;
6.66 + }
6.67 + return fails;
6.68 +}
6.69 +
6.70 +int main()
6.71 +{
6.72 + /* Non-TLB behaviour tests */
6.73 +
6.74 +
6.75 + /* TLB tests */
6.76 + install_utlb_test_handler();
6.77 + invalidate_tlb();
6.78 + /* Permanently map the first and last MB of RAM into userspace - without
6.79 + * this it's a bit hard to actually run any user-mode tests.
6.80 + */
6.81 + LOAD(62, 0, 0x0C000000, 0x0C000000, TLB_VALID|TLB_USERMODE|TLB_WRITABLE|TLB_SIZE_1M|TLB_CACHEABLE|TLB_DIRTY|TLB_SHARE);
6.82 + LOAD(63, 0, 0x0CF00000, 0x0CF00000, TLB_VALID|TLB_USERMODE|TLB_WRITABLE|TLB_SIZE_1M|TLB_CACHEABLE|TLB_DIRTY|TLB_SHARE);
6.83 + set_tlb_enabled(1);
6.84 +
6.85 + /* Test miss */
6.86 + TEST( "U0", 0, 0x12345008, 0x0c000018, RTLBMISS, WTLBMISS, RTLBMISS, WTLBMISS );
6.87 + TEST( "P1", 0, 0x8c000018, 0x0c000018, OK, OK, RADDERR, WADDERR );
6.88 + TEST( "P1", 0, 0xac000018, 0x0c000018, OK, OK, RADDERR, WADDERR );
6.89 + TEST( "P3", 0, 0xC4345008, 0x0c000018, RTLBMISS, WTLBMISS, RADDERR, WADDERR );
6.90 +
6.91 + /* Test flags with 1K pages */
6.92 + LOAD( 0, 0, 0x12345C00, 0x0C000000, TLB_VALID|TLB_USERMODE|TLB_WRITABLE|TLB_SIZE_1K|TLB_CACHEABLE|TLB_DIRTY );
6.93 + LOAD( 1, 1, 0x12345C00, 0x0CFFFC00, TLB_VALID|TLB_USERMODE|TLB_WRITABLE|TLB_SIZE_1K|TLB_CACHEABLE|TLB_DIRTY );
6.94 + LOAD( 2, 0, 0x12345800, 0x0C000800, TLB_VALID|TLB_WRITABLE|TLB_SIZE_1K|TLB_CACHEABLE|TLB_DIRTY );
6.95 + LOAD( 3, 0, 0x12345400, 0x0C000400, TLB_VALID|TLB_USERMODE|TLB_SIZE_1K|TLB_CACHEABLE|TLB_DIRTY );
6.96 + LOAD( 4, 0, 0x12345000, 0x0C000000, TLB_VALID|TLB_SIZE_1K|TLB_CACHEABLE|TLB_DIRTY );
6.97 + LOAD( 5, 1, 0x12345800, 0x0CF01800, TLB_VALID|TLB_USERMODE|TLB_WRITABLE|TLB_SIZE_1K|TLB_CACHEABLE );
6.98 + LOAD( 6, 1, 0x12346000, 0x0C000000, TLB_VALID|TLB_WRITABLE|TLB_SIZE_1K|TLB_CACHEABLE );
6.99 + LOAD( 7, 2, 0x12346800, 0x0C000400, TLB_VALID|TLB_USERMODE|TLB_WRITABLE|TLB_SIZE_1K|TLB_CACHEABLE|TLB_SHARE|TLB_DIRTY );
6.100 + TEST( "1K ASID 0", 0, 0x12345C18, 0x0C000018, OK, OK, OK, OK );
6.101 + TEST( "1K ASID 1", 1, 0x12345C18, 0x0CFFFC18, OK, OK, OK, OK );
6.102 + TEST( "1K ASID 2", 2, 0x12345C18, 0x0C000018, RTLBMISS, WTLBMISS, RTLBMISS, WTLBMISS );
6.103 + TEST( "1K PRIV", 0, 0x12345818, 0x0C000818, OK, OK, READPROT, WRITEPROT );
6.104 + TEST( "1K READONLY", 0, 0x12345418, 0x0C000418, OK, WRITEPROT, OK, WRITEPROT );
6.105 + TEST( "1K PRIVREAD", 0, 0x12345018, 0x0C000018, OK, WRITEPROT, READPROT, WRITEPROT );
6.106 + TEST( "1K FIRSTWR", 1, 0x12345818, 0x0CF01818, OK, FIRSTWRITE, OK, FIRSTWRITE );
6.107 + TEST( "1K PRIVFWR", 1, 0x12346018, 0x0C000018, OK, FIRSTWRITE, READPROT, WRITEPROT );
6.108 + TEST( "1K MISS", 1, 0x12346418, 0x0C000018, RTLBMISS, WTLBMISS, RTLBMISS, WTLBMISS );
6.109 + TEST( "1K SHARED 0", 0, 0x12346818, 0x0C000418, OK, OK, OK, OK );
6.110 + TEST( "1K SHARED 2", 2, 0x12346818, 0x0C000418, OK, OK, OK, OK );
6.111 +
6.112 +
6.113 + uninstall_utlb_test_handler();
6.114 +
6.115 +
6.116 + printf( "--> %d/%d Test cases passed (%d%%)\n", cases_run-cases_failed, cases_run, ( (cases_run-cases_failed)*100/cases_run) );
6.117 + printf( "--> %d/%d Tests passed (%d%%)\n", tests_run-tests_failed, tests_run, ( (tests_run-tests_failed)*100/tests_run) );
6.118 +
6.119 + return cases_failed == 0 ? 0 : 1;
6.120 +}
7.1 --- a/test/sh4/testsh4.c Mon Jan 26 07:26:24 2009 +0000
7.2 +++ b/test/sh4/testsh4.c Mon Jan 26 12:32:23 2009 +0000
7.3 @@ -14,6 +14,9 @@
7.4
7.5 void test_print_failure( char *testname, int number, char *message )
7.6 {
7.7 + fprintf( stderr, "Fail" );
7.8 + fprintf( stderr, testname );
7.9 +
7.10 if( message == NULL ) {
7.11 fprintf( stderr, "%s: Test %d failed!\n", testname, number );
7.12 } else {
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/test/sh4/testutlb.s Mon Jan 26 12:32:23 2009 +0000
8.3 @@ -0,0 +1,720 @@
8.4 +
8.5 +
8.6 +.global _install_utlb_test_handler
8.7 +_install_utlb_test_handler:
8.8 + mov.l utlb_old_vbr_k, r0
8.9 + stc vbr, r1
8.10 + mov.l r1, @r0
8.11 +
8.12 + mov.l utlb_vbr_k, r0
8.13 + ldc r0, vbr
8.14 + rts
8.15 + nop
8.16 +
8.17 +.global _uninstall_utlb_test_handler
8.18 +_uninstall_utlb_test_handler:
8.19 + mov.l utlb_old_vbr_k, r0
8.20 + mov.l @r0, r0
8.21 + ldc r0, vbr
8.22 + rts
8.23 + nop
8.24 +
8.25 +utlb_exc_handler:
8.26 + mov.l utlb_exc_stack_k, r15
8.27 + mov.l r0, @-r15
8.28 + mov.l r1, @-r15
8.29 + mov.l r2, @-r15
8.30 + sts pr, r0
8.31 + mov.l r0, @-r15
8.32 +
8.33 + mov.l mmu_expevt_k, r2
8.34 + mov.l @r2, r2
8.35 + mov r2, r0
8.36 + shlr2 r0
8.37 + cmp/eq #0x58, r0
8.38 + bt utlb_trap
8.39 +
8.40 + mov.l utlb_exc_k_1, r0
8.41 + mov.l @(16,r0), r1
8.42 + tst r1, r1
8.43 + bt utlb_exc_unexpected
8.44 +
8.45 + mov.l @r0, r1
8.46 + tst r1, r1
8.47 + bf utlb_exc_set
8.48 + mov.l r2, @r0
8.49 + stc spc, r2
8.50 + mov.l r2, @(8,r0)
8.51 +
8.52 +utlb_exc_set:
8.53 + mov.l @(4,r0), r2
8.54 + add #1, r2
8.55 + mov.l r2, @(4,r0)
8.56 +
8.57 + mov.l @(12,r0), r2
8.58 + stc spc, r1
8.59 + add r2, r1
8.60 + ldc r1, spc
8.61 +
8.62 +utlb_exc_done:
8.63 + mov.l @r15+, r0
8.64 + lds r0, pr
8.65 + mov.l @r15+, r2
8.66 + mov.l @r15+, r1
8.67 + mov.l @r15+, r0
8.68 + rte
8.69 + stc sgr, r15
8.70 +
8.71 +utlb_trap:
8.72 + mov.l mmu_tra_k, r2
8.73 + mov.l @r2, r0
8.74 + shlr2 r0
8.75 + cmp/eq #42, r0
8.76 + bt utlb_trap_priv
8.77 + cmp/eq #41, r0
8.78 + bt utlb_trap_printf
8.79 + bra utlb_exc_done
8.80 + nop
8.81 +utlb_trap_priv:
8.82 + stc ssr, r0
8.83 + mov.l mmu_sr_md, r1
8.84 + or r1, r0
8.85 + ldc r0, ssr
8.86 + bra utlb_exc_done
8.87 + nop
8.88 +utlb_trap_printf:
8.89 + stc sr, r0
8.90 + mov.l mmu_sr_rb_mask, r1
8.91 + and r1, r0
8.92 + ldc r0, sr
8.93 + mov.l utlb_printf_k, r0
8.94 + jsr @r0
8.95 + nop
8.96 + bra utlb_exc_done
8.97 + nop
8.98 +utlb_exc_unexpected: /* Report an unexpected exception. Save everything in case printf clobbers it */
8.99 + mov.l r3, @-r15
8.100 + mov.l r4, @-r15
8.101 + mov.l r5, @-r15
8.102 + mov.l r6, @-r15
8.103 + mov.l r7, @-r15
8.104 + mov.l r8, @-r15
8.105 + mov.l r9, @-r15
8.106 + mov.l r10, @-r15
8.107 + mov.l r11, @-r15
8.108 + mov.l r12, @-r15
8.109 + mov.l r13, @-r15
8.110 + mov.l r14, @-r15
8.111 + sts fpscr, r0
8.112 + mov.l r0, @-r15
8.113 +
8.114 + stc spc, r6
8.115 + mov r2, r5
8.116 + mov.l utlb_unexpected_msg_k, r4
8.117 + mov.l utlb_printf_k, r3
8.118 + jsr @r3
8.119 + nop
8.120 +
8.121 + mov.l @r15+, r0
8.122 + lds r0, fpscr
8.123 + mov.l @r15+, r14
8.124 + mov.l @r15+, r13
8.125 + mov.l @r15+, r12
8.126 + mov.l @r15+, r11
8.127 + mov.l @r15+, r10
8.128 + mov.l @r15+, r9
8.129 + mov.l @r15+, r8
8.130 + mov.l @r15+, r7
8.131 + mov.l @r15+, r6
8.132 + mov.l @r15+, r5
8.133 + mov.l @r15+, r4
8.134 + mov.l @r15+, r3
8.135 + mov.l utlb_exc_k_1, r0
8.136 + bra utlb_exc_set
8.137 + nop
8.138 +
8.139 +
8.140 +.align 4
8.141 +utlb_vbr_k:
8.142 + .long utlb_vbr
8.143 +utlb_old_vbr_k:
8.144 + .long utlb_old_vbr
8.145 +utlb_exc_k_1:
8.146 + .long utlb_exc
8.147 +mmu_expevt_k:
8.148 + .long 0xFF000024
8.149 +mmu_tra_k:
8.150 + .long 0xFF000020
8.151 +mmu_sr_md:
8.152 + .long 0x40000000
8.153 +mmu_sr_rb_mask:
8.154 + .long 0x50000000
8.155 +utlb_exc_stack_k:
8.156 + .long utlb_exc_stack
8.157 +utlb_printf_k:
8.158 + .long _printf
8.159 +utlb_unexpected_msg_k:
8.160 + .long utlb_unexpected_msg
8.161 +
8.162 + .skip 0x1F00 /* 8K stack */
8.163 +utlb_vbr:
8.164 + .skip 0x100
8.165 +utlb_exc_stack:
8.166 + mov.l utlb_exc_handler_k1, r15
8.167 + jmp @r15
8.168 + nop
8.169 + nop
8.170 +utlb_exc_handler_k1:
8.171 + .long utlb_exc_handler
8.172 +
8.173 + .skip 0x2F4
8.174 + mov.l utlb_exc_handler_k2, r15
8.175 + jmp @r15
8.176 + nop
8.177 + nop
8.178 +utlb_exc_handler_k2:
8.179 + .long utlb_exc_handler
8.180 + .skip 0x1F4
8.181 + rte
8.182 + stc sgr, r15
8.183 +
8.184 +
8.185 +utlb_expect_exc:
8.186 + mova utlb_exc, r0
8.187 + xor r1, r1
8.188 + mov.l r1, @r0
8.189 + mov.l r1, @(4,r0)
8.190 + mov.l r1, @(8,r0)
8.191 + mov #1, r1
8.192 + mov.l r1, @(16,r0)
8.193 + mov #2, r1
8.194 + mov.l r1, @(12,r0)
8.195 + rts
8.196 + nop
8.197 +
8.198 +utlb_noexpect_exc:
8.199 + mova utlb_exc, r0
8.200 + xor r1, r1
8.201 + mov.l r1, @r0
8.202 + mov.l r1, @(4,r0)
8.203 + mov.l r1, @(8,r0)
8.204 + mov.l r1, @(16,r0)
8.205 + mov #2, r1
8.206 + mov.l r1, @(12,r0)
8.207 + rts
8.208 + nop
8.209 +
8.210 +/* Check the result of a read test. Call with:
8.211 + * r0 = expected spc
8.212 + * r1 = value read (if any)
8.213 + * r9 = (char *) testname
8.214 + * r10 = test VMA
8.215 + * r11 = test PMA
8.216 + * r12 = expected exc
8.217 + *
8.218 + * Trashes r0..r7
8.219 + */
8.220 +utlb_check_read_exc:
8.221 + mov.l utlb_exc_k, r3
8.222 + mov.l addr_mask, r2
8.223 + and r2, r3
8.224 +
8.225 + mov.l @r3, r2
8.226 + cmp/eq r2, r12
8.227 + bf test_read_exc_bad
8.228 + tst r12, r12
8.229 + bt test_read_ok /* Expected no exception, and got none */
8.230 + mov.l @(4,r3), r2
8.231 + dt r2
8.232 + bf test_read_count_bad
8.233 + mov.l @(8,r3), r2
8.234 + cmp/eq r0, r2
8.235 + bt test_read_ok
8.236 +test_read_pc_bad:
8.237 + add #1, r14
8.238 + mov r0, r6
8.239 + mov.l err_read_pc_msg_k, r4
8.240 + mov r2, r7
8.241 + mov r9, r5
8.242 + trapa #41
8.243 + bra test_read_ok
8.244 + nop
8.245 +test_read_count_bad:
8.246 + add #1, r14
8.247 + add #2, r2
8.248 + mov.l err_read_count_msg_k, r4
8.249 + mov r2, r6
8.250 + mov r9, r5
8.251 + trapa #41
8.252 + bra test_read_ok
8.253 + nop
8.254 +test_read_exc_bad:
8.255 + add #1, r14
8.256 + mov.l err_read_exc_msg_k, r4
8.257 + mov r12, r6
8.258 + mov r2, r7
8.259 + mov r9, r5
8.260 + trapa #41
8.261 + bra test_read_ok
8.262 + nop
8.263 +test_read_ok:
8.264 + bra utlb_expect_exc
8.265 + nop
8.266 +
8.267 +/* Check the result of a write test (and clears the exception). Call with:
8.268 + * r0 = expected spc
8.269 + * r1 = written value
8.270 + * r9 = (char *) testname
8.271 + * r10 = test VMA
8.272 + * r11 = test PMA
8.273 + * r13 = expected exc
8.274 + * r14 = fail count (updated)
8.275 + *
8.276 + * Trashes r0..r7
8.277 + */
8.278 +utlb_check_write_exc:
8.279 + mov.l utlb_exc_k, r3
8.280 + mov.l addr_mask, r2
8.281 + and r2, r3
8.282 +
8.283 + mov.l @r3, r2
8.284 + cmp/eq r2, r13
8.285 + bf test_write_exc_bad
8.286 + tst r13, r13
8.287 + bt test_write_ok /* Expected no exception, and got none */
8.288 + mov.l @(4,r3), r2
8.289 + dt r2
8.290 + bf test_write_count_bad
8.291 + mov.l @(8,r3), r2
8.292 + cmp/eq r0, r2
8.293 + bt test_write_ok
8.294 +test_write_pc_bad:
8.295 + add #1, r14
8.296 + mov r0, r6
8.297 + mov.l err_write_pc_msg_k, r4
8.298 + mov r2, r7
8.299 + mov r9, r5
8.300 + trapa #41
8.301 + bra test_write_ok
8.302 + nop
8.303 +test_write_count_bad:
8.304 + add #1, r14
8.305 + add #1, r2
8.306 + mov.l err_write_count_msg_k, r4
8.307 + mov r2, r6
8.308 + mov r9, r5
8.309 + trapa #41
8.310 + bra test_write_ok
8.311 + nop
8.312 +test_write_exc_bad:
8.313 + add #1, r14
8.314 + mov.l err_write_exc_msg_k, r4
8.315 + mov r13, r6
8.316 + mov r2, r7
8.317 + mov r9, r5
8.318 + trapa #41
8.319 + bra test_write_ok
8.320 + nop
8.321 +test_write_ok:
8.322 + bra utlb_expect_exc
8.323 + nop
8.324 +.align 4
8.325 +utlb_exc_k:
8.326 + .long utlb_exc
8.327 +err_read_exc_msg_k:
8.328 + .long err_read_exc_msg
8.329 +err_read_count_msg_k:
8.330 + .long err_read_count_msg
8.331 +err_read_pc_msg_k:
8.332 + .long err_read_pc_msg
8.333 +err_write_exc_msg_k:
8.334 + .long err_write_exc_msg
8.335 +err_write_count_msg_k:
8.336 + .long err_write_count_msg
8.337 +err_write_pc_msg_k:
8.338 + .long err_write_pc_msg
8.339 +
8.340 +.align 4
8.341 +utlb_old_vbr:
8.342 + .long 0
8.343 +utlb_exc:
8.344 + .long 0
8.345 +utlb_exc_count:
8.346 + .long 0
8.347 +utlb_exc_spc:
8.348 + .long 0
8.349 +utlb_rte_offset:
8.350 + .long 2
8.351 +utlb_expected:
8.352 + .long 0
8.353 +
8.354 +.global _run_utlb_priv_test
8.355 +_run_utlb_priv_test:
8.356 + mov.l r14, @-r15
8.357 + sts pr, r0
8.358 + mov.l r0, @-r15
8.359 + mov.l r13, @-r15
8.360 + mov.l r12, @-r15
8.361 + mov.l r11, @-r15
8.362 + mov.l r10, @-r15
8.363 + mov.l r9, @-r15
8.364 + mov.l r8, @-r15
8.365 +
8.366 + mov.l @(0,r4), r9 /* Test name */
8.367 + mov.l @(4,r4), r10 /* Test VMA */
8.368 + mov.l @(8,r4), r11 /* Test PMA */
8.369 + mov.l @(12,r4), r12 /* Read exception */
8.370 + mov.l @(16,r4), r13 /* Write exception */
8.371 + xor r14, r14 /* Fail count */
8.372 +
8.373 + mov.l @r11, r0 /* Save original memory value */
8.374 + ocbp @r11
8.375 + mov.l r0, @-r15
8.376 +
8.377 + tst r12, r12
8.378 + bt utlb_read_test_noexc
8.379 +
8.380 +/* Exception test cases - all should fail with the same exception */
8.381 +utlb_read_test_exc:
8.382 + mov r10, r8
8.383 + bsr utlb_expect_exc
8.384 + nop
8.385 +
8.386 +/* Test mov.l Rm, Rn */
8.387 + mova test_readl_1, r0
8.388 +.align 4
8.389 +test_readl_1:
8.390 + mov.l @r10, r1
8.391 + bsr utlb_check_read_exc
8.392 + nop
8.393 +
8.394 +/* Test mov.l @Rm+, Rn */
8.395 + mova test_readl_2, r0
8.396 +.align 4
8.397 +test_readl_2:
8.398 + mov.l @r8+, r1
8.399 + bsr utlb_check_read_exc
8.400 + nop
8.401 + cmp/eq r8,r10
8.402 + bt test_readl_2_ok
8.403 +
8.404 + add #1, r14
8.405 + mov.l err_readlp_bad_msg_k, r4
8.406 + mov r9, r5
8.407 + trapa #41
8.408 +
8.409 +test_readl_2_ok:
8.410 +/* Test mov.w @Rm, Rn */
8.411 + mova test_readw_1, r0
8.412 +.align 4
8.413 +test_readw_1:
8.414 + mov.w @r10, r1
8.415 + bsr utlb_check_read_exc
8.416 + nop
8.417 +
8.418 +/* Test mov.w @Rm+, Rn */
8.419 + mova test_readw_2, r0
8.420 +.align 4
8.421 +test_readw_2:
8.422 + mov.w @r8+, r1
8.423 + bsr utlb_check_read_exc
8.424 + nop
8.425 + cmp/eq r8, r10
8.426 + bt test_readw_2_ok
8.427 +
8.428 + add #1, r14
8.429 + mov.l err_readwp_bad_msg_k, r4
8.430 + mov r9, r5
8.431 + trapa #41
8.432 +
8.433 +test_readw_2_ok:
8.434 +
8.435 +/* Test mov.b @Rm, Rn */
8.436 + mova test_readb_1, r0
8.437 +.align 4
8.438 +test_readb_1:
8.439 + mov.b @r10, r1
8.440 + bsr utlb_check_read_exc
8.441 + nop
8.442 +
8.443 +/* Test mov.b @Rm+, Rn */
8.444 + mova test_readb_2, r0
8.445 +.align 4
8.446 +test_readb_2:
8.447 + mov.b @r8+, r1
8.448 + bsr utlb_check_read_exc
8.449 + nop
8.450 + cmp/eq r8, r10
8.451 + bt test_readb_2_ok
8.452 +
8.453 + add #1, r14
8.454 + mov.l err_readbp_bad_msg_k, r4
8.455 + mov r9, r5
8.456 + trapa #41
8.457 +
8.458 +test_readb_2_ok:
8.459 +
8.460 + bra utlb_read_test_done
8.461 + nop
8.462 +
8.463 +/* Non-exception read tests */
8.464 +utlb_read_test_noexc:
8.465 + mov.l utlb_exc_k_2, r8
8.466 + mov.l addr_mask, r0
8.467 + and r0, r8
8.468 + bsr utlb_noexpect_exc
8.469 + nop
8.470 +
8.471 + mov.l @r10, r1
8.472 + not r1, r2
8.473 + mov.l r2, @r11
8.474 + ocbp @r11
8.475 + ocbi @r10
8.476 + mov.l @r10, r1
8.477 + ocbi @r10
8.478 + cmp/eq r1, r2
8.479 + bt noexc_readl_ok
8.480 +
8.481 +
8.482 + add #1, r14
8.483 + mov.l err_read_mismatch_msg_k, r4
8.484 + mov r9, r5
8.485 + trapa #41
8.486 +
8.487 +noexc_readl_ok:
8.488 +
8.489 + mov.l @(4,r8), r0
8.490 + add r0, r14
8.491 +utlb_read_test_done:
8.492 +
8.493 +/*********************** Begin write tests *****************************/
8.494 + tst r13, r13
8.495 + bt utlb_write_test_noexc
8.496 +
8.497 +/* Exception write tests */
8.498 +utlb_write_test_exc:
8.499 + bsr utlb_expect_exc
8.500 + nop
8.501 +
8.502 + mova test_writel_pc, r0
8.503 +.align 4
8.504 +test_writel_pc:
8.505 + mov.l r1, @r10
8.506 + bsr utlb_check_write_exc
8.507 + nop
8.508 +
8.509 + mova test_writelp_pc, r0
8.510 + mov r10, r8
8.511 +.align 4
8.512 +test_writelp_pc:
8.513 + mov.l r1, @-r8
8.514 + bsr utlb_check_write_exc
8.515 + nop
8.516 + cmp/eq r8, r10
8.517 + bt test_writelp_ok
8.518 + add #1, r14
8.519 + mov.l err_writelp_bad_msg_k, r4
8.520 + mov r9, r5
8.521 + trapa #41
8.522 +test_writelp_ok:
8.523 +
8.524 + mova test_writew_pc, r0
8.525 +.align 4
8.526 +test_writew_pc:
8.527 + mov.w r1, @r10
8.528 + bsr utlb_check_write_exc
8.529 + nop
8.530 +
8.531 + mova test_writewp_pc, r0
8.532 + mov r10, r8
8.533 +.align 4
8.534 +test_writewp_pc:
8.535 + mov.w r1, @-r8
8.536 + bsr utlb_check_write_exc
8.537 + nop
8.538 + cmp/eq r8, r10
8.539 + bt test_writewp_ok
8.540 + add #1, r14
8.541 + mov.l err_writewp_bad_msg_k, r4
8.542 + mov r9, r5
8.543 + trapa #41
8.544 +test_writewp_ok:
8.545 +
8.546 + mova test_writeb_pc, r0
8.547 +.align 4
8.548 +test_writeb_pc:
8.549 + mov.b r1, @r10
8.550 + bsr utlb_check_write_exc
8.551 + nop
8.552 +
8.553 + mova test_writebp_pc, r0
8.554 + mov r10, r8
8.555 +.align 4
8.556 +test_writebp_pc:
8.557 + mov.b r1, @-r8
8.558 + bsr utlb_check_write_exc
8.559 + nop
8.560 + cmp/eq r8, r10
8.561 + bt test_writebp_ok
8.562 + add #1, r14
8.563 + mov.l err_writelp_bad_msg_k, r4
8.564 + mov r9, r5
8.565 + trapa #41
8.566 +test_writebp_ok:
8.567 +
8.568 + bra utlb_write_test_done
8.569 + nop
8.570 +
8.571 +/* Non-exception write tests */
8.572 +utlb_write_test_noexc:
8.573 + mov.l utlb_exc_k_2, r8
8.574 + mov.l addr_mask, r0
8.575 + and r0, r8
8.576 + bsr utlb_noexpect_exc
8.577 + nop
8.578 +
8.579 + mov.l @r11, r7
8.580 + ocbp @r11
8.581 + not r7, r1
8.582 +
8.583 + mov.l r1, @r10
8.584 + ocbp @r10
8.585 + mov.l @r11, r6
8.586 + cmp/eq r6, r1
8.587 + bt test_writel_1_ok
8.588 +
8.589 + add #1, r14
8.590 + mov.l err_write_ignored_msg_k, r4
8.591 + mov r9, r5
8.592 + trapa #41
8.593 +
8.594 +test_writel_1_ok:
8.595 +
8.596 + mov.l @(4,r8), r0
8.597 + add r0, r14
8.598 +utlb_write_test_done:
8.599 +
8.600 + xor r0, r0
8.601 + mov.l r0, @(16,r8)
8.602 +
8.603 + mov.l @r15+, r0
8.604 + mov.l r0, @r11
8.605 + mov.l @r15+, r8
8.606 + mov.l @r15+, r9
8.607 + mov.l @r15+, r10
8.608 + mov.l @r15+, r11
8.609 + mov.l @r15+, r12
8.610 + mov.l @r15+, r13
8.611 + mov.l @r15+, r1
8.612 + lds r1, pr
8.613 + mov r14, r0
8.614 + mov.l @r15+, r14
8.615 + rts
8.616 + nop
8.617 +
8.618 +.align 4
8.619 +err_read_mismatch_msg_k:
8.620 + .long err_read_mismatch_msg
8.621 +err_write_ignored_msg_k:
8.622 + .long err_write_ignored_msg
8.623 +err_readlp_bad_msg_k:
8.624 + .long err_readlp_bad_msg
8.625 +err_readwp_bad_msg_k:
8.626 + .long err_readwp_bad_msg
8.627 +err_readbp_bad_msg_k:
8.628 + .long err_readbp_bad_msg
8.629 +err_writelp_bad_msg_k:
8.630 + .long err_readlp_bad_msg
8.631 +err_writewp_bad_msg_k:
8.632 + .long err_readwp_bad_msg
8.633 +err_writebp_bad_msg_k:
8.634 + .long err_readbp_bad_msg
8.635 +
8.636 +
8.637 +
8.638 +.global _run_utlb_user_test
8.639 +_run_utlb_user_test:
8.640 + sts pr, r0
8.641 + mov.l r0, @-r15
8.642 + stc sr, r2
8.643 + mov.l sr_mask, r1
8.644 + and r1, r2
8.645 +
8.646 + mova user_entry_point, r0
8.647 + mov.l addr_mask, r1
8.648 + and r1, r0
8.649 +
8.650 + mov.l r15, @-r15
8.651 +
8.652 + jmp @r0
8.653 + nop
8.654 +
8.655 +user_entry_point:
8.656 + nop
8.657 + ldc r2, sr
8.658 +
8.659 + /* In user mode */
8.660 +
8.661 + mov.l main_test_k, r0
8.662 + and r1, r0
8.663 + and r1, r4
8.664 + and r1, r15
8.665 + jsr @r0
8.666 + nop
8.667 +
8.668 + /* Done, return to priv mode */
8.669 + trapa #42
8.670 + mov.l user_retaddr, r1
8.671 + jmp @r1
8.672 + nop
8.673 +
8.674 +user_exit_point:
8.675 + /* Back to priv mode */
8.676 + mov.l @r15+, r15
8.677 + mov.l @r15+, r1
8.678 + lds r1, pr
8.679 + rts
8.680 + nop
8.681 +.align 4
8.682 +
8.683 +utlb_exc_k_2:
8.684 + .long utlb_exc
8.685 +main_test_k:
8.686 + .long _run_utlb_priv_test
8.687 +addr_mask:
8.688 + .long 0x1FFFFFFF
8.689 +sr_mask:
8.690 + .long 0x3FFFFFFF
8.691 +user_retaddr:
8.692 + .long user_exit_point
8.693 +
8.694 +err_read_exc_msg:
8.695 + .string "%s: Read failed: Expected Exc %04X but got %04X\n"
8.696 +err_read_count_msg:
8.697 + .string "%s: Read bad exception: Exception 1 exception, but got %d\n"
8.698 +err_read_pc_msg:
8.699 + .string "%s: Read bad exception: Expected PC=%08X but was %08X\n"
8.700 +err_read_mismatch_msg:
8.701 + .string "%s: Read failed: Data mismatch!\n"
8.702 +err_readlp_bad_msg:
8.703 + .string "%s: Mov.l @Rm+, Rn failed: Rm changed!\n"
8.704 +err_readwp_bad_msg:
8.705 + .string "%s: Mov.w @Rm+, Rn failed: Rm changed!\n"
8.706 +err_readbp_bad_msg:
8.707 + .string "%s: Mov.b @Rm+, Rn failed: Rm changed!\n"
8.708 +err_writelp_bad_msg:
8.709 + .string "%s: Mov.l Rm, @-Rn failed: Rm changed!\n"
8.710 +err_writewp_bad_msg:
8.711 + .string "%s: Mov.w Rm, @-Rn failed: Rm changed!\n"
8.712 +err_writebp_bad_msg:
8.713 + .string "%s: Mov.b Rm, @-Rn failed: Rm changed!\n"
8.714 +err_write_exc_msg:
8.715 + .string "%s: Write failed: Expected Exc %04X but got %04X\n"
8.716 +err_write_count_msg:
8.717 + .string "%s: Write bad exception: Expected 1 exception, but got %d\n"
8.718 +err_write_pc_msg:
8.719 + .string "%s: Write bad exception: Expected PC=%08X but was %08X\n"
8.720 +err_write_ignored_msg:
8.721 + .string "%s: Write failed: write didn't happen!\n"
8.722 +utlb_unexpected_msg:
8.723 + .string "*** Unexpected exception %04X at %08X!\n"
9.1 --- a/test/sh4/tlb.s Mon Jan 26 07:26:24 2009 +0000
9.2 +++ b/test/sh4/tlb.s Mon Jan 26 12:32:23 2009 +0000
9.3 @@ -104,6 +104,8 @@
9.4 bt test_tlb_6
9.5 test_tlb5_fail:
9.6 fail test_tlb_str_k
9.7 + bra test_tlb_6
9.8 + nop
9.9
9.10 test_tlb5_addr:
9.11 .long 0xF6000000
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/test/sh4/utlb.c Mon Jan 26 12:32:23 2009 +0000
10.3 @@ -0,0 +1,99 @@
10.4 +/**
10.5 + * $Id: utlb.c 831 2008-08-13 10:32:00Z nkeynes $
10.6 + *
10.7 + * UTLB unit test support
10.8 + *
10.9 + * Copyright (c) 2006 Nathan Keynes.
10.10 + *
10.11 + * This program is free software; you can redistribute it and/or modify
10.12 + * it under the terms of the GNU General Public License as published by
10.13 + * the Free Software Foundation; either version 2 of the License, or
10.14 + * (at your option) any later version.
10.15 + *
10.16 + * This program is distributed in the hope that it will be useful,
10.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.19 + * GNU General Public License for more details.
10.20 + */
10.21 +
10.22 +#include <assert.h>
10.23 +#include "utlb.h"
10.24 +#include "../lib.h"
10.25 +
10.26 +#define TLB_VALID 0x00000100
10.27 +#define TLB_USERMODE 0x00000040
10.28 +#define TLB_WRITABLE 0x00000020
10.29 +#define TLB_SIZE_1K 0x00000000
10.30 +#define TLB_SIZE_4K 0x00000010
10.31 +#define TLB_SIZE_64K 0x00000080
10.32 +#define TLB_SIZE_1M 0x00000090
10.33 +#define TLB_CACHEABLE 0x00000008
10.34 +#define TLB_DIRTY 0x00000004
10.35 +#define TLB_SHARE 0x00000002
10.36 +#define TLB_WRITETHRU 0x00000001
10.37 +
10.38 +#define PTEH 0xFF000000
10.39 +#define PTEL 0xFF000004
10.40 +#define TEA 0xFF00000C
10.41 +#define MMUCR 0xFF000010
10.42 +
10.43 +void set_tlb_enabled( int flag )
10.44 +{
10.45 + uint32_t val = long_read( MMUCR );
10.46 + if( flag ) {
10.47 + val |= 1;
10.48 + } else {
10.49 + val &= ~1;
10.50 + }
10.51 + long_write( MMUCR, val );
10.52 +}
10.53 +
10.54 +void invalidate_tlb()
10.55 +{
10.56 + uint32_t val = long_read( MMUCR );
10.57 + long_write( MMUCR, val | 4 );
10.58 +}
10.59 +
10.60 +void set_sv_enabled( int flag )
10.61 +{
10.62 + uint32_t val = long_read( MMUCR );
10.63 + if( flag ) {
10.64 + val |= 0x100;
10.65 + } else {
10.66 + val &= ~0x100;
10.67 + }
10.68 + long_write( MMUCR, val );
10.69 +}
10.70 +
10.71 +void set_storequeue_protected( int flag )
10.72 +{
10.73 + uint32_t val = long_read( MMUCR );
10.74 + if( flag ) {
10.75 + val |= 0x200;
10.76 + } else {
10.77 + val &= ~0x200;
10.78 + }
10.79 + long_write( MMUCR, val );
10.80 +}
10.81 +
10.82 +
10.83 +void set_asid( int asid )
10.84 +{
10.85 + uint32_t val = long_read( PTEH ) & 0xFFFFFF00;
10.86 + long_write( PTEH, val | asid );
10.87 +}
10.88 +
10.89 +
10.90 +void load_utlb_entry( int entryNo, uint32_t vpn, uint32_t ppn, int asid, uint32_t mode )
10.91 +{
10.92 + long_write( (0xF6000000 | (entryNo<<8)), vpn | asid );
10.93 + long_write( (0xF7000000 | (entryNo<<8)), ppn | mode );
10.94 +}
10.95 +
10.96 +
10.97 +void check_utlb_access( uint32_t addr, uint32_t direct_addr, int mode )
10.98 +{
10.99 +
10.100 +
10.101 +}
10.102 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/test/sh4/utlb.h Mon Jan 26 12:32:23 2009 +0000
11.3 @@ -0,0 +1,51 @@
11.4 +/**
11.5 + * $Id: utlb.c 831 2008-08-13 10:32:00Z nkeynes $
11.6 + *
11.7 + * UTLB unit test support
11.8 + *
11.9 + * Copyright (c) 2006 Nathan Keynes.
11.10 + *
11.11 + * This program is free software; you can redistribute it and/or modify
11.12 + * it under the terms of the GNU General Public License as published by
11.13 + * the Free Software Foundation; either version 2 of the License, or
11.14 + * (at your option) any later version.
11.15 + *
11.16 + * This program is distributed in the hope that it will be useful,
11.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.19 + * GNU General Public License for more details.
11.20 + */
11.21 +
11.22 +#include <../lib.h>
11.23 +
11.24 +#ifndef TEST_UTLB
11.25 +#define TEST_UTLB 1
11.26 +
11.27 +#define TLB_VALID 0x00000100
11.28 +#define TLB_USERMODE 0x00000040
11.29 +#define TLB_WRITABLE 0x00000020
11.30 +#define TLB_USERWRITABLE (TLB_WRITABLE|TLB_USERMODE)
11.31 +#define TLB_SIZE_MASK 0x00000090
11.32 +#define TLB_SIZE_1K 0x00000000
11.33 +#define TLB_SIZE_4K 0x00000010
11.34 +#define TLB_SIZE_64K 0x00000080
11.35 +#define TLB_SIZE_1M 0x00000090
11.36 +#define TLB_CACHEABLE 0x00000008
11.37 +#define TLB_DIRTY 0x00000004
11.38 +#define TLB_SHARE 0x00000002
11.39 +#define TLB_WRITETHRU 0x00000001
11.40 +
11.41 +void set_tlb_enabled( int flag );
11.42 +void invalidate_tlb();
11.43 +void set_sv_enabled( int flag );
11.44 +void set_storequeue_protected( int flag );
11.45 +void set_asid( int asid );
11.46 +void load_utlb_entry( int entryNo, uint32_t vpn, uint32_t ppn, int asid, uint32_t mode );
11.47 +
11.48 +#define ACCESS_OK 0
11.49 +#define ACCESS_READONLY 1
11.50 +#define ACCESS_PRIVONLY 2
11.51 +#define ACCESS_USERMISS 4
11.52 +void check_utlb_access( uint32_t addr, uint32_t direct_addr, int mode );
11.53 +
11.54 +#endif /* !TEST_UTLB */
.