diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-02-23 00:08:37 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-02-23 00:08:37 -0800 |
commit | 1a3574ab4863a11bc40b6c7f760e905affc3cf31 (patch) | |
tree | 6dae4acce58e2654f2464758145efe97b5fccb48 /m68k_core_x86.c | |
parent | 7958037a5b03952b8ff467b0d3d90a32678221ee (diff) |
WIP support for XBAND mapper hardware
Diffstat (limited to 'm68k_core_x86.c')
-rw-r--r-- | m68k_core_x86.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/m68k_core_x86.c b/m68k_core_x86.c index 3d55757..d575b1d 100644 --- a/m68k_core_x86.c +++ b/m68k_core_x86.c @@ -2309,6 +2309,7 @@ void m68k_out_of_bounds_execution(uint32_t address) void translate_out_of_bounds(m68k_options *opts, uint32_t address) { code_info *code = &opts->gen.code; + check_cycles_int(&opts->gen, address); mov_ir(code, address, opts->gen.scratch1, SZ_D); call_args(code, (code_ptr)m68k_out_of_bounds_execution, 1, opts->gen.scratch1); } @@ -2340,23 +2341,47 @@ m68k_context * m68k_handle_code_write(uint32_t address, m68k_context * context) code_ptr dst = get_native_address(context->options, inst_start); code_info orig = {dst, dst + 128, 0}; mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D); - - if (!options->retrans_stub) { - options->retrans_stub = code->cur; - call(code, options->gen.save_context); - push_r(code, options->gen.context_reg); - call_args(code,(code_ptr)m68k_retranslate_inst, 2, options->gen.scratch2, options->gen.context_reg); - pop_r(code, options->gen.context_reg); - mov_rr(code, RAX, options->gen.scratch1, SZ_PTR); - call(code, options->gen.load_context); - jmp_r(code, options->gen.scratch1); - } jmp(&orig, options->retrans_stub); inst_start = get_instruction_start(options, inst_start - 2); } return context; } +void m68k_invalidate_code_range(m68k_context *context, uint32_t start, uint32_t end) +{ + m68k_options *opts = context->options; + native_map_slot *native_code_map = opts->gen.native_code_map; + memmap_chunk const *mem_chunk = find_map_chunk(start, &opts->gen, 0, NULL); + if (mem_chunk) { + //calculate the lowest alias for this address + start = mem_chunk->start + ((start - mem_chunk->start) & mem_chunk->mask); + } + mem_chunk = find_map_chunk(end, &opts->gen, 0, NULL); + if (mem_chunk) { + //calculate the lowest alias for this address + end = mem_chunk->start + ((end - mem_chunk->start) & mem_chunk->mask); + } + uint32_t start_chunk = start / NATIVE_CHUNK_SIZE, end_chunk = end / NATIVE_CHUNK_SIZE; + for (uint32_t chunk = start_chunk; chunk <= end_chunk; chunk++) + { + if (native_code_map[chunk].base) { + uint32_t start_offset = chunk == start_chunk ? start % NATIVE_CHUNK_SIZE : 0; + uint32_t end_offset = chunk == end_chunk ? end % NATIVE_CHUNK_SIZE : NATIVE_CHUNK_SIZE; + for (uint32_t offset = start_offset; offset < end_offset; offset++) + { + if (native_code_map[chunk].offsets[offset] != INVALID_OFFSET && native_code_map[chunk].offsets[offset] != EXTENSION_WORD) { + code_info code; + code.cur = native_code_map[chunk].base + native_code_map[chunk].offsets[offset]; + code.last = code.cur + 32; + code.stack_off = 0; + mov_ir(&code, chunk * NATIVE_CHUNK_SIZE + offset, opts->gen.scratch2, SZ_D); + jmp(&code, opts->retrans_stub); + } + } + } + } +} + void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler) { static code_ptr bp_stub = NULL; @@ -2948,4 +2973,13 @@ void init_m68k_opts(m68k_options * opts, memmap_chunk * memmap, uint32_t num_chu call(code, opts->native_addr_and_sync); cycles(&opts->gen, 18); jmp_r(code, opts->gen.scratch1); + + opts->retrans_stub = code->cur; + call(code, opts->gen.save_context); + push_r(code, opts->gen.context_reg); + call_args(code,(code_ptr)m68k_retranslate_inst, 2, opts->gen.scratch2, opts->gen.context_reg); + pop_r(code, opts->gen.context_reg); + mov_rr(code, RAX, opts->gen.scratch1, SZ_PTR); + call(code, opts->gen.load_context); + jmp_r(code, opts->gen.scratch1); } |