Пример #1
0
 private void ToolStripRevision_Click(object sender, EventArgs e)
 {
     if (version == BoardVersion.RevB)
     {
         version = BoardVersion.RevC;
     }
     else if (version == BoardVersion.RevC)
     {
         version = BoardVersion.RevU;
     }
     else if (version == BoardVersion.RevU)
     {
         version = BoardVersion.RevUPlus;
     }
     else
     {
         version = BoardVersion.RevB;
     }
     kernel.SetVersion(version);
     if (uploaderWindow != null)
     {
         uploaderWindow.SetBoardVersion(version);
     }
     DisplayBoardVersion();
     // Reset the memory, keyboard, GABE and reload the program?
     debugWindow.Pause();
     BasicWindow_Load(null, null);
 }
Пример #2
0
        public FoenixSystem(Gpu gpu, BoardVersion version, string DefaultKernel)
        {
            this.gpu     = gpu;
            boardVersion = version;

            int          memSize = MemoryMap.RAM_SIZE;
            CodecRAM     codec   = null;
            SDCardDevice sdcard  = null;

            if (boardVersion == BoardVersion.RevC)
            {
                memSize *= 2;
                codec    = new CodecRAM(MemoryMap.CODEC_WR_CTRL_FMX, 2); // This register is only a single byte but we allow writing a word
                sdcard   = new GabeSDController(MemoryMap.GABE_SDC_CTRL_START, MemoryMap.GABE_SDC_CTRL_SIZE);
            }
            else
            {
                codec  = new CodecRAM(MemoryMap.CODEC_WR_CTRL, 2); // This register is only a single byte but we allow writing a word
                sdcard = new CH376SRegister(MemoryMap.SDCARD_DATA, MemoryMap.SDCARD_SIZE);
            }
            MemMgr = new MemoryManager
            {
                RAM     = new MemoryRAM(MemoryMap.RAM_START, memSize),                  // RAM: 2MB Rev B, 4MB Rev C
                VICKY   = new MemoryRAM(MemoryMap.VICKY_START, MemoryMap.VICKY_SIZE),   // 60K
                VIDEO   = new MemoryRAM(MemoryMap.VIDEO_START, MemoryMap.VIDEO_SIZE),   // 4MB Video
                FLASH   = new MemoryRAM(MemoryMap.FLASH_START, MemoryMap.FLASH_SIZE),   // 8MB RAM
                BEATRIX = new GabeRAM(MemoryMap.BEATRIX_START, MemoryMap.BEATRIX_SIZE), // 4K

                // Special devices
                MATH      = new MathCoproRegisters(MemoryMap.MATH_START, MemoryMap.MATH_END - MemoryMap.MATH_START + 1), // 48 bytes
                KEYBOARD  = new KeyboardRegister(MemoryMap.KBD_DATA_BUF, 5),
                SDCARD    = sdcard,
                INTERRUPT = new InterruptController(MemoryMap.INT_PENDING_REG0, 4),
                UART1     = new UART(MemoryMap.UART1_REGISTERS, 8),
                UART2     = new UART(MemoryMap.UART2_REGISTERS, 8),
                OPL2      = new OPL2(MemoryMap.OPL2_S_BASE, 256),
                MPU401    = new MPU401(MemoryMap.MPU401_REGISTERS, 2),
                VDMA      = new VDMA(MemoryMap.VDMA_START, MemoryMap.VDMA_SIZE)
            };
            MemMgr.CODEC = codec;

            // Assign memory variables used by other processes
            CPU = new CPU(MemMgr);
            CPU.SimulatorCommand += CPU_SimulatorCommand;
            gpu.VRAM              = MemMgr.VIDEO;
            gpu.RAM   = MemMgr.RAM;
            gpu.VICKY = MemMgr.VICKY;
            MemMgr.VDMA.setVideoRam(MemMgr.VIDEO);

            // Load the kernel.hex if present
            ResetCPU(true, DefaultKernel);

            // This fontset is loaded just in case the kernel doesn't provide one.
            gpu.LoadFontSet("Foenix", @"Resources\Bm437_PhoenixEGA_8x8.bin", 0, CharacterSet.CharTypeCodes.ASCII_PET, CharacterSet.SizeCodes.Size8x8);

            // Write bytes $9F in the joystick registers to mean that they are not installed.
            MemMgr.WriteWord(0xAFE800, 0x9F9F);
            MemMgr.WriteWord(0xAFE802, 0x9F9F);
        }
Пример #3
0
        public void SetBoardVersion(BoardVersion ver)
        {
            boardVersion = ver;
            switch (ver)
            {
            case BoardVersion.RevB:
                RevModeLabel.Text = "Mode: RevB";
                break;

            case BoardVersion.RevC:
                RevModeLabel.Text = "Mode: RevC";
                break;
            }
        }
Пример #4
0
 private void ToolStripRevision_Click(object sender, EventArgs e)
 {
     if (version == BoardVersion.RevB)
     {
         version = BoardVersion.RevC;
     }
     else
     {
         version = BoardVersion.RevB;
     }
     kernel.SetVersion(version);
     if (uploaderWindow != null)
     {
         uploaderWindow.SetBoardVersion(version);
     }
     DisplayBoardVersion();
     // TODO - Reset the memory and reload the program?
 }
Пример #5
0
 public MainWindow(Dictionary <string, string> context)
 {
     if (context != null)
     {
         if (context.ContainsKey("jumpStartAddress"))
         {
             jumpStartAddress = int.Parse(context["jumpStartAddress"]);
         }
         if (context.ContainsKey("defaultKernel"))
         {
             defaultKernel = context["defaultKernel"];
         }
         if (context.ContainsKey("autoRun"))
         {
             autoRun = "true".Equals(context["autoRun"]);
         }
         if (context.ContainsKey("disabledIRQs"))
         {
             disabledIRQs = "true".Equals(context["disabledIRQs"]);
         }
         if (context.ContainsKey("version"))
         {
             if (context["version"] == "RevB")
             {
                 version = BoardVersion.RevB;
             }
             else if (context["version"] == "RevU")
             {
                 version = BoardVersion.RevU;
             }
         }
     }
     if (context == null || "true".Equals(context["Continue"]))
     {
         InitializeComponent();
         Instance = this;
     }
 }
Пример #6
0
        public MainWindow(Dictionary <string, string> context)
        {
            if (context != null)
            {
                if (context.ContainsKey("jumpStartAddress"))
                {
                    jumpStartAddress = int.Parse(context["jumpStartAddress"]);
                }
                if (context.ContainsKey("defaultKernel"))
                {
                    defaultKernel = context["defaultKernel"];
                }
                if (context.ContainsKey("autoRun"))
                {
                    autoRun = "true".Equals(context["autoRun"]);
                }
                if (context.ContainsKey("disabledIRQs"))
                {
                    disabledIRQs = "true".Equals(context["disabledIRQs"]);
                }
                if (context.ContainsKey("version"))
                {
                    if (context["version"] == "RevB")
                    {
                        version = BoardVersion.RevB;
                    }
                    else if (context["version"] == "RevU")
                    {
                        version = BoardVersion.RevU;
                    }
                    else if (context["version"] == "RevU+")
                    {
                        version = BoardVersion.RevUPlus;
                    }
                }
            }
            // If the user didn't specify context switches, read the ini setting
            if (context == null)
            {
                autoRun = Simulator.Properties.Settings.Default.Autorun;
                switch (Simulator.Properties.Settings.Default.BoardRevision)
                {
                case "B":
                    version = BoardVersion.RevB;
                    break;

                case "C":
                    version = BoardVersion.RevC;
                    break;

                case "U":
                    version = BoardVersion.RevU;
                    break;

                case "U+":
                    version = BoardVersion.RevUPlus;
                    break;
                }
            }
            if (context == null || "true".Equals(context["Continue"]))
            {
                InitializeComponent();
                Instance = this;
            }
        }
Пример #7
0
        /*
         * Read a file into memory
         */
        public void Load(String filename)
        {
            XmlReader reader = XmlReader.Create(filename);

            Version = BoardVersion.RevB;
            kernel.ResCheckerRef.Clear();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name.Equals("data"))
                    {
                        LoadMemory(reader.GetAttribute("address"), reader.ReadElementContentAsString());
                        continue;
                    }
                    if (reader.Name.Equals("resource"))
                    {
                        ResourceChecker.Resource res = new ResourceChecker.Resource
                        {
                            Name         = reader.GetAttribute("name"),
                            SourceFile   = reader.GetAttribute("source"),
                            StartAddress = Convert.ToInt32(reader.GetAttribute("start-address"), 16),
                            Length       = Convert.ToInt32(reader.GetAttribute("length"), 16)
                        };
                        string resType = reader.GetAttribute("resource-type");
                        if (resType != null)
                        {
                            res.FileType = (ResourceType)Enum.Parse(typeof(ResourceType), resType);
                        }
                        else
                        {
                            res.FileType = ResourceType.raw;
                        }
                        kernel.ResCheckerRef.Add(res);
                        continue;
                    }
                    if (reader.Name.Equals("code"))
                    {
                        string addrStr = reader.GetAttribute("address");
                        if (addrStr.Length > 0)
                        {
                            int       address = Convert.ToInt32(addrStr.Replace("$", ""), 16);
                            string    label   = reader.GetAttribute("label");
                            string    source  = reader.GetAttribute("source");
                            string    command = reader.GetAttribute("command");
                            DebugLine code    = new DebugLine(address);
                            code.SetLabel(label);
                            code.SetMnemonic(source);
                            code.SetOpcodes(command);
                            if (codeList.ContainsKey(address))
                            {
                                codeList.Remove(address);
                            }
                            codeList.Add(address, code);
                        }
                        continue;
                    }
                    if (reader.Name.Equals("breakpoint"))
                    {
                        string address = reader.GetAttribute("address");
                        BreakPoints.Add(address);
                        continue;
                    }
                    if (reader.Name.Equals("project"))
                    {
                        String version = reader.GetAttribute("version");
                        if (version != null)
                        {
                            Enum.TryParse <BoardVersion>(version, out Version);
                        }
                        continue;
                    }
                    if (reader.Name.Equals("watch"))
                    {
                        int           address = Convert.ToInt32(reader.GetAttribute("address"), 16);
                        string        name    = reader.GetAttribute("label");
                        WatchedMemory mem     = new WatchedMemory(name, address, 0, 0);
                        if (watchList.ContainsKey(address))
                        {
                            watchList.Remove(address);
                        }
                        watchList.Add(address, mem);
                    }
                }
            }
            reader.Close();
        }
Пример #8
0
        public FoenixSystem(BoardVersion version, string DefaultKernel)
        {
            boardVersion = version;

            int          memSize = MemoryMap.RAM_SIZE;
            CodecRAM     codec   = null;
            SDCardDevice sdcard  = null;

            if (boardVersion == BoardVersion.RevC || boardVersion == BoardVersion.RevU)
            {
                memSize *= 2;
                codec    = new CodecRAM(MemoryMap.CODEC_WR_CTRL_FMX, 2); // This register is only a single byte but we allow writing a word
                sdcard   = new GabeSDController(MemoryMap.GABE_SDC_CTRL_START, MemoryMap.GABE_SDC_CTRL_SIZE);
            }
            else
            {
                codec  = new CodecRAM(MemoryMap.CODEC_WR_CTRL, 2); // This register is only a single byte but we allow writing a word
                sdcard = new CH376SRegister(MemoryMap.SDCARD_DATA, MemoryMap.SDCARD_SIZE);
            }
            MemMgr = new MemoryManager
            {
                RAM     = new MemoryRAM(MemoryMap.RAM_START, memSize),                  // RAM: 2MB Rev B, 4MB Rev C
                VICKY   = new MemoryRAM(MemoryMap.VICKY_START, MemoryMap.VICKY_SIZE),   // 60K
                VIDEO   = new MemoryRAM(MemoryMap.VIDEO_START, MemoryMap.VIDEO_SIZE),   // 4MB Video
                FLASH   = new MemoryRAM(MemoryMap.FLASH_START, MemoryMap.FLASH_SIZE),   // 8MB RAM
                BEATRIX = new GabeRAM(MemoryMap.BEATRIX_START, MemoryMap.BEATRIX_SIZE), // 4K

                // Special devices
                MATH      = new MathCoproRegister(MemoryMap.MATH_START, MemoryMap.MATH_END - MemoryMap.MATH_START + 1), // 48 bytes
                KEYBOARD  = new KeyboardRegister(MemoryMap.KBD_DATA_BUF, 5),
                SDCARD    = sdcard,
                INTERRUPT = new InterruptController(MemoryMap.INT_PENDING_REG0, 4),
                UART1     = new UART(MemoryMap.UART1_REGISTERS, 8),
                UART2     = new UART(MemoryMap.UART2_REGISTERS, 8),
                OPL2      = new OPL2(MemoryMap.OPL2_S_BASE, 256),
                FLOAT     = new MathFloatRegister(MemoryMap.FLOAT_START, MemoryMap.FLOAT_END - MemoryMap.FLOAT_START + 1),
                MPU401    = new MPU401(MemoryMap.MPU401_REGISTERS, 2),
                VDMA      = new VDMA(MemoryMap.VDMA_START, MemoryMap.VDMA_SIZE),
                TIMER0    = new TimerRegister(MemoryMap.TIMER0_CTRL_REG, 8),
                TIMER1    = new TimerRegister(MemoryMap.TIMER1_CTRL_REG, 8),
                TIMER2    = new TimerRegister(MemoryMap.TIMER2_CTRL_REG, 8)
            };
            MemMgr.CODEC = codec;
            MemMgr.KEYBOARD.SetKernel(this);

            // Assign memory variables used by other processes
            CPU = new CPU(MemMgr);

            MemMgr.VDMA.setVideoRam(MemMgr.VIDEO);
            MemMgr.VDMA.setSystemRam(MemMgr.RAM);

            // Load the kernel.hex if present
            ResetCPU(DefaultKernel);

            // Write bytes $9F in the joystick registers to mean that they are not installed.
            MemMgr.WriteWord(0xAFE800, 0x9F9F);
            MemMgr.WriteWord(0xAFE802, 0x9F9F);
            MemMgr.TIMER0.TimerInterruptDelegate += TimerEvent0;
            MemMgr.TIMER1.TimerInterruptDelegate += TimerEvent1;
            MemMgr.TIMER2.TimerInterruptDelegate += TimerEvent2;
        }
Пример #9
0
        // return true if the CPU was reset and the program was loaded
        public bool ResetCPU(string kernelFilename)
        {
            if (CPU != null)
            {
                CPU.DebugPause = true;
                //CPU.Halt();
            }

            if (kernelFilename != null)
            {
                LoadedKernel = kernelFilename;
            }

            // If the reset vector is not set in Bank 0, but it is set in Bank 18, the copy bank 18 into bank 0.
            int BasePageAddress = 0x18_0000;

            if (boardVersion == BoardVersion.RevC)
            {
                BasePageAddress = 0x38_0000;
            }

            if (LoadedKernel.EndsWith(".fnxml", true, null))
            {
                this.ResetMemory();
                FoeniXmlFile fnxml = new FoeniXmlFile(this, Resources);
                fnxml.Load(LoadedKernel);
                boardVersion = fnxml.Version;
            }
            else
            {
                LoadedKernel = HexFile.Load(MemMgr.RAM, LoadedKernel, BasePageAddress, out _, out _);
                if (LoadedKernel != null)
                {
                    if (lstFile == null)
                    {
                        lstFile = new ListFile(LoadedKernel);
                    }
                    else
                    {
                        // TODO: This results in lines of code to be shown in incorrect order - Fix
                        ListFile tempList = new ListFile(LoadedKernel);
                        foreach (DebugLine line in tempList.Lines.Values)
                        {
                            if (lstFile.Lines.ContainsKey(line.PC))
                            {
                                lstFile.Lines.Remove(line.PC);
                            }
                            lstFile.Lines.Add(line.PC, line);
                            for (int i = 1; i < line.commandLength; i++)
                            {
                                if (lstFile.Lines.ContainsKey(line.PC + i))
                                {
                                    lstFile.Lines.Remove(line.PC + i);
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }

            // See if lines of code exist in the 0x18_0000 to 0x18_FFFF block for RevB or 0x38_0000 to 0x38_FFFF block for Rev C
            List <DebugLine> copiedLines = new List <DebugLine>();

            if (lstFile.Lines.Count > 0)
            {
                foreach (DebugLine line in lstFile.Lines.Values)
                {
                    if (line != null && line.PC >= BasePageAddress && line.PC < BasePageAddress + 0x1_0000)
                    {
                        DebugLine dl = (DebugLine)line.Clone();
                        dl.PC -= BasePageAddress;
                        copiedLines.Add(dl);
                    }
                }
            }
            if (copiedLines.Count > 0)
            {
                foreach (DebugLine line in copiedLines)
                {
                    if (lstFile.Lines.ContainsKey(line.PC))
                    {
                        lstFile.Lines.Remove(line.PC);
                    }
                    lstFile.Lines.Add(line.PC, line);
                }
            }
            CPU.Reset();
            return(true);
        }
Пример #10
0
 public void SetVersion(BoardVersion rev)
 {
     boardVersion = rev;
 }
Пример #11
0
        public FoenixSystem(BoardVersion version, string DefaultKernel)
        {
            boardVersion = version;

            int          memSize         = MemoryMap.RAM_SIZE;
            CodecRAM     codec           = null;
            SDCardDevice sdcard          = null;
            byte         SystemStat      = 0;                          // FMX
            int          keyboardAddress = MemoryMap.KBD_DATA_BUF_FMX; // FMX

            switch (boardVersion)
            {
            case BoardVersion.RevB:
                break;

            case BoardVersion.RevC:
                memSize *= 2;
                break;

            case BoardVersion.RevU:
                SystemStat      = 1;
                keyboardAddress = MemoryMap.KBD_DATA_BUF_U;
                break;

            case BoardVersion.RevUPlus:
                memSize        *= 2;
                SystemStat      = 5;
                keyboardAddress = MemoryMap.KBD_DATA_BUF_U;
                break;
            }
            if (boardVersion == BoardVersion.RevB)
            {
                codec  = new CodecRAM(MemoryMap.CODEC_WR_CTRL, 2); // This register is only a single byte but we allow writing a word
                sdcard = new CH376SRegister(MemoryMap.SDCARD_DATA, MemoryMap.SDCARD_SIZE);
            }
            else
            {
                codec  = new CodecRAM(MemoryMap.CODEC_WR_CTRL_FMX, 2); // This register is only a single byte but we allow writing a word
                sdcard = new GabeSDController(MemoryMap.GABE_SDC_CTRL_START, MemoryMap.GABE_SDC_CTRL_SIZE);
            }

            MemMgr = new MemoryManager
            {
                RAM   = new MemoryRAM(MemoryMap.RAM_START, memSize),                // RAM: 2MB Rev B & U, 4MB Rev C & U+
                VICKY = new MemoryRAM(MemoryMap.VICKY_START, MemoryMap.VICKY_SIZE), // 60K
                VIDEO = new MemoryRAM(MemoryMap.VIDEO_START, MemoryMap.VIDEO_SIZE), // 4MB Video
                FLASH = new MemoryRAM(MemoryMap.FLASH_START, MemoryMap.FLASH_SIZE), // 8MB RAM
                GABE  = new GabeRAM(MemoryMap.GABE_START, MemoryMap.GABE_SIZE),     // 4K

                // Special devices
                MATH      = new MathCoproRegister(MemoryMap.MATH_START, MemoryMap.MATH_END - MemoryMap.MATH_START + 1), // 48 bytes
                KEYBOARD  = new KeyboardRegister(keyboardAddress, 5),
                SDCARD    = sdcard,
                INTERRUPT = new InterruptController(MemoryMap.INT_PENDING_REG0, 4),
                UART1     = new UART(MemoryMap.UART1_REGISTERS, 8),
                UART2     = new UART(MemoryMap.UART2_REGISTERS, 8),
                OPL2      = new OPL2(MemoryMap.OPL2_S_BASE, 256),
                FLOAT     = new MathFloatRegister(MemoryMap.FLOAT_START, MemoryMap.FLOAT_END - MemoryMap.FLOAT_START + 1),
                MPU401    = new MPU401(MemoryMap.MPU401_REGISTERS, 2),
                VDMA      = new VDMA(MemoryMap.VDMA_START, MemoryMap.VDMA_SIZE),
                TIMER0    = new TimerRegister(MemoryMap.TIMER0_CTRL_REG, 8),
                TIMER1    = new TimerRegister(MemoryMap.TIMER1_CTRL_REG, 8),
                TIMER2    = new TimerRegister(MemoryMap.TIMER2_CTRL_REG, 8)
            };
            MemMgr.CODEC = codec;
            MemMgr.KEYBOARD.SetKernel(this);

            // Assign memory variables used by other processes
            CPU = new CPU(MemMgr);

            MemMgr.VDMA.setVideoRam(MemMgr.VIDEO);
            MemMgr.VDMA.setSystemRam(MemMgr.RAM);
            MemMgr.VDMA.setVickyRam(MemMgr.VICKY);
            MemMgr.GABE.WriteByte(MemoryMap.GABE_SYS_STAT - MemoryMap.GABE_START, SystemStat);

            // Load the kernel.hex if present
            ResetCPU(DefaultKernel);

            // Write bytes $9F in the joystick registers to mean that they are not installed.
            MemMgr.WriteWord(0xAFE800, 0x9F9F);
            MemMgr.WriteWord(0xAFE802, 0x9F9F);
            MemMgr.TIMER0.TimerInterruptDelegate += TimerEvent0;
            MemMgr.TIMER1.TimerInterruptDelegate += TimerEvent1;
            MemMgr.TIMER2.TimerInterruptDelegate += TimerEvent2;

            // Set the Vicky rev and subrev
            MemMgr.VICKY.WriteWord(0x1C, 0x7654);
            MemMgr.VICKY.WriteWord(0x1E, 0x3456);
            MemMgr.VICKY.WriteByte(MemoryMap.GAMMA_CTRL_REG - MemoryMap.VICKY_BASE_ADDR, 0x11); // Gamma and hi-res are off
            // set the date
            MemMgr.VICKY.WriteByte(MemoryMap.FPGA_DOR - MemoryMap.VICKY_BASE_ADDR, 0x1);
            MemMgr.VICKY.WriteByte(MemoryMap.FPGA_MOR - MemoryMap.VICKY_BASE_ADDR, 0x2);
            MemMgr.VICKY.WriteByte(MemoryMap.FPGA_YOR - MemoryMap.VICKY_BASE_ADDR, 0x21);

            // Set board revision
            MemMgr.GABE.WriteByte(MemoryMap.REVOFPCB_C - MemoryMap.GABE_START, (byte)'E');
            MemMgr.GABE.WriteByte(MemoryMap.REVOFPCB_4 - MemoryMap.GABE_START, (byte)'M');
            MemMgr.GABE.WriteByte(MemoryMap.REVOFPCB_A - MemoryMap.GABE_START, (byte)'U');
            // Set the rev date
        }
Пример #12
0
        private void DecodeProgramArguments(string[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].Trim())
                {
                // the hex file to load is specified
                case "-h":
                case "--hex":
                    // a kernel file must be specified
                    if (args[i + 1].Trim().StartsWith("-") || !args[i + 1].Trim().EndsWith("hex"))
                    {
                        throw new Exception("You must specify a hex file.");
                    }
                    defaultKernel = args[i + 1];
                    i++;     // skip the next argument
                    break;

                case "-j":
                case "--jump":
                    // An address must be specified
                    int value = Convert.ToInt32(args[i + 1].Replace("$:", ""), 16);
                    if (value != 0)
                    {
                        jumpStartAddress = value;
                        i++;     // skip the next argument
                    }
                    else
                    {
                        throw new Exception("Invalid address specified: " + args[i + 1]);
                    }
                    break;

                // Autorun - a value is not expected for this one
                case "-r":
                case "--run":
                    autoRun = true;
                    break;

                // Disable IRQs - a value is not expected for this one
                case "-i":
                case "--irq":
                    disabledIRQs = true;
                    break;

                // Board Version B or C
                case "-b":
                case "--board":
                    string verArg = args[i + 1];
                    switch (verArg.ToLower())
                    {
                    case "b":
                        version = BoardVersion.RevB;
                        break;

                    case "c":
                        version = BoardVersion.RevC;
                        break;
                    }
                    break;

                default:
                    throw new Exception("Unknown switch used:" + args[i].Trim());
                }
            }
        }