Exemple #1
0
        private TLBEntry CreateEntryFromRegs()
        {
            TLBEntry entry = new TLBEntry(m_MipsState.Addressing64BitMode);

            entry.PageMask = m_Cp0Regs.PageMask;
            entry.VPN2     = new VirtualPageNumber2(m_Cp0Regs.EntryHi);
            entry.PfnOdd   = m_Cp0Regs.EntryLo0;
            entry.PfnEven  = m_Cp0Regs.EntryLo1;
            return(entry);
        }
Exemple #2
0
        public int IndexOf(TLBEntry item)
        {
            for (Int32 i = 0; i < m_Entries.Length; i++)
            {
                if (Object.Equals(item, m_Entries[i]))
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemple #3
0
        public long TranslateVirtualAddress(long virtualAddress)
        {
            VirtualPageNumber2 vpn2     = new VirtualPageNumber2(m_Cp0Regs.EntryHi);
            PageSize           pageSize = new PageSize(m_Cp0Regs.PageMask);
            TLBEntry           entry    = null;

            /* Note:
             * We are assuming the software set ASID and VPN in the EntryHi when comparing
             * the virtual address with the TLB cache.  Without a real test of this,
             * we don't know truly know if we rely on EntryHi every time there is a translation
             * to be performed.  I do not understand how the TLB is really even used on the N64
             * system, virtual memory is useless without having some kind of pagefile.
             */

            if (m_DuplicateEntryError)
            {
                // TODO: Set the TS bit in the status register
                m_DisableTLB = true;
                return(-1);
            }

            /* Access the global entries first */
            if (!m_GlobalVPN2Dictionary.TryGetValue(vpn2, out entry))
            {
                /* If nothing is in global table, then access the entries grouped by an ASID */
                if (!m_VPN2Dictionary.TryGetValue(vpn2, out entry))
                {
                    throw new TLBException(TLBExceptionType.Refill);
                }
            }

            Boolean         isOddPage = ((virtualAddress & pageSize.Size) > 0) ? false : true;
            PageFrameNumber pfn       = isOddPage ? entry.PfnOdd : entry.PfnEven;

            if (pfn.IsValid)
            {
                return(pfn.MapPhysical(pageSize, (UInt64)virtualAddress));
            }
            else
            {
                throw new TLBException(TLBExceptionType.Refill);
            }
        }
Exemple #4
0
        public virtual void Read()
        {
            if (m_DisableTLB)
            {
                return;
            }

            UpdateRandom();

            TLBEntry entry = GetEntry((Int32)m_Cp0Regs.Index);

            if (entry != null)
            {
                m_Cp0Regs.PageMask = entry.PageMask;
                m_Cp0Regs.EntryHi  = entry.VPN2.EntryHi;
                m_Cp0Regs.EntryLo0 = entry.PfnOdd;
                m_Cp0Regs.EntryLo1 = entry.PfnEven;
            }
        }
Exemple #5
0
        public void AddEntry(int index, TLBEntry entry)
        {
            m_Entries[index] = entry;

            try
            {
                /* Is the entry global? */
                if (entry.IsGlobal)
                {
                    m_GlobalVPN2Dictionary.Add(entry.VPN2, entry);
                }
                else
                {
                    m_VPN2Dictionary.Add(entry.VPN2, entry);
                }
            }
            catch
            {
                m_DuplicateEntryError = true;
            }

            UpdateRandom();
            OnCacheChanged(index);
        }
Exemple #6
0
 public bool Remove(TLBEntry item)
 {
     throw new NotSupportedException();
 }
Exemple #7
0
 public bool Contains(TLBEntry item)
 {
     return(m_Entries.Contains(item));
 }
Exemple #8
0
 public void Add(TLBEntry item)
 {
     throw new NotSupportedException();
 }
Exemple #9
0
 public void Insert(int index, TLBEntry item)
 {
     m_Entries[index] = item;
 }
Exemple #10
0
 internal TLBEntryInfo(Int32 index, TLBEntry entry)
 {
     m_TLBIndex = index;
     m_Entry    = entry;
 }