Search
lxdream.org :: lxdream/test/testmmu.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/testmmu.c
changeset 551:07125ce718da
prev550:a27e31340147
author nkeynes
date Thu Jan 31 09:35:01 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Update release notes for 0.8.3
view annotate diff log raw
     1 #include <assert.h>
     2 #include <stdio.h>
     3 #include "lib.h"
     5 #define PTEH  0xFF000000
     6 #define PTEL  0xFF000004
     7 #define TTB   0xFF000008
     8 #define TEA   0xFF00000C
     9 #define MMUCR 0xFF000010
    10 #define PTEA  0xFF000034
    12 #define ITLB_ADDR(entry) (0xF2000000 + (entry<<8))
    13 #define ITLB_DATA(entry) (0xF3000000 + (entry<<8))
    14 #define UTLB_ADDR(entry) (0xF6000000 + (entry<<8))
    15 #define UTLB_DATA1(entry) (0xF7000000 + (entry<<8))
    16 #define UTLB_DATA2(entry) (0xF7800000 + (entry<<8))
    18 /* Bang on the mmio side of the TLBs to make sure the bits
    19  * respond appropriately (with AT disabled so we don't risk
    20  * doing a hard crash) */
    21 void test_tlb_mmio()
    22 {
    23     int entry;
    24     for( entry=0; entry<64; entry++ ) {
    25 	long_write( UTLB_DATA1(entry), 0 );
    26 	long_write( UTLB_ADDR(entry), 0xFFFFFFFF );
    27 	assert( long_read( UTLB_ADDR(entry) ) == 0xFFFFFFFF );
    28 	assert( long_read( UTLB_DATA1(entry) ) == 0x00000104 );
    29 	long_write( UTLB_ADDR(entry), 0x00000000 );
    30 	assert( long_read( UTLB_ADDR(entry) ) == 0x00000000 );
    31 	assert( long_read( UTLB_DATA1(entry) ) == 0x00000000 );
    32 	long_write( UTLB_DATA1(entry), 0xFFFFFFFF );
    33 	assert( long_read( UTLB_DATA1(entry) ) == 0x1FFFFDFF );
    34 	assert( long_read( UTLB_ADDR(entry) ) == 0x00000300 );
    35 	long_write( UTLB_DATA1(entry), 0x00000000 );
    36 	assert( long_read( UTLB_DATA1(entry) ) == 0x00000000 );
    37 	assert( long_read( UTLB_ADDR(entry) ) == 0x00000000 );
    38 	long_write( UTLB_DATA2(entry), 0xFFFFFFFF );
    39 	assert( long_read( UTLB_DATA2(entry) ) == 0x0000000F );
    40 	long_write( UTLB_DATA2(entry), 0x00000000 );
    41 	assert( long_read( UTLB_DATA2(entry) ) == 0x00000000 );
    42     }
    44     for( entry=0; entry<4; entry++ ) {
    45 	long_write( ITLB_DATA(entry), 0 );
    46 	long_write( ITLB_ADDR(entry), 0xFFFFFFFF );
    47 	assert( long_read( ITLB_ADDR(entry) ) == 0xFFFFFDFF );
    48 	assert( long_read( ITLB_DATA(entry) ) == 0x00000100 );
    49 	long_write( ITLB_ADDR(entry), 0x00000000 );
    50 	assert( long_read( ITLB_ADDR(entry) ) == 0x00000000 );
    51 	assert( long_read( ITLB_DATA(entry) ) == 0x00000000 );
    52 	long_write( ITLB_DATA(entry), 0xFFFFFFFF );
    53 	assert( long_read( ITLB_DATA(entry) ) == 0x1FFFFDDA );
    54 	assert( long_read( ITLB_ADDR(entry) ) == 0x00000100 );
    55 	long_write( ITLB_DATA(entry), 0x00000000 );
    56 	assert( long_read( ITLB_DATA(entry) ) == 0x00000000 );
    57 	assert( long_read( ITLB_ADDR(entry) ) == 0x00000000 );
    59     }
    60 }
    62 int main( int argc, char *argv[] )
    63 {
    64     test_tlb_mmio();
    65     return 0;
    66 }
.