Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VGAConsole"/> class.
        /// </summary>
        public VGAConsole(SimCPU simCPU, ISimDisplay dislayForm)
            : base(simCPU)
        {
            this.dislayForm      = dislayForm;
            this.IsMemoryMonitor = true;

            ioBase      = StandardIOBase;
            baseAddress = StandardAddressBase;

            width  = 80;
            height = 27;

            cursorPosition = 0;
            lastCommand    = 0;

            font = new Font("Lucida Console", 9, FontStyle.Regular);
            //font = new Font("Consolas", 8, FontStyle.Regular);
            fontWidth  = (int)font.SizeInPoints;
            fontHeight = (int)font.SizeInPoints + 5;

            bitmap  = new System.Drawing.Bitmap(fontWidth * width, fontHeight * height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            graphic = Graphics.FromImage(bitmap);

            dislayForm.SetBitMap(bitmap);
        }
Exemplo n.º 2
0
        protected void AddBreakpointByLabel(int lineNbr, string data)
        {
            var symbol = SimCPU.GetSymbol(data);

            AddOutput(lineNbr, "STATUS: Add breakpoint " + symbol.Name + " at " + MainForm.Format(symbol.Address, MainForm.Display32));
            MainForm.AddBreakpoint(symbol.Name, symbol.Address);
        }
Exemplo n.º 3
0
        protected void AddWatchByLabel(int lineNbr, string data)
        {
            var symbol = SimCPU.GetSymbol(data);

            AddOutput(lineNbr, "STATUS: Add watach " + symbol.Name + " at " + MainForm.Format(symbol.Address, MainForm.Display32));
            MainForm.AddWatch(symbol.Name, symbol.Address, (int)symbol.Size);
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        public override BaseSimDevice Clone(SimCPU simCPU)
        {
            var device = new CMOS(simCPU);

            device.index = index;
            return(device);
        }
Exemplo n.º 6
0
        public override void ExtendState(SimCPU simCPU)
        {
            var x86 = simCPU as CPUx86;

            AddStack(x86);
            AddStackFrame(x86);
            AddCallStack(x86);
        }
Exemplo n.º 7
0
        public override void Execute(SimCPU cpu, SimInstruction instruction)
        {
            var x86 = cpu as CPUx86;

            x86.EIP.Value = x86.EIP.Value + instruction.OpcodeSize;

            Execute(x86, instruction);
        }
Exemplo n.º 8
0
        public override void Execute(SimCPU cpu, SimInstruction instruction)
        {
            var x86 = cpu as CPUx86;

            x86.EIP.Value = x86.EIP.Value + instruction.OpcodeSize;

            Execute(x86, instruction);
        }
Exemplo n.º 9
0
        public override BaseSimDevice Clone(SimCPU simCPU)
        {
            var device = new MosaDebug(simCPU, debug);

            device.value32 = value32;
            device.bytes32 = bytes32;
            device.sb      = new StringBuilder(sb.ToString());

            return(device);
        }
Exemplo n.º 10
0
        public override BaseSimDevice Clone(SimCPU simCPU)
        {
            var device = new MosaDebug(simCPU, debug);

            device.value32 = value32;
            device.bytes32 = bytes32;
            device.sb = new StringBuilder(sb.ToString());

            return device;
        }
Exemplo n.º 11
0
        private void AddSymbol(ulong ip)
        {
            SimSymbol symbol = SimCPU.FindSymbol(ip);

            if (symbol != null)
            {
                treeView1.Nodes.Add(new CallStackEntry(symbol, ip, true));
            }
            else
            {
                treeView1.Nodes.Add(new CallStackEntry(ip, true));
            }
        }
Exemplo n.º 12
0
        private void UpdateDisplay()
        {
            int lines = lbMemory.Height / (lbMemory.Font.Height + 2);

            try
            {
                string nbr    = tbMemory.Text.ToUpper().Trim();
                int    digits = 10;
                int where = nbr.IndexOf('X');

                if (where >= 0)
                {
                    digits = 16;
                    nbr    = nbr.Substring(where + 1);
                }

                uint at = Convert.ToUInt32(nbr, digits);

                string[] newlines = new string[lines];

                for (int line = 0; line < lines; line++)
                {
                    string l = at.ToString("X").PadLeft(8, '0') + ':';
                    string d = string.Empty;
                    for (int x = 0; x < 16; x++)
                    {
                        byte mem = SimCPU.DirectRead8(at);

                        if (x % 4 == 0)
                        {
                            l = l + ' ';
                        }
                        l = l + mem.ToString("X").PadLeft(2, '0');
                        char b = (char)mem;
                        d = d + (char.IsLetterOrDigit(b) ? b : '.');
                        at++;
                    }

                    newlines[line] = l + ' ' + d;
                }
                lbMemory.Lines = newlines;
                Status         = string.Empty;
            }
            catch (Exception e)
            {
                Status = "Error: " + e.ToString();
            }
        }
Exemplo n.º 13
0
        public void AddHistory(BaseSimState simState)
        {
            if (!MainForm.Record)
            {
                return;
            }

            if (simState.IP == 0xFFFFFFF0)
            {
                return;
            }

            string methodName = SimCPU.FindSymbol(simState.IP).Name;

            pendingHistory.Enqueue(new HistoryEntry(simState, methodName, MainForm.Display32));
        }
Exemplo n.º 14
0
        public override void UpdateDock(BaseSimState simState)
        {
            var currentInstruction = simState.Instruction;
            var nextInstruction    = SimCPU.GetOpcode(simState.NextIP);

            textBox1.Text = simState.Tick.ToString();
            textBox2.Text = currentInstruction != null?currentInstruction.ToString() : "-BLANK-";

            textBox3.Text = nextInstruction != null?nextInstruction.ToString() : "-BLANK-";

            textBox4.Text = "0x" + simState.IP.ToString("X8");
            textBox5.Text = "0x" + simState.NextIP.ToString("X8");

            textBox6.Text = simState.CPUException != null?simState.CPUException.ToString() : "None";

            double speed = simState.Tick / simState.TotalElapsedSeconds;

            textBox7.Text = speed.ToString("0.00");

            Refresh();
        }
Exemplo n.º 15
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     var device = new CMOS(simCPU);
     device.index = index;
     return device;
 }
Exemplo n.º 16
0
        public static readonly uint VirtualPageBitMap = 1024 * 1024 * 21; // 0x1500000

        #endregion Fields

        #region Constructors

        public MosaKernel(SimCPU simCPU)
            : base(simCPU)
        {
        }
Exemplo n.º 17
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return new MosaImage(simCPU);
 }
Exemplo n.º 18
0
        public static readonly uint VirtualPageBitMap = 1024 * 1024 * 20;  // 0x01400000

        public MosaKernel(SimCPU simCPU)
            : base(simCPU)
        {
        }
Exemplo n.º 19
0
 public PowerUp(SimCPU simCPU)
     : base(simCPU)
 {
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MosaDebug"/> class.
 /// </summary>
 /// <param name="simCPU">The sim cpu.</param>
 public MosaDebug(SimCPU simCPU)
     : base(simCPU)
 {
     debug = null;
 }
Exemplo n.º 21
0
 public BaseSimDevice(SimCPU simCPU)
 {
     this.simCPU     = simCPU;
     IsMemoryMonitor = false;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CMOS"/> class.
 /// </summary>
 /// <param name="ioBase">The io base.</param>
 public CMOS(SimCPU simCPU)
     : base(simCPU)
 {
 }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BochDebug"/> class.
 /// </summary>
 /// <param name="simCPU">The sim cpu.</param>
 public BochDebug(SimCPU simCPU)
     : base(simCPU)
 {
     debug = null;
 }
Exemplo n.º 24
0
        public static readonly uint MultibootStructure = 0x10090;         // same as QEMU

        public Multiboot(SimCPU simCPU)
            : base(simCPU)
        {
        }
Exemplo n.º 25
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return(new Multiboot(simCPU));
 }
Exemplo n.º 26
0
 public override void ExtendState(SimCPU simCPU)
 {
     var x86 = simCPU as CPUx86;
     AddStack(x86);
     AddStackFrame(x86);
     AddCallStack(x86);
 }
Exemplo n.º 27
0
 public PowerUp(SimCPU simCPU)
     : base(simCPU)
 {
 }
Exemplo n.º 28
0
 public SimStream(SimCPU simCPU, ulong offset)
 {
     this.simCPU = simCPU;
     this.internaloffset = offset;
 }
Exemplo n.º 29
0
 public MosaImage(SimCPU simCPU)
     : base(simCPU)
 {
 }
Exemplo n.º 30
0
 public virtual void Execute(SimCPU cpu, SimInstruction instruction)
 {
 }
Exemplo n.º 31
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return(new MosaImage(simCPU));
 }
Exemplo n.º 32
0
		public BaseSimDevice(SimCPU simCPU)
		{
			this.simCPU = simCPU;
			IsMemoryMonitor = false;
		}
Exemplo n.º 33
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return(new MosaTestMemory(simCPU));
 }
Exemplo n.º 34
0
 public BaseSimDevice(SimCPU simCPU)
 {
     this.simCPU = simCPU;
 }
Exemplo n.º 35
0
 public MosaTestMemory(SimCPU simCPU)
     : base(simCPU)
 {
 }
Exemplo n.º 36
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return new Multiboot(simCPU);
 }
Exemplo n.º 37
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return(new MosaKernel(simCPU));
 }
 public SimLinkerFinalizationStage(SimCPU simCPU)
 {
     this.simCPU = simCPU;
 }
Exemplo n.º 39
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return new MosaTestMemory(simCPU);
 }
Exemplo n.º 40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MosaDebug"/> class.
 /// </summary>
 /// <param name="simCPU">The sim cpu.</param>
 public MosaDebug(SimCPU simCPU)
     : base(simCPU)
 {
     debug = null;
 }
Exemplo n.º 41
0
 public SimLinkerFinalizationStage(SimCPU simCPU)
 {
     this.simCPU = simCPU;
 }
Exemplo n.º 42
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return new MosaKernel(simCPU);
 }
Exemplo n.º 43
0
        public ulong offset;            // hack until next version of SharpDism

        public SimAssemblyCode(SimCPU simCPU, ulong offset = 0)
        {
            this.simCPU = simCPU;
            this.offset = offset;
        }
Exemplo n.º 44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BochDebug"/> class.
 /// </summary>
 /// <param name="simCPU">The sim cpu.</param>
 public BochDebug(SimCPU simCPU)
     : base(simCPU)
 {
     debug = null;
 }
Exemplo n.º 45
0
 public MosaTestMemory(SimCPU simCPU)
     : base(simCPU)
 {
 }
Exemplo n.º 46
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return(null);            // not clonable
 }
Exemplo n.º 47
0
 public SimStream(SimCPU simCPU, ulong offset)
 {
     this.simCPU         = simCPU;
     this.internaloffset = offset;
 }
Exemplo n.º 48
0
        public static readonly uint MultibootStructure = 0x10090; // same as QEMU

        #endregion Fields

        #region Constructors

        public Multiboot(SimCPU simCPU)
            : base(simCPU)
        {
        }
Exemplo n.º 49
0
 public abstract BaseSimDevice Clone(SimCPU simCPU);
Exemplo n.º 50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VGAConsole"/> class.
        /// </summary>
        public VGAConsole(SimCPU simCPU, ISimDisplay dislayForm)
            : base(simCPU)
        {
            this.dislayForm = dislayForm;
            IsMemoryMonitor = true;

            ioBase = StandardIOBase;
            baseAddress = StandardAddressBase;

            width = 80;
            height = 27;

            cursorPosition = 0;
            lastCommand = 0;

            font = new Font("Lucida Console", 9, FontStyle.Regular);

            //font = new Font("Consolas", 8, FontStyle.Regular);
            fontWidth = (int)font.SizeInPoints;
            fontHeight = (int)font.SizeInPoints + 5;

            bitmap = new System.Drawing.Bitmap(fontWidth * width, fontHeight * height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            graphic = Graphics.FromImage(bitmap);

            dislayForm.SetBitMap(bitmap);
        }
Exemplo n.º 51
0
        public static readonly uint ImageSize   = 1024 * 1024 * 8;       // 8MB

        public MosaImage(SimCPU simCPU)
            : base(simCPU)
        {
        }
Exemplo n.º 52
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return null; // not clonable
 }
Exemplo n.º 53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MosaDebug"/> class.
 /// </summary>
 /// <param name="simCPU">The sim cpu.</param>
 /// <param name="output">The output.</param>
 public MosaDebug(SimCPU simCPU, TextWriter output)
     : base(simCPU)
 {
     debug = output;
 }
Exemplo n.º 54
0
 public override BaseSimDevice Clone(SimCPU simCPU)
 {
     return new PowerUp(simCPU);
 }
Exemplo n.º 55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MosaDebug"/> class.
 /// </summary>
 /// <param name="simCPU">The sim cpu.</param>
 /// <param name="output">The output.</param>
 public MosaDebug(SimCPU simCPU, TextWriter output)
     : base(simCPU)
 {
     debug = output;
 }
Exemplo n.º 56
0
 public virtual void Execute(SimCPU cpu, SimInstruction instruction)
 {
 }