Пример #1
0
        public long GetPageForPhysAddr(HARDWARE_ADDRESS_ENTRY PAddr, ref long[] block, ref bool GotData, bool NoCache = true)
        {
            long rv = 0;
            // convert PAddr to PFN
            var aPFN = PAddr.NextTable_PFN;

            GotData = false;
            //NoCache = true;

            if (!NoCache && PageCache.ContainsKey(aPFN))
            {
                do
                {
                    PageCache.TryGetValue(aPFN, out block);
                }while (block == null);
                // shift down since were loading a long[]
                GotData = true;
                return(block[(PAddr >> 3) & 0x1ff]);
            }

            // should return with - error_value
            if (aPFN > int.MaxValue || aPFN < 0)
            {
                return(0);
            }
#if USE_BITMAP
            if (pfnTableIdx != null)
            {
                pfnTableIdx.Set((int)PFN, true);
            }
#endif
            // paranoid android setting

            var FileOffset = OffsetToMemIndex(aPFN);
            if (FileOffset < 0)
            {
                rv = MagicNumbers.BAD_RUN_CONFIG_READ;
            }
            else
            {
                // add back in the file offset for possible exact byte lookup
                rv = GetPageFromFileOffset(FileOffset + PAddr.AddressOffset, ref block, ref GotData);
            }

            if (!GotData)
            {
                rv = MagicNumbers.BAD_VALUE_READ;
            }

            if (!NoCache && GotData)
            {
                PageCache.TryAdd(aPFN, block);
            }

            return(rv);
        }