filename | src/sh4/xltcache.h |
changeset | 376:8c7587af5a5d |
prev | 366:6fb0d05152d7 |
next | 400:049d72a7a229 |
author | nkeynes |
date | Wed Sep 12 11:31:16 2007 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Fix load_spreg/store_spreg Fix PREF Add jump target debug checking |
file | annotate | diff | log | raw |
nkeynes@359 | 1 | /** |
nkeynes@376 | 2 | * $Id: xltcache.h,v 1.3 2007-09-12 09:16:47 nkeynes Exp $ |
nkeynes@359 | 3 | * |
nkeynes@359 | 4 | * Translation cache support (architecture independent) |
nkeynes@359 | 5 | * |
nkeynes@359 | 6 | * Copyright (c) 2005 Nathan Keynes. |
nkeynes@359 | 7 | * |
nkeynes@359 | 8 | * This program is free software; you can redistribute it and/or modify |
nkeynes@359 | 9 | * it under the terms of the GNU General Public License as published by |
nkeynes@359 | 10 | * the Free Software Foundation; either version 2 of the License, or |
nkeynes@359 | 11 | * (at your option) any later version. |
nkeynes@359 | 12 | * |
nkeynes@359 | 13 | * This program is distributed in the hope that it will be useful, |
nkeynes@359 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
nkeynes@359 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
nkeynes@359 | 16 | * GNU General Public License for more details. |
nkeynes@359 | 17 | */ |
nkeynes@359 | 18 | |
nkeynes@359 | 19 | #include "dream.h" |
nkeynes@359 | 20 | #include "mem.h" |
nkeynes@359 | 21 | |
nkeynes@359 | 22 | typedef struct xlat_cache_block { |
nkeynes@359 | 23 | int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */ |
nkeynes@359 | 24 | uint32_t size; |
nkeynes@359 | 25 | void **lut_entry; /* For deletion */ |
nkeynes@359 | 26 | unsigned char code[0]; |
nkeynes@359 | 27 | } *xlat_cache_block_t; |
nkeynes@359 | 28 | |
nkeynes@359 | 29 | /** |
nkeynes@359 | 30 | * Returns the next block in the new cache list that can be written to by the |
nkeynes@359 | 31 | * translator. |
nkeynes@359 | 32 | */ |
nkeynes@359 | 33 | xlat_cache_block_t xlat_start_block(sh4addr_t address); |
nkeynes@359 | 34 | |
nkeynes@359 | 35 | /** |
nkeynes@359 | 36 | * Increases the current block size (only valid between calls to xlat_start_block() |
nkeynes@359 | 37 | * and xlat_commit_block()). |
nkeynes@359 | 38 | * @return the new block, which may be different from the old block. |
nkeynes@359 | 39 | */ |
nkeynes@359 | 40 | xlat_cache_block_t xlat_extend_block(); |
nkeynes@359 | 41 | |
nkeynes@359 | 42 | /** |
nkeynes@359 | 43 | * Commit the current translation block |
nkeynes@359 | 44 | * @param addr target address (for the lookup table) |
nkeynes@359 | 45 | * @param destsize final size of the translation in bytes. |
nkeynes@359 | 46 | * @param srcsize size of the original data that was translated in bytes |
nkeynes@359 | 47 | */ |
nkeynes@359 | 48 | void xlat_commit_block( uint32_t destsize, uint32_t srcsize ); |
nkeynes@359 | 49 | |
nkeynes@359 | 50 | /** |
nkeynes@376 | 51 | * Dump the disassembly of the specified code block to a stream |
nkeynes@376 | 52 | * (primarily for debugging purposes) |
nkeynes@376 | 53 | * @param out The stream to write the output to |
nkeynes@376 | 54 | * @param code a translated block |
nkeynes@376 | 55 | */ |
nkeynes@376 | 56 | void xlat_disasm_block( FILE *out, void *code ); |
nkeynes@376 | 57 | |
nkeynes@376 | 58 | |
nkeynes@376 | 59 | /** |
nkeynes@359 | 60 | * Delete (deactivate) the specified block from the cache. Caller is responsible |
nkeynes@359 | 61 | * for ensuring that there really is a block there. |
nkeynes@359 | 62 | */ |
nkeynes@359 | 63 | void xlat_delete_block( xlat_cache_block_t block ); |
nkeynes@359 | 64 | |
nkeynes@359 | 65 | /** |
nkeynes@359 | 66 | * Retrieve the entry point for the translated code corresponding to the given |
nkeynes@359 | 67 | * SH4 address, or NULL if there is no code for that address. |
nkeynes@359 | 68 | */ |
nkeynes@359 | 69 | void *xlat_get_code( sh4addr_t address ); |
nkeynes@359 | 70 | |
nkeynes@359 | 71 | /** |
nkeynes@366 | 72 | * Retrieve the size of the code block starting at the specified pointer. If the |
nkeynes@366 | 73 | * pointer is not a valid code block, the return value is undefined. |
nkeynes@366 | 74 | */ |
nkeynes@366 | 75 | uint32_t xlat_get_block_size( void *ptr ); |
nkeynes@366 | 76 | |
nkeynes@366 | 77 | /** |
nkeynes@359 | 78 | * Flush the code cache for the page containing the given address |
nkeynes@359 | 79 | */ |
nkeynes@359 | 80 | void xlat_flush_page( sh4addr_t address ); |
nkeynes@359 | 81 | |
nkeynes@359 | 82 | /** |
nkeynes@359 | 83 | * Flush the entire code cache. This isn't as cheap as one might like |
nkeynes@359 | 84 | */ |
nkeynes@359 | 85 | void xlat_flush_cache(); |
nkeynes@359 | 86 | |
nkeynes@359 | 87 | /** |
nkeynes@359 | 88 | * Check the internal integrity of the cache |
nkeynes@359 | 89 | */ |
nkeynes@359 | 90 | void xlat_check_integrity(); |
.