njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- The translation table and cache. ---*/ |
| 4 | /*--- pub_core_transtab.h ---*/ |
| 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
| 8 | This file is part of Valgrind, a dynamic binary instrumentation |
| 9 | framework. |
| 10 | |
sewardj | 4d474d0 | 2008-02-11 11:34:59 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2008 Julian Seward |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 12 | jseward@acm.org |
| 13 | |
| 14 | This program is free software; you can redistribute it and/or |
| 15 | modify it under the terms of the GNU General Public License as |
| 16 | published by the Free Software Foundation; either version 2 of the |
| 17 | License, or (at your option) any later version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but |
| 20 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program; if not, write to the Free Software |
| 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 27 | 02111-1307, USA. |
| 28 | |
| 29 | The GNU General Public License is contained in the file COPYING. |
| 30 | */ |
| 31 | |
| 32 | #ifndef __PUB_CORE_TRANSTAB_H |
| 33 | #define __PUB_CORE_TRANSTAB_H |
| 34 | |
| 35 | //-------------------------------------------------------------------- |
| 36 | // PURPOSE: This module is responsible for caching translations, and |
| 37 | // enabling fast look-ups of them. |
| 38 | //-------------------------------------------------------------------- |
| 39 | |
njn | 2e8f4ef | 2005-05-14 21:44:20 +0000 | [diff] [blame] | 40 | #include "pub_core_transtab_asm.h" |
| 41 | |
sewardj | 5f76de0 | 2007-02-11 05:08:06 +0000 | [diff] [blame] | 42 | /* The fast-cache for tt-lookup, and for finding counters. Unused |
| 43 | entries are denoted by .guest == 1, which is assumed to be a bogus |
| 44 | address for all guest code. */ |
| 45 | typedef |
| 46 | struct { |
| 47 | Addr guest; |
| 48 | Addr host; |
| 49 | } |
| 50 | FastCacheEntry; |
| 51 | |
| 52 | extern __attribute__((aligned(16))) |
| 53 | FastCacheEntry VG_(tt_fast) [VG_TT_FAST_SIZE]; |
| 54 | |
| 55 | #define TRANSTAB_BOGUS_GUEST_ADDR ((Addr)1) |
| 56 | |
| 57 | extern UInt* VG_(tt_fastN)[VG_TT_FAST_SIZE]; |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 58 | |
| 59 | extern void VG_(init_tt_tc) ( void ); |
| 60 | |
| 61 | extern |
| 62 | void VG_(add_to_transtab)( VexGuestExtents* vge, |
| 63 | Addr64 entry, |
| 64 | AddrH code, |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 65 | UInt code_len, |
| 66 | Bool is_self_checking ); |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 67 | |
| 68 | extern Bool VG_(search_transtab) ( /*OUT*/AddrH* result, |
| 69 | Addr64 guest_addr, |
| 70 | Bool upd_cache ); |
| 71 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 72 | extern void VG_(discard_translations) ( Addr64 start, ULong range, |
| 73 | HChar* who ); |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 74 | |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 75 | extern void VG_(print_tt_tc_stats) ( void ); |
| 76 | |
| 77 | extern UInt VG_(get_bbs_translated) ( void ); |
| 78 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 79 | /* Add to / search the auxiliary, small, unredirected translation |
| 80 | table. */ |
| 81 | |
| 82 | extern |
| 83 | void VG_(add_to_unredir_transtab)( VexGuestExtents* vge, |
| 84 | Addr64 entry, |
| 85 | AddrH code, |
| 86 | UInt code_len, |
| 87 | Bool is_self_checking ); |
| 88 | extern |
| 89 | Bool VG_(search_unredir_transtab) ( /*OUT*/AddrH* result, |
| 90 | Addr64 guest_addr ); |
| 91 | |
njn | 2025cf9 | 2005-06-26 20:44:48 +0000 | [diff] [blame] | 92 | // BB profiling stuff |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 93 | |
njn | 2025cf9 | 2005-06-26 20:44:48 +0000 | [diff] [blame] | 94 | typedef struct _BBProfEntry { |
| 95 | Addr64 addr; |
| 96 | ULong score; |
| 97 | } BBProfEntry; |
| 98 | |
| 99 | extern ULong VG_(get_BB_profile) ( BBProfEntry tops[], UInt n_tops ); |
njn | 8bddf58 | 2005-05-13 23:40:55 +0000 | [diff] [blame] | 100 | |
| 101 | #endif // __PUB_CORE_TRANSTAB_H |
| 102 | |
| 103 | /*--------------------------------------------------------------------*/ |
| 104 | /*--- end ---*/ |
| 105 | /*--------------------------------------------------------------------*/ |