Esempio n. 1
0
 public SimMonitor(SimCPU cpu)
 {
     CPU         = cpu;
     DebugOutput = false;
     //DebugOutput = true;
     Stop = false;
     StepOverBreakPoint = 0;
 }
Esempio n. 2
0
 public SimMonitor(SimCPU cpu)
 {
     CPU = cpu;
     DebugOutput = false;
     //DebugOutput = true;
     Stop = false;
     StepOverBreakPoint = 0;
 }
Esempio n. 3
0
        protected SimCPU(SimCPU simCPU)
        {
            // Create CPU clone with the assumption that NO new instructions or symbols are added.

            MemoryBlocks = new uint[simCPU.MemoryBlocks.Length][];
            InstructionCache = simCPU.InstructionCache;
            SourceInformation = simCPU.SourceInformation;
            SimDevices = new List<BaseSimDevice>();
            SimMemoryDevices = simCPU.SimMemoryDevices;
            PortDevices = new BaseSimDevice[65536];
            Symbols = simCPU.Symbols;
            Monitor = new SimMonitor(this);
            AcceleratorAddresses = new List<ulong>();
            AcceleratorEnabled = simCPU.AcceleratorEnabled;
            AccelerationMethods = new Dictionary<ulong, AccelerationMethod>();
            MemoryRegions = simCPU.MemoryRegions;
            Tick = simCPU.Tick;
            IsLittleEndian = simCPU.IsLittleEndian;

            CurrentProgramCounter = simCPU.CurrentProgramCounter;
            LastProgramCounter = simCPU.LastProgramCounter;
            LastInstruction = simCPU.LastInstruction;
            StackPointer = simCPU.StackPointer;
            FramePointer = simCPU.FramePointer;
            LastException = simCPU.LastException;

            foreach (var device in simCPU.SimDevices)
            {
                var clone = device.Clone(this);

                if (clone == null)
                    throw new InvalidProgramException("Unable to clone sim device");

                SimDevices.Add(clone);

                var ports = clone.GetPortList();

                if (ports != null)
                {
                    foreach (var port in ports)
                    {
                        PortDevices[port] = clone;
                    }
                }
            }

            for (int i = 0; i < MemoryBlocks.Length; i++)
            {
                if (simCPU.MemoryBlocks[i] == null)
                    continue;

                MemoryBlocks[i] = new uint[BlockSize];

                simCPU.MemoryBlocks[i].CopyTo(MemoryBlocks[i], 0);
            }

            RegisterAccelerationFunctions();
        }
Esempio n. 4
0
        protected BaseSimState(SimCPU simCPU)
        {
            Tick         = simCPU.Tick;
            IP           = simCPU.LastProgramCounter;
            NextIP       = simCPU.CurrentProgramCounter;
            Instruction  = simCPU.LastInstruction;
            CPUException = simCPU.LastException;

            Values = new Dictionary <string, object>();
        }
Esempio n. 5
0
        protected BaseSimState(SimCPU simCPU)
        {
            Tick = simCPU.Tick;
            IP = simCPU.LastProgramCounter;
            NextIP = simCPU.CurrentProgramCounter;
            Instruction = simCPU.LastInstruction;
            CPUException = simCPU.LastException;

            Values = new Dictionary<string, object>();
        }
Esempio n. 6
0
 public virtual void ExtendState(SimCPU simCPU)
 {
 }
 public SimAssemblyCode(SimCPU simCPU, ulong offset = 0)
 {
     this.simCPU = simCPU;
     this.offset = offset;
 }
Esempio n. 8
0
        protected SimCPU(SimCPU simCPU)
        {
            // Create CPU clone with the assumption that NO new instructions or symbols are added.

            MemoryBlocks         = new uint[simCPU.MemoryBlocks.Length][];
            InstructionCache     = simCPU.InstructionCache;
            SourceInformation    = simCPU.SourceInformation;
            SimDevices           = new List <BaseSimDevice>();
            SimMemoryDevices     = simCPU.SimMemoryDevices;
            PortDevices          = new BaseSimDevice[65536];
            Symbols              = simCPU.Symbols;
            Monitor              = new SimMonitor(this);
            AcceleratorAddresses = new List <ulong>();
            AcceleratorEnabled   = simCPU.AcceleratorEnabled;
            AccelerationMethods  = new Dictionary <ulong, AccelerationMethod>();
            MemoryRegions        = simCPU.MemoryRegions;
            Tick           = simCPU.Tick;
            IsLittleEndian = simCPU.IsLittleEndian;

            CurrentProgramCounter = simCPU.CurrentProgramCounter;
            LastProgramCounter    = simCPU.LastProgramCounter;
            LastInstruction       = simCPU.LastInstruction;
            StackPointer          = simCPU.StackPointer;
            FramePointer          = simCPU.FramePointer;
            LastException         = simCPU.LastException;

            foreach (var device in simCPU.SimDevices)
            {
                var clone = device.Clone(this);

                if (clone == null)
                {
                    throw new InvalidProgramException("Unable to clone sim device");
                }

                SimDevices.Add(clone);

                var ports = clone.GetPortList();

                if (ports != null)
                {
                    foreach (var port in ports)
                    {
                        PortDevices[port] = clone;
                    }
                }
            }

            for (int i = 0; i < MemoryBlocks.Length; i++)
            {
                if (simCPU.MemoryBlocks[i] == null)
                {
                    continue;
                }

                MemoryBlocks[i] = new uint[BlockSize];

                simCPU.MemoryBlocks[i].CopyTo(MemoryBlocks[i], 0);
            }

            RegisterAccelerationFunctions();
        }
Esempio n. 9
0
 public override void ExtendState(SimCPU simCPU)
 {
     var x86 = simCPU as CPUx86;
     AddStack(x86);
     AddStackFrame(x86);
     AddCallStack(x86);
 }
Esempio n. 10
0
        public void StartSimulator(string platform)
        {
            if (TypeSystem == null)
                return;

            Status = "Compiling...";

            Architecture = GetArchitecture(platform);
            var simAdapter = GetSimAdaptor(platform);
            Linker = new SimLinker(simAdapter);

            compileStartTime = DateTime.Now;

            var compilerOptions = new CompilerOptions();

            compilerOptions.EnableSSA = true;
            compilerOptions.EnableOptimizations = true;
            compilerOptions.EnablePromoteTemporaryVariablesOptimization = true;
            compilerOptions.EnableSparseConditionalConstantPropagation = true;

            SimCompiler.Compile(TypeSystem, TypeLayout, InternalTrace, compilerOptions, Architecture, simAdapter, Linker);

            SimCPU = simAdapter.SimCPU;

            SimCPU.Monitor.BreakAtTick = 1;
            SimCPU.Monitor.BreakOnException = true;
            SimCPU.Monitor.OnStateUpdate = UpdateSimState;
            SimCPU.Reset();

            Display32 = SimCPU.GetState().NativeRegisterSize == 32;

            SimCPU.Monitor.OnExecutionStepCompleted(true);

            Status = "Compiled.";

            symbolView.CreateEntries();
        }
Esempio n. 11
0
        private void Compile()
        {
            var simAdapter = GetSimAdaptor("x86");

            compileStartTime = DateTime.Now;

            Compiler.CompilerOptions.EnableSSA = false;
            Compiler.CompilerOptions.EnableOptimizations = false;
            Compiler.CompilerOptions.EnableVariablePromotion = false;
            Compiler.CompilerOptions.EnableSparseConditionalConstantPropagation = false;
            Compiler.CompilerOptions.EnableInlinedMethods = false;

            Compiler.CompilerOptions.LinkerFactory = delegate { return new SimLinker(simAdapter); };
            Compiler.CompilerFactory = delegate { return new SimCompiler(simAdapter); };

            Compiler.Execute(Environment.ProcessorCount);

            SimCPU = simAdapter.SimCPU;

            SimCPU.Monitor.BreakAtTick = 1;
            SimCPU.Monitor.BreakOnException = true;
            SimCPU.Monitor.OnStateUpdate = UpdateSimState;
            SimCPU.Reset();

            Display32 = SimCPU.GetState().NativeRegisterSize == 32;
        }
Esempio n. 12
0
 public virtual void ExtendState(SimCPU simCPU)
 {
 }