comparison m68k_core.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 afa3d0a227ae
children 462d9770d467
comparison
equal deleted inserted replaced
1227:262c0ce8f586 1228:2e6dcb5c11a2
615 static void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size) 615 static void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size)
616 { 616 {
617 m68k_options * opts = context->options; 617 m68k_options * opts = context->options;
618 native_map_slot * native_code_map = opts->gen.native_code_map; 618 native_map_slot * native_code_map = opts->gen.native_code_map;
619 uint32_t meta_off; 619 uint32_t meta_off;
620 memmap_chunk const *mem_chunk = find_map_chunk(address, &opts->gen, MMAP_WRITE | MMAP_CODE, &meta_off); 620 memmap_chunk const *mem_chunk = find_map_chunk(address, &opts->gen, MMAP_CODE, &meta_off);
621 if (mem_chunk) { 621 if (mem_chunk) {
622 if ((mem_chunk->flags & (MMAP_WRITE | MMAP_CODE)) == (MMAP_WRITE | MMAP_CODE)) { 622 if (mem_chunk->flags & MMAP_CODE) {
623 uint32_t masked = (address & mem_chunk->mask); 623 uint32_t masked = (address - mem_chunk->start) & mem_chunk->mask;
624 uint32_t final_off = masked + meta_off; 624 uint32_t final_off = masked + meta_off;
625 uint32_t ram_flags_off = final_off >> (opts->gen.ram_flags_shift + 3); 625 uint32_t ram_flags_off = final_off >> (opts->gen.ram_flags_shift + 3);
626 context->ram_code_flags[ram_flags_off] |= 1 << ((final_off >> opts->gen.ram_flags_shift) & 7); 626 context->ram_code_flags[ram_flags_off] |= 1 << ((final_off >> opts->gen.ram_flags_shift) & 7);
627 627
628 uint32_t slot = final_off / 1024; 628 uint32_t slot = final_off / 1024;
668 } 668 }
669 669
670 static uint8_t get_native_inst_size(m68k_options * opts, uint32_t address) 670 static uint8_t get_native_inst_size(m68k_options * opts, uint32_t address)
671 { 671 {
672 uint32_t meta_off; 672 uint32_t meta_off;
673 memmap_chunk const *chunk = find_map_chunk(address, &opts->gen, MMAP_WRITE | MMAP_CODE, &meta_off); 673 memmap_chunk const *chunk = find_map_chunk(address, &opts->gen, MMAP_CODE, &meta_off);
674 if (chunk) { 674 if (chunk) {
675 meta_off += (address - chunk->start) & chunk->mask; 675 meta_off += (address - chunk->start) & chunk->mask;
676 } 676 }
677 uint32_t slot = meta_off/1024; 677 uint32_t slot = meta_off/1024;
678 return opts->gen.ram_inst_sizes[slot][(meta_off/2)%512]; 678 return opts->gen.ram_inst_sizes[slot][(meta_off/2)%512];
880 fflush(opts->address_log); 880 fflush(opts->address_log);
881 } 881 }
882 do { 882 do {
883 encoded = get_native_pointer(address, (void **)context->mem_pointers, &opts->gen); 883 encoded = get_native_pointer(address, (void **)context->mem_pointers, &opts->gen);
884 if (!encoded) { 884 if (!encoded) {
885 map_native_address(context, address, code->cur, 2, 1); 885 code_ptr start = code->cur;
886 translate_out_of_bounds(opts, address); 886 translate_out_of_bounds(opts, address);
887 code_ptr after = code->cur;
888 map_native_address(context, address, code->cur, 2, after-start);
887 break; 889 break;
888 } 890 }
889 code_ptr existing = get_native_address(opts, address); 891 code_ptr existing = get_native_address(opts, address);
890 if (existing) { 892 if (existing) {
891 jmp(code, existing); 893 jmp(code, existing);