Search
lxdream.org :: lxdream/test/sh4/utlb.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/sh4/utlb.c
changeset 976:e57a25d9eb7d
next1022:43f35b12ece7
author nkeynes
date Mon Jan 26 12:32:23 2009 +0000 (15 years ago)
permissions -rw-r--r--
last change Add some initial TLB test cases
view annotate diff log raw
     1 /**
     2  * $Id: utlb.c 831 2008-08-13 10:32:00Z nkeynes $
     3  * 
     4  * UTLB unit test support
     5  *
     6  * Copyright (c) 2006 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 "utlb.h"
    21 #include "../lib.h"
    23 #define TLB_VALID     0x00000100
    24 #define TLB_USERMODE  0x00000040
    25 #define TLB_WRITABLE  0x00000020
    26 #define TLB_SIZE_1K   0x00000000
    27 #define TLB_SIZE_4K   0x00000010
    28 #define TLB_SIZE_64K  0x00000080
    29 #define TLB_SIZE_1M   0x00000090
    30 #define TLB_CACHEABLE 0x00000008
    31 #define TLB_DIRTY     0x00000004
    32 #define TLB_SHARE     0x00000002
    33 #define TLB_WRITETHRU 0x00000001
    35 #define PTEH  0xFF000000
    36 #define PTEL  0xFF000004
    37 #define TEA   0xFF00000C
    38 #define MMUCR 0xFF000010
    40 void set_tlb_enabled( int flag )
    41 {
    42     uint32_t val = long_read( MMUCR );
    43     if( flag ) {
    44         val |= 1;
    45     } else {
    46         val &= ~1;
    47     }
    48     long_write( MMUCR, val );
    49 }
    51 void invalidate_tlb()
    52 {
    53     uint32_t val = long_read( MMUCR );
    54     long_write( MMUCR, val | 4 );
    55 }
    57 void set_sv_enabled( int flag )
    58 {
    59     uint32_t val = long_read( MMUCR );
    60     if( flag ) {
    61         val |= 0x100;
    62     } else {
    63         val &= ~0x100;
    64     }
    65     long_write( MMUCR, val );
    66 }
    68 void set_storequeue_protected( int flag ) 
    69 {
    70     uint32_t val = long_read( MMUCR );
    71     if( flag ) {
    72         val |= 0x200;
    73     } else {
    74         val &= ~0x200;
    75     }
    76     long_write( MMUCR, val );
    77 }
    80 void set_asid( int asid )
    81 {
    82     uint32_t val = long_read( PTEH ) & 0xFFFFFF00;
    83     long_write( PTEH, val | asid );
    84 }
    87 void load_utlb_entry( int entryNo, uint32_t vpn, uint32_t ppn, int asid, uint32_t mode )
    88 {
    89     long_write( (0xF6000000 | (entryNo<<8)), vpn | asid );
    90     long_write( (0xF7000000 | (entryNo<<8)), ppn | mode );
    91 }
    94 void check_utlb_access( uint32_t addr, uint32_t direct_addr, int mode ) 
    95 {
    98 }
.