Search
lxdream.org :: lxdream :: r398:16b0856ea511
lxdream 0.9.1
released Jun 29
Download Now
changeset398:16b0856ea511
parent397:640324505325
child399:23e51a2b4f99
authornkeynes
dateWed Sep 19 12:09:33 2007 +0000 (12 years ago)
Add a 'translate and run' method for running uncached code
src/sh4/sh4trans.c
1.1 --- a/src/sh4/sh4trans.c Wed Sep 19 11:30:30 2007 +0000
1.2 +++ b/src/sh4/sh4trans.c Wed Sep 19 12:09:33 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: sh4trans.c,v 1.3 2007-09-18 09:12:30 nkeynes Exp $
1.6 + * $Id: sh4trans.c,v 1.4 2007-09-19 12:09:33 nkeynes Exp $
1.7 *
1.8 * SH4 translation core module. This part handles the non-target-specific
1.9 * section of the translation.
1.10 @@ -16,7 +16,7 @@
1.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.12 * GNU General Public License for more details.
1.13 */
1.14 -
1.15 +#include <assert.h>
1.16 #include "sh4core.h"
1.17 #include "sh4trans.h"
1.18 #include "xltcache.h"
1.19 @@ -109,4 +109,28 @@
1.20 return block->code;
1.21 }
1.22
1.23 +/**
1.24 + * Translate a linear basic block to a temporary buffer, execute it, and return
1.25 + * the result of the execution. The translation is discarded.
1.26 + */
1.27 +gboolean sh4_translate_and_run( sh4addr_t start )
1.28 +{
1.29 + char buf[65536];
1.30
1.31 + uint32_t pc = start;
1.32 + int done;
1.33 + xlat_output = buf;
1.34 + uint8_t *eob = xlat_output + sizeof(buf);
1.35 +
1.36 + sh4_translate_begin_block();
1.37 +
1.38 + while( (done = sh4_x86_translate_instruction( pc )) == 0 ) {
1.39 + assert( (eob - xlat_output) >= MAX_INSTRUCTION_SIZE );
1.40 + pc += 2;
1.41 + }
1.42 + pc+=2;
1.43 + sh4_translate_end_block(pc);
1.44 +
1.45 + gboolean (*code)() = (void *)buf;
1.46 + return code();
1.47 +}
.