revision 225:e5cea6125580
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 225:e5cea6125580 |
parent | 224:289ddaeeebb3 |
child | 226:0eeeb25447d3 |
author | nkeynes |
date | Wed Sep 20 09:52:32 2006 +0000 (17 years ago) |
Commit start of SH4 test cases
![]() | test/Makefile | view | annotate | diff | log | |
![]() | test/sh4/README | view | annotate | diff | log | |
![]() | test/sh4/add.s | view | annotate | diff | log | |
![]() | test/sh4/testsh4.c | view | annotate | diff | log | |
![]() | test/timer.c | view | annotate | diff | log | |
![]() | test/timer.h | view | annotate | diff | log |
1.1 --- a/test/Makefile Tue Sep 12 13:33:18 2006 +00001.2 +++ b/test/Makefile Wed Sep 20 09:52:32 2006 +00001.3 @@ -71,6 +71,9 @@1.5 build-tests: testmath testide testta testregs1.7 +testsh4: crt0.so sh4/testsh4.so sh4/timer.so sh4/add.so1.8 + $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)1.9 +1.10 testide: crt0.so testide.so ide.so1.11 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00002.2 +++ b/test/sh4/README Wed Sep 20 09:52:32 2006 +00002.3 @@ -0,0 +1,11 @@2.4 +SH4 instruction set tests.2.5 +Each core instruction has its own set of tests that are assembled into the2.6 +main test executable.2.7 +2.8 +Note: Since each instruction's tests obviously depends on other2.9 +instructions, its possible for multiple bugs to cancel each other out.2.10 +However the tests are structured as much as possible to prevent this.2.11 +2.12 +Each test loops repeatedly for a constant number of times (currently 1000)2.13 +to a) ensure that dynamic recompilation kicks in and recompiles the block,2.14 +and b) allow the code to be timed (to a first approximation anyway).
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00003.2 +++ b/test/sh4/add.s Wed Sep 20 09:52:32 2006 +00003.3 @@ -0,0 +1,145 @@3.4 + .section .text3.5 +.global _test_add3.6 +_test_add:3.7 + mov.l r14, @-r153.8 + sts.l pr, @-r153.9 + mov.l r12, @-r153.10 + mov.l r13, @-r153.11 + mov r15, r143.12 + xor r12,r123.13 + xor r13,r133.14 +# r12 is the test counter3.15 +# r13 is the failed-test counter3.16 +3.17 +test_add_1: # test adding 0+0 = 03.18 + add #1, r123.19 + xor r0,r03.20 + xor r1,r13.21 + xor r2,r23.22 + add r0,r13.23 + cmp/eq r1, r23.24 + bt test_add_23.25 + add #1, r133.26 +3.27 +test_add_2: # test 0+ constant 1 = 13.28 + add #1, r123.29 + xor r0, r03.30 + xor r1, r13.31 + add #1, r13.32 + mov.l test_add_2_result, r23.33 + cmp/eq r1, r23.34 + bt test_add_33.35 + add #1, r133.36 + bra test_add_33.37 + nop3.38 +3.39 + .align 43.40 +test_add_2_result:3.41 + .long 0x000000013.42 +3.43 +test_add_3: # test 0 + constant -1 = -13.44 + add #1, r123.45 + xor r0, r03.46 + xor r1, r13.47 + add #-1, r13.48 + mov.l test_add_3_result, r23.49 + cmp/eq r1, r23.50 + bt test_add_43.51 + add #1, r133.52 + bra test_add_43.53 + nop3.54 +3.55 + .align 43.56 +test_add_3_result:3.57 + .long 0xFFFFFFFF3.58 +3.59 +test_add_4: # test a+b = c w/ overflow3.60 + add #1, r123.61 + mov.l test_add_4_op1, r43.62 + mov.l test_add_4_op2, r53.63 + mov.l test_add_4_result, r03.64 + add r4, r53.65 + cmp/eq r5, r03.66 + bt test_add_53.67 + add #1, r133.68 + bra test_add_53.69 + nop3.70 +3.71 + .align 43.72 +test_add_4_op1:3.73 + .long 0x987654323.74 +test_add_4_op2:3.75 + .long 0xA12345673.76 +test_add_4_result:3.77 + .long 0x399999993.78 +3.79 +test_add_5: # test carry neither used nor set (ala ADDC)3.80 + add #1, r123.81 + mov.l test_add_5_op1, r83.82 + mov.l test_add_5_op2, r93.83 + stc sr, r103.84 + xor r0,r03.85 + add #1, r03.86 + or r0,r103.87 + ldc r10, sr3.88 + add r9,r83.89 + mov.l test_add_5_result, r113.90 + cmp/eq r11, r83.91 + bt test_add_5_b3.92 + add #1, r133.93 + mov.l test_print_failure_k, r33.94 + mov r12, r53.95 + mov.l test_add_str_k, r43.96 + jsr @r33.97 + nop3.98 + bra test_add_63.99 + nop3.100 +test_add_5_b:3.101 + stc sr, r13.102 + and r0, r13.103 + cmp/eq r0, r13.104 + bt test_add_63.105 + add #1, r133.106 + mov.l test_print_failure_k, r33.107 + mov r12, r53.108 + mov.l test_add_str_k, r43.109 + jsr @r33.110 + nop3.111 + bra test_add_63.112 + nop3.113 +3.114 +test_add_5_op1:3.115 + .long 0x111111113.116 +test_add_5_op2:3.117 + .long 0x1000FFFF3.118 +test_add_5_result:3.119 + .long 0x211211103.120 +3.121 +test_add_6:3.122 +3.123 +test_add_end:3.124 + mov.l test_add_str_k, r43.125 + mov r13, r53.126 + mov r12, r63.127 + mov.l test_print_result_k, r13.128 + jsr @r13.129 + mov r14, r153.130 + mov.l @r15+, r133.131 + mov.l @r15+, r123.132 + lds.l @r15+, pr3.133 + mov.l @r15+, r143.134 + rts3.135 + nop3.136 +3.137 + .align 23.138 +test_add_str:3.139 + .string "ADD"3.140 + .align 23.141 +3.142 +test_add_str_k:3.143 + .long test_add_str3.144 +test_print_result_k:3.145 + .long _test_print_result3.146 +test_print_failure_k:3.147 + .long _test_print_failure3.148 +3.149 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00004.2 +++ b/test/sh4/testsh4.c Wed Sep 20 09:52:32 2006 +00004.3 @@ -0,0 +1,18 @@4.4 +#include <stdio.h>4.5 +4.6 +int test_print_result( char *testname, int failed, int total )4.7 +{4.8 + fprintf( stderr, "%s: %d/%d tests passed\n", testname, total-failed, total );4.9 + return failed;4.10 +}4.11 +4.12 +void test_print_failure( char *testname, int number )4.13 +{4.14 + fprintf( stderr, "%s: Test %d failed!\n", testname, number );4.15 +}4.16 +4.17 +int main()4.18 +{4.19 +4.20 + test_add();4.21 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00005.2 +++ b/test/timer.c Wed Sep 20 09:52:32 2006 +00005.3 @@ -0,0 +1,45 @@5.4 +#include "../lib.h"5.5 +#define TMU_CHANNEL 25.6 +5.7 +#define TOCR 0xFFD80000 /* Output control register */5.8 +#define TSTR 0xFFD80004 /* Start register */5.9 +#define TCOR(c) (0xFFD80008 + (c*12)) /* Constant register */5.10 +#define TCNT(c) (0xFFD8000C + (c*12)) /* Count register */5.11 +#define TCR(c) (0xFFD80010 + (c*12)) /* Control register */5.12 +5.13 +/**5.14 + * Initialize the on-chip timer controller. We snag TMU channel 2 in its5.15 + * highest resolution mode, and start it counting down from max_int.5.16 + */5.17 +void timer_start() {5.18 + unsigned int val = long_read(TSTR);5.19 + long_write( TSTR, val & (~(1<<TMU_CHANNEL)) ); /* Stop counter */5.20 + long_write( TCOR(TMU_CHANNEL), 0xFFFFFFFF );5.21 + long_write( TCNT(TMU_CHANNEL), 0xFFFFFFFF );5.22 + long_write( TCR(TMU_CHANNEL), 0x00000000 );5.23 + long_write( TSTR, val | (1<<TMU_CHANNEL) );5.24 +}5.25 +5.26 +/**5.27 + * Report the current value of TMU2.5.28 + */5.29 +long timer_gettime() {5.30 + return long_read(TCNT(TMU_CHANNEL));5.31 +}5.32 +5.33 +/**5.34 + * Stop TMU2 and report the current value.5.35 + */5.36 +long timer_stop() {5.37 + long_write( TSTR, long_read(TSTR) & (~(1<<TMU_CHANNEL)) );5.38 + return long_read( TCNT(TMU_CHANNEL) );5.39 +}5.40 +5.41 +5.42 +/**5.43 + * Convert the supplied timer value to a number of micro seconds since the timer5.44 + * was started.5.45 + */5.46 +long timer_to_microsecs( long value ) {5.47 + return value;5.48 +}
.