Search
lxdream.org :: lxdream/src/sh4/sh4trans.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4trans.h
changeset 586:2a3ba82cf243
prev527:14c9489f647e
next591:7b9612fd2395
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/sh4trans.h Sun Nov 18 11:12:44 2007 +0000
1.2 +++ b/src/sh4/sh4trans.h Tue Jan 15 20:50:23 2008 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: sh4trans.h,v 1.4 2007-09-29 11:06:40 nkeynes Exp $
1.6 + * $Id$
1.7 *
1.8 * SH4->x86 translation module
1.9 *
1.10 @@ -16,6 +16,7 @@
1.11 * GNU General Public License for more details.
1.12 */
1.13
1.14 +#include "sh4/xltcache.h"
1.15 #include "dream.h"
1.16 #include "mem.h"
1.17
1.18 @@ -27,18 +28,53 @@
1.19 * allows a little room
1.20 */
1.21 #define EPILOGUE_SIZE 128
1.22 +
1.23 +/** Maximum number of recovery records for a translated block (2048 based on
1.24 + * 1 record per SH4 instruction in a 4K page).
1.25 + */
1.26 +#define MAX_RECOVERY_SIZE 2048
1.27 +
1.28 /**
1.29 + * Translation flag - exit the current block but continue (eg exception handling)
1.30 + */
1.31 +#define XLAT_EXIT_CONTINUE 1
1.32
1.33 +/**
1.34 + * Translation flag - exit the current block and halt immediately (eg fatal error)
1.35 + */
1.36 +#define XLAT_EXIT_HALT 2
1.37 +
1.38 +/**
1.39 + * Translation flag - exit the current block and halt immediately for a system
1.40 + * breakpoint.
1.41 + */
1.42 +#define XLAT_EXIT_BREAKPOINT 3
1.43 +
1.44 +/**
1.45 + * Translation flag - exit the current block and continue after performing a full
1.46 + * system reset (dreamcast_reset())
1.47 + */
1.48 +#define XLAT_EXIT_SYSRESET 4
1.49 +
1.50 +/**
1.51 */
1.52 uint32_t sh4_xlat_run_slice( uint32_t nanosecs );
1.53
1.54 /**
1.55 + * Return true if translated code is currently running
1.56 + */
1.57 +gboolean sh4_xlat_is_running();
1.58 +
1.59 +/**
1.60 * Translate the specified block of code starting from the specified start
1.61 * address until the first branch/jump instruction.
1.62 */
1.63 void *sh4_translate_basic_block( sh4addr_t start );
1.64
1.65 +
1.66 extern uint8_t *xlat_output;
1.67 +extern struct xlat_recovery_record xlat_recovery[MAX_RECOVERY_SIZE];
1.68 +extern uint32_t xlat_recovery_posn;
1.69
1.70 /******************************************************************************
1.71 * Code generation - these methods must be provided by the
1.72 @@ -51,3 +87,28 @@
1.73 void sh4_translate_begin_block( sh4addr_t pc );
1.74 uint32_t sh4_translate_instruction( sh4addr_t pc );
1.75 void sh4_translate_end_block( sh4addr_t pc );
1.76 +
1.77 +typedef void (*unwind_thunk_t)(void);
1.78 +
1.79 +/**
1.80 + * From within the translator, (typically called from MMU exception handling routines)
1.81 + * immediately exit the current translation block (performing cleanup as necessary) and
1.82 + * return to sh4_xlat_run_slice(). Effectively a fast longjmp w/ xlat recovery.
1.83 + *
1.84 + * Note: The correct working of this method depends on the translator anticipating the
1.85 + * exception and generating the appropriate recovery block(s) - currently this means
1.86 + * that it should ONLY be called from within the context of a memory read or write.
1.87 + *
1.88 + * @param is_completion If TRUE, exit after completing the current instruction (effectively),
1.89 + * otherwise abort the current instruction with no effect.
1.90 + * @param thunk A function to execute after perform xlat recovery, but before returning
1.91 + * to run_slice. If NULL, control returns directly.
1.92 + * @return This method never returns.
1.93 + */
1.94 +void sh4_translate_unwind_stack( gboolean is_completion, unwind_thunk_t thunk );
1.95 +
1.96 +/**
1.97 + * From within the translator, immediately exit the current translation block with
1.98 + * the specified exit code (one of the XLAT_EXIT_* values).
1.99 + */
1.100 +void sh4_translate_exit( int exit_code );
.