Exemplo n.º 1
0
 public LargePage(IVirtualMemory memory, uint count = 0x800000)
 {
     _memory = memory;
     if (count < 512) count *= 1024 * 1024;
     data = (byte*)_memory.Alloc(count, out size); //-READ|WRITE
     if (data == null)
         throw new InvalidOperationException("virtual alloc");
 }
Exemplo n.º 2
0
        public void ProcessAll()
        {
            _physicalMemory = _physicalMemoryFactory.Create(FrameList);
            _virtualMemory  = _virtualMemoryFactory.Create(PageList);

            Process.PhysicalMemory = _physicalMemory;
            Process.VirtualMemory  = _virtualMemory;

            while (Process.HasNextPageToLoad)
            {
                Process.LoadNextPage();
            }

            StrategyName = Process.ToString();
            PageErrors   = Process.PagesErrors;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Decodes the instruction in virtual memory at the given address.
        /// </summary>
        /// <param name="mem"></param>
        /// <param name="address"></param>
        public Instruction(IVirtualMemory vMem, uint address, out bool pageFault)
        {
            //
            // Read the first halfword of the instruction in, determine its type and see if we need go further.
            //
            ushort hword = vMem.ReadHalfWordV(address, SegmentType.Code, out pageFault);

            Op = (Opcode)(hword >> 8);

            Rx = (hword & 0xf0) >> 4;
            Ry = hword & 0xf;

            if ((hword & 0x8000) != 0)
            {
                //
                // This is a memory reference instruction.
                // Is this a short or long displacement instruction?
                //
                if ((hword & 0x1000) != 0)
                {
                    Displacement = (int)vMem.ReadWordV(address + 2, SegmentType.Code, out pageFault);
                    Length       = 6;
                }
                else
                {
                    Displacement = (short)vMem.ReadHalfWordV(address + 2, SegmentType.Code, out pageFault);
                    Length       = 4;
                }

                // Compute the displacement address (PC + Displacement) for branches.
                // The LSB is used for branch prediction logic
                BranchAddress = (uint)((address + Displacement) & 0xfffffffe);
            }
            else
            {
                Length = 2;
            }
        }
Exemplo n.º 4
0
 public static IVirtualMemory CreateRef(this IVirtualMemory objectRef) =>
 ((IVirtualMemory)objectRef.CreateRef(typeof(IVirtualMemory)));