Previous 199869 Revisions Next

r29586 Sunday 13th April, 2014 at 03:25:18 UTC by R. Belmont
m68k: Update used and modified bits in the page tables and greatly improved PTEST results on 68040. [R. Belmont]


nw: do a clean build after this or nothing using a 680x0 will work properly.
[src/emu/cpu/m68000]m68000.h m68kcpu.c m68kmmu.h

trunk/src/emu/cpu/m68000/m68kmmu.h
r29585r29586
625625      // is UDT marked valid?
626626      if (root_entry & 2)
627627      {
628         // we're accessing through this root entry, so set the U bit
629         if ((!(root_entry & 0x8)) && (!ptest))
630         {
631            root_entry |= 0x8;
632            m68k->program->write_dword(root_ptr, root_entry);
633         }
634
635         // PTEST: any write protect bits set in the search tree will set W in SR
636         if ((ptest) && (root_entry & 4))
637         {
638            m68k->mmu_tmp_sr |= 4;
639         }
640
628641         pointer_ptr = (root_entry & ~0x1ff) + (ptr_idx<<2);
629642         pointer_entry = m68k->program->read_dword(pointer_ptr);
630643
644         // PTEST: any write protect bits set in the search tree will set W in SR
645         if ((ptest) && (pointer_entry & 4))
646         {
647            m68k->mmu_tmp_sr |= 4;
648         }
649
650         // update U bit on this pointer entry too
651         if ((!(pointer_entry & 0x8)) && (!ptest))
652         {
653            pointer_entry |= 0x8;
654            m68k->program->write_dword(pointer_ptr, pointer_entry);
655         }
656
631657         //          logerror("pointer entry = %08x\n", pointer_entry);
632658
633659         // write protected by the root or pointer entries?
r29585r29586
682708         page_idx = (addr_in >> 13) & 0x1f;
683709         page = addr_in & 0x1fff;
684710         pointer_entry &= ~0x7f;
685
686711         //          logerror("8k pages: index %x page %x\n", page_idx, page);
687712      }
688713      else    // 4k pages
r29585r29586
690715         page_idx = (addr_in >> 12) & 0x3f;
691716         page = addr_in & 0xfff;
692717         pointer_entry &= ~0xff;
693
694718         //          logerror("4k pages: index %x page %x\n", page_idx, page);
695719      }
696720
697721      page_ptr = pointer_entry + (page_idx<<2);
698722      page_entry = m68k->program->read_dword(page_ptr);
723      m68k->mmu_last_page_entry_addr = page_ptr;
699724
700725      //      logerror("page_entry = %08x\n", page_entry);
701726
r29585r29586
703728      while ((page_entry & 3) == 2)
704729      {
705730         page_entry = m68k->program->read_dword(page_entry & ~0x3);
731         m68k->mmu_last_page_entry_addr = (page_entry & ~0x3);
706732      }
733      m68k->mmu_last_page_entry = page_entry;
707734
708735      // is the page write protected or supervisor protected?
709736      if ((((page_entry & 4) && !m68k->mmu_tmp_rw) || ((page_entry & 0x80) && !(fc&4))) && !ptest)
r29585r29586
745772               addr_out = (page_entry & ~0xfff) | page;
746773            }
747774
775            if (!(ptest))
776            {
777               page_entry |= 0x8;   // always set the U bit
748778
749            break;
779               // if we're writing, the M bit comes into play
780               if (!m68k->mmu_tmp_rw)
781               {
782                  page_entry |= 0x10;   // set Modified
783               }
750784
785               // if these updates resulted in a change, write the entry back where we found it
786               if (page_entry != m68k->mmu_last_page_entry)
787               {
788                  m68k->mmu_last_page_entry = page_entry;
789                  m68k->program->write_dword(m68k->mmu_last_page_entry_addr, m68k->mmu_last_page_entry);
790               }
791            }
792            else
793            {
794               // page entry: UR G U1 U0 S CM CM M U W PDT
795               // SR:         B  G U1 U0 S CM CM M 0 W T R
796               m68k->mmu_tmp_sr |= ((addr_out & ~0xfff) || (page_entry & 0x7f4));
797            }
798            break;
799
751800         case 2: // shouldn't happen
752801            fatalerror("68040: got indirect final page pointer, shouldn't be possible\n");
753802            break;
trunk/src/emu/cpu/m68000/m68kcpu.c
r29585r29586
10181018   save_item(NAME(mmu_acr1));
10191019   save_item(NAME(mmu_acr2));
10201020   save_item(NAME(mmu_acr3));
1021   save_item(NAME(mmu_last_page_entry));
1022   save_item(NAME(mmu_last_page_entry_addr));
10211023
10221024   for (int i=0; i<MMU_ATC_ENTRIES;i++) {
10231025      save_item(NAME(mmu_atc_tag[i]), i);
trunk/src/emu/cpu/m68000/m68000.h
r29585r29586
351351   UINT32 mmu_tt0, mmu_tt1;
352352   UINT32 mmu_itt0, mmu_itt1, mmu_dtt0, mmu_dtt1;
353353   UINT32 mmu_acr0, mmu_acr1, mmu_acr2, mmu_acr3;
354   UINT32 mmu_last_page_entry, mmu_last_page_entry_addr;
354355
355356   UINT16 mmu_tmp_sr;      /* temporary hack: status code for ptest and to handle write protection */
356357   UINT16 mmu_tmp_fc;      /* temporary hack: function code for the mmu (moves) */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team