question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CPU Exceptions on any graphics start

See original GitHub issue

When I try to start any type of graphics it displays random errors. It should start graphics when command “startgui” is executed. The errors are mainly Cpu exception x0D or x06. Also VGAScreen does not work.

My code:

using System;
using System.Collections.Generic;
using System.Threading;
using Sys = Cosmos.System;
using Cosmos.System.Graphics;
using Cosmos.System.FileSystem;
using Cosmos.HAL;
using System.Drawing;

namespace microOS
{
    public class Kernel : Sys.Kernel
    {
        protected override void BeforeRun()
        {
            Console.Clear();
            Console.WriteLine("Starting cmdline...");
            StartCmdLine();
            Console.WriteLine("Done");    
        }

        const string version = "v0.1.3";
        CommandLine cmd;
        GraphicalInterface gui;

        void StartCmdLine() 
        {
            Console.WriteLine("Loading commands...");
            cmd = new CommandLine();
            cmd.InitCommandLine();
            Console.WriteLine($"microOS {version} booted succesfully.");
        }

        void StartGraphicalInterface() 
        {
            gui = new GraphicalInterface();
            gui.InitGUI();
        }

        protected override void Run()
        {
            Console.Write(">>>");
            string cmmd = Console.ReadLine();
            if (cmmd == "startgui")
            {
                Console.WriteLine("Starting graphical interface...");
                StartGraphicalInterface();
            }
            else
            {
                cmd.CheckCommand(cmmd);
            }
        }
    }

    public class GraphicalInterface
    {
        public const string guiver = "v0.0.1";

        Screen screen;

        public void Update()
        {
            screen.FillRectangle(10, 10, 100, 100, new Pen(Color.Black));
        }

        public void InitGUI()
        {
            screen = new Screen(640, 400);
            screen.BackColor = Color.Black;
        }
    }

    public class Screen
    {
        public Color BackColor;
        public VBECanvas canvas;

        public void FillRectangle(int x, int y, int w, int h, Pen pen) 
        {
            canvas.DrawFilledRectangle(pen, x, y, w, h);
        }

        public Screen(int w, int h)
        {
            canvas = (VBECanvas)FullScreenCanvas.GetFullScreenCanvas(new Mode(w, h, ColorDepth.ColorDepth32));
            canvas.Clear();
            canvas.Clear(BackColor);
        }
    }

    public class CommandLine
    {
        public const string cmdver = "v0.0.1";
        
        public void InitCommandLine()
        {
            
        }

        public void CheckCommand(string command) 
        {
            if (command.StartsWith("prnt"))
            {
                Console.WriteLine(command.Substring(5));
            }
            else if(command == "clear") 
            {
                Console.Clear();
            }
            else if (command == "help")
            {
                HelpMenu();
            }
            else if(command == "startgui") 
            {
                
            }
            else
            {
                Console.WriteLine($"Command or file \"{command}\" does not exist.");
            }
        }

        public string[] commands = new string[] { "prnt <text>", "clear", "help" };

        #region Commands

        void HelpMenu()
        {
            Console.Write("List of available commands: ");
            foreach(string command in commands) 
            {
                Console.Write($"{command}, ");
            }
            Console.WriteLine();
        }

        #endregion
    }
}

Screenshots: obraz

obraz

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
elkaamee326commented, Mar 2, 2021

Did it display the same output for the VGAScreen? At the moment I would recommend using the VMware SVGAII Canvas, because it is very fast and it is easy to put images on there. I think they are still working on VBE, so for now stick with VMware SVGAII. Also, to know the exception put Console.WriteLine statements between each line that looks suspicous of an error happening and then when it stops at that location put a try and catch block.

0reactions
sayaPintarcommented, Mar 31, 2021

ok, thanks!.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CPU Exceptions - Writing an OS in Rust
CPU exceptions occur in various erroneous situations, for example, when accessing an invalid memory address or when dividing by zero.
Read more >
Interrupts and Exceptions
Exceptions An Exception is an event that is triggered when something exceptional occurs during normal program execution. Examples of such exceptional ...
Read more >
x86 Handling Exceptions
Exceptions can happen at any point in time during operation of the processor and they signify an event that needs attention of the...
Read more >
ARM Cortex-R Series Programmer's Guide
When an exception occurs, the core saves the current status and the return address, enters a specific mode and possibly disables hardware interrupts....
Read more >
Cortex-M0+ Devices Generic User Guide
This book is a generic user guide for devices that implement the ARM Cortex-M0+ processor.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found