From e12a89550a8a59d83029525730b70178195e12f0 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 13 Sep 2017 23:24:21 -0700 Subject: [PATCH 01/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] [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/37] 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); } } } From f7a7d45e87f2d44d4a5e9110ea8eb96bf82df1fe Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Sat, 23 Dec 2017 22:11:21 +0300 Subject: [PATCH 17/37] Add FloatArray and DoubleArray Test --- .../System/ArrayTests.cs | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs index 1bbefd499..d49668423 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs @@ -11,13 +11,34 @@ namespace Cosmos.Compiler.Tests.Bcl.System { public static void Execute() { - byte[] xResult = { 1, 2, 3, 4, 5, 6, 7, 8 }; - byte[] xExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 }; - byte[] xSource = { 1 }; + if (true) + { + byte[] xResult = { 1, 2, 3, 4, 5, 6, 7, 8 }; + byte[] xExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 }; + byte[] xSource = { 1 }; - Array.Copy(xSource, 0, xResult, 7, 1); + Array.Copy(xSource, 0, xResult, 7, 1); - Assert.IsTrue((xResult[7] == xExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xResult[7] + " != " + (uint)xExpectedResult[7]); + Assert.IsTrue((xResult[7] == xExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xResult[7] + " != " + (uint)xExpectedResult[7]); + } + + // Single[] Test + float[] xResult = { 1.25, 2.50, 3.51, 4.31, 9.28, 18.56 }; + float[] xExpectedResult = { 1.25, 2.598, 5.39, 4.31, 9.28, 18.56 }; + float[] xSource = { 0.49382, 1.59034, 2.598, 5.39, 7.48392, 4.2839 }; + + Array.Copy(xSource, 2, xResult, 1, 2); + + Assert.IsTrue((xResult[1] + xResult[2]) == (xExpectedResult[1] + xExpectedResult[2]), "Array.Copy doesn't work with Singles: xResult[1] = " + (uint)xResult[1] + " != " + (uint)xExpectedResult[1] " and xResult[2] = " + (uint)xResult[2] + " != " + (uint)xExpectedResult[2]); + + // Double[] Test + double[] xResult = { 0.384, 1.5823, 2.5894, 2.9328539, 3.9201, 4.295 }; + double[] xExpectedResult = { 0.384, 1.5823, 2.5894, 95.32815, 3.9201, 4.295 }; + double[] xSource = { 95.32815 }; + + Array.Copy(xSource, 0, xResult, 3, 1); + + Assert.IsTrue(xResult[3] == xExpectedResult[3], "Array.Copy doesn't work with Doubles: xResult[1] = " + (uint)xResult[3] + " != " + (uint)xExpectedResult[3]); } } } From 4af9397061691a59081fc2f12a2a9cd8a5ed3c02 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Sat, 23 Dec 2017 22:22:07 +0300 Subject: [PATCH 18/37] Replace Array.Copy with Assigning --- .../System/ArrayTests.cs | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs index d49668423..0648fca07 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs @@ -11,34 +11,32 @@ namespace Cosmos.Compiler.Tests.Bcl.System { public static void Execute() { - if (true) - { - byte[] xResult = { 1, 2, 3, 4, 5, 6, 7, 8 }; - byte[] xExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 }; - byte[] xSource = { 1 }; + byte[] xByteResult = { 1, 2, 3, 4, 5, 6, 7, 8 }; + byte[] xByteExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 }; + byte[] xByteSource = { 1 }; - Array.Copy(xSource, 0, xResult, 7, 1); + Array.Copy(xByteSource, 0, xByteResult, 7, 1); - Assert.IsTrue((xResult[7] == xExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xResult[7] + " != " + (uint)xExpectedResult[7]); - } + Assert.IsTrue((xByteResult[7] == xByteExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xByteResult[7] + " != " + (uint)xByteExpectedResult[7]); // Single[] Test - float[] xResult = { 1.25, 2.50, 3.51, 4.31, 9.28, 18.56 }; - float[] xExpectedResult = { 1.25, 2.598, 5.39, 4.31, 9.28, 18.56 }; - float[] xSource = { 0.49382, 1.59034, 2.598, 5.39, 7.48392, 4.2839 }; + float[] xSingleResult = { 1.25, 2.50, 3.51, 4.31, 9.28, 18.56 }; + float[] xSingleExpectedResult = { 1.25, 2.598, 5.39, 4.31, 9.28, 18.56 }; + float[] xSingleSource = { 0.49382, 1.59034, 2.598, 5.39, 7.48392, 4.2839 }; - Array.Copy(xSource, 2, xResult, 1, 2); + xSingleResult[1] = xSingleSource[2]; + xSingleResult[2] = xSingleSource[3]; - Assert.IsTrue((xResult[1] + xResult[2]) == (xExpectedResult[1] + xExpectedResult[2]), "Array.Copy doesn't work with Singles: xResult[1] = " + (uint)xResult[1] + " != " + (uint)xExpectedResult[1] " and xResult[2] = " + (uint)xResult[2] + " != " + (uint)xExpectedResult[2]); + Assert.IsTrue(((xSingleResult[1] + xSingleResult[2]) == (xSingleExpectedResult[1] + xSingleExpectedResult[2])), "Assinging values to single array elements doesn't work: xResult[1] = " + (uint)xSingleResult[1] + " != " + (uint)xSingleExpectedResult[1] " and xResult[2] = " + (uint)xResult[2] + " != " + (uint)xExpectedResult[2]); // Double[] Test - double[] xResult = { 0.384, 1.5823, 2.5894, 2.9328539, 3.9201, 4.295 }; - double[] xExpectedResult = { 0.384, 1.5823, 2.5894, 95.32815, 3.9201, 4.295 }; - double[] xSource = { 95.32815 }; + double[] xDoubleResult = { 0.384, 1.5823, 2.5894, 2.9328539, 3.9201, 4.295 }; + double[] xDoubleExpectedResult = { 0.384, 1.5823, 2.5894, 95.32815, 3.9201, 4.295 }; + double[] xDoubleSource = { 95.32815 }; - Array.Copy(xSource, 0, xResult, 3, 1); + xDoubleResult[3] = xDoubleSource[0]; - Assert.IsTrue(xResult[3] == xExpectedResult[3], "Array.Copy doesn't work with Doubles: xResult[1] = " + (uint)xResult[3] + " != " + (uint)xExpectedResult[3]); + Assert.IsTrue(xDoubleResult[3] == xDoubleExpectedResult[3], "Assinging values to double array elements doesn't work: xResult[1] = " + (uint)xDoubleResult[3] + " != " + (uint)xDoubleExpectedResult[3]); } } } From 2a6dcfe6e3c9d65c7a144b0702e723e11c7d6f76 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Sat, 23 Dec 2017 22:26:37 +0300 Subject: [PATCH 19/37] Fix. --- Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs index 0648fca07..c328d136f 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs @@ -27,7 +27,7 @@ namespace Cosmos.Compiler.Tests.Bcl.System xSingleResult[1] = xSingleSource[2]; xSingleResult[2] = xSingleSource[3]; - Assert.IsTrue(((xSingleResult[1] + xSingleResult[2]) == (xSingleExpectedResult[1] + xSingleExpectedResult[2])), "Assinging values to single array elements doesn't work: xResult[1] = " + (uint)xSingleResult[1] + " != " + (uint)xSingleExpectedResult[1] " and xResult[2] = " + (uint)xResult[2] + " != " + (uint)xExpectedResult[2]); + Assert.IsTrue(((xSingleResult[1] + xSingleResult[2]) == (xSingleExpectedResult[1] + xSingleExpectedResult[2])), "Assinging values to single array elements doesn't work: xResult[1] = " + (uint)xSingleResult[1] + " != " + (uint)xSingleExpectedResult[1] + " and xResult[2] = " + (uint)xResult[2] + " != " + (uint)xExpectedResult[2]); // Double[] Test double[] xDoubleResult = { 0.384, 1.5823, 2.5894, 2.9328539, 3.9201, 4.295 }; From a4e6fb2ff742d86a6c2e30031b0f61b866b3de3f Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Sat, 23 Dec 2017 22:32:32 +0300 Subject: [PATCH 20/37] Unstoppable fix. --- Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs index c328d136f..1fd352a71 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs @@ -20,9 +20,9 @@ namespace Cosmos.Compiler.Tests.Bcl.System Assert.IsTrue((xByteResult[7] == xByteExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xByteResult[7] + " != " + (uint)xByteExpectedResult[7]); // Single[] Test - float[] xSingleResult = { 1.25, 2.50, 3.51, 4.31, 9.28, 18.56 }; - float[] xSingleExpectedResult = { 1.25, 2.598, 5.39, 4.31, 9.28, 18.56 }; - float[] xSingleSource = { 0.49382, 1.59034, 2.598, 5.39, 7.48392, 4.2839 }; + float[] xSingleResult = { 1.25f, 2.50f, 3.51f, 4.31f, 9.28f, 18.56f }; + float[] xSingleExpectedResult = { 1.25f, 2.598f, 5.39f, 4.31f, 9.28f, 18.56f }; + float[] xSingleSource = { 0.49382f, 1.59034f, 2.598f, 5.39f, 7.48392f, 4.2839f }; xSingleResult[1] = xSingleSource[2]; xSingleResult[2] = xSingleSource[3]; From 07a8b9fc1372324b5dc2342e4e5edaaf8d542cd9 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Sat, 23 Dec 2017 22:37:20 +0300 Subject: [PATCH 21/37] Fix. --- Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs index 1fd352a71..2335e1001 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs @@ -27,7 +27,7 @@ namespace Cosmos.Compiler.Tests.Bcl.System xSingleResult[1] = xSingleSource[2]; xSingleResult[2] = xSingleSource[3]; - Assert.IsTrue(((xSingleResult[1] + xSingleResult[2]) == (xSingleExpectedResult[1] + xSingleExpectedResult[2])), "Assinging values to single array elements doesn't work: xResult[1] = " + (uint)xSingleResult[1] + " != " + (uint)xSingleExpectedResult[1] + " and xResult[2] = " + (uint)xResult[2] + " != " + (uint)xExpectedResult[2]); + Assert.IsTrue(((xSingleResult[1] + xSingleResult[2]) == (xSingleExpectedResult[1] + xSingleExpectedResult[2])), "Assinging values to single array elements doesn't work: xResult[1] = " + (uint)xSingleResult[1] + " != " + (uint)xSingleExpectedResult[1] + " and xResult[2] = " + (uint)xSingleResult[2] + " != " + (uint)xSingleExpectedResult[2]); // Double[] Test double[] xDoubleResult = { 0.384, 1.5823, 2.5894, 2.9328539, 3.9201, 4.295 }; From 3f8a858d437bf50873baf65732d60876d546b3c0 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 11:24:17 +0300 Subject: [PATCH 22/37] Remove break and use foreach --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 1d062af11..211978cbd 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -313,15 +313,9 @@ namespace Cosmos.System.FileSystem /// Initializes the partitions for all block devices. /// protected virtual void InitializePartitions() - { - for (int i = 0; i < BlockDevice.Devices.Count; i++) - { - if (BlockDevice.Devices[i] is Partition) - { - mPartitions.Add((Partition)BlockDevice.Devices[i]); - break; - } - } + { + foreach(Partition xPart in BlockDevice.Devices) + mPartitions.Add(xPart); if (mPartitions.Count > 0) { From db0b4bc5df330cf1dd8c06769ec459c548f5d248 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 11:42:41 +0300 Subject: [PATCH 23/37] QaB --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 211978cbd..16fadbbc5 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -315,7 +315,9 @@ namespace Cosmos.System.FileSystem protected virtual void InitializePartitions() { foreach(Partition xPart in BlockDevice.Devices) + { mPartitions.Add(xPart); + } if (mPartitions.Count > 0) { From f9aeddd582e552caa5c134b24dea263d62103f12 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 19:41:25 +0300 Subject: [PATCH 24/37] Revert `foreach` --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 16fadbbc5..eb4120f1d 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -314,9 +314,12 @@ namespace Cosmos.System.FileSystem /// protected virtual void InitializePartitions() { - foreach(Partition xPart in BlockDevice.Devices) + for(int i = 0; i < BlockDeviecs.Devices.Count; i++) { - mPartitions.Add(xPart); + if (BlockDevices.Devices[i] is Partition) + { + mPartition.Add(BlockDevices.Devices[i]); + } } if (mPartitions.Count > 0) From 81872c1dc30ba9b180d796ffc510a81bb3f672de Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 19:42:19 +0300 Subject: [PATCH 25/37] Update CosmosVFS.cs --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index eb4120f1d..f4f29926c 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -314,11 +314,11 @@ namespace Cosmos.System.FileSystem /// protected virtual void InitializePartitions() { - for(int i = 0; i < BlockDeviecs.Devices.Count; i++) + for(int i = 0; i < BlockDeviec.Devices.Count; i++) { - if (BlockDevices.Devices[i] is Partition) + if (BlockDevice.Devices[i] is Partition) { - mPartition.Add(BlockDevices.Devices[i]); + mPartition.Add(BlockDevice.Devices[i]); } } From cf6500859dfbc290ccaa9ff5bebbc5ff81b566f8 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 19:43:04 +0300 Subject: [PATCH 26/37] Update CosmosVFS.cs --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index f4f29926c..135a48393 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -313,8 +313,8 @@ namespace Cosmos.System.FileSystem /// Initializes the partitions for all block devices. /// protected virtual void InitializePartitions() - { - for(int i = 0; i < BlockDeviec.Devices.Count; i++) + { + for (int i = 0; i < BlockDevice.Devices.Count; i++) { if (BlockDevice.Devices[i] is Partition) { From c9277c28cb858c0720b1c7be0c5f36acd826109d Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 20:03:28 +0300 Subject: [PATCH 27/37] Update CosmosVFS.cs --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 135a48393..4f9910dc7 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -318,7 +318,7 @@ namespace Cosmos.System.FileSystem { if (BlockDevice.Devices[i] is Partition) { - mPartition.Add(BlockDevice.Devices[i]); + mPartitions.Add((Partition)BlockDevice.Devices[i]); } } From d5200d3f07fc56970cc1c352ab46a8739b865137 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 26 Dec 2017 22:27:32 +0300 Subject: [PATCH 28/37] Update CosmosVFS.cs --- source/Cosmos.System2/FileSystem/CosmosVFS.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs index 4f9910dc7..7f645d596 100644 --- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs +++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs @@ -313,7 +313,7 @@ namespace Cosmos.System.FileSystem /// Initializes the partitions for all block devices. /// protected virtual void InitializePartitions() - { + { for (int i = 0; i < BlockDevice.Devices.Count; i++) { if (BlockDevice.Devices[i] is Partition) From 620150edf8c565a4602a95e15a5d1873c25adda7 Mon Sep 17 00:00:00 2001 From: Arawn Davies Date: Tue, 20 Feb 2018 21:29:30 +0000 Subject: [PATCH 29/37] Adds required changes to CGS when initializing the driver --- .../Graphics/FullScreenCanvas.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 7df1c025f..9eea1233c 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -19,7 +19,7 @@ namespace Cosmos.System.Graphics private static VideoDriver videoDevice; - private static Canvas MyVideoDriver; + private static Canvas MyVideoDriver = null; public static Canvas GetFullScreenCanvas(Mode mode) { @@ -28,11 +28,20 @@ namespace Cosmos.System.Graphics /* Use SVGAII When Exists in PCI */ if(SVGAIIExists) videoDevice = VideoDriver.VMWareSVGAIIDriver; + + // If there's no instance of a video driver created (which there isn't), create it: + if (MyVideoDriver == null) { + + // If running on VMWare and using SVGAII, then use that driver: + if (videoDevice == VideoDriver.VMWareSVGAIIDriver) + // Creates the instance + return MyVideoDriver = new SVGAIIScreen(mode); + // If not running on VMWare, then use the VESA BIOS Extensions: + else if (videoDevice == VideoDriver.VBEDriver) + // Creates the instance + return MyVideoDriver = new VBAScreen(mode); + } - if (videoDevice == VideoDriver.VMWareSVGAIIDriver) - return MyVideoDriver = new SVGAIIScreen(mode); - else if (videoDevice == VideoDriver.VBEDriver) - return MyVideoDriver = new VBEScreen(mode); /* We have already got a VideoDriver istance simple change its mode */ MyVideoDriver.Mode = mode; From d61cfa6c06f3b5f7b51b283bb0a148fd8d7fbd5a Mon Sep 17 00:00:00 2001 From: Arawn Davies Date: Thu, 22 Feb 2018 00:22:45 +0000 Subject: [PATCH 30/37] Nearly there --- Demos/CosmosGraphicSubsystem/Kernel.cs | 5 +++-- source/Cosmos.System2/Graphics/FullScreenCanvas.cs | 11 +++++++---- source/Cosmos.System2/Graphics/SVGAIIScreen.cs | 6 ++++++ source/Cosmos.System2/Graphics/VBEScreen.cs | 3 +-- source/Cosmos.System2/Graphics/VGAScreen.cs | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index 8d7759f64..e80696484 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -14,9 +14,10 @@ namespace Cosmos_Graphic_Subsytem protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - + /* Get on instance of the Canvas that is all the Screen */ - canvas = FullScreenCanvas.GetFullScreenCanvas(); + Mode start = new Mode(640, 480, ColorDepth.ColorDepth32); + canvas = FullScreenCanvas.GetFullScreenCanvas(start); /* Clear the Screen with the color 'Blue' */ canvas.Clear(Color.Blue); diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 9eea1233c..e6c15a187 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -13,7 +13,7 @@ namespace Cosmos.System.Graphics VBEDriver } - private static PCIDevice SVGAIIDevice = PCI.GetDevice(0x15AD, 0x0405); + private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter); private static bool SVGAIIExists = SVGAIIDevice.DeviceExists; @@ -39,7 +39,7 @@ namespace Cosmos.System.Graphics // If not running on VMWare, then use the VESA BIOS Extensions: else if (videoDevice == VideoDriver.VBEDriver) // Creates the instance - return MyVideoDriver = new VBAScreen(mode); + return MyVideoDriver = new VBEScreen(mode); } @@ -51,8 +51,11 @@ namespace Cosmos.System.Graphics public static Canvas GetFullScreenCanvas() { Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); - - /* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */ + + /* + WARNING: MyVideoDriver is initiated as null - needs changing! + We have already got a VideoDriver instance + - reset its mode to DefaultGraphicMode */ return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode); } } diff --git a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs index 8c761a08a..fe9393890 100644 --- a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs +++ b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs @@ -46,8 +46,14 @@ namespace Cosmos.System.Graphics xSVGAIIDriver.Update(0, 0, (uint)mode.Columns, (uint)mode.Rows); } + public override void DrawArray(Color[] colors, int x, int y, int width, int height) + { + throw new NotImplementedException(); + //xSVGAIIDriver. + } public override void DrawPoint(Pen pen, float x, float y) { + //xSVGAIIDriver. throw new NotImplementedException(); } diff --git a/source/Cosmos.System2/Graphics/VBEScreen.cs b/source/Cosmos.System2/Graphics/VBEScreen.cs index c95add72f..2e129f981 100644 --- a/source/Cosmos.System2/Graphics/VBEScreen.cs +++ b/source/Cosmos.System2/Graphics/VBEScreen.cs @@ -5,10 +5,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Cosmos.System.Graphics; using Cosmos.Common.Extensions; -namespace Cosmos.System +namespace Cosmos.System.Graphics { public class VBEScreen : Canvas { diff --git a/source/Cosmos.System2/Graphics/VGAScreen.cs b/source/Cosmos.System2/Graphics/VGAScreen.cs index 5fae7bd03..388d7378f 100644 --- a/source/Cosmos.System2/Graphics/VGAScreen.cs +++ b/source/Cosmos.System2/Graphics/VGAScreen.cs @@ -1,7 +1,7 @@ using System; using HALVGAScreen = Cosmos.HAL.VGAScreen; -namespace Cosmos.System +namespace Cosmos.System.Graphics { public class VGAScreen { From 359f8ea974648d83f2a74c5842dc528df819a3df Mon Sep 17 00:00:00 2001 From: Arawn Davies Date: Thu, 22 Feb 2018 11:57:13 +0000 Subject: [PATCH 31/37] Update FullScreenCanvas.cs --- .../Graphics/FullScreenCanvas.cs | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index e6c15a187..40e6e2940 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -18,7 +18,8 @@ namespace Cosmos.System.Graphics private static bool SVGAIIExists = SVGAIIDevice.DeviceExists; private static VideoDriver videoDevice; - + + // Created null - NullReferenceException when calling GetFullScreenCanvas() with 0 overloads private static Canvas MyVideoDriver = null; public static Canvas GetFullScreenCanvas(Mode mode) @@ -30,20 +31,23 @@ namespace Cosmos.System.Graphics videoDevice = VideoDriver.VMWareSVGAIIDriver; // If there's no instance of a video driver created (which there isn't), create it: - if (MyVideoDriver == null) { - - // If running on VMWare and using SVGAII, then use that driver: - if (videoDevice == VideoDriver.VMWareSVGAIIDriver) - // Creates the instance - return MyVideoDriver = new SVGAIIScreen(mode); - // If not running on VMWare, then use the VESA BIOS Extensions: - else if (videoDevice == VideoDriver.VBEDriver) - // Creates the instance - return MyVideoDriver = new VBEScreen(mode); - } - + if (MyVideoDriver == null) + { + // If running on VMWare and using SVGAII, then use that driver: + if (videoDevice == VideoDriver.VMWareSVGAIIDriver) + { + // Creates the instance + return MyVideoDriver = new SVGAIIScreen(mode); + } + // If not running on VMWare, then use the VESA BIOS Extensions: + else if (videoDevice == VideoDriver.VBEDriver) + { + // Creates the instance + return MyVideoDriver = new VBEScreen(mode); + } + } - /* We have already got a VideoDriver istance simple change its mode */ + /* We have already got a VideoDriver instance, simply change its mode */ MyVideoDriver.Mode = mode; return MyVideoDriver; } From efa36d16004db93b89735e25e1e0bed7094ffc49 Mon Sep 17 00:00:00 2001 From: Arawn Davies Date: Sat, 24 Feb 2018 22:10:18 +0000 Subject: [PATCH 32/37] Re-write of GetFullScreenCanvas --- .../Graphics/FullScreenCanvas.cs | 100 +++++++++++------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 40e6e2940..0b36e1926 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -12,55 +12,75 @@ namespace Cosmos.System.Graphics //VGADriver, VBEDriver } - + private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter); - + private static bool SVGAIIExists = SVGAIIDevice.DeviceExists; - + private static VideoDriver videoDevice; - + // Created null - NullReferenceException when calling GetFullScreenCanvas() with 0 overloads private static Canvas MyVideoDriver = null; - public static Canvas GetFullScreenCanvas(Mode mode) - { - Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode); - - /* Use SVGAII When Exists in PCI */ - if(SVGAIIExists) - videoDevice = VideoDriver.VMWareSVGAIIDriver; - - // If there's no instance of a video driver created (which there isn't), create it: - if (MyVideoDriver == null) - { - // If running on VMWare and using SVGAII, then use that driver: - if (videoDevice == VideoDriver.VMWareSVGAIIDriver) - { - // Creates the instance - return MyVideoDriver = new SVGAIIScreen(mode); - } - // If not running on VMWare, then use the VESA BIOS Extensions: - else if (videoDevice == VideoDriver.VBEDriver) - { - // Creates the instance - return MyVideoDriver = new VBEScreen(mode); - } - } - - /* We have already got a VideoDriver instance, simply change its mode */ - MyVideoDriver.Mode = mode; - return MyVideoDriver; - } - public static Canvas GetFullScreenCanvas() { - Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); + // If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), + // Do necessary check and set to default gfx mode + if (MyVideoDriver == null) + { + return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode); + } + // If it's not null, simply change graphics mode */ + else + { + MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; + return MyVideoDriver; + } + // Old check left for reference + /* + if (videoDevice == VideoDriver.VMWareSVGAIIDriver) + { - /* - WARNING: MyVideoDriver is initiated as null - needs changing! - We have already got a VideoDriver instance - - reset its mode to DefaultGraphicMode */ - return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode); + } + else + { + + } + */ + } + public static Canvas GetFullScreenCanvas(Mode mode) + { + Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); + // If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), + // Do necessary check and set gfx mode as specified (mode) + if (MyVideoDriver == null) + { + if (SVGAIIExists) + { + // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode + // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. + // returns MyVideoDriver as the Canvas + videoDevice = VideoDriver.VMWareSVGAIIDriver; + MyVideoDriver = new SVGAIIScreen(mode); + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } + else + { + // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) + videoDevice = VideoDriver.VBEDriver; + MyVideoDriver = new VBEScreen(mode); + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } + } + else + { + // If MyVideoDriver has been initialized before (Graphics mode has previously been set) + // Change the graphics mode to the mode specified + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } } } } From becfc92417340dda57729100186cafdfd5791667 Mon Sep 17 00:00:00 2001 From: Arawn Davies Date: Sun, 25 Feb 2018 00:13:19 +0000 Subject: [PATCH 33/37] Finally! Fixed PCIDeviceExists returning null if it doesn't instead of false - Bit of a hack but it's done the job for now, needs redoing --- .../CosmosGraphicSubsystem.csproj | 9 ++++---- Demos/CosmosGraphicSubsystem/Kernel.cs | 8 +++++-- Kernel.sln | 16 +++++++++++++- source/Cosmos.HAL2/PciDevice.cs | 10 +++++++-- .../Graphics/FullScreenCanvas.cs | 22 ++++++++++++++++--- 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj index c3e773797..d57ca8c04 100644 --- a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj +++ b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj @@ -2,10 +2,11 @@ netstandard2.0 + CosmosGraphicSubsystemBoot - elf + Bin True Source User @@ -17,9 +18,9 @@ MethodFooters False Serial: COM1 - Bochs - Bochs - Use Bochs emulator to deploy and debug. + VMware + VMware + Use VMware Player or Workstation to deploy and debug. 192.168.0.8 True MethodFooters diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index e80696484..c23251ab6 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -14,11 +14,15 @@ namespace Cosmos_Graphic_Subsytem protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); + Console.WriteLine("Specifying custom graphics mode as 800x600@32"); + // Specify custom graphics mode (800x600 @ 16) + Mode start = new Mode(800, 600, ColorDepth.ColorDepth32); - /* Get on instance of the Canvas that is all the Screen */ - Mode start = new Mode(640, 480, ColorDepth.ColorDepth32); + Console.WriteLine("Here we go!"); + // Create new instance of FullScreenCanvas, specifying graphics mode canvas = FullScreenCanvas.GetFullScreenCanvas(start); + /* Clear the Screen with the color 'Blue' */ canvas.Clear(Color.Blue); } diff --git a/Kernel.sln b/Kernel.sln index f6adc82d7..7fec20689 100644 --- a/Kernel.sln +++ b/Kernel.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +VisualStudioVersion = 15.0.27130.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel G2", "Kernel G2", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}" EndProject @@ -94,6 +94,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{7370A62F-12DA-4181-BE3B-009D0926CA7E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PCITest", "PCITest", "{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCITest", "Demos\PCITest\PCITest.csproj", "{D3639BE5-49A0-4163-9174-1D0CC6823E06}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -335,6 +339,14 @@ Global {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|Any CPU.Build.0 = Release|Any CPU {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.ActiveCfg = Release|Any CPU {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.Build.0 = Release|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.ActiveCfg = Debug|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.Build.0 = Debug|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.Build.0 = Release|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.ActiveCfg = Release|Any CPU + {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -380,6 +392,8 @@ Global {E35E0DBF-555F-4D38-8F28-ACDFA9DC97BD} = {5FF9BF2A-5162-4F12-82B6-1693AD776636} {0812DD0A-4CEE-4376-B78A-02EBCBAA14C2} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} {7370A62F-12DA-4181-BE3B-009D0926CA7E} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} + {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} = {B56A6119-1B8F-44E4-9446-291E52F47D4C} + {D3639BE5-49A0-4163-9174-1D0CC6823E06} = {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1A1E8F1D-82B3-471F-9B59-0350DEA9203D} diff --git a/source/Cosmos.HAL2/PciDevice.cs b/source/Cosmos.HAL2/PciDevice.cs index 6419beceb..7d6d372ad 100644 --- a/source/Cosmos.HAL2/PciDevice.cs +++ b/source/Cosmos.HAL2/PciDevice.cs @@ -107,8 +107,14 @@ namespace Cosmos.HAL HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType); BIST = (PCIBist)ReadRegister8((byte)Config.BIST); InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN); - - DeviceExists = (uint)VendorID != 0xFFFF && (uint)DeviceID != 0xFFFF; + if ((uint)VendorID == 0xFF && (uint)DeviceID == 0xFFFF) + { + DeviceExists = false; + } + else + { + DeviceExists = true; + } if (HeaderType == PCIHeaderType.Normal) { BaseAddressBar = new PCIBaseAddressBar[6]; diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 0b36e1926..18ec3928b 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -15,7 +15,23 @@ namespace Cosmos.System.Graphics private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter); - private static bool SVGAIIExists = SVGAIIDevice.DeviceExists; + public static bool DoesSVGAIIExist() + { + if (SVGAIIDevice != null) + { + if (SVGAIIDevice.DeviceExists == true) + { + return true; + } + return false; + } + else + { + return false; + } + + } + //public static bool SVGAIIExists = SVGAIIDevice != null; private static VideoDriver videoDevice; @@ -50,12 +66,12 @@ namespace Cosmos.System.Graphics } public static Canvas GetFullScreenCanvas(Mode mode) { - Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode"); + Global.mDebugger.SendInternal($"GetFullScreenCanvas() with mode" + mode); // If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), // Do necessary check and set gfx mode as specified (mode) if (MyVideoDriver == null) { - if (SVGAIIExists) + if (DoesSVGAIIExist()) { // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. From a7c2d5fefb583c6ad53cc8c13e454b605570db1b Mon Sep 17 00:00:00 2001 From: Arawn Davies Date: Sun, 25 Feb 2018 14:43:12 +0000 Subject: [PATCH 34/37] Changes --- .gitignore | 1 + .../CosmosGraphicSubsystem.csproj | 3 +- Demos/CosmosGraphicSubsystem/Kernel.cs | 10 +- Kernel.sln | 14 -- source/Cosmos.System2/Graphics/Canvas.cs | 2 +- .../Graphics/FullScreenCanvas.cs | 127 ++++++++++++------ .../Cosmos.System2/Graphics/SVGAIIScreen.cs | 2 +- source/Cosmos.System2/Graphics/VBEScreen.cs | 2 +- 8 files changed, 99 insertions(+), 62 deletions(-) diff --git a/.gitignore b/.gitignore index a2b71da68..b149e8e43 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ source/_ReSharper.Caches/ Docs/~$RingsGen2.xlsx source/Kernel-X86/90-Application/GuessKernelGen3.csproj Docs/~$RingsGen3.xlsx +*.map diff --git a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj index d57ca8c04..2fb265c37 100644 --- a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj +++ b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj @@ -3,6 +3,7 @@ netstandard2.0 CosmosGraphicSubsystemBoot + CosmosGraphicSubsystemBoot @@ -41,7 +42,7 @@ Use Bochs emulator to deploy and debug. ISO Bochs - True + False Source False Serial: COM1 diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index c23251ab6..5efa754c9 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -14,13 +14,13 @@ namespace Cosmos_Graphic_Subsytem protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - Console.WriteLine("Specifying custom graphics mode as 800x600@32"); - // Specify custom graphics mode (800x600 @ 16) - Mode start = new Mode(800, 600, ColorDepth.ColorDepth32); + Console.WriteLine("Using default graphics mode"); + //Mode start = new Mode(800, 600, ColorDepth.ColorDepth32); Console.WriteLine("Here we go!"); - // Create new instance of FullScreenCanvas, specifying graphics mode - canvas = FullScreenCanvas.GetFullScreenCanvas(start); + Console.ReadKey(true); + // Create new instance of FullScreenCanvas, using default graphics mode + canvas = FullScreenCanvas.GetFullScreenCanvas(); // canvas = GetFullScreenCanvas(start); /* Clear the Screen with the color 'Blue' */ diff --git a/Kernel.sln b/Kernel.sln index 7fec20689..7f506d1f8 100644 --- a/Kernel.sln +++ b/Kernel.sln @@ -94,10 +94,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{7370A62F-12DA-4181-BE3B-009D0926CA7E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PCITest", "PCITest", "{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCITest", "Demos\PCITest\PCITest.csproj", "{D3639BE5-49A0-4163-9174-1D0CC6823E06}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -339,14 +335,6 @@ Global {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|Any CPU.Build.0 = Release|Any CPU {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.ActiveCfg = Release|Any CPU {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.Build.0 = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.ActiveCfg = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.Build.0 = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.Build.0 = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.ActiveCfg = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -392,8 +380,6 @@ Global {E35E0DBF-555F-4D38-8F28-ACDFA9DC97BD} = {5FF9BF2A-5162-4F12-82B6-1693AD776636} {0812DD0A-4CEE-4376-B78A-02EBCBAA14C2} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} {7370A62F-12DA-4181-BE3B-009D0926CA7E} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} - {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} = {B56A6119-1B8F-44E4-9446-291E52F47D4C} - {D3639BE5-49A0-4163-9174-1D0CC6823E06} = {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1A1E8F1D-82B3-471F-9B59-0350DEA9203D} diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs index 4163d4bec..004027853 100644 --- a/source/Cosmos.System2/Graphics/Canvas.cs +++ b/source/Cosmos.System2/Graphics/Canvas.cs @@ -249,13 +249,13 @@ namespace Cosmos.System.Graphics } } + // public virtual void DrawCircle(Pen pen, Point point, int radius) { DrawCircle(pen, point.X, point.Y, radius); } - //http://members.chello.at/~easyfilter/bresenham.html public virtual void DrawEllipse(Pen pen, int x_center, int y_center, int x_radius, int y_radius) { diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 18ec3928b..c0558d655 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -15,7 +15,7 @@ namespace Cosmos.System.Graphics private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter); - public static bool DoesSVGAIIExist() + public static bool SVGAIIExist() { if (SVGAIIDevice != null) { @@ -31,38 +31,44 @@ namespace Cosmos.System.Graphics } } - //public static bool SVGAIIExists = SVGAIIDevice != null; - private static VideoDriver videoDevice; - // Created null - NullReferenceException when calling GetFullScreenCanvas() with 0 overloads private static Canvas MyVideoDriver = null; + private static Canvas GetVideoDriver() + { + if (SVGAIIExist()) + { + return new SVGAIIScreen(); + } + else + { + return new VBEScreen(); + } + } + private static Canvas GetVideoDriver(Mode mode) + { + if (SVGAIIExist()) + { + return new SVGAIIScreen(mode); + } + else + { + return new VBEScreen(mode); + } + } + public static Canvas GetFullScreenCanvas() { - // If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), - // Do necessary check and set to default gfx mode if (MyVideoDriver == null) { - return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode); + return MyVideoDriver = GetVideoDriver(); } - // If it's not null, simply change graphics mode */ else { MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; return MyVideoDriver; } - // Old check left for reference - /* - if (videoDevice == VideoDriver.VMWareSVGAIIDriver) - { - - } - else - { - - } - */ } public static Canvas GetFullScreenCanvas(Mode mode) { @@ -71,32 +77,75 @@ namespace Cosmos.System.Graphics // Do necessary check and set gfx mode as specified (mode) if (MyVideoDriver == null) { - if (DoesSVGAIIExist()) - { - // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode - // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. - // returns MyVideoDriver as the Canvas - videoDevice = VideoDriver.VMWareSVGAIIDriver; - MyVideoDriver = new SVGAIIScreen(mode); - MyVideoDriver.Mode = mode; - return MyVideoDriver; - } - else - { - // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) - videoDevice = VideoDriver.VBEDriver; - MyVideoDriver = new VBEScreen(mode); - MyVideoDriver.Mode = mode; - return MyVideoDriver; - } + return MyVideoDriver = GetVideoDriver(mode); } else { - // If MyVideoDriver has been initialized before (Graphics mode has previously been set) - // Change the graphics mode to the mode specified MyVideoDriver.Mode = mode; return MyVideoDriver; } } } } +/* + if (DoesSVGAIIExist()) + { + // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode + // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. + // returns MyVideoDriver as the Canvas + videoDevice = VideoDriver.VMWareSVGAIIDriver; + MyVideoDriver = new SVGAIIScreen(mode); + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } + else + { + // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) + videoDevice = VideoDriver.VBEDriver; + MyVideoDriver = new VBEScreen(mode); + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } +} +else +{ + // If MyVideoDriver has been initialized before (Graphics mode has previously been set) + // Change the graphics mode to the mode specified + MyVideoDriver.Mode = mode; + return MyVideoDriver; +} +} +/* + +// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), +// Do necessary check and set to default gfx mode +if (MyVideoDriver == null) +{ +if (DoesSVGAIIExist()) +{ + // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode + // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. + // returns MyVideoDriver as the Canvas + videoDevice = VideoDriver.VMWareSVGAIIDriver; + MyVideoDriver = new SVGAIIScreen(SVGAIIScreen.defaultGraphicsMode); + MyVideoDriver.Mode = SVGAIIScreen.defaultGraphicsMode; + return MyVideoDriver; +} +else +{ + // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) + videoDevice = VideoDriver.VBEDriver; + MyVideoDriver = new VBEScreen(VBEScreen.defaultGraphicsMode); + MyVideoDriver.Mode = VBEScreen.defaultGraphicsMode; + return MyVideoDriver; +} +} +// If it's not null, simply change graphics mode +else +{ +MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; +return MyVideoDriver; +} +*/ + + diff --git a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs index fe9393890..c8f5b5d92 100644 --- a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs +++ b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs @@ -140,7 +140,7 @@ namespace Cosmos.System.Graphics new Mode(3840, 2400, ColorDepth.ColorDepth32), // WQUXGA }; } - + public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth16); protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth16); private void SetGraphicsMode(Mode aMode) diff --git a/source/Cosmos.System2/Graphics/VBEScreen.cs b/source/Cosmos.System2/Graphics/VBEScreen.cs index 2e129f981..ec3510806 100644 --- a/source/Cosmos.System2/Graphics/VBEScreen.cs +++ b/source/Cosmos.System2/Graphics/VBEScreen.cs @@ -75,7 +75,7 @@ namespace Cosmos.System.Graphics } protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth32); - + public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth32); /// /// Use this to setup the screen, this will disable the console. /// From fc7771494e5266422cf6f62d4da82be8ac52ef0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Sun, 25 Feb 2018 21:23:32 +0000 Subject: [PATCH 35/37] Updated appveyor.yml. --- appveyor.yml | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6c74fd4b2..2fa476d8e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,61 +11,41 @@ init: git clone https://github.com/CosmosOS/IL2CPU.git c:\IL2CPU --depth 1 build_script: -- cmd: >- +- cmd: | rem %APPVEYOR_BUILD_FOLDER% Build\Tools\nuget restore "Builder.sln" - Build\Tools\nuget restore "..\XSharp\XSharp.sln" - Build\Tools\nuget restore "..\IL2CPU\IL2CPU.sln" - Build\Tools\nuget restore "Build.sln" - Build\Tools\nuget restore "Test.sln" - msbuild "Builder.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug /p:DeployExtension=false + msbuild "Builder.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug msbuild "Build.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug /p:OutputPath="%APPVEYOR_BUILD_FOLDER%\Build\VSIP" /p:DeployExtension=false - msbuild "Test.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug - dotnet publish source\Cosmos.Build.MSBuild -r win7-x86 -o "c:\CosmosRun\Build\VSIP\" - dotnet publish ..\IL2CPU\source\IL2CPU -r win7-x86 -o "c:\CosmosRun\Build\IL2CPU\" xcopy /Y "Build\VSIP\Cosmos.Debug.Kernel.*" "c:\CosmosRun\Kernel\" - xcopy /Y "Build\VSIP\Cosmos.Core.*" "c:\CosmosRun\Kernel\" - xcopy /Y "Build\VSIP\Cosmos.HAL.*" "c:\CosmosRun\Kernel\" - xcopy /Y "Build\VSIP\Cosmos.System.*" "c:\CosmosRun\Kernel\" - xcopy /Y "Build\VSIP\Cosmos.Common.*" "c:\CosmosRun\Kernel\" - xcopy /Y "Build\VSIP\Cosmos.Debug.GDB.exe" "c:\CosmosRun\Build\VSIP\" - xcopy /Y "Build\syslinux\*.*" "c:\CosmosRun\Build\ISO\" - xcopy /Y /S "Build\VMware\*" "c:\CosmosRun\Build\VMware\" - xcopy /Y /S "Build\Tools" "c:\CosmosRun\Build\Tools\" - xcopy /Y "source\Cosmos.Core.DebugStub\*.xs" "c:\CosmosRun\XSharp\DebugStub\" - xcopy /Y /S "Resources\Bochs\*.*" "%ProgramFiles(x86)%\Bochs-2.6.8\" - reg add HKLM\SOFTWARE\WOW6432Node\Cosmos /v UserKit /d c:\CosmosRun\ - reg add HKCR\BochsConfigFile\shell\Run\command /ve /d "\"C:\Program Files (x86)\Bochs-2.6.8\Bochs.exe\" -q -f \"%1\"" - #test: off # assemblies: # - Cosmos.Core.Memory.Test.dll From 5e51301d5cb2db630b094e8743d894bb25546c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Mon, 26 Feb 2018 00:22:06 +0000 Subject: [PATCH 36/37] Added tests for Convert. Added back plugs for Decimal. Plugged Int32.ToString(IFormatProvider). --- Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs | 1 + .../System/ConvertTests.cs | 29 +++++++++++++++++++ .../System}/DecimalImpl.cs | 8 ++--- .../Cosmos.System2_Plugs/System/Int32Impl.cs | 4 +-- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs rename source/{Archive/Old System Plugs => Cosmos.System2_Plugs/System}/DecimalImpl.cs (70%) diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs b/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs index 8bb114a44..11509f711 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs @@ -45,6 +45,7 @@ namespace Cosmos.Compiler.Tests.Bcl SingleTest.Execute(); DoubleTest.Execute(); MathTest.Execute(); + ConvertTests.Execute(); //mDebugger.Send("Thread test start of 500 ms"); //ThreadTest.Execute(); diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs new file mode 100644 index 000000000..656c30f79 --- /dev/null +++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs @@ -0,0 +1,29 @@ +using System; + +using Cosmos.TestRunner; + +namespace Cosmos.Compiler.Tests.Bcl.System +{ + internal static class ConvertTests + { + public static void Execute() + { + var number = 5; + var numberToString = Convert.ToString(number); + + Assert.IsTrue(numberToString == "5", $"Convert.ToString(Int32) doesn't work. Result: {numberToString}"); + + var numberToByte = Convert.ToByte(number); + + Assert.IsTrue(numberToByte == 5, $"Convert.ToByte(Int32) doesn't work. Result: {numberToByte}"); + + var byteToSingle = Convert.ToSingle(numberToByte); + + Assert.IsTrue(EqualityHelper.SinglesAreEqual(byteToSingle, 5.0f), $"Convert.ToSingle(Byte) doesn't work. Result: {byteToSingle}"); + + var numberToBase64 = Convert.ToBase64String(BitConverter.GetBytes(number)); + + Assert.IsTrue(numberToBase64 == "BQAAAA==", $"Convert.ToBase64String(byte[]) doesn't work. Result: {numberToBase64}"); + } + } +} diff --git a/source/Archive/Old System Plugs/DecimalImpl.cs b/source/Cosmos.System2_Plugs/System/DecimalImpl.cs similarity index 70% rename from source/Archive/Old System Plugs/DecimalImpl.cs rename to source/Cosmos.System2_Plugs/System/DecimalImpl.cs index 434744b46..9b452bed6 100644 --- a/source/Archive/Old System Plugs/DecimalImpl.cs +++ b/source/Cosmos.System2_Plugs/System/DecimalImpl.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Cosmos.IL2CPU.Plugs; +using IL2CPU.API.Attribs; -namespace Cosmos.System.Plugs.System +namespace Cosmos.System_Plugs.System { [Plug(Target = typeof(decimal))] public static class DecimalImpl diff --git a/source/Cosmos.System2_Plugs/System/Int32Impl.cs b/source/Cosmos.System2_Plugs/System/Int32Impl.cs index 76d855515..be131cba9 100644 --- a/source/Cosmos.System2_Plugs/System/Int32Impl.cs +++ b/source/Cosmos.System2_Plugs/System/Int32Impl.cs @@ -1,7 +1,5 @@ using System; using Cosmos.Common; -using Cosmos.Debug.Kernel; -using IL2CPU.API; using IL2CPU.API.Attribs; namespace Cosmos.System_Plugs.System @@ -14,6 +12,8 @@ namespace Cosmos.System_Plugs.System return StringHelper.GetNumberString(aThis); } + public static string ToString(ref int aThis, IFormatProvider aFormatProvider) => ToString(ref aThis); + public static Int32 Parse(string s) { const string digits = "0123456789"; From bb95229fbf24486057549f6c0e95cead4c38c824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Mon, 26 Feb 2018 14:28:43 +0000 Subject: [PATCH 37/37] Fixed build tasks logging importance. --- source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs | 3 +++ source/Cosmos.Build.Tasks/Ld.cs | 2 ++ source/Cosmos.Build.Tasks/MakeIso.cs | 2 ++ source/Cosmos.Build.Tasks/Nasm.cs | 3 +++ source/Cosmos.Build.Tasks/TheRingMaster.cs | 3 +++ 5 files changed, 13 insertions(+) diff --git a/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs b/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs index c90c64e28..aaa2195aa 100644 --- a/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs +++ b/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs @@ -20,6 +20,9 @@ namespace Cosmos.Build.Tasks protected override string ToolName => "objdump.exe"; + protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High; + protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; + protected override bool ValidateParameters() { if (!File.Exists(InputFile)) diff --git a/source/Cosmos.Build.Tasks/Ld.cs b/source/Cosmos.Build.Tasks/Ld.cs index 8287c22ac..6a5632bc3 100644 --- a/source/Cosmos.Build.Tasks/Ld.cs +++ b/source/Cosmos.Build.Tasks/Ld.cs @@ -28,7 +28,9 @@ namespace Cosmos.Build.Tasks #endregion protected override string ToolName => "ld.exe"; + protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High; + protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; private static bool IsValidAddress(string aAddress) { diff --git a/source/Cosmos.Build.Tasks/MakeIso.cs b/source/Cosmos.Build.Tasks/MakeIso.cs index 3b0b5eaa5..5b565c120 100644 --- a/source/Cosmos.Build.Tasks/MakeIso.cs +++ b/source/Cosmos.Build.Tasks/MakeIso.cs @@ -14,7 +14,9 @@ namespace Cosmos.Build.Tasks public string OutputFile { get; set; } protected override string ToolName => "mkisofs.exe"; + protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High; + protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; protected override bool ValidateParameters() { diff --git a/source/Cosmos.Build.Tasks/Nasm.cs b/source/Cosmos.Build.Tasks/Nasm.cs index e35776a2d..5421ee40e 100644 --- a/source/Cosmos.Build.Tasks/Nasm.cs +++ b/source/Cosmos.Build.Tasks/Nasm.cs @@ -34,6 +34,9 @@ namespace Cosmos.Build.Tasks protected override string ToolName => "nasm.exe"; + protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High; + protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; + protected override bool ValidateParameters() { if (String.IsNullOrWhiteSpace(InputFile)) diff --git a/source/Cosmos.Build.Tasks/TheRingMaster.cs b/source/Cosmos.Build.Tasks/TheRingMaster.cs index dac363f11..a575a31ca 100644 --- a/source/Cosmos.Build.Tasks/TheRingMaster.cs +++ b/source/Cosmos.Build.Tasks/TheRingMaster.cs @@ -12,6 +12,9 @@ namespace Cosmos.Build.Tasks protected override string ToolName => "TheRingMaster.exe"; + protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High; + protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High; + protected override bool ValidateParameters() { if (!File.Exists(KernelAssemblyPath))