nkeynes@359: /** nkeynes@359: * $Id: xltcache.h,v 1.1 2007-08-23 12:33:27 nkeynes Exp $ nkeynes@359: * nkeynes@359: * Translation cache support (architecture independent) nkeynes@359: * nkeynes@359: * Copyright (c) 2005 Nathan Keynes. nkeynes@359: * nkeynes@359: * This program is free software; you can redistribute it and/or modify nkeynes@359: * it under the terms of the GNU General Public License as published by nkeynes@359: * the Free Software Foundation; either version 2 of the License, or nkeynes@359: * (at your option) any later version. nkeynes@359: * nkeynes@359: * This program is distributed in the hope that it will be useful, nkeynes@359: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@359: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@359: * GNU General Public License for more details. nkeynes@359: */ nkeynes@359: nkeynes@359: #include "dream.h" nkeynes@359: #include "mem.h" nkeynes@359: nkeynes@359: typedef struct xlat_cache_block { nkeynes@359: int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */ nkeynes@359: uint32_t size; nkeynes@359: void **lut_entry; /* For deletion */ nkeynes@359: unsigned char code[0]; nkeynes@359: } *xlat_cache_block_t; nkeynes@359: nkeynes@359: /** nkeynes@359: * Returns the next block in the new cache list that can be written to by the nkeynes@359: * translator. nkeynes@359: */ nkeynes@359: xlat_cache_block_t xlat_start_block(sh4addr_t address); nkeynes@359: nkeynes@359: /** nkeynes@359: * Increases the current block size (only valid between calls to xlat_start_block() nkeynes@359: * and xlat_commit_block()). nkeynes@359: * @return the new block, which may be different from the old block. nkeynes@359: */ nkeynes@359: xlat_cache_block_t xlat_extend_block(); nkeynes@359: nkeynes@359: /** nkeynes@359: * Commit the current translation block nkeynes@359: * @param addr target address (for the lookup table) nkeynes@359: * @param destsize final size of the translation in bytes. nkeynes@359: * @param srcsize size of the original data that was translated in bytes nkeynes@359: */ nkeynes@359: void xlat_commit_block( uint32_t destsize, uint32_t srcsize ); nkeynes@359: nkeynes@359: /** nkeynes@359: * Delete (deactivate) the specified block from the cache. Caller is responsible nkeynes@359: * for ensuring that there really is a block there. nkeynes@359: */ nkeynes@359: void xlat_delete_block( xlat_cache_block_t block ); nkeynes@359: nkeynes@359: /** nkeynes@359: * Retrieve the entry point for the translated code corresponding to the given nkeynes@359: * SH4 address, or NULL if there is no code for that address. nkeynes@359: */ nkeynes@359: void *xlat_get_code( sh4addr_t address ); nkeynes@359: nkeynes@359: /** nkeynes@359: * Flush the code cache for the page containing the given address nkeynes@359: */ nkeynes@359: void xlat_flush_page( sh4addr_t address ); nkeynes@359: nkeynes@359: /** nkeynes@359: * Flush the entire code cache. This isn't as cheap as one might like nkeynes@359: */ nkeynes@359: void xlat_flush_cache(); nkeynes@359: nkeynes@359: /** nkeynes@359: * Check the internal integrity of the cache nkeynes@359: */ nkeynes@359: void xlat_check_integrity();