From e12a89550a8a59d83029525730b70178195e12f0 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:24:21 -0700 Subject: [PATCH 01/16] [CGS] Misc: TODOs --- source/Cosmos.System2/Graphics/Canvas.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs index 94f6e80fe..6854d63ca 100644 --- a/source/Cosmos.System2/Graphics/Canvas.cs +++ b/source/Cosmos.System2/Graphics/Canvas.cs @@ -1,4 +1,4 @@ -//#define COSMOSDEBUG +//#define COSMOSDEBUG using System; using System.Collections.Generic; using System.Linq; @@ -91,6 +91,8 @@ namespace Cosmos.System.Graphics public abstract void DrawPoint(Pen pen, int x, int y); public abstract void DrawPoint(Pen pen, float x, float y); + + public abstract Color GetPointColor(int x, int y); private void DrawHorizontalLine(Pen pen, int dx, int x1, int y1) { From 10792f79a017bc35b060827f76e45e75d309cc3f Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:26:02 -0700 Subject: [PATCH 02/16] [CGS] VmWare Support: Screen Class --- .../Cosmos.System2/Graphics/SVGAIIScreen.cs | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 source/Cosmos.System2/Graphics/SVGAIIScreen.cs diff --git a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs new file mode 100644 index 000000000..8c761a08a --- /dev/null +++ b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Cosmos.HAL.Drivers.PCI.Video; + +namespace Cosmos.System.Graphics +{ + public class SVGAIIScreen : Canvas + { + public VMWareSVGAII xSVGAIIDriver; + internal Debug.Kernel.Debugger mSVGAIIDebugger = new Debug.Kernel.Debugger("System", "SVGAIIScreen"); + + public SVGAIIScreen() : base() + { + mSVGAIIDebugger.SendInternal($"Creting new SVGAIIScreen with default mode {defaultGraphicMode}"); + + xSVGAIIDriver = new VMWareSVGAII(); + xSVGAIIDriver.SetMode((uint)defaultGraphicMode.Columns, (uint)defaultGraphicMode.Rows, (uint)defaultGraphicMode.ColorDepth); + } + + public SVGAIIScreen(Mode aMode) : base(aMode) + { + ThrowIfModeIsNotValid(aMode); + + xSVGAIIDriver = new VMWareSVGAII(); + xSVGAIIDriver.SetMode((uint)aMode.Columns, (uint)aMode.Rows, (uint)aMode.ColorDepth); + } + + public override Mode Mode + { + get => mode; + set + { + mode = value; + SetGraphicsMode(mode); + } + } + + public override void DrawPoint(Pen pen, int x, int y) + { + Color xColor = pen.Color; + + mSVGAIIDebugger.SendInternal($"Drawing point to x:{x}, y:{y} with {xColor.Name} Color"); + xSVGAIIDriver.SetPixel((uint)x, (uint)y, (uint)xColor.ToArgb()); + mSVGAIIDebugger.SendInternal($"Done drawing point"); + xSVGAIIDriver.Update(0, 0, (uint)mode.Columns, (uint)mode.Rows); + } + + public override void DrawPoint(Pen pen, float x, float y) + { + throw new NotImplementedException(); + } + + public override void DrawFilledRectangle(Pen pen, int x_start, int y_start, int width, int height) + { + xSVGAIIDriver.Fill((uint)x_start, (uint)y_start, (uint)width, (uint)height, (uint)pen.Color.ToArgb()); + } + + public override List getAvailableModes() + { + return new List + { + /* 16-bit Depth Resolutions*/ + + /* SD Resolutions */ + new Mode(320, 200, ColorDepth.ColorDepth16), + new Mode(320, 240, ColorDepth.ColorDepth16), + new Mode(640, 480, ColorDepth.ColorDepth16), + new Mode(720, 480, ColorDepth.ColorDepth16), + new Mode(800, 600, ColorDepth.ColorDepth16), + new Mode(1152, 768, ColorDepth.ColorDepth16), + + /* Old HD-Ready Resolutions */ + new Mode(1280, 720, ColorDepth.ColorDepth16), + new Mode(1280, 768, ColorDepth.ColorDepth16), + new Mode(1280, 800, ColorDepth.ColorDepth16), // WXGA + new Mode(1280, 1024, ColorDepth.ColorDepth16), // SXGA + + /* Better HD-Ready Resolutions */ + new Mode(1360, 768, ColorDepth.ColorDepth16), + new Mode(1366, 768, ColorDepth.ColorDepth16), // Original Laptop Resolution + new Mode(1440, 900, ColorDepth.ColorDepth16), // WXGA+ + new Mode(1400, 1050, ColorDepth.ColorDepth16), // SXGA+ + new Mode(1600, 1200, ColorDepth.ColorDepth16), // UXGA + new Mode(1680, 1050, ColorDepth.ColorDepth16), // WXGA++ + + /* HDTV Resolutions */ + new Mode(1920, 1080, ColorDepth.ColorDepth16), + new Mode(1920, 1200, ColorDepth.ColorDepth16), // WUXGA + + /* 2K Resolutions */ + new Mode(2048, 1536, ColorDepth.ColorDepth16), // QXGA + new Mode(2560, 1080, ColorDepth.ColorDepth16), // UW-UXGA + new Mode(2560, 1600, ColorDepth.ColorDepth16), // WQXGA + new Mode(2560, 2048, ColorDepth.ColorDepth16), // QXGA+ + new Mode(3200, 2048, ColorDepth.ColorDepth16), // WQXGA+ + new Mode(3200, 2400, ColorDepth.ColorDepth16), // QUXGA + new Mode(3840, 2400, ColorDepth.ColorDepth16), // WQUXGA + + /* 32-bit Depth Resolutions*/ + /* SD Resolutions */ + new Mode(320, 200, ColorDepth.ColorDepth32), + new Mode(320, 240, ColorDepth.ColorDepth32), + new Mode(640, 480, ColorDepth.ColorDepth32), + new Mode(720, 480, ColorDepth.ColorDepth32), + new Mode(800, 600, ColorDepth.ColorDepth32), + new Mode(1152, 768, ColorDepth.ColorDepth32), + + /* Old HD-Ready Resolutions */ + new Mode(1280, 720, ColorDepth.ColorDepth32), + new Mode(1280, 768, ColorDepth.ColorDepth32), + new Mode(1280, 800, ColorDepth.ColorDepth32), // WXGA + new Mode(1280, 1024, ColorDepth.ColorDepth32), // SXGA + + /* Better HD-Ready Resolutions */ + new Mode(1360, 768, ColorDepth.ColorDepth32), + new Mode(1366, 768, ColorDepth.ColorDepth32), // Original Laptop Resolution + new Mode(1440, 900, ColorDepth.ColorDepth32), // WXGA+ + new Mode(1400, 1050, ColorDepth.ColorDepth32), // SXGA+ + new Mode(1600, 1200, ColorDepth.ColorDepth32), // UXGA + new Mode(1680, 1050, ColorDepth.ColorDepth32), // WXGA++ + + /* HDTV Resolutions */ + new Mode(1920, 1080, ColorDepth.ColorDepth32), + new Mode(1920, 1200, ColorDepth.ColorDepth32), // WUXGA + + /* 2K Resolutions */ + new Mode(2048, 1536, ColorDepth.ColorDepth32), // QXGA + new Mode(2560, 1080, ColorDepth.ColorDepth32), // UW-UXGA + new Mode(2560, 1600, ColorDepth.ColorDepth32), // WQXGA + new Mode(2560, 2048, ColorDepth.ColorDepth32), // QXGA+ + new Mode(3200, 2048, ColorDepth.ColorDepth32), // WQXGA+ + new Mode(3200, 2400, ColorDepth.ColorDepth32), // QUXGA + new Mode(3840, 2400, ColorDepth.ColorDepth32), // WQUXGA + }; + } + + protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth16); + + private void SetGraphicsMode(Mode aMode) + { + ThrowIfModeIsNotValid(aMode); + + var xWidth = (uint)aMode.Columns; + var xHeight = (uint)aMode.Rows; + var xColorDepth = (uint)aMode.ColorDepth; + + xSVGAIIDriver.SetMode(xWidth, xHeight, xColorDepth); + } + + public override void Clear(Color color) + { + xSVGAIIDriver.Fill(0, 0, (uint)mode.Columns, (uint)mode.Rows, (uint)color.ToArgb()); + } + + public Color GetPixel(int aX, int aY) + { + var xColorARGB = xSVGAIIDriver.GetPixel((uint)aX, (uint)aX); + var xColor = Color.FromArgb((int)xColorARGB); + return xColor; + } + + public void SetCursor(bool aVisible, int aX, int aY) + { + xSVGAIIDriver.SetCursor(aVisible, (uint)aX, (uint)aY); + } + + public void CreateCursor() + { + xSVGAIIDriver.DefineCursor(); + } + + public void CopyPixel(int aX, int aY, int aNewX, int aNewY, int aWidth = 1, int aHeight = 1) + { + xSVGAIIDriver.Copy((uint)aX, (uint)aY, (uint)aNewX, (uint)aNewY, (uint)aWidth, (uint)aHeight); + } + + public void MovePixel(int aX, int aY, int aNewX, int aNewY) + { + xSVGAIIDriver.Copy((uint)aX, (uint)aY, (uint)aNewX, (uint)aNewY, 1, 1); + xSVGAIIDriver.SetPixel((uint)aX, (uint)aY, 0); + } + + public override Color GetPointColor(int x, int y) + { + return Color.FromArgb((int)xSVGAIIDriver.GetPixel((uint)x, (uint)y)); + } + } +} From 2c4cdea994a4587cfc656c0b3de46b118fe1bbd2 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:28:40 -0700 Subject: [PATCH 03/16] [CGS] Misc: TODOs --- source/Cosmos.System2/Graphics/VBEScreen.cs | 37 +++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/source/Cosmos.System2/Graphics/VBEScreen.cs b/source/Cosmos.System2/Graphics/VBEScreen.cs index e216fe449..6f6ac1eec 100644 --- a/source/Cosmos.System2/Graphics/VBEScreen.cs +++ b/source/Cosmos.System2/Graphics/VBEScreen.cs @@ -1,4 +1,4 @@ -//#define COSMOSDEBUG +//#define COSMOSDEBUG using Cosmos.HAL.Drivers; using System; using System.Collections.Generic; @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Cosmos.System.Graphics; +using Cosmos.Common.Extensions; namespace Cosmos.System { @@ -26,7 +27,7 @@ namespace Cosmos.System public VBEScreen(Mode mode) : base(mode) { - //Global.mDebugger.SendInternal($"Creating new VBEScreen() with mode {mode}"); + Global.mDebugger.SendInternal($"Creating new VBEScreen() with mode {mode.Columns}x{mode.Rows}x{(uint)mode.ColorDepth}"); ThrowIfModeIsNotValid(mode); @@ -128,9 +129,7 @@ namespace Cosmos.System * For now we can Draw only if the ColorDepth is 32 bit, we will throw otherwise. * * How to support other ColorDepth? The offset calculation should be the same (and so could be done out of the switch) - * adding support ColorDepth.ColorDepth24 is easier as you need can use the version of SetVRAM() that take a byte - * and call it 3 time for the B, G and R component (the Color class has properties to do this!), the problem is - * for ColorDepth.ColorDepth16 and ColorDepth.ColorDepth8 than need a conversion from color (an ARGB32 color) to the RGB16 and RGB8 + * ColorDepth.ColorDepth16 and ColorDepth.ColorDepth8 need a conversion from color (an ARGB32 color) to the RGB16 and RGB8 * how to do this conversion faster maybe using pre-computed tables? What happens if the color cannot be converted? We will throw? */ switch (mode.ColorDepth) @@ -148,7 +147,18 @@ namespace Cosmos.System Global.mDebugger.SendInternal("Point drawn"); break; + case ColorDepth.ColorDepth24: + Global.mDebugger.SendInternal("Computing offset..."); + pitch = (uint)mode.Columns * ColorDepthInBytes; + stride = ColorDepthInBytes; + //offset = ((uint)x * pitch) + ((uint)y * stride); + offset = ((uint)x * stride) + ((uint)y * pitch); + Global.mDebugger.SendInternal($"Drawing Point of color {color} at offset {offset}"); + VBEDriver.SetVRAM(offset, (((uint)color.R * 1000 + color.G) * 1000 + color.B)); + + Global.mDebugger.SendInternal("Point drawn"); + break; default: String errorMsg = "DrawPoint() with ColorDepth " + (int)Mode.ColorDepth + " not yet supported"; throw new NotImplementedException(errorMsg); @@ -163,7 +173,22 @@ namespace Cosmos.System #endregion #region Reading - // TODO add to Canvas GetPointColor() + public override Color GetPointColor(int x, int y) + { + uint pitch; + uint stride; + uint offset; + uint ColorDepthInBytes = (uint)mode.ColorDepth / 8; + + Global.mDebugger.SendInternal("Computing offset..."); + pitch = (uint)mode.Columns * ColorDepthInBytes; + stride = ColorDepthInBytes; + //offset = ((uint)x * pitch) + ((uint)y * stride); + offset = ((uint)x * stride) + ((uint)y * pitch); + + Global.mDebugger.SendInternal($"Getting color from point at offset {offset}"); + return Color.FromArgb(VBEDriver.GetVRAM(offset)); + } #endregion From 77e260d610f9aefe85fd6ecde28f6cffe4b0c354 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:30:41 -0700 Subject: [PATCH 04/16] [CGS] VmWare Support: return SVGAII and VideoDriver Enum --- .../Graphics/FullScreenCanvas.cs | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index dd7618be9..581e1d9ea 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -1,22 +1,27 @@ -//#define COSMOSDEBUG +//#define COSMOSDEBUG using Cosmos.System.Graphics; +using Cosmos.HAL; namespace Cosmos.System.Graphics { public static class FullScreenCanvas { - /* - * For now we hardcode that the VideoDriver is always VBE when we have more that a driver supported we need to find - * what to use when we do the 'new' (inside GetFullScreenCanvas() static methods). MyVideoDriver should be - * of type Canvas - */ - static private Canvas MyVideoDriver = null; + public enum VideoDriver + { + VMWareSVGAIIDriver, + //VGADriver, + VBEDriver + } - public static Canvas GetFullScreenCanvas(Mode mode) + private static Canvas MyVideoDriver; + + public static Canvas GetFullScreenCanvas(Mode mode, VideoDriver videoDriver) { Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode); - if (MyVideoDriver == null) + if (videoDriver == VideoDriver.VMWareSVGAIIDriver) + return MyVideoDriver = new SVGAIIScreen(mode); + else if (videoDriver == VideoDriver.VBEDriver) return MyVideoDriver = new VBEScreen(mode); /* We have already got a VideoDriver istance simple change its mode */ @@ -24,11 +29,14 @@ namespace Cosmos.System.Graphics return MyVideoDriver; } - public static Canvas GetFullScreenCanvas() + public static Canvas GetFullScreenCanvas(VideoDriver videoDriver) { Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); - if (MyVideoDriver == null) - return new VBEScreen(); + + if (videoDriver == VideoDriver.VMWareSVGAIIDriver) + return MyVideoDriver = new SVGAIIScreen(); + else if (videoDriver == VideoDriver.VBEDriver) + return MyVideoDriver = new VBEScreen(); /* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */ MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; From 1f693e0182480a46a31c0907025da64bac053ab8 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:40:54 -0700 Subject: [PATCH 05/16] [CGS] VmWare Support: Fix Error --- Demos/CosmosGraphicSubsystem/Kernel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index 84cfe3082..ca2a1e070 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -15,8 +15,11 @@ namespace Cosmos_Graphic_Subsytem { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); + var xVideoDriver = HAL.PCI.GetDevice(0x15AD, 0x0405); + + var SVGAII = xVideoDriver.DeviceExists; /* Get on istance of the Canvas that is all the Screen */ - canvas = FullScreenCanvas.GetFullScreenCanvas(); + if(SVGAII) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver); /* Clear the Screen with the color 'Blue' */ canvas.Clear(Color.Blue); From 5752c56e439d57b58c7ed7ddd81f88f17b796e1a Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:45:48 -0700 Subject: [PATCH 06/16] [CGS] VmWare Support: Fix Issue --- Demos/CosmosGraphicSubsystem/Kernel.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index ca2a1e070..87b38f7c7 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -15,11 +15,14 @@ namespace Cosmos_Graphic_Subsytem { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - var xVideoDriver = HAL.PCI.GetDevice(0x15AD, 0x0405); - - var SVGAII = xVideoDriver.DeviceExists; - /* Get on istance of the Canvas that is all the Screen */ - if(SVGAII) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver); + var xSVGAIIDevice = HAL.PCI.GetDevice(0x15AD, 0x0405); + + var xSVGAIIExists = xVideoDriver.DeviceExists; + /* Check if there is SVGAII Device here to + * Get on istance of the Canvas that is all the Screen + */ + if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); + else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanas.VideoDriver.VMWareSVGAIIDrier); /* Clear the Screen with the color 'Blue' */ canvas.Clear(Color.Blue); From 180458971fea9dd11106e5a82e0e2ebb0c124167 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:48:48 -0700 Subject: [PATCH 07/16] [CGS] VmWare Support: Fix Issue --- Tests/GraphicTest/Kernel.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tests/GraphicTest/Kernel.cs b/Tests/GraphicTest/Kernel.cs index 396568080..a661db3bc 100644 --- a/Tests/GraphicTest/Kernel.cs +++ b/Tests/GraphicTest/Kernel.cs @@ -22,8 +22,13 @@ namespace GraphicTest protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); + + var xSVGAIIDevice = HAL.PCI.GetDevice(0x15AD, 0x0405); + + var xSVGAIIExists = xVideoDriver.DeviceExists; - canvas = FullScreenCanvas.GetFullScreenCanvas(); + if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); + else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanas.VideoDriver.VMWareSVGAIIDrier); canvas.Clear(Color.Blue); } From 7a204711c8dd1bb5db9fe031869d5869f4ac6402 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 00:03:21 -0700 Subject: [PATCH 08/16] [CGS] VmWare Support: Fix Issue --- Demos/CosmosGraphicSubsystem/Kernel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index 87b38f7c7..06cb7d5b6 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -15,7 +15,7 @@ namespace Cosmos_Graphic_Subsytem { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - var xSVGAIIDevice = HAL.PCI.GetDevice(0x15AD, 0x0405); + var xSVGAIIDevice = Cosmos.HAL.PCI.GetDevice(0x15AD, 0x0405); var xSVGAIIExists = xVideoDriver.DeviceExists; /* Check if there is SVGAII Device here to From 6c028dde5ac3c011628cc1b3c5195cc616b3b751 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 00:04:34 -0700 Subject: [PATCH 09/16] [CGS] VmWare Support: Fix Issue --- Tests/GraphicTest/Kernel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/GraphicTest/Kernel.cs b/Tests/GraphicTest/Kernel.cs index a661db3bc..7fac8c353 100644 --- a/Tests/GraphicTest/Kernel.cs +++ b/Tests/GraphicTest/Kernel.cs @@ -23,12 +23,12 @@ namespace GraphicTest { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - var xSVGAIIDevice = HAL.PCI.GetDevice(0x15AD, 0x0405); + var xSVGAIIDevice = Cosmos.HAL.PCI.GetDevice(0x15AD, 0x0405); - var xSVGAIIExists = xVideoDriver.DeviceExists; + var xSVGAIIExists = xSVGAIIDevice.DeviceExists; if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); - else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanas.VideoDriver.VMWareSVGAIIDrier); + else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VMWareSVGAIIDrier); canvas.Clear(Color.Blue); } From ba185b2dfd61439244983db6a9f0e8b618450f70 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 00:06:10 -0700 Subject: [PATCH 10/16] [CGS] VmWare Support: Fix Issue --- Demos/CosmosGraphicSubsystem/Kernel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index 06cb7d5b6..e1c7cdc6b 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -17,12 +17,12 @@ namespace Cosmos_Graphic_Subsytem var xSVGAIIDevice = Cosmos.HAL.PCI.GetDevice(0x15AD, 0x0405); - var xSVGAIIExists = xVideoDriver.DeviceExists; + var xSVGAIIExists = xSVGAIIDevice.DeviceExists; /* Check if there is SVGAII Device here to * Get on istance of the Canvas that is all the Screen */ if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); - else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanas.VideoDriver.VMWareSVGAIIDrier); + else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VMWareSVGAIIDrier); /* Clear the Screen with the color 'Blue' */ canvas.Clear(Color.Blue); From 6b8b4f9b83c0dd3dbcad327276e68c7137149adb Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 00:13:54 -0700 Subject: [PATCH 11/16] [CGS] VmWare Support: Fix Issue --- Tests/GraphicTest/Kernel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/GraphicTest/Kernel.cs b/Tests/GraphicTest/Kernel.cs index 7fac8c353..370c24e7d 100644 --- a/Tests/GraphicTest/Kernel.cs +++ b/Tests/GraphicTest/Kernel.cs @@ -28,7 +28,7 @@ namespace GraphicTest var xSVGAIIExists = xSVGAIIDevice.DeviceExists; if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); - else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VMWareSVGAIIDrier); + else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VMWareSVGAIIDriver); canvas.Clear(Color.Blue); } From a641ea6521431268c66d621a7364875c3ed1ceb3 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 18:18:13 +0300 Subject: [PATCH 12/16] [CGS] VmWare Support: Hidding VideoDriver Enum from User --- .../Graphics/FullScreenCanvas.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 581e1d9ea..7b9013e23 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -6,22 +6,32 @@ namespace Cosmos.System.Graphics { public static class FullScreenCanvas { - public enum VideoDriver + private enum VideoDriver { VMWareSVGAIIDriver, //VGADriver, VBEDriver } + + private static PCIDevice SVGAIIDevice = PCI.GetDevice(0x15AD, 0x0405); + + private static bool SVGAIIExists = SVGAIIDevice.DeviceExists; + + private static VideoDriver videoDevice; private static Canvas MyVideoDriver; - public static Canvas GetFullScreenCanvas(Mode mode, VideoDriver videoDriver) + public static Canvas GetFullScreenCanvas(Mode mode) { Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode); - if (videoDriver == VideoDriver.VMWareSVGAIIDriver) + /* Use SVGAII When Exists in PCI */ + if(xSVGAIIExists) + xVideoDevice = VideoDriver.VMWareSVGAIIDriver; + + if (xVideoDevice == VideoDriver.VMWareSVGAIIDriver) return MyVideoDriver = new SVGAIIScreen(mode); - else if (videoDriver == VideoDriver.VBEDriver) + else if (xVideoDevice == VideoDriver.VBEDriver) return MyVideoDriver = new VBEScreen(mode); /* We have already got a VideoDriver istance simple change its mode */ @@ -29,13 +39,17 @@ namespace Cosmos.System.Graphics return MyVideoDriver; } - public static Canvas GetFullScreenCanvas(VideoDriver videoDriver) + public static Canvas GetFullScreenCanvas() { Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); - - if (videoDriver == VideoDriver.VMWareSVGAIIDriver) + + /* Use SVGAII When Exists in PCI */ + if(xSVGAIIExists) + xVideoDevice = VideoDriver.VMWareSVGAIIDriver; + + if (xVideoDevice == VideoDriver.VMWareSVGAIIDriver) return MyVideoDriver = new SVGAIIScreen(); - else if (videoDriver == VideoDriver.VBEDriver) + else if (xVideoDevice == VideoDriver.VBEDriver) return MyVideoDriver = new VBEScreen(); /* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */ From c78b61280392227fd36f1390c9ec1197fae95c28 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 18:20:58 +0300 Subject: [PATCH 13/16] [CGS] VmWare Support: Fix Issue --- Demos/CosmosGraphicSubsystem/Kernel.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index e1c7cdc6b..8d7759f64 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -14,15 +14,9 @@ namespace Cosmos_Graphic_Subsytem protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - - var xSVGAIIDevice = Cosmos.HAL.PCI.GetDevice(0x15AD, 0x0405); - - var xSVGAIIExists = xSVGAIIDevice.DeviceExists; - /* Check if there is SVGAII Device here to - * Get on istance of the Canvas that is all the Screen - */ - if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); - else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VMWareSVGAIIDrier); + + /* Get on instance of the Canvas that is all the Screen */ + canvas = FullScreenCanvas.GetFullScreenCanvas(); /* Clear the Screen with the color 'Blue' */ canvas.Clear(Color.Blue); From cefcf2f1359d0d4ba9b82407b7f667965e312efb Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 18:20:59 +0300 Subject: [PATCH 14/16] [CGS] VmWare Support: Fix Issue --- Tests/GraphicTest/Kernel.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Tests/GraphicTest/Kernel.cs b/Tests/GraphicTest/Kernel.cs index 370c24e7d..396568080 100644 --- a/Tests/GraphicTest/Kernel.cs +++ b/Tests/GraphicTest/Kernel.cs @@ -22,13 +22,8 @@ namespace GraphicTest protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - - var xSVGAIIDevice = Cosmos.HAL.PCI.GetDevice(0x15AD, 0x0405); - - var xSVGAIIExists = xSVGAIIDevice.DeviceExists; - if(xSVGAIIExists) canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VBEDriver); - else canvas = FullScreenCanvas.GetFullScreenCanvas(FullScreenCanvas.VideoDriver.VMWareSVGAIIDriver); + canvas = FullScreenCanvas.GetFullScreenCanvas(); canvas.Clear(Color.Blue); } From bd658a5bd3e934723ee672fe1b66b43a77f68e27 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 14 Sep 2017 18:28:17 +0300 Subject: [PATCH 15/16] [CGS] VmWare Support: Fix Issue --- .../Cosmos.System2/Graphics/FullScreenCanvas.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 7b9013e23..4f63907dd 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -26,12 +26,12 @@ namespace Cosmos.System.Graphics Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode); /* Use SVGAII When Exists in PCI */ - if(xSVGAIIExists) - xVideoDevice = VideoDriver.VMWareSVGAIIDriver; + if(SVGAIIExists) + videoDevice = VideoDriver.VMWareSVGAIIDriver; - if (xVideoDevice == VideoDriver.VMWareSVGAIIDriver) + if (videoDevice == VideoDriver.VMWareSVGAIIDriver) return MyVideoDriver = new SVGAIIScreen(mode); - else if (xVideoDevice == VideoDriver.VBEDriver) + else if (videoDevice == VideoDriver.VBEDriver) return MyVideoDriver = new VBEScreen(mode); /* We have already got a VideoDriver istance simple change its mode */ @@ -44,12 +44,12 @@ namespace Cosmos.System.Graphics Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); /* Use SVGAII When Exists in PCI */ - if(xSVGAIIExists) - xVideoDevice = VideoDriver.VMWareSVGAIIDriver; + if(SVGAIIExists) + videoDevice = VideoDriver.VMWareSVGAIIDriver; - if (xVideoDevice == VideoDriver.VMWareSVGAIIDriver) + if (videoDevice == VideoDriver.VMWareSVGAIIDriver) return MyVideoDriver = new SVGAIIScreen(); - else if (xVideoDevice == VideoDriver.VBEDriver) + else if (videoDevice == VideoDriver.VBEDriver) return MyVideoDriver = new VBEScreen(); /* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */ From 42ed5093be55dff72e4ab254c583746f0cf30c2b Mon Sep 17 00:00:00 2001 From: zarlo Date: Fri, 15 Sep 2017 04:30:50 +1000 Subject: [PATCH 16/16] Update FullScreenCanvas.cs this is better --- source/Cosmos.System2/Graphics/FullScreenCanvas.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 4f63907dd..7df1c025f 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -42,19 +42,9 @@ namespace Cosmos.System.Graphics public static Canvas GetFullScreenCanvas() { Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); - - /* Use SVGAII When Exists in PCI */ - if(SVGAIIExists) - videoDevice = VideoDriver.VMWareSVGAIIDriver; - - if (videoDevice == VideoDriver.VMWareSVGAIIDriver) - return MyVideoDriver = new SVGAIIScreen(); - else if (videoDevice == VideoDriver.VBEDriver) - return MyVideoDriver = new VBEScreen(); - + /* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */ - MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; - return MyVideoDriver; + return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode); } } }