Search
lxdream.org :: lxdream/src/test/testxlt.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testxlt.c
changeset 561:533f6b478071
prev515:5e5bb1dd369e
next922:8a8361264b1e
author nkeynes
date Fri Oct 31 02:57:59 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Declare mem_copy_* functions as FASTCALL
Split sh4_flush_store_queue into TLB/non-TLB versions, and optimize
slightly based on that
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Translation cache test functions
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #include <assert.h>
    20 #include "sh4/xltcache.h"
    21 #include "dreamcast.h"
    23 extern xlat_cache_block_t xlat_new_cache;
    24 extern xlat_cache_block_t xlat_new_cache_ptr;
    25 extern xlat_cache_block_t xlat_temp_cache;
    26 extern xlat_cache_block_t xlat_temp_cache_ptr;
    28 /**
    29  * Test initial allocations from the new cache
    30  */
    31 void test_initial()
    32 {
    33     int i;
    34     xlat_cache_block_t block = xlat_start_block( 0x0C008000 );
    35     assert( block->active == 1 );
    36     assert( block->size == XLAT_NEW_CACHE_SIZE - (2*sizeof(struct xlat_cache_block)) );
    37     memset( block->code, 0xB5, 8192 );
    38     xlat_commit_block( 8192, 100 );
    39     assert( block->active == 1 );
    40     assert( block->size == 8192 );
    42     int size = XLAT_NEW_CACHE_SIZE - (4*sizeof(struct xlat_cache_block)) - 8192 - 4096;
    43     xlat_cache_block_t block2 = xlat_start_block( 0x0C009000 );
    44     assert( block2->active == 1 );
    45     assert( block2->size == XLAT_NEW_CACHE_SIZE - (3*sizeof(struct xlat_cache_block)) - 8192 );
    46     memset( block2->code, 0x6D, size );
    47     xlat_commit_block( size, 200 );
    48     assert( block2->active == 1 );
    49     assert( block2->size == size );
    51     void *addr = xlat_get_code( 0x0C008000 );
    52     assert( addr == &block->code );
    53     addr = xlat_get_code( 0x0C009000 );
    54     assert( addr == &block2->code );
    55     addr = xlat_get_code( 0x0C008002 );
    56     assert( addr == NULL );
    58     xlat_cache_block_t block3 = xlat_start_block( 0x0D009800 );
    59     assert( block3->active == 1 );
    60     assert( block3->size == 4096 );
    61     memset( block3->code, 0x9C, 4096 );
    62     xlat_cache_block_t block3a = xlat_extend_block(8192);
    63     assert( block3a != block3 );
    64     assert( block3a == block );
    65     assert( block3a->active == 1 );
    66     assert( block3a->size = 8192 );
    67     assert( block3->active == 0 );
    68     assert( block3->size == 4096 );
    69     for( i=0; i<4096; i++ ) {
    70 	assert( block3a->code[i] == 0x9C );
    71     }
    72     for( i=4096; i<8192; i++ ) {
    73 	assert( block3a->code[i] == 0xB5 );
    74     }
    75     xlat_commit_block(6142, 432);
    76     addr = xlat_get_code( 0x0D009800 );
    77     assert( addr == &block3a->code );
    78     /* check promoted block in temp cache */
    79     addr = xlat_get_code( 0x0C008000 );
    80     assert( addr == &xlat_temp_cache->code );
    81     assert( xlat_temp_cache->active == 1 );
    82     assert( xlat_temp_cache->size == 8192 );
    83     for( i=0; i<8192; i++ ) {
    84 	assert( xlat_temp_cache->code[i] == 0xB5 );
    85     }
    86 }
    88 int main()
    89 {
    90     xlat_cache_init();
    91     xlat_check_integrity();
    93     test_initial();
    94     return 0;
    95 }
.