Mercurial > repos > blastem
comparison m68k_core_x86.c @ 1228:2e6dcb5c11a2
WIP support for XBAND mapper hardware
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 23 Feb 2017 00:08:37 -0800 |
parents | 4399044adbef |
children | 462d9770d467 |
comparison
equal
deleted
inserted
replaced
1227:262c0ce8f586 | 1228:2e6dcb5c11a2 |
---|---|
2307 } | 2307 } |
2308 | 2308 |
2309 void translate_out_of_bounds(m68k_options *opts, uint32_t address) | 2309 void translate_out_of_bounds(m68k_options *opts, uint32_t address) |
2310 { | 2310 { |
2311 code_info *code = &opts->gen.code; | 2311 code_info *code = &opts->gen.code; |
2312 check_cycles_int(&opts->gen, address); | |
2312 mov_ir(code, address, opts->gen.scratch1, SZ_D); | 2313 mov_ir(code, address, opts->gen.scratch1, SZ_D); |
2313 call_args(code, (code_ptr)m68k_out_of_bounds_execution, 1, opts->gen.scratch1); | 2314 call_args(code, (code_ptr)m68k_out_of_bounds_execution, 1, opts->gen.scratch1); |
2314 } | 2315 } |
2315 | 2316 |
2316 void m68k_set_last_prefetch(m68k_options *opts, uint32_t address) | 2317 void m68k_set_last_prefetch(m68k_options *opts, uint32_t address) |
2338 while (inst_start && (address - inst_start) < M68K_MAX_INST_SIZE) { | 2339 while (inst_start && (address - inst_start) < M68K_MAX_INST_SIZE) { |
2339 code_info *code = &options->gen.code; | 2340 code_info *code = &options->gen.code; |
2340 code_ptr dst = get_native_address(context->options, inst_start); | 2341 code_ptr dst = get_native_address(context->options, inst_start); |
2341 code_info orig = {dst, dst + 128, 0}; | 2342 code_info orig = {dst, dst + 128, 0}; |
2342 mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D); | 2343 mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D); |
2343 | |
2344 if (!options->retrans_stub) { | |
2345 options->retrans_stub = code->cur; | |
2346 call(code, options->gen.save_context); | |
2347 push_r(code, options->gen.context_reg); | |
2348 call_args(code,(code_ptr)m68k_retranslate_inst, 2, options->gen.scratch2, options->gen.context_reg); | |
2349 pop_r(code, options->gen.context_reg); | |
2350 mov_rr(code, RAX, options->gen.scratch1, SZ_PTR); | |
2351 call(code, options->gen.load_context); | |
2352 jmp_r(code, options->gen.scratch1); | |
2353 } | |
2354 jmp(&orig, options->retrans_stub); | 2344 jmp(&orig, options->retrans_stub); |
2355 inst_start = get_instruction_start(options, inst_start - 2); | 2345 inst_start = get_instruction_start(options, inst_start - 2); |
2356 } | 2346 } |
2357 return context; | 2347 return context; |
2348 } | |
2349 | |
2350 void m68k_invalidate_code_range(m68k_context *context, uint32_t start, uint32_t end) | |
2351 { | |
2352 m68k_options *opts = context->options; | |
2353 native_map_slot *native_code_map = opts->gen.native_code_map; | |
2354 memmap_chunk const *mem_chunk = find_map_chunk(start, &opts->gen, 0, NULL); | |
2355 if (mem_chunk) { | |
2356 //calculate the lowest alias for this address | |
2357 start = mem_chunk->start + ((start - mem_chunk->start) & mem_chunk->mask); | |
2358 } | |
2359 mem_chunk = find_map_chunk(end, &opts->gen, 0, NULL); | |
2360 if (mem_chunk) { | |
2361 //calculate the lowest alias for this address | |
2362 end = mem_chunk->start + ((end - mem_chunk->start) & mem_chunk->mask); | |
2363 } | |
2364 uint32_t start_chunk = start / NATIVE_CHUNK_SIZE, end_chunk = end / NATIVE_CHUNK_SIZE; | |
2365 for (uint32_t chunk = start_chunk; chunk <= end_chunk; chunk++) | |
2366 { | |
2367 if (native_code_map[chunk].base) { | |
2368 uint32_t start_offset = chunk == start_chunk ? start % NATIVE_CHUNK_SIZE : 0; | |
2369 uint32_t end_offset = chunk == end_chunk ? end % NATIVE_CHUNK_SIZE : NATIVE_CHUNK_SIZE; | |
2370 for (uint32_t offset = start_offset; offset < end_offset; offset++) | |
2371 { | |
2372 if (native_code_map[chunk].offsets[offset] != INVALID_OFFSET && native_code_map[chunk].offsets[offset] != EXTENSION_WORD) { | |
2373 code_info code; | |
2374 code.cur = native_code_map[chunk].base + native_code_map[chunk].offsets[offset]; | |
2375 code.last = code.cur + 32; | |
2376 code.stack_off = 0; | |
2377 mov_ir(&code, chunk * NATIVE_CHUNK_SIZE + offset, opts->gen.scratch2, SZ_D); | |
2378 jmp(&code, opts->retrans_stub); | |
2379 } | |
2380 } | |
2381 } | |
2382 } | |
2358 } | 2383 } |
2359 | 2384 |
2360 void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler) | 2385 void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler) |
2361 { | 2386 { |
2362 static code_ptr bp_stub = NULL; | 2387 static code_ptr bp_stub = NULL; |
2946 shl_ir(code, 2, opts->gen.scratch1, SZ_D); | 2971 shl_ir(code, 2, opts->gen.scratch1, SZ_D); |
2947 call(code, opts->read_32); | 2972 call(code, opts->read_32); |
2948 call(code, opts->native_addr_and_sync); | 2973 call(code, opts->native_addr_and_sync); |
2949 cycles(&opts->gen, 18); | 2974 cycles(&opts->gen, 18); |
2950 jmp_r(code, opts->gen.scratch1); | 2975 jmp_r(code, opts->gen.scratch1); |
2951 } | 2976 |
2977 opts->retrans_stub = code->cur; | |
2978 call(code, opts->gen.save_context); | |
2979 push_r(code, opts->gen.context_reg); | |
2980 call_args(code,(code_ptr)m68k_retranslate_inst, 2, opts->gen.scratch2, opts->gen.context_reg); | |
2981 pop_r(code, opts->gen.context_reg); | |
2982 mov_rr(code, RAX, opts->gen.scratch1, SZ_PTR); | |
2983 call(code, opts->gen.load_context); | |
2984 jmp_r(code, opts->gen.scratch1); | |
2985 } |