Search
lxdream.org :: lxdream/src/sh4/sh4trans.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4trans.h
changeset 926:68f3e0fe02f1
prev905:4c17ebd9ef5e
next941:c67574ed4355
author nkeynes
date Sat Dec 27 02:59:35 2008 +0000 (15 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Replace fpscr_mask/fpscr flags in xlat_cache_block with a single xlat_sh4_mode,
which tracks the field of the same name in sh4r - actually a little faster this way.
Now depends on SR.MD, FPSCR.PR and FPSCR.SZ (although it doesn't benefit from the SR
flag yet).

Also fixed the failure to check the flags in the common case (code address returned
by previous block) which took away the performance benefits, but oh well.
view annotate diff log raw
     1 /**
     2  * $Id$
     3  * 
     4  * SH4->x86 translation module
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #ifndef lxdream_sh4trans_H
    20 #define lxdream_sh4trans_H 1
    22 #include "sh4/xltcache.h"
    23 #include "dream.h"
    24 #include "mem.h"
    26 #ifdef __cplusplus
    27 extern "C" {
    28 #endif
    30 /** Maximum size of a translated instruction, in bytes. Current worst case seems
    31  * to be a BF/S followed by one of the long FMOVs.
    32  */
    33 #define MAX_INSTRUCTION_SIZE 512
    34 /** Maximum size of the translation epilogue (current real size is 116 bytes, so
    35  * allows a little room
    36  */
    37 #define EPILOGUE_SIZE 136
    39 /** Maximum number of recovery records for a translated block (2048 based on
    40  * 1 record per SH4 instruction in a 4K page).
    41  */
    42 #define MAX_RECOVERY_SIZE 2049
    44 /**
    45  */
    46 uint32_t sh4_xlat_run_slice( uint32_t nanosecs );
    48 /**
    49  * Return true if translated code is currently running
    50  */
    51 gboolean sh4_xlat_is_running();
    53 /**
    54  * Initialize the translation engine (if required). Note xlat cache
    55  * must already be initialized.
    56  */
    57 void sh4_xlat_init();
    59 /**
    60  * Translate the specified block of code starting from the specified start
    61  * address until the first branch/jump instruction.
    62  */
    63 void *sh4_translate_basic_block( sh4addr_t start );
    65 /**
    66  * Add a recovery record for the current code generation position, with the
    67  * specified instruction count
    68  */
    69 void sh4_translate_add_recovery( uint32_t icount );
    71 extern uint8_t *xlat_output;
    72 extern struct xlat_recovery_record xlat_recovery[MAX_RECOVERY_SIZE];
    73 extern xlat_cache_block_t xlat_current_block;
    74 extern uint32_t xlat_recovery_posn;
    76 /******************************************************************************
    77  * Code generation - these methods must be provided by the
    78  * actual code gen (eg sh4x86.c) 
    79  ******************************************************************************/
    81 #define TARGET_X86 1
    83 void sh4_translate_init( void );
    84 void sh4_translate_begin_block( sh4addr_t pc );
    85 uint32_t sh4_translate_instruction( sh4addr_t pc );
    86 void sh4_translate_end_block( sh4addr_t pc );
    87 uint32_t sh4_translate_end_block_size();
    88 void sh4_translate_emit_breakpoint( sh4vma_t pc );
    90 typedef void (*unwind_thunk_t)(void);
    92 /**
    93  * From within the translator, (typically called from MMU exception handling routines)
    94  * immediately exit the current translation block (performing cleanup as necessary) and
    95  * return to sh4_xlat_run_slice(). Effectively a fast longjmp w/ xlat recovery.
    96  *
    97  * Note: The correct working of this method depends on the translator anticipating the
    98  * exception and generating the appropriate recovery block(s) - currently this means 
    99  * that it should ONLY be called from within the context of a memory read or write.
   100  *
   101  * @param is_completion If TRUE, exit after completing the current instruction (effectively),
   102  *   otherwise abort the current instruction with no effect. 
   103  * @param thunk A function to execute after perform xlat recovery, but before returning
   104  * to run_slice. If NULL, control returns directly.
   105  * @return This method never returns. 
   106  */
   107 void sh4_translate_unwind_stack( gboolean is_completion, unwind_thunk_t thunk );
   109 /**
   110  * Called when doing a break out of the translator - finalizes the system state up to
   111  * the end of the current instruction.
   112  */
   113 void sh4_translate_exit_recover( );
   115 /**
   116  * From within the translator, exit the current block at the end of the 
   117  * current instruction, flush the translation cache (completely) 
   118  * @return TRUE to perform a vm-exit/continue after the flush
   119  */
   120 gboolean sh4_translate_flush_cache( void );
   122 /**
   123  * Support function called from the translator when a breakpoint is hit.
   124  * Either returns immediately (to skip the breakpoint), or aborts the current
   125  * cycle and never returns.
   126  */
   127 void FASTCALL sh4_translate_breakpoint_hit( sh4vma_t pc );
   129 #ifdef __cplusplus
   130 }
   131 #endif
   133 #endif /* !lxdream_sh4trans_H */
.