src/emu/cpu/m68000/m68kmmu.h
| r0 | r6043 | |
| 1 | /* |
| 2 | m68kmmu.h - PMMU implementation for 68851/68030/68040 |
| 3 | |
| 4 | By R. Belmont |
| 5 | |
| 6 | Copyright Nicola Salmoria and the MAME Team. |
| 7 | Visit http://mamedev.org for licensing and usage restrictions. |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | pmmu_translate_addr: perform 68851/68030-style PMMU address translation |
| 12 | */ |
| 13 | INLINE UINT32 pmmu_translate_addr(m68ki_cpu_core *m68k, UINT32 addr_in) |
| 14 | { |
| 15 | UINT32 addr_out, tbl_entry, tbl_entry2, tamode, tbmode; |
| 16 | UINT32 root_aptr, root_limit, tofs, is, abits, bbits, cbits; |
| 17 | UINT32 resolved, tptr, shift; |
| 18 | |
| 19 | resolved = 0; |
| 20 | addr_out = addr_in; |
| 21 | |
| 22 | // if SRP is enabled and we're in supervisor mode, use it |
| 23 | if ((m68k->mmu_tc & 0x02000000) && (m68ki_get_sr(m68k) & 0x2000)) |
| 24 | { |
| 25 | root_aptr = m68k->mmu_srp_aptr; |
| 26 | root_limit = m68k->mmu_srp_limit; |
| 27 | } |
| 28 | else // else use the CRP |
| 29 | { |
| 30 | root_aptr = m68k->mmu_crp_aptr; |
| 31 | root_limit = m68k->mmu_crp_limit; |
| 32 | } |
| 33 | |
| 34 | // get initial shift (# of top bits to ignore) |
| 35 | is = (m68k->mmu_tc>>16) & 0xf; |
| 36 | abits = (m68k->mmu_tc>>12)&0xf; |
| 37 | bbits = (m68k->mmu_tc>>8)&0xf; |
| 38 | cbits = (m68k->mmu_tc>>4)&0xf; |
| 39 | |
| 40 | // logerror("PMMU: tcr %08x limit %08x aptr %08x is %x abits %d bbits %d cbits %d\n", m68k->mmu_tc, root_limit, root_aptr, is, abits, bbits, cbits); |
| 41 | |
| 42 | // get table A offset |
| 43 | tofs = (addr_in<<is)>>(32-abits); |
| 44 | |
| 45 | // find out what format table A is |
| 46 | switch (root_limit & 3) |
| 47 | { |
| 48 | case 0: // invalid, should cause MMU exception |
| 49 | case 1: // page descriptor, should cause direct mapping |
| 50 | fatalerror("680x0 PMMU: Unhandled root mode\n"); |
| 51 | break; |
| 52 | |
| 53 | case 2: // valid 4 byte descriptors |
| 54 | tofs *= 4; |
| 55 | // logerror("PMMU: reading table A entry at %08x\n", tofs + (root_aptr & 0xfffffffc)); |
| 56 | tbl_entry = memory_read_dword_32be(m68k->program, tofs + (root_aptr & 0xfffffffc)); |
| 57 | tamode = tbl_entry & 3; |
| 58 | // logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tamode, tofs); |
| 59 | break; |
| 60 | |
| 61 | case 3: // valid 8 byte descriptors |
| 62 | tofs *= 8; |
| 63 | // logerror("PMMU: reading table A entries at %08x\n", tofs + (root_aptr & 0xfffffffc)); |
| 64 | tbl_entry2 = memory_read_dword_32be(m68k->program, tofs + (root_aptr & 0xfffffffc)); |
| 65 | tbl_entry = memory_read_dword_32be(m68k->program, tofs + (root_aptr & 0xfffffffc)+4); |
| 66 | tamode = tbl_entry2 & 3; |
| 67 | // logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tamode, tofs); |
| 68 | break; |
| 69 | } |
| 70 | |
| 71 | // get table B offset and pointer |
| 72 | tofs = (addr_in<<(is+abits))>>(32-bbits); |
| 73 | tptr = tbl_entry & 0xfffffff0; |
| 74 | |
| 75 | // find out what format table B is, if any |
| 76 | switch (tamode) |
| 77 | { |
| 78 | case 0: // invalid, should cause MMU exception |
| 79 | fatalerror("680x0 PMMU: Unhandled Table A mode %d (addr_in %08x)\n", tamode, addr_in); |
| 80 | break; |
| 81 | |
| 82 | case 2: // 4-byte table B descriptor |
| 83 | tofs *= 4; |
| 84 | // logerror("PMMU: reading table B entry at %08x\n", tofs + tptr); |
| 85 | tbl_entry = memory_read_dword_32be(m68k->program, tofs + tptr); |
| 86 | tbmode = tbl_entry & 3; |
| 87 | // logerror("PMMU: addr %08x entry %08x mode %x tofs %x\n", addr_in, tbl_entry, tbmode, tofs); |
| 88 | break; |
| 89 | |
| 90 | case 3: // 8-byte table B descriptor |
| 91 | tofs *= 8; |
| 92 | // logerror("PMMU: reading table B entries at %08x\n", tofs + tptr); |
| 93 | tbl_entry2 = memory_read_dword_32be(m68k->program, tofs + tptr); |
| 94 | tbl_entry = memory_read_dword_32be(m68k->program, tofs + tptr + 4); |
| 95 | tbmode = tbl_entry2 & 3; |
| 96 | // logerror("PMMU: addr %08x entry %08x entry2 %08x mode %x tofs %x\n", addr_in, tbl_entry, tbl_entry2, tbmode, tofs); |
| 97 | break; |
| 98 | |
| 99 | case 1: // early termination descriptor |
| 100 | tbl_entry &= 0xffffff00; |
| 101 | |
| 102 | shift = is+abits; |
| 103 | addr_out = ((addr_in<<shift)>>shift) + tbl_entry; |
| 104 | resolved = 1; |
| 105 | break; |
| 106 | } |
| 107 | |
| 108 | // if table A wasn't early-out, continue to process table B |
| 109 | if (!resolved) |
| 110 | { |
| 111 | switch (tbmode) |
| 112 | { |
| 113 | case 0: // invalid, should cause MMU exception |
| 114 | case 2: // 4-byte table C descriptor |
| 115 | case 3: // 8-byte table C descriptor |
| 116 | fatalerror("680x0 PMMU: Unhandled Table B mode %d (addr_in %08x)\n", tbmode, addr_in); |
| 117 | break; |
| 118 | |
| 119 | case 1: // early termination descriptor |
| 120 | tbl_entry &= 0xffffff00; |
| 121 | |
| 122 | shift = is+abits+bbits; |
| 123 | addr_out = ((addr_in<<shift)>>shift) + tbl_entry; |
| 124 | resolved = 1; |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // if ((addr_in < 0x40000000) || (addr_in > 0x4fffffff)) printf("PMMU: [%08x] => [%08x]\n", addr_in, addr_out); |
| 130 | |
| 131 | return addr_out; |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | |
| 136 | maincpu at 40804366: called unimplemented instruction f000 (cpgen) |
| 137 | PMMU: tcr 80f05570 limit 7fff0003 aptr 043ffcc0 is 0 |
| 138 | PMMU: reading table A entries at 043ffce0 |
| 139 | PMMU: addr 4080438a entry 00000000 entry2 7ffffc18 mode 0 aofs 20 |
| 140 | 680x0 PMMU: Unhandled Table A mode 0 |
| 141 | |
| 142 | enable, PS = f |
| 143 | |
| 144 | tblA @ 043ffcc0: |
| 145 | |
| 146 | 043ffcc0 0001fc0a 043ffcb0 => 00000019 04000019 |
| 147 | 043ffcc8 7ffffc18 00000000 |
| 148 | 043ffcd0 7ffffc18 00000000 |
| 149 | 043ffcd8 7ffffc18 00000000 |
| 150 | 043ffce0 7ffffc18 00000000 |
| 151 | 043ffce8 7ffffc18 00000000 |
| 152 | 043ffcf0 7ffffc18 00000000 |
| 153 | 043ffcf8 7ffffc18 00000000 |
| 154 | 043ffd00 7ffffc19 40000000 |
| 155 | 043ffd08 7ffffc19 48000000 |
| 156 | 043ffd10 7ffffc59 50000000 |
| 157 | 043ffd18 7ffffc59 58000000 |
| 158 | 043ffd20 7ffffc59 60000000 |
| 159 | 043ffd28 7ffffc59 68000000 |
| 160 | 043ffd30 7ffffc59 70000000 |
| 161 | 043ffd38 7ffffc59 78000000 |
| 162 | 043ffd40 7ffffc59 80000000 |
| 163 | 043ffd48 7ffffc59 88000000 |
| 164 | 043ffd50 7ffffc59 90000000 |
| 165 | 043ffd58 7ffffc59 98000000 |
| 166 | 043ffd60 7ffffc59 a0000000 |
| 167 | 043ffd68 7ffffc59 a8000000 |
| 168 | 043ffd70 7ffffc59 b0000000 |
| 169 | 043ffd78 7ffffc59 b8000000 |
| 170 | 043ffd80 7ffffc59 c0000000 |
| 171 | 043ffd88 7ffffc59 c8000000 |
| 172 | 043ffd90 7ffffc59 d0000000 |
| 173 | 043ffd98 7ffffc59 d8000000 |
| 174 | 043ffda0 7ffffc59 e0000000 |
| 175 | 043ffda8 7ffffc59 e8000000 |
| 176 | 043ffdb0 7ffffc59 f0000000 |
| 177 | 043ffdb8 7ffffc59 f8000000 |
| 178 | |
| 179 | */ |
| 180 | |
src/emu/cpu/m68000/m68k_in.c
| r6042 | r6043 | |
| 7997 | 7997 | |
| 7998 | 7998 | M68KMAKE_OP(pflush, 32, ., .) |
| 7999 | 7999 | { |
| 8000 | | if ((CPU_TYPE_IS_040_PLUS(m68k->cpu_type)) && (m68k->has_pmmu)) |
| 8000 | if ((CPU_TYPE_IS_EC020_PLUS(m68k->cpu_type)) && (m68k->has_pmmu)) |
| 8001 | 8001 | { |
| 8002 | | // Nothing to do, unless address translation cache is emulated |
| 8003 | 8002 | logerror("680x0: unhandled PFLUSH\n"); |
| 8004 | 8003 | return; |
| 8005 | 8004 | } |
| 8006 | | m68ki_exception_illegal(m68k); |
| 8005 | m68ki_exception_1111(m68k); |
| 8007 | 8006 | } |
| 8008 | 8007 | |
| 8009 | 8008 | M68KMAKE_OP(pmove, 32, ., .) |
| r6042 | r6043 | |
| 8011 | 8010 | UINT16 modes; |
| 8012 | 8011 | UINT32 ea; |
| 8013 | 8012 | |
| 8014 | | modes = m68ki_read_imm_16(m68k); |
| 8015 | | ea = M68KMAKE_GET_EA_AY_32; |
| 8016 | | |
| 8017 | 8013 | if ((CPU_TYPE_IS_EC020_PLUS(m68k->cpu_type)) && (m68k->has_pmmu)) |
| 8018 | 8014 | { |
| 8019 | | logerror("680x0: unhandled PMOVE modes %x ea %x\n", modes, ea); |
| 8015 | modes = m68ki_read_imm_16(m68k); |
| 8016 | ea = M68KMAKE_GET_EA_AY_32; |
| 8017 | |
| 8018 | if ((modes & 0xfde0) == 0x2000) // PLOAD |
| 8019 | { |
| 8020 | logerror("680x0: unhandled PLOAD\n"); |
| 8021 | return; |
| 8022 | } |
| 8023 | |
| 8024 | if ((modes & 0xe200) == 0x2000) // PFLUSHA |
| 8025 | { |
| 8026 | logerror("680x0: unhandled PFLUSHA\n"); |
| 8027 | return; |
| 8028 | } |
| 8029 | |
| 8030 | switch ((modes>>13) & 0x7) |
| 8031 | { |
| 8032 | case 0: // MC68030/040 form with FD bit |
| 8033 | case 2: // MC68881 form, FD never set |
| 8034 | if (modes & 0x200) |
| 8035 | { |
| 8036 | logerror("680x0: PMOVE from MMU not supported\n"); |
| 8037 | } |
| 8038 | else |
| 8039 | { |
| 8040 | switch ((modes>>10) & 7) |
| 8041 | { |
| 8042 | case 0: // translation control register |
| 8043 | m68k->mmu_tc = memory_read_word_32be(m68k->program, ea)<<16; |
| 8044 | m68k->mmu_tc |= memory_read_word_32be(m68k->program, ea+2); |
| 8045 | |
| 8046 | if (m68k->mmu_tc & 0x80000000) |
| 8047 | { |
| 8048 | m68k->pmmu_enabled = 1; |
| 8049 | } |
| 8050 | else |
| 8051 | { |
| 8052 | m68k->pmmu_enabled = 0; |
| 8053 | } |
| 8054 | break; |
| 8055 | |
| 8056 | case 2: // supervisor root pointer |
| 8057 | m68k->mmu_srp_limit = memory_read_word_32be(m68k->program, ea)<<16; |
| 8058 | m68k->mmu_srp_limit |= memory_read_word_32be(m68k->program, ea+2); |
| 8059 | m68k->mmu_srp_aptr = memory_read_word_32be(m68k->program, ea+4)<<16; |
| 8060 | m68k->mmu_srp_aptr |= memory_read_word_32be(m68k->program, ea+6); |
| 8061 | break; |
| 8062 | |
| 8063 | case 3: // CPU root pointer |
| 8064 | m68k->mmu_crp_limit = memory_read_word_32be(m68k->program, ea)<<16; |
| 8065 | m68k->mmu_crp_limit |= memory_read_word_32be(m68k->program, ea+2); |
| 8066 | m68k->mmu_crp_aptr = memory_read_word_32be(m68k->program, ea+4)<<16; |
| 8067 | m68k->mmu_crp_aptr |= memory_read_word_32be(m68k->program, ea+6); |
| 8068 | break; |
| 8069 | |
| 8070 | default: |
| 8071 | logerror("680x0: PMOVE to unknown MMU register %x\n", (modes>>10) & 7); |
| 8072 | break; |
| 8073 | } |
| 8074 | } |
| 8075 | break; |
| 8076 | |
| 8077 | case 3: // MC68030 to/from status reg |
| 8078 | if (modes & 0x200) |
| 8079 | { |
| 8080 | memory_write_word_32be(m68k->program, ea, m68k->mmu_sr); |
| 8081 | } |
| 8082 | else |
| 8083 | { |
| 8084 | m68k->mmu_sr = memory_read_word_32be(m68k->program, ea); |
| 8085 | } |
| 8086 | break; |
| 8087 | |
| 8088 | default: |
| 8089 | logerror("680x0: unknown PMOVE mode %x (modes %04x) (PC %x)\n", (modes>>13) & 0x7, modes, m68k->pc); |
| 8090 | break; |
| 8091 | } |
| 8092 | |
| 8020 | 8093 | } |
| 8021 | 8094 | else |
| 8022 | 8095 | { |
| 8023 | | m68ki_exception_illegal(m68k); |
| 8096 | m68ki_exception_1111(m68k); |
| 8024 | 8097 | } |
| 8025 | 8098 | } |
| 8026 | 8099 | |
src/emu/cpu/m68000/m68kcpu.c
| r6042 | r6043 | |
| 5 | 5 | #if 0 |
| 6 | 6 | static const char copyright_notice[] = |
| 7 | 7 | "MUSASHI\n" |
| 8 | | "Version 4.10 (2009-09-27)\n" |
| 8 | "Version 4.5 (2009-10-09)\n" |
| 9 | 9 | "A portable Motorola M680x0 processor emulation engine.\n" |
| 10 | 10 | "Copyright Karl Stenerud. All rights reserved.\n" |
| 11 | 11 | "\n" |
| r6042 | r6043 | |
| 38 | 38 | #include "m68kfpu.c" |
| 39 | 39 | #include "debugger.h" |
| 40 | 40 | |
| 41 | #include "m68kmmu.h" |
| 42 | |
| 41 | 43 | extern void m68040_fpu_op0(m68ki_cpu_core *m68k); |
| 42 | 44 | extern void m68040_fpu_op1(m68ki_cpu_core *m68k); |
| 43 | 45 | |
| r6042 | r6043 | |
| 611 | 613 | m68ki_jump(m68k, REG_PC); |
| 612 | 614 | } |
| 613 | 615 | |
| 616 | /* translate logical to physical addresses */ |
| 617 | static CPU_TRANSLATE( m68k ) |
| 618 | { |
| 619 | m68ki_cpu_core *m68k = get_safe_token(device); |
| 614 | 620 | |
| 621 | /* only applies to the program address space and only does something if the MMU's enabled */ |
| 622 | if (m68k) |
| 623 | { |
| 624 | if ((space == ADDRESS_SPACE_PROGRAM) && (m68k->pmmu_enabled)) |
| 625 | { |
| 626 | *address = pmmu_translate_addr(m68k, *address); |
| 627 | } |
| 628 | } |
| 629 | return TRUE; |
| 630 | } |
| 631 | |
| 615 | 632 | /* Execute some instructions until we use up cycles clock cycles */ |
| 616 | 633 | static CPU_EXECUTE( m68k ) |
| 617 | 634 | { |
| r6042 | r6043 | |
| 718 | 735 | { |
| 719 | 736 | m68ki_cpu_core *m68k = get_safe_token(device); |
| 720 | 737 | |
| 738 | /* Disable the PMMU on reset */ |
| 739 | m68k->pmmu_enabled = 0; |
| 740 | |
| 721 | 741 | /* Clear all stop levels and eat up all remaining cycles */ |
| 722 | 742 | m68k->stopped = 0; |
| 723 | 743 | if (m68k->remaining_cycles > 0) |
| r6042 | r6043 | |
| 890 | 910 | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(m68k); break; |
| 891 | 911 | case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(m68k); break; |
| 892 | 912 | case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(m68k); break; |
| 913 | case CPUINFO_FCT_TRANSLATE: info->translate = CPU_TRANSLATE_NAME(m68k); break; |
| 893 | 914 | |
| 894 | 915 | /* --- the following bits of info are returned as pointers --- */ |
| 895 | 916 | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m68k->remaining_cycles; break; |
| r6042 | r6043 | |
| 898 | 919 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 899 | 920 | case DEVINFO_STR_NAME: /* set per-core */ break; |
| 900 | 921 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Motorola 68K"); break; |
| 901 | | case DEVINFO_STR_VERSION: strcpy(info->s, "4.00"); break; |
| 922 | case DEVINFO_STR_VERSION: strcpy(info->s, "4.50"); break; |
| 902 | 923 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 903 | 924 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Karl Stenerud. All rights reserved. (2.1 fixes HJB)"); break; |
| 904 | 925 | |
| r6042 | r6043 | |
| 1062 | 1083 | writelong_d32 |
| 1063 | 1084 | }; |
| 1064 | 1085 | |
| 1086 | /* interface for 32-bit data bus with PMMU (68EC020, 68020) */ |
| 1087 | static UINT8 read_byte_32_mmu(const address_space *space, offs_t address) |
| 1088 | { |
| 1089 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1090 | |
| 1091 | if (m68k->pmmu_enabled) |
| 1092 | { |
| 1093 | address = pmmu_translate_addr(m68k, address); |
| 1094 | } |
| 1065 | 1095 | |
| 1096 | return memory_read_byte_32be(space, address); |
| 1097 | } |
| 1066 | 1098 | |
| 1099 | static void write_byte_32_mmu(const address_space *space, offs_t address, UINT8 data) |
| 1100 | { |
| 1101 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1102 | |
| 1103 | if (m68k->pmmu_enabled) |
| 1104 | { |
| 1105 | address = pmmu_translate_addr(m68k, address); |
| 1106 | } |
| 1067 | 1107 | |
| 1108 | memory_write_byte_32be(space, address, data); |
| 1109 | } |
| 1110 | |
| 1111 | static UINT16 read_immediate_16_mmu(const address_space *space, offs_t address) |
| 1112 | { |
| 1113 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1114 | |
| 1115 | if (m68k->pmmu_enabled) |
| 1116 | { |
| 1117 | address = pmmu_translate_addr(m68k, address); |
| 1118 | } |
| 1119 | |
| 1120 | return memory_decrypted_read_word(space, (address) ^ m68k->memory.opcode_xor); |
| 1121 | } |
| 1122 | |
| 1123 | /* potentially misaligned 16-bit reads with a 32-bit data bus (and 24-bit address bus) */ |
| 1124 | static UINT16 readword_d32_mmu(const address_space *space, offs_t address) |
| 1125 | { |
| 1126 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1127 | UINT16 result; |
| 1128 | |
| 1129 | if (m68k->pmmu_enabled) |
| 1130 | { |
| 1131 | address = pmmu_translate_addr(m68k, address); |
| 1132 | } |
| 1133 | |
| 1134 | if (!(address & 1)) |
| 1135 | return memory_read_word_32be(space, address); |
| 1136 | result = memory_read_byte_32be(space, address) << 8; |
| 1137 | return result | memory_read_byte_32be(space, address + 1); |
| 1138 | } |
| 1139 | |
| 1140 | /* potentially misaligned 16-bit writes with a 32-bit data bus (and 24-bit address bus) */ |
| 1141 | static void writeword_d32_mmu(const address_space *space, offs_t address, UINT16 data) |
| 1142 | { |
| 1143 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1144 | |
| 1145 | if (m68k->pmmu_enabled) |
| 1146 | { |
| 1147 | address = pmmu_translate_addr(m68k, address); |
| 1148 | } |
| 1149 | |
| 1150 | if (!(address & 1)) |
| 1151 | { |
| 1152 | memory_write_word_32be(space, address, data); |
| 1153 | return; |
| 1154 | } |
| 1155 | memory_write_byte_32be(space, address, data >> 8); |
| 1156 | memory_write_byte_32be(space, address + 1, data); |
| 1157 | } |
| 1158 | |
| 1159 | /* potentially misaligned 32-bit reads with a 32-bit data bus (and 24-bit address bus) */ |
| 1160 | static UINT32 readlong_d32_mmu(const address_space *space, offs_t address) |
| 1161 | { |
| 1162 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1163 | UINT32 result; |
| 1164 | |
| 1165 | if (m68k->pmmu_enabled) |
| 1166 | { |
| 1167 | address = pmmu_translate_addr(m68k, address); |
| 1168 | } |
| 1169 | |
| 1170 | if (!(address & 3)) |
| 1171 | return memory_read_dword_32be(space, address); |
| 1172 | else if (!(address & 1)) |
| 1173 | { |
| 1174 | result = memory_read_word_32be(space, address) << 16; |
| 1175 | return result | memory_read_word_32be(space, address + 2); |
| 1176 | } |
| 1177 | result = memory_read_byte_32be(space, address) << 24; |
| 1178 | result |= memory_read_word_32be(space, address + 1) << 8; |
| 1179 | return result | memory_read_byte_32be(space, address + 3); |
| 1180 | } |
| 1181 | |
| 1182 | /* potentially misaligned 32-bit writes with a 32-bit data bus (and 24-bit address bus) */ |
| 1183 | static void writelong_d32_mmu(const address_space *space, offs_t address, UINT32 data) |
| 1184 | { |
| 1185 | m68ki_cpu_core *m68k = get_safe_token(space->cpu); |
| 1186 | |
| 1187 | if (m68k->pmmu_enabled) |
| 1188 | { |
| 1189 | address = pmmu_translate_addr(m68k, address); |
| 1190 | } |
| 1191 | |
| 1192 | if (!(address & 3)) |
| 1193 | { |
| 1194 | memory_write_dword_32be(space, address, data); |
| 1195 | return; |
| 1196 | } |
| 1197 | else if (!(address & 1)) |
| 1198 | { |
| 1199 | memory_write_word_32be(space, address, data >> 16); |
| 1200 | memory_write_word_32be(space, address + 2, data); |
| 1201 | return; |
| 1202 | } |
| 1203 | memory_write_byte_32be(space, address, data >> 24); |
| 1204 | memory_write_word_32be(space, address + 1, data >> 8); |
| 1205 | memory_write_byte_32be(space, address + 3, data); |
| 1206 | } |
| 1207 | |
| 1208 | static const m68k_memory_interface interface_d32_mmu = |
| 1209 | { |
| 1210 | WORD_XOR_BE(0), |
| 1211 | read_immediate_16_mmu, |
| 1212 | read_byte_32_mmu, |
| 1213 | readword_d32_mmu, |
| 1214 | readlong_d32_mmu, |
| 1215 | write_byte_32_mmu, |
| 1216 | writeword_d32_mmu, |
| 1217 | writelong_d32_mmu |
| 1218 | }; |
| 1219 | |
| 1220 | |
| 1068 | 1221 | void m68k_set_reset_callback(const device_config *device, m68k_reset_func callback) |
| 1069 | 1222 | { |
| 1070 | 1223 | m68ki_cpu_core *m68k = get_safe_token(device); |
| r6042 | r6043 | |
| 1301 | 1454 | } |
| 1302 | 1455 | } |
| 1303 | 1456 | |
| 1457 | // 68020 with 68851 PMMU |
| 1458 | static CPU_INIT( m68020pmmu ) |
| 1459 | { |
| 1460 | m68ki_cpu_core *m68k = get_safe_token(device); |
| 1304 | 1461 | |
| 1462 | CPU_INIT_CALL(m68020); |
| 1463 | |
| 1464 | m68k->has_pmmu = 1; |
| 1465 | m68k->memory = interface_d32_mmu; |
| 1466 | } |
| 1467 | |
| 1468 | CPU_GET_INFO( m68020pmmu ) |
| 1469 | { |
| 1470 | switch (state) |
| 1471 | { |
| 1472 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1473 | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(m68020pmmu); break; |
| 1474 | |
| 1475 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1476 | case DEVINFO_STR_NAME: strcpy(info->s, "68020, 68851"); break; |
| 1477 | |
| 1478 | default: CPU_GET_INFO_CALL(m68020); break; |
| 1479 | } |
| 1480 | } |
| 1481 | |
| 1305 | 1482 | /**************************************************************************** |
| 1306 | 1483 | * M680EC20 section |
| 1307 | 1484 | ****************************************************************************/ |
| r6042 | r6043 | |
| 1361 | 1538 | m68k->cpu_type = CPU_TYPE_030; |
| 1362 | 1539 | m68k->state.subtypemask = m68k->cpu_type; |
| 1363 | 1540 | m68k->dasm_type = M68K_CPU_TYPE_68030; |
| 1364 | | m68k->memory = interface_d32; |
| 1541 | m68k->memory = interface_d32_mmu; |
| 1365 | 1542 | m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ |
| 1366 | 1543 | m68k->cyc_instruction = m68ki_cycles[3]; |
| 1367 | 1544 | m68k->cyc_exception = m68ki_exception_cycle_table[3]; |
| r6042 | r6043 | |
| 1480 | 1657 | m68k->cpu_type = CPU_TYPE_040; |
| 1481 | 1658 | m68k->state.subtypemask = m68k->cpu_type; |
| 1482 | 1659 | m68k->dasm_type = M68K_CPU_TYPE_68040; |
| 1483 | | m68k->memory = interface_d32; |
| 1660 | m68k->memory = interface_d32_mmu; |
| 1484 | 1661 | m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ |
| 1485 | 1662 | m68k->cyc_instruction = m68ki_cycles[4]; |
| 1486 | 1663 | m68k->cyc_exception = m68ki_exception_cycle_table[4]; |
| r6042 | r6043 | |
| 1568 | 1745 | m68k->cyc_movem_l = 2; |
| 1569 | 1746 | m68k->cyc_shift = 0; |
| 1570 | 1747 | m68k->cyc_reset = 518; |
| 1571 | | m68k->has_pmmu = 1; |
| 1748 | m68k->has_pmmu = 0; |
| 1572 | 1749 | } |
| 1573 | 1750 | |
| 1574 | 1751 | CPU_GET_INFO( m68ec040 ) |