Search
lxdream.org :: lxdream/src/test/testxlt.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testxlt.c
changeset 922:8a8361264b1e
prev561:533f6b478071
next991:60c7fab9c880
author nkeynes
date Thu Jan 15 11:18:10 2009 +0000 (15 years ago)
permissions -rw-r--r--
last change Fix broken link line ($LINK rather than just $CCLD)
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;
    26 /**
    27  * Test initial allocations from the new cache
    28  */
    29 void test_initial()
    30 {
    31     int i;
    32     xlat_cache_block_t block = xlat_start_block( 0x0C008000 );
    33     assert( block->active == 1 );
    34     assert( block->size == XLAT_NEW_CACHE_SIZE - (2*sizeof(struct xlat_cache_block)) );
    35     memset( block->code, 0xB5, 8192 );
    36     xlat_commit_block( 8192, 100 );
    37     assert( block->active == 1 );
    38     assert( block->size == 8192 );
    40     int size = XLAT_NEW_CACHE_SIZE - (4*sizeof(struct xlat_cache_block)) - 8192 - 4096;
    41     xlat_cache_block_t block2 = xlat_start_block( 0x0C009000 );
    42     assert( block2->active == 1 );
    43     assert( block2->size == XLAT_NEW_CACHE_SIZE - (3*sizeof(struct xlat_cache_block)) - 8192 );
    44     memset( block2->code, 0x6D, size );
    45     xlat_commit_block( size, 200 );
    46     assert( block2->active == 1 );
    47     assert( block2->size == size );
    49     void *addr = xlat_get_code( 0x0C008000 );
    50     assert( addr == &block->code );
    51     addr = xlat_get_code( 0x0C009000 );
    52     assert( addr == &block2->code );
    53     addr = xlat_get_code( 0x0C008002 );
    54     assert( addr == NULL );
    56     xlat_cache_block_t block3 = xlat_start_block( 0x0D009800 );
    57     assert( block3->active == 1 );
    58     assert( block3->size == 4096 );
    59     memset( block3->code, 0x9C, 4096 );
    60     xlat_cache_block_t block3a = xlat_extend_block(8192);
    61     assert( block3a != block3 );
    62     assert( block3a == block );
    63     assert( block3a->active == 1 );
    64     assert( block3a->size = 8192 );
    65     assert( block3->active == 0 );
    66     assert( block3->size == 4096 );
    67     for( i=0; i<4096; i++ ) {
    68 	assert( block3a->code[i] == 0x9C );
    69     }
    70     for( i=4096; i<8192; i++ ) {
    71 	assert( block3a->code[i] == 0xB5 );
    72     }
    73     xlat_commit_block(6142, 432);
    74     addr = xlat_get_code( 0x0D009800 );
    75     assert( addr == &block3a->code );
    76 }
    78 int main()
    79 {
    80     xlat_cache_init();
    81     xlat_check_integrity();
    83     test_initial();
    84     return 0;
    85 }
.