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
file annotate diff log raw
nkeynes@561
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@561
     3
 *
nkeynes@561
     4
 * Translation cache test functions
nkeynes@561
     5
 *
nkeynes@561
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@561
     7
 *
nkeynes@561
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@561
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@561
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@561
    11
 * (at your option) any later version.
nkeynes@561
    12
 *
nkeynes@561
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@561
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@561
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@561
    16
 * GNU General Public License for more details.
nkeynes@561
    17
 */
nkeynes@561
    18
nkeynes@363
    19
#include <assert.h>
nkeynes@991
    20
#include "xlat/xltcache.h"
nkeynes@363
    21
#include "dreamcast.h"
nkeynes@363
    22
nkeynes@363
    23
extern xlat_cache_block_t xlat_new_cache;
nkeynes@363
    24
extern xlat_cache_block_t xlat_new_cache_ptr;
nkeynes@363
    25
nkeynes@1189
    26
void sh4_translate_unlink_block( void *use_list )
nkeynes@1189
    27
{
nkeynes@1189
    28
}
nkeynes@1189
    29
nkeynes@363
    30
/**
nkeynes@363
    31
 * Test initial allocations from the new cache
nkeynes@363
    32
 */
nkeynes@363
    33
void test_initial()
nkeynes@363
    34
{
nkeynes@363
    35
    int i;
nkeynes@363
    36
    xlat_cache_block_t block = xlat_start_block( 0x0C008000 );
nkeynes@363
    37
    assert( block->active == 1 );
nkeynes@363
    38
    assert( block->size == XLAT_NEW_CACHE_SIZE - (2*sizeof(struct xlat_cache_block)) );
nkeynes@363
    39
    memset( block->code, 0xB5, 8192 );
nkeynes@515
    40
    xlat_commit_block( 8192, 100 );
nkeynes@363
    41
    assert( block->active == 1 );
nkeynes@363
    42
    assert( block->size == 8192 );
nkeynes@363
    43
    
nkeynes@363
    44
    int size = XLAT_NEW_CACHE_SIZE - (4*sizeof(struct xlat_cache_block)) - 8192 - 4096;
nkeynes@363
    45
    xlat_cache_block_t block2 = xlat_start_block( 0x0C009000 );
nkeynes@363
    46
    assert( block2->active == 1 );
nkeynes@363
    47
    assert( block2->size == XLAT_NEW_CACHE_SIZE - (3*sizeof(struct xlat_cache_block)) - 8192 );
nkeynes@363
    48
    memset( block2->code, 0x6D, size );
nkeynes@515
    49
    xlat_commit_block( size, 200 );
nkeynes@363
    50
    assert( block2->active == 1 );
nkeynes@363
    51
    assert( block2->size == size );
nkeynes@363
    52
    
nkeynes@363
    53
    void *addr = xlat_get_code( 0x0C008000 );
nkeynes@363
    54
    assert( addr == &block->code );
nkeynes@363
    55
    addr = xlat_get_code( 0x0C009000 );
nkeynes@363
    56
    assert( addr == &block2->code );
nkeynes@363
    57
    addr = xlat_get_code( 0x0C008002 );
nkeynes@363
    58
    assert( addr == NULL );
nkeynes@363
    59
    
nkeynes@363
    60
    xlat_cache_block_t block3 = xlat_start_block( 0x0D009800 );
nkeynes@363
    61
    assert( block3->active == 1 );
nkeynes@363
    62
    assert( block3->size == 4096 );
nkeynes@363
    63
    memset( block3->code, 0x9C, 4096 );
nkeynes@515
    64
    xlat_cache_block_t block3a = xlat_extend_block(8192);
nkeynes@363
    65
    assert( block3a != block3 );
nkeynes@363
    66
    assert( block3a == block );
nkeynes@363
    67
    assert( block3a->active == 1 );
nkeynes@363
    68
    assert( block3a->size = 8192 );
nkeynes@363
    69
    assert( block3->active == 0 );
nkeynes@363
    70
    assert( block3->size == 4096 );
nkeynes@363
    71
    for( i=0; i<4096; i++ ) {
nkeynes@363
    72
	assert( block3a->code[i] == 0x9C );
nkeynes@363
    73
    }
nkeynes@363
    74
    for( i=4096; i<8192; i++ ) {
nkeynes@363
    75
	assert( block3a->code[i] == 0xB5 );
nkeynes@363
    76
    }
nkeynes@515
    77
    xlat_commit_block(6142, 432);
nkeynes@363
    78
    addr = xlat_get_code( 0x0D009800 );
nkeynes@363
    79
    assert( addr == &block3a->code );
nkeynes@363
    80
}
nkeynes@363
    81
nkeynes@363
    82
int main()
nkeynes@363
    83
{
nkeynes@363
    84
    xlat_cache_init();
nkeynes@363
    85
    xlat_check_integrity();
nkeynes@363
    86
    
nkeynes@363
    87
    test_initial();
nkeynes@363
    88
    return 0;
nkeynes@363
    89
}
.