Search
lxdream.org :: lxdream/src/test/testxlt.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testxlt.c
changeset 363:7d0bab24016c
next515: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
view annotate diff log raw
     1 #include <assert.h>
     2 #include "sh4/xltcache.h"
     3 #include "dreamcast.h"
     5 extern xlat_cache_block_t xlat_new_cache;
     6 extern xlat_cache_block_t xlat_new_cache_ptr;
     7 extern xlat_cache_block_t xlat_temp_cache;
     8 extern xlat_cache_block_t xlat_temp_cache_ptr;
    10 /**
    11  * Test initial allocations from the new cache
    12  */
    13 void test_initial()
    14 {
    15     int i;
    16     xlat_cache_block_t block = xlat_start_block( 0x0C008000 );
    17     assert( block->active == 1 );
    18     assert( block->size == XLAT_NEW_CACHE_SIZE - (2*sizeof(struct xlat_cache_block)) );
    19     memset( block->code, 0xB5, 8192 );
    20     xlat_commit_block( 8192 );
    21     assert( block->active == 1 );
    22     assert( block->size == 8192 );
    24     int size = XLAT_NEW_CACHE_SIZE - (4*sizeof(struct xlat_cache_block)) - 8192 - 4096;
    25     xlat_cache_block_t block2 = xlat_start_block( 0x0C009000 );
    26     assert( block2->active == 1 );
    27     assert( block2->size == XLAT_NEW_CACHE_SIZE - (3*sizeof(struct xlat_cache_block)) - 8192 );
    28     memset( block2->code, 0x6D, size );
    29     xlat_commit_block( size );
    30     assert( block2->active == 1 );
    31     assert( block2->size == size );
    33     void *addr = xlat_get_code( 0x0C008000 );
    34     assert( addr == &block->code );
    35     addr = xlat_get_code( 0x0C009000 );
    36     assert( addr == &block2->code );
    37     addr = xlat_get_code( 0x0C008002 );
    38     assert( addr == NULL );
    40     xlat_cache_block_t block3 = xlat_start_block( 0x0D009800 );
    41     assert( block3->active == 1 );
    42     assert( block3->size == 4096 );
    43     memset( block3->code, 0x9C, 4096 );
    44     xlat_cache_block_t block3a = xlat_extend_block();
    45     assert( block3a != block3 );
    46     assert( block3a == block );
    47     assert( block3a->active == 1 );
    48     assert( block3a->size = 8192 );
    49     assert( block3->active == 0 );
    50     assert( block3->size == 4096 );
    51     for( i=0; i<4096; i++ ) {
    52 	assert( block3a->code[i] == 0x9C );
    53     }
    54     for( i=4096; i<8192; i++ ) {
    55 	assert( block3a->code[i] == 0xB5 );
    56     }
    57     xlat_commit_block(6142);
    58     addr = xlat_get_code( 0x0D009800 );
    59     assert( addr == &block3a->code );
    60     /* check promoted block in temp cache */
    61     addr = xlat_get_code( 0x0C008000 );
    62     assert( addr == &xlat_temp_cache->code );
    63     assert( xlat_temp_cache->active == 1 );
    64     assert( xlat_temp_cache->size == 8192 );
    65     for( i=0; i<8192; i++ ) {
    66 	assert( xlat_temp_cache->code[i] == 0xB5 );
    67     }
    68 }
    70 int main()
    71 {
    72     xlat_cache_init();
    73     xlat_check_integrity();
    75     test_initial();
    76     return 0;
    77 }
.