2 * $Id: xltcache.h,v 1.4 2007-09-20 08:35:04 nkeynes Exp $
4 * Translation cache support (architecture independent)
6 * Copyright (c) 2005 Nathan Keynes.
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.
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.
22 typedef struct xlat_cache_block {
23 int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
25 void **lut_entry; /* For deletion */
26 unsigned char code[0];
27 } *xlat_cache_block_t;
30 * Returns the next block in the new cache list that can be written to by the
33 xlat_cache_block_t xlat_start_block(sh4addr_t address);
36 * Increases the current block size (only valid between calls to xlat_start_block()
37 * and xlat_commit_block()).
38 * @return the new block, which may be different from the old block.
40 xlat_cache_block_t xlat_extend_block();
43 * Commit the current translation block
44 * @param addr target address (for the lookup table)
45 * @param destsize final size of the translation in bytes.
46 * @param srcsize size of the original data that was translated in bytes
48 void xlat_commit_block( uint32_t destsize, uint32_t srcsize );
51 * Dump the disassembly of the specified code block to a stream
52 * (primarily for debugging purposes)
53 * @param out The stream to write the output to
54 * @param code a translated block
56 void xlat_disasm_block( FILE *out, void *code );
60 * Delete (deactivate) the specified block from the cache. Caller is responsible
61 * for ensuring that there really is a block there.
63 void xlat_delete_block( xlat_cache_block_t block );
66 * Retrieve the entry point for the translated code corresponding to the given
67 * SH4 address, or NULL if there is no code for that address.
69 void *xlat_get_code( sh4addr_t address );
72 * Retrieve the size of the code block starting at the specified pointer. If the
73 * pointer is not a valid code block, the return value is undefined.
75 uint32_t xlat_get_block_size( void *ptr );
78 * Flush the code cache for the page containing the given address
80 void xlat_flush_page( sh4addr_t address );
82 void xlat_invalidate_word( sh4addr_t address );
83 void xlat_invalidate_long( sh4addr_t address );
87 * Invalidate the code cache for a memory region
89 void xlat_invalidate_block( sh4addr_t address, size_t bytes );
92 * Flush the entire code cache. This isn't as cheap as one might like
94 void xlat_flush_cache();
97 * Check the internal integrity of the cache
99 void xlat_check_integrity();
.