Search
lxdream.org :: lxdream/src/sh4/xltcache.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.h
changeset 586:2a3ba82cf243
prev422:61a0598e07ff
next592:4343cbfdd21b
author nkeynes
date Tue Jan 15 20:50:23 2008 +0000 (13 years ago)
permissions -rw-r--r--
last change Merged lxdream-mmu r570:596 to trunk
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.h Sat Oct 06 09:03:24 2007 +0000
1.2 +++ b/src/sh4/xltcache.h Tue Jan 15 20:50:23 2008 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: xltcache.h,v 1.7 2007-10-06 09:03:24 nkeynes Exp $
1.6 + * $Id$
1.7 *
1.8 * Translation cache support (architecture independent)
1.9 *
1.10 @@ -19,12 +19,34 @@
1.11 #include "dream.h"
1.12 #include "mem.h"
1.13
1.14 -typedef struct xlat_cache_block {
1.15 +#ifndef lxdream_xltcache_H
1.16 +#define lxdream_xltcache_H
1.17 +
1.18 +/**
1.19 + * For now, recovery is purely a matter of mapping native pc => sh4 pc,
1.20 + * and updating sh4r.pc & sh4r.slice_cycles accordingly. In future more
1.21 + * detailed recovery may be required if the translator optimizes more
1.22 + * agressively.
1.23 + *
1.24 + * The recovery table contains (at least) one entry per abortable instruction,
1.25 + *
1.26 + */
1.27 +typedef struct xlat_recovery_record {
1.28 + uintptr_t xlat_pc; // native (translated) pc
1.29 + uint32_t sh4_icount; // instruction number of the corresponding SH4 instruction
1.30 + // (0 = first instruction, 1 = second instruction, ... )
1.31 +} *xlat_recovery_record_t;
1.32 +
1.33 +struct xlat_cache_block {
1.34 int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
1.35 uint32_t size;
1.36 void **lut_entry; /* For deletion */
1.37 + xlat_recovery_record_t recover_table;
1.38 + uint32_t recover_table_size;
1.39 unsigned char code[0];
1.40 -} *xlat_cache_block_t;
1.41 +} __attribute__((packed));
1.42 +
1.43 +typedef struct xlat_cache_block *xlat_cache_block_t;
1.44
1.45 /**
1.46 * Initialize the translation cache
1.47 @@ -74,18 +96,53 @@
1.48 void *xlat_get_code( sh4addr_t address );
1.49
1.50 /**
1.51 + * Retrieve the recovery record corresponding to the given
1.52 + * native address, or NULL if there is no recovery code for the address.
1.53 + * @param code The code block containing the recovery table.
1.54 + * @param native_pc A pointer that must be within the currently executing
1.55 + * @param recover_after If TRUE, return the first record after the given pc, otherwise
1.56 + * return the first record before or equal to the given pc.
1.57 + * translation block.
1.58 + */
1.59 +struct xlat_recovery_record *xlat_get_recovery( void *code, void *native_pc, gboolean recover_after );
1.60 +
1.61 +/**
1.62 + * Retrieve the entry point for the translated code corresponding to the given
1.63 + * SH4 virtual address, or NULL if there is no code for the address.
1.64 + * If the virtual address cannot be resolved, this method will raise a TLB miss
1.65 + * exception, and return NULL.
1.66 + */
1.67 +void *xlat_get_code_by_vma( sh4vma_t address );
1.68 +
1.69 +/**
1.70 * Retrieve the address of the lookup table entry corresponding to the
1.71 * given SH4 address.
1.72 */
1.73 void **xlat_get_lut_entry( sh4addr_t address );
1.74
1.75 /**
1.76 - * Retrieve the size of the code block starting at the specified pointer. If the
1.77 + * Retrieve the current host address of the running translated code block.
1.78 + * @return the host PC, or null if there is no currently executing translated
1.79 + * block (or the stack is corrupted)
1.80 + * Note: this method is implemented in host-specific asm.
1.81 + */
1.82 +void *xlat_get_native_pc();
1.83 +
1.84 +/**
1.85 + * Retrieve the size of the block starting at the specified pointer. If the
1.86 * pointer is not a valid code block, the return value is undefined.
1.87 */
1.88 uint32_t xlat_get_block_size( void *ptr );
1.89
1.90 /**
1.91 + * Retrieve the size of the code in the block starting at the specified
1.92 + * pointer. Effectively this is xlat_get_block_size() minus the size of
1.93 + * the recovery table. If the pointer is not a valid code block, the
1.94 + * return value is undefined.
1.95 + */
1.96 +uint32_t xlat_get_code_size( void *ptr );
1.97 +
1.98 +/**
1.99 * Flush the code cache for the page containing the given address
1.100 */
1.101 void xlat_flush_page( sh4addr_t address );
1.102 @@ -108,3 +165,5 @@
1.103 * Check the internal integrity of the cache
1.104 */
1.105 void xlat_check_integrity();
1.106 +
1.107 +#endif /* lxdream_xltcache_H */
.