Search
lxdream.org :: lxdream/src/test/testxlt.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testxlt.c
changeset 1189:1540105786c8
prev991:60c7fab9c880
next1195:072131b61d2a
author nkeynes
date Thu Dec 01 08:02:13 2011 +1000 (10 years ago)
permissions -rw-r--r--
last change Fix make check
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 "xlat/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;
    26 void sh4_translate_unlink_block( void *use_list )
    27 {
    28 }
    30 /**
    31  * Test initial allocations from the new cache
    32  */
    33 void test_initial()
    34 {
    35     int i;
    36     xlat_cache_block_t block = xlat_start_block( 0x0C008000 );
    37     assert( block->active == 1 );
    38     assert( block->size == XLAT_NEW_CACHE_SIZE - (2*sizeof(struct xlat_cache_block)) );
    39     memset( block->code, 0xB5, 8192 );
    40     xlat_commit_block( 8192, 100 );
    41     assert( block->active == 1 );
    42     assert( block->size == 8192 );
    44     int size = XLAT_NEW_CACHE_SIZE - (4*sizeof(struct xlat_cache_block)) - 8192 - 4096;
    45     xlat_cache_block_t block2 = xlat_start_block( 0x0C009000 );
    46     assert( block2->active == 1 );
    47     assert( block2->size == XLAT_NEW_CACHE_SIZE - (3*sizeof(struct xlat_cache_block)) - 8192 );
    48     memset( block2->code, 0x6D, size );
    49     xlat_commit_block( size, 200 );
    50     assert( block2->active == 1 );
    51     assert( block2->size == size );
    53     void *addr = xlat_get_code( 0x0C008000 );
    54     assert( addr == &block->code );
    55     addr = xlat_get_code( 0x0C009000 );
    56     assert( addr == &block2->code );
    57     addr = xlat_get_code( 0x0C008002 );
    58     assert( addr == NULL );
    60     xlat_cache_block_t block3 = xlat_start_block( 0x0D009800 );
    61     assert( block3->active == 1 );
    62     assert( block3->size == 4096 );
    63     memset( block3->code, 0x9C, 4096 );
    64     xlat_cache_block_t block3a = xlat_extend_block(8192);
    65     assert( block3a != block3 );
    66     assert( block3a == block );
    67     assert( block3a->active == 1 );
    68     assert( block3a->size = 8192 );
    69     assert( block3->active == 0 );
    70     assert( block3->size == 4096 );
    71     for( i=0; i<4096; i++ ) {
    72 	assert( block3a->code[i] == 0x9C );
    73     }
    74     for( i=4096; i<8192; i++ ) {
    75 	assert( block3a->code[i] == 0xB5 );
    76     }
    77     xlat_commit_block(6142, 432);
    78     addr = xlat_get_code( 0x0D009800 );
    79     assert( addr == &block3a->code );
    80 }
    82 int main()
    83 {
    84     xlat_cache_init();
    85     xlat_check_integrity();
    87     test_initial();
    88     return 0;
    89 }
.