Search
lxdream.org :: lxdream/test/sh4/utlb.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/sh4/utlb.c
changeset 1022:43f35b12ece7
prev976:e57a25d9eb7d
author nkeynes
date Wed Jun 03 11:39:06 2009 +0000 (12 years ago)
permissions -rw-r--r--
last change Add missing svn:keywords properties
file annotate diff log raw
nkeynes@976
     1
/**
nkeynes@1022
     2
 * $Id$
nkeynes@976
     3
 * 
nkeynes@976
     4
 * UTLB unit test support
nkeynes@976
     5
 *
nkeynes@976
     6
 * Copyright (c) 2006 Nathan Keynes.
nkeynes@976
     7
 *
nkeynes@976
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@976
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@976
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@976
    11
 * (at your option) any later version.
nkeynes@976
    12
 *
nkeynes@976
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@976
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@976
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@976
    16
 * GNU General Public License for more details.
nkeynes@976
    17
 */
nkeynes@976
    18
nkeynes@976
    19
#include <assert.h>
nkeynes@976
    20
#include "utlb.h"
nkeynes@976
    21
#include "../lib.h"
nkeynes@976
    22
nkeynes@976
    23
#define TLB_VALID     0x00000100
nkeynes@976
    24
#define TLB_USERMODE  0x00000040
nkeynes@976
    25
#define TLB_WRITABLE  0x00000020
nkeynes@976
    26
#define TLB_SIZE_1K   0x00000000
nkeynes@976
    27
#define TLB_SIZE_4K   0x00000010
nkeynes@976
    28
#define TLB_SIZE_64K  0x00000080
nkeynes@976
    29
#define TLB_SIZE_1M   0x00000090
nkeynes@976
    30
#define TLB_CACHEABLE 0x00000008
nkeynes@976
    31
#define TLB_DIRTY     0x00000004
nkeynes@976
    32
#define TLB_SHARE     0x00000002
nkeynes@976
    33
#define TLB_WRITETHRU 0x00000001
nkeynes@976
    34
nkeynes@976
    35
#define PTEH  0xFF000000
nkeynes@976
    36
#define PTEL  0xFF000004
nkeynes@976
    37
#define TEA   0xFF00000C
nkeynes@976
    38
#define MMUCR 0xFF000010
nkeynes@976
    39
nkeynes@976
    40
void set_tlb_enabled( int flag )
nkeynes@976
    41
{
nkeynes@976
    42
    uint32_t val = long_read( MMUCR );
nkeynes@976
    43
    if( flag ) {
nkeynes@976
    44
        val |= 1;
nkeynes@976
    45
    } else {
nkeynes@976
    46
        val &= ~1;
nkeynes@976
    47
    }
nkeynes@976
    48
    long_write( MMUCR, val );
nkeynes@976
    49
}
nkeynes@976
    50
nkeynes@976
    51
void invalidate_tlb()
nkeynes@976
    52
{
nkeynes@976
    53
    uint32_t val = long_read( MMUCR );
nkeynes@976
    54
    long_write( MMUCR, val | 4 );
nkeynes@976
    55
}
nkeynes@976
    56
nkeynes@976
    57
void set_sv_enabled( int flag )
nkeynes@976
    58
{
nkeynes@976
    59
    uint32_t val = long_read( MMUCR );
nkeynes@976
    60
    if( flag ) {
nkeynes@976
    61
        val |= 0x100;
nkeynes@976
    62
    } else {
nkeynes@976
    63
        val &= ~0x100;
nkeynes@976
    64
    }
nkeynes@976
    65
    long_write( MMUCR, val );
nkeynes@976
    66
}
nkeynes@976
    67
nkeynes@976
    68
void set_storequeue_protected( int flag ) 
nkeynes@976
    69
{
nkeynes@976
    70
    uint32_t val = long_read( MMUCR );
nkeynes@976
    71
    if( flag ) {
nkeynes@976
    72
        val |= 0x200;
nkeynes@976
    73
    } else {
nkeynes@976
    74
        val &= ~0x200;
nkeynes@976
    75
    }
nkeynes@976
    76
    long_write( MMUCR, val );
nkeynes@976
    77
}
nkeynes@976
    78
    
nkeynes@976
    79
nkeynes@976
    80
void set_asid( int asid )
nkeynes@976
    81
{
nkeynes@976
    82
    uint32_t val = long_read( PTEH ) & 0xFFFFFF00;
nkeynes@976
    83
    long_write( PTEH, val | asid );
nkeynes@976
    84
}
nkeynes@976
    85
nkeynes@976
    86
nkeynes@976
    87
void load_utlb_entry( int entryNo, uint32_t vpn, uint32_t ppn, int asid, uint32_t mode )
nkeynes@976
    88
{
nkeynes@976
    89
    long_write( (0xF6000000 | (entryNo<<8)), vpn | asid );
nkeynes@976
    90
    long_write( (0xF7000000 | (entryNo<<8)), ppn | mode );
nkeynes@976
    91
}
nkeynes@976
    92
nkeynes@976
    93
nkeynes@976
    94
void check_utlb_access( uint32_t addr, uint32_t direct_addr, int mode ) 
nkeynes@976
    95
{
nkeynes@976
    96
    
nkeynes@976
    97
    
nkeynes@976
    98
}
nkeynes@976
    99
.