Search
lxdream.org :: lxdream/src/sh4/xltcache.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.h
changeset 569:a1c49e1e8776
prev561:533f6b478071
next571:9bc09948d0f2
author nkeynes
date Fri Jan 04 11:54:17 2008 +0000 (15 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Bring icache partially into line with the mmu, a little less slow with AT off
now.
view annotate diff log raw
     1 /**
     2  * $Id$
     3  * 
     4  * Translation cache support (architecture independent)
     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 "dream.h"
    20 #include "mem.h"
    22 typedef struct xlat_cache_block {
    23     int active;  /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
    24     uint32_t size;
    25     void **lut_entry; /* For deletion */
    26     unsigned char code[0];
    27 } *xlat_cache_block_t;
    29 /**
    30  * Initialize the translation cache
    31  */
    32 void xlat_cache_init(void);
    34 /**
    35  * Returns the next block in the new cache list that can be written to by the
    36  * translator.
    37  */
    38 xlat_cache_block_t xlat_start_block(sh4addr_t address);
    40 /**
    41  * Increases the current block size (only valid between calls to xlat_start_block()
    42  * and xlat_commit_block()). 
    43  * @return the new block, which may be different from the old block.
    44  */
    45 xlat_cache_block_t xlat_extend_block( uint32_t newSize );
    47 /**
    48  * Commit the current translation block
    49  * @param addr target address (for the lookup table)
    50  * @param destsize final size of the translation in bytes.
    51  * @param srcsize size of the original data that was translated in bytes
    52  */
    53 void xlat_commit_block( uint32_t destsize, uint32_t srcsize );
    55 /**
    56  * Dump the disassembly of the specified code block to a stream
    57  * (primarily for debugging purposes)
    58  * @param out The stream to write the output to
    59  * @param code a translated block
    60  */
    61 void xlat_disasm_block( FILE *out, void *code );
    64 /**
    65  * Delete (deactivate) the specified block from the cache. Caller is responsible
    66  * for ensuring that there really is a block there.
    67  */
    68 void xlat_delete_block( xlat_cache_block_t block );
    70 /**
    71  * Retrieve the entry point for the translated code corresponding to the given
    72  * SH4 address, or NULL if there is no code for that address.
    73  */
    74 void *xlat_get_code( sh4addr_t address );
    76 /**
    77  * Retrieve the entry point for the translated code corresponding to the given
    78  * SH4 virtual address, or NULL if there is no code for the address. 
    79  * If the virtual address cannot be resolved, this method will raise a TLB miss 
    80  * exception, and return NULL.
    81  */
    82 void *xlat_get_code_by_vma( sh4vma_t address );
    84 /**
    85  * Retrieve the address of the lookup table entry corresponding to the
    86  * given SH4 address.
    87  */
    88 void **xlat_get_lut_entry( sh4addr_t address );
    90 /**
    91  * Retrieve the size of the code block starting at the specified pointer. If the
    92  * pointer is not a valid code block, the return value is undefined.
    93  */
    94 uint32_t xlat_get_block_size( void *ptr );
    96 /**
    97  * Flush the code cache for the page containing the given address
    98  */
    99 void xlat_flush_page( sh4addr_t address );
   101 void xlat_invalidate_word( sh4addr_t address );
   102 void xlat_invalidate_long( sh4addr_t address );
   105 /**
   106  * Invalidate the code cache for a memory region
   107  */
   108 void xlat_invalidate_block( sh4addr_t address, size_t bytes );
   110 /**
   111  * Flush the entire code cache. This isn't as cheap as one might like
   112  */
   113 void xlat_flush_cache();
   115 /**
   116  * Check the internal integrity of the cache
   117  */
   118 void xlat_check_integrity();
.