filename | src/test/testxlt.c |
changeset | 363:7d0bab24016c |
next | 515:5e5bb1dd369e |
author | nkeynes |
date | Tue Sep 11 02:14:46 2007 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Cache the pointer to the last FR bank (speeds fp ops up by about 10%) Implement experimental fix for FLOAT/FTRC Make read/write sr functions non-static (share with translator) Much more translator WIP |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/test/testxlt.c Tue Sep 11 02:14:46 2007 +00001.3 @@ -0,0 +1,77 @@1.4 +#include <assert.h>1.5 +#include "sh4/xltcache.h"1.6 +#include "dreamcast.h"1.7 +1.8 +extern xlat_cache_block_t xlat_new_cache;1.9 +extern xlat_cache_block_t xlat_new_cache_ptr;1.10 +extern xlat_cache_block_t xlat_temp_cache;1.11 +extern xlat_cache_block_t xlat_temp_cache_ptr;1.12 +1.13 +/**1.14 + * Test initial allocations from the new cache1.15 + */1.16 +void test_initial()1.17 +{1.18 + int i;1.19 + xlat_cache_block_t block = xlat_start_block( 0x0C008000 );1.20 + assert( block->active == 1 );1.21 + assert( block->size == XLAT_NEW_CACHE_SIZE - (2*sizeof(struct xlat_cache_block)) );1.22 + memset( block->code, 0xB5, 8192 );1.23 + xlat_commit_block( 8192 );1.24 + assert( block->active == 1 );1.25 + assert( block->size == 8192 );1.26 +1.27 + int size = XLAT_NEW_CACHE_SIZE - (4*sizeof(struct xlat_cache_block)) - 8192 - 4096;1.28 + xlat_cache_block_t block2 = xlat_start_block( 0x0C009000 );1.29 + assert( block2->active == 1 );1.30 + assert( block2->size == XLAT_NEW_CACHE_SIZE - (3*sizeof(struct xlat_cache_block)) - 8192 );1.31 + memset( block2->code, 0x6D, size );1.32 + xlat_commit_block( size );1.33 + assert( block2->active == 1 );1.34 + assert( block2->size == size );1.35 +1.36 + void *addr = xlat_get_code( 0x0C008000 );1.37 + assert( addr == &block->code );1.38 + addr = xlat_get_code( 0x0C009000 );1.39 + assert( addr == &block2->code );1.40 + addr = xlat_get_code( 0x0C008002 );1.41 + assert( addr == NULL );1.42 +1.43 + xlat_cache_block_t block3 = xlat_start_block( 0x0D009800 );1.44 + assert( block3->active == 1 );1.45 + assert( block3->size == 4096 );1.46 + memset( block3->code, 0x9C, 4096 );1.47 + xlat_cache_block_t block3a = xlat_extend_block();1.48 + assert( block3a != block3 );1.49 + assert( block3a == block );1.50 + assert( block3a->active == 1 );1.51 + assert( block3a->size = 8192 );1.52 + assert( block3->active == 0 );1.53 + assert( block3->size == 4096 );1.54 + for( i=0; i<4096; i++ ) {1.55 + assert( block3a->code[i] == 0x9C );1.56 + }1.57 + for( i=4096; i<8192; i++ ) {1.58 + assert( block3a->code[i] == 0xB5 );1.59 + }1.60 + xlat_commit_block(6142);1.61 + addr = xlat_get_code( 0x0D009800 );1.62 + assert( addr == &block3a->code );1.63 + /* check promoted block in temp cache */1.64 + addr = xlat_get_code( 0x0C008000 );1.65 + assert( addr == &xlat_temp_cache->code );1.66 + assert( xlat_temp_cache->active == 1 );1.67 + assert( xlat_temp_cache->size == 8192 );1.68 + for( i=0; i<8192; i++ ) {1.69 + assert( xlat_temp_cache->code[i] == 0xB5 );1.70 + }1.71 +}1.72 +1.73 +int main()1.74 +{1.75 + xlat_cache_init();1.76 + xlat_check_integrity();1.77 +1.78 + test_initial();1.79 + return 0;1.80 +}
.