Search
lxdream.org :: lxdream/src/sh4/xltcache.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.h
changeset 571:9bc09948d0f2
prev569:a1c49e1e8776
next580:508dc852a8eb
author nkeynes
date Thu Jan 10 08:28:37 2008 +0000 (13 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change More MMU work in progess. Much better now...
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.h Fri Jan 04 11:54:17 2008 +0000
1.2 +++ b/src/sh4/xltcache.h Thu Jan 10 08:28:37 2008 +0000
1.3 @@ -19,10 +19,30 @@
1.4 #include "dream.h"
1.5 #include "mem.h"
1.6
1.7 +#ifndef lxdream_xltcache_H
1.8 +#define lxdream_xltcache_H
1.9 +
1.10 +/**
1.11 + * For now, recovery is purely a matter of mapping native pc => sh4 pc,
1.12 + * and updating sh4r.pc & sh4r.slice_cycles accordingly. In future more
1.13 + * detailed recovery may be required if the translator optimizes more
1.14 + * agressively.
1.15 + *
1.16 + * The recovery table contains (at least) one entry per abortable instruction,
1.17 + *
1.18 + */
1.19 +typedef struct xlat_recovery_record {
1.20 + uintptr_t xlat_pc; // native (translated) pc
1.21 + uint32_t sh4_icount; // instruction number of the corresponding SH4 instruction
1.22 + // (0 = first instruction, 1 = second instruction, ... )
1.23 +} *xlat_recovery_record_t;
1.24 +
1.25 typedef struct xlat_cache_block {
1.26 int active; /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
1.27 uint32_t size;
1.28 void **lut_entry; /* For deletion */
1.29 + xlat_recovery_record_t recover_table;
1.30 + uint32_t recover_table_size;
1.31 unsigned char code[0];
1.32 } *xlat_cache_block_t;
1.33
1.34 @@ -74,6 +94,17 @@
1.35 void *xlat_get_code( sh4addr_t address );
1.36
1.37 /**
1.38 + * Retrieve the recovery record corresponding to the given
1.39 + * native address, or NULL if there is no recovery code for the address.
1.40 + * @param code The code block containing the recovery table.
1.41 + * @param native_pc A pointer that must be within the currently executing
1.42 + * @param recover_after If TRUE, return the first record after the given pc, otherwise
1.43 + * return the first record before or equal to the given pc.
1.44 + * translation block.
1.45 + */
1.46 +struct xlat_recovery_record *xlat_get_recovery( void *code, void *native_pc, gboolean recover_after );
1.47 +
1.48 +/**
1.49 * Retrieve the entry point for the translated code corresponding to the given
1.50 * SH4 virtual address, or NULL if there is no code for the address.
1.51 * If the virtual address cannot be resolved, this method will raise a TLB miss
1.52 @@ -88,12 +119,28 @@
1.53 void **xlat_get_lut_entry( sh4addr_t address );
1.54
1.55 /**
1.56 - * Retrieve the size of the code block starting at the specified pointer. If the
1.57 + * Retrieve the current host address of the running translated code block.
1.58 + * @return the host PC, or null if there is no currently executing translated
1.59 + * block (or the stack is corrupted)
1.60 + * Note: this method is implemented in host-specific asm.
1.61 + */
1.62 +void *xlat_get_native_pc();
1.63 +
1.64 +/**
1.65 + * Retrieve the size of the block starting at the specified pointer. If the
1.66 * pointer is not a valid code block, the return value is undefined.
1.67 */
1.68 uint32_t xlat_get_block_size( void *ptr );
1.69
1.70 /**
1.71 + * Retrieve the size of the code in the block starting at the specified
1.72 + * pointer. Effectively this is xlat_get_block_size() minus the size of
1.73 + * the recovery table. If the pointer is not a valid code block, the
1.74 + * return value is undefined.
1.75 + */
1.76 +uint32_t xlat_get_code_size( void *ptr );
1.77 +
1.78 +/**
1.79 * Flush the code cache for the page containing the given address
1.80 */
1.81 void xlat_flush_page( sh4addr_t address );
1.82 @@ -116,3 +163,5 @@
1.83 * Check the internal integrity of the cache
1.84 */
1.85 void xlat_check_integrity();
1.86 +
1.87 +#endif /* lxdream_xltcache_H */
.