sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame^] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- ---*/ |
| 4 | /*--- This file (jit_main.c) is ---*/ |
| 5 | /*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/ |
| 6 | /*--- ---*/ |
| 7 | /*---------------------------------------------------------------*/ |
| 8 | |
| 9 | #include "libjit.h" |
| 10 | #include "jit_globals.h" |
| 11 | #include "vex_util.h" |
| 12 | |
| 13 | |
| 14 | /* This file contains the top level interface to the library. */ |
| 15 | |
| 16 | /* --------- Initialise the library. --------- */ |
| 17 | |
| 18 | /* Exported to library client. */ |
| 19 | |
| 20 | void LibJIT_Init ( |
| 21 | /* failure exit function */ |
| 22 | void (*failure_exit) ( void ), |
| 23 | /* logging output function */ |
| 24 | void (*log_bytes) ( Char*, Int nbytes ), |
| 25 | /* debug paranoia level */ |
| 26 | Int debuglevel, |
| 27 | /* verbosity level */ |
| 28 | Int verbosity, |
| 29 | /* Are we supporting valgrind checking? */ |
| 30 | Bool valgrind_support, |
| 31 | /* Max # guest insns per bb */ |
| 32 | Int guest_insns_per_bb |
| 33 | ) |
| 34 | { |
| 35 | vassert(!vex_initdone); |
| 36 | vassert(failure_exit); |
| 37 | vex_failure_exit = failure_exit; |
| 38 | vassert(log_bytes); |
| 39 | vex_log_bytes = log_bytes; |
| 40 | vassert(debuglevel >= 0); |
| 41 | vex_debuglevel = debuglevel; |
| 42 | vassert(verbosity >= 0); |
| 43 | vex_verbosity = verbosity; |
| 44 | vex_valgrind_support = valgrind_support; |
| 45 | vassert(guest_insns_per_bb >= 1 && guest_insns_per_bb <= 100); |
| 46 | vex_guest_insns_per_bb = guest_insns_per_bb; |
| 47 | vex_initdone = True; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | /* --------- Make a translation. --------- */ |
| 52 | |
| 53 | /* Exported to library client. */ |
| 54 | |
| 55 | TranslateResult LibJIT_Translate ( |
| 56 | /* The instruction sets we are translating from and to. */ |
| 57 | InsnSet iset_guest, |
| 58 | InsnSet iset_host, |
| 59 | /* IN: the block to translate, and its guest address. */ |
| 60 | Char* guest_bytes, |
| 61 | Addr64 guest_bytes_addr, |
| 62 | /* OUT: the number of bytes actually read */ |
| 63 | Int* guest_bytes_read, |
| 64 | /* IN: a place to put the resulting code, and its size */ |
| 65 | Char* host_bytes, |
| 66 | Int host_bytes_size, |
| 67 | /* OUT: how much of the output area is used. */ |
| 68 | Int* host_bytes_used, |
| 69 | /* IN: optionally, an instrumentation function. */ |
| 70 | IRBB (*instrument) ( IRBB* ), |
| 71 | /* IN: optionally, an access check function for guest code. */ |
| 72 | Bool (*byte_accessible) ( Addr64 ) |
| 73 | ) |
| 74 | { |
| 75 | vassert(vex_initdone); |
| 76 | LibJIT_Clear(False); |
| 77 | return TransOK; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | |
| 82 | /*---------------------------------------------------------------*/ |
| 83 | /*--- end jit_main.c ---*/ |
| 84 | /*---------------------------------------------------------------*/ |