Search
lxdream.org :: lxdream/src/sh4/sh4trans.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4trans.h
changeset 571:9bc09948d0f2
prev561:533f6b478071
next577:a181aeacd6e8
author nkeynes
date Thu Jan 10 08:28:37 2008 +0000 (15 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change More MMU work in progess. Much better now...
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 #include "sh4/xltcache.h"
    20 #include "dream.h"
    21 #include "mem.h"
    23 /** Maximum size of a translated instruction, in bytes. This includes potentially
    24  * writing the entire epilogue
    25  */
    26 #define MAX_INSTRUCTION_SIZE 256
    27 /** Maximum size of the translation epilogue (current real size is 116 bytes, so
    28  * allows a little room
    29  */
    30 #define EPILOGUE_SIZE 128
    32 /** Maximum number of recovery records for a translated block (2048 based on
    33  * 1 record per SH4 instruction in a 4K page).
    34  */
    35 #define MAX_RECOVERY_SIZE 2048
    37 /**
    38  */
    39 uint32_t sh4_xlat_run_slice( uint32_t nanosecs );
    41 /**
    42  * Translate the specified block of code starting from the specified start
    43  * address until the first branch/jump instruction.
    44  */
    45 void *sh4_translate_basic_block( sh4addr_t start );
    48 extern uint8_t *xlat_output;
    49 extern struct xlat_recovery_record xlat_recovery[MAX_RECOVERY_SIZE];
    50 extern uint32_t xlat_recovery_posn;
    52 /******************************************************************************
    53  * Code generation - these methods must be provided by the
    54  * actual code gen (eg sh4x86.c) 
    55  ******************************************************************************/
    57 #define TARGET_X86 1
    58 #define TARGET_X86_64 2
    60 void sh4_translate_begin_block( sh4addr_t pc );
    61 uint32_t sh4_translate_instruction( sh4addr_t pc );
    62 void sh4_translate_end_block( sh4addr_t pc );
    64 typedef void (*unwind_thunk_t)(void);
    66 /**
    67  * From within the translator, (typically called from MMU exception handling routines)
    68  * immediately exit the current translation block (performing cleanup as necessary) and
    69  * return to sh4_xlat_run_slice(). Effectively a fast longjmp w/ xlat recovery.
    70  *
    71  * Note: The correct working of this method depends on the translator anticipating the
    72  * exception and generating the appropriate recovery block(s) - currently this means 
    73  * that it should ONLY be called from within the context of a memory read or write.
    74  *
    75  * @param is_completion If TRUE, exit after completing the current instruction (effectively),
    76  *   otherwise abort the current instruction with no effect. 
    77  * @param thunk A function to execute after perform xlat recovery, but before returning
    78  * to run_slice. If NULL, control returns directly.
    79  * @return This method never returns. 
    80  */
    81 void sh4_translate_unwind_stack( gboolean is_completion, unwind_thunk_t thunk );
.