CPU Exceptions on any graphics start
See original GitHub issueWhen 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:
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
ok, thanks!.