--- a/src/sh4/xltcache.h Fri Jan 04 11:54:17 2008 +0000 +++ b/src/sh4/xltcache.h Thu Jan 10 08:28:37 2008 +0000 @@ -19,10 +19,30 @@ #include "dream.h" #include "mem.h" +#ifndef lxdream_xltcache_H +#define lxdream_xltcache_H + +/** + * For now, recovery is purely a matter of mapping native pc => sh4 pc, + * and updating sh4r.pc & sh4r.slice_cycles accordingly. In future more + * detailed recovery may be required if the translator optimizes more + * agressively. + * + * The recovery table contains (at least) one entry per abortable instruction, + * + */ +typedef struct xlat_recovery_record { + uintptr_t xlat_pc; // native (translated) pc + uint32_t sh4_icount; // instruction number of the corresponding SH4 instruction + // (0 = first instruction, 1 = second instruction, ... ) +} *xlat_recovery_record_t; + typedef struct xlat_cache_block { int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */ uint32_t size; void **lut_entry; /* For deletion */ + xlat_recovery_record_t recover_table; + uint32_t recover_table_size; unsigned char code[0]; } *xlat_cache_block_t; @@ -74,6 +94,17 @@ void *xlat_get_code( sh4addr_t address ); /** + * Retrieve the recovery record corresponding to the given + * native address, or NULL if there is no recovery code for the address. + * @param code The code block containing the recovery table. + * @param native_pc A pointer that must be within the currently executing + * @param recover_after If TRUE, return the first record after the given pc, otherwise + * return the first record before or equal to the given pc. + * translation block. + */ +struct xlat_recovery_record *xlat_get_recovery( void *code, void *native_pc, gboolean recover_after ); + +/** * Retrieve the entry point for the translated code corresponding to the given * SH4 virtual address, or NULL if there is no code for the address. * If the virtual address cannot be resolved, this method will raise a TLB miss @@ -88,12 +119,28 @@ void **xlat_get_lut_entry( sh4addr_t address ); /** - * Retrieve the size of the code block starting at the specified pointer. If the + * Retrieve the current host address of the running translated code block. + * @return the host PC, or null if there is no currently executing translated + * block (or the stack is corrupted) + * Note: this method is implemented in host-specific asm. + */ +void *xlat_get_native_pc(); + +/** + * Retrieve the size of the block starting at the specified pointer. If the * pointer is not a valid code block, the return value is undefined. */ uint32_t xlat_get_block_size( void *ptr ); /** + * Retrieve the size of the code in the block starting at the specified + * pointer. Effectively this is xlat_get_block_size() minus the size of + * the recovery table. If the pointer is not a valid code block, the + * return value is undefined. + */ +uint32_t xlat_get_code_size( void *ptr ); + +/** * Flush the code cache for the page containing the given address */ void xlat_flush_page( sh4addr_t address ); @@ -116,3 +163,5 @@ * Check the internal integrity of the cache */ void xlat_check_integrity(); + +#endif /* lxdream_xltcache_H */